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"
46 #include "SVTK_ViewModel.h"
47 #include "SVTK_ViewWindow.h"
48 #include "SVTK_Selector.h"
49 #include "SVTK_Selection.h"
50 #include "SALOME_ListIO.hxx"
52 #include "utilities.h"
55 #include <TColStd_MapOfInteger.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
59 #include <qapplication.h>
60 #include <qbuttongroup.h>
61 #include <qgroupbox.h>
63 #include <qlineedit.h>
64 #include <qpushbutton.h>
65 #include <qradiobutton.h>
66 #include <qcheckbox.h>
71 #include "SALOMEconfig.h"
72 #include CORBA_SERVER_HEADER(SMESH_Group)
76 //=================================================================================
77 // class : SMESHGUI_RotationDlg()
79 //=================================================================================
80 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule, const char* name,
81 bool modal, WFlags fl)
82 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
83 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
84 mySMESHGUI( theModule ),
85 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
87 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_ROTATION")));
88 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
91 setName("SMESHGUI_RotationDlg");
93 setCaption(tr("SMESH_ROTATION_TITLE"));
94 setSizeGripEnabled(TRUE);
95 SMESHGUI_RotationDlgLayout = new QGridLayout(this);
96 SMESHGUI_RotationDlgLayout->setSpacing(6);
97 SMESHGUI_RotationDlgLayout->setMargin(11);
99 /***************************************************************/
100 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
101 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
102 (QSizePolicy::SizeType)0, 0, 0,
103 GroupConstructors->sizePolicy().hasHeightForWidth()));
104 GroupConstructors->setTitle(tr("SMESH_ROTATION"));
105 GroupConstructors->setExclusive(TRUE);
106 GroupConstructors->setColumnLayout(0, Qt::Vertical);
107 GroupConstructors->layout()->setSpacing(0);
108 GroupConstructors->layout()->setMargin(0);
109 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
110 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
111 GroupConstructorsLayout->setSpacing(6);
112 GroupConstructorsLayout->setMargin(11);
113 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
114 RadioButton1->setText(tr("" ));
115 RadioButton1->setPixmap(image0);
116 RadioButton1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1,
117 (QSizePolicy::SizeType)0,
118 RadioButton1->sizePolicy().hasHeightForWidth()));
119 RadioButton1->setMinimumSize(QSize(50, 0));
120 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
121 QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
122 GroupConstructorsLayout->addItem(spacer, 0, 1);
123 SMESHGUI_RotationDlgLayout->addWidget(GroupConstructors, 0, 0);
125 /***************************************************************/
126 GroupButtons = new QGroupBox(this, "GroupButtons");
127 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
128 (QSizePolicy::SizeType)0, 0, 0,
129 GroupButtons->sizePolicy().hasHeightForWidth()));
130 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
131 GroupButtons->setTitle(tr("" ));
132 GroupButtons->setColumnLayout(0, Qt::Vertical);
133 GroupButtons->layout()->setSpacing(0);
134 GroupButtons->layout()->setMargin(0);
135 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
136 GroupButtonsLayout->setAlignment(Qt::AlignTop);
137 GroupButtonsLayout->setSpacing(6);
138 GroupButtonsLayout->setMargin(11);
139 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
140 buttonCancel->setText(tr("SMESH_BUT_CLOSE"));
141 buttonCancel->setAutoDefault(TRUE);
142 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
143 buttonApply = new QPushButton(GroupButtons, "buttonApply");
144 buttonApply->setText(tr("SMESH_BUT_APPLY"));
145 buttonApply->setAutoDefault(TRUE);
146 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
147 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
148 GroupButtonsLayout->addItem(spacer_9, 0, 2);
149 buttonOk = new QPushButton(GroupButtons, "buttonOk");
150 buttonOk->setText(tr("SMESH_BUT_OK"));
151 buttonOk->setAutoDefault(TRUE);
152 buttonOk->setDefault(TRUE);
153 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
154 SMESHGUI_RotationDlgLayout->addWidget(GroupButtons, 2, 0);
156 /***************************************************************/
157 GroupArguments = new QGroupBox(this, "GroupArguments");
158 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
159 GroupArguments->setColumnLayout(0, Qt::Vertical);
160 GroupArguments->layout()->setSpacing(0);
161 GroupArguments->layout()->setMargin(0);
162 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
163 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
164 GroupArgumentsLayout->setSpacing(6);
165 GroupArgumentsLayout->setMargin(11);
167 // Controls for elements selection
168 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
169 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
170 TextLabelElements->setFixedWidth(74);
171 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
173 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
174 SelectElementsButton->setText(tr("" ));
175 SelectElementsButton->setPixmap(image1);
176 SelectElementsButton->setToggleButton(FALSE);
177 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
179 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
180 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
181 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
183 // Control for the whole mesh selection
184 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
185 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
186 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
188 // Controls for axis defining
189 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
190 GroupAxis->setTitle(tr("SMESH_AXIS"));
191 GroupAxis->setColumnLayout(0, Qt::Vertical);
192 GroupAxis->layout()->setSpacing(0);
193 GroupAxis->layout()->setMargin(0);
194 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
195 GroupAxisLayout->setAlignment(Qt::AlignTop);
196 GroupAxisLayout->setSpacing(6);
197 GroupAxisLayout->setMargin(11);
199 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
200 TextLabelPoint->setText(tr("SMESH_POINT"));
201 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
203 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
204 SelectPointButton->setPixmap(image1);
205 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
207 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
208 TextLabelX->setText(tr("SMESH_X"));
209 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
211 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
212 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
214 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
215 TextLabelY->setText(tr("SMESH_Y"));
216 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
218 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
219 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
221 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
222 TextLabelZ->setText(tr("SMESH_Z"));
223 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
225 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
226 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
228 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
229 TextLabelVector->setText(tr("SMESH_VECTOR"));
230 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
232 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
233 SelectVectorButton->setPixmap(image1);
234 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
236 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
237 TextLabelDX->setText(tr("SMESH_DX"));
238 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
240 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
241 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
243 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
244 TextLabelDY->setText(tr("SMESH_DY"));
245 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
247 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
248 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
250 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
251 TextLabelDZ->setText(tr("SMESH_DZ"));
252 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
254 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
255 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
257 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 2);
259 // Controls for angle defining
260 TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle");
261 TextLabelAngle->setText(tr("SMESH_ANGLE"));
262 GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1);
264 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
265 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
267 // Controls for "Create a copy" option
268 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
269 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
270 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
272 SMESHGUI_RotationDlgLayout->addWidget(GroupArguments, 1, 0);
274 /* Initialisations */
275 SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
276 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
277 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
278 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
279 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
280 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
282 SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3);
284 GroupArguments->show();
286 RadioButton1->setChecked(TRUE);
288 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
290 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
292 // Costruction of the logical filter
293 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
294 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
296 QPtrList<SUIT_SelectionFilter> aListOfFilters;
297 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
298 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
300 myMeshOrSubMeshOrGroupFilter =
301 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
305 /* signals and slots connections */
306 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
307 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
308 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
309 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
311 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
312 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
313 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
315 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
316 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
317 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
319 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
320 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
321 /* to close dialog if study change */
322 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
323 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
324 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
326 /* Move widget on the botton right corner of main widget */
328 mySMESHGUI->DefineDlgPosition(this, x, y);
330 this->show(); /* displays Dialog */
332 ConstructorsClicked(0);
336 //=================================================================================
337 // function : ~SMESHGUI_RotationDlg()
338 // purpose : Destroys the object and frees any allocated resources
339 //=================================================================================
340 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
342 // no need to delete child widgets, Qt does it all for us
345 //=================================================================================
348 //=================================================================================
349 void SMESHGUI_RotationDlg::Init (bool ResetControls)
353 myEditCurrentArgument = (QWidget*)LineEditElements;
354 LineEditElements->setFocus();
358 buttonOk->setEnabled(false);
359 buttonApply->setEnabled(false);
362 myMesh = SMESH::SMESH_Mesh::_nil();
365 SpinBox_X->SetValue(0.0);
366 SpinBox_Y->SetValue(0.0);
367 SpinBox_Z->SetValue(0.0);
368 SpinBox_DX->SetValue(0.0);
369 SpinBox_DY->SetValue(0.0);
370 SpinBox_DZ->SetValue(0.0);
372 SpinBox_Angle->SetValue(45);
374 CheckBoxCopy->setChecked(false);
375 CheckBoxMesh->setChecked(false);
378 onSelectMesh(CheckBoxMesh->isChecked());
381 //=================================================================================
382 // function : ConstructorsClicked()
383 // purpose : Radio button management
384 //=================================================================================
385 void SMESHGUI_RotationDlg::ConstructorsClicked (int constructorId)
389 //=================================================================================
390 // function : ClickOnApply()
392 //=================================================================================
393 void SMESHGUI_RotationDlg::ClickOnApply()
395 if (mySMESHGUI->isActiveStudyLocked())
398 if (myNbOkElements && IsAxisOk()) {
399 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
401 SMESH::long_array_var anElementsId = new SMESH::long_array;
403 anElementsId->length(aListElementsId.count());
404 for (int i = 0; i < aListElementsId.count(); i++)
405 anElementsId[i] = aListElementsId[i].toInt();
407 SMESH::AxisStruct anAxis;
409 anAxis.x = SpinBox_X->GetValue();
410 anAxis.y = SpinBox_Y->GetValue();
411 anAxis.z = SpinBox_Z->GetValue();;
412 anAxis.vx = SpinBox_DX->GetValue();
413 anAxis.vy = SpinBox_DY->GetValue();
414 anAxis.vz = SpinBox_DZ->GetValue();
416 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
417 bool toCreateCopy = CheckBoxCopy->isChecked();
420 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
421 QApplication::setOverrideCursor(Qt::waitCursor);
422 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
423 QApplication::restoreOverrideCursor();
429 SelectionIntoArgument();
433 //=================================================================================
434 // function : ClickOnOk()
436 //=================================================================================
437 void SMESHGUI_RotationDlg::ClickOnOk()
443 //=================================================================================
444 // function : ClickOnCancel()
446 //=================================================================================
447 void SMESHGUI_RotationDlg::ClickOnCancel()
449 disconnect(mySelectionMgr, 0, this, 0);
450 mySelectionMgr->clearFilters();
451 //mySelectionMgr->clearSelected();
452 SMESH::SetPointRepresentation(false);
453 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
454 aViewWindow->SetSelectionMode(ActorSelection);
455 mySMESHGUI->ResetState();
459 //=======================================================================
460 // function : onTextChange()
462 //=======================================================================
463 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
465 QLineEdit* send = (QLineEdit*)sender();
470 if (send == LineEditElements)
473 buttonOk->setEnabled(false);
474 buttonApply->setEnabled(false);
476 // hilight entered elements
477 SMDS_Mesh* aMesh = 0;
479 aMesh = myActor->GetObject()->GetMesh();
482 if (send == LineEditElements) {
483 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
485 TColStd_MapOfInteger newIndices;
487 QStringList aListId = QStringList::split(" ", theNewText, false);
488 for (int i = 0; i < aListId.count(); i++) {
489 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
491 newIndices.Add(e->GetID());
495 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
496 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
497 aViewWindow->highlight( anIO, true, true );
499 myElementsId = theNewText;
503 if (myNbOkElements && IsAxisOk()) {
504 buttonOk->setEnabled(true);
505 buttonApply->setEnabled(true);
511 //=================================================================================
512 // function : SelectionIntoArgument()
513 // purpose : Called when selection as changed or other case
514 //=================================================================================
515 void SMESHGUI_RotationDlg::SelectionIntoArgument()
521 QString aString = "";
524 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
525 LineEditElements->setText(aString);
527 buttonOk->setEnabled(false);
528 buttonApply->setEnabled(false);
532 if (!GroupButtons->isEnabled()) // inactive
537 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
539 int nbSel = aList.Extent();
543 Handle(SALOME_InteractiveObject) IO = aList.First();
544 myMesh = SMESH::GetMeshByIO(IO);
545 if (myMesh->_is_nil())
548 myActor = SMESH::FindActorByObject(myMesh);
550 myActor = SMESH::FindActorByEntry(IO->getEntry());
556 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
559 if (CheckBoxMesh->isChecked()) {
560 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
562 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
564 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
568 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
569 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
571 myElementsId += QString(" %1").arg(i);
575 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
577 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
579 // get IDs from submesh
580 SMESH::long_array_var anElementsIds = new SMESH::long_array;
581 anElementsIds = aSubMesh->GetElementsId();
582 for (int i = 0; i < anElementsIds->length(); i++) {
583 myElementsId += QString(" %1").arg(anElementsIds[i]);
585 aNbUnits = anElementsIds->length();
588 SMESH::SMESH_GroupBase_var aGroup =
589 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
590 if (aGroup->_is_nil())
593 // get IDs from smesh group
594 SMESH::long_array_var anElementsIds = new SMESH::long_array;
595 anElementsIds = aGroup->GetListOfID();
596 for (int i = 0; i < anElementsIds->length(); i++) {
597 myElementsId += QString(" %1").arg(anElementsIds[i]);
599 aNbUnits = anElementsIds->length();
602 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
603 myElementsId = aString;
609 myNbOkElements = true;
611 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
615 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
619 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
627 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
628 SpinBox_X->SetValue(x);
629 SpinBox_Y->SetValue(y);
630 SpinBox_Z->SetValue(z);
631 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
632 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
633 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
634 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
639 if (myEditCurrentArgument == (QWidget*)LineEditElements)
640 LineEditElements->setText(aString);
644 if (myNbOkElements && IsAxisOk()) {
645 buttonOk->setEnabled(true);
646 buttonApply->setEnabled(true);
650 //=================================================================================
651 // function : SetEditCurrentArgument()
653 //=================================================================================
654 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
656 QPushButton* send = (QPushButton*)sender();
658 disconnect(mySelectionMgr, 0, this, 0);
659 mySelectionMgr->clearSelected();
660 mySelectionMgr->clearFilters();
662 switch (myConstructorId) {
663 case 0: /* default constructor */
665 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
666 if (send == SelectElementsButton) {
667 myEditCurrentArgument = (QWidget*)LineEditElements;
668 SMESH::SetPointRepresentation(false);
669 if (CheckBoxMesh->isChecked()) {
671 aViewWindow->SetSelectionMode(ActorSelection);
672 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
675 aViewWindow->SetSelectionMode( CellSelection );
677 } else if (send == SelectPointButton) {
678 myEditCurrentArgument = (QWidget*)SpinBox_X;
679 SMESH::SetPointRepresentation(true);
681 aViewWindow->SetSelectionMode( NodeSelection );
682 } else if (send == SelectVectorButton) {
683 myEditCurrentArgument = (QWidget*)SpinBox_DX;
684 SMESH::SetPointRepresentation(true);
686 aViewWindow->SetSelectionMode( NodeSelection );
692 myEditCurrentArgument->setFocus();
693 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
694 SelectionIntoArgument();
697 //=================================================================================
698 // function : DeactivateActiveDialog()
700 //=================================================================================
701 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
703 if (GroupConstructors->isEnabled()) {
704 GroupConstructors->setEnabled(false);
705 GroupArguments->setEnabled(false);
706 GroupButtons->setEnabled(false);
707 mySMESHGUI->ResetState();
708 mySMESHGUI->SetActiveDialogBox(0);
712 //=================================================================================
713 // function : ActivateThisDialog()
715 //=================================================================================
716 void SMESHGUI_RotationDlg::ActivateThisDialog()
718 /* Emit a signal to deactivate the active dialog */
719 mySMESHGUI->EmitSignalDeactivateDialog();
720 GroupConstructors->setEnabled(true);
721 GroupArguments->setEnabled(true);
722 GroupButtons->setEnabled(true);
724 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
726 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
727 aViewWindow->SetSelectionMode( CellSelection );
728 SelectionIntoArgument();
731 //=================================================================================
732 // function : enterEvent()
734 //=================================================================================
735 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
737 if (!GroupConstructors->isEnabled())
738 ActivateThisDialog();
741 //=================================================================================
742 // function : closeEvent()
744 //=================================================================================
745 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
747 /* same than click on cancel button */
748 this->ClickOnCancel();
751 //=================================================================================
752 // function : hideEvent()
753 // purpose : caused by ESC key
754 //=================================================================================
755 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
761 //=================================================================================
762 // function : onSelectMesh()
764 //=================================================================================
765 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
768 TextLabelElements->setText(tr("SMESH_NAME"));
770 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
772 if (myEditCurrentArgument != LineEditElements) {
773 LineEditElements->clear();
777 mySelectionMgr->clearFilters();
778 SMESH::SetPointRepresentation(false);
781 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
782 aViewWindow->SetSelectionMode(ActorSelection);
783 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
784 LineEditElements->setReadOnly(true);
786 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
787 aViewWindow->SetSelectionMode( CellSelection );
788 LineEditElements->setReadOnly(false);
789 onTextChange(LineEditElements->text());
792 SelectionIntoArgument();
795 //=================================================================================
796 // function : IsAxisOk()
798 //=================================================================================
799 bool SMESHGUI_RotationDlg::IsAxisOk()
801 return (SpinBox_DX->GetValue() != 0 ||
802 SpinBox_DY->GetValue() != 0 ||
803 SpinBox_DZ->GetValue() != 0);
806 //=================================================================================
807 // function : onVectorChanged()
809 //=================================================================================
810 void SMESHGUI_RotationDlg::onVectorChanged()
813 buttonOk->setEnabled(true);
814 buttonApply->setEnabled(true);
816 buttonOk->setEnabled(false);
817 buttonApply->setEnabled(false);