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 ) ),
86 myViewWindow( SMESH::GetViewWindow( theModule ) ),
87 mySelector( myViewWindow->GetSelector() )
89 QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_ROTATION")));
90 QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
93 setName("SMESHGUI_RotationDlg");
95 setCaption(tr("SMESH_ROTATION_TITLE"));
96 setSizeGripEnabled(TRUE);
97 SMESHGUI_RotationDlgLayout = new QGridLayout(this);
98 SMESHGUI_RotationDlgLayout->setSpacing(6);
99 SMESHGUI_RotationDlgLayout->setMargin(11);
101 /***************************************************************/
102 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
103 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
104 (QSizePolicy::SizeType)0, 0, 0,
105 GroupConstructors->sizePolicy().hasHeightForWidth()));
106 GroupConstructors->setTitle(tr("SMESH_ROTATION"));
107 GroupConstructors->setExclusive(TRUE);
108 GroupConstructors->setColumnLayout(0, Qt::Vertical);
109 GroupConstructors->layout()->setSpacing(0);
110 GroupConstructors->layout()->setMargin(0);
111 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
112 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
113 GroupConstructorsLayout->setSpacing(6);
114 GroupConstructorsLayout->setMargin(11);
115 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
116 RadioButton1->setText(tr("" ));
117 RadioButton1->setPixmap(image0);
118 RadioButton1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1,
119 (QSizePolicy::SizeType)0,
120 RadioButton1->sizePolicy().hasHeightForWidth()));
121 RadioButton1->setMinimumSize(QSize(50, 0));
122 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
123 QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
124 GroupConstructorsLayout->addItem(spacer, 0, 1);
125 SMESHGUI_RotationDlgLayout->addWidget(GroupConstructors, 0, 0);
127 /***************************************************************/
128 GroupButtons = new QGroupBox(this, "GroupButtons");
129 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
130 (QSizePolicy::SizeType)0, 0, 0,
131 GroupButtons->sizePolicy().hasHeightForWidth()));
132 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
133 GroupButtons->setTitle(tr("" ));
134 GroupButtons->setColumnLayout(0, Qt::Vertical);
135 GroupButtons->layout()->setSpacing(0);
136 GroupButtons->layout()->setMargin(0);
137 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
138 GroupButtonsLayout->setAlignment(Qt::AlignTop);
139 GroupButtonsLayout->setSpacing(6);
140 GroupButtonsLayout->setMargin(11);
141 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
142 buttonCancel->setText(tr("SMESH_BUT_CLOSE"));
143 buttonCancel->setAutoDefault(TRUE);
144 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
145 buttonApply = new QPushButton(GroupButtons, "buttonApply");
146 buttonApply->setText(tr("SMESH_BUT_APPLY"));
147 buttonApply->setAutoDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
149 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
150 GroupButtonsLayout->addItem(spacer_9, 0, 2);
151 buttonOk = new QPushButton(GroupButtons, "buttonOk");
152 buttonOk->setText(tr("SMESH_BUT_OK"));
153 buttonOk->setAutoDefault(TRUE);
154 buttonOk->setDefault(TRUE);
155 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
156 SMESHGUI_RotationDlgLayout->addWidget(GroupButtons, 2, 0);
158 /***************************************************************/
159 GroupArguments = new QGroupBox(this, "GroupArguments");
160 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
161 GroupArguments->setColumnLayout(0, Qt::Vertical);
162 GroupArguments->layout()->setSpacing(0);
163 GroupArguments->layout()->setMargin(0);
164 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
165 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
166 GroupArgumentsLayout->setSpacing(6);
167 GroupArgumentsLayout->setMargin(11);
169 // Controls for elements selection
170 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
171 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
172 TextLabelElements->setFixedWidth(74);
173 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
175 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
176 SelectElementsButton->setText(tr("" ));
177 SelectElementsButton->setPixmap(image1);
178 SelectElementsButton->setToggleButton(FALSE);
179 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
181 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
182 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
183 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
185 // Control for the whole mesh selection
186 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
187 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
188 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
190 // Controls for axis defining
191 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
192 GroupAxis->setTitle(tr("SMESH_AXIS"));
193 GroupAxis->setColumnLayout(0, Qt::Vertical);
194 GroupAxis->layout()->setSpacing(0);
195 GroupAxis->layout()->setMargin(0);
196 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
197 GroupAxisLayout->setAlignment(Qt::AlignTop);
198 GroupAxisLayout->setSpacing(6);
199 GroupAxisLayout->setMargin(11);
201 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
202 TextLabelPoint->setText(tr("SMESH_POINT"));
203 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
205 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
206 SelectPointButton->setPixmap(image1);
207 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
209 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
210 TextLabelX->setText(tr("SMESH_X"));
211 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
213 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
214 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
216 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
217 TextLabelY->setText(tr("SMESH_Y"));
218 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
220 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
221 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
223 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
224 TextLabelZ->setText(tr("SMESH_Z"));
225 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
227 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
228 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
230 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
231 TextLabelVector->setText(tr("SMESH_VECTOR"));
232 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
234 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
235 SelectVectorButton->setPixmap(image1);
236 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
238 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
239 TextLabelDX->setText(tr("SMESH_DX"));
240 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
242 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
243 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
245 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
246 TextLabelDY->setText(tr("SMESH_DY"));
247 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
249 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
250 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
252 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
253 TextLabelDZ->setText(tr("SMESH_DZ"));
254 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
256 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
257 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
259 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 2);
261 // Controls for angle defining
262 TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle");
263 TextLabelAngle->setText(tr("SMESH_ANGLE"));
264 GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1);
266 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
267 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
269 // Controls for "Create a copy" option
270 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
271 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
272 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
274 SMESHGUI_RotationDlgLayout->addWidget(GroupArguments, 1, 0);
276 /* Initialisations */
277 SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
278 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
279 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
280 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
281 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
282 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
284 SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3);
286 GroupArguments->show();
288 RadioButton1->setChecked(TRUE);
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();
427 mySelectionMgr->clearSelected();
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 myViewWindow->SetSelectionMode(ActorSelection);
454 mySMESHGUI->ResetState();
458 //=======================================================================
459 // function : onTextChange()
461 //=======================================================================
462 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
464 QLineEdit* send = (QLineEdit*)sender();
469 if (send == LineEditElements)
472 buttonOk->setEnabled(false);
473 buttonApply->setEnabled(false);
475 // hilight entered elements
476 SMDS_Mesh* aMesh = 0;
478 aMesh = myActor->GetObject()->GetMesh();
481 if (send == LineEditElements) {
482 //mySelectionMgr->clearSelected();
483 //mySelectionMgr->AddIObject(myActor->getIO());
485 aList.Append(myActor->getIO());
486 mySelectionMgr->setSelectedObjects(aList, false);
488 TColStd_IndexedMapOfInteger selectedIndices;
489 TColStd_MapOfInteger newIndices;
490 mySelector->GetIndex( myActor->getIO(), selectedIndices);
492 QStringList aListId = QStringList::split(" ", theNewText, false);
493 for (int i = 0; i < aListId.count(); i++) {
494 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
496 //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) {
497 if (selectedIndices.Add(e->GetID())) {
498 //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
499 newIndices.Add(e->GetID());
505 if (newIndices.Extent() > 0){
506 mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true );
507 myViewWindow->highlight( myActor->getIO(), true, true );
510 myElementsId = theNewText;
514 if (myNbOkElements && IsAxisOk()) {
515 buttonOk->setEnabled(true);
516 buttonApply->setEnabled(true);
522 //=================================================================================
523 // function : SelectionIntoArgument()
524 // purpose : Called when selection as changed or other case
525 //=================================================================================
526 void SMESHGUI_RotationDlg::SelectionIntoArgument()
532 QString aString = "";
535 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
536 LineEditElements->setText(aString);
538 buttonOk->setEnabled(false);
539 buttonApply->setEnabled(false);
543 if (!GroupButtons->isEnabled()) // inactive
548 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
550 int nbSel = aList.Extent();
554 Handle(SALOME_InteractiveObject) IO = aList.First();
555 myMesh = SMESH::GetMeshByIO(IO);
556 if (myMesh->_is_nil())
559 myActor = SMESH::FindActorByObject(myMesh);
561 myActor = SMESH::FindActorByEntry(IO->getEntry());
567 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
570 if (CheckBoxMesh->isChecked()) {
571 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
573 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
575 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
579 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
580 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
582 myElementsId += QString(" %1").arg(i);
586 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
588 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
590 // get IDs from submesh
591 SMESH::long_array_var anElementsIds = new SMESH::long_array;
592 anElementsIds = aSubMesh->GetElementsId();
593 for (int i = 0; i < anElementsIds->length(); i++) {
594 myElementsId += QString(" %1").arg(anElementsIds[i]);
596 aNbUnits = anElementsIds->length();
599 SMESH::SMESH_GroupBase_var aGroup =
600 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
601 if (aGroup->_is_nil())
604 // get IDs from smesh group
605 SMESH::long_array_var anElementsIds = new SMESH::long_array;
606 anElementsIds = aGroup->GetListOfID();
607 for (int i = 0; i < anElementsIds->length(); i++) {
608 myElementsId += QString(" %1").arg(anElementsIds[i]);
610 aNbUnits = anElementsIds->length();
613 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
614 myElementsId = aString;
620 myNbOkElements = true;
622 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
626 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
630 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
638 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
639 SpinBox_X->SetValue(x);
640 SpinBox_Y->SetValue(y);
641 SpinBox_Z->SetValue(z);
642 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
643 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
644 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
645 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
650 if (myEditCurrentArgument == (QWidget*)LineEditElements)
651 LineEditElements->setText(aString);
655 if (myNbOkElements && IsAxisOk()) {
656 buttonOk->setEnabled(true);
657 buttonApply->setEnabled(true);
661 //=================================================================================
662 // function : SetEditCurrentArgument()
664 //=================================================================================
665 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
667 QPushButton* send = (QPushButton*)sender();
669 disconnect(mySelectionMgr, 0, this, 0);
670 mySelectionMgr->clearSelected();
671 mySelectionMgr->clearFilters();
673 switch (myConstructorId) {
674 case 0: /* default constructor */
676 if (send == SelectElementsButton) {
677 myEditCurrentArgument = (QWidget*)LineEditElements;
678 SMESH::SetPointRepresentation(false);
679 if (CheckBoxMesh->isChecked()) {
680 myViewWindow->SetSelectionMode(ActorSelection);
681 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
684 myViewWindow->SetSelectionMode( CellSelection );
686 } else if (send == SelectPointButton) {
687 myEditCurrentArgument = (QWidget*)SpinBox_X;
688 SMESH::SetPointRepresentation(true);
690 myViewWindow->SetSelectionMode( NodeSelection );
691 } else if (send == SelectVectorButton) {
692 myEditCurrentArgument = (QWidget*)SpinBox_DX;
693 SMESH::SetPointRepresentation(true);
695 myViewWindow->SetSelectionMode( NodeSelection );
701 myEditCurrentArgument->setFocus();
702 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
703 SelectionIntoArgument();
706 //=================================================================================
707 // function : DeactivateActiveDialog()
709 //=================================================================================
710 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
712 if (GroupConstructors->isEnabled()) {
713 GroupConstructors->setEnabled(false);
714 GroupArguments->setEnabled(false);
715 GroupButtons->setEnabled(false);
716 mySMESHGUI->ResetState();
717 mySMESHGUI->SetActiveDialogBox(0);
721 //=================================================================================
722 // function : ActivateThisDialog()
724 //=================================================================================
725 void SMESHGUI_RotationDlg::ActivateThisDialog()
727 /* Emit a signal to deactivate the active dialog */
728 mySMESHGUI->EmitSignalDeactivateDialog();
729 GroupConstructors->setEnabled(true);
730 GroupArguments->setEnabled(true);
731 GroupButtons->setEnabled(true);
733 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
735 myViewWindow->SetSelectionMode( CellSelection );
736 SelectionIntoArgument();
739 //=================================================================================
740 // function : enterEvent()
742 //=================================================================================
743 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
745 if (!GroupConstructors->isEnabled())
746 ActivateThisDialog();
749 //=================================================================================
750 // function : closeEvent()
752 //=================================================================================
753 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
755 /* same than click on cancel button */
756 this->ClickOnCancel();
759 //=================================================================================
760 // function : hideEvent()
761 // purpose : caused by ESC key
762 //=================================================================================
763 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
769 //=================================================================================
770 // function : onSelectMesh()
772 //=================================================================================
773 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
776 TextLabelElements->setText(tr("SMESH_NAME"));
778 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
780 if (myEditCurrentArgument != LineEditElements) {
781 LineEditElements->clear();
785 mySelectionMgr->clearFilters();
786 SMESH::SetPointRepresentation(false);
789 myViewWindow->SetSelectionMode(ActorSelection);
790 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
791 LineEditElements->setReadOnly(true);
793 myViewWindow->SetSelectionMode( CellSelection );
794 LineEditElements->setReadOnly(false);
795 onTextChange(LineEditElements->text());
798 SelectionIntoArgument();
801 //=================================================================================
802 // function : IsAxisOk()
804 //=================================================================================
805 bool SMESHGUI_RotationDlg::IsAxisOk()
807 return (SpinBox_DX->GetValue() != 0 ||
808 SpinBox_DY->GetValue() != 0 ||
809 SpinBox_DZ->GetValue() != 0);
812 //=================================================================================
813 // function : onVectorChanged()
815 //=================================================================================
816 void SMESHGUI_RotationDlg::onVectorChanged()
819 buttonOk->setEnabled(true);
820 buttonApply->setEnabled(true);
822 buttonOk->setEnabled(false);
823 buttonApply->setEnabled(false);