Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/geom.git] / src / BuildGUI / BuildGUI_WireDlg.cxx
index 05326e4570afe7636deac44857b85612b2399508..1b930742e8073f3fdf9f0aeed4d63f3985e192c3 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // GEOM GEOMGUI : GUI for Geometry component
 // File   : BuildGUI_WireDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
@@ -37,6 +38,7 @@
 #include <LightApp_SelectionMgr.h>
 
 #include <TColStd_MapOfInteger.hxx>
+#include <Precision.hxx>
 
 //=================================================================================
 // class    : BuildGUI_WireDlg()
@@ -61,16 +63,22 @@ BuildGUI_WireDlg::BuildGUI_WireDlg( GeometryGUI* theGeometryGUI, QWidget* parent
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
-  GroupPoints = new DlgRef_1Sel( centralWidget() );
+  GroupArgs = new DlgRef_1Sel1Spin( centralWidget() );
+
+  GroupArgs->GroupBox1->setTitle( tr( "GEOM_WIRE_CONNECT" ) );
+  GroupArgs->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
+  GroupArgs->PushButton1->setIcon( image1 );
+  GroupArgs->LineEdit1->setReadOnly( true );
 
-  GroupPoints->GroupBox1->setTitle( tr( "GEOM_WIRE_CONNECT" ) );
-  GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
-  GroupPoints->PushButton1->setIcon( image1 );
-  GroupPoints->LineEdit1->setReadOnly( true );
+  GroupArgs->TextLabel2->setText( tr( "GEOM_TOLERANCE" ) );
+  double SpecificStep = 0.0001;
+  double prec = Precision::Confusion();
+  initSpinBox(GroupArgs->SpinBox_DX, prec, MAX_NUMBER, SpecificStep, "len_tol_precision" );
+  GroupArgs->SpinBox_DX->setValue(prec);
 
   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
   layout->setMargin( 0 ); layout->setSpacing( 6 );
-  layout->addWidget( GroupPoints );
+  layout->addWidget( GroupArgs );
   /***************************************************************/
 
   setHelpFileName( "create_wire_page.html" );
@@ -97,8 +105,8 @@ BuildGUI_WireDlg::~BuildGUI_WireDlg()
 void BuildGUI_WireDlg::Init()
 {
   /* init variables */
-  myEditCurrentArgument = GroupPoints->LineEdit1;
-  GroupPoints->LineEdit1->setReadOnly( true );
+  myEditCurrentArgument = GroupArgs->LineEdit1;
+  GroupArgs->LineEdit1->setReadOnly( true );
   
   myOkEdgesAndWires = false;
   
@@ -110,9 +118,9 @@ void BuildGUI_WireDlg::Init()
   /* signals and slots connections */
   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
-  connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+  connect( GroupArgs->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
-          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
   
   initName( tr( "GEOM_WIRE" ) );
 }
@@ -180,14 +188,14 @@ void BuildGUI_WireDlg::SelectionIntoArgument()
 void BuildGUI_WireDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
-  if ( send != GroupPoints->PushButton1 )
+  if ( send != GroupArgs->PushButton1 )
     return;
 
   TColStd_MapOfInteger aMap;
   aMap.Add( GEOM_WIRE );
   aMap.Add( GEOM_EDGE );
   globalSelection( aMap );
-  myEditCurrentArgument = GroupPoints->LineEdit1;
+  myEditCurrentArgument = GroupArgs->LineEdit1;
 
   myEditCurrentArgument->setFocus();
   SelectionIntoArgument();
@@ -202,7 +210,7 @@ void BuildGUI_WireDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
-          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+           SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
   TColStd_MapOfInteger aMap;
   aMap.Add( GEOM_WIRE );
   aMap.Add( GEOM_EDGE );
@@ -233,25 +241,23 @@ GEOM::GEOM_IOperations_ptr BuildGUI_WireDlg::createOperation()
 // function : isValid
 // purpose  :
 //=================================================================================
-bool BuildGUI_WireDlg::isValid( QString& )
+bool BuildGUI_WireDlg::isValid (QString& msg)
 {
-  return myOkEdgesAndWires;
+  bool ok = GroupArgs->SpinBox_DX->isValid(msg, !IsPreview());
+  return myOkEdgesAndWires && ok;
 }
 
 //=================================================================================
 // function : execute
 // purpose  :
 //=================================================================================
-bool BuildGUI_WireDlg::execute( ObjectList& objects )
+bool BuildGUI_WireDlg::execute (ObjectList& objects)
 {
-  GEOM::GEOM_Object_var anObj;
+  GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
+  GEOM::GEOM_Object_var anObj = anOper->MakeWire(myEdgesAndWires, GroupArgs->SpinBox_DX->value());
 
-  anObj = GEOM::GEOM_IShapesOperations::_narrow(
-    getOperation() )->MakeWire( myEdgesAndWires );
-
-  if ( !anObj->_is_nil() )
-    objects.push_back( anObj._retn() );
+  if (!anObj->_is_nil())
+    objects.push_back(anObj._retn());
 
   return true;
 }
-