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"
35 #include "SMESHGUI_MeshEditPreview.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TypeFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_Desktop.h>
47 #include <SUIT_OverrideCursor.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_SelectionMgr.h>
51 #include <SalomeApp_Application.h>
52 #include <SalomeApp_IntSpinBox.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SVTK_Selector.h>
56 #include <SALOME_ListIO.hxx>
57 #include <VTKViewer_CellLocationsArray.h>
60 #include <TColStd_MapOfInteger.hxx>
63 #include <QApplication>
64 #include <QButtonGroup>
68 #include <QPushButton>
69 #include <QRadioButton>
71 #include <QHBoxLayout>
72 #include <QVBoxLayout>
73 #include <QGridLayout>
77 #include <SALOMEconfig.h>
78 #include CORBA_SERVER_HEADER(SMESH_Group)
79 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
84 //=================================================================================
85 // class : SMESHGUI_RevolutionDlg()
87 //=================================================================================
88 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
89 : QDialog( SMESH::GetDesktop( theModule ) ),
90 mySMESHGUI( theModule ),
91 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
93 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
95 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
96 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
97 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
98 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
101 setAttribute(Qt::WA_DeleteOnClose, true);
102 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
103 setSizeGripEnabled(true);
105 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
106 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
107 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
109 /***************************************************************/
110 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
111 GroupConstructors = new QButtonGroup(this);
112 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
113 ConstructorsBoxLayout->setSpacing(SPACING);
114 ConstructorsBoxLayout->setMargin(MARGIN);
116 RadioButton1 = new QRadioButton(ConstructorsBox);
117 RadioButton1->setIcon(image0);
118 RadioButton2 = new QRadioButton(ConstructorsBox);
119 RadioButton2->setIcon(image1);
121 ConstructorsBoxLayout->addWidget(RadioButton1);
122 ConstructorsBoxLayout->addWidget(RadioButton2);
123 GroupConstructors->addButton(RadioButton1, 0);
124 GroupConstructors->addButton(RadioButton2, 1);
126 /***************************************************************/
127 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
128 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
129 GroupArgumentsLayout->setSpacing(SPACING);
130 GroupArgumentsLayout->setMargin(MARGIN);
132 myIdValidator = new SMESHGUI_IdValidator(this);
134 // Controls for elements selection
135 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
137 SelectElementsButton = new QPushButton(GroupArguments);
138 SelectElementsButton->setIcon(image2);
140 LineEditElements = new QLineEdit(GroupArguments);
141 LineEditElements->setValidator(myIdValidator);
143 // Control for the whole mesh selection
144 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
146 // Controls for axis defining
147 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
148 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
149 GroupAxisLayout->setSpacing(SPACING);
150 GroupAxisLayout->setMargin(MARGIN);
152 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
153 SelectPointButton = new QPushButton(GroupAxis);
154 SelectPointButton->setIcon(image2);
156 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
157 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
159 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
160 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
162 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
163 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
165 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
166 SelectVectorButton = new QPushButton(GroupAxis);
167 SelectVectorButton->setIcon(image2);
169 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
170 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
172 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
173 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
175 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
176 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
178 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
179 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
180 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
181 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
182 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
183 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
184 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
185 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
186 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
187 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
188 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
189 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
190 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
191 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
192 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
193 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
195 // Controls for angle defining & number of steps defining
196 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
197 GroupAngle = new QButtonGroup(GroupAngleBox);
198 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
199 GroupAngleLayout->setSpacing(6);
200 GroupAngleLayout->setMargin(11);
202 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
203 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
204 GroupAngle->addButton(RadioButton3, 0);
205 GroupAngle->addButton(RadioButton4, 1);
207 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
208 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
210 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
211 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
213 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
214 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
215 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
216 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
217 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
218 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
220 // Controls for tolerance defining
221 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
222 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
224 // Control for mesh preview
225 CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
227 // CheckBox for groups generation
228 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
229 MakeGroupsCheck->setChecked(true);
231 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
232 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
233 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
234 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
235 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 3);
236 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 3);
237 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
238 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2);
239 GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 3);
240 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 3);
242 /***************************************************************/
243 GroupButtons = new QGroupBox(this);
244 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
245 GroupButtonsLayout->setSpacing(SPACING);
246 GroupButtonsLayout->setMargin(MARGIN);
248 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
249 buttonOk->setAutoDefault(true);
250 buttonOk->setDefault(true);
251 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
252 buttonApply->setAutoDefault(true);
253 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
254 buttonCancel->setAutoDefault(true);
255 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
256 buttonHelp->setAutoDefault(true);
258 GroupButtonsLayout->addWidget(buttonOk);
259 GroupButtonsLayout->addSpacing(10);
260 GroupButtonsLayout->addWidget(buttonApply);
261 GroupButtonsLayout->addSpacing(10);
262 GroupButtonsLayout->addStretch();
263 GroupButtonsLayout->addWidget(buttonCancel);
264 GroupButtonsLayout->addWidget(buttonHelp);
266 /***************************************************************/
267 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
268 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
269 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
271 /* Initialisations */
272 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
273 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
274 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
275 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
276 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
277 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
279 RadioButton3->setChecked(true);
281 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
283 SpinBox_NbSteps->setRange(1, 999999);
285 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
287 RadioButton1->setChecked(true);
289 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
291 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
293 // Costruction of the logical filter
294 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
295 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
297 QList<SUIT_SelectionFilter*> aListOfFilters;
298 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
299 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
301 myMeshOrSubMeshOrGroupFilter =
302 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
304 myHelpFileName = "revolution_page.html";
308 /* signals and slots connections */
309 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
310 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
311 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
312 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
313 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
315 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
316 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
317 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
319 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
320 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
321 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
323 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
324 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
325 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
327 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
328 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
329 /* to close dialog if study change */
330 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
331 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
332 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
334 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
335 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
337 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
338 connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
340 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
342 ConstructorsClicked(0);
343 SelectionIntoArgument();
346 //=================================================================================
347 // function : ~SMESHGUI_RevolutionDlg()
348 // purpose : Destroys the object and frees any allocated resources
349 //=================================================================================
350 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
355 //=================================================================================
358 //=================================================================================
359 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
363 myEditCurrentArgument = 0;
364 LineEditElements->clear();
369 myMesh = SMESH::SMESH_Mesh::_nil();
372 SpinBox_X->SetValue(0.0);
373 SpinBox_Y->SetValue(0.0);
374 SpinBox_Z->SetValue(0.0);
375 SpinBox_DX->SetValue(0.0);
376 SpinBox_DY->SetValue(0.0);
377 SpinBox_DZ->SetValue(0.0);
379 SpinBox_Angle->SetValue(45);
380 SpinBox_NbSteps->setValue(1);
381 SpinBox_Tolerance->SetValue(1e-05);
383 CheckBoxMesh->setChecked(false);
385 CheckBoxPreview->setChecked(false);
386 onDisplaySimulation(false);
390 //=================================================================================
391 // function : ConstructorsClicked()
392 // purpose : Radio button management
393 //=================================================================================
394 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
396 //disconnect(mySelectionMgr, 0, this, 0);
399 mySelectionMgr->selectedObjects( io );
401 mySelectionMgr->setSelectedObjects( aList );
402 // LineEditElements->clear();
404 buttonApply->setEnabled(false);
405 buttonOk->setEnabled(false);
406 mySimulation->SetVisibility(false);
408 Selection_Mode aSelMode = ActorSelection;
410 switch (constructorId) {
413 GroupArguments->setTitle(tr("REVOLUTION_1D"));
414 aSelMode = EdgeSelection;
419 GroupArguments->setTitle(tr("REVOLUTION_2D"));
420 aSelMode = FaceSelection;
425 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
426 SMESH::SetPointRepresentation(false);
429 if (!CheckBoxMesh->isChecked())
431 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
432 aViewWindow->SetSelectionMode(aSelMode);
435 myEditCurrentArgument = (QWidget*)LineEditElements;
436 LineEditElements->setFocus();
438 if (CheckBoxMesh->isChecked())
441 //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
442 mySelectionMgr->setSelectedObjects( io );
445 //=================================================================================
446 // function : ClickOnApply()
448 //=================================================================================
449 bool SMESHGUI_RevolutionDlg::ClickOnApply()
451 if (mySMESHGUI->isActiveStudyLocked())
457 if (myNbOkElements && IsAxisOk()) {
458 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
460 SMESH::long_array_var anElementsId = new SMESH::long_array;
462 anElementsId->length(aListElementsId.count());
463 for (int i = 0; i < aListElementsId.count(); i++)
464 anElementsId[i] = aListElementsId[i].toInt();
466 SMESH::AxisStruct anAxis;
468 anAxis.x = SpinBox_X->GetValue();
469 anAxis.y = SpinBox_Y->GetValue();
470 anAxis.z = SpinBox_Z->GetValue();;
471 anAxis.vx = SpinBox_DX->GetValue();
472 anAxis.vy = SpinBox_DY->GetValue();
473 anAxis.vz = SpinBox_DZ->GetValue();
475 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
476 long aNbSteps = (long)SpinBox_NbSteps->value();
477 double aTolerance = SpinBox_Tolerance->GetValue();
479 if ( GroupAngle->checkedId() == 1 )
480 anAngle = anAngle/aNbSteps;
482 QStringList aParameters;
483 aParameters << SpinBox_X->text();
484 aParameters << SpinBox_Y->text();
485 aParameters << SpinBox_Z->text();
486 aParameters << SpinBox_DX->text();
487 aParameters << SpinBox_DY->text();
488 aParameters << SpinBox_DZ->text();
489 aParameters << SpinBox_Angle->text();
490 aParameters << SpinBox_NbSteps->text();
491 aParameters << SpinBox_Tolerance->text();
494 SUIT_OverrideCursor aWaitCursor;
495 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
497 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
498 SMESH::ListOfGroups_var groups =
499 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
500 anAngle, aNbSteps, aTolerance);
502 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
504 myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
509 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
510 mySMESHGUI->updateObjBrowser(true); // new groups may appear
512 ConstructorsClicked(GetConstructorId());
513 SelectionIntoArgument();
519 //=================================================================================
520 // function : ClickOnOk()
522 //=================================================================================
523 void SMESHGUI_RevolutionDlg::ClickOnOk()
529 //=================================================================================
530 // function : ClickOnCancel()
532 //=================================================================================
533 void SMESHGUI_RevolutionDlg::ClickOnCancel()
535 disconnect(mySelectionMgr, 0, this, 0);
536 mySelectionMgr->clearFilters();
537 //mySelectionMgr->clearSelected();
538 SMESH::SetPointRepresentation(false);
539 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
540 aViewWindow->SetSelectionMode(ActorSelection);
541 mySMESHGUI->ResetState();
545 //=================================================================================
546 // function : ClickOnHelp()
548 //=================================================================================
549 void SMESHGUI_RevolutionDlg::ClickOnHelp()
551 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
553 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
557 platform = "winapplication";
559 platform = "application";
561 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
562 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
563 arg(app->resourceMgr()->stringValue("ExternalBrowser",
565 arg(myHelpFileName));
569 //=======================================================================
570 // function : onAngleTextChange()
572 //=======================================================================
573 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
576 SpinBox_Angle->text().toDouble( &isNumber );
578 RadioButton3->setChecked( true );
579 RadioButton4->setEnabled( isNumber );
582 //=======================================================================
583 // function : onTextChange()
585 //=======================================================================
586 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
588 QLineEdit* send = (QLineEdit*)sender();
593 if (send == LineEditElements)
596 buttonOk->setEnabled(false);
597 buttonApply->setEnabled(false);
599 // hilight entered elements
600 SMDS_Mesh* aMesh = 0;
602 aMesh = myActor->GetObject()->GetMesh();
605 if (send == LineEditElements) {
606 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
608 TColStd_MapOfInteger newIndices;
610 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
612 for (int i = 0; i < aListId.count(); i++) {
613 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
615 newIndices.Add(e->GetID());
619 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
620 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
621 aViewWindow->highlight( myActor->getIO(), true, true );
623 myElementsId = theNewText;
627 if (myNbOkElements && IsAxisOk()) {
628 buttonOk->setEnabled(true);
629 buttonApply->setEnabled(true);
631 onDisplaySimulation(true);
636 //=================================================================================
637 // function : SelectionIntoArgument()
638 // purpose : Called when selection as changed or other case
639 //=================================================================================
640 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
646 QString aString = "";
649 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
650 LineEditElements->setText(aString);
652 buttonOk->setEnabled(false);
653 buttonApply->setEnabled(false);
657 if (!GroupButtons->isEnabled()) // inactive
661 const SALOME_ListIO& aList = mySelector->StoredIObjects();
663 int nbSel = aList.Extent();
667 Handle(SALOME_InteractiveObject) IO = aList.First();
668 myMesh = SMESH::GetMeshByIO(IO);
669 if (myMesh->_is_nil())
672 myActor = SMESH::FindActorByObject(myMesh);
674 myActor = SMESH::FindActorByEntry(IO->getEntry());
680 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
683 // MakeGroups is available if there are groups
684 if ( myMesh->NbGroups() == 0 ) {
685 MakeGroupsCheck->setChecked(false);
686 MakeGroupsCheck->setEnabled(false);
688 MakeGroupsCheck->setEnabled(true);
691 if (CheckBoxMesh->isChecked()) {
692 int aConstructorId = GetConstructorId();
694 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
696 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
698 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
702 if (aConstructorId == 0) {
703 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
705 while (anIter->more()) {
706 const SMDS_MeshEdge * edge = anIter->next();
708 myElementsId += QString(" %1").arg(edge->GetID());
712 } else if (aConstructorId == 1) {
713 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
714 while (anIter->more()) {
715 const SMDS_MeshFace * face = anIter->next();
717 myElementsId += QString(" %1").arg(face->GetID());
722 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
724 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
726 // get IDs from submesh
727 SMESH::long_array_var anElementsIds = new SMESH::long_array;
728 if (aConstructorId == 0)
729 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
730 else if (aConstructorId == 1)
731 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
733 for (int i = 0; i < anElementsIds->length(); i++)
734 myElementsId += QString(" %1").arg(anElementsIds[i]);
735 aNbUnits = anElementsIds->length();
738 SMESH::SMESH_GroupBase_var aGroup =
739 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
740 if (aGroup->_is_nil())
743 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
744 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
747 // get IDs from smesh group
748 SMESH::long_array_var anElementsIds = new SMESH::long_array;
749 anElementsIds = aGroup->GetListOfID();
750 for (int i = 0; i < anElementsIds->length(); i++) {
751 myElementsId += QString(" %1").arg(anElementsIds[i]);
753 aNbUnits = anElementsIds->length();
756 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
757 myElementsId = aString;
763 myNbOkElements = true;
765 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
769 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
773 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
781 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
782 SpinBox_X->SetValue(x);
783 SpinBox_Y->SetValue(y);
784 SpinBox_Z->SetValue(z);
785 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
786 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
787 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
788 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
793 if (myEditCurrentArgument == (QWidget*)LineEditElements)
794 LineEditElements->setText(aString);
798 if (myNbOkElements && IsAxisOk()) {
799 buttonOk->setEnabled(true);
800 buttonApply->setEnabled(true);
803 onDisplaySimulation(true);
806 //=================================================================================
807 // function : SetEditCurrentArgument()
809 //=================================================================================
810 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
812 QPushButton* send = (QPushButton*)sender();
814 disconnect(mySelectionMgr, 0, this, 0);
815 mySelectionMgr->clearSelected();
816 mySelectionMgr->clearFilters();
818 if (send == SelectElementsButton) {
819 mySimulation->SetVisibility(false);
820 myEditCurrentArgument = (QWidget*)LineEditElements;
821 SMESH::SetPointRepresentation(false);
822 if (CheckBoxMesh->isChecked()) {
823 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
824 aViewWindow->SetSelectionMode(ActorSelection);
825 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
827 int aConstructorId = GetConstructorId();
828 if (aConstructorId == 0)
830 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
831 aViewWindow->SetSelectionMode(EdgeSelection);
833 else if (aConstructorId == 1)
835 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
836 aViewWindow->SetSelectionMode(FaceSelection);
839 } else if (send == SelectPointButton) {
840 myEditCurrentArgument = (QWidget*)SpinBox_X;
841 SMESH::SetPointRepresentation(true);
842 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
843 aViewWindow->SetSelectionMode(NodeSelection);
844 } else if (send == SelectVectorButton) {
845 myEditCurrentArgument = (QWidget*)SpinBox_DX;
846 SMESH::SetPointRepresentation(true);
847 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
848 aViewWindow->SetSelectionMode(NodeSelection);
852 myEditCurrentArgument->setFocus();
853 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
854 SelectionIntoArgument();
857 //=================================================================================
858 // function : DeactivateActiveDialog()
860 //=================================================================================
861 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
863 if (ConstructorsBox->isEnabled()) {
864 ConstructorsBox->setEnabled(false);
865 GroupArguments->setEnabled(false);
866 GroupButtons->setEnabled(false);
867 mySMESHGUI->ResetState();
868 mySMESHGUI->SetActiveDialogBox(0);
872 //=================================================================================
873 // function : ActivateThisDialog()
875 //=================================================================================
876 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
878 /* Emit a signal to deactivate the active dialog */
879 mySMESHGUI->EmitSignalDeactivateDialog();
880 ConstructorsBox->setEnabled(true);
881 GroupArguments->setEnabled(true);
882 GroupButtons->setEnabled(true);
884 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
886 ConstructorsClicked(GetConstructorId());
887 SelectionIntoArgument();
890 //=================================================================================
891 // function : enterEvent()
893 //=================================================================================
894 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
896 if (!ConstructorsBox->isEnabled())
897 ActivateThisDialog();
900 //=================================================================================
901 // function : closeEvent()
903 //=================================================================================
904 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
906 /* same than click on cancel button */
910 //=======================================================================
911 // function : hideEvent()
912 // purpose : caused by ESC key
913 //=======================================================================
914 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
920 //=======================================================================
921 //function : onSelectMesh
923 //=======================================================================
924 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
927 TextLabelElements->setText(tr("SMESH_NAME"));
929 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
931 if (myEditCurrentArgument != LineEditElements) {
932 LineEditElements->clear();
933 mySimulation->SetVisibility(false);
937 mySelectionMgr->clearFilters();
938 SMESH::SetPointRepresentation(false);
941 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
942 aViewWindow->SetSelectionMode(ActorSelection);
943 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
944 LineEditElements->setReadOnly(true);
945 LineEditElements->setValidator(0);
947 int aConstructorId = GetConstructorId();
948 if (aConstructorId == 0)
950 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
951 aViewWindow->SetSelectionMode(EdgeSelection);
953 else if (aConstructorId == 0)
955 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
956 aViewWindow->SetSelectionMode(FaceSelection);
959 LineEditElements->setReadOnly(false);
960 LineEditElements->setValidator(myIdValidator);
961 onTextChange(LineEditElements->text());
962 mySimulation->SetVisibility(false);
965 SelectionIntoArgument();
968 //=================================================================================
969 // function : GetConstructorId()
971 //=================================================================================
972 int SMESHGUI_RevolutionDlg::GetConstructorId()
974 return GroupConstructors->checkedId();
977 //=================================================================================
978 // function : IsAxisOk()
980 //=================================================================================
981 bool SMESHGUI_RevolutionDlg::IsAxisOk()
983 return (SpinBox_DX->GetValue() != 0 ||
984 SpinBox_DY->GetValue() != 0 ||
985 SpinBox_DZ->GetValue() != 0);
988 //=================================================================================
989 // function : onVectorChanged()
991 //=================================================================================
992 void SMESHGUI_RevolutionDlg::onVectorChanged()
995 buttonOk->setEnabled(true);
996 buttonApply->setEnabled(true);
998 buttonOk->setEnabled(false);
999 buttonApply->setEnabled(false);
1001 onDisplaySimulation(true);
1004 //=================================================================================
1005 // function : keyPressEvent()
1007 //=================================================================================
1008 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1010 QDialog::keyPressEvent( e );
1011 if ( e->isAccepted() )
1014 if ( e->key() == Qt::Key_F1 ) {
1020 //=================================================================================
1021 // function : toDisplaySimulation()
1023 //=================================================================================
1024 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1026 onDisplaySimulation(true);
1029 //=================================================================================
1030 // function : onDisplaySimulation()
1032 //=================================================================================
1033 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1035 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1038 if (myNbOkElements && IsAxisOk())
1040 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1042 SMESH::long_array_var anElementsId = new SMESH::long_array;
1044 anElementsId->length(aListElementsId.count());
1045 for (int i = 0; i < aListElementsId.count(); i++)
1046 anElementsId[i] = aListElementsId[i].toInt();
1048 SMESH::AxisStruct anAxis;
1050 anAxis.x = SpinBox_X->GetValue();
1051 anAxis.y = SpinBox_Y->GetValue();
1052 anAxis.z = SpinBox_Z->GetValue();
1053 anAxis.vx = SpinBox_DX->GetValue();
1054 anAxis.vy = SpinBox_DY->GetValue();
1055 anAxis.vz = SpinBox_DZ->GetValue();
1057 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1058 long aNbSteps = (long)SpinBox_NbSteps->value();
1059 double aTolerance = SpinBox_Tolerance->GetValue();
1061 if (GroupAngle->checkedId() == 1)
1062 anAngle = anAngle/aNbSteps;
1065 SUIT_OverrideCursor aWaitCursor;
1066 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1067 aMeshEditor->RotationSweep(anElementsId.inout(),
1072 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1073 mySimulation->SetData(aMeshPreviewStruct._retn());
1078 mySimulation->SetVisibility(false);
1084 mySimulation->SetVisibility(false);
1089 //=================================================================================
1090 // function : isValid
1092 //=================================================================================
1093 bool SMESHGUI_RevolutionDlg::isValid()
1097 ok = SpinBox_X->isValid( msg, true ) && ok;
1098 ok = SpinBox_Y->isValid( msg, true ) && ok;
1099 ok = SpinBox_Z->isValid( msg, true ) && ok;
1100 ok = SpinBox_DX->isValid( msg, true ) && ok;
1101 ok = SpinBox_DY->isValid( msg, true ) && ok;
1102 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1103 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1104 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1105 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1108 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1109 if ( !msg.isEmpty() )
1111 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );