Salome HOME
0020044: EDF 866 GEOM: Extrusion along a path : impossible to select a Wire
[modules/geom.git] / src / GenerationGUI / GenerationGUI_FillingDlg.cxx
index 4cac5f7b3470e32bc45ff2fdc94c86417125e55b..ae4f0251ac9335b1128d33fffe1353dbb646299b 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "GenerationGUI_FillingDlg.h"
 
-#include <GEOM_DlgRef.h>
+#include <DlgRef.h>
 #include <GeometryGUI.h>
 #include <GEOMBase.h>
 
@@ -61,7 +61,7 @@ GenerationGUI_FillingDlg::GenerationGUI_FillingDlg( GeometryGUI* theGeometryGUI,
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
-  GroupPoints = new DlgRef_1Sel5Spin( centralWidget() );
+  GroupPoints = new DlgRef_1Sel5Spin1Check( centralWidget() );
   GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
   GroupPoints->TextLabel1->setText( tr( "GEOM_FILLING_COMPOUND" ) );
   GroupPoints->TextLabel2->setText( tr( "GEOM_FILLING_MIN_DEG" ) );
@@ -69,6 +69,7 @@ GenerationGUI_FillingDlg::GenerationGUI_FillingDlg( GeometryGUI* theGeometryGUI,
   GroupPoints->TextLabel4->setText( tr( "GEOM_FILLING_NB_ITER" ) );
   GroupPoints->TextLabel5->setText( tr( "GEOM_FILLING_MAX_DEG" ) );
   GroupPoints->TextLabel6->setText( tr( "GEOM_FILLING_TOL_3D" ) );
+  GroupPoints->CheckBox1->setText( tr( "GEOM_FILLING_APPROX" ) );
   GroupPoints->PushButton1->setIcon( image1 );
   GroupPoints->LineEdit1->setReadOnly( true );
 
@@ -77,7 +78,7 @@ GenerationGUI_FillingDlg::GenerationGUI_FillingDlg( GeometryGUI* theGeometryGUI,
   layout->addWidget( GroupPoints  );
   /***************************************************************/
 
-  setHelpFileName( "filling.htm" );
+  setHelpFileName( "create_filling_page.html" );
 
   /* Initialisations */
   Init();
@@ -106,7 +107,8 @@ void GenerationGUI_FillingDlg::Init()
   myMaxDeg = 5;
   myTol3D = 0.0001;
   myTol2D = 0.0001;
-  myNbIter = 5;
+  myNbIter = 0;
+  myIsApprox = false;
   myOkCompound = false;
 
   globalSelection( GEOM_COMPOUND );
@@ -116,7 +118,7 @@ void GenerationGUI_FillingDlg::Init()
   /* min, max, step and decimals for spin boxes & initial values */
   initSpinBox( GroupPoints->SpinBox1, 2.0, MAX_NUMBER,  SpecificStep1, 3 );
   initSpinBox( GroupPoints->SpinBox2, 0.00001, 10000.0, SpecificStep2, 5 );
-  initSpinBox( GroupPoints->SpinBox3, 1.0, MAX_NUMBER,  SpecificStep1, 3 );
+  initSpinBox( GroupPoints->SpinBox3, 0.0, MAX_NUMBER,  SpecificStep1, 3 );
   initSpinBox( GroupPoints->SpinBox4, 1.0, MAX_NUMBER,  SpecificStep1, 3 );
   initSpinBox( GroupPoints->SpinBox5, 0.00001, 10000.0, SpecificStep2, 5 );
 
@@ -139,13 +141,9 @@ void GenerationGUI_FillingDlg::Init()
   connect( GroupPoints->SpinBox4, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
   connect( GroupPoints->SpinBox5, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
 
-  // VSR: TODO ->>
-  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupPoints->SpinBox1, SLOT( SetStep( double ) ) );
-  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupPoints->SpinBox2, SLOT( SetStep( double ) ) );
-  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupPoints->SpinBox3, SLOT( SetStep( double ) ) );
-  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupPoints->SpinBox4, SLOT( SetStep( double ) ) );
-  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupPoints->SpinBox5, SLOT( SetStep( double ) ) );
-  // <<-
+  connect( GroupPoints->CheckBox1, SIGNAL( stateChanged( int ) ), this, SLOT( ApproxChanged() ) );
+
+  connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
 
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
@@ -153,6 +151,19 @@ void GenerationGUI_FillingDlg::Init()
   initName( tr( "GEOM_FILLING" ) );
 }
 
+//=================================================================================
+// function : SetDoubleSpinBoxStep()
+// purpose  : Double spin box management
+//=================================================================================
+void GenerationGUI_FillingDlg::SetDoubleSpinBoxStep( double step )
+{
+  GroupPoints->SpinBox1->setSingleStep(step);
+  GroupPoints->SpinBox2->setSingleStep(step);
+  GroupPoints->SpinBox3->setSingleStep(step);
+  GroupPoints->SpinBox4->setSingleStep(step);
+  GroupPoints->SpinBox5->setSingleStep(step);
+}
+
 
 //=================================================================================
 // function : ClickOnOk()
@@ -186,41 +197,43 @@ bool GenerationGUI_FillingDlg::ClickOnApply()
 void GenerationGUI_FillingDlg::SelectionIntoArgument()
 {
   erasePreview();
-  myEditCurrentArgument->setText( "" );
+  myEditCurrentArgument->setText("");
 
-  if ( IObjectCount() != 1 ) {
-    if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  SALOME_ListIO aSelList;
+  aSelMgr->selectedObjects(aSelList);
+
+  if (aSelList.Extent() != 1) {
+    if (myEditCurrentArgument == GroupPoints->LineEdit1)
       myOkCompound = false;
     return;
   }
 
   // nbSel == 1
   Standard_Boolean testResult = Standard_False;
-  GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
+  GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
 
-  if ( !testResult )
+  if (!testResult)
     return;
 
-  if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+  if (myEditCurrentArgument == GroupPoints->LineEdit1) {
     TopoDS_Shape S;
     myOkCompound = false;
 
-    if ( GEOMBase::GetShape(aSelectedObject, S) &&
-        S.ShapeType() == TopAbs_COMPOUND ) {
-       // myCompound should be a compound of edges
-       for ( TopoDS_Iterator it( S ); it.More(); it.Next() )
-         if ( it.Value().ShapeType() != TopAbs_EDGE )
-           return;
-       myCompound = aSelectedObject;
-       myOkCompound = true;
-      }
+    if (GEOMBase::GetShape(aSelectedObject, S) && S.ShapeType() == TopAbs_COMPOUND) {
+      // myCompound should be a compound of edges
+      for (TopoDS_Iterator it (S); it.More(); it.Next())
+        if (it.Value().ShapeType() != TopAbs_EDGE)
+          return;
+      myCompound = aSelectedObject;
+      myOkCompound = true;
+    }
   }
 
-  myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
+  myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
   displayPreview();
 }
 
-
 //=================================================================================
 // function : SetEditCurrentArgument()
 // purpose  :
@@ -300,6 +313,16 @@ void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue )
   displayPreview();
 }
 
+//=================================================================================
+// function : ApproxChanged()
+// purpose  :
+//=================================================================================
+void GenerationGUI_FillingDlg::ApproxChanged()
+{
+  myIsApprox = GroupPoints->CheckBox1->isChecked();
+  displayPreview();
+}
+
 //=================================================================================
 // function : createOperation
 // purpose  :
@@ -327,7 +350,7 @@ bool GenerationGUI_FillingDlg::execute( ObjectList& objects )
   GEOM::GEOM_Object_var anObj;
 
   anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation() )->MakeFilling(
-    myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D, myNbIter );
+    myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D, myNbIter, myIsApprox );
 
   if ( !anObj->_is_nil() )
     objects.push_back( anObj._retn() );