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
24 // File : SMESHGUI_RotationDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_RotationDlg.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
41 #include "SMDS_Mesh.hxx"
43 #include "SUIT_Desktop.h"
44 #include "SUIT_Session.h"
45 #include "SUIT_MessageBox.h"
47 #include "LightApp_Application.h"
49 #include "SVTK_ViewModel.h"
50 #include "SVTK_ViewWindow.h"
51 #include "SVTK_Selector.h"
52 #include "SVTK_Selection.h"
53 #include "SALOME_ListIO.hxx"
55 #include "utilities.h"
58 #include <TColStd_MapOfInteger.hxx>
59 #include <TColStd_IndexedMapOfInteger.hxx>
62 #include <qapplication.h>
63 #include <qbuttongroup.h>
64 #include <qgroupbox.h>
66 #include <qlineedit.h>
67 #include <qpushbutton.h>
68 #include <qradiobutton.h>
69 #include <qcheckbox.h>
74 #include "SALOMEconfig.h"
75 #include CORBA_SERVER_HEADER(SMESH_Group)
79 //=================================================================================
80 // class : SMESHGUI_RotationDlg()
82 //=================================================================================
83 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule, const char* name,
84 bool modal, WFlags fl)
85 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
86 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
87 mySMESHGUI( theModule ),
88 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
90 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION")));
91 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
94 setName("SMESHGUI_RotationDlg");
96 setCaption(tr("SMESH_ROTATION_TITLE"));
97 setSizeGripEnabled(TRUE);
98 SMESHGUI_RotationDlgLayout = new QGridLayout(this);
99 SMESHGUI_RotationDlgLayout->setSpacing(6);
100 SMESHGUI_RotationDlgLayout->setMargin(11);
102 /***************************************************************/
103 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
104 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
105 (QSizePolicy::SizeType)0, 0, 0,
106 GroupConstructors->sizePolicy().hasHeightForWidth()));
107 GroupConstructors->setTitle(tr("SMESH_ROTATION"));
108 GroupConstructors->setExclusive(TRUE);
109 GroupConstructors->setColumnLayout(0, Qt::Vertical);
110 GroupConstructors->layout()->setSpacing(0);
111 GroupConstructors->layout()->setMargin(0);
112 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
113 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
114 GroupConstructorsLayout->setSpacing(6);
115 GroupConstructorsLayout->setMargin(11);
116 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
117 RadioButton1->setText(tr("" ));
118 RadioButton1->setPixmap(image0);
119 RadioButton1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1,
120 (QSizePolicy::SizeType)0,
121 RadioButton1->sizePolicy().hasHeightForWidth()));
122 RadioButton1->setMinimumSize(QSize(50, 0));
123 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
124 QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
125 GroupConstructorsLayout->addItem(spacer, 0, 1);
126 SMESHGUI_RotationDlgLayout->addWidget(GroupConstructors, 0, 0);
128 /***************************************************************/
129 GroupButtons = new QGroupBox(this, "GroupButtons");
130 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
131 (QSizePolicy::SizeType)0, 0, 0,
132 GroupButtons->sizePolicy().hasHeightForWidth()));
133 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
134 GroupButtons->setTitle(tr("" ));
135 GroupButtons->setColumnLayout(0, Qt::Vertical);
136 GroupButtons->layout()->setSpacing(0);
137 GroupButtons->layout()->setMargin(0);
138 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
139 GroupButtonsLayout->setAlignment(Qt::AlignTop);
140 GroupButtonsLayout->setSpacing(6);
141 GroupButtonsLayout->setMargin(11);
142 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
143 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
144 buttonHelp->setAutoDefault(TRUE);
145 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
146 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
147 buttonCancel->setText(tr("SMESH_BUT_CLOSE"));
148 buttonCancel->setAutoDefault(TRUE);
149 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
150 buttonApply = new QPushButton(GroupButtons, "buttonApply");
151 buttonApply->setText(tr("SMESH_BUT_APPLY"));
152 buttonApply->setAutoDefault(TRUE);
153 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
154 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
155 GroupButtonsLayout->addItem(spacer_9, 0, 2);
156 buttonOk = new QPushButton(GroupButtons, "buttonOk");
157 buttonOk->setText(tr("SMESH_BUT_OK"));
158 buttonOk->setAutoDefault(TRUE);
159 buttonOk->setDefault(TRUE);
160 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
161 SMESHGUI_RotationDlgLayout->addWidget(GroupButtons, 2, 0);
163 /***************************************************************/
164 GroupArguments = new QGroupBox(this, "GroupArguments");
165 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
166 GroupArguments->setColumnLayout(0, Qt::Vertical);
167 GroupArguments->layout()->setSpacing(0);
168 GroupArguments->layout()->setMargin(0);
169 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
170 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
171 GroupArgumentsLayout->setSpacing(6);
172 GroupArgumentsLayout->setMargin(11);
174 // Controls for elements selection
175 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
176 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
177 TextLabelElements->setFixedWidth(74);
178 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
180 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
181 SelectElementsButton->setText(tr("" ));
182 SelectElementsButton->setPixmap(image1);
183 SelectElementsButton->setToggleButton(FALSE);
184 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
186 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
187 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
188 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
190 // Control for the whole mesh selection
191 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
192 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
193 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
195 // Controls for axis defining
196 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
197 GroupAxis->setTitle(tr("SMESH_AXIS"));
198 GroupAxis->setColumnLayout(0, Qt::Vertical);
199 GroupAxis->layout()->setSpacing(0);
200 GroupAxis->layout()->setMargin(0);
201 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
202 GroupAxisLayout->setAlignment(Qt::AlignTop);
203 GroupAxisLayout->setSpacing(6);
204 GroupAxisLayout->setMargin(11);
206 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
207 TextLabelPoint->setText(tr("SMESH_POINT"));
208 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
210 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
211 SelectPointButton->setPixmap(image1);
212 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
214 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
215 TextLabelX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
216 TextLabelX->setText(tr("SMESH_X"));
217 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
219 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
220 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
222 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
223 TextLabelY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
224 TextLabelY->setText(tr("SMESH_Y"));
225 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
227 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
228 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
230 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
231 TextLabelZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
232 TextLabelZ->setText(tr("SMESH_Z"));
233 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
235 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
236 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
238 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
239 TextLabelVector->setText(tr("SMESH_VECTOR"));
240 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
242 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
243 SelectVectorButton->setPixmap(image1);
244 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
246 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
247 TextLabelDX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
248 TextLabelDX->setText(tr("SMESH_DX"));
249 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
251 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
252 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
254 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
255 TextLabelDY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
256 TextLabelDY->setText(tr("SMESH_DY"));
257 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
259 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
260 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
262 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
263 TextLabelDZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
264 TextLabelDZ->setText(tr("SMESH_DZ"));
265 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
267 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
268 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
270 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 2);
272 // Controls for angle defining
273 TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle");
274 TextLabelAngle->setText(tr("SMESH_ANGLE"));
275 GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1);
277 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
278 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
280 // Controls for "Create a copy" option
281 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
282 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
283 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
285 SMESHGUI_RotationDlgLayout->addWidget(GroupArguments, 1, 0);
287 /* Initialisations */
288 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
289 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
290 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
291 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
292 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
293 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
295 SpinBox_Angle->RangeStepAndValidator(-360.0, +360.0, 5.0, 3);
297 GroupArguments->show();
299 RadioButton1->setChecked(TRUE);
301 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
303 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
305 // Costruction of the logical filter
306 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
307 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
309 QPtrList<SUIT_SelectionFilter> aListOfFilters;
310 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
311 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
313 myMeshOrSubMeshOrGroupFilter =
314 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
316 myHelpFileName = "/files/rotation.htm";
320 /* signals and slots connections */
321 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
322 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
323 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
324 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
325 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
327 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
328 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
329 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
331 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
332 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
333 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
335 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
336 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
337 /* to close dialog if study change */
338 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
339 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
340 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
342 this->show(); /* displays Dialog */
344 ConstructorsClicked(0);
348 //=================================================================================
349 // function : ~SMESHGUI_RotationDlg()
350 // purpose : Destroys the object and frees any allocated resources
351 //=================================================================================
352 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
354 // no need to delete child widgets, Qt does it all for us
357 //=================================================================================
360 //=================================================================================
361 void SMESHGUI_RotationDlg::Init (bool ResetControls)
365 myEditCurrentArgument = (QWidget*)LineEditElements;
366 LineEditElements->setFocus();
370 buttonOk->setEnabled(false);
371 buttonApply->setEnabled(false);
374 myMesh = SMESH::SMESH_Mesh::_nil();
377 SpinBox_X->SetValue(0.0);
378 SpinBox_Y->SetValue(0.0);
379 SpinBox_Z->SetValue(0.0);
380 SpinBox_DX->SetValue(0.0);
381 SpinBox_DY->SetValue(0.0);
382 SpinBox_DZ->SetValue(0.0);
384 SpinBox_Angle->SetValue(45);
386 CheckBoxCopy->setChecked(false);
387 CheckBoxMesh->setChecked(false);
390 onSelectMesh(CheckBoxMesh->isChecked());
393 //=================================================================================
394 // function : ConstructorsClicked()
395 // purpose : Radio button management
396 //=================================================================================
397 void SMESHGUI_RotationDlg::ConstructorsClicked (int constructorId)
401 //=================================================================================
402 // function : ClickOnApply()
404 //=================================================================================
405 void SMESHGUI_RotationDlg::ClickOnApply()
407 if (mySMESHGUI->isActiveStudyLocked())
410 if (myNbOkElements && IsAxisOk()) {
411 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
413 SMESH::long_array_var anElementsId = new SMESH::long_array;
415 anElementsId->length(aListElementsId.count());
416 for (int i = 0; i < aListElementsId.count(); i++)
417 anElementsId[i] = aListElementsId[i].toInt();
419 SMESH::AxisStruct anAxis;
421 anAxis.x = SpinBox_X->GetValue();
422 anAxis.y = SpinBox_Y->GetValue();
423 anAxis.z = SpinBox_Z->GetValue();;
424 anAxis.vx = SpinBox_DX->GetValue();
425 anAxis.vy = SpinBox_DY->GetValue();
426 anAxis.vz = SpinBox_DZ->GetValue();
428 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
429 bool toCreateCopy = CheckBoxCopy->isChecked();
432 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
433 QApplication::setOverrideCursor(Qt::waitCursor);
434 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
435 QApplication::restoreOverrideCursor();
441 SelectionIntoArgument();
445 //=================================================================================
446 // function : ClickOnOk()
448 //=================================================================================
449 void SMESHGUI_RotationDlg::ClickOnOk()
455 //=================================================================================
456 // function : ClickOnCancel()
458 //=================================================================================
459 void SMESHGUI_RotationDlg::ClickOnCancel()
461 disconnect(mySelectionMgr, 0, this, 0);
462 mySelectionMgr->clearFilters();
463 //mySelectionMgr->clearSelected();
464 SMESH::SetPointRepresentation(false);
465 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
466 aViewWindow->SetSelectionMode(ActorSelection);
467 mySMESHGUI->ResetState();
471 //=================================================================================
472 // function : ClickOnHelp()
474 //=================================================================================
475 void SMESHGUI_RotationDlg::ClickOnHelp()
477 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
479 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
481 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
482 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
483 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
484 QObject::tr("BUT_OK"));
488 //=======================================================================
489 // function : onTextChange()
491 //=======================================================================
492 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
494 QLineEdit* send = (QLineEdit*)sender();
499 if (send == LineEditElements)
502 buttonOk->setEnabled(false);
503 buttonApply->setEnabled(false);
505 // hilight entered elements
506 SMDS_Mesh* aMesh = 0;
508 aMesh = myActor->GetObject()->GetMesh();
511 if (send == LineEditElements) {
512 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
514 TColStd_MapOfInteger newIndices;
516 QStringList aListId = QStringList::split(" ", theNewText, false);
517 for (int i = 0; i < aListId.count(); i++) {
518 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
520 newIndices.Add(e->GetID());
524 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
525 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
526 aViewWindow->highlight( anIO, true, true );
528 myElementsId = theNewText;
532 if (myNbOkElements && IsAxisOk()) {
533 buttonOk->setEnabled(true);
534 buttonApply->setEnabled(true);
540 //=================================================================================
541 // function : SelectionIntoArgument()
542 // purpose : Called when selection as changed or other case
543 //=================================================================================
544 void SMESHGUI_RotationDlg::SelectionIntoArgument()
550 QString aString = "";
553 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
554 LineEditElements->setText(aString);
556 buttonOk->setEnabled(false);
557 buttonApply->setEnabled(false);
561 if (!GroupButtons->isEnabled()) // inactive
566 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
568 int nbSel = aList.Extent();
572 Handle(SALOME_InteractiveObject) IO = aList.First();
573 myMesh = SMESH::GetMeshByIO(IO);
574 if (myMesh->_is_nil())
577 myActor = SMESH::FindActorByObject(myMesh);
579 myActor = SMESH::FindActorByEntry(IO->getEntry());
585 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
588 if (CheckBoxMesh->isChecked()) {
589 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
591 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
593 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
597 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
598 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
600 myElementsId += QString(" %1").arg(i);
604 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
606 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
608 // get IDs from submesh
609 SMESH::long_array_var anElementsIds = new SMESH::long_array;
610 anElementsIds = aSubMesh->GetElementsId();
611 for (int i = 0; i < anElementsIds->length(); i++) {
612 myElementsId += QString(" %1").arg(anElementsIds[i]);
614 aNbUnits = anElementsIds->length();
617 SMESH::SMESH_GroupBase_var aGroup =
618 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
619 if (aGroup->_is_nil())
622 // get IDs from smesh group
623 SMESH::long_array_var anElementsIds = new SMESH::long_array;
624 anElementsIds = aGroup->GetListOfID();
625 for (int i = 0; i < anElementsIds->length(); i++) {
626 myElementsId += QString(" %1").arg(anElementsIds[i]);
628 aNbUnits = anElementsIds->length();
631 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
632 myElementsId = aString;
638 myNbOkElements = true;
640 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
644 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
648 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
656 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
657 SpinBox_X->SetValue(x);
658 SpinBox_Y->SetValue(y);
659 SpinBox_Z->SetValue(z);
660 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
661 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
662 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
663 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
668 if (myEditCurrentArgument == (QWidget*)LineEditElements)
669 LineEditElements->setText(aString);
673 if (myNbOkElements && IsAxisOk()) {
674 buttonOk->setEnabled(true);
675 buttonApply->setEnabled(true);
679 //=================================================================================
680 // function : SetEditCurrentArgument()
682 //=================================================================================
683 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
685 QPushButton* send = (QPushButton*)sender();
687 disconnect(mySelectionMgr, 0, this, 0);
688 mySelectionMgr->clearSelected();
689 mySelectionMgr->clearFilters();
691 switch (myConstructorId) {
692 case 0: /* default constructor */
694 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
695 if (send == SelectElementsButton) {
696 myEditCurrentArgument = (QWidget*)LineEditElements;
697 SMESH::SetPointRepresentation(false);
698 if (CheckBoxMesh->isChecked()) {
700 aViewWindow->SetSelectionMode(ActorSelection);
701 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
704 aViewWindow->SetSelectionMode( CellSelection );
706 } else if (send == SelectPointButton) {
707 myEditCurrentArgument = (QWidget*)SpinBox_X;
708 SMESH::SetPointRepresentation(true);
710 aViewWindow->SetSelectionMode( NodeSelection );
711 } else if (send == SelectVectorButton) {
712 myEditCurrentArgument = (QWidget*)SpinBox_DX;
713 SMESH::SetPointRepresentation(true);
715 aViewWindow->SetSelectionMode( NodeSelection );
721 myEditCurrentArgument->setFocus();
722 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
723 SelectionIntoArgument();
726 //=================================================================================
727 // function : DeactivateActiveDialog()
729 //=================================================================================
730 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
732 if (GroupConstructors->isEnabled()) {
733 GroupConstructors->setEnabled(false);
734 GroupArguments->setEnabled(false);
735 GroupButtons->setEnabled(false);
736 mySMESHGUI->ResetState();
737 mySMESHGUI->SetActiveDialogBox(0);
741 //=================================================================================
742 // function : ActivateThisDialog()
744 //=================================================================================
745 void SMESHGUI_RotationDlg::ActivateThisDialog()
747 /* Emit a signal to deactivate the active dialog */
748 mySMESHGUI->EmitSignalDeactivateDialog();
749 GroupConstructors->setEnabled(true);
750 GroupArguments->setEnabled(true);
751 GroupButtons->setEnabled(true);
753 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
755 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
756 aViewWindow->SetSelectionMode( CellSelection );
757 SelectionIntoArgument();
760 //=================================================================================
761 // function : enterEvent()
763 //=================================================================================
764 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
766 if (!GroupConstructors->isEnabled())
767 ActivateThisDialog();
770 //=================================================================================
771 // function : closeEvent()
773 //=================================================================================
774 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
776 /* same than click on cancel button */
777 this->ClickOnCancel();
780 //=================================================================================
781 // function : hideEvent()
782 // purpose : caused by ESC key
783 //=================================================================================
784 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
790 //=================================================================================
791 // function : onSelectMesh()
793 //=================================================================================
794 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
797 TextLabelElements->setText(tr("SMESH_NAME"));
799 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
801 if (myEditCurrentArgument != LineEditElements) {
802 LineEditElements->clear();
806 mySelectionMgr->clearFilters();
807 SMESH::SetPointRepresentation(false);
810 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
811 aViewWindow->SetSelectionMode(ActorSelection);
812 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
813 LineEditElements->setReadOnly(true);
815 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
816 aViewWindow->SetSelectionMode( CellSelection );
817 LineEditElements->setReadOnly(false);
818 onTextChange(LineEditElements->text());
821 SelectionIntoArgument();
824 //=================================================================================
825 // function : IsAxisOk()
827 //=================================================================================
828 bool SMESHGUI_RotationDlg::IsAxisOk()
830 return (SpinBox_DX->GetValue() != 0 ||
831 SpinBox_DY->GetValue() != 0 ||
832 SpinBox_DZ->GetValue() != 0);
835 //=================================================================================
836 // function : onVectorChanged()
838 //=================================================================================
839 void SMESHGUI_RotationDlg::onVectorChanged()
842 buttonOk->setEnabled(true);
843 buttonApply->setEnabled(true);
845 buttonOk->setEnabled(false);
846 buttonApply->setEnabled(false);
850 //=================================================================================
851 // function : keyPressEvent()
853 //=================================================================================
854 void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e )
856 QDialog::keyPressEvent( e );
857 if ( e->isAccepted() )
860 if ( e->key() == Key_F1 )