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->setText(tr("SMESH_X"));
216 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
218 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
219 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
221 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
222 TextLabelY->setText(tr("SMESH_Y"));
223 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
225 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
226 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
228 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
229 TextLabelZ->setText(tr("SMESH_Z"));
230 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
232 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
233 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
235 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
236 TextLabelVector->setText(tr("SMESH_VECTOR"));
237 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
239 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
240 SelectVectorButton->setPixmap(image1);
241 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
243 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
244 TextLabelDX->setText(tr("SMESH_DX"));
245 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
247 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
248 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
250 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
251 TextLabelDY->setText(tr("SMESH_DY"));
252 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
254 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
255 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
257 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
258 TextLabelDZ->setText(tr("SMESH_DZ"));
259 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
261 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
262 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
264 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 2);
266 // Controls for angle defining
267 TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle");
268 TextLabelAngle->setText(tr("SMESH_ANGLE"));
269 GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1);
271 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
272 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
274 // Controls for "Create a copy" option
275 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
276 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
277 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
279 SMESHGUI_RotationDlgLayout->addWidget(GroupArguments, 1, 0);
281 /* Initialisations */
282 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
283 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
284 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
286 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
287 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
289 SpinBox_Angle->RangeStepAndValidator(-360.0, +360.0, 5.0, 3);
291 GroupArguments->show();
293 RadioButton1->setChecked(TRUE);
295 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
297 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
299 // Costruction of the logical filter
300 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
301 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
303 QPtrList<SUIT_SelectionFilter> aListOfFilters;
304 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
305 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
307 myMeshOrSubMeshOrGroupFilter =
308 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
310 myHelpFileName = "/files/rotation.htm";
314 /* signals and slots connections */
315 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
316 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
317 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
318 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
319 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
321 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
322 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
323 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
325 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
326 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
327 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
329 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
330 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
331 /* to close dialog if study change */
332 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
333 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
334 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
336 this->show(); /* displays Dialog */
338 ConstructorsClicked(0);
342 //=================================================================================
343 // function : ~SMESHGUI_RotationDlg()
344 // purpose : Destroys the object and frees any allocated resources
345 //=================================================================================
346 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
348 // no need to delete child widgets, Qt does it all for us
351 //=================================================================================
354 //=================================================================================
355 void SMESHGUI_RotationDlg::Init (bool ResetControls)
359 myEditCurrentArgument = (QWidget*)LineEditElements;
360 LineEditElements->setFocus();
364 buttonOk->setEnabled(false);
365 buttonApply->setEnabled(false);
368 myMesh = SMESH::SMESH_Mesh::_nil();
371 SpinBox_X->SetValue(0.0);
372 SpinBox_Y->SetValue(0.0);
373 SpinBox_Z->SetValue(0.0);
374 SpinBox_DX->SetValue(0.0);
375 SpinBox_DY->SetValue(0.0);
376 SpinBox_DZ->SetValue(0.0);
378 SpinBox_Angle->SetValue(45);
380 CheckBoxCopy->setChecked(false);
381 CheckBoxMesh->setChecked(false);
384 onSelectMesh(CheckBoxMesh->isChecked());
387 //=================================================================================
388 // function : ConstructorsClicked()
389 // purpose : Radio button management
390 //=================================================================================
391 void SMESHGUI_RotationDlg::ConstructorsClicked (int constructorId)
395 //=================================================================================
396 // function : ClickOnApply()
398 //=================================================================================
399 void SMESHGUI_RotationDlg::ClickOnApply()
401 if (mySMESHGUI->isActiveStudyLocked())
404 if (myNbOkElements && IsAxisOk()) {
405 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
407 SMESH::long_array_var anElementsId = new SMESH::long_array;
409 anElementsId->length(aListElementsId.count());
410 for (int i = 0; i < aListElementsId.count(); i++)
411 anElementsId[i] = aListElementsId[i].toInt();
413 SMESH::AxisStruct anAxis;
415 anAxis.x = SpinBox_X->GetValue();
416 anAxis.y = SpinBox_Y->GetValue();
417 anAxis.z = SpinBox_Z->GetValue();;
418 anAxis.vx = SpinBox_DX->GetValue();
419 anAxis.vy = SpinBox_DY->GetValue();
420 anAxis.vz = SpinBox_DZ->GetValue();
422 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
423 bool toCreateCopy = CheckBoxCopy->isChecked();
426 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
427 QApplication::setOverrideCursor(Qt::waitCursor);
428 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
429 QApplication::restoreOverrideCursor();
435 SelectionIntoArgument();
439 //=================================================================================
440 // function : ClickOnOk()
442 //=================================================================================
443 void SMESHGUI_RotationDlg::ClickOnOk()
449 //=================================================================================
450 // function : ClickOnCancel()
452 //=================================================================================
453 void SMESHGUI_RotationDlg::ClickOnCancel()
455 disconnect(mySelectionMgr, 0, this, 0);
456 mySelectionMgr->clearFilters();
457 //mySelectionMgr->clearSelected();
458 SMESH::SetPointRepresentation(false);
459 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
460 aViewWindow->SetSelectionMode(ActorSelection);
461 mySMESHGUI->ResetState();
465 //=================================================================================
466 // function : ClickOnHelp()
468 //=================================================================================
469 void SMESHGUI_RotationDlg::ClickOnHelp()
471 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
473 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
477 platform = "winapplication";
479 platform = "application";
481 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
482 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
483 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).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, myActor->getIO(), aString);
632 myElementsId = aString;
638 myNbOkElements = true;
640 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), 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 )