Salome HOME
0021031: EDF 1646 GEOM: Modify Location leads to Position driver failed
[modules/geom.git] / src / TransformationGUI / TransformationGUI_PositionDlg.cxx
index e6cd6c213fe075e8acfa93052af0dfa037acfd80..da9067e0f7cb2327f3fd754d5b41747bee0f7e43 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_PositionDlg.cxx
 // Author : Damien COQUERET, Open CASCADE S.A.S.
@@ -90,7 +91,6 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg
 
   // Activate Create a Copy mode
   Group1->CheckButton1->setChecked(true);
-  Group1->CheckButton1->setChecked(false);
   CreateCopyModeChanged(true);
 
   Init();
@@ -122,7 +122,7 @@ void TransformationGUI_PositionDlg::Init()
   Group1->LineEdit4->setText("");
   Group1->LineEdit5->setText("");
 
-  initSpinBox(Group1->SpinBox_DX, 0, 1, 0.05, 6); // VSR:TODO : DBL_DIGITS_DISPLAY
+  initSpinBox(Group1->SpinBox_DX, 0, 1, 0.05, "parametric_precision" );
   Group1->SpinBox_DX->setValue(0);
 
   Group1->CheckButton2->setEnabled(false);
@@ -299,6 +299,12 @@ bool TransformationGUI_PositionDlg::ClickOnApply()
     return false;
 
   initName();
+
+  myObjects.length(0);
+  myEditCurrentArgument = Group1->LineEdit1;
+  myEditCurrentArgument->setText("");
+  myGeomGUI->getApp()->selectionMgr()->clearSelected();
+
   // activate selection and connect selection manager
   ConstructorsClicked(getConstructorId());
   return true;
@@ -339,8 +345,8 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument()
     else
       myEditCurrentArgument->setText(aName);
 
-    if (getConstructorId() == 2)
-      Group1->PushButton5->click();
+    /*    if (getConstructorId() == 2)
+          Group1->PushButton5->click();*/
   }
   else if (myEditCurrentArgument == Group1->LineEdit2) {
     if (aSelList.Extent() != 1)
@@ -400,20 +406,20 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument()
       //Find SubShape Object in Father
       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
       
-      if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
-       GEOM::GEOM_IShapesOperations_var aShapesOp =
-         getGeomEngine()->GetIShapesOperations(getStudyId());
-       aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+      if (aFindedObject->_is_nil()) { // Object not found in study
+        GEOM::GEOM_IShapesOperations_var aShapesOp =
+          getGeomEngine()->GetIShapesOperations(getStudyId());
+        aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
       }
       else { // get Object from study
-       aSelectedObject = aFindedObject;
+        aSelectedObject = aFindedObject;
       }
     }
     else {
       if (S.ShapeType() != TopAbs_EDGE && S.ShapeType() != TopAbs_WIRE) {
-       aSelectedObject = GEOM::GEOM_Object::_nil();
-       aName = "";
-       return;
+        aSelectedObject = GEOM::GEOM_Object::_nil();
+        aName = "";
+        return;
       }
     }
     
@@ -425,10 +431,11 @@ void TransformationGUI_PositionDlg::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();
 }
@@ -553,10 +560,10 @@ void TransformationGUI_PositionDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
-          this, SLOT( SelectionIntoArgument() ) );
+           this, SLOT( SelectionIntoArgument() ) );
 
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
-          this, SLOT( SelectionIntoArgument() ) );
+           this, SLOT( SelectionIntoArgument() ) );
 
   ConstructorsClicked( getConstructorId() );
 }
@@ -607,16 +614,15 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
   bool toCreateCopy = IsPreview() || Group1->CheckButton1->isChecked();
   GEOM::GEOM_Object_var anObj;
 
+  GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
+
   switch (getConstructorId()) {
   case 0:
     {
       for (int i = 0; i < myObjects.length(); i++) {
-        if (toCreateCopy)
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS);
-        else
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            PositionShape(myObjects[i], myObjects[i], myEndLCS);
+        anObj = toCreateCopy ? 
+          anOper->PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS) :
+          anOper->PositionShape(myObjects[i], myObjects[i], myEndLCS);
 
         if (!anObj->_is_nil())
           objects.push_back(anObj._retn());
@@ -627,12 +633,9 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
   case 1:
     {
       for (int i = 0; i < myObjects.length(); i++) {
-        if (toCreateCopy)
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS);
-        else
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            PositionShape(myObjects[i], myStartLCS, myEndLCS);
+          anObj = toCreateCopy ? 
+            anOper->PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS) :
+            anOper->PositionShape(myObjects[i], myStartLCS, myEndLCS);
         if (!anObj->_is_nil())
           objects.push_back(anObj._retn());
       }
@@ -644,10 +647,9 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
       double aDistance = Group1->SpinBox_DX->value();
       bool toReverse = Group1->CheckButton3->isChecked();
       for (int i = 0; i < myObjects.length(); i++) {
-       anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-         PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse);
-       if (!anObj->_is_nil())
-         objects.push_back(anObj._retn());
+        anObj = anOper->PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse);
+        if (!anObj->_is_nil())
+          objects.push_back(anObj._retn());
       }
       res = true;
       break;
@@ -668,7 +670,8 @@ void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr   theS
     // 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());
   }
 }