From: rnv Date: Fri, 5 Dec 2008 14:35:34 +0000 (+0000) Subject: Improve dump python. X-Git-Tag: TG_DumpPython_Extension_3_1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb02acbf1217569ff6b47c7b9b46e5d200206a73;p=modules%2Fsmesh.git Improve dump python. --- diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index b683f9f98..94cb0ceee 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -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(IO)->_is_nil()) { //MESH + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + mySelectedObject = SMESH::IObjectToInterface(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(IO)->_is_nil()) { //SUBMESH - // get submesh + // get submesh SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(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(IO); + SMESH::IObjectToInterface(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(); diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h index fbb2ee08d..d128be586 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.h +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -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; diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index 5b7970ac0..fbf3e9f81 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -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; diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index 0fa72fd3b..e9f5cc220 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -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(IO)->_is_nil()) { //MESH + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP + mySelectedObject = SMESH::IObjectToInterface(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); diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.h b/src/SMESHGUI/SMESHGUI_TranslationDlg.h index bce8b7f18..6ee822987 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.h +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.h @@ -89,6 +89,8 @@ private: SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; + SMESH::SMESH_IDSource_var mySelectedObject; + QGroupBox* ConstructorsBox; QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index 1108b4fcb..9ba0fd56c 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -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.