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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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_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(-999999.999, +999999.999, 10.0, 3);
283 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
284 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
285 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
286 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
287 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
289 SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 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);
475 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
476 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
477 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
478 QObject::tr("BUT_OK"));
482 //=======================================================================
483 // function : onTextChange()
485 //=======================================================================
486 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
488 QLineEdit* send = (QLineEdit*)sender();
493 if (send == LineEditElements)
496 buttonOk->setEnabled(false);
497 buttonApply->setEnabled(false);
499 // hilight entered elements
500 SMDS_Mesh* aMesh = 0;
502 aMesh = myActor->GetObject()->GetMesh();
505 if (send == LineEditElements) {
506 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
508 TColStd_MapOfInteger newIndices;
510 QStringList aListId = QStringList::split(" ", theNewText, false);
511 for (int i = 0; i < aListId.count(); i++) {
512 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
514 newIndices.Add(e->GetID());
518 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
519 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
520 aViewWindow->highlight( anIO, true, true );
522 myElementsId = theNewText;
526 if (myNbOkElements && IsAxisOk()) {
527 buttonOk->setEnabled(true);
528 buttonApply->setEnabled(true);
534 //=================================================================================
535 // function : SelectionIntoArgument()
536 // purpose : Called when selection as changed or other case
537 //=================================================================================
538 void SMESHGUI_RotationDlg::SelectionIntoArgument()
544 QString aString = "";
547 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
548 LineEditElements->setText(aString);
550 buttonOk->setEnabled(false);
551 buttonApply->setEnabled(false);
555 if (!GroupButtons->isEnabled()) // inactive
560 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
562 int nbSel = aList.Extent();
566 Handle(SALOME_InteractiveObject) IO = aList.First();
567 myMesh = SMESH::GetMeshByIO(IO);
568 if (myMesh->_is_nil())
571 myActor = SMESH::FindActorByObject(myMesh);
573 myActor = SMESH::FindActorByEntry(IO->getEntry());
579 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
582 if (CheckBoxMesh->isChecked()) {
583 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
585 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
587 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
591 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
592 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
594 myElementsId += QString(" %1").arg(i);
598 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
600 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
602 // get IDs from submesh
603 SMESH::long_array_var anElementsIds = new SMESH::long_array;
604 anElementsIds = aSubMesh->GetElementsId();
605 for (int i = 0; i < anElementsIds->length(); i++) {
606 myElementsId += QString(" %1").arg(anElementsIds[i]);
608 aNbUnits = anElementsIds->length();
611 SMESH::SMESH_GroupBase_var aGroup =
612 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
613 if (aGroup->_is_nil())
616 // get IDs from smesh group
617 SMESH::long_array_var anElementsIds = new SMESH::long_array;
618 anElementsIds = aGroup->GetListOfID();
619 for (int i = 0; i < anElementsIds->length(); i++) {
620 myElementsId += QString(" %1").arg(anElementsIds[i]);
622 aNbUnits = anElementsIds->length();
625 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
626 myElementsId = aString;
632 myNbOkElements = true;
634 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
638 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
642 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
650 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
651 SpinBox_X->SetValue(x);
652 SpinBox_Y->SetValue(y);
653 SpinBox_Z->SetValue(z);
654 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
655 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
656 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
657 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
662 if (myEditCurrentArgument == (QWidget*)LineEditElements)
663 LineEditElements->setText(aString);
667 if (myNbOkElements && IsAxisOk()) {
668 buttonOk->setEnabled(true);
669 buttonApply->setEnabled(true);
673 //=================================================================================
674 // function : SetEditCurrentArgument()
676 //=================================================================================
677 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
679 QPushButton* send = (QPushButton*)sender();
681 disconnect(mySelectionMgr, 0, this, 0);
682 mySelectionMgr->clearSelected();
683 mySelectionMgr->clearFilters();
685 switch (myConstructorId) {
686 case 0: /* default constructor */
688 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
689 if (send == SelectElementsButton) {
690 myEditCurrentArgument = (QWidget*)LineEditElements;
691 SMESH::SetPointRepresentation(false);
692 if (CheckBoxMesh->isChecked()) {
694 aViewWindow->SetSelectionMode(ActorSelection);
695 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
698 aViewWindow->SetSelectionMode( CellSelection );
700 } else if (send == SelectPointButton) {
701 myEditCurrentArgument = (QWidget*)SpinBox_X;
702 SMESH::SetPointRepresentation(true);
704 aViewWindow->SetSelectionMode( NodeSelection );
705 } else if (send == SelectVectorButton) {
706 myEditCurrentArgument = (QWidget*)SpinBox_DX;
707 SMESH::SetPointRepresentation(true);
709 aViewWindow->SetSelectionMode( NodeSelection );
715 myEditCurrentArgument->setFocus();
716 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
717 SelectionIntoArgument();
720 //=================================================================================
721 // function : DeactivateActiveDialog()
723 //=================================================================================
724 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
726 if (GroupConstructors->isEnabled()) {
727 GroupConstructors->setEnabled(false);
728 GroupArguments->setEnabled(false);
729 GroupButtons->setEnabled(false);
730 mySMESHGUI->ResetState();
731 mySMESHGUI->SetActiveDialogBox(0);
735 //=================================================================================
736 // function : ActivateThisDialog()
738 //=================================================================================
739 void SMESHGUI_RotationDlg::ActivateThisDialog()
741 /* Emit a signal to deactivate the active dialog */
742 mySMESHGUI->EmitSignalDeactivateDialog();
743 GroupConstructors->setEnabled(true);
744 GroupArguments->setEnabled(true);
745 GroupButtons->setEnabled(true);
747 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
749 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
750 aViewWindow->SetSelectionMode( CellSelection );
751 SelectionIntoArgument();
754 //=================================================================================
755 // function : enterEvent()
757 //=================================================================================
758 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
760 if (!GroupConstructors->isEnabled())
761 ActivateThisDialog();
764 //=================================================================================
765 // function : closeEvent()
767 //=================================================================================
768 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
770 /* same than click on cancel button */
771 this->ClickOnCancel();
774 //=================================================================================
775 // function : hideEvent()
776 // purpose : caused by ESC key
777 //=================================================================================
778 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
784 //=================================================================================
785 // function : onSelectMesh()
787 //=================================================================================
788 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
791 TextLabelElements->setText(tr("SMESH_NAME"));
793 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
795 if (myEditCurrentArgument != LineEditElements) {
796 LineEditElements->clear();
800 mySelectionMgr->clearFilters();
801 SMESH::SetPointRepresentation(false);
804 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
805 aViewWindow->SetSelectionMode(ActorSelection);
806 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
807 LineEditElements->setReadOnly(true);
809 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
810 aViewWindow->SetSelectionMode( CellSelection );
811 LineEditElements->setReadOnly(false);
812 onTextChange(LineEditElements->text());
815 SelectionIntoArgument();
818 //=================================================================================
819 // function : IsAxisOk()
821 //=================================================================================
822 bool SMESHGUI_RotationDlg::IsAxisOk()
824 return (SpinBox_DX->GetValue() != 0 ||
825 SpinBox_DY->GetValue() != 0 ||
826 SpinBox_DZ->GetValue() != 0);
829 //=================================================================================
830 // function : onVectorChanged()
832 //=================================================================================
833 void SMESHGUI_RotationDlg::onVectorChanged()
836 buttonOk->setEnabled(true);
837 buttonApply->setEnabled(true);
839 buttonOk->setEnabled(false);
840 buttonApply->setEnabled(false);