0022750: [EDF] Improve ergonomics of the "Detect Self-intersections" dialog box

This commit is contained in:
skv 2014-10-13 12:14:17 +04:00 committed by vsr
parent 568f30b167
commit dff9617e4b
11 changed files with 605 additions and 106 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -8,9 +8,16 @@ This operation checks the topology of the selected shape to detect self-intersec
In this dialog:
- \b Object - the checked object. \b Selection button allows picking it in the viewer or in the object browser.
- \b Errors list contains the list of intersections. Select the intersection to show <b>Incriminated Sub-shapes</b> in the field to the right.
- \b Object - the checked object. \b Selection button allows picking it in the viewer or in the object browser.
- <b>Level of check</b> - The combo box that allows to set the level of checking shape on self-interference.
It defines which interferferences will be checked. Default value is "All interferences".
- <b>Compute self-intersections</b> button computes self-interferences.
- \b Summary section contains the general report if the object has self-intersections and/or if errors are occured during computation.
- \b Self-intersections list contains the list of self-intersections detected.
Select the intersection to show <b>Sub-shapes</b> in the field to the right.
- \b Apply and <b>Apply and Close</b> buttons are used to store selected self-intersected shapes in the study for further analysis.
If no shapes are selected, but an intersection is selected the both of intersected shapes are stored. If no intersections selected
all shapes of all intersections are stored in the study.
\note This tool is useful for detection of shapes, not suitable for
arguments of Boolean operations and Partition algorithm.
@ -18,8 +25,10 @@ For more information about Partition and Boolean Operations Algorithms
and their limitations refer to <a href="SALOME_BOA_PA.pdf">this document</a>.
\n <b>Result:</b> Boolean.
\n <b>TUI Command:</b> <em>geompy.CheckSelfIntersections(theShape),</em>
where \em theShape is the shape checked for validity.
\n <b>TUI Command:</b> <em>geompy.CheckSelfIntersections(theShape, theCheckLevel = GEOM.SI_ALL),</em> \n
where: \n
\em theShape is the shape checked for validity. \n
\em theCheckLevel is the level of check. Default value is GEOM.SI_ALL to check all interferences.
See also a \ref tui_check_self_intersections_page "TUI example".

View File

@ -188,6 +188,20 @@ module GEOM
FDT_String
};
/**
* This enumeration represents the level of checking shape on
* self-interference. It defines which interferferences will be checked.
*/
enum si_check_level
{
SI_V_V, // only V/V interferences
SI_V_E, // V/V and V/E interferences
SI_E_E, // V/V, V/E and E/E interferences
SI_V_F, // V/V, V/E, E/E and V/F interferences
SI_E_F, // V/V, V/E, E/E, V/F and E/F interferences
SI_ALL // all interferences
};
/*!
* \brief Object creation parameters
@ -4148,10 +4162,12 @@ module GEOM
/*!
* \brief Check a topology of the given shape on self-intersections presence.
* \param theShape Shape to check validity of.
* \param theCheckLevel the level of self-interference check.
* \param theIntersections Output. List of intersected sub-shapes IDs, it contains pairs of IDs.
* \return TRUE, if the shape does not have any self-intersections.
*/
boolean CheckSelfIntersections (in GEOM_Object theShape,
in long theCheckLevel,
out ListOfLong theIntersections);
/*!

View File

@ -415,22 +415,6 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation>
</message>
<message>
<source>GEOM_CHECK_SELF_INTERSECTIONS_FAILED</source>
<translation>Detection of self-intersections failed</translation>
</message>
<message>
<source>GEOM_NO_SELF_INTERSECTIONS</source>
<translation>There are no self-intersections in the shape</translation>
</message>
<message>
<source>GEOM_SELF_INTERSECTIONS_FOUND</source>
<translation>Some self-intersections detected</translation>
</message>
<message>
<source>GEOM_CHECK_SELF_INTERSECTIONS_ERRORS</source>
<translation>Warning: there were errors during the operation, so the list may be incomplete.</translation>
</message>
<message>
<source>GEOM_CIRCLE</source>
<translation>Circle</translation>
@ -6927,4 +6911,71 @@ Do you want to create new material?</translation>
<translation>V-Isoline</translation>
</message>
</context>
<context>
<name>MeasureGUI_CheckSelfIntersectionsDlg</name>
<message>
<source>GEOM_CHECK_INTE_INTERSECTIONS</source>
<translation>Self-intersections</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_SUBSHAPES</source>
<translation>Sub-shapes</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_CHECK_LEVEL</source>
<translation>Level of check</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_SUMMARY</source>
<translation>Summary</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_COMPUTE</source>
<translation>Compute self-intersections</translation>
</message>
<message>
<source>GEOM_SELF_INTERSECTION_NAME</source>
<translation>Self_intersection</translation>
</message>
<message>
<source>GEOM_NO_SELF_INTERSECTIONS</source>
<translation>There are no self-intersections in the shape</translation>
</message>
<message>
<source>GEOM_SELF_INTERSECTIONS_FOUND</source>
<translation>Some self-intersections detected</translation>
</message>
<message>
<source>GEOM_CHECK_SELF_INTERSECTIONS_FAILED</source>
<translation>Detection of self-intersections failed</translation>
</message>
<message>
<source>GEOM_CHECK_SELF_INTERSECTIONS_ERRORS</source>
<translation>Warning: there were errors during the operation, so the list may be incomplete.</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_V_V</source>
<translation>Vertex to Vertex</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_V_E</source>
<translation>Vertex to Edge + all above</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_E_E</source>
<translation>Edge to Edge + all above</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_V_F</source>
<translation>Vertex to Face + all above</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_E_F</source>
<translation>Edge to Face + all above</translation>
</message>
<message>
<source>GEOM_CHECK_INTE_ALL</source>
<translation>All interferences</translation>
</message>
</context>
</TS>

View File

@ -1501,6 +1501,7 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::PrintShapeErrors
//=============================================================================
bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
(Handle(GEOM_Object) theShape,
const SICheckLevel theCheckLevel,
Handle(TColStd_HSequenceOfInteger)& theIntersections)
{
SetErrorCode(KO);
@ -1534,6 +1535,7 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
//
BOPAlgo_CheckerSI aCSI; // checker of self-interferences
aCSI.SetArguments(aLCS);
aCSI.SetLevelOfCheck(theCheckLevel);
// 1. Launch the checker
aCSI.Perform();

View File

@ -85,6 +85,20 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
SK_ADVANCED, // all advanced shapes (temporary implementation)
};
/**
* This enumeration represents the level of checking shape on
* self-interference. It defines which interferferences will be checked.
*/
enum SICheckLevel
{
SI_V_V = 0, // only V/V interferences
SI_V_E, // V/V and V/E interferences
SI_E_E, // V/V, V/E and E/E interferences
SI_V_F, // V/V, V/E, E/E and V/F interferences
SI_E_F, // V/V, V/E, E/E, V/F and E/F interferences
SI_ALL // all interferences
};
Standard_EXPORT ShapeKind KindOfShape (Handle(GEOM_Object) theShape,
Handle(TColStd_HSequenceOfInteger)& theIntegers,
Handle(TColStd_HSequenceOfReal)& theDoubles);
@ -141,6 +155,7 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
const std::list<ShapeError> &theErrors);
Standard_EXPORT bool CheckSelfIntersections (Handle(GEOM_Object) theShape,
const SICheckLevel theCheckLevel,
Handle(TColStd_HSequenceOfInteger)& theIntersections);
Standard_EXPORT TCollection_AsciiString IsGoodForSolid (Handle(GEOM_Object) theShape);

View File

@ -706,6 +706,7 @@ char* GEOM_IMeasureOperations_i::PrintShapeErrors
*/
//=============================================================================
CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
CORBA::Long theCheckLevel,
GEOM::ListOfLong_out theIntersections)
{
// Set a not done flag
@ -720,10 +721,35 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Obj
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
if (!aShape.IsNull()) {
GEOMImpl_IMeasureOperations::SICheckLevel aCheckLevel;
switch(theCheckLevel) {
case GEOM::SI_V_V:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_V;
break;
case GEOM::SI_V_E:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_E;
break;
case GEOM::SI_E_E:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_E;
break;
case GEOM::SI_V_F:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_F;
break;
case GEOM::SI_E_F:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_F;
break;
case GEOM::SI_ALL:
default:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_ALL;
break;
}
Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
// Detect self-intersections
isGood = GetOperations()->CheckSelfIntersections(aShape, anIntegers);
isGood = GetOperations()->CheckSelfIntersections
(aShape, aCheckLevel, anIntegers);
int nbInts = anIntegers->Length();

View File

@ -97,6 +97,7 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors);
CORBA::Boolean CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
CORBA::Long theCheckLevel,
GEOM::ListOfLong_out theIntersections);
char* IsGoodForSolid (GEOM::GEOM_Object_ptr theShape);

View File

@ -10588,22 +10588,38 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
## Detect self-intersections in the given shape.
# @param theShape Shape to check.
# @param theCheckLevel is the level of self-intersection check.
# Possible input values are:
# - GEOM.SI_V_V(0) - only V/V interferences
# - GEOM.SI_V_E(1) - V/V and V/E interferences
# - GEOM.SI_E_E(2) - V/V, V/E and E/E interferences
# - GEOM.SI_V_F(3) - V/V, V/E, E/E and V/F interferences
# - GEOM.SI_E_F(4) - V/V, V/E, E/E, V/F and E/F interferences
# - GEOM.SI_ALL(5) - all interferences.
# @return TRUE, if the shape contains no self-intersections.
#
# @ref tui_measurement_tools_page "Example"
@ManageTransactions("MeasuOp")
def CheckSelfIntersections(self, theShape):
def CheckSelfIntersections(self, theShape, theCheckLevel = GEOM.SI_ALL):
"""
Detect self-intersections in the given shape.
Parameters:
theShape Shape to check.
theCheckLevel is the level of self-intersection check.
Possible input values are:
- GEOM.SI_V_V(0) - only V/V interferences
- GEOM.SI_V_E(1) - V/V and V/E interferences
- GEOM.SI_E_E(2) - V/V, V/E and E/E interferences
- GEOM.SI_V_F(3) - V/V, V/E, E/E and V/F interferences
- GEOM.SI_E_F(4) - V/V, V/E, E/E, V/F and E/F interferences
- GEOM.SI_ALL(5) - all interferences.
Returns:
TRUE, if the shape contains no self-intersections.
"""
# Example: see GEOM_TestMeasures.py
(IsValid, Pairs) = self.MeasuOp.CheckSelfIntersections(theShape)
(IsValid, Pairs) = self.MeasuOp.CheckSelfIntersections(theShape, EnumToLong(theCheckLevel))
RaiseIfFailed("CheckSelfIntersections", self.MeasuOp)
return IsValid

View File

@ -24,8 +24,9 @@
// File : MeasureGUI_CheckSelfIntersectionsDlg.cxx
#include "MeasureGUI_CheckSelfIntersectionsDlg.h"
#include "MeasureGUI_Widgets.h"
#include "MeasureGUI.h"
#include <SUIT_OverrideCursor.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <LightApp_SelectionMgr.h>
@ -34,6 +35,7 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <DlgRef.h>
@ -41,6 +43,8 @@
#include <GEOMBase.h>
#include <GEOMImpl_Types.hxx>
#include <QListWidget>
#define TEXTEDIT_FONT_FAMILY "Courier"
#define TEXTEDIT_FONT_SIZE 11
@ -52,7 +56,14 @@
// true to construct a modal dialog.
//=================================================================================
MeasureGUI_CheckSelfIntersectionsDlg::MeasureGUI_CheckSelfIntersectionsDlg (GeometryGUI* GUI, QWidget* parent)
: MeasureGUI_Skeleton(GUI, parent, false)
: GEOMBase_Skeleton (GUI, parent, false),
myTextView (0),
mySelButton (0),
myEditObjName (0),
myLevelBox (0),
myComputeButton (0),
myInteList (0),
myShapeList (0)
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHECK_SELF_INTERSECTIONS")));
@ -63,27 +74,60 @@ MeasureGUI_CheckSelfIntersectionsDlg::MeasureGUI_CheckSelfIntersectionsDlg (Geom
/***************************************************************/
mainFrame()->GroupConstructors->setTitle(tr("GEOM_CHECK_SELF_INTERSECTIONS"));
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close();
myGrp = new MeasureGUI_1Sel1TextView2ListBox (centralWidget());
myGrp->GroupBox1->setTitle(tr("GEOM_CHECK_INFOS"));
myGrp->TextLabel1->setText(tr("GEOM_OBJECT"));
QGroupBox *aGrp = new QGroupBox(tr("GEOM_CHECK_INFOS"));
QLabel *anObjLbl = new QLabel(tr("GEOM_OBJECT"));
QLabel *anInteLbl = new QLabel(tr("GEOM_CHECK_INTE_INTERSECTIONS"));
QLabel *aShapeLbl = new QLabel(tr("GEOM_CHECK_INTE_SUBSHAPES"));
QLabel *aLevelLbl = new QLabel(tr("GEOM_CHECK_INTE_CHECK_LEVEL"));
QLabel *aSummaryLbl = new QLabel(tr("GEOM_CHECK_INTE_SUMMARY"));
QFont aFont (TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE);
myGrp->TextView1->setReadOnly(true);
QFont aFont (TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE);
aFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias);
myGrp->TextView1->setFont(aFont);
myTextView = new QTextBrowser;
myTextView->setReadOnly(true);
myTextView->setFont(aFont);
myGrp->PushButton1->setIcon(image1);
myGrp->LineEdit1->setReadOnly(true);
mySelButton = new QPushButton;
mySelButton->setIcon(image1);
mySelButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
myGrp->TextLabel2->setText(tr("GEOM_CHECK_BLOCKS_COMPOUND_ERRORS"));
myGrp->TextLabel3->setText(tr("GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES"));
myEditObjName = new QLineEdit;
myEditObjName->setReadOnly(true);
myGrp->ListBox2->setSelectionMode(QAbstractItemView::ExtendedSelection);
myLevelBox = new QComboBox;
myComputeButton = new QPushButton(tr("GEOM_CHECK_INTE_COMPUTE"));
myInteList = new QListWidget;
myShapeList = new QListWidget;
myShapeList->setSelectionMode(QAbstractItemView::ExtendedSelection);
QGridLayout *aGrpLayout = new QGridLayout(aGrp);
aGrpLayout->setMargin(9);
aGrpLayout->setSpacing(6);
aGrpLayout->addWidget(anObjLbl, 0, 0);
aGrpLayout->addWidget(anInteLbl, 5, 0);
aGrpLayout->addWidget(aShapeLbl, 5, 2);
aGrpLayout->addWidget(aLevelLbl, 1, 0);
aGrpLayout->addWidget(myLevelBox, 1, 1, 1, 2);
aGrpLayout->addWidget(myComputeButton, 2, 0, 1, 3);
aGrpLayout->addWidget(aSummaryLbl, 3, 0);
aGrpLayout->addWidget(myTextView, 4, 0, 1, 3);
aGrpLayout->addWidget(mySelButton, 0, 1);
aGrpLayout->addWidget(myEditObjName, 0, 2);
aGrpLayout->addWidget(myInteList, 6, 0, 1, 2);
aGrpLayout->addWidget(myShapeList, 6, 2);
QVBoxLayout* layout = new QVBoxLayout (centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(myGrp);
layout->addWidget(aGrp);
/***************************************************************/
@ -107,94 +151,302 @@ MeasureGUI_CheckSelfIntersectionsDlg::~MeasureGUI_CheckSelfIntersectionsDlg()
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::Init()
{
mySelBtn = myGrp->PushButton1;
mySelEdit = myGrp->LineEdit1;
MeasureGUI_Skeleton::Init();
// Fill in the combo box.
myLevelBox->insertItem(GEOM::SI_V_V, tr("GEOM_CHECK_INTE_V_V"));
myLevelBox->insertItem(GEOM::SI_V_E, tr("GEOM_CHECK_INTE_V_E"));
myLevelBox->insertItem(GEOM::SI_E_E, tr("GEOM_CHECK_INTE_E_E"));
myLevelBox->insertItem(GEOM::SI_V_F, tr("GEOM_CHECK_INTE_V_F"));
myLevelBox->insertItem(GEOM::SI_E_F, tr("GEOM_CHECK_INTE_E_F"));
myLevelBox->insertItem(GEOM::SI_ALL, tr("GEOM_CHECK_INTE_ALL"));
myLevelBox->setCurrentIndex(GEOM::SI_ALL);
connect(myGrp->ListBox1, SIGNAL(itemSelectionChanged()), SLOT(onErrorsListSelectionChanged()));
connect(myGrp->ListBox2, SIGNAL(itemSelectionChanged()), SLOT(onSubShapesListSelectionChanged()));
connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()),
this, SLOT(DeactivateActiveDialog()));
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()),
this, SLOT(ClickOnCancel()));
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(mySelButton, SIGNAL(clicked()),
this, SLOT(SetEditCurrentArgument()));
connect(myInteList, SIGNAL(itemSelectionChanged()),
SLOT(onInteListSelectionChanged()));
connect(myShapeList, SIGNAL(itemSelectionChanged()),
SLOT(onSubShapesListSelectionChanged()));
connect(myLevelBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(clear()));
connect(myComputeButton, SIGNAL(clicked()), this, SLOT(onCompute()));
LightApp_SelectionMgr* aSel = myGeomGUI->getApp()->selectionMgr();
connect(aSel, SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
initName( tr( "GEOM_SELF_INTERSECTION_NAME") );
buttonOk()->setEnabled(false);
buttonApply()->setEnabled(false);
myComputeButton->setEnabled(false);
activateSelection();
SelectionIntoArgument();
}
//=================================================================================
// function : processObject
// function : clear
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::processObject()
void MeasureGUI_CheckSelfIntersectionsDlg::clear()
{
myGrp->ListBox1->clear();
myGrp->ListBox2->clear();
myTextView->setText("");
disconnect(myInteList, SIGNAL(itemSelectionChanged()), this, 0);
disconnect(myShapeList, SIGNAL(itemSelectionChanged()), this, 0);
myInteList->clear();
myShapeList->clear();
connect(myInteList, SIGNAL(itemSelectionChanged()),
SLOT(onInteListSelectionChanged()));
connect(myShapeList, SIGNAL(itemSelectionChanged()),
SLOT(onSubShapesListSelectionChanged()));
erasePreview();
buttonOk()->setEnabled(false);
buttonApply()->setEnabled(false);
myComputeButton->setEnabled(true);
}
if (myObj->_is_nil())
//=================================================================================
// function : onCompute
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::onCompute()
{
bool hasSelfInte = false;
QString anErrMsg("");
if (!findSelfIntersections(hasSelfInte, anErrMsg)) {
myTextView->setText(anErrMsg);
return;
}
// Status and apply buttons
QString aMsg("");
if (hasSelfInte) {
aMsg += tr("GEOM_SELF_INTERSECTIONS_FOUND");
buttonOk()->setEnabled(true);
buttonApply()->setEnabled(true);
} else {
aMsg += tr("GEOM_NO_SELF_INTERSECTIONS");
}
if (!anErrMsg.isEmpty()) {
aMsg += "\n\n";
aMsg += anErrMsg;
}
myTextView->setText(aMsg);
// Pairs
QStringList anInteList;
QString anInteStr ("");
int nbPairs = myInters->length()/2;
for (int i = 1; i <= nbPairs; i++) {
anInteStr = "Intersection # ";
anInteStr += QString::number(i);
anInteList.append(anInteStr);
}
myInteList->addItems(anInteList);
myComputeButton->setEnabled(false);
}
//=================================================================================
// function : ActivateThisDialog
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
LightApp_SelectionMgr* aSel = myGeomGUI->getApp()->selectionMgr();
if ( aSel )
connect( aSel, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
activateSelection();
DISPLAY_PREVIEW_MACRO
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::DeactivateActiveDialog()
{
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : activateSelection
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::activateSelection()
{
globalSelection(GEOM_ALLSHAPES);
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::ClickOnOk()
{
if ( ClickOnApply() )
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool MeasureGUI_CheckSelfIntersectionsDlg::ClickOnApply()
{
if ( !onAccept() )
return false;
initName();
return true;
}
//=================================================================================
// function : extractPrefix
// purpose :
//=================================================================================
bool MeasureGUI_CheckSelfIntersectionsDlg::extractPrefix() const
{
return true;
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr MeasureGUI_CheckSelfIntersectionsDlg::createOperation()
{
return getGeomEngine()->GetIMeasureOperations( getStudyId() );
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool MeasureGUI_CheckSelfIntersectionsDlg::isValid( QString& )
{
return !myObj->_is_nil();
}
//=================================================================================
// function : SetEditCurrentArgument
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::SetEditCurrentArgument()
{
myEditObjName->setFocus();
SelectionIntoArgument();
}
//=================================================================================
// function : SelectionIntoArgument
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::SelectionIntoArgument()
{
// Clear the dialog.
clear();
myObj = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();
if (aSelList.Extent() > 0) {
aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
}
if (aSelectedObject->_is_nil()) {
myEditObjName->setText("");
return;
}
myObj = aSelectedObject;
myEditObjName->setText(GEOMBase::GetName(myObj));
}
//=================================================================================
// function : enterEvent
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::enterEvent(QEvent *)
{
if ( !mainFrame()->GroupConstructors->isEnabled() )
ActivateThisDialog();
}
//=================================================================================
// function : findSelfIntersections
// purpose :
//=================================================================================
bool MeasureGUI_CheckSelfIntersectionsDlg::findSelfIntersections
(bool &HasSelfInte, QString &theErrMsg)
{
if (myObj->_is_nil()) {
return false;
}
GEOM::GEOM_IMeasureOperations_var anOper =
GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
bool isOK = true;
int nbPairs = 0;
int aLevel = myLevelBox->currentIndex();
QString aMsg ("");
GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
bool isGood = false, isFailed = false;
int nbPairs = 0;
try {
isGood = anOper->CheckSelfIntersections(myObj, myInters);
HasSelfInte = !anOper->CheckSelfIntersections(myObj, aLevel, myInters);
nbPairs = myInters->length()/2;
if (nbPairs*2 != myInters->length()) {
isFailed = true;
isOK = false;
}
}
catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
isFailed = true;
}
if (!anOper->IsDone() && myInters->length() == 0) {
aMsg += tr(anOper->GetErrorCode());
myGrp->TextView1->setText(aMsg);
return;
}
else if (isFailed) {
aMsg += tr("GEOM_CHECK_SELF_INTERSECTIONS_FAILED");
myGrp->TextView1->setText(aMsg);
return;
}
// Status
if (isGood) {
aMsg += tr("GEOM_NO_SELF_INTERSECTIONS");
}
else {
aMsg += tr("GEOM_SELF_INTERSECTIONS_FOUND");
isOK = false;
}
if (!anOper->IsDone()) {
aMsg += "\n\n";
aMsg += tr("GEOM_CHECK_SELF_INTERSECTIONS_ERRORS");
if (myInters->length() == 0) {
theErrMsg = tr(anOper->GetErrorCode());
isOK = false;
} else {
// Valid case. Display all computed self-intersections
theErrMsg = tr("GEOM_CHECK_SELF_INTERSECTIONS_ERRORS");
}
} else if (!isOK) {
theErrMsg = tr("GEOM_CHECK_SELF_INTERSECTIONS_FAILED");
}
myGrp->TextView1->setText(aMsg);
// Pairs
QStringList aErrList;
QString aErrStr ("");
for (int i = 1; i <= nbPairs; i++) {
aErrStr = "Intersection # ";
aErrStr += QString::number(i);
aErrList.append(aErrStr);
}
myGrp->ListBox1->addItems(aErrList);
return isOK;
}
//=================================================================================
// function : onErrorsListSelectionChanged
// function : onInteListSelectionChanged
// purpose :
//=================================================================================
void MeasureGUI_CheckSelfIntersectionsDlg::onErrorsListSelectionChanged()
void MeasureGUI_CheckSelfIntersectionsDlg::onInteListSelectionChanged()
{
erasePreview();
int aCurItem = myGrp->ListBox1->currentRow();
int aCurItem = myInteList->currentRow();
if (aCurItem < 0)
return;
//int nbPairs = myInters->length()/2;
QStringList aSubShapeList;
TopoDS_Shape aSelShape;
if (!myObj->_is_nil() && GEOMBase::GetShape(myObj, aSelShape)) {
@ -210,8 +462,8 @@ void MeasureGUI_CheckSelfIntersectionsDlg::onErrorsListSelectionChanged()
if (!aType.isEmpty())
aSubShapeList.append(QString("%1_%2").arg(aType).arg(myInters[aCurItem*2 + 1]));
}
myGrp->ListBox2->clear();
myGrp->ListBox2->addItems(aSubShapeList);
myShapeList->clear();
myShapeList->addItems(aSubShapeList);
}
//=================================================================================
@ -223,14 +475,14 @@ void MeasureGUI_CheckSelfIntersectionsDlg::onSubShapesListSelectionChanged()
erasePreview();
// Current pair
int aErrCurItem = myGrp->ListBox1->currentRow();
int aErrCurItem = myInteList->currentRow();
if (aErrCurItem < 0)
return;
// Selected IDs
QList<int> aIds;
for (int i = 0, n = myGrp->ListBox2->count(); i < n; i++) {
if (myGrp->ListBox2->item(i)->isSelected())
for (int i = 0, n = myShapeList->count(); i < n; i++) {
if (myShapeList->item(i)->isSelected())
aIds.append(i);
}
if (aIds.count() < 1)
@ -259,3 +511,82 @@ void MeasureGUI_CheckSelfIntersectionsDlg::onSubShapesListSelectionChanged()
}
}
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool MeasureGUI_CheckSelfIntersectionsDlg::execute(ObjectList& objects)
{
bool hasSelfInte;
QString anErrMsg;
if (!findSelfIntersections(hasSelfInte, anErrMsg)) {
return false;
}
const int aNbInteSelected = myInteList->selectedItems().size();
const bool isPublishAllInte = (aNbInteSelected < 1);
const bool isPublishAllShapes =
(aNbInteSelected != 1 || myShapeList->selectedItems().empty());
int i;
const int n = myInteList->count();
TColStd_IndexedMapOfInteger aMapIndex;
// Collect the map of indices.
for (i = 0; i < n; i++) {
if (isPublishAllInte) {
// Collect the both of two indices.
aMapIndex.Add(myInters[i*2]);
aMapIndex.Add(myInters[i*2 + 1]);
} else if (myInteList->item(i)->isSelected()) {
if (isPublishAllShapes) {
// Collect the both of two indices.
aMapIndex.Add(myInters[i*2]);
aMapIndex.Add(myInters[i*2 + 1]);
} else if (myShapeList->count() == 2) {
// Collect only selected items.
if (myShapeList->item(0)->isSelected()) {
aMapIndex.Add(myInters[i*2]);
}
if (myShapeList->item(1)->isSelected()) {
aMapIndex.Add(myInters[i*2 + 1]);
}
}
}
}
// Create objects.
GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
const int aNbShapes = aMapIndex.Extent();
anArray->length(aNbShapes);
for (i = 1; i <= aNbShapes; i++) {
anArray[i - 1] = aMapIndex.FindKey(i);
}
if (myShapesOper->_is_nil()) {
myShapesOper = getGeomEngine()->GetIShapesOperations(getStudyId());
}
GEOM::ListOfGO_var aList = myShapesOper->MakeSubShapes(myObj, anArray);
const int aNbObj = aList->length();
for (i = 0; i < aNbObj; i++) {
objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
}
return true;
}
//================================================================
// Function : getFather
// Purpose : Get father object for object to be added in study
// (called with addInStudy method)
//================================================================
GEOM::GEOM_Object_ptr MeasureGUI_CheckSelfIntersectionsDlg::getFather
(GEOM::GEOM_Object_ptr)
{
return myObj;
}

View File

@ -26,38 +26,70 @@
#ifndef MEASUREGUI_CHECKSELFINTERDLG_H
#define MEASUREGUI_CHECKSELFINTERDLG_H
#include <MeasureGUI_Skeleton.h>
#include <GEOMBase_Skeleton.h>
class QComboBox;
class QListWidget;
class QTextBrowser;
class MeasureGUI_1Sel1TextView2ListBox;
//=================================================================================
// class : MeasureGUI_CheckSelfIntersectionsDlg
// purpose :
//=================================================================================
class MeasureGUI_CheckSelfIntersectionsDlg : public MeasureGUI_Skeleton
class MeasureGUI_CheckSelfIntersectionsDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
MeasureGUI_CheckSelfIntersectionsDlg(GeometryGUI*, QWidget*);
~MeasureGUI_CheckSelfIntersectionsDlg();
protected:
// redefined from GEOMBase_Helper and MeasureGUI_Skeleton
virtual void processObject();
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid(QString &);
virtual bool execute(ObjectList &);
virtual bool extractPrefix() const;
virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr);
private slots:
void onErrorsListSelectionChanged();
void onInteListSelectionChanged();
void onSubShapesListSelectionChanged();
void clear();
void onCompute();
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
void SelectionIntoArgument();
void SetEditCurrentArgument();
private:
void Init();
void activateSelection();
void enterEvent(QEvent *);
bool findSelfIntersections
(bool &HasSelfInte,
QString &theErrMsg);
private:
MeasureGUI_1Sel1TextView2ListBox* myGrp;
QTextBrowser *myTextView;
QPushButton *mySelButton;
QLineEdit *myEditObjName;
QComboBox *myLevelBox;
QPushButton *myComputeButton;
QListWidget *myInteList;
QListWidget *myShapeList;
GEOM::GEOM_Object_var myObj;
GEOM::ListOfLong_var myInters;
GEOM::GEOM_IShapesOperations_var myShapesOper;
};
#endif // MEASUREGUI_CHECKSELFINTERDLG_H