From d09ed2c65d455f661711c8d5633469b942f7c4fc Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 5 Dec 2008 10:01:50 +0000 Subject: [PATCH] Improve dump python. --- src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx | 65 +++++++++++++++++++-------- src/SMESHGUI/SMESHGUI_SymmetryDlg.h | 2 + src/SMESH_I/SMESH_NoteBook.cxx | 16 ++++--- src/SMESH_SWIG/smeshDC.py | 10 +++-- 4 files changed, 65 insertions(+), 28 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index 6a41b5f05..5b7970ac0 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -90,7 +90,8 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( 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_SYMMETRY_POINT"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); @@ -483,39 +484,57 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply() SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); switch ( actionButton ) { - case MOVE_ELEMS_BUTTON: - aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); + case MOVE_ELEMS_BUTTON: { + if(CheckBoxMesh->isChecked()) + aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, false ); + else + aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); + if( !myMesh->_is_nil()) myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; - case COPY_ELEMS_BUTTON: + } + case COPY_ELEMS_BUTTON: { + SMESH::ListOfGroups_var groups; if ( makeGroups ) - SMESH::ListOfGroups_var groups = - aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); + if(CheckBoxMesh->isChecked()) + groups = aMeshEditor->MirrorObjectMakeGroups(mySelectedObject, aMirror, aMirrorType); + else + groups = aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); else - aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true); + 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; - case MAKE_MESH_BUTTON: - SMESH::SMESH_Mesh_var mesh = - aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, - LineEditNewMesh->text().toLatin1().data()); + } + case MAKE_MESH_BUTTON: { + SMESH::SMESH_Mesh_var mesh; + if(CheckBoxMesh->isChecked()) + mesh = aMeshEditor->MirrorObjectMakeMesh(mySelectedObject, aMirror, aMirrorType, makeGroups, + LineEditNewMesh->text().toLatin1().data()); + else + mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, + LineEditNewMesh->text().toLatin1().data()); if( !mesh->_is_nil()) mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); + break; + } } } 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; } @@ -681,8 +700,13 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from 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) return; @@ -694,17 +718,20 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() aNbUnits++; } } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //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]); } aNbUnits = anElementsIds->length(); + } else { // GROUP // get smesh group SMESH::SMESH_GroupBase_var aGroup = @@ -720,14 +747,14 @@ void SMESHGUI_SymmetryDlg::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_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h index 21a36753f..fdfdce45e 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -84,6 +84,8 @@ private: QWidget* myEditCurrentArgument; /* Current LineEdit */ + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; diff --git a/src/SMESH_I/SMESH_NoteBook.cxx b/src/SMESH_I/SMESH_NoteBook.cxx index e03cc0a9e..d28afb5c0 100644 --- a/src/SMESH_I/SMESH_NoteBook.cxx +++ b/src/SMESH_I/SMESH_NoteBook.cxx @@ -462,13 +462,17 @@ void SMESH_NoteBook::ReplaceVariables() } aStates->IncrementState(); } - else if(aMethod.IsEqual("Rotate") || - aMethod.IsEqual("RotateMakeGroups") || - aMethod.IsEqual("RotateMakeMesh") || - aMethod.IsEqual("RotationSweep") || + else if(aMethod.IsEqual("Rotate") || + aMethod.IsEqual("RotateMakeGroups") || + aMethod.IsEqual("RotateMakeMesh") || + aMethod.IsEqual("RotationSweep") || aMethod.IsEqual("RotationSweepMakeGroups") || - aMethod.IsEqual("Mirror") || - aMethod.IsEqual("MirrorMakeGroups")) { + aMethod.IsEqual("Mirror") || + aMethod.IsEqual("MirrorMakeMesh") || + aMethod.IsEqual("MirrorMakeGroups") || + aMethod.IsEqual("MirrorObject") || + aMethod.IsEqual("MirrorObjectMakeMesh") || + aMethod.IsEqual("MirrorObjectMakeGroups")) { bool isSubstitute = false; int anArgIndex = 0; for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index a8ce37ada..1108b4fcb 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -318,10 +318,10 @@ def ParseDirStruct(Dir): # Returns list of variable values from salome notebook def ParseAxisStruct(Axis): - Parameters = ":::::" + Parameters = 5*variable_separator if isinstance(Axis, AxisStructStr): - Parameters = str(Axis.xStr) + ":" + str(Axis.yStr) + ":" + str(Axis.zStr) + ":" - Parameters += str(Axis.dxStr) + ":" + str(Axis.dyStr) + ":" + str(Axis.dzStr) + Parameters = str(Axis.xStr) + variable_separator + str(Axis.yStr) + variable_separator + str(Axis.zStr) + variable_separator + Parameters += str(Axis.dxStr) + variable_separator + str(Axis.dyStr) + variable_separator + str(Axis.dzStr) Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz) return Axis, Parameters @@ -2692,6 +2692,8 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType) self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy) @@ -2711,8 +2713,10 @@ class Mesh: theObject = theObject.GetMesh() if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh( self.smeshpyD,self.geompyD,mesh ) ## Translates the elements -- 2.39.2