1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_RotationDlg.cxx
24 // 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"
35 #include "SMESHGUI_FilterDlg.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TypeFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_Desktop.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SUIT_OverrideCursor.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_SelectionMgr.h>
52 #include <SVTK_ViewModel.h>
53 #include <SVTK_ViewWindow.h>
54 #include <SALOME_ListIO.hxx>
56 // SALOME KERNEL includes
57 #include <SALOMEDSClient_SObject.hxx>
60 #include <TColStd_MapOfInteger.hxx>
63 #include <QApplication>
64 #include <QButtonGroup>
68 #include <QPushButton>
69 #include <QRadioButton>
71 #include <QHBoxLayout>
72 #include <QVBoxLayout>
73 #include <QGridLayout>
77 #include <SALOMEconfig.h>
78 #include CORBA_SERVER_HEADER(SMESH_Group)
79 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
81 enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action type
86 //=================================================================================
87 // class : SMESHGUI_RotationDlg()
89 //=================================================================================
90 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule )
91 : QDialog( SMESH::GetDesktop( theModule ) ),
92 mySMESHGUI( theModule ),
93 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
96 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION")));
97 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
100 setAttribute(Qt::WA_DeleteOnClose, true);
101 setWindowTitle(tr("SMESH_ROTATION_TITLE"));
102 setSizeGripEnabled(true);
104 QVBoxLayout* SMESHGUI_RotationDlgLayout = new QVBoxLayout(this);
105 SMESHGUI_RotationDlgLayout->setSpacing(SPACING);
106 SMESHGUI_RotationDlgLayout->setMargin(MARGIN);
108 /***************************************************************/
109 GroupConstructors = new QGroupBox(tr("SMESH_ROTATION"), this);
110 QButtonGroup* ButtonGroup = new QButtonGroup(this);
111 QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
112 GroupConstructorsLayout->setSpacing(SPACING);
113 GroupConstructorsLayout->setMargin(MARGIN);
115 RadioButton1= new QRadioButton(GroupConstructors);
116 RadioButton1->setIcon(image0);
118 GroupConstructorsLayout->addWidget(RadioButton1);
119 ButtonGroup->addButton(RadioButton1, 0);
121 /***************************************************************/
122 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
123 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
124 GroupArgumentsLayout->setSpacing(SPACING);
125 GroupArgumentsLayout->setMargin(MARGIN);
127 myIdValidator = new SMESHGUI_IdValidator(this);
129 // Controls for elements selection
130 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
131 SelectElementsButton = new QPushButton(GroupArguments);
132 SelectElementsButton->setIcon(image1);
133 LineEditElements = new QLineEdit(GroupArguments);
134 LineEditElements->setValidator(myIdValidator);
135 QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
136 connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
138 // Control for the whole mesh selection
139 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
141 // Controls for axis defining
142 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
143 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
144 GroupAxisLayout->setSpacing(SPACING);
145 GroupAxisLayout->setMargin(MARGIN);
147 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
148 SelectPointButton = new QPushButton(GroupAxis);
149 SelectPointButton->setIcon(image1);
151 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
152 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
153 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
154 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
155 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
156 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
158 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
159 SelectVectorButton = new QPushButton(GroupAxis);
160 SelectVectorButton->setIcon(image1);
162 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
163 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
164 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
165 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
166 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
167 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
169 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
170 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
171 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
172 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
173 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
174 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
175 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
176 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
177 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
178 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
179 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
180 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
181 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
182 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
183 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
184 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
186 // Controls for angle defining
187 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupArguments);
188 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments);
191 ActionBox = new QGroupBox(GroupArguments);
192 ActionGroup = new QButtonGroup(GroupArguments);
193 QVBoxLayout* ActionBoxLayout = new QVBoxLayout(ActionBox);
194 ActionBoxLayout->setSpacing(SPACING);
195 ActionBoxLayout->setMargin(MARGIN);
197 QRadioButton* aMoveElements = new QRadioButton(tr("SMESH_MOVE_ELEMENTS"), ActionBox);
198 QRadioButton* aCopyElements = new QRadioButton(tr("SMESH_COPY_ELEMENTS"), ActionBox);
199 QRadioButton* aCreateMesh = new QRadioButton(tr("SMESH_CREATE_MESH"), ActionBox);
201 ActionBoxLayout->addWidget(aMoveElements);
202 ActionBoxLayout->addWidget(aCopyElements);
203 ActionBoxLayout->addWidget(aCreateMesh);
204 ActionGroup->addButton(aMoveElements, MOVE_ELEMS_BUTTON);
205 ActionGroup->addButton(aCopyElements, COPY_ELEMS_BUTTON);
206 ActionGroup->addButton(aCreateMesh, MAKE_MESH_BUTTON);
208 // CheckBox for groups generation
209 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
211 // Name of a mesh to create
212 LineEditNewMesh = new QLineEdit(GroupArguments);
214 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
215 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
216 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 1);
217 GroupArgumentsLayout->addWidget(filterBtn, 0, 3);
218 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
219 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
220 GroupArgumentsLayout->addWidget(TextLabelAngle, 3, 0, 1, 2);
221 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
222 GroupArgumentsLayout->addWidget(ActionBox, 4, 0, 3, 3);
223 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 3);
224 GroupArgumentsLayout->addWidget(LineEditNewMesh, 6, 3);
226 /***************************************************************/
227 GroupButtons = new QGroupBox(this);
228 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
229 GroupButtonsLayout->setSpacing(SPACING);
230 GroupButtonsLayout->setMargin(MARGIN);
232 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
233 buttonOk->setAutoDefault(true);
234 buttonOk->setDefault(true);
235 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
236 buttonApply->setAutoDefault(true);
237 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
238 buttonCancel->setAutoDefault(true);
239 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
240 buttonHelp->setAutoDefault(true);
242 GroupButtonsLayout->addWidget(buttonOk);
243 GroupButtonsLayout->addSpacing(10);
244 GroupButtonsLayout->addWidget(buttonApply);
245 GroupButtonsLayout->addSpacing(10);
246 GroupButtonsLayout->addStretch();
247 GroupButtonsLayout->addWidget(buttonCancel);
248 GroupButtonsLayout->addWidget(buttonHelp);
250 /***************************************************************/
251 SMESHGUI_RotationDlgLayout->addWidget(GroupConstructors);
252 SMESHGUI_RotationDlgLayout->addWidget(GroupArguments);
253 SMESHGUI_RotationDlgLayout->addWidget(GroupButtons);
255 /* Initialisations */
256 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
257 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
258 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
259 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
260 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
261 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
263 SpinBox_Angle->RangeStepAndValidator(-360.0, +360.0, 5.0, 3);
266 RadioButton1->setChecked(true);
268 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
270 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
272 // Costruction of the logical filter
273 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
274 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
276 QList<SUIT_SelectionFilter*> aListOfFilters;
277 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
278 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
280 myMeshOrSubMeshOrGroupFilter =
281 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
283 myHelpFileName = "rotation_page.html";
287 /* signals and slots connections */
288 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
289 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
290 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
291 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
293 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
294 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
295 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
297 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
298 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
299 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
301 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
302 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
303 /* to close dialog if study change */
304 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
305 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
306 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
307 connect(ActionGroup, SIGNAL(buttonClicked(int)), SLOT(onActionClicked(int)));
309 onActionClicked(MOVE_ELEMS_BUTTON);
312 //=================================================================================
313 // function : ~SMESHGUI_RotationDlg()
314 // purpose : Destroys the object and frees any allocated resources
315 //=================================================================================
316 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
319 myFilterDlg->setParent( 0 );
325 //=================================================================================
328 //=================================================================================
329 void SMESHGUI_RotationDlg::Init (bool ResetControls)
333 myEditCurrentArgument = (QWidget*)LineEditElements;
334 LineEditElements->setFocus();
338 buttonOk->setEnabled(false);
339 buttonApply->setEnabled(false);
342 myMesh = SMESH::SMESH_Mesh::_nil();
345 SpinBox_X->SetValue(0.0);
346 SpinBox_Y->SetValue(0.0);
347 SpinBox_Z->SetValue(0.0);
348 SpinBox_DX->SetValue(0.0);
349 SpinBox_DY->SetValue(0.0);
350 SpinBox_DZ->SetValue(0.0);
352 SpinBox_Angle->SetValue(45);
354 ActionGroup->button( MOVE_ELEMS_BUTTON )->setChecked(true);
355 CheckBoxMesh->setChecked(false);
356 // MakeGroupsCheck->setChecked(false);
357 // MakeGroupsCheck->setEnabled(false);
358 // onSelectMesh(false);
361 onSelectMesh(CheckBoxMesh->isChecked());
364 //=================================================================================
365 // function : ClickOnApply()
367 //=================================================================================
368 void SMESHGUI_RotationDlg::ClickOnApply()
370 if (mySMESHGUI->isActiveStudyLocked())
373 if (myNbOkElements && IsAxisOk()) {
374 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
376 SMESH::long_array_var anElementsId = new SMESH::long_array;
378 anElementsId->length(aListElementsId.count());
379 for (int i = 0; i < aListElementsId.count(); i++)
380 anElementsId[i] = aListElementsId[i].toInt();
382 SMESH::AxisStruct anAxis;
384 anAxis.x = SpinBox_X->GetValue();
385 anAxis.y = SpinBox_Y->GetValue();
386 anAxis.z = SpinBox_Z->GetValue();;
387 anAxis.vx = SpinBox_DX->GetValue();
388 anAxis.vy = SpinBox_DY->GetValue();
389 anAxis.vz = SpinBox_DZ->GetValue();
391 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
392 int actionButton = ActionGroup->checkedId();
393 bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
395 SUIT_OverrideCursor aWaitCursor;
396 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
397 switch ( actionButton ) {
398 case MOVE_ELEMS_BUTTON:
399 aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false);
401 case COPY_ELEMS_BUTTON:
403 SMESH::ListOfGroups_var groups =
404 aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle);
406 aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true);
408 case MAKE_MESH_BUTTON:
409 SMESH::SMESH_Mesh_var mesh =
410 aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups,
411 LineEditNewMesh->text().toLatin1().data());
417 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
418 actionButton == MAKE_MESH_BUTTON )
419 mySMESHGUI->updateObjBrowser(true); // new groups may appear
421 SelectionIntoArgument();
425 //=================================================================================
426 // function : ClickOnOk()
428 //=================================================================================
429 void SMESHGUI_RotationDlg::ClickOnOk()
435 //=================================================================================
436 // function : ClickOnCancel()
438 //=================================================================================
439 void SMESHGUI_RotationDlg::ClickOnCancel()
441 disconnect(mySelectionMgr, 0, this, 0);
442 mySelectionMgr->clearFilters();
443 //mySelectionMgr->clearSelected();
444 if (SMESH::GetCurrentVtkView()) {
445 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
446 SMESH::SetPointRepresentation(false);
448 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
449 aViewWindow->SetSelectionMode(ActorSelection);
450 mySMESHGUI->ResetState();
454 //=================================================================================
455 // function : ClickOnHelp()
457 //=================================================================================
458 void SMESHGUI_RotationDlg::ClickOnHelp()
460 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
462 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
466 platform = "winapplication";
468 platform = "application";
470 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
471 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
472 arg(app->resourceMgr()->stringValue("ExternalBrowser",
474 arg(myHelpFileName));
478 //=======================================================================
479 // function : onTextChange()
481 //=======================================================================
482 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
484 QLineEdit* send = (QLineEdit*)sender();
489 if (send == LineEditElements)
492 buttonOk->setEnabled(false);
493 buttonApply->setEnabled(false);
495 // hilight entered elements
496 SMDS_Mesh* aMesh = 0;
498 aMesh = myActor->GetObject()->GetMesh();
501 if (send == LineEditElements) {
502 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
504 TColStd_MapOfInteger newIndices;
506 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
507 for (int i = 0; i < aListId.count(); i++) {
508 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
510 newIndices.Add(e->GetID());
514 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
515 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
516 aViewWindow->highlight( anIO, true, true );
518 myElementsId = theNewText;
522 if (myNbOkElements && IsAxisOk()) {
523 buttonOk->setEnabled(true);
524 buttonApply->setEnabled(true);
530 //=================================================================================
531 // function : SelectionIntoArgument()
532 // purpose : Called when selection as changed or other case
533 //=================================================================================
534 void SMESHGUI_RotationDlg::SelectionIntoArgument()
540 QString aString = "";
543 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
544 LineEditElements->setText(aString);
546 buttonOk->setEnabled(false);
547 buttonApply->setEnabled(false);
551 if (!GroupButtons->isEnabled()) // inactive
556 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
558 int nbSel = aList.Extent();
562 Handle(SALOME_InteractiveObject) IO = aList.First();
563 myMesh = SMESH::GetMeshByIO(IO);
564 if (myMesh->_is_nil())
567 myActor = SMESH::FindActorByObject(myMesh);
569 myActor = SMESH::FindActorByEntry(IO->getEntry());
575 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
578 // MakeGroups is available if there are groups and "Copy"
579 if ( myMesh->NbGroups() == 0 ) {
580 MakeGroupsCheck->setChecked(false);
581 MakeGroupsCheck->setEnabled(false);
583 else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
584 MakeGroupsCheck->setEnabled(true);
586 if (CheckBoxMesh->isChecked()) {
587 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
589 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
591 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
595 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
596 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
598 myElementsId += QString(" %1").arg(i);
602 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
604 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
606 // get IDs from submesh
607 SMESH::long_array_var anElementsIds = new SMESH::long_array;
608 anElementsIds = aSubMesh->GetElementsId();
609 for (int i = 0; i < anElementsIds->length(); i++) {
610 myElementsId += QString(" %1").arg(anElementsIds[i]);
612 aNbUnits = anElementsIds->length();
615 SMESH::SMESH_GroupBase_var aGroup =
616 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
617 if (aGroup->_is_nil())
620 // get IDs from smesh group
621 SMESH::long_array_var anElementsIds = new SMESH::long_array;
622 anElementsIds = aGroup->GetListOfID();
623 for (int i = 0; i < anElementsIds->length(); i++) {
624 myElementsId += QString(" %1").arg(anElementsIds[i]);
626 aNbUnits = anElementsIds->length();
629 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
630 myElementsId = aString;
636 myNbOkElements = true;
638 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
642 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
646 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
654 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
655 SpinBox_X->SetValue(x);
656 SpinBox_Y->SetValue(y);
657 SpinBox_Z->SetValue(z);
658 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
659 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
660 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
661 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
666 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
667 LineEditElements->setText(aString);
668 LineEditElements->repaint();
669 LineEditElements->setEnabled(false); // to update lineedit IPAL 19809
670 LineEditElements->setEnabled(true);
676 if (myNbOkElements && IsAxisOk()) {
677 buttonOk->setEnabled(true);
678 buttonApply->setEnabled(true);
682 //=================================================================================
683 // function : SetEditCurrentArgument()
685 //=================================================================================
686 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
688 QPushButton* send = (QPushButton*)sender();
690 disconnect(mySelectionMgr, 0, this, 0);
691 mySelectionMgr->clearSelected();
692 mySelectionMgr->clearFilters();
694 switch (myConstructorId) {
695 case 0: /* default constructor */
697 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
698 if (send == SelectElementsButton) {
699 myEditCurrentArgument = (QWidget*)LineEditElements;
700 SMESH::SetPointRepresentation(false);
701 if (CheckBoxMesh->isChecked()) {
703 aViewWindow->SetSelectionMode(ActorSelection);
704 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
707 aViewWindow->SetSelectionMode( CellSelection );
709 } else if (send == SelectPointButton) {
710 myEditCurrentArgument = (QWidget*)SpinBox_X;
711 SMESH::SetPointRepresentation(true);
713 aViewWindow->SetSelectionMode( NodeSelection );
714 } else if (send == SelectVectorButton) {
715 myEditCurrentArgument = (QWidget*)SpinBox_DX;
716 SMESH::SetPointRepresentation(true);
718 aViewWindow->SetSelectionMode( NodeSelection );
724 myEditCurrentArgument->setFocus();
725 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
726 SelectionIntoArgument();
729 //=================================================================================
730 // function : DeactivateActiveDialog()
732 //=================================================================================
733 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
735 if (GroupConstructors->isEnabled()) {
736 GroupConstructors->setEnabled(false);
737 GroupArguments->setEnabled(false);
738 GroupButtons->setEnabled(false);
739 mySMESHGUI->ResetState();
740 mySMESHGUI->SetActiveDialogBox(0);
744 //=================================================================================
745 // function : ActivateThisDialog()
747 //=================================================================================
748 void SMESHGUI_RotationDlg::ActivateThisDialog()
750 /* Emit a signal to deactivate the active dialog */
751 mySMESHGUI->EmitSignalDeactivateDialog();
752 GroupConstructors->setEnabled(true);
753 GroupArguments->setEnabled(true);
754 GroupButtons->setEnabled(true);
756 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
758 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
759 aViewWindow->SetSelectionMode( CellSelection );
760 SelectionIntoArgument();
763 //=================================================================================
764 // function : enterEvent()
766 //=================================================================================
767 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
769 if (!GroupConstructors->isEnabled())
770 ActivateThisDialog();
773 //=================================================================================
774 // function : closeEvent()
776 //=================================================================================
777 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
779 /* same than click on cancel button */
783 //=================================================================================
784 // function : hideEvent()
785 // purpose : caused by ESC key
786 //=================================================================================
787 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
793 //=================================================================================
794 // function : onSelectMesh()
796 //=================================================================================
797 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
800 TextLabelElements->setText(tr("SMESH_NAME"));
802 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
804 if (myEditCurrentArgument != LineEditElements) {
805 LineEditElements->clear();
809 mySelectionMgr->clearFilters();
810 SMESH::SetPointRepresentation(false);
813 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
814 aViewWindow->SetSelectionMode(ActorSelection);
815 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
816 LineEditElements->setReadOnly(true);
817 LineEditElements->setValidator(0);
819 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
820 aViewWindow->SetSelectionMode( CellSelection );
821 LineEditElements->setReadOnly(false);
822 LineEditElements->setValidator(myIdValidator);
823 onTextChange(LineEditElements->text());
826 SelectionIntoArgument();
829 //=================================================================================
830 // function : IsAxisOk()
832 //=================================================================================
833 bool SMESHGUI_RotationDlg::IsAxisOk()
835 return (SpinBox_DX->GetValue() != 0 ||
836 SpinBox_DY->GetValue() != 0 ||
837 SpinBox_DZ->GetValue() != 0);
840 //=================================================================================
841 // function : onVectorChanged()
843 //=================================================================================
844 void SMESHGUI_RotationDlg::onVectorChanged()
847 buttonOk->setEnabled(true);
848 buttonApply->setEnabled(true);
850 buttonOk->setEnabled(false);
851 buttonApply->setEnabled(false);
856 //=======================================================================
857 //function : onActionClicked
858 //purpose : slot called when an action type changed
859 //=======================================================================
861 void SMESHGUI_RotationDlg::onActionClicked(int button)
864 case MOVE_ELEMS_BUTTON:
865 MakeGroupsCheck->setEnabled(false);
866 LineEditNewMesh->setEnabled(false);
868 case COPY_ELEMS_BUTTON:
869 LineEditNewMesh->setEnabled(false);
870 MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
871 if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
872 MakeGroupsCheck->setEnabled(true);
874 MakeGroupsCheck->setEnabled(false);
876 case MAKE_MESH_BUTTON:
877 LineEditNewMesh->setEnabled(true);
878 MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
879 if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
880 MakeGroupsCheck->setEnabled(true);
882 MakeGroupsCheck->setEnabled(false);
888 //=======================================================================
889 //function : setNewMeshName
890 //purpose : update contents of LineEditNewMesh
891 //=======================================================================
893 void SMESHGUI_RotationDlg::setNewMeshName()
895 LineEditNewMesh->setText("");
896 if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
898 if ( CheckBoxMesh->isChecked() ) {
899 name = LineEditElements->text();
902 _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
903 name = meshSO->GetName().c_str();
905 if ( !name.isEmpty() )
906 LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "rotated"));
910 //=================================================================================
911 // function : keyPressEvent()
913 //=================================================================================
914 void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e )
916 QDialog::keyPressEvent( e );
917 if ( e->isAccepted() )
920 if ( e->key() == Qt::Key_F1 ) {
926 //=================================================================================
927 // function : setFilters()
928 // purpose : SLOT. Called when "Filter" button pressed.
929 //=================================================================================
930 void SMESHGUI_RotationDlg::setFilters()
933 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
935 myFilterDlg->SetSelection();
936 myFilterDlg->SetMesh( myMesh );
937 myFilterDlg->SetSourceWg( LineEditElements );