Salome HOME
TC 5.1.5: SIGSEGV on closing study
[modules/geom.git] / src / TransformationGUI / TransformationGUI_RotationDlg.cxx
index c56fd9c9b935de0f116db7ae06fd9121793e570c..e33e32d51aff8011b2e32dfa333a9b1a587287cd 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_RotationDlg.cxx
 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
@@ -122,7 +123,7 @@ void TransformationGUI_RotationDlg::Init()
   double SpecificStep = 5;
 
   // min, max, step and decimals for spin boxes & initial values
-  initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
+  initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, "angle_precision" );
   GroupPoints->SpinBox_DX->setValue(anAngle);
 
   // init variables
@@ -235,6 +236,11 @@ bool TransformationGUI_RotationDlg::ClickOnApply()
     return false;
 
   initName();
+
+  myObjects.length(0);
+  myEditCurrentArgument = GroupPoints->LineEdit1;
+  myEditCurrentArgument->setText("");
+
   // activate selection and connect selection manager
   ConstructorsClicked(getConstructorId());
   return true;
@@ -263,6 +269,7 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument()
   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
   SALOME_ListIO aSelList;
   aSelMgr->selectedObjects(aSelList);
+  GEOM::GEOM_Object_var aSelectedObject;
 
   QString aName;
 
@@ -274,8 +281,6 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument()
     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
     if (!myObjects.length())
       return;
-    else
-      myEditCurrentArgument->setText(aName);
   }
   else {
     if (aSelList.Extent() != 1)
@@ -283,7 +288,7 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument()
 
     // nbSel == 1
     Standard_Boolean testResult = Standard_False;
-    GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
+    aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
 
     if (!testResult || CORBA::is_nil(aSelectedObject))
       return;
@@ -311,7 +316,7 @@ void TransformationGUI_RotationDlg::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);
@@ -328,36 +333,43 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument()
         }
       }
     }
+  }
+  
+  myEditCurrentArgument->setText(aName);
 
-    myEditCurrentArgument->setText(aName);
-
-    if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) {
-      myAxis = aSelectedObject;
-      if (!myAxis->_is_nil() && !myObjects.length())
-        GroupPoints->PushButton1->click();
-    }
-    else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
-      myCentPoint = aSelectedObject;
-      if (!myCentPoint->_is_nil() && myPoint1->_is_nil())
-        GroupPoints->PushButton4->click();
-    }
-    else if (myEditCurrentArgument == GroupPoints->LineEdit4) {
-      myPoint1 = aSelectedObject;
-      if (!myPoint1->_is_nil() && myPoint2->_is_nil())
-        GroupPoints->PushButton5->click();
-    }
-    else if (myEditCurrentArgument == GroupPoints->LineEdit5) {
-      myPoint2 = aSelectedObject;
-      if (!myPoint2->_is_nil() && !myObjects.length())
-        GroupPoints->PushButton1->click();
-    }
+  if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+    /*    if (myObjects.length()) {
+      if (getConstructorId() == 0 && myAxis->_is_nil() || getConstructorId() == 1 && myCentPoint->_is_nil() )
+        GroupPoints->PushButton2->click();
+        }*/   // here commented, because multiple objects can be selected IPAL 21437
+  }
+  else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) {
+    myAxis = aSelectedObject;
+    if (!myAxis->_is_nil() && !myObjects.length())
+      GroupPoints->PushButton1->click();
+  }
+  else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
+    myCentPoint = aSelectedObject;
+    if (!myCentPoint->_is_nil() && myPoint1->_is_nil())
+      GroupPoints->PushButton4->click();
+  }
+  else if (myEditCurrentArgument == GroupPoints->LineEdit4) {
+    myPoint1 = aSelectedObject;
+    if (!myPoint1->_is_nil() && myPoint2->_is_nil())
+      GroupPoints->PushButton5->click();
+  }
+  else if (myEditCurrentArgument == GroupPoints->LineEdit5) {
+    myPoint2 = aSelectedObject;
+    if (!myPoint2->_is_nil() && !myObjects.length())
+      GroupPoints->PushButton1->click();
   }
 
   // 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();
 }
@@ -377,7 +389,11 @@ void TransformationGUI_RotationDlg::SetEditCurrentArgument()
     myEditCurrentArgument = GroupPoints->LineEdit1;
 
     GroupPoints->PushButton2->setDown(false);
+    GroupPoints->PushButton4->setDown(false);
+    GroupPoints->PushButton5->setDown(false);
     GroupPoints->LineEdit2->setEnabled(false);
+    GroupPoints->LineEdit4->setEnabled(false);
+    GroupPoints->LineEdit5->setEnabled(false);
   }
   else if (send == GroupPoints->PushButton2) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
@@ -453,7 +469,7 @@ void TransformationGUI_RotationDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
-          this, SLOT( SelectionIntoArgument() ) );
+           this, SLOT( SelectionIntoArgument() ) );
 
   ConstructorsClicked( getConstructorId() );
 }
@@ -528,6 +544,8 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
 
   GEOM::GEOM_Object_var anObj;
 
+  GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
+
   switch (getConstructorId()) {
   case 0:
     {
@@ -536,11 +554,10 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
       if (toCreateCopy) {
         for (int i = 0; i < myObjects.length(); i++) {
           myCurrObject = myObjects[i];
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
+          anObj = anOper->RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
           if (!anObj->_is_nil()) {
             if(!IsPreview()) {
-              anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+              anObj->SetParameters(aParameters.join(":").toLatin1().constData());
             }
             objects.push_back(anObj._retn());
           }
@@ -549,15 +566,14 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
       else {
         for (int i = 0; i < myObjects.length(); i++) {
           myCurrObject = myObjects[i];
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            Rotate(myObjects[i], myAxis, GetAngle() * PI180);
+          anObj = anOper->Rotate(myObjects[i], myAxis, GetAngle() * PI180);
           if (!anObj->_is_nil()) {
             if(!IsPreview()) {
-              anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
-             updateAttributes(anObj, aParameters);
-           }
+              anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+              updateAttributes(anObj, aParameters);
+            }
             objects.push_back(anObj._retn());
-         }
+          }
         }
       }
       res = true;
@@ -568,8 +584,7 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
       if (toCreateCopy) {
         for (int i = 0; i < myObjects.length(); i++) {
           myCurrObject = myObjects[i];
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2);
+          anObj = anOper->RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2);
           if (!anObj->_is_nil())
             objects.push_back(anObj._retn());
         }
@@ -577,8 +592,7 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
       else {
         for (int i = 0; i < myObjects.length(); i++) {
           myCurrObject = myObjects[i];
-          anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-            RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
+          anObj = anOper->RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
           if (!anObj->_is_nil())
             objects.push_back(anObj._retn());
         }
@@ -607,7 +621,8 @@ void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr   theS
     anArgs[0] = myCurrObject;
     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
                                         /*theFindMethod=*/GEOM::FSM_Transformed,
-                                        /*theInheritFirstArg=*/true);
+                                        /*theInheritFirstArg=*/true,
+                                        mainFrame()->CheckBoxAddPrefix->isChecked());
   }
 }