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")));
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));
}
actionButton == MAKE_MESH_BUTTON )
mySMESHGUI->updateObjBrowser(true); // new groups may appear
Init(false);
+ mySelectedObject = SMESH::SMESH_IDSource::_nil();
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);
}
}
} 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)
}
break;
}
+
}
myEditCurrentArgument->setFocus();
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
+ SMESH::SMESH_IDSource_var mySelectedObject;
QGroupBox* GroupConstructors;
QRadioButton* RadioButton1;
}
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;
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")));
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;
}
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;
}
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);
SMESH_Actor* myActor;
SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
+ SMESH::SMESH_IDSource_var mySelectedObject;
+
QGroupBox* ConstructorsBox;
QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1;
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)
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
## 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)
## 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.