Salome HOME
Improve dump python.
authorrnv <rnv@opencascade.com>
Fri, 5 Dec 2008 14:35:34 +0000 (14:35 +0000)
committerrnv <rnv@opencascade.com>
Fri, 5 Dec 2008 14:35:34 +0000 (14:35 +0000)
src/SMESHGUI/SMESHGUI_RotationDlg.cxx
src/SMESHGUI/SMESHGUI_RotationDlg.h
src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx
src/SMESHGUI/SMESHGUI_TranslationDlg.cxx
src/SMESHGUI/SMESHGUI_TranslationDlg.h
src/SMESH_SWIG/smeshDC.py

index b683f9f98128290cc412ecd5b6bcb533caf28348..94cb0ceeee3f01ca94d27d3d2af30a3eadd4484d 100644 (file)
@@ -89,7 +89,8 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action
 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule )
   : QDialog( SMESH::GetDesktop( theModule ) ),
     mySMESHGUI( theModule ),
-    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+    mySelectedObject(SMESH::SMESH_IDSource::_nil())
 {
   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION")));
   QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
@@ -399,23 +400,38 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
       switch ( actionButton ) {
       case MOVE_ELEMS_BUTTON:
-        aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
+        if(CheckBoxMesh->isChecked())
+          aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, false);
+        else
+            aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
        if( !myMesh->_is_nil())
          myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
         break;
       case COPY_ELEMS_BUTTON:
-        if ( makeGroups )
-          SMESH::ListOfGroups_var groups = 
-            aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
-        else
-          aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
+        if ( makeGroups ) {
+          SMESH::ListOfGroups_var groups;
+          if(CheckBoxMesh->isChecked())
+            groups = aMeshEditor->RotateObjectMakeGroups(mySelectedObject, anAxis, anAngle);
+          else
+            groups = aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
+        }
+        else {
+          if(CheckBoxMesh->isChecked())
+            aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, true);
+          else 
+            aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
+        }
        if( !myMesh->_is_nil())
          myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
         break;
       case MAKE_MESH_BUTTON:
-        SMESH::SMESH_Mesh_var mesh = 
-          aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
-                                      LineEditNewMesh->text().toLatin1().data());
+        SMESH::SMESH_Mesh_var mesh;
+        if(CheckBoxMesh->isChecked())
+          mesh = aMeshEditor->RotateObjectMakeMesh(mySelectedObject, anAxis, anAngle, makeGroups,
+                                                   LineEditNewMesh->text().toLatin1().data());
+        else 
+          mesh = aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
+                                             LineEditNewMesh->text().toLatin1().data());
        if( !mesh->_is_nil())
          mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
       }
@@ -427,6 +443,7 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
          actionButton == MAKE_MESH_BUTTON )
       mySMESHGUI->updateObjBrowser(true); // new groups may appear
     Init(false);
+    mySelectedObject = SMESH::SMESH_IDSource::_nil();
     SelectionIntoArgument();
   }
 
@@ -594,13 +611,18 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument()
     if (CheckBoxMesh->isChecked()) {
       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
 
-      if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
+      if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH
+        mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+      }
+      else
+        return;
         // get IDs from mesh
-        SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
-        if (!aSMDSMesh)
+        /*
+          SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
+          if (!aSMDSMesh)
           return;
 
-        for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
+          for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
           const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
           if (e) {
             myElementsId += QString(" %1").arg(i);
@@ -608,40 +630,41 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument()
           }
         }
       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
-        // get submesh
+      // get submesh
         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
-
+        
         // get IDs from submesh
         SMESH::long_array_var anElementsIds = new SMESH::long_array;
         anElementsIds = aSubMesh->GetElementsId();
         for (int i = 0; i < anElementsIds->length(); i++) {
-          myElementsId += QString(" %1").arg(anElementsIds[i]);
-        }
+        myElementsId += QString(" %1").arg(anElementsIds[i]);
+          }
         aNbUnits = anElementsIds->length();
       } else { // GROUP
         // get smesh group
         SMESH::SMESH_GroupBase_var aGroup =
-          SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
+        SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
         if (aGroup->_is_nil())
-          return;
+        return;
 
-        // get IDs from smesh group
+          // get IDs from smesh group
         SMESH::long_array_var anElementsIds = new SMESH::long_array;
         anElementsIds = aGroup->GetListOfID();
         for (int i = 0; i < anElementsIds->length(); i++) {
-          myElementsId += QString(" %1").arg(anElementsIds[i]);
-        }
+        myElementsId += QString(" %1").arg(anElementsIds[i]);
+          }
         aNbUnits = anElementsIds->length();
-      }
-    } else {
+        }
+        */
+      } else {
       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
       myElementsId = aString;
-    }
-
-    if (aNbUnits < 1)
-      return;
+      if (aNbUnits < 1)
+        return;
+      }
 
     myNbOkElements = true;
+
   } else {
     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
     if (aNbUnits != 1)
@@ -724,6 +747,7 @@ void SMESHGUI_RotationDlg::SetEditCurrentArgument()
       }
       break;
     }
+
   }
 
   myEditCurrentArgument->setFocus();
index fbb2ee08dc5d4ecd955f9908f1cc4325264c0267..d128be5864f8e4202a071575dbc7ae1bd30e5bae 100644 (file)
@@ -87,6 +87,7 @@ private:
   SMESH::SMESH_Mesh_var  myMesh;
   SMESH_Actor*           myActor;
   SMESH_LogicalFilter*   myMeshOrSubMeshOrGroupFilter;
+  SMESH::SMESH_IDSource_var mySelectedObject;
   
   QGroupBox*             GroupConstructors;
   QRadioButton*          RadioButton1;
index 5b7970ac042a0446725d78b5d02f94885f7a17ab..fbf3e9f819eaebaa72dcb512411dc6fae0d2470c 100644 (file)
@@ -496,16 +496,18 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
       }
       case COPY_ELEMS_BUTTON: {
         SMESH::ListOfGroups_var groups;
-        if ( makeGroups )
+        if ( makeGroups ) {
           if(CheckBoxMesh->isChecked())
             groups = aMeshEditor->MirrorObjectMakeGroups(mySelectedObject, aMirror, aMirrorType);
           else
             groups = aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType);
-        else
+        }
+        else {
           if(CheckBoxMesh->isChecked())
             aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, true);
           else
             aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
+        }
        if( !myMesh->_is_nil())
          myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
         break;
index 0fa72fd3bcd11d1065deaf032e7b1c3de73f979a..e9f5cc2203f011c861734e23ffd0a8281fbcc051 100644 (file)
@@ -90,7 +90,8 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action
 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule )
   : QDialog( SMESH::GetDesktop( theModule ) ),
     mySMESHGUI( theModule ),
-    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+    mySelectedObject(SMESH::SMESH_IDSource::_nil())
 {
   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
   QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
@@ -455,38 +456,54 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
       switch ( actionButton ) {
       case MOVE_ELEMS_BUTTON:
-        aMeshEditor->Translate(anElementsId, aVector, false);
+        if(CheckBoxMesh->isChecked())
+          aMeshEditor->TranslateObject(mySelectedObject, aVector, false);
+        else
+          aMeshEditor->Translate(anElementsId, aVector, false);
        if( !myMesh->_is_nil())
          myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
         break;
       case COPY_ELEMS_BUTTON:
-        if ( makeGroups )
-          SMESH::ListOfGroups_var groups = 
-            aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
-        else
-          aMeshEditor->Translate(anElementsId, aVector, true);
+        if ( makeGroups ) {
+          SMESH::ListOfGroups_var groups; 
+          if(CheckBoxMesh->isChecked())
+            groups = aMeshEditor->TranslateObjectMakeGroups(mySelectedObject,aVector);
+          else
+            groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
+        }
+        else {
+          if(CheckBoxMesh->isChecked())
+            aMeshEditor->TranslateObject(mySelectedObject, aVector, true);
+          else
+            aMeshEditor->Translate(anElementsId, aVector, true);
+        }
        if( !myMesh->_is_nil())
          myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
         break;
       case MAKE_MESH_BUTTON:
-        SMESH::SMESH_Mesh_var mesh = 
-          aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
-                                         LineEditNewMesh->text().toLatin1().data());
+        SMESH::SMESH_Mesh_var mesh; 
+        if(CheckBoxMesh->isChecked())
+          mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups,
+                                                      LineEditNewMesh->text().toLatin1().data());
+        else
+          mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
+                                                LineEditNewMesh->text().toLatin1().data());
        if( !mesh->_is_nil())
          mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters));
       }
     } catch (...) {
     }
-
+    
     SMESH::UpdateView();
     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
          actionButton == MAKE_MESH_BUTTON )
       mySMESHGUI->updateObjBrowser(true); // new groups may appear
     Init(false);
     ConstructorsClicked(GetConstructorId());
+    mySelectedObject = SMESH::SMESH_IDSource::_nil();
     SelectionIntoArgument();
   }
-
+  
   return true;
 }
 
@@ -653,8 +670,13 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument()
     if (CheckBoxMesh->isChecked()) {
       SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
 
-      if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
+      if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP
+        mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+      }
+      else
+        return;
         // get IDs from mesh
+        /*
         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
         if (!aSMDSMesh)
           return;
@@ -692,14 +714,14 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument()
         }
         aNbUnits = anElementsIds->length();
       }
+        */
     } else {
       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
       myElementsId = aString;
+      if (aNbUnits < 1)
+        return;  
     }
 
-    if (aNbUnits < 1)
-      return;
-
     myNbOkElements = true;
   } else {
     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
index bce8b7f18d328cf3fefc4d0732ea30117c742b2c..6ee82298721ba0fc99dc04d699cd51cc49e8b94c 100644 (file)
@@ -89,6 +89,8 @@ private:
   SMESH_Actor*           myActor;
   SMESH_LogicalFilter*   myMeshOrSubMeshOrGroupFilter;
 
+  SMESH::SMESH_IDSource_var mySelectedObject;
+
   QGroupBox*             ConstructorsBox;
   QButtonGroup*          GroupConstructors;
   QRadioButton*          RadioButton1;
index 1108b4fcbfceb38d38b7af53665cb74ad00c7948..9ba0fd56c811bf3e76a7d635b43f8ed3a0960420 100644 (file)
@@ -2767,6 +2767,8 @@ class Mesh:
             theObject = theObject.GetMesh()
         if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
             Vector = self.smeshpyD.GetDirStruct(Vector)
+        Vector,Parameters = ParseDirStruct(Vector)
+        self.mesh.SetParameters(Parameters)
         if Copy and MakeGroups:
             return self.editor.TranslateObjectMakeGroups(theObject, Vector)
         self.editor.TranslateObject(theObject, Vector, Copy)
@@ -2784,7 +2786,9 @@ class Mesh:
             theObject = theObject.GetMesh()
         if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
             Vector = self.smeshpyD.GetDirStruct(Vector)
+        Vector,Parameters = ParseDirStruct(Vector)
         mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
+        mesh.SetParameters(Parameters)
         return Mesh( self.smeshpyD, self.geompyD, mesh )
 
     ## Rotates the elements
@@ -2843,16 +2847,25 @@ class Mesh:
     ## Rotates the object
     #  @param theObject the object to rotate( mesh, submesh, or group)
     #  @param Axis the axis of rotation (AxisStruct or geom line)
-    #  @param AngleInRadians the angle of rotation (in radians)
+    #  @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
     #  @param Copy allows copying the rotated elements
     #  @param MakeGroups forces the generation of new groups from existing ones (if Copy)
     #  @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
     #  @ingroup l2_modif_trsf
     def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
+        flag = False
+        if isinstance(AngleInRadians,str):
+            flag = True
+        AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
+        if flag:
+            AngleInRadians = DegreesToRadians(AngleInRadians)
         if (isinstance(theObject, Mesh)):
             theObject = theObject.GetMesh()
         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
             Axis = self.smeshpyD.GetAxisStruct(Axis)
+        Axis,AxisParameters = ParseAxisStruct(Axis)
+        Parameters = AxisParameters + ":" + Parameters
+        self.mesh.SetParameters(Parameters)
         if Copy and MakeGroups:
             return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
         self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
@@ -2861,18 +2874,27 @@ class Mesh:
     ## Creates a new mesh from the rotated object
     #  @param theObject the object to rotate (mesh, submesh, or group)
     #  @param Axis the axis of rotation (AxisStruct or geom line)
-    #  @param AngleInRadians the angle of rotation (in radians)
+    #  @param AngleInRadians the angle of rotation (in radians)  or a name of variable which defines angle in degrees
     #  @param MakeGroups forces the generation of new groups from existing ones
     #  @param NewMeshName the name of the newly created mesh
     #  @return instance of Mesh class
     #  @ingroup l2_modif_trsf
     def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
+        flag = False
+        if isinstance(AngleInRadians,str):
+            flag = True
+        AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
+        if flag:
+            AngleInRadians = DegreesToRadians(AngleInRadians)
         if (isinstance( theObject, Mesh )):
             theObject = theObject.GetMesh()
         if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
             Axis = self.smeshpyD.GetAxisStruct(Axis)
+        Axis,AxisParameters = ParseAxisStruct(Axis)
+        Parameters = AxisParameters + ":" + Parameters
         mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
                                                        MakeGroups, NewMeshName)
+        mesh.SetParameters(Parameters)
         return Mesh( self.smeshpyD, self.geompyD, mesh )
 
     ## Finds groups of ajacent nodes within Tolerance.