Salome HOME
Copyright update 2022
[modules/geom.git] / src / TransformationGUI / TransformationGUI_MultiRotationDlg.cxx
index 6ac1ca9232ae1d232490b38d179604ea99a4e871..f47707a73c6b9b8e6aa7ea49a413f95874c2df1b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  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
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -174,11 +174,11 @@ void TransformationGUI_MultiRotationDlg::ConstructorsClicked (int constructorId)
 {
   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
 
-  myBase.nullify();
-  myVector.nullify();
+  //myBase.nullify();
+  //myVector.nullify();
 
-  GroupArgs->LineEdit1->setText("");
-  GroupArgs->LineEdit2->setText("");
+  //GroupArgs->LineEdit1->setText("");
+  //GroupArgs->LineEdit2->setText("");
 
   GroupArgs->SpinBox_DX1->setValue(myAng);
   GroupArgs->SpinBox_DY1->setValue(myNbTimes1);
@@ -268,14 +268,15 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
       myBase = aSelectedObject;
 
       // recompute myAng and myStep (Mantis issue 0021718)
-      GEOM::GEOM_IMeasureOperations_var anOper = getGeomEngine()->GetIMeasureOperations(getStudyId());
+      GEOM::GEOM_IMeasureOperations_var anOper = getGeomEngine()->GetIMeasureOperations();
       double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
       anOper->GetBoundingBox(myBase.get(), true, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
       if (anOper->IsDone()) {
         // angular step
         double diag = sqrt((Xmax-Xmin)*(Xmax-Xmin) + (Ymax-Ymin)*(Ymax-Ymin));
         double d = sqrt((0.5*(Xmax+Xmin))*(0.5*(Xmax+Xmin)) + (0.5*(Ymax+Ymin))*(0.5*(Ymax+Ymin)));
-        myAng = floor(2.0 * atan(diag/d) * 180.0 / M_PI);
+        if ( fabs(d) > 1.e-16 )
+         myAng = floor(2.0 * atan(diag/d) * 180.0 / M_PI);
         GroupArgs->SpinBox_DX1->setValue(myAng);
 
         // radial step
@@ -284,19 +285,19 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
       }
 
       if ( !myVector )
-       GroupArgs->PushButton2->click();
+        GroupArgs->PushButton2->click();
     }
     else if ( myEditCurrentArgument == GroupArgs->LineEdit2 ) {
       myVector = aSelectedObject;
       if ( !myBase )
-       GroupArgs->PushButton1->click();
+        GroupArgs->PushButton1->click();
     }
     
     // clear selection
-    disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
-    myGeomGUI->getApp()->selectionMgr()->clearSelected();
-    connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
-           this, SLOT(SelectionIntoArgument()));
+    // disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+    // myGeomGUI->getApp()->selectionMgr()->clearSelected();
+    // connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+    //         this, SLOT(SelectionIntoArgument()));
   }
   else {
     if ( myEditCurrentArgument == GroupArgs->LineEdit1 )
@@ -329,7 +330,7 @@ void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument()
   else if (send == GroupArgs->PushButton2) {
     myEditCurrentArgument = GroupArgs->LineEdit2;
 
-    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
+    localSelection(TopAbs_EDGE);
 
     GroupArgs->PushButton1->setDown(false);
     GroupArgs->LineEdit1->setEnabled(false);
@@ -448,7 +449,7 @@ void TransformationGUI_MultiRotationDlg::CheckAngleStep (bool isOn)
 //=================================================================================
 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation()
 {
-  return getGeomEngine()->GetITransformOperations(getStudyId());
+  return getGeomEngine()->GetITransformOperations();
 }
 
 //=================================================================================
@@ -526,7 +527,7 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
 
   if (!anObj->_is_nil()) {
     if (!IsPreview())
-      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+      anObj->SetParameters(aParameters.join(":").toUtf8().constData());
     objects.push_back(anObj._retn());
   }
 
@@ -549,12 +550,22 @@ void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
   }
 }
 
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> TransformationGUI_MultiRotationDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  res << myBase << myVector;
+  return res;
+}
+
 //=================================================================================
 // function : restoreSubShapes
 // purpose  :
 //=================================================================================
-void TransformationGUI_MultiRotationDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
-                                                           SALOMEDS::SObject_ptr theSObject)
+void TransformationGUI_MultiRotationDlg::restoreSubShapes (SALOMEDS::SObject_ptr theSObject)
 {
   if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
     // we pass here the first operation argument (object) through the list of arguments
@@ -563,7 +574,7 @@ void TransformationGUI_MultiRotationDlg::restoreSubShapes (SALOMEDS::Study_ptr
     GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
     anArgs->length(1);
     anArgs[0] = myBase.copy();
-    getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
+    getGeomEngine()->RestoreSubShapesSO(theSObject, anArgs,
                                         /*theFindMethod=*/GEOM::FSM_MultiTransformed,
                                         /*theInheritFirstArg=*/true,
                                         mainFrame()->CheckBoxAddPrefix->isChecked());