Salome HOME
Additional minor fix of issue 0017431: unset the MODAL behavior for the 'Basic Proper...
[modules/geom.git] / src / OperationGUI / OperationGUI_PartitionDlg.cxx
index ab15bb14668ba958587bdfd31f2c23aa4688ef6e..9c787d2cef546053ee9f21e21665a5b2a9b1fd78 100644 (file)
@@ -24,9 +24,8 @@
 //
 
 #include "OperationGUI_PartitionDlg.h"
-#include "OperationGUI_MaterialDlg.h"
 
-#include <GEOM_DlgRef.h>
+#include <DlgRef.h>
 #include <GeometryGUI.h>
 #include <GEOMBase.h>
 
@@ -63,7 +62,7 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU
   mainFrame()->RadioButton3->close();
 
   // Full partition (contains half-space partition)
-  GroupPoints = new DlgRef_2Sel1List( centralWidget() );
+  GroupPoints = new DlgRef_2Sel1List1Check( centralWidget() );
   GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) );
   GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
   GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECT" ) );
@@ -72,6 +71,9 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU
   GroupPoints->PushButton2->setIcon( image2 );
   GroupPoints->LineEdit1->setReadOnly( true );
   GroupPoints->LineEdit2->setReadOnly( true );
+  GroupPoints->LineEdit1->setEnabled(true);
+  GroupPoints->LineEdit2->setEnabled(false);
+  GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) );
 
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
@@ -79,7 +81,7 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU
 
   /***************************************************************/
 
-  setHelpFileName( "partition.htm" ); 
+  setHelpFileName( "partition_page.html" );
  
   Init();
 }
@@ -117,7 +119,10 @@ void OperationGUI_PartitionDlg::Init()
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) );
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) );
   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
+  GroupPoints->CheckButton1->setChecked( false );
   
+  mainFrame()->GroupBoxPublish->show();
+
   /* signals and slots connections */
   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
@@ -131,13 +136,14 @@ void OperationGUI_PartitionDlg::Init()
   connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
   
   connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
-  
-  connect( myGeomGUI->getApp()->selectionMgr(), 
+
+  connect( myGeomGUI->getApp()->selectionMgr(),
           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
   
   initName( tr( "GEOM_PARTITION" ) );
 
   ConstructorsClicked( 0 );
+  GroupPoints->PushButton1->click();
 }
 
 
@@ -162,14 +168,21 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId )
     GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECT" ) );
     GroupPoints->TextLabel3->show();
     GroupPoints->ComboBox1->show();
-    
     GroupPoints->ComboBox1->setCurrentIndex( 0 );
+    GroupPoints->CheckButton1->show();
+    GroupPoints->PushButton1->setDown( true );
+    GroupPoints->PushButton2->setDown( false );
+    GroupPoints->LineEdit1->setEnabled(true);
+    GroupPoints->LineEdit2->setEnabled(false);
     break;
   case 1: /*Half-space partition */
     GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION_HALFSPACE" ) );
     GroupPoints->TextLabel3->hide();
     GroupPoints->ComboBox1->hide();
     GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) );
+    GroupPoints->CheckButton1->hide();
+    GroupPoints->PushButton1->setDown( true );
+    GroupPoints->LineEdit1->setEnabled(true);
     break;
   } 
 
@@ -222,7 +235,11 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
   myEditCurrentArgument->setText( "" );
   QString aString = "";
   
-  int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true );
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  SALOME_ListIO aSelList;
+  aSelMgr->selectedObjects(aSelList);
+
+  int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
     
   if ( nbSel < 1 ) {
     if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
@@ -235,7 +252,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
   
   // One and only one plane can be selected
   
-  if ( getConstructorId() == 1 && 
+  if ( getConstructorId() == 1 &&
        myEditCurrentArgument == GroupPoints->LineEdit2 && 
        nbSel != 1 ) {
     myListTools.length( 0 );
@@ -243,13 +260,13 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument()
   }
   
   if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
-    GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myListShapes, true );
+    GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
     myListMaterials.length( 0 );
     if ( !myListShapes.length() )
       return;
   }
   else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
-    GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myListTools, true );
+    GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true);
     if ( !myListTools.length() )
       return;
   }
@@ -266,10 +283,18 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
   
-  if ( send == GroupPoints->PushButton1 ) 
+  if ( send == GroupPoints->PushButton1 ) {
     myEditCurrentArgument = GroupPoints->LineEdit1;
+    GroupPoints->PushButton2->setDown(false);
+    GroupPoints->LineEdit1->setEnabled(true);
+    GroupPoints->LineEdit2->setEnabled(false);
+  }
   else if ( send == GroupPoints->PushButton2 ) {
+    myGeomGUI->getApp()->selectionMgr()->clearSelected(); //clear prewious selection
     myEditCurrentArgument = GroupPoints->LineEdit2;
+    GroupPoints->PushButton1->setDown(false);
+    GroupPoints->LineEdit1->setEnabled(false);
+    GroupPoints->LineEdit2->setEnabled(true);
     if ( getConstructorId() == 1 )
       globalSelection( GEOM_PLANE  );
   }
@@ -278,6 +303,7 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument()
       
   myEditCurrentArgument->setFocus();
   SelectionIntoArgument();
+  send->setDown(true);
 }
 
 
@@ -356,15 +382,25 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects )
 
   int aLimit = GetLimit();
   int aConstructorId = getConstructorId();
+  int aKeepNonlimitShapes = 0;
 
-  if ( aConstructorId == 1 )
+  if ( aConstructorId == 1 ) {
     aLimit = GEOM::SHAPE;
+  }
+  else {
+    if ( GroupPoints->CheckButton1->isChecked() ) {
+      aKeepNonlimitShapes = 1;
+    }
+    else {
+      aKeepNonlimitShapes = 0;
+    }
+  }
 
   if ( isValid( msg ) ) {
-    anObj = GEOM::GEOM_IBooleanOperations::_narrow(getOperation())->
-      MakePartition(myListShapes, myListTools,
-                    myListKeepInside, myListRemoveInside,
-                   aLimit, false, myListMaterials);
+    anObj = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() )->
+      MakePartition( myListShapes, myListTools,
+                    myListKeepInside, myListRemoveInside,
+                    aLimit, false, myListMaterials, aKeepNonlimitShapes );
     res = true;
   }
 
@@ -374,17 +410,21 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects )
   return res;
 }
 
-
 //=================================================================================
-// function : closeEvent
+// function : restoreSubShapes
 // purpose  :
 //=================================================================================
-void OperationGUI_PartitionDlg::closeEvent( QCloseEvent* e )
+void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::Study_ptr   theStudy,
+                                                  SALOMEDS::SObject_ptr theSObject )
 {
-  GEOMBase_Skeleton::closeEvent( e );
+  if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
+    // empty list of arguments means that all arguments should be restored
+    getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
+                                        /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory,
+                                        /*theInheritFirstArg=*/myListShapes.length() == 1 ); // ? false
+  }
 }
 
-
 //=======================================================================
 //function : ComboTextChanged
 //purpose  : 
@@ -400,7 +440,6 @@ void OperationGUI_PartitionDlg::ComboTextChanged()
   //GroupPoints->PushButton4->setEnabled(IsEnabled);
 }
 
-
 //=================================================================================
 // function : GetLimit()
 // purpose  :