Improve dump python.

This commit is contained in:
rnv 2008-12-05 14:35:34 +00:00
parent 50ec5b5cbf
commit eb02acbf12
6 changed files with 122 additions and 49 deletions

View 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();

View 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;

View 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;

View 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,23 +456,38 @@ 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));
}
@ -484,6 +500,7 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
ConstructorsClicked(GetConstructorId());
mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
}
@ -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);

View File

@ -89,6 +89,8 @@ private:
SMESH_Actor* myActor;
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
SMESH::SMESH_IDSource_var mySelectedObject;
QGroupBox* ConstructorsBox;
QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1;

View 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.