Salome HOME
TC 5.1.5: SIGSEGV on closing study
[modules/geom.git] / src / TransformationGUI / TransformationGUI_MultiRotationDlg.cxx
index 80d028e25d36d829edc69fff1cca0fb6e71d9224..aebe44d8263eac9c331907aa82a957eb605486bf 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_MultiRotationDlg.cxx
 // Author : Damien COQUERET, Open CASCADE S.A.S.
@@ -70,7 +71,7 @@ TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg
   mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
   mainFrame()->RadioButton3->close();
 
-  GroupPoints = new DlgRef_2Sel1Spin(centralWidget());
+  GroupPoints = new DlgRef_2Sel1SpinInt(centralWidget());
   GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_SIMPLE"));
   GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
   GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
@@ -124,23 +125,20 @@ void TransformationGUI_MultiRotationDlg::Init()
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
 
-  double SpecificStep1 = 5;
-  double SpecificStep2 = 1;
+  int SpecificStep1 = 5;
+  int SpecificStep2 = 1;
   // min, max, step and decimals for spin boxes & initial values
-  initSpinBox(GroupPoints->SpinBox_DX, 1.0, 999, SpecificStep2, 10);
+  initSpinBox(GroupPoints->SpinBox_DX, 1, 999, SpecificStep2);
   GroupPoints->SpinBox_DX->setValue(myNbTimes1);
-  GroupPoints->SpinBox_DX->setDecimals(0);
 
-  initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox(GroupDimensions->SpinBox_DY1, 1.0, 999, SpecificStep2, 10);
-  initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
-  initSpinBox(GroupDimensions->SpinBox_DY2, 1.0, 999, SpecificStep2, 10);
+  initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, "angle_precision" );
+  initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep2);
+  initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step,"length_precision" );
+  initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep2);
   GroupDimensions->SpinBox_DX1->setValue(myAng);
   GroupDimensions->SpinBox_DY1->setValue(myNbTimes1);
   GroupDimensions->SpinBox_DX2->setValue(myStep);
   GroupDimensions->SpinBox_DY2->setValue(myNbTimes2);
-  GroupDimensions->SpinBox_DY1->setDecimals(0);
-  GroupDimensions->SpinBox_DY2->setDecimals(0);
 
   // init variables
   myAng = 45.0;
@@ -155,6 +153,8 @@ void TransformationGUI_MultiRotationDlg::Init()
 
   myBase = myVector = GEOM::GEOM_Object::_nil();
 
+  mainFrame()->GroupBoxPublish->show();
+
   // signals and slots connections
   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@@ -171,11 +171,11 @@ void TransformationGUI_MultiRotationDlg::Init()
   connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
   connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
 
-  connect(GroupPoints->SpinBox_DX,      SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(GroupPoints->SpinBox_DX,      SIGNAL(valueChanged(int)),    this, SLOT(ValueChangedInSpinBox(int)));
   connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
-  connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)),    this, SLOT(ValueChangedInSpinBox(int)));
   connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
-  connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)),    this, SLOT(ValueChangedInSpinBox(int)));
 
   connect(GroupDimensions->SpinBox_DX1,SIGNAL(textChanged( const QString& )),
           this, SLOT(TextValueChangedInSpinBox( const QString& )));
@@ -195,11 +195,13 @@ void TransformationGUI_MultiRotationDlg::Init()
 //=================================================================================
 void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep (double step)
 {
-  GroupPoints->SpinBox_DX->setSingleStep(step);
-  GroupDimensions->SpinBox_DX1->setSingleStep(step);
-  GroupDimensions->SpinBox_DY1->setSingleStep(step);
   GroupDimensions->SpinBox_DX2->setSingleStep(step);
-  GroupDimensions->SpinBox_DY2->setSingleStep(step);
+  
+  // san: Commented so as not to override specific step settings
+  //GroupPoints->SpinBox_DX->setSingleStep((int)step);
+  //GroupDimensions->SpinBox_DX1->setSingleStep(step);
+  //GroupDimensions->SpinBox_DY1->setSingleStep((int)step);
+  //GroupDimensions->SpinBox_DY2->setSingleStep((int)step);
 }
 
 //=================================================================================
@@ -332,7 +334,7 @@ void TransformationGUI_MultiRotationDlg::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());
           myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex);
@@ -452,7 +454,7 @@ void TransformationGUI_MultiRotationDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
-          this, SLOT( SelectionIntoArgument() ) );
+           this, SLOT( SelectionIntoArgument() ) );
 
   ConstructorsClicked( getConstructorId() );
 }
@@ -478,6 +480,7 @@ void TransformationGUI_MultiRotationDlg::TextValueChangedInSpinBox(const QString
     GroupDimensions->CheckButton1->setChecked(false);
   GroupDimensions->CheckButton1->setEnabled(isDigit);
 }
+
 //=================================================================================
 // function : ValueChangedInSpinBox()
 // purpose  :
@@ -486,14 +489,26 @@ void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (double newValue)
 {
   QObject* send = (QObject*)sender();
 
-  if (send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DY1)
-    myNbTimes1 = (int)newValue;
-  else if (send == GroupDimensions->SpinBox_DX1)
+  if (send == GroupDimensions->SpinBox_DX1)
     myAng = newValue;
   else if (send == GroupDimensions->SpinBox_DX2)
     myStep = newValue;
+
+  displayPreview();
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose  :
+//=================================================================================
+void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (int newValue)
+{
+  QObject* send = (QObject*)sender();
+
+  if (send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DY1)
+    myNbTimes1 = newValue;
   else if (send == GroupDimensions->SpinBox_DY2)
-    myNbTimes2 = (int)newValue;
+    myNbTimes2 = newValue;
 
   displayPreview();
 }
@@ -508,9 +523,7 @@ void TransformationGUI_MultiRotationDlg::ReverseAngle()
 
   int aConstructorId = getConstructorId();
 
-  if (aConstructorId == 0)
-    GroupPoints->SpinBox_DX->setValue(myAng);
-  else if (aConstructorId == 1)
+  if (aConstructorId == 1)
     GroupDimensions->SpinBox_DX1->setValue(myAng);
 
   displayPreview();
@@ -557,11 +570,12 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
   GEOM::GEOM_Object_var anObj;
   QStringList aParameters;
 
+  GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
+
   switch (getConstructorId()) {
   case 0:
     if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
-      anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-        MultiRotate1D(myBase, myVector, myNbTimes1);
+      anObj = anOper->MultiRotate1D(myBase, myVector, myNbTimes1);
       if(!IsPreview())
         aParameters<<GroupPoints->SpinBox_DX->text();
       res = true;
@@ -569,8 +583,7 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
     break;
   case 1:
     if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
-      anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
-        MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2);
+      anObj = anOper->MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2);
       if(!IsPreview()) {
         aParameters<<GroupDimensions->SpinBox_DX1->text();
         aParameters<<GroupDimensions->SpinBox_DY1->text();
@@ -584,7 +597,7 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
 
   if (!anObj->_is_nil()) {
     if(!IsPreview())
-      anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
     objects.push_back(anObj._retn());
   }
 
@@ -609,3 +622,24 @@ void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
   }
   addSubshapesToFather(objMap);
 }
+
+//=================================================================================
+// function : restoreSubShapes
+// purpose  :
+//=================================================================================
+void TransformationGUI_MultiRotationDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
+                                                           SALOMEDS::SObject_ptr theSObject)
+{
+  if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
+    // we pass here the first operation argument (object) through the list of arguments
+    // because the rotation operation place its arguments in the data structure in another order,
+    // and we need to point the first argument directly
+    GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
+    anArgs->length(1);
+    anArgs[0] = myBase;
+    getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
+                                        /*theFindMethod=*/GEOM::FSM_Transformed,
+                                        /*theInheritFirstArg=*/true,
+                                        mainFrame()->CheckBoxAddPrefix->isChecked());
+  }
+}