Salome HOME
0021031: EDF 1646 GEOM: Modify Location leads to Position driver failed
[modules/geom.git] / src / TransformationGUI / TransformationGUI_ScaleDlg.cxx
index 32daa0cb5799c1b738d50bc74fb94259111ad44c..17023381f3bebe2b3796e7119284742cc7515df6 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   : TransformationGUI_ScaleDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
@@ -155,9 +156,9 @@ void TransformationGUI_ScaleDlg::Init()
   double aFactor = 2.0;
   double SpecificStep = 0.5;
 
-  initSpinBox(SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
-  initSpinBox(SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
-  initSpinBox(SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  initSpinBox(SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, "parametric_precision" );
+  initSpinBox(SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, "parametric_precision" );
+  initSpinBox(SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, "parametric_precision" );
   SpinBox_FX->setValue(aFactor);
   SpinBox_FY->setValue(aFactor);
   SpinBox_FZ->setValue(aFactor);
@@ -182,8 +183,9 @@ void TransformationGUI_ScaleDlg::Init()
   connect(SpinBox_FX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
   connect(SpinBox_FY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
   connect(SpinBox_FZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
-
-  connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
+  
+  // san : Commented so as not to override specific step settings
+  //connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
 
   connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
 
@@ -200,6 +202,9 @@ void TransformationGUI_ScaleDlg::ConstructorsClicked (int constructorId)
 {
   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
 
+  myPoint = GEOM::GEOM_Object::_nil();
+  LineEdit2->clear();
+  
   switch (constructorId) {
   case 0: // translation an object by dx, dy, dz
     TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
@@ -256,6 +261,12 @@ bool TransformationGUI_ScaleDlg::ClickOnApply()
     return false;
 
   initName(tr("GEOM_SCALE"));
+
+  myObjects.length(0);
+  myEditCurrentArgument = LineEdit1;
+  myEditCurrentArgument->setText("");
+  myGeomGUI->getApp()->selectionMgr()->clearSelected();
+
   // activate selection and connect selection manager
   ConstructorsClicked(getConstructorId());
   return true;
@@ -317,7 +328,7 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
             //Find SubShape Object in Father
             GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
 
-            if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
+            if (aFindedObject->_is_nil()) { // Object not found in study
               GEOM::GEOM_IShapesOperations_var aShapesOp =
                 getGeomEngine()->GetIShapesOperations(getStudyId());
               aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
@@ -344,10 +355,11 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
   }
 
   // clear selection
-  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+  /*  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
   myGeomGUI->getApp()->selectionMgr()->clearSelected();
   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
-          this, SLOT(SelectionIntoArgument()));
+  this, SLOT(SelectionIntoArgument()));*/
+  // here commented, because multiple objects can be selected IPAL 21437
 
   displayPreview();
 }
@@ -412,7 +424,7 @@ void TransformationGUI_ScaleDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
-          this, SLOT( SelectionIntoArgument() ) );
+           this, SLOT( SelectionIntoArgument() ) );
 
   ConstructorsClicked( getConstructorId() );
 }
@@ -488,6 +500,8 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
 
   GEOM::GEOM_Object_var anObj;
 
+  GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
+
   switch (getConstructorId())
   {
   case 0:
@@ -496,8 +510,7 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
       {
         for (int i = 0; i < myObjects.length(); i++)
         {
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value());
+          anObj = anOper->ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value());
           if (!anObj->_is_nil()) {
             if(!IsPreview()) 
               anObj->SetParameters(SpinBox_FX->text().toLatin1().constData());
@@ -509,8 +522,7 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
       {
         for (int i = 0; i < myObjects.length(); i++)
         {
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            ScaleShape(myObjects[i], myPoint, SpinBox_FX->value());
+          anObj = anOper->ScaleShape(myObjects[i], myPoint, SpinBox_FX->value());
           if (!anObj->_is_nil())
             objects.push_back(anObj._retn());
         }
@@ -523,16 +535,15 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
       {
         for (int i = 0; i < myObjects.length(); i++)
         {
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
-                                     SpinBox_FY->value(), SpinBox_FZ->value());
+          anObj = anOper->ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
+                                                  SpinBox_FY->value(), SpinBox_FZ->value());
           if (!anObj->_is_nil())
             if(!IsPreview()) {
               QStringList aParameters;
               aParameters<<SpinBox_FX->text();
               aParameters<<SpinBox_FY->text();
               aParameters<<SpinBox_FZ->text();
-              anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+              anObj->SetParameters(aParameters.join(":").toLatin1().constData());
             }
             objects.push_back(anObj._retn());
         }
@@ -541,9 +552,8 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
       {
         for (int i = 0; i < myObjects.length(); i++)
         {
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(),
-                                 SpinBox_FY->value(), SpinBox_FZ->value());
+          anObj = anOper->ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(),
+                                              SpinBox_FY->value(), SpinBox_FZ->value());
           if (!anObj->_is_nil())
             objects.push_back(anObj._retn());
         }
@@ -568,7 +578,8 @@ void TransformationGUI_ScaleDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStud
     // empty list of arguments means that all arguments should be restored
     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
                                         /*theFindMethod=*/GEOM::FSM_Transformed,
-                                        /*theInheritFirstArg=*/true);
+                                        /*theInheritFirstArg=*/true,
+                                        mainFrame()->CheckBoxAddPrefix->isChecked());
   }
 }