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 this->show(); /* displays Dialog */
328 ConstructorsClicked(0);
332 //=================================================================================
333 // function : ~SMESHGUI_RotationDlg()
334 // purpose : Destroys the object and frees any allocated resources
335 //=================================================================================
336 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
338 // no need to delete child widgets, Qt does it all for us
341 //=================================================================================
344 //=================================================================================
345 void SMESHGUI_RotationDlg::Init (bool ResetControls)
349 myEditCurrentArgument = (QWidget*)LineEditElements;
350 LineEditElements->setFocus();
354 buttonOk->setEnabled(false);
355 buttonApply->setEnabled(false);
358 myMesh = SMESH::SMESH_Mesh::_nil();
361 SpinBox_X->SetValue(0.0);
362 SpinBox_Y->SetValue(0.0);
363 SpinBox_Z->SetValue(0.0);
364 SpinBox_DX->SetValue(0.0);
365 SpinBox_DY->SetValue(0.0);
366 SpinBox_DZ->SetValue(0.0);
368 SpinBox_Angle->SetValue(45);
370 CheckBoxCopy->setChecked(false);
371 CheckBoxMesh->setChecked(false);
374 onSelectMesh(CheckBoxMesh->isChecked());
377 //=================================================================================
378 // function : ConstructorsClicked()
379 // purpose : Radio button management
380 //=================================================================================
381 void SMESHGUI_RotationDlg::ConstructorsClicked (int constructorId)
385 //=================================================================================
386 // function : ClickOnApply()
388 //=================================================================================
389 void SMESHGUI_RotationDlg::ClickOnApply()
391 if (mySMESHGUI->isActiveStudyLocked())
394 if (myNbOkElements && IsAxisOk()) {
395 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
397 SMESH::long_array_var anElementsId = new SMESH::long_array;
399 anElementsId->length(aListElementsId.count());
400 for (int i = 0; i < aListElementsId.count(); i++)
401 anElementsId[i] = aListElementsId[i].toInt();
403 SMESH::AxisStruct anAxis;
405 anAxis.x = SpinBox_X->GetValue();
406 anAxis.y = SpinBox_Y->GetValue();
407 anAxis.z = SpinBox_Z->GetValue();;
408 anAxis.vx = SpinBox_DX->GetValue();
409 anAxis.vy = SpinBox_DY->GetValue();
410 anAxis.vz = SpinBox_DZ->GetValue();
412 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
413 bool toCreateCopy = CheckBoxCopy->isChecked();
416 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
417 QApplication::setOverrideCursor(Qt::waitCursor);
418 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
419 QApplication::restoreOverrideCursor();
425 SelectionIntoArgument();
429 //=================================================================================
430 // function : ClickOnOk()
432 //=================================================================================
433 void SMESHGUI_RotationDlg::ClickOnOk()
439 //=================================================================================
440 // function : ClickOnCancel()
442 //=================================================================================
443 void SMESHGUI_RotationDlg::ClickOnCancel()
445 disconnect(mySelectionMgr, 0, this, 0);
446 mySelectionMgr->clearFilters();
447 //mySelectionMgr->clearSelected();
448 SMESH::SetPointRepresentation(false);
449 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
450 aViewWindow->SetSelectionMode(ActorSelection);
451 mySMESHGUI->ResetState();
455 //=======================================================================
456 // function : onTextChange()
458 //=======================================================================
459 void SMESHGUI_RotationDlg::onTextChange (const QString& theNewText)
461 QLineEdit* send = (QLineEdit*)sender();
466 if (send == LineEditElements)
469 buttonOk->setEnabled(false);
470 buttonApply->setEnabled(false);
472 // hilight entered elements
473 SMDS_Mesh* aMesh = 0;
475 aMesh = myActor->GetObject()->GetMesh();
478 if (send == LineEditElements) {
479 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
481 TColStd_MapOfInteger newIndices;
483 QStringList aListId = QStringList::split(" ", theNewText, false);
484 for (int i = 0; i < aListId.count(); i++) {
485 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
487 newIndices.Add(e->GetID());
491 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
492 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
493 aViewWindow->highlight( anIO, true, true );
495 myElementsId = theNewText;
499 if (myNbOkElements && IsAxisOk()) {
500 buttonOk->setEnabled(true);
501 buttonApply->setEnabled(true);
507 //=================================================================================
508 // function : SelectionIntoArgument()
509 // purpose : Called when selection as changed or other case
510 //=================================================================================
511 void SMESHGUI_RotationDlg::SelectionIntoArgument()
517 QString aString = "";
520 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
521 LineEditElements->setText(aString);
523 buttonOk->setEnabled(false);
524 buttonApply->setEnabled(false);
528 if (!GroupButtons->isEnabled()) // inactive
533 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
535 int nbSel = aList.Extent();
539 Handle(SALOME_InteractiveObject) IO = aList.First();
540 myMesh = SMESH::GetMeshByIO(IO);
541 if (myMesh->_is_nil())
544 myActor = SMESH::FindActorByObject(myMesh);
546 myActor = SMESH::FindActorByEntry(IO->getEntry());
552 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
555 if (CheckBoxMesh->isChecked()) {
556 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
558 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
560 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
564 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
565 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
567 myElementsId += QString(" %1").arg(i);
571 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
573 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
575 // get IDs from submesh
576 SMESH::long_array_var anElementsIds = new SMESH::long_array;
577 anElementsIds = aSubMesh->GetElementsId();
578 for (int i = 0; i < anElementsIds->length(); i++) {
579 myElementsId += QString(" %1").arg(anElementsIds[i]);
581 aNbUnits = anElementsIds->length();
584 SMESH::SMESH_GroupBase_var aGroup =
585 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
586 if (aGroup->_is_nil())
589 // get IDs from smesh group
590 SMESH::long_array_var anElementsIds = new SMESH::long_array;
591 anElementsIds = aGroup->GetListOfID();
592 for (int i = 0; i < anElementsIds->length(); i++) {
593 myElementsId += QString(" %1").arg(anElementsIds[i]);
595 aNbUnits = anElementsIds->length();
598 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
599 myElementsId = aString;
605 myNbOkElements = true;
607 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
611 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
615 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
623 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
624 SpinBox_X->SetValue(x);
625 SpinBox_Y->SetValue(y);
626 SpinBox_Z->SetValue(z);
627 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
628 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
629 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
630 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
635 if (myEditCurrentArgument == (QWidget*)LineEditElements)
636 LineEditElements->setText(aString);
640 if (myNbOkElements && IsAxisOk()) {
641 buttonOk->setEnabled(true);
642 buttonApply->setEnabled(true);
646 //=================================================================================
647 // function : SetEditCurrentArgument()
649 //=================================================================================
650 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
652 QPushButton* send = (QPushButton*)sender();
654 disconnect(mySelectionMgr, 0, this, 0);
655 mySelectionMgr->clearSelected();
656 mySelectionMgr->clearFilters();
658 switch (myConstructorId) {
659 case 0: /* default constructor */
661 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
662 if (send == SelectElementsButton) {
663 myEditCurrentArgument = (QWidget*)LineEditElements;
664 SMESH::SetPointRepresentation(false);
665 if (CheckBoxMesh->isChecked()) {
667 aViewWindow->SetSelectionMode(ActorSelection);
668 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
671 aViewWindow->SetSelectionMode( CellSelection );
673 } else if (send == SelectPointButton) {
674 myEditCurrentArgument = (QWidget*)SpinBox_X;
675 SMESH::SetPointRepresentation(true);
677 aViewWindow->SetSelectionMode( NodeSelection );
678 } else if (send == SelectVectorButton) {
679 myEditCurrentArgument = (QWidget*)SpinBox_DX;
680 SMESH::SetPointRepresentation(true);
682 aViewWindow->SetSelectionMode( NodeSelection );
688 myEditCurrentArgument->setFocus();
689 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
690 SelectionIntoArgument();
693 //=================================================================================
694 // function : DeactivateActiveDialog()
696 //=================================================================================
697 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
699 if (GroupConstructors->isEnabled()) {
700 GroupConstructors->setEnabled(false);
701 GroupArguments->setEnabled(false);
702 GroupButtons->setEnabled(false);
703 mySMESHGUI->ResetState();
704 mySMESHGUI->SetActiveDialogBox(0);
708 //=================================================================================
709 // function : ActivateThisDialog()
711 //=================================================================================
712 void SMESHGUI_RotationDlg::ActivateThisDialog()
714 /* Emit a signal to deactivate the active dialog */
715 mySMESHGUI->EmitSignalDeactivateDialog();
716 GroupConstructors->setEnabled(true);
717 GroupArguments->setEnabled(true);
718 GroupButtons->setEnabled(true);
720 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
722 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
723 aViewWindow->SetSelectionMode( CellSelection );
724 SelectionIntoArgument();
727 //=================================================================================
728 // function : enterEvent()
730 //=================================================================================
731 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
733 if (!GroupConstructors->isEnabled())
734 ActivateThisDialog();
737 //=================================================================================
738 // function : closeEvent()
740 //=================================================================================
741 void SMESHGUI_RotationDlg::closeEvent (QCloseEvent*)
743 /* same than click on cancel button */
744 this->ClickOnCancel();
747 //=================================================================================
748 // function : hideEvent()
749 // purpose : caused by ESC key
750 //=================================================================================
751 void SMESHGUI_RotationDlg::hideEvent (QHideEvent*)
757 //=================================================================================
758 // function : onSelectMesh()
760 //=================================================================================
761 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
764 TextLabelElements->setText(tr("SMESH_NAME"));
766 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
768 if (myEditCurrentArgument != LineEditElements) {
769 LineEditElements->clear();
773 mySelectionMgr->clearFilters();
774 SMESH::SetPointRepresentation(false);
777 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
778 aViewWindow->SetSelectionMode(ActorSelection);
779 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
780 LineEditElements->setReadOnly(true);
782 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
783 aViewWindow->SetSelectionMode( CellSelection );
784 LineEditElements->setReadOnly(false);
785 onTextChange(LineEditElements->text());
788 SelectionIntoArgument();
791 //=================================================================================
792 // function : IsAxisOk()
794 //=================================================================================
795 bool SMESHGUI_RotationDlg::IsAxisOk()
797 return (SpinBox_DX->GetValue() != 0 ||
798 SpinBox_DY->GetValue() != 0 ||
799 SpinBox_DZ->GetValue() != 0);
802 //=================================================================================
803 // function : onVectorChanged()
805 //=================================================================================
806 void SMESHGUI_RotationDlg::onVectorChanged()
809 buttonOk->setEnabled(true);
810 buttonApply->setEnabled(true);
812 buttonOk->setEnabled(false);
813 buttonApply->setEnabled(false);