1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_RotationDlg.cxx
23 // Author : Michael ZORIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_RotationDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
36 #include <SMESH_Actor.h>
37 #include <SMESH_TypeFilter.hxx>
38 #include <SMESH_LogicalFilter.hxx>
39 #include <SMDS_Mesh.hxx>
41 // SALOME GUI includes
42 #include <SUIT_Desktop.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ResourceMgr.h>
47 #include <LightApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
50 #include <SVTK_ViewModel.h>
51 #include <SVTK_ViewWindow.h>
52 #include <SALOME_ListIO.hxx>
54 // SALOME KERNEL includes
55 #include <SALOMEDSClient_SObject.hxx>
58 #include <TColStd_MapOfInteger.hxx>
61 #include <QApplication>
62 #include <QButtonGroup>
66 #include <QPushButton>
67 #include <QRadioButton>
69 #include <QHBoxLayout>
70 #include <QVBoxLayout>
71 #include <QGridLayout>
75 #include <SALOMEconfig.h>
76 #include CORBA_SERVER_HEADER(SMESH_Group)
77 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
79 enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action type
84 //=================================================================================
85 // class : SMESHGUI_RotationDlg()
87 //=================================================================================
88 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule )
89 : QDialog( SMESH::GetDesktop( theModule ) ),
90 mySMESHGUI( theModule ),
91 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
93 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION")));
94 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
97 setAttribute(Qt::WA_DeleteOnClose, true);
98 setWindowTitle(tr("SMESH_ROTATION_TITLE"));
99 setSizeGripEnabled(true);
101 QVBoxLayout* SMESHGUI_RotationDlgLayout = new QVBoxLayout(this);
102 SMESHGUI_RotationDlgLayout->setSpacing(SPACING);
103 SMESHGUI_RotationDlgLayout->setMargin(MARGIN);
105 /***************************************************************/
106 GroupConstructors = new QGroupBox(tr("SMESH_ROTATION"), this);
107 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
108 GroupConstructorsLayout->setSpacing(SPACING);
109 GroupConstructorsLayout->setMargin(MARGIN);
111 RadioButton1= new QRadioButton(GroupConstructors);
112 RadioButton1->setIcon(image0);
114 GroupConstructorsLayout->addWidget(RadioButton1);
115 GroupConstructorsLayout->addStretch();
117 /***************************************************************/
118 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
119 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
120 GroupArgumentsLayout->setSpacing(SPACING);
121 GroupArgumentsLayout->setMargin(MARGIN);
123 // Controls for elements selection
124 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
125 SelectElementsButton = new QPushButton(GroupArguments);
126 SelectElementsButton->setIcon(image1);
127 LineEditElements = new QLineEdit(GroupArguments);
128 LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
130 // Control for the whole mesh selection
131 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
133 // Controls for axis defining
134 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
135 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
136 GroupAxisLayout->setSpacing(SPACING);
137 GroupAxisLayout->setMargin(MARGIN);
139 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
140 SelectPointButton = new QPushButton(GroupAxis);
141 SelectPointButton->setIcon(image1);
143 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
144 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
145 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
146 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
147 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
148 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
150 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
151 SelectVectorButton = new QPushButton(GroupAxis);
152 SelectVectorButton->setIcon(image1);
154 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
155 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
156 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
157 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
158 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
159 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
161 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
162 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
163 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
164 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
165 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
166 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
167 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
168 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
169 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
170 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
171 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
172 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
173 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
174 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
175 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
176 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
178 // Controls for angle defining
179 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupArguments);
180 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments);
183 ActionBox = new QGroupBox(tr("ACTION"), GroupArguments);
184 ActionGroup = new QButtonGroup(GroupArguments);
185 QVBoxLayout* ActionBoxLayout = new QVBoxLayout(ActionBox);
186 ActionBoxLayout->setSpacing(SPACING);
187 ActionBoxLayout->setMargin(MARGIN);
189 QRadioButton* aMoveElements = new QRadioButton(tr("SMESH_MOVE_ELEMENTS"), ActionBox);
190 QRadioButton* aCopyElements = new QRadioButton(tr("SMESH_COPY_ELEMENTS"), ActionBox);
191 QRadioButton* aCreateMesh = new QRadioButton(tr("SMESH_CREATE_MESH"), ActionBox);
193 ActionBoxLayout->addWidget(aMoveElements);
194 ActionBoxLayout->addWidget(aCopyElements);
195 ActionBoxLayout->addWidget(aCreateMesh);
196 ActionGroup->addButton(aMoveElements, MOVE_ELEMS_BUTTON);
197 ActionGroup->addButton(aCopyElements, COPY_ELEMS_BUTTON);
198 ActionGroup->addButton(aCreateMesh, MAKE_MESH_BUTTON);
200 // CheckBox for groups generation
201 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
203 // Name of a mesh to create
204 LineEditNewMesh = new QLineEdit(GroupArguments);
206 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
207 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
208 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 2);
209 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
210 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
211 GroupArgumentsLayout->addWidget(TextLabelAngle, 3, 0, 1, 2);
212 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
213 GroupArgumentsLayout->addWidget(ActionBox, 4, 0, 3, 3);
214 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 3);
215 GroupArgumentsLayout->addWidget(LineEditNewMesh, 6, 3);
217 /***************************************************************/
218 GroupButtons = new QGroupBox(this);
219 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
220 GroupButtonsLayout->setSpacing(SPACING);
221 GroupButtonsLayout->setMargin(MARGIN);
223 buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
224 buttonOk->setAutoDefault(true);
225 buttonOk->setDefault(true);
226 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
227 buttonApply->setAutoDefault(true);
228 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
229 buttonCancel->setAutoDefault(true);
230 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
231 buttonHelp->setAutoDefault(true);
233 GroupButtonsLayout->addWidget(buttonOk);
234 GroupButtonsLayout->addSpacing(10);
235 GroupButtonsLayout->addWidget(buttonApply);
236 GroupButtonsLayout->addSpacing(10);
237 GroupButtonsLayout->addStretch();
238 GroupButtonsLayout->addWidget(buttonCancel);
239 GroupButtonsLayout->addWidget(buttonHelp);
241 /***************************************************************/
242 SMESHGUI_RotationDlgLayout->addWidget(GroupConstructors);
243 SMESHGUI_RotationDlgLayout->addWidget(GroupArguments);
244 SMESHGUI_RotationDlgLayout->addWidget(GroupButtons);
246 /* Initialisations */
247 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
248 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
249 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
250 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
251 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
252 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
254 SpinBox_Angle->RangeStepAndValidator(-360.0, +360.0, 5.0, 3);
257 RadioButton1->setChecked(true);
259 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
261 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
263 // Costruction of the logical filter
264 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
265 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
267 QList<SUIT_SelectionFilter*> aListOfFilters;
268 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
269 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
271 myMeshOrSubMeshOrGroupFilter =
272 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
274 myHelpFileName = "rotation_page.html";
278 /* signals and slots connections */
279 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
280 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
281 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
282 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
284 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
285 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
286 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
288 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
289 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
290 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
292 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
293 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
294 /* to close dialog if study change */
295 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
296 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
297 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
298 connect(ActionGroup, SIGNAL(buttonClicked(int)), SLOT(onActionClicked(int)));
300 onActionClicked(MOVE_ELEMS_BUTTON);
303 //=================================================================================
304 // function : ~SMESHGUI_RotationDlg()
305 // purpose : Destroys the object and frees any allocated resources
306 //=================================================================================
307 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
311 //=================================================================================
314 //=================================================================================
315 void SMESHGUI_RotationDlg::Init (bool ResetControls)
319 myEditCurrentArgument = (QWidget*)LineEditElements;
320 LineEditElements->setFocus();
324 buttonOk->setEnabled(false);
325 buttonApply->setEnabled(false);
328 myMesh = SMESH::SMESH_Mesh::_nil();
331 SpinBox_X->SetValue(0.0);
332 SpinBox_Y->SetValue(0.0);
333 SpinBox_Z->SetValue(0.0);
334 SpinBox_DX->SetValue(0.0);
335 SpinBox_DY->SetValue(0.0);
336 SpinBox_DZ->SetValue(0.0);
338 SpinBox_Angle->SetValue(45);
340 ActionGroup->button( MOVE_ELEMS_BUTTON )->setChecked(true);
341 CheckBoxMesh->setChecked(false);
342 // MakeGroupsCheck->setChecked(false);
343 // MakeGroupsCheck->setEnabled(false);
344 // onSelectMesh(false);
347 onSelectMesh(CheckBoxMesh->isChecked());
350 //=================================================================================
351 // function : ClickOnApply()
353 //=================================================================================
354 void SMESHGUI_RotationDlg::ClickOnApply()
356 if (mySMESHGUI->isActiveStudyLocked())
359 if (myNbOkElements && IsAxisOk()) {
360 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
362 SMESH::long_array_var anElementsId = new SMESH::long_array;
364 anElementsId->length(aListElementsId.count());
365 for (int i = 0; i < aListElementsId.count(); i++)
366 anElementsId[i] = aListElementsId[i].toInt();
368 SMESH::AxisStruct anAxis;
370 anAxis.x = SpinBox_X->GetValue();
371 anAxis.y = SpinBox_Y->GetValue();
372 anAxis.z = SpinBox_Z->GetValue();;
373 anAxis.vx = SpinBox_DX->GetValue();
374 anAxis.vy = SpinBox_DY->GetValue();
375 anAxis.vz = SpinBox_DZ->GetValue();
377 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
378 int actionButton = ActionGroup->checkedId();
379 bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
381 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
382 QApplication::setOverrideCursor(Qt::WaitCursor);
383 switch ( actionButton ) {
384 case MOVE_ELEMS_BUTTON:
385 aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
387 case COPY_ELEMS_BUTTON:
389 SMESH::ListOfGroups_var groups =
390 aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
392 aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
394 case MAKE_MESH_BUTTON:
395 SMESH::SMESH_Mesh_var mesh =
396 aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
397 LineEditNewMesh->text().toLatin1().data());
399 QApplication::restoreOverrideCursor();
404 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
405 actionButton == MAKE_MESH_BUTTON )
406 mySMESHGUI->updateObjBrowser(true); // new groups may appear
408 SelectionIntoArgument();
412 //=================================================================================
413 // function : ClickOnOk()
415 //=================================================================================
416 void SMESHGUI_RotationDlg::ClickOnOk()
422 //=================================================================================
423 // function : ClickOnCancel()
425 //=================================================================================
426 void SMESHGUI_RotationDlg::ClickOnCancel()
428 disconnect(mySelectionMgr, 0, this, 0);
429 mySelectionMgr->clearFilters();
430 //mySelectionMgr->clearSelected();
431 SMESH::SetPointRepresentation(false);
432 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
433 aViewWindow->SetSelectionMode(ActorSelection);
434 mySMESHGUI->ResetState();
438 //=================================================================================
439 // function : ClickOnHelp()
441 //=================================================================================
442 void SMESHGUI_RotationDlg::ClickOnHelp()
444 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
446 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
450 platform = "winapplication";
452 platform = "application";
454 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
455 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
456 arg(app->resourceMgr()->stringValue("ExternalBrowser",
458 arg(myHelpFileName));
462 //=======================================================================
463 // function : onTextChange()
465 //=======================================================================
466 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
468 QLineEdit* send = (QLineEdit*)sender();
473 if (send == LineEditElements)
476 buttonOk->setEnabled(false);
477 buttonApply->setEnabled(false);
479 // hilight entered elements
480 SMDS_Mesh* aMesh = 0;
482 aMesh = myActor->GetObject()->GetMesh();
485 if (send == LineEditElements) {
486 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
488 TColStd_MapOfInteger newIndices;
490 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
491 for (int i = 0; i < aListId.count(); i++) {
492 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
494 newIndices.Add(e->GetID());
498 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
499 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
500 aViewWindow->highlight( anIO, true, true );
502 myElementsId = theNewText;
506 if (myNbOkElements && IsAxisOk()) {
507 buttonOk->setEnabled(true);
508 buttonApply->setEnabled(true);
514 //=================================================================================
515 // function : SelectionIntoArgument()
516 // purpose : Called when selection as changed or other case
517 //=================================================================================
518 void SMESHGUI_RotationDlg::SelectionIntoArgument()
524 QString aString = "";
527 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
528 LineEditElements->setText(aString);
530 buttonOk->setEnabled(false);
531 buttonApply->setEnabled(false);
535 if (!GroupButtons->isEnabled()) // inactive
540 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
542 int nbSel = aList.Extent();
546 Handle(SALOME_InteractiveObject) IO = aList.First();
547 myMesh = SMESH::GetMeshByIO(IO);
548 if (myMesh->_is_nil())
551 myActor = SMESH::FindActorByObject(myMesh);
553 myActor = SMESH::FindActorByEntry(IO->getEntry());
559 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
562 // MakeGroups is available if there are groups and "Copy"
563 if ( myMesh->NbGroups() == 0 ) {
564 MakeGroupsCheck->setChecked(false);
565 MakeGroupsCheck->setEnabled(false);
567 else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
568 MakeGroupsCheck->setEnabled(true);
570 if (CheckBoxMesh->isChecked()) {
571 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
573 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
575 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
579 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
580 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
582 myElementsId += QString(" %1").arg(i);
586 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
588 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
590 // get IDs from submesh
591 SMESH::long_array_var anElementsIds = new SMESH::long_array;
592 anElementsIds = aSubMesh->GetElementsId();
593 for (int i = 0; i < anElementsIds->length(); i++) {
594 myElementsId += QString(" %1").arg(anElementsIds[i]);
596 aNbUnits = anElementsIds->length();
599 SMESH::SMESH_GroupBase_var aGroup =
600 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
601 if (aGroup->_is_nil())
604 // get IDs from smesh group
605 SMESH::long_array_var anElementsIds = new SMESH::long_array;
606 anElementsIds = aGroup->GetListOfID();
607 for (int i = 0; i < anElementsIds->length(); i++) {
608 myElementsId += QString(" %1").arg(anElementsIds[i]);
610 aNbUnits = anElementsIds->length();
613 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
614 myElementsId = aString;
620 myNbOkElements = true;
622 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
626 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
630 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
638 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
639 SpinBox_X->SetValue(x);
640 SpinBox_Y->SetValue(y);
641 SpinBox_Z->SetValue(z);
642 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
643 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
644 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
645 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
650 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
651 LineEditElements->setText(aString);
657 if (myNbOkElements && IsAxisOk()) {
658 buttonOk->setEnabled(true);
659 buttonApply->setEnabled(true);
663 //=================================================================================
664 // function : SetEditCurrentArgument()
666 //=================================================================================
667 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
669 QPushButton* send = (QPushButton*)sender();
671 disconnect(mySelectionMgr, 0, this, 0);
672 mySelectionMgr->clearSelected();
673 mySelectionMgr->clearFilters();
675 switch (myConstructorId) {
676 case 0: /* default constructor */
678 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
679 if (send == SelectElementsButton) {
680 myEditCurrentArgument = (QWidget*)LineEditElements;
681 SMESH::SetPointRepresentation(false);
682 if (CheckBoxMesh->isChecked()) {
684 aViewWindow->SetSelectionMode(ActorSelection);
685 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
688 aViewWindow->SetSelectionMode( CellSelection );
690 } else if (send == SelectPointButton) {
691 myEditCurrentArgument = (QWidget*)SpinBox_X;
692 SMESH::SetPointRepresentation(true);
694 aViewWindow->SetSelectionMode( NodeSelection );
695 } else if (send == SelectVectorButton) {
696 myEditCurrentArgument = (QWidget*)SpinBox_DX;
697 SMESH::SetPointRepresentation(true);
699 aViewWindow->SetSelectionMode( NodeSelection );
705 myEditCurrentArgument->setFocus();
706 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
707 SelectionIntoArgument();
710 //=================================================================================
711 // function : DeactivateActiveDialog()
713 //=================================================================================
714 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
716 if (GroupConstructors->isEnabled()) {
717 GroupConstructors->setEnabled(false);
718 GroupArguments->setEnabled(false);
719 GroupButtons->setEnabled(false);
720 mySMESHGUI->ResetState();
721 mySMESHGUI->SetActiveDialogBox(0);
725 //=================================================================================
726 // function : ActivateThisDialog()
728 //=================================================================================
729 void SMESHGUI_RotationDlg::ActivateThisDialog()
731 /* Emit a signal to deactivate the active dialog */
732 mySMESHGUI->EmitSignalDeactivateDialog();
733 GroupConstructors->setEnabled(true);
734 GroupArguments->setEnabled(true);
735 GroupButtons->setEnabled(true);
737 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
739 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
740 aViewWindow->SetSelectionMode( CellSelection );
741 SelectionIntoArgument();
744 //=================================================================================
745 // function : enterEvent()
747 //=================================================================================
748 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
750 if (!GroupConstructors->isEnabled())
751 ActivateThisDialog();
754 //=================================================================================
755 // function : closeEvent()
757 //=================================================================================
758 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
760 /* same than click on cancel button */
764 //=================================================================================
765 // function : hideEvent()
766 // purpose : caused by ESC key
767 //=================================================================================
768 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
774 //=================================================================================
775 // function : onSelectMesh()
777 //=================================================================================
778 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
781 TextLabelElements->setText(tr("SMESH_NAME"));
783 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
785 if (myEditCurrentArgument != LineEditElements) {
786 LineEditElements->clear();
790 mySelectionMgr->clearFilters();
791 SMESH::SetPointRepresentation(false);
794 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
795 aViewWindow->SetSelectionMode(ActorSelection);
796 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
797 LineEditElements->setReadOnly(true);
799 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
800 aViewWindow->SetSelectionMode( CellSelection );
801 LineEditElements->setReadOnly(false);
802 onTextChange(LineEditElements->text());
805 SelectionIntoArgument();
808 //=================================================================================
809 // function : IsAxisOk()
811 //=================================================================================
812 bool SMESHGUI_RotationDlg::IsAxisOk()
814 return (SpinBox_DX->GetValue() != 0 ||
815 SpinBox_DY->GetValue() != 0 ||
816 SpinBox_DZ->GetValue() != 0);
819 //=================================================================================
820 // function : onVectorChanged()
822 //=================================================================================
823 void SMESHGUI_RotationDlg::onVectorChanged()
826 buttonOk->setEnabled(true);
827 buttonApply->setEnabled(true);
829 buttonOk->setEnabled(false);
830 buttonApply->setEnabled(false);
835 //=======================================================================
836 //function : onActionClicked
837 //purpose : slot called when an action type changed
838 //=======================================================================
840 void SMESHGUI_RotationDlg::onActionClicked(int button)
843 case MOVE_ELEMS_BUTTON:
844 MakeGroupsCheck->setEnabled(false);
845 LineEditNewMesh->setEnabled(false);
847 case COPY_ELEMS_BUTTON:
848 LineEditNewMesh->setEnabled(false);
849 MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
850 if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
851 MakeGroupsCheck->setEnabled(true);
853 MakeGroupsCheck->setEnabled(false);
855 case MAKE_MESH_BUTTON:
856 LineEditNewMesh->setEnabled(true);
857 MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
858 if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
859 MakeGroupsCheck->setEnabled(true);
861 MakeGroupsCheck->setEnabled(false);
867 //=======================================================================
868 //function : setNewMeshName
869 //purpose : update contents of LineEditNewMesh
870 //=======================================================================
872 void SMESHGUI_RotationDlg::setNewMeshName()
874 LineEditNewMesh->setText("");
875 if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
877 if ( CheckBoxMesh->isChecked() ) {
878 name = LineEditElements->text();
881 _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
882 name = meshSO->GetName().c_str();
884 if ( !name.isEmpty() )
885 LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "rotated"));
889 //=================================================================================
890 // function : keyPressEvent()
892 //=================================================================================
893 void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e )
895 QDialog::keyPressEvent( e );
896 if ( e->isAccepted() )
899 if ( e->key() == Qt::Key_F1 ) {