]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/OperationGUI/OperationGUI_PartitionDlg.cxx
Salome HOME
Copyright update 2022
[modules/geom.git] / src / OperationGUI / OperationGUI_PartitionDlg.cxx
index 6907e1d52466409b7cd78de888839cf2d48b8ec9..040bb3eeb0ace59ec489130c6543630de48d86fe 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  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
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -67,6 +67,8 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU
   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) );
   mainFrame()->RadioButton1->setIcon( image0 );
   mainFrame()->RadioButton2->setIcon( image1 );
+  mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton2->close();
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
@@ -85,6 +87,10 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU
   GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) );
   GroupPoints->CheckButton2->setText( tr( "GEOM_NO_SELF_INTERSECTION" ) );
 
+  mySelfInte = new QCheckBox(GroupPoints->GroupBox1);
+  mySelfInte->setText(tr("GEOM_CHECK_SELF_INTERSECTIONS"));
+  GroupPoints->gridLayout1->addWidget(mySelfInte, 5, 0, 1, 3);
+
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
   layout->addWidget( GroupPoints );
@@ -140,6 +146,7 @@ void OperationGUI_PartitionDlg::Init()
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX);
   GroupPoints->CheckButton1->setChecked( false );
+  mySelfInte->setChecked(false);
 
   mainFrame()->GroupBoxPublish->show();
 
@@ -162,7 +169,10 @@ void OperationGUI_PartitionDlg::Init()
 
   connect( GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
   connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
+  connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), mySelfInte, SLOT(setEnabled(bool)) );
+  connect( mySelfInte,                SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
 
+  mySelfInte->setEnabled(GroupPoints->CheckButton2->isChecked());
   initName( tr( "GEOM_PARTITION" ) );
 
   ConstructorsClicked( 0 );
@@ -195,6 +205,7 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId )
     GroupPoints->ComboBox1->setCurrentIndex( 0 );
     GroupPoints->CheckButton1->show();
     GroupPoints->CheckButton2->show();
+    mySelfInte->show();
     GroupPoints->PushButton1->setDown( true );
     GroupPoints->PushButton2->setDown( false );
     GroupPoints->LineEdit1->setEnabled(true);
@@ -208,6 +219,7 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId )
     GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) );
     GroupPoints->CheckButton1->hide();
     GroupPoints->CheckButton2->hide();
+    mySelfInte->hide();
     GroupPoints->PushButton1->setDown( true );
     GroupPoints->LineEdit1->setEnabled(true);
     break;
@@ -305,7 +317,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
     //myListMaterials.length( 0 ); // obsolete
 
     GEOM::shape_type type = GEOM::SHAPE;
-    for (int i = 0; i < myListShapes.length(); i++)
+    for (int i = 0; i < (int)myListShapes.length(); i++)
       type = qMin( type, myListShapes[i]->GetMaxShapeType() );
     int idx = qMax( 0, GroupPoints->ComboBox1->findData( type ) );
     GroupPoints->ComboBox1->setCurrentIndex( idx );
@@ -318,7 +330,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
     if ( !myListTools.length() )
       return;
     else if ( myListTools.length() == 1 && getConstructorId() == 1 ) {
-      GEOM::GEOM_IMeasureOperations_var mOp = getGeomEngine()->GetIMeasureOperations( getStudyId() );
+      GEOM::GEOM_IMeasureOperations_var mOp = getGeomEngine()->GetIMeasureOperations();
       GEOM::ListOfLong_var   intList;
       GEOM::ListOfDouble_var dblList;
       GEOM::GEOM_IKindOfShape::shape_kind kind = mOp->KindOfShape( myListTools[0].in(), intList.out(), dblList.out() );
@@ -416,7 +428,7 @@ void OperationGUI_PartitionDlg::enterEvent( QEvent* )
 //=================================================================================
 GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation()
 {
-  return getGeomEngine()->GetIBooleanOperations( getStudyId() );
+  return getGeomEngine()->GetIBooleanOperations();
 }
 
 
@@ -446,6 +458,7 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
   switch ( getConstructorId() ) {
   case 0:
     {
+      bool isDetectSelfInte    = mySelfInte->isChecked();
       int aLimit               = GetLimit();
       int aKeepNonlimitShapes  = GroupPoints->CheckButton1->isChecked();
       bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked();
@@ -453,7 +466,8 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
       anObj = aNoSelfIntersection ?
         anOper->MakePartitionNonSelfIntersectedShape(myListShapes, myListTools,
                                                      myListKeepInside, myListRemoveInside,
-                                                     aLimit, false, myListMaterials, aKeepNonlimitShapes) :
+                                                     aLimit, false, myListMaterials, aKeepNonlimitShapes,
+                                                     isDetectSelfInte) :
         anOper->MakePartition(myListShapes, myListTools,
                               myListKeepInside, myListRemoveInside,
                               aLimit, false, myListMaterials, aKeepNonlimitShapes);
@@ -462,7 +476,7 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
     break;
   case 1:
     {
-      anObj = anOper->MakeHalfPartition( myListShapes[0].in(), myListTools[0].in() );
+      anObj = anOper->MakeHalfPartition(myListShapes[0].in(), myListTools[0].in());
       res = true;
     }
     break;
@@ -491,14 +505,13 @@ bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
 // function : restoreSubShapes
 // purpose  :
 //=================================================================================
-void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::Study_ptr   theStudy,
-                                                  SALOMEDS::SObject_ptr theSObject )
+void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::SObject_ptr theSObject )
 {
   if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
     // empty list of arguments means that all arguments should be restored
-    getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
+    getGeomEngine()->RestoreSubShapesSO( theSObject, GEOM::ListOfGO(),
                                          /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory,
-                                         /*theInheritFirstArg=*/myListShapes.length() == 1,
+                                         /*theInheritFirstArg=*/myListShapes.length() == 1 && myListTools.length() == 0,
                                          mainFrame()->CheckBoxAddPrefix->isChecked() ); // ? false
   }
 }
@@ -539,3 +552,29 @@ int OperationGUI_PartitionDlg::GetLimit() const
 
   return aLimit;
 }
+
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> OperationGUI_PartitionDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  for (int i = 0; i < (int)myListShapes.length(); i++) {
+    GEOM::GeomObjPtr aGeomObjPtr(myListShapes[i]);
+    res << aGeomObjPtr;
+  }
+  for (int i = 0; i < (int)myListTools.length(); i++) {
+    GEOM::GeomObjPtr aGeomObjPtr(myListTools[i]);
+    res << aGeomObjPtr;
+  }
+  for (int i = 0; i < (int)myListRemoveInside.length(); i++) {
+    GEOM::GeomObjPtr aGeomObjPtr(myListRemoveInside[i]);
+    res << aGeomObjPtr;
+  }
+  for (int i = 0; i < (int)myListKeepInside.length(); i++) {
+    GEOM::GeomObjPtr aGeomObjPtr(myListKeepInside[i]);
+    res << aGeomObjPtr;
+  }
+  return res;
+}