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_RevolutionDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_RevolutionDlg.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_ResourceMgr.h"
45 #include "SVTK_ViewModel.h"
46 #include "SVTK_ViewWindow.h"
47 #include "SVTK_Selector.h"
48 #include "SVTK_Selection.h"
49 #include "SALOME_ListIO.hxx"
51 #include "utilities.h"
54 #include <TColStd_MapOfInteger.hxx>
55 #include <TColStd_IndexedMapOfInteger.hxx>
58 #include <qapplication.h>
59 #include <qbuttongroup.h>
60 #include <qgroupbox.h>
62 #include <qlineedit.h>
63 #include <qpushbutton.h>
64 #include <qradiobutton.h>
65 #include <qcheckbox.h>
68 #include <qvalidator.h>
72 #include "SALOMEconfig.h"
73 #include CORBA_SERVER_HEADER(SMESH_Group)
77 //=================================================================================
78 // class : SMESHGUI_RevolutionDlg()
80 //=================================================================================
81 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name,
82 bool modal, WFlags fl)
83 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
84 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
85 mySMESHGUI( theModule ),
86 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
88 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
89 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
90 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
91 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
94 setName("SMESHGUI_RevolutionDlg");
96 setCaption(tr("REVOLUTION_AROUND_AXIS"));
97 setSizeGripEnabled(TRUE);
98 SMESHGUI_RevolutionDlgLayout = new QGridLayout(this);
99 SMESHGUI_RevolutionDlgLayout->setSpacing(6);
100 SMESHGUI_RevolutionDlgLayout->setMargin(11);
102 /***************************************************************/
103 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
104 GroupConstructors->setTitle(tr("SMESH_REVOLUTION" ));
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 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
117 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
118 RadioButton2->setText(tr("" ));
119 RadioButton2->setPixmap(image1);
120 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
121 SMESHGUI_RevolutionDlgLayout->addWidget(GroupConstructors, 0, 0);
123 /***************************************************************/
124 GroupButtons = new QGroupBox(this, "GroupButtons");
125 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
126 GroupButtons->setTitle(tr("" ));
127 GroupButtons->setColumnLayout(0, Qt::Vertical);
128 GroupButtons->layout()->setSpacing(0);
129 GroupButtons->layout()->setMargin(0);
130 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
131 GroupButtonsLayout->setAlignment(Qt::AlignTop);
132 GroupButtonsLayout->setSpacing(6);
133 GroupButtonsLayout->setMargin(11);
134 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
135 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
136 buttonCancel->setAutoDefault(TRUE);
137 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
138 buttonApply = new QPushButton(GroupButtons, "buttonApply");
139 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
140 buttonApply->setAutoDefault(TRUE);
141 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
142 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
143 GroupButtonsLayout->addItem(spacer_9, 0, 2);
144 buttonOk = new QPushButton(GroupButtons, "buttonOk");
145 buttonOk->setText(tr("SMESH_BUT_OK" ));
146 buttonOk->setAutoDefault(TRUE);
147 buttonOk->setDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
149 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons, 2, 0);
151 /***************************************************************/
152 GroupArguments = new QGroupBox(this, "GroupArguments");
153 GroupArguments->setTitle(tr("REVOLUTION_1D"));
154 GroupArguments->setColumnLayout(0, Qt::Vertical);
155 GroupArguments->layout()->setSpacing(0);
156 GroupArguments->layout()->setMargin(0);
157 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
158 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
159 GroupArgumentsLayout->setSpacing(6);
160 GroupArgumentsLayout->setMargin(11);
162 // Controls for elements selection
163 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
164 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
165 TextLabelElements->setFixedWidth(74);
166 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
168 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
169 SelectElementsButton->setText(tr("" ));
170 SelectElementsButton->setPixmap(image2);
171 SelectElementsButton->setToggleButton(FALSE);
172 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
174 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
175 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
176 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
178 // Control for the whole mesh selection
179 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
180 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
181 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 3);
183 // Controls for axis defining
184 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
185 GroupAxis->setTitle(tr("SMESH_AXIS"));
186 GroupAxis->setColumnLayout(0, Qt::Vertical);
187 GroupAxis->layout()->setSpacing(0);
188 GroupAxis->layout()->setMargin(0);
189 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
190 GroupAxisLayout->setAlignment(Qt::AlignTop);
191 GroupAxisLayout->setSpacing(6);
192 GroupAxisLayout->setMargin(11);
194 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
195 TextLabelPoint->setText(tr("SMESH_POINT"));
196 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
198 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
199 SelectPointButton->setPixmap(image2);
200 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
202 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
203 TextLabelX->setText(tr("SMESH_X"));
204 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
206 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
207 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
209 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
210 TextLabelY->setText(tr("SMESH_Y"));
211 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
213 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
214 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
216 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
217 TextLabelZ->setText(tr("SMESH_Z"));
218 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
220 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
221 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
223 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
224 TextLabelVector->setText(tr("SMESH_VECTOR"));
225 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
227 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
228 SelectVectorButton->setPixmap(image2);
229 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
231 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
232 TextLabelDX->setText(tr("SMESH_DX"));
233 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
235 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
236 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
238 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
239 TextLabelDY->setText(tr("SMESH_DY"));
240 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
242 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
243 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
245 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
246 TextLabelDZ->setText(tr("SMESH_DZ"));
247 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
249 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
250 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
252 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3);
254 // Controls for angle defining
255 TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle");
256 TextLabelAngle->setText(tr("SMESH_ANGLE" ));
257 GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1);
259 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
260 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
262 // Controls for nb. steps defining
263 TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps");
264 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
265 GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 4, 4, 0, 1);
267 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
268 GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 4, 2);
270 // Controls for tolerance defining
271 TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance");
272 TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
273 GroupArgumentsLayout->addMultiCellWidget(TextLabelTolerance, 5, 5, 0, 1);
275 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
276 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 5, 2);
278 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0);
280 /* Initialisations */
281 SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
282 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
283 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
284 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
285 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
286 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
288 SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 5.0, 3);
290 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
291 SpinBox_NbSteps->setValidator(anIntValidator);
292 SpinBox_NbSteps->setRange(1, 999999);
294 SpinBox_Tolerance->RangeStepAndValidator(0.0, +999999.999, 0.1, 6);
296 GroupArguments->show();
297 RadioButton1->setChecked(TRUE);
299 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
301 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
303 // Costruction of the logical filter
304 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
305 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
307 QPtrList<SUIT_SelectionFilter> aListOfFilters;
308 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
309 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
311 myMeshOrSubMeshOrGroupFilter =
312 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
316 /* signals and slots connections */
317 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
318 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
319 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
320 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
322 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
323 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
324 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
326 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
327 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
328 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
330 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
331 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
332 /* to close dialog if study change */
333 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
334 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
335 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
337 /* Move widget on the botton right corner of main widget */
339 mySMESHGUI->DefineDlgPosition(this, x, y);
341 this->show(); /* displays Dialog */
343 ConstructorsClicked(0);
344 SelectionIntoArgument();
348 //=================================================================================
349 // function : ~SMESHGUI_RevolutionDlg()
350 // purpose : Destroys the object and frees any allocated resources
351 //=================================================================================
352 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
354 // no need to delete child widgets, Qt does it all for us
357 //=================================================================================
360 //=================================================================================
361 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
365 myEditCurrentArgument = 0;
366 LineEditElements->clear();
371 myMesh = SMESH::SMESH_Mesh::_nil();
374 SpinBox_X->SetValue(0.0);
375 SpinBox_Y->SetValue(0.0);
376 SpinBox_Z->SetValue(0.0);
377 SpinBox_DX->SetValue(0.0);
378 SpinBox_DY->SetValue(0.0);
379 SpinBox_DZ->SetValue(0.0);
381 SpinBox_Angle->SetValue(45);
382 SpinBox_NbSteps->setValue(1);
383 SpinBox_Tolerance->SetValue(1e-05);
385 CheckBoxMesh->setChecked(false);
390 //=================================================================================
391 // function : ConstructorsClicked()
392 // purpose : Radio button management
393 //=================================================================================
394 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
396 disconnect(mySelectionMgr, 0, this, 0);
398 Selection_Mode aSelMode = ActorSelection;
400 switch (constructorId) {
403 GroupArguments->setTitle(tr("REVOLUTION_1D"));
404 aSelMode = EdgeSelection;
409 GroupArguments->setTitle(tr("REVOLUTION_2D"));
410 aSelMode = FaceSelection;
415 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
416 SMESH::SetPointRepresentation(false);
419 if (!CheckBoxMesh->isChecked())
421 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
422 aViewWindow->SetSelectionMode(aSelMode);
425 myEditCurrentArgument = (QWidget*)LineEditElements;
426 LineEditElements->setFocus();
428 if (CheckBoxMesh->isChecked())
431 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
434 //=================================================================================
435 // function : ClickOnApply()
437 //=================================================================================
438 void SMESHGUI_RevolutionDlg::ClickOnApply()
440 if (mySMESHGUI->isActiveStudyLocked())
443 if (myNbOkElements && IsAxisOk()) {
444 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
446 SMESH::long_array_var anElementsId = new SMESH::long_array;
448 anElementsId->length(aListElementsId.count());
449 for (int i = 0; i < aListElementsId.count(); i++)
450 anElementsId[i] = aListElementsId[i].toInt();
452 SMESH::AxisStruct anAxis;
454 anAxis.x = SpinBox_X->GetValue();
455 anAxis.y = SpinBox_Y->GetValue();
456 anAxis.z = SpinBox_Z->GetValue();;
457 anAxis.vx = SpinBox_DX->GetValue();
458 anAxis.vy = SpinBox_DY->GetValue();
459 anAxis.vz = SpinBox_DZ->GetValue();
461 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
462 long aNbSteps = (long)SpinBox_NbSteps->value();
463 double aTolerance = SpinBox_Tolerance->GetValue();
466 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
467 QApplication::setOverrideCursor(Qt::waitCursor);
468 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
469 QApplication::restoreOverrideCursor();
475 ConstructorsClicked(GetConstructorId());
476 SelectionIntoArgument();
480 //=================================================================================
481 // function : ClickOnOk()
483 //=================================================================================
484 void SMESHGUI_RevolutionDlg::ClickOnOk()
490 //=================================================================================
491 // function : ClickOnCancel()
493 //=================================================================================
494 void SMESHGUI_RevolutionDlg::ClickOnCancel()
496 disconnect(mySelectionMgr, 0, this, 0);
497 mySelectionMgr->clearFilters();
498 //mySelectionMgr->clearSelected();
499 SMESH::SetPointRepresentation(false);
500 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
501 aViewWindow->SetSelectionMode(ActorSelection);
502 mySMESHGUI->ResetState();
506 //=======================================================================
507 // function : onTextChange()
509 //=======================================================================
510 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
512 QLineEdit* send = (QLineEdit*)sender();
517 if (send == LineEditElements)
520 buttonOk->setEnabled(false);
521 buttonApply->setEnabled(false);
523 // hilight entered elements
524 SMDS_Mesh* aMesh = 0;
526 aMesh = myActor->GetObject()->GetMesh();
529 if (send == LineEditElements) {
530 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
532 TColStd_MapOfInteger newIndices;
534 QStringList aListId = QStringList::split(" ", theNewText, false);
536 for (int i = 0; i < aListId.count(); i++) {
537 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
539 newIndices.Add(e->GetID());
543 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
544 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
545 aViewWindow->highlight( myActor->getIO(), true, true );
547 myElementsId = theNewText;
551 if (myNbOkElements && IsAxisOk()) {
552 buttonOk->setEnabled(true);
553 buttonApply->setEnabled(true);
559 //=================================================================================
560 // function : SelectionIntoArgument()
561 // purpose : Called when selection as changed or other case
562 //=================================================================================
563 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
569 QString aString = "";
572 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
573 LineEditElements->setText(aString);
575 buttonOk->setEnabled(false);
576 buttonApply->setEnabled(false);
580 if (!GroupButtons->isEnabled()) // inactive
584 const SALOME_ListIO& aList = mySelector->StoredIObjects();
586 int nbSel = aList.Extent();
590 Handle(SALOME_InteractiveObject) IO = aList.First();
591 myMesh = SMESH::GetMeshByIO(IO);
592 if (myMesh->_is_nil())
595 myActor = SMESH::FindActorByObject(myMesh);
597 myActor = SMESH::FindActorByEntry(IO->getEntry());
603 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
606 if (CheckBoxMesh->isChecked()) {
607 int aConstructorId = GetConstructorId();
609 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
611 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
613 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
617 if (aConstructorId == 0) {
618 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
620 while (anIter->more()) {
621 const SMDS_MeshEdge * edge = anIter->next();
623 myElementsId += QString(" %1").arg(edge->GetID());
627 } else if (aConstructorId == 1) {
628 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
629 while (anIter->more()) {
630 const SMDS_MeshFace * face = anIter->next();
632 myElementsId += QString(" %1").arg(face->GetID());
637 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
639 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
641 // get IDs from submesh
642 SMESH::long_array_var anElementsIds = new SMESH::long_array;
643 if (aConstructorId == 0)
644 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
645 else if (aConstructorId == 1)
646 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
648 for (int i = 0; i < anElementsIds->length(); i++)
649 myElementsId += QString(" %1").arg(anElementsIds[i]);
650 aNbUnits = anElementsIds->length();
653 SMESH::SMESH_GroupBase_var aGroup =
654 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
655 if (aGroup->_is_nil())
658 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
659 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
662 // get IDs from smesh group
663 SMESH::long_array_var anElementsIds = new SMESH::long_array;
664 anElementsIds = aGroup->GetListOfID();
665 for (int i = 0; i < anElementsIds->length(); i++) {
666 myElementsId += QString(" %1").arg(anElementsIds[i]);
668 aNbUnits = anElementsIds->length();
671 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
672 myElementsId = aString;
678 myNbOkElements = true;
680 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
684 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
688 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
696 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
697 SpinBox_X->SetValue(x);
698 SpinBox_Y->SetValue(y);
699 SpinBox_Z->SetValue(z);
700 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
701 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
702 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
703 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
708 if (myEditCurrentArgument == (QWidget*)LineEditElements)
709 LineEditElements->setText(aString);
713 if (myNbOkElements && IsAxisOk()) {
714 buttonOk->setEnabled(true);
715 buttonApply->setEnabled(true);
719 //=================================================================================
720 // function : SetEditCurrentArgument()
722 //=================================================================================
723 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
725 QPushButton* send = (QPushButton*)sender();
727 disconnect(mySelectionMgr, 0, this, 0);
728 mySelectionMgr->clearSelected();
729 mySelectionMgr->clearFilters();
731 if (send == SelectElementsButton) {
732 myEditCurrentArgument = (QWidget*)LineEditElements;
733 SMESH::SetPointRepresentation(false);
734 if (CheckBoxMesh->isChecked()) {
735 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
736 aViewWindow->SetSelectionMode(ActorSelection);
737 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
739 int aConstructorId = GetConstructorId();
740 if (aConstructorId == 0)
742 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
743 aViewWindow->SetSelectionMode(EdgeSelection);
745 else if (aConstructorId == 1)
747 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
748 aViewWindow->SetSelectionMode(FaceSelection);
751 } else if (send == SelectPointButton) {
752 myEditCurrentArgument = (QWidget*)SpinBox_X;
753 SMESH::SetPointRepresentation(true);
754 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
755 aViewWindow->SetSelectionMode(NodeSelection);
756 } else if (send == SelectVectorButton) {
757 myEditCurrentArgument = (QWidget*)SpinBox_DX;
758 SMESH::SetPointRepresentation(true);
759 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
760 aViewWindow->SetSelectionMode(NodeSelection);
764 myEditCurrentArgument->setFocus();
765 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
766 SelectionIntoArgument();
769 //=================================================================================
770 // function : DeactivateActiveDialog()
772 //=================================================================================
773 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
775 if (GroupConstructors->isEnabled()) {
776 GroupConstructors->setEnabled(false);
777 GroupArguments->setEnabled(false);
778 GroupButtons->setEnabled(false);
779 mySMESHGUI->ResetState();
780 mySMESHGUI->SetActiveDialogBox(0);
784 //=================================================================================
785 // function : ActivateThisDialog()
787 //=================================================================================
788 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
790 /* Emit a signal to deactivate the active dialog */
791 mySMESHGUI->EmitSignalDeactivateDialog();
792 GroupConstructors->setEnabled(true);
793 GroupArguments->setEnabled(true);
794 GroupButtons->setEnabled(true);
796 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
798 ConstructorsClicked(GetConstructorId());
799 SelectionIntoArgument();
802 //=================================================================================
803 // function : enterEvent()
805 //=================================================================================
806 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
808 if (!GroupConstructors->isEnabled())
809 ActivateThisDialog();
812 //=================================================================================
813 // function : closeEvent()
815 //=================================================================================
816 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
818 /* same than click on cancel button */
819 this->ClickOnCancel();
822 //=======================================================================
823 // function : hideEvent()
824 // purpose : caused by ESC key
825 //=======================================================================
826 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
832 //=======================================================================
833 //function : onSelectMesh
835 //=======================================================================
836 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
839 TextLabelElements->setText(tr("SMESH_NAME"));
841 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
843 if (myEditCurrentArgument != LineEditElements) {
844 LineEditElements->clear();
848 mySelectionMgr->clearFilters();
849 SMESH::SetPointRepresentation(false);
852 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
853 aViewWindow->SetSelectionMode(ActorSelection);
854 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
855 LineEditElements->setReadOnly(true);
857 int aConstructorId = GetConstructorId();
858 if (aConstructorId == 0)
860 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861 aViewWindow->SetSelectionMode(EdgeSelection);
863 else if (aConstructorId == 0)
865 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
866 aViewWindow->SetSelectionMode(FaceSelection);
869 LineEditElements->setReadOnly(false);
870 onTextChange(LineEditElements->text());
873 SelectionIntoArgument();
876 //=================================================================================
877 // function : GetConstructorId()
879 //=================================================================================
880 int SMESHGUI_RevolutionDlg::GetConstructorId()
882 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
883 return GroupConstructors->id(GroupConstructors->selected());
887 //=================================================================================
888 // function : IsAxisOk()
890 //=================================================================================
891 bool SMESHGUI_RevolutionDlg::IsAxisOk()
893 return (SpinBox_DX->GetValue() != 0 ||
894 SpinBox_DY->GetValue() != 0 ||
895 SpinBox_DZ->GetValue() != 0);
898 //=================================================================================
899 // function : onVectorChanged()
901 //=================================================================================
902 void SMESHGUI_RevolutionDlg::onVectorChanged()
905 buttonOk->setEnabled(true);
906 buttonApply->setEnabled(true);
908 buttonOk->setEnabled(false);
909 buttonApply->setEnabled(false);