Salome HOME
NOMINMAX definition has been moved into CONFIGURATION repository.
[modules/geom.git] / src / RepairGUI / RepairGUI_SewingDlg.cxx
index 34cc7ddb6ab1bc8cd4a5569b78c1b7f94a42bb06..8c83be27c460f9824e3406db921923b4e6d79539 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -70,7 +70,7 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg( GeometryGUI* theGeometryGUI, QWidget*
 
   GroupPoints = new DlgRef_1SelExt( centralWidget() );
   GroupPoints->GroupBox1->setTitle( tr( "GEOM_SEWING" ) );
-  GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
+  GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPES" ) );
   GroupPoints->PushButton1->setIcon( image1 );
   GroupPoints->LineEdit1->setReadOnly( true );
 
@@ -117,7 +117,7 @@ void RepairGUI_SewingDlg::Init()
   /* init variables */
   myEditCurrentArgument = GroupPoints->LineEdit1;
 
-  myObject = GEOM::GEOM_Object::_nil();
+  myObjects.clear();
 
   //myGeomGUI->SetState( 0 );
   initSelection();
@@ -166,7 +166,7 @@ bool RepairGUI_SewingDlg::ClickOnApply()
   initName();
 
   GroupPoints->LineEdit1->setText( "" );
-  myObject = GEOM::GEOM_Object::_nil();
+  myObjects.clear();
 
   initSelection();
 
@@ -182,17 +182,13 @@ void RepairGUI_SewingDlg::SelectionIntoArgument()
 {
   erasePreview();
   myEditCurrentArgument->setText( "" );
-  myObject = GEOM::GEOM_Object::_nil();
+  myObjects.clear();
 
-  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
-  SALOME_ListIO aSelList;
-  aSelMgr->selectedObjects(aSelList);
+  myObjects = getSelected( TopAbs_SHAPE, -1 );
 
-  if ( aSelList.Extent() == 1 ) {
-    Handle(SALOME_InteractiveObject) anIO = aSelList.First();
-    myObject = GEOMBase::ConvertIOinGEOMObject( anIO );
-    if ( !CORBA::is_nil( myObject ) )
-      myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
+  if ( !myObjects.isEmpty() ) {
+    QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+    myEditCurrentArgument->setText( aName );
   }
 }
 
@@ -235,7 +231,7 @@ void RepairGUI_SewingDlg::ActivateThisDialog()
            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
 
   GroupPoints->LineEdit1->setText( "" );
-  myObject = GEOM::GEOM_Object::_nil();
+  myObjects.clear();
 
   myClosed = -1;
   myOpen = -1;
@@ -262,7 +258,7 @@ void RepairGUI_SewingDlg::enterEvent( QEvent* )
 //=================================================================================
 GEOM::GEOM_IOperations_ptr RepairGUI_SewingDlg::createOperation()
 {
-  return getGeomEngine()->GetIHealingOperations( getStudyId() );
+  return getGeomEngine()->GetIHealingOperations();
 }
 
 //=================================================================================
@@ -273,7 +269,7 @@ bool RepairGUI_SewingDlg::isValid( QString& msg )
 {
   myClosed = -1;
   bool ok = myTolEdt->isValid( msg, !IsPreview() );
-  return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ) && ok;
+  return !myObjects.isEmpty() && ( IsPreview() || myTolEdt->value() > 0. ) && ok;
 }
 
 //=================================================================================
@@ -285,10 +281,15 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
   bool aResult = false;
   GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
 
+  GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
+  objList->length( myObjects.count() );
+  for ( int i = 0; i < myObjects.count(); ++i )
+    objList[i] = myObjects[i].copy();
+
   if ( IsPreview() ) { // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog
     GEOM::ListOfGO_var aClosed, anOpen;
 
-    aResult = anOper->GetFreeBoundary( myObject, aClosed, anOpen );
+    aResult = anOper->GetFreeBoundary( objList, aClosed, anOpen );
 
     if ( aResult ) {
       myClosed = aClosed->length();
@@ -306,9 +307,9 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
     GEOM::GEOM_Object_var anObj;
 
     if (myAllowNonManifoldChk->isChecked()) {
-      anObj = anOper->SewAllowNonManifold( myObject, myTolEdt->value() );
+      anObj = anOper->SewAllowNonManifold( objList, myTolEdt->value() );
     } else {
-      anObj = anOper->Sew( myObject, myTolEdt->value() );
+      anObj = anOper->Sew( objList, myTolEdt->value() );
     }
 
     aResult = !anObj->_is_nil();
@@ -318,7 +319,7 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
       {
         QStringList aParameters;
         aParameters << myTolEdt->text();
-        anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+        anObj->SetParameters(aParameters.join(":").toUtf8().constData());
       }
       objects.push_back( anObj._retn() );
     }
@@ -334,6 +335,7 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
 void RepairGUI_SewingDlg::initSelection()
 {
   TColStd_MapOfInteger aTypes;
+  aTypes.Add( GEOM_FACE );
   aTypes.Add( GEOM_SHELL );
   aTypes.Add( GEOM_SOLID );
   aTypes.Add( GEOM_COMPOUND );
@@ -356,3 +358,12 @@ void RepairGUI_SewingDlg::onDetect()
     msg = tr( "GEOM_FREE_BOUNDS_ERROR" );
   SUIT_MessageBox::information( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg );
 }
+
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> RepairGUI_SewingDlg::getSourceObjects()
+{
+  return myObjects;
+}