+ 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();
+
+ try {
+ HasSelfInte = !anOper->CheckSelfIntersections(myObj, aLevel, myInters);
+ nbPairs = myInters->length()/2;
+
+ if (nbPairs*2 != myInters->length()) {
+ isOK = false;
+ }
+ }
+ catch (const SALOME::SALOME_Exception& e) {
+ SalomeApp_Tools::QtCatchCorbaException(e);
+ isOK = false;
+ }
+
+ if (!anOper->IsDone()) {
+ 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");