1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_RevolutionDlg.cxx
24 // 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"
36 #include "SMESHGUI_FilterDlg.h"
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
41 #include <SMDS_Mesh.hxx>
43 // SALOME GUI includes
44 #include <SUIT_ResourceMgr.h>
45 #include <SUIT_Session.h>
46 #include <SUIT_MessageBox.h>
47 #include <SUIT_Desktop.h>
48 #include <SUIT_OverrideCursor.h>
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <SalomeApp_Application.h>
53 #include <SalomeApp_IntSpinBox.h>
55 #include <SVTK_ViewWindow.h>
56 #include <SVTK_Selector.h>
57 #include <SALOME_ListIO.hxx>
58 #include <VTKViewer_CellLocationsArray.h>
61 #include <TColStd_MapOfInteger.hxx>
64 #include <QApplication>
65 #include <QButtonGroup>
69 #include <QPushButton>
70 #include <QRadioButton>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
86 //=================================================================================
87 // class : SMESHGUI_RevolutionDlg()
89 //=================================================================================
90 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
91 : SMESHGUI_PreviewDlg( theModule ),
92 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
93 myVectorDefinition(NONE_SELECT),
95 mySelectedObject(SMESH::SMESH_IDSource::_nil()),
98 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
100 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
101 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
102 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
103 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
106 setAttribute(Qt::WA_DeleteOnClose, true);
107 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
108 setSizeGripEnabled(true);
110 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
111 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
112 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
114 /***************************************************************/
115 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
116 GroupConstructors = new QButtonGroup(this);
117 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
118 ConstructorsBoxLayout->setSpacing(SPACING);
119 ConstructorsBoxLayout->setMargin(MARGIN);
121 RadioButton1 = new QRadioButton(ConstructorsBox);
122 RadioButton1->setIcon(image0);
123 RadioButton2 = new QRadioButton(ConstructorsBox);
124 RadioButton2->setIcon(image1);
126 ConstructorsBoxLayout->addWidget(RadioButton1);
127 ConstructorsBoxLayout->addWidget(RadioButton2);
128 GroupConstructors->addButton(RadioButton1, 0);
129 GroupConstructors->addButton(RadioButton2, 1);
131 /***************************************************************/
132 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
133 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
134 GroupArgumentsLayout->setSpacing(SPACING);
135 GroupArgumentsLayout->setMargin(MARGIN);
137 myIdValidator = new SMESHGUI_IdValidator(this);
139 // Controls for elements selection
140 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
142 SelectElementsButton = new QPushButton(GroupArguments);
143 SelectElementsButton->setIcon(image2);
145 LineEditElements = new QLineEdit(GroupArguments);
146 LineEditElements->setValidator(myIdValidator);
147 LineEditElements->setMaxLength(-1);
148 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
149 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
151 // Control for the whole mesh selection
152 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
154 // Controls for axis defining
155 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
156 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
157 GroupAxisLayout->setSpacing(SPACING);
158 GroupAxisLayout->setMargin(MARGIN);
160 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
161 SelectPointButton = new QPushButton(GroupAxis);
162 SelectPointButton->setIcon(image2);
164 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
165 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
167 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
168 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
170 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
171 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
173 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
174 SelectVectorButton = new QPushButton(GroupAxis);
175 SelectVectorButton->setIcon(image2);
177 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
178 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
180 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
181 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
183 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
184 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
186 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
187 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
188 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
189 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
190 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
191 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
192 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
193 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
194 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
195 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
196 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
197 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
198 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
199 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
200 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
201 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
203 // Controls for angle defining & number of steps defining
204 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
205 GroupAngle = new QButtonGroup(GroupAngleBox);
206 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
207 GroupAngleLayout->setSpacing(6);
208 GroupAngleLayout->setMargin(11);
210 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
211 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
212 GroupAngle->addButton(RadioButton3, 0);
213 GroupAngle->addButton(RadioButton4, 1);
215 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
216 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
218 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
219 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
221 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
222 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
223 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
224 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
225 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
226 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
228 // Controls for tolerance defining
229 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
230 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
232 // Control for mesh preview
233 myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
235 // CheckBox for groups generation
236 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
237 MakeGroupsCheck->setChecked(true);
239 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
240 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
241 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
242 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
243 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
244 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
245 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 4);
246 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
247 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2, 1, 2);
248 GroupArgumentsLayout->addWidget(myPreviewCheckBox, 5, 0, 1, 4);
249 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
251 /***************************************************************/
252 GroupButtons = new QGroupBox(this);
253 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
254 GroupButtonsLayout->setSpacing(SPACING);
255 GroupButtonsLayout->setMargin(MARGIN);
257 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
258 buttonOk->setAutoDefault(true);
259 buttonOk->setDefault(true);
260 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
261 buttonApply->setAutoDefault(true);
262 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
263 buttonCancel->setAutoDefault(true);
264 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
265 buttonHelp->setAutoDefault(true);
267 GroupButtonsLayout->addWidget(buttonOk);
268 GroupButtonsLayout->addSpacing(10);
269 GroupButtonsLayout->addWidget(buttonApply);
270 GroupButtonsLayout->addSpacing(10);
271 GroupButtonsLayout->addStretch();
272 GroupButtonsLayout->addWidget(buttonCancel);
273 GroupButtonsLayout->addWidget(buttonHelp);
275 /***************************************************************/
276 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
277 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
278 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
280 /* Initialisations */
281 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
282 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
283 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
284 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
285 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
286 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
288 RadioButton3->setChecked(true);
290 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, "angle_precision");
292 SpinBox_NbSteps->setRange(1, 999999);
294 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
296 RadioButton1->setChecked(true);
298 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
300 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
302 // Costruction of the logical filter
303 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
304 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
306 QList<SUIT_SelectionFilter*> aListOfFilters;
307 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
308 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
310 myMeshOrSubMeshOrGroupFilter =
311 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
313 myHelpFileName = "revolution_page.html";
317 /*Create menu to vector selection*/
318 SelectVectorMenu = new QMenu(this);
319 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
320 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
321 connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
323 /* signals and slots connections */
324 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
325 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
326 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
327 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
328 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
330 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
331 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
332 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
334 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
335 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
338 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
339 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
340 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
342 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
343 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
344 /* to close dialog if study change */
345 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
346 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
347 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
349 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
350 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
351 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
352 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
354 //To Connect preview check box
355 connectPreviewControl();
357 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
359 ConstructorsClicked(0);
360 SelectionIntoArgument();
363 //=================================================================================
364 // function : ~SMESHGUI_RevolutionDlg()
365 // purpose : Destroys the object and frees any allocated resources
366 //=================================================================================
367 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
371 myFilterDlg->setParent( 0 );
377 //=================================================================================
380 //=================================================================================
381 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
385 myEditCurrentArgument = 0;
386 LineEditElements->clear();
392 myMesh = SMESH::SMESH_Mesh::_nil();
395 SpinBox_X->SetValue(0.0);
396 SpinBox_Y->SetValue(0.0);
397 SpinBox_Z->SetValue(0.0);
398 SpinBox_DX->SetValue(0.0);
399 SpinBox_DY->SetValue(0.0);
400 SpinBox_DZ->SetValue(0.0);
402 SpinBox_Angle->SetValue(45);
403 SpinBox_NbSteps->setValue(1);
404 SpinBox_Tolerance->SetValue(1e-05);
406 CheckBoxMesh->setChecked(false);
408 myPreviewCheckBox->setChecked(false);
409 onDisplaySimulation(false);
413 //=================================================================================
414 // function : ConstructorsClicked()
415 // purpose : Radio button management
416 //=================================================================================
417 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
419 disconnect(mySelectionMgr, 0, this, 0);
422 mySelectionMgr->selectedObjects( io );
424 mySelectionMgr->setSelectedObjects( aList );*/
426 buttonApply->setEnabled(false);
427 buttonOk->setEnabled(false);
428 mySimulation->SetVisibility(false);
430 Selection_Mode aSelMode = ActorSelection;
432 switch (constructorId) {
435 GroupArguments->setTitle(tr("REVOLUTION_1D"));
436 aSelMode = EdgeSelection;
441 GroupArguments->setTitle(tr("REVOLUTION_2D"));
442 aSelMode = FaceSelection;
447 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
448 SMESH::SetPointRepresentation(false);
451 if (!CheckBoxMesh->isChecked())
453 LineEditElements->clear();
456 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
457 aViewWindow->SetSelectionMode(aSelMode);
460 myEditCurrentArgument = (QWidget*)LineEditElements;
461 LineEditElements->setFocus();
463 if (CheckBoxMesh->isChecked())
466 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
467 // mySelectionMgr->setSelectedObjects( io );
470 //=================================================================================
471 // function : ClickOnApply()
473 //=================================================================================
474 bool SMESHGUI_RevolutionDlg::ClickOnApply()
476 if (mySMESHGUI->isActiveStudyLocked())
482 if (myNbOkElements && IsAxisOk()) {
483 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
485 SMESH::long_array_var anElementsId = new SMESH::long_array;
487 anElementsId->length(aListElementsId.count());
488 for (int i = 0; i < aListElementsId.count(); i++)
489 anElementsId[i] = aListElementsId[i].toInt();
491 SMESH::AxisStruct anAxis;
493 anAxis.x = SpinBox_X->GetValue();
494 anAxis.y = SpinBox_Y->GetValue();
495 anAxis.z = SpinBox_Z->GetValue();;
496 anAxis.vx = SpinBox_DX->GetValue();
497 anAxis.vy = SpinBox_DY->GetValue();
498 anAxis.vz = SpinBox_DZ->GetValue();
500 double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
501 long aNbSteps = (long)SpinBox_NbSteps->value();
502 double aTolerance = SpinBox_Tolerance->GetValue();
504 if ( GroupAngle->checkedId() == 1 )
505 anAngle = anAngle/aNbSteps;
507 QStringList aParameters;
508 aParameters << SpinBox_X->text();
509 aParameters << SpinBox_Y->text();
510 aParameters << SpinBox_Z->text();
511 aParameters << SpinBox_DX->text();
512 aParameters << SpinBox_DY->text();
513 aParameters << SpinBox_DZ->text();
514 aParameters << SpinBox_Angle->text();
515 aParameters << SpinBox_NbSteps->text();
516 aParameters << SpinBox_Tolerance->text();
519 SUIT_OverrideCursor aWaitCursor;
520 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
522 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
523 if( CheckBoxMesh->isChecked() ) {
524 if( GetConstructorId() == 0 )
525 SMESH::ListOfGroups_var groups =
526 aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
527 anAngle, aNbSteps, aTolerance);
529 SMESH::ListOfGroups_var groups =
530 aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
531 anAngle, aNbSteps, aTolerance);
534 SMESH::ListOfGroups_var groups =
535 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
536 anAngle, aNbSteps, aTolerance);
539 if( CheckBoxMesh->isChecked() ) {
540 if( GetConstructorId() == 0 )
541 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
543 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
546 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
549 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
554 SMESH::Update(myIO, SMESH::eDisplay);
555 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
556 mySMESHGUI->updateObjBrowser(true); // new groups may appear
558 ConstructorsClicked(GetConstructorId());
559 mySelectedObject = SMESH::SMESH_IDSource::_nil();
560 SelectionIntoArgument();
562 SMESHGUI::Modified();
568 //=================================================================================
569 // function : ClickOnOk()
571 //=================================================================================
572 void SMESHGUI_RevolutionDlg::ClickOnOk()
578 //=================================================================================
579 // function : ClickOnCancel()
581 //=================================================================================
582 void SMESHGUI_RevolutionDlg::ClickOnCancel()
587 void SMESHGUI_RevolutionDlg::reject()
592 //=================================================================================
593 // function : ClickOnHelp()
595 //=================================================================================
596 void SMESHGUI_RevolutionDlg::ClickOnHelp()
598 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
600 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
604 platform = "winapplication";
606 platform = "application";
608 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
609 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
610 arg(app->resourceMgr()->stringValue("ExternalBrowser",
612 arg(myHelpFileName));
616 //=======================================================================
617 // function : onAngleTextChange()
619 //=======================================================================
620 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
623 SpinBox_Angle->text().toDouble( &isNumber );
625 RadioButton3->setChecked( true );
626 RadioButton4->setEnabled( isNumber );
629 //=======================================================================
630 // function : onTextChange()
632 //=======================================================================
633 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
635 QLineEdit* send = (QLineEdit*)sender();
640 if (send == LineEditElements)
643 buttonOk->setEnabled(false);
644 buttonApply->setEnabled(false);
646 // hilight entered elements
647 SMDS_Mesh* aMesh = 0;
649 aMesh = myActor->GetObject()->GetMesh();
652 if (send == LineEditElements) {
653 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
655 TColStd_MapOfInteger newIndices;
657 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
659 for (int i = 0; i < aListId.count(); i++) {
660 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
662 newIndices.Add(e->GetID());
666 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
667 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
668 aViewWindow->highlight( myActor->getIO(), true, true );
670 myElementsId = theNewText;
674 if (myNbOkElements && IsAxisOk()) {
675 buttonOk->setEnabled(true);
676 buttonApply->setEnabled(true);
678 onDisplaySimulation(true);
683 //=================================================================================
684 // function : SelectionIntoArgument()
685 // purpose : Called when selection as changed or other case
686 //=================================================================================
687 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
692 QString aString = "";
695 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
696 LineEditElements->setText(aString);
698 buttonOk->setEnabled(false);
699 buttonApply->setEnabled(false);
703 if (!GroupButtons->isEnabled()) // inactive
707 const SALOME_ListIO& aList = mySelector->StoredIObjects();
709 int nbSel = aList.Extent();
713 Handle(SALOME_InteractiveObject) IO = aList.First();
714 SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
715 if (aMeshVar->_is_nil())
718 SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
720 anActor = SMESH::FindActorByEntry(IO->getEntry());
721 if (!anActor && !CheckBoxMesh->isChecked())
726 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
732 // MakeGroups is available if there are groups
733 if ( myMesh->NbGroups() == 0 ) {
734 MakeGroupsCheck->setChecked(false);
735 MakeGroupsCheck->setEnabled(false);
737 MakeGroupsCheck->setEnabled(true);
740 if (CheckBoxMesh->isChecked()) {
741 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
743 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
744 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
748 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
749 myElementsId = aString;
753 myNbOkElements = true;
756 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
760 bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
761 (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
762 myVectorDefinition==POINT_SELECT));
764 bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
765 myVectorDefinition==FACE_SELECT);
768 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
770 else if(isFaceSelected){
771 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
778 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
786 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
787 SpinBox_X->SetValue(x);
788 SpinBox_Y->SetValue(y);
789 SpinBox_Z->SetValue(z);
790 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
791 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
792 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
793 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
796 else if(isFaceSelected){
797 const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
801 gp_XYZ aNormale = SMESH::getNormale(face);
802 SpinBox_DX->SetValue(aNormale.X());
803 SpinBox_DY->SetValue(aNormale.Y());
804 SpinBox_DZ->SetValue(aNormale.Z());
810 if (myEditCurrentArgument == (QWidget*)LineEditElements)
811 LineEditElements->setText(aString);
815 if (myNbOkElements && IsAxisOk()) {
816 buttonOk->setEnabled(true);
817 buttonApply->setEnabled(true);
820 onDisplaySimulation(true);
823 //=================================================================================
824 // function : SetEditCurrentArgument()
826 //=================================================================================
827 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
829 QPushButton* send = (QPushButton*)sender();
831 disconnect(mySelectionMgr, 0, this, 0);
832 mySelectionMgr->clearSelected();
833 mySelectionMgr->clearFilters();
835 if (send == SelectElementsButton) {
836 mySimulation->SetVisibility(false);
837 myEditCurrentArgument = (QWidget*)LineEditElements;
838 SMESH::SetPointRepresentation(false);
839 if (CheckBoxMesh->isChecked()) {
840 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
841 aViewWindow->SetSelectionMode(ActorSelection);
842 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
844 int aConstructorId = GetConstructorId();
845 if (aConstructorId == 0)
847 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
848 aViewWindow->SetSelectionMode(EdgeSelection);
850 else if (aConstructorId == 1)
852 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
853 aViewWindow->SetSelectionMode(FaceSelection);
856 } else if (send == SelectPointButton) {
857 myEditCurrentArgument = (QWidget*)SpinBox_X;
858 SMESH::SetPointRepresentation(true);
859 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
860 aViewWindow->SetSelectionMode(NodeSelection);
863 myEditCurrentArgument->setFocus();
864 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
865 SelectionIntoArgument();
868 //=================================================================================
869 // function : DeactivateActiveDialog()
871 //=================================================================================
872 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
874 if (ConstructorsBox->isEnabled()) {
875 ConstructorsBox->setEnabled(false);
876 GroupArguments->setEnabled(false);
877 GroupButtons->setEnabled(false);
878 mySMESHGUI->ResetState();
879 mySMESHGUI->SetActiveDialogBox(0);
883 //=================================================================================
884 // function : ActivateThisDialog()
886 //=================================================================================
887 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
889 /* Emit a signal to deactivate the active dialog */
890 mySMESHGUI->EmitSignalDeactivateDialog();
891 ConstructorsBox->setEnabled(true);
892 GroupArguments->setEnabled(true);
893 GroupButtons->setEnabled(true);
895 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
897 ConstructorsClicked(GetConstructorId());
898 SelectionIntoArgument();
901 //=================================================================================
902 // function : enterEvent()
904 //=================================================================================
905 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
907 if (!ConstructorsBox->isEnabled())
908 ActivateThisDialog();
911 //=================================================================================
912 // function : closeEvent()
914 //=================================================================================
915 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
917 /* same than click on cancel button */
918 disconnect(mySelectionMgr, 0, this, 0);
919 mySelectionMgr->clearFilters();
920 //mySelectionMgr->clearSelected();
921 if (SMESH::GetCurrentVtkView()) {
922 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
923 SMESH::SetPointRepresentation(false);
925 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
926 aViewWindow->SetSelectionMode(ActorSelection);
927 mySMESHGUI->ResetState();
930 //=======================================================================
931 //function : onSelectMesh
933 //=======================================================================
934 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
937 myIDs = LineEditElements->text();
938 TextLabelElements->setText(tr("SMESH_NAME"));
941 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
942 myFilterBtn->setEnabled(!toSelectMesh);
944 if (myEditCurrentArgument != LineEditElements) {
945 LineEditElements->clear();
946 mySimulation->SetVisibility(false);
950 mySelectionMgr->clearFilters();
951 SMESH::SetPointRepresentation(false);
954 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
955 aViewWindow->SetSelectionMode(ActorSelection);
956 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
957 LineEditElements->setReadOnly(true);
958 LineEditElements->setValidator(0);
960 int aConstructorId = GetConstructorId();
961 if (aConstructorId == 0)
963 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
964 aViewWindow->SetSelectionMode(EdgeSelection);
966 else if (aConstructorId == 1)
968 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
969 aViewWindow->SetSelectionMode(FaceSelection);
972 LineEditElements->setReadOnly(false);
973 LineEditElements->setValidator(myIdValidator);
974 onTextChange(LineEditElements->text());
975 mySimulation->SetVisibility(false);
978 SelectionIntoArgument();
981 LineEditElements->setText( myIDs );
984 //=================================================================================
985 // function : GetConstructorId()
987 //=================================================================================
988 int SMESHGUI_RevolutionDlg::GetConstructorId()
990 return GroupConstructors->checkedId();
993 //=================================================================================
994 // function : IsAxisOk()
996 //=================================================================================
997 bool SMESHGUI_RevolutionDlg::IsAxisOk()
999 return (SpinBox_DX->GetValue() != 0 ||
1000 SpinBox_DY->GetValue() != 0 ||
1001 SpinBox_DZ->GetValue() != 0);
1004 //=================================================================================
1005 // function : onVectorChanged()
1007 //=================================================================================
1008 void SMESHGUI_RevolutionDlg::onVectorChanged()
1011 buttonOk->setEnabled(true);
1012 buttonApply->setEnabled(true);
1014 buttonOk->setEnabled(false);
1015 buttonApply->setEnabled(false);
1017 onDisplaySimulation(true);
1020 //=================================================================================
1021 // function : keyPressEvent()
1023 //=================================================================================
1024 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1026 QDialog::keyPressEvent( e );
1027 if ( e->isAccepted() )
1030 if ( e->key() == Qt::Key_F1 ) {
1036 //=================================================================================
1037 // function : onDisplaySimulation()
1038 // purpose : Show/Hide preview
1039 //=================================================================================
1040 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1042 if (myPreviewCheckBox->isChecked() && toDisplayPreview)
1045 if (myNbOkElements && IsAxisOk())
1047 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1049 SMESH::long_array_var anElementsId = new SMESH::long_array;
1051 anElementsId->length(aListElementsId.count());
1052 for (int i = 0; i < aListElementsId.count(); i++)
1053 anElementsId[i] = aListElementsId[i].toInt();
1055 SMESH::AxisStruct anAxis;
1057 anAxis.x = SpinBox_X->GetValue();
1058 anAxis.y = SpinBox_Y->GetValue();
1059 anAxis.z = SpinBox_Z->GetValue();
1060 anAxis.vx = SpinBox_DX->GetValue();
1061 anAxis.vy = SpinBox_DY->GetValue();
1062 anAxis.vz = SpinBox_DZ->GetValue();
1064 double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
1065 long aNbSteps = (long)SpinBox_NbSteps->value();
1066 double aTolerance = SpinBox_Tolerance->GetValue();
1068 if (GroupAngle->checkedId() == 1)
1069 anAngle = anAngle/aNbSteps;
1072 SUIT_OverrideCursor aWaitCursor;
1073 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1074 if( CheckBoxMesh->isChecked() ) {
1075 if( GetConstructorId() == 0 )
1076 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1077 anAngle, aNbSteps, aTolerance);
1079 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1080 anAngle, aNbSteps, aTolerance);
1083 aMeshEditor->RotationSweep(anElementsId.inout(),
1088 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1089 mySimulation->SetData(aMeshPreviewStruct._retn());
1094 mySimulation->SetVisibility(false);
1100 mySimulation->SetVisibility(false);
1104 //=================================================================================
1105 // function : onSelectVectorButton()
1107 //=================================================================================
1108 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1109 if(SelectVectorMenu) {
1110 SelectVectorMenu->exec( QCursor::pos() );
1114 //=================================================================================
1115 // function : onSelectVectorMenu()
1117 //=================================================================================
1118 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1122 disconnect(mySelectionMgr, 0, this, 0);
1124 switch(myMenuActions[action]) {
1126 SMESH::SetPointRepresentation(true);
1127 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1128 aViewWindow->SetSelectionMode(NodeSelection);
1132 SMESH::SetPointRepresentation(false);
1133 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1134 aViewWindow->SetSelectionMode(FaceSelection);
1138 myVectorDefinition = myMenuActions[action];
1139 myEditCurrentArgument = (QWidget*)SpinBox_DX;
1140 myEditCurrentArgument->setFocus();
1141 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1142 SelectionIntoArgument();
1145 //=================================================================================
1146 // function : setFilters()
1147 // purpose : SLOT. Called when "Filter" button pressed.
1148 //=================================================================================
1149 void SMESHGUI_RevolutionDlg::setFilters()
1151 if(myMesh->_is_nil()) {
1152 SUIT_MessageBox::critical(this,
1154 tr("NO_MESH_SELECTED"));
1160 types.append( SMESH::EDGE );
1161 types.append( SMESH::FACE );
1162 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1164 myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1166 myFilterDlg->SetSelection();
1167 myFilterDlg->SetMesh( myMesh );
1168 myFilterDlg->SetSourceWg( LineEditElements );
1170 myFilterDlg->show();
1173 //=================================================================================
1174 // function : isValid
1176 //=================================================================================
1177 bool SMESHGUI_RevolutionDlg::isValid()
1181 ok = SpinBox_X->isValid( msg, true ) && ok;
1182 ok = SpinBox_Y->isValid( msg, true ) && ok;
1183 ok = SpinBox_Z->isValid( msg, true ) && ok;
1184 ok = SpinBox_DX->isValid( msg, true ) && ok;
1185 ok = SpinBox_DY->isValid( msg, true ) && ok;
1186 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1187 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1188 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1189 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1192 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1193 if ( !msg.isEmpty() )
1195 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );