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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_RevolutionDlg.cxx
23 // Author : Michael ZORIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_RevolutionDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
36 #include <SMESH_Actor.h>
37 #include <SMESH_TypeFilter.hxx>
38 #include <SMESH_LogicalFilter.hxx>
39 #include <SMDS_Mesh.hxx>
41 // SALOME GUI includes
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_Desktop.h>
47 #include <LightApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
50 #include <SVTK_ViewWindow.h>
51 #include <SVTK_Selector.h>
52 #include <SALOME_ListIO.hxx>
55 #include <TColStd_MapOfInteger.hxx>
58 #include <QApplication>
59 #include <QButtonGroup>
63 #include <QPushButton>
64 #include <QRadioButton>
66 #include <QHBoxLayout>
67 #include <QVBoxLayout>
68 #include <QGridLayout>
73 #include <SALOMEconfig.h>
74 #include CORBA_SERVER_HEADER(SMESH_Group)
75 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
80 //=================================================================================
81 // class : SMESHGUI_RevolutionDlg()
83 //=================================================================================
84 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
85 : QDialog( SMESH::GetDesktop( theModule ) ),
86 mySMESHGUI( theModule ),
87 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
89 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
90 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
91 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
92 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
95 setAttribute(Qt::WA_DeleteOnClose, true);
96 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
97 setSizeGripEnabled(true);
99 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
100 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
101 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
103 /***************************************************************/
104 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
105 GroupConstructors = new QButtonGroup(this);
106 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
107 ConstructorsBoxLayout->setSpacing(SPACING);
108 ConstructorsBoxLayout->setMargin(MARGIN);
110 RadioButton1 = new QRadioButton(ConstructorsBox);
111 RadioButton1->setIcon(image0);
112 RadioButton2 = new QRadioButton(ConstructorsBox);
113 RadioButton2->setIcon(image1);
115 ConstructorsBoxLayout->addWidget(RadioButton1);
116 ConstructorsBoxLayout->addWidget(RadioButton2);
117 GroupConstructors->addButton(RadioButton1, 0);
118 GroupConstructors->addButton(RadioButton2, 1);
120 /***************************************************************/
121 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
122 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
123 GroupArgumentsLayout->setSpacing(SPACING);
124 GroupArgumentsLayout->setMargin(MARGIN);
126 // Controls for elements selection
127 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
129 SelectElementsButton = new QPushButton(GroupArguments);
130 SelectElementsButton->setIcon(image2);
132 LineEditElements = new QLineEdit(GroupArguments);
133 LineEditElements->setValidator(new SMESHGUI_IdValidator(this));
135 // Control for the whole mesh selection
136 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
138 // Controls for axis defining
139 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
140 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
141 GroupAxisLayout->setSpacing(SPACING);
142 GroupAxisLayout->setMargin(MARGIN);
144 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
145 SelectPointButton = new QPushButton(GroupAxis);
146 SelectPointButton->setIcon(image2);
148 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
149 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
151 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
152 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
154 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
155 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
157 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
158 SelectVectorButton = new QPushButton(GroupAxis);
159 SelectVectorButton->setIcon(image2);
161 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
162 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
164 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
165 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
167 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
168 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
170 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
171 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
172 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
173 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
174 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
175 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
176 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
177 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
178 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
179 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
180 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
181 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
182 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
183 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
184 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
185 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
187 // Controls for angle defining
188 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupArguments);
189 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments);
191 // Controls for nb. steps defining
192 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
193 SpinBox_NbSteps = new QSpinBox(GroupArguments);
195 // Controls for tolerance defining
196 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
197 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
199 // CheckBox for groups generation
200 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
201 MakeGroupsCheck->setChecked(true);
203 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
204 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
205 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
206 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
207 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 3);
208 GroupArgumentsLayout->addWidget(TextLabelAngle, 3, 0, 1, 2);
209 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
210 GroupArgumentsLayout->addWidget(TextLabelNbSteps, 4, 0, 1, 2);
211 GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 4, 2);
212 GroupArgumentsLayout->addWidget(TextLabelTolerance, 5, 0, 1, 2);
213 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 5, 2);
214 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 3);
216 /***************************************************************/
217 GroupButtons = new QGroupBox(this);
218 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
219 GroupButtonsLayout->setSpacing(SPACING);
220 GroupButtonsLayout->setMargin(MARGIN);
222 buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
223 buttonOk->setAutoDefault(true);
224 buttonOk->setDefault(true);
225 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
226 buttonApply->setAutoDefault(true);
227 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
228 buttonCancel->setAutoDefault(true);
229 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
230 buttonHelp->setAutoDefault(true);
232 GroupButtonsLayout->addWidget(buttonOk);
233 GroupButtonsLayout->addSpacing(10);
234 GroupButtonsLayout->addWidget(buttonApply);
235 GroupButtonsLayout->addSpacing(10);
236 GroupButtonsLayout->addStretch();
237 GroupButtonsLayout->addWidget(buttonCancel);
238 GroupButtonsLayout->addWidget(buttonHelp);
240 /***************************************************************/
241 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
242 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
243 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
245 /* Initialisations */
246 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
247 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
248 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
249 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
250 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
251 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
253 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
255 SpinBox_NbSteps->setRange(1, 999999);
257 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 6);
259 RadioButton1->setChecked(true);
261 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
263 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
265 // Costruction of the logical filter
266 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
267 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
269 QList<SUIT_SelectionFilter*> aListOfFilters;
270 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
271 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
273 myMeshOrSubMeshOrGroupFilter =
274 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
276 myHelpFileName = "revolution_page.html";
280 /* signals and slots connections */
281 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
282 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
283 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
284 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
285 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
287 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
288 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
289 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
291 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
292 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
293 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
295 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
296 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
297 /* to close dialog if study change */
298 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
299 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
300 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
302 ConstructorsClicked(0);
303 SelectionIntoArgument();
306 //=================================================================================
307 // function : ~SMESHGUI_RevolutionDlg()
308 // purpose : Destroys the object and frees any allocated resources
309 //=================================================================================
310 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
312 // no need to delete child widgets, Qt does it all for us
315 //=================================================================================
318 //=================================================================================
319 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
323 myEditCurrentArgument = 0;
324 LineEditElements->clear();
329 myMesh = SMESH::SMESH_Mesh::_nil();
332 SpinBox_X->SetValue(0.0);
333 SpinBox_Y->SetValue(0.0);
334 SpinBox_Z->SetValue(0.0);
335 SpinBox_DX->SetValue(0.0);
336 SpinBox_DY->SetValue(0.0);
337 SpinBox_DZ->SetValue(0.0);
339 SpinBox_Angle->SetValue(45);
340 SpinBox_NbSteps->setValue(1);
341 SpinBox_Tolerance->SetValue(1e-05);
343 CheckBoxMesh->setChecked(false);
348 //=================================================================================
349 // function : ConstructorsClicked()
350 // purpose : Radio button management
351 //=================================================================================
352 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
354 disconnect(mySelectionMgr, 0, this, 0);
356 Selection_Mode aSelMode = ActorSelection;
358 switch (constructorId) {
361 GroupArguments->setTitle(tr("REVOLUTION_1D"));
362 aSelMode = EdgeSelection;
367 GroupArguments->setTitle(tr("REVOLUTION_2D"));
368 aSelMode = FaceSelection;
373 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
374 SMESH::SetPointRepresentation(false);
377 if (!CheckBoxMesh->isChecked())
379 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
380 aViewWindow->SetSelectionMode(aSelMode);
383 myEditCurrentArgument = (QWidget*)LineEditElements;
384 LineEditElements->setFocus();
386 if (CheckBoxMesh->isChecked())
389 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
392 //=================================================================================
393 // function : ClickOnApply()
395 //=================================================================================
396 void SMESHGUI_RevolutionDlg::ClickOnApply()
398 if (mySMESHGUI->isActiveStudyLocked())
401 if (myNbOkElements && IsAxisOk()) {
402 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
404 SMESH::long_array_var anElementsId = new SMESH::long_array;
406 anElementsId->length(aListElementsId.count());
407 for (int i = 0; i < aListElementsId.count(); i++)
408 anElementsId[i] = aListElementsId[i].toInt();
410 SMESH::AxisStruct anAxis;
412 anAxis.x = SpinBox_X->GetValue();
413 anAxis.y = SpinBox_Y->GetValue();
414 anAxis.z = SpinBox_Z->GetValue();;
415 anAxis.vx = SpinBox_DX->GetValue();
416 anAxis.vy = SpinBox_DY->GetValue();
417 anAxis.vz = SpinBox_DZ->GetValue();
419 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
420 long aNbSteps = (long)SpinBox_NbSteps->value();
421 double aTolerance = SpinBox_Tolerance->GetValue();
424 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
425 QApplication::setOverrideCursor(Qt::WaitCursor);
427 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
428 SMESH::ListOfGroups_var groups =
429 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
430 anAngle, aNbSteps, aTolerance);
432 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
434 QApplication::restoreOverrideCursor();
439 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
440 mySMESHGUI->updateObjBrowser(true); // new groups may appear
442 ConstructorsClicked(GetConstructorId());
443 SelectionIntoArgument();
447 //=================================================================================
448 // function : ClickOnOk()
450 //=================================================================================
451 void SMESHGUI_RevolutionDlg::ClickOnOk()
457 //=================================================================================
458 // function : ClickOnCancel()
460 //=================================================================================
461 void SMESHGUI_RevolutionDlg::ClickOnCancel()
463 disconnect(mySelectionMgr, 0, this, 0);
464 mySelectionMgr->clearFilters();
465 //mySelectionMgr->clearSelected();
466 SMESH::SetPointRepresentation(false);
467 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
468 aViewWindow->SetSelectionMode(ActorSelection);
469 mySMESHGUI->ResetState();
473 //=================================================================================
474 // function : ClickOnHelp()
476 //=================================================================================
477 void SMESHGUI_RevolutionDlg::ClickOnHelp()
479 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
481 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
485 platform = "winapplication";
487 platform = "application";
489 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
490 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
491 arg(app->resourceMgr()->stringValue("ExternalBrowser",
493 arg(myHelpFileName));
497 //=======================================================================
498 // function : onTextChange()
500 //=======================================================================
501 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
503 QLineEdit* send = (QLineEdit*)sender();
508 if (send == LineEditElements)
511 buttonOk->setEnabled(false);
512 buttonApply->setEnabled(false);
514 // hilight entered elements
515 SMDS_Mesh* aMesh = 0;
517 aMesh = myActor->GetObject()->GetMesh();
520 if (send == LineEditElements) {
521 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
523 TColStd_MapOfInteger newIndices;
525 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
527 for (int i = 0; i < aListId.count(); i++) {
528 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
530 newIndices.Add(e->GetID());
534 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
535 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
536 aViewWindow->highlight( myActor->getIO(), true, true );
538 myElementsId = theNewText;
542 if (myNbOkElements && IsAxisOk()) {
543 buttonOk->setEnabled(true);
544 buttonApply->setEnabled(true);
550 //=================================================================================
551 // function : SelectionIntoArgument()
552 // purpose : Called when selection as changed or other case
553 //=================================================================================
554 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
560 QString aString = "";
563 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
564 LineEditElements->setText(aString);
566 buttonOk->setEnabled(false);
567 buttonApply->setEnabled(false);
571 if (!GroupButtons->isEnabled()) // inactive
575 const SALOME_ListIO& aList = mySelector->StoredIObjects();
577 int nbSel = aList.Extent();
581 Handle(SALOME_InteractiveObject) IO = aList.First();
582 myMesh = SMESH::GetMeshByIO(IO);
583 if (myMesh->_is_nil())
586 myActor = SMESH::FindActorByObject(myMesh);
588 myActor = SMESH::FindActorByEntry(IO->getEntry());
594 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
597 // MakeGroups is available if there are groups
598 if ( myMesh->NbGroups() == 0 ) {
599 MakeGroupsCheck->setChecked(false);
600 MakeGroupsCheck->setEnabled(false);
602 MakeGroupsCheck->setEnabled(true);
605 if (CheckBoxMesh->isChecked()) {
606 int aConstructorId = GetConstructorId();
608 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
610 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
612 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
616 if (aConstructorId == 0) {
617 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
619 while (anIter->more()) {
620 const SMDS_MeshEdge * edge = anIter->next();
622 myElementsId += QString(" %1").arg(edge->GetID());
626 } else if (aConstructorId == 1) {
627 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
628 while (anIter->more()) {
629 const SMDS_MeshFace * face = anIter->next();
631 myElementsId += QString(" %1").arg(face->GetID());
636 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
638 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
640 // get IDs from submesh
641 SMESH::long_array_var anElementsIds = new SMESH::long_array;
642 if (aConstructorId == 0)
643 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
644 else if (aConstructorId == 1)
645 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
647 for (int i = 0; i < anElementsIds->length(); i++)
648 myElementsId += QString(" %1").arg(anElementsIds[i]);
649 aNbUnits = anElementsIds->length();
652 SMESH::SMESH_GroupBase_var aGroup =
653 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
654 if (aGroup->_is_nil())
657 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
658 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
661 // get IDs from smesh group
662 SMESH::long_array_var anElementsIds = new SMESH::long_array;
663 anElementsIds = aGroup->GetListOfID();
664 for (int i = 0; i < anElementsIds->length(); i++) {
665 myElementsId += QString(" %1").arg(anElementsIds[i]);
667 aNbUnits = anElementsIds->length();
670 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
671 myElementsId = aString;
677 myNbOkElements = true;
679 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
683 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
687 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
695 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
696 SpinBox_X->SetValue(x);
697 SpinBox_Y->SetValue(y);
698 SpinBox_Z->SetValue(z);
699 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
700 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
701 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
702 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
707 if (myEditCurrentArgument == (QWidget*)LineEditElements)
708 LineEditElements->setText(aString);
712 if (myNbOkElements && IsAxisOk()) {
713 buttonOk->setEnabled(true);
714 buttonApply->setEnabled(true);
718 //=================================================================================
719 // function : SetEditCurrentArgument()
721 //=================================================================================
722 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
724 QPushButton* send = (QPushButton*)sender();
726 disconnect(mySelectionMgr, 0, this, 0);
727 mySelectionMgr->clearSelected();
728 mySelectionMgr->clearFilters();
730 if (send == SelectElementsButton) {
731 myEditCurrentArgument = (QWidget*)LineEditElements;
732 SMESH::SetPointRepresentation(false);
733 if (CheckBoxMesh->isChecked()) {
734 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
735 aViewWindow->SetSelectionMode(ActorSelection);
736 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
738 int aConstructorId = GetConstructorId();
739 if (aConstructorId == 0)
741 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
742 aViewWindow->SetSelectionMode(EdgeSelection);
744 else if (aConstructorId == 1)
746 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
747 aViewWindow->SetSelectionMode(FaceSelection);
750 } else if (send == SelectPointButton) {
751 myEditCurrentArgument = (QWidget*)SpinBox_X;
752 SMESH::SetPointRepresentation(true);
753 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
754 aViewWindow->SetSelectionMode(NodeSelection);
755 } else if (send == SelectVectorButton) {
756 myEditCurrentArgument = (QWidget*)SpinBox_DX;
757 SMESH::SetPointRepresentation(true);
758 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
759 aViewWindow->SetSelectionMode(NodeSelection);
763 myEditCurrentArgument->setFocus();
764 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
765 SelectionIntoArgument();
768 //=================================================================================
769 // function : DeactivateActiveDialog()
771 //=================================================================================
772 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
774 if (ConstructorsBox->isEnabled()) {
775 ConstructorsBox->setEnabled(false);
776 GroupArguments->setEnabled(false);
777 GroupButtons->setEnabled(false);
778 mySMESHGUI->ResetState();
779 mySMESHGUI->SetActiveDialogBox(0);
783 //=================================================================================
784 // function : ActivateThisDialog()
786 //=================================================================================
787 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
789 /* Emit a signal to deactivate the active dialog */
790 mySMESHGUI->EmitSignalDeactivateDialog();
791 ConstructorsBox->setEnabled(true);
792 GroupArguments->setEnabled(true);
793 GroupButtons->setEnabled(true);
795 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
797 ConstructorsClicked(GetConstructorId());
798 SelectionIntoArgument();
801 //=================================================================================
802 // function : enterEvent()
804 //=================================================================================
805 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
807 if (!ConstructorsBox->isEnabled())
808 ActivateThisDialog();
811 //=================================================================================
812 // function : closeEvent()
814 //=================================================================================
815 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
817 /* same than click on cancel button */
821 //=======================================================================
822 // function : hideEvent()
823 // purpose : caused by ESC key
824 //=======================================================================
825 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
831 //=======================================================================
832 //function : onSelectMesh
834 //=======================================================================
835 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
838 TextLabelElements->setText(tr("SMESH_NAME"));
840 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
842 if (myEditCurrentArgument != LineEditElements) {
843 LineEditElements->clear();
847 mySelectionMgr->clearFilters();
848 SMESH::SetPointRepresentation(false);
851 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
852 aViewWindow->SetSelectionMode(ActorSelection);
853 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
854 LineEditElements->setReadOnly(true);
856 int aConstructorId = GetConstructorId();
857 if (aConstructorId == 0)
859 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
860 aViewWindow->SetSelectionMode(EdgeSelection);
862 else if (aConstructorId == 0)
864 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
865 aViewWindow->SetSelectionMode(FaceSelection);
868 LineEditElements->setReadOnly(false);
869 onTextChange(LineEditElements->text());
872 SelectionIntoArgument();
875 //=================================================================================
876 // function : GetConstructorId()
878 //=================================================================================
879 int SMESHGUI_RevolutionDlg::GetConstructorId()
881 return GroupConstructors->checkedId();
884 //=================================================================================
885 // function : IsAxisOk()
887 //=================================================================================
888 bool SMESHGUI_RevolutionDlg::IsAxisOk()
890 return (SpinBox_DX->GetValue() != 0 ||
891 SpinBox_DY->GetValue() != 0 ||
892 SpinBox_DZ->GetValue() != 0);
895 //=================================================================================
896 // function : onVectorChanged()
898 //=================================================================================
899 void SMESHGUI_RevolutionDlg::onVectorChanged()
902 buttonOk->setEnabled(true);
903 buttonApply->setEnabled(true);
905 buttonOk->setEnabled(false);
906 buttonApply->setEnabled(false);
910 //=================================================================================
911 // function : keyPressEvent()
913 //=================================================================================
914 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
916 QDialog::keyPressEvent( e );
917 if ( e->isAccepted() )
920 if ( e->key() == Qt::Key_F1 ) {