Salome HOME
0019928: EDF 771 SMESH : Extrusion (Revolution) with normal to a face
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_RevolutionDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_RevolutionDlg.cxx
24 // Author : Michael ZORIN, Open CASCADE S.A.S.
25 // SMESH includes
26 //
27 #include "SMESHGUI_RevolutionDlg.h"
28
29 #include "SMESHGUI.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"
37
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
41 #include <SMDS_Mesh.hxx>
42
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>
49
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <SalomeApp_Application.h>
53 #include <SalomeApp_IntSpinBox.h>
54
55 #include <SVTK_ViewWindow.h>
56 #include <SVTK_Selector.h>
57 #include <SALOME_ListIO.hxx>
58 #include <VTKViewer_CellLocationsArray.h>
59
60 // OCCT includes
61 #include <TColStd_MapOfInteger.hxx>
62
63 // Qt includes
64 #include <QApplication>
65 #include <QButtonGroup>
66 #include <QGroupBox>
67 #include <QLabel>
68 #include <QLineEdit>
69 #include <QPushButton>
70 #include <QRadioButton>
71 #include <QCheckBox>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
75 #include <QKeyEvent>
76 #include <QMenu>
77
78 // IDL includes
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
82
83 #define SPACING 6
84 #define MARGIN  11
85
86 //=================================================================================
87 // class    : SMESHGUI_RevolutionDlg()
88 // purpose  :
89 //=================================================================================
90 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
91   : QDialog( SMESH::GetDesktop( theModule ) ),
92     mySMESHGUI( theModule ),
93     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
94     myVectorDefinition(NONE_SELECT),
95     myFilterDlg( 0 ),
96     mySelectedObject(SMESH::SMESH_IDSource::_nil())
97 {
98   mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
99
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")));
104
105   setModal(false);
106   setAttribute(Qt::WA_DeleteOnClose, true);
107   setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
108   setSizeGripEnabled(true);
109   
110   QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
111   SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
112   SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
113
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);
120
121   RadioButton1 = new QRadioButton(ConstructorsBox);
122   RadioButton1->setIcon(image0);
123   RadioButton2 = new QRadioButton(ConstructorsBox);
124   RadioButton2->setIcon(image1);
125
126   ConstructorsBoxLayout->addWidget(RadioButton1);
127   ConstructorsBoxLayout->addWidget(RadioButton2);
128   GroupConstructors->addButton(RadioButton1, 0);
129   GroupConstructors->addButton(RadioButton2, 1);
130
131   /***************************************************************/
132   GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
133   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
134   GroupArgumentsLayout->setSpacing(SPACING);
135   GroupArgumentsLayout->setMargin(MARGIN);
136
137   myIdValidator = new SMESHGUI_IdValidator(this);
138
139   // Controls for elements selection
140   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
141
142   SelectElementsButton = new QPushButton(GroupArguments);
143   SelectElementsButton->setIcon(image2);
144
145   LineEditElements  = new QLineEdit(GroupArguments);
146   LineEditElements->setValidator(myIdValidator);
147   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
148   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
149
150   // Control for the whole mesh selection
151   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
152
153   // Controls for axis defining
154   GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
155   QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
156   GroupAxisLayout->setSpacing(SPACING);
157   GroupAxisLayout->setMargin(MARGIN);
158
159   TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
160   SelectPointButton  = new QPushButton(GroupAxis);
161   SelectPointButton->setIcon(image2);
162
163   TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
164   SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
165
166   TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
167   SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
168
169   TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
170   SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
171
172   TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
173   SelectVectorButton = new QPushButton(GroupAxis);
174   SelectVectorButton->setIcon(image2);
175
176   TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
177   SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
178
179   TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
180   SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
181
182   TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
183   SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
184
185   GroupAxisLayout->addWidget(TextLabelPoint,     0, 0);
186   GroupAxisLayout->addWidget(SelectPointButton,  0, 1);
187   GroupAxisLayout->addWidget(TextLabelX,         0, 2);
188   GroupAxisLayout->addWidget(SpinBox_X,          0, 3);
189   GroupAxisLayout->addWidget(TextLabelY,         0, 4);
190   GroupAxisLayout->addWidget(SpinBox_Y,          0, 5);
191   GroupAxisLayout->addWidget(TextLabelZ,         0, 6);
192   GroupAxisLayout->addWidget(SpinBox_Z,          0, 7);
193   GroupAxisLayout->addWidget(TextLabelVector,    1, 0);
194   GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
195   GroupAxisLayout->addWidget(TextLabelDX,        1, 2);
196   GroupAxisLayout->addWidget(SpinBox_DX,         1, 3);
197   GroupAxisLayout->addWidget(TextLabelDY,        1, 4);
198   GroupAxisLayout->addWidget(SpinBox_DY,         1, 5);
199   GroupAxisLayout->addWidget(TextLabelDZ,        1, 6);
200   GroupAxisLayout->addWidget(SpinBox_DZ,         1, 7);
201
202   // Controls for angle defining & number of steps defining
203   GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
204   GroupAngle = new QButtonGroup(GroupAngleBox);
205   QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
206   GroupAngleLayout->setSpacing(6);
207   GroupAngleLayout->setMargin(11);
208
209   RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
210   RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"),   GroupAngleBox);
211   GroupAngle->addButton(RadioButton3, 0);
212   GroupAngle->addButton(RadioButton4, 1);
213
214   TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
215   SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
216
217   TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
218   SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
219
220   GroupAngleLayout->addWidget(RadioButton3,     0, 0);
221   GroupAngleLayout->addWidget(RadioButton4,     0, 1);
222   GroupAngleLayout->addWidget(TextLabelAngle,   1, 0);
223   GroupAngleLayout->addWidget(SpinBox_Angle,    1, 1);
224   GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
225   GroupAngleLayout->addWidget(SpinBox_NbSteps,  2, 1);
226
227   // Controls for tolerance defining
228   TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
229   SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
230
231   // Control for mesh preview
232   CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
233
234   // CheckBox for groups generation
235   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
236   MakeGroupsCheck->setChecked(true);
237
238   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
239   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
240   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2);
241   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 3);
242   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 4);
243   GroupArgumentsLayout->addWidget(GroupAxis,            2, 0, 1, 4);
244   GroupArgumentsLayout->addWidget(GroupAngleBox,        3, 0, 1, 4);
245   GroupArgumentsLayout->addWidget(TextLabelTolerance,   4, 0, 1, 2);
246   GroupArgumentsLayout->addWidget(SpinBox_Tolerance,    4, 2, 1, 2);
247   GroupArgumentsLayout->addWidget(CheckBoxPreview,      5, 0, 1, 4);
248   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      6, 0, 1, 4);
249
250   /***************************************************************/
251   GroupButtons = new QGroupBox(this);
252   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
253   GroupButtonsLayout->setSpacing(SPACING);
254   GroupButtonsLayout->setMargin(MARGIN);
255   
256   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
257   buttonOk->setAutoDefault(true);
258   buttonOk->setDefault(true);
259   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
260   buttonApply->setAutoDefault(true);
261   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
262   buttonCancel->setAutoDefault(true);
263   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
264   buttonHelp->setAutoDefault(true);
265
266   GroupButtonsLayout->addWidget(buttonOk);
267   GroupButtonsLayout->addSpacing(10);
268   GroupButtonsLayout->addWidget(buttonApply);
269   GroupButtonsLayout->addSpacing(10);
270   GroupButtonsLayout->addStretch();
271   GroupButtonsLayout->addWidget(buttonCancel);
272   GroupButtonsLayout->addWidget(buttonHelp);
273
274   /***************************************************************/
275   SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
276   SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
277   SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
278
279   /* Initialisations */
280   SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
281   SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
282   SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
283   SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
284   SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285   SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
286
287   RadioButton3->setChecked(true);
288
289   SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
290
291   SpinBox_NbSteps->setRange(1, 999999);
292
293   SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
294
295   RadioButton1->setChecked(true);
296
297   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
298
299   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
300
301   // Costruction of the logical filter
302   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
303   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
304
305   QList<SUIT_SelectionFilter*> aListOfFilters;
306   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
307   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
308
309   myMeshOrSubMeshOrGroupFilter =
310     new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
311
312   myHelpFileName = "revolution_page.html";
313
314   Init();
315
316   /*Create menu to vector selection*/
317   SelectVectorMenu = new QMenu(this);
318   myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
319   myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
320   connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
321
322   /* signals and slots connections */
323   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
324   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
325   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
326   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
327   connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
328
329   connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
330   connect(SelectPointButton,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
331   connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
332
333   connect(SpinBox_X,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
334   connect(SpinBox_Y,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
335   connect(SpinBox_Z,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336
337   connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
338   connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
339   connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
340
341   connect(mySMESHGUI,     SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
342   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
343   /* to close dialog if study change */
344   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
345   connect(LineEditElements, SIGNAL(textChanged(const QString&)),   SLOT(onTextChange(const QString&)));
346   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                 SLOT(onSelectMesh(bool)));
347
348   connect(GroupAngle,        SIGNAL(buttonClicked(int)),   this, SLOT(toDisplaySimulation()));
349   connect(SpinBox_Angle,     SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
350   connect(SpinBox_NbSteps,   SIGNAL(valueChanged(int)),    this, SLOT(toDisplaySimulation()));
351   connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
352   connect(CheckBoxPreview,   SIGNAL(toggled(bool)),        this, SLOT(onDisplaySimulation(bool)));
353
354   connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
355
356   ConstructorsClicked(0);
357   SelectionIntoArgument();
358 }
359
360 //=================================================================================
361 // function : ~SMESHGUI_RevolutionDlg()
362 // purpose  : Destroys the object and frees any allocated resources
363 //=================================================================================
364 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
365 {
366   delete mySimulation;
367   if ( myFilterDlg ) {
368     myFilterDlg->setParent( 0 );
369     delete myFilterDlg;
370     myFilterDlg = 0;
371   }
372 }
373
374 //=================================================================================
375 // function : Init()
376 // purpose  :
377 //=================================================================================
378 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
379 {
380   myBusy = false;
381
382   myEditCurrentArgument = 0;
383   LineEditElements->clear();
384   myElementsId = "";
385   myNbOkElements = 0;
386   myIDs.clear();
387
388   myActor = 0;
389   myMesh = SMESH::SMESH_Mesh::_nil();
390
391   if (ResetControls) {
392     SpinBox_X->SetValue(0.0);
393     SpinBox_Y->SetValue(0.0);
394     SpinBox_Z->SetValue(0.0);
395     SpinBox_DX->SetValue(0.0);
396     SpinBox_DY->SetValue(0.0);
397     SpinBox_DZ->SetValue(0.0);
398
399     SpinBox_Angle->SetValue(45);
400     SpinBox_NbSteps->setValue(1);
401     SpinBox_Tolerance->SetValue(1e-05);
402
403     CheckBoxMesh->setChecked(false);
404     onSelectMesh(false);
405     CheckBoxPreview->setChecked(false);
406     onDisplaySimulation(false);
407   }
408 }
409
410 //=================================================================================
411 // function : ConstructorsClicked()
412 // purpose  : Radio button management
413 //=================================================================================
414 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
415 {
416   disconnect(mySelectionMgr, 0, this, 0);
417
418   /*  SALOME_ListIO io;
419   mySelectionMgr->selectedObjects( io );
420   SALOME_ListIO aList;
421   mySelectionMgr->setSelectedObjects( aList );*/
422
423   buttonApply->setEnabled(false);
424   buttonOk->setEnabled(false);
425   mySimulation->SetVisibility(false);
426
427   Selection_Mode aSelMode = ActorSelection;
428
429   switch (constructorId) {
430   case 0:
431     {
432       GroupArguments->setTitle(tr("REVOLUTION_1D"));
433       aSelMode = EdgeSelection;
434       break;
435     }
436   case 1:
437     {
438       GroupArguments->setTitle(tr("REVOLUTION_2D"));
439       aSelMode = FaceSelection;
440       break;
441     }
442   }
443
444   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
445     SMESH::SetPointRepresentation(false);
446   }
447
448   if (!CheckBoxMesh->isChecked())
449     {
450       LineEditElements->clear();
451       myIDs.clear();
452       myNbOkElements = 0;
453       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
454         aViewWindow->SetSelectionMode(aSelMode);
455     }
456
457   myEditCurrentArgument = (QWidget*)LineEditElements;
458   LineEditElements->setFocus();
459
460   if (CheckBoxMesh->isChecked())
461     onSelectMesh(true);
462
463   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
464   //  mySelectionMgr->setSelectedObjects( io );
465 }
466
467 //=================================================================================
468 // function : ClickOnApply()
469 // purpose  :
470 //=================================================================================
471 bool SMESHGUI_RevolutionDlg::ClickOnApply()
472 {
473   if (mySMESHGUI->isActiveStudyLocked())
474     return false;
475
476   if (!isValid())
477     return false;
478
479   if (myNbOkElements && IsAxisOk()) {
480     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
481
482     SMESH::long_array_var anElementsId = new SMESH::long_array;
483
484     anElementsId->length(aListElementsId.count());
485     for (int i = 0; i < aListElementsId.count(); i++)
486       anElementsId[i] = aListElementsId[i].toInt();
487
488     SMESH::AxisStruct anAxis;
489
490     anAxis.x =  SpinBox_X->GetValue();
491     anAxis.y =  SpinBox_Y->GetValue();
492     anAxis.z =  SpinBox_Z->GetValue();;
493     anAxis.vx = SpinBox_DX->GetValue();
494     anAxis.vy = SpinBox_DY->GetValue();
495     anAxis.vz = SpinBox_DZ->GetValue();
496
497     double anAngle = (SpinBox_Angle->GetValue())*PI/180;
498     long aNbSteps = (long)SpinBox_NbSteps->value();
499     double aTolerance = SpinBox_Tolerance->GetValue();
500
501     if ( GroupAngle->checkedId() == 1 )
502       anAngle = anAngle/aNbSteps;
503
504     QStringList aParameters;
505     aParameters << SpinBox_X->text();
506     aParameters << SpinBox_Y->text();
507     aParameters << SpinBox_Z->text();
508     aParameters << SpinBox_DX->text();
509     aParameters << SpinBox_DY->text();
510     aParameters << SpinBox_DZ->text();
511     aParameters << SpinBox_Angle->text();
512     aParameters << SpinBox_NbSteps->text();
513     aParameters << SpinBox_Tolerance->text();
514
515     try {
516       SUIT_OverrideCursor aWaitCursor;
517       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
518       
519       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
520         if( CheckBoxMesh->isChecked() ) {
521           if( GetConstructorId() == 0 )
522             SMESH::ListOfGroups_var groups = 
523               aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
524                                                            anAngle, aNbSteps, aTolerance);
525           else
526             SMESH::ListOfGroups_var groups = 
527               aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
528                                                            anAngle, aNbSteps, aTolerance);
529         }
530         else
531           SMESH::ListOfGroups_var groups = 
532             aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
533                                                  anAngle, aNbSteps, aTolerance);
534       }
535       else {
536         if( CheckBoxMesh->isChecked() ) {
537           if( GetConstructorId() == 0 )
538             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
539           else
540             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
541         }
542         else
543           aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
544       }
545
546       myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
547     } catch (...) {
548     }
549
550     SMESH::UpdateView();
551     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
552       mySMESHGUI->updateObjBrowser(true); // new groups may appear
553     Init(false);
554     ConstructorsClicked(GetConstructorId());
555     mySelectedObject = SMESH::SMESH_IDSource::_nil();
556     SelectionIntoArgument();
557   }
558
559   return true;
560 }
561
562 //=================================================================================
563 // function : ClickOnOk()
564 // purpose  :
565 //=================================================================================
566 void SMESHGUI_RevolutionDlg::ClickOnOk()
567 {
568   if( ClickOnApply() )
569     ClickOnCancel();
570 }
571
572 //=================================================================================
573 // function : ClickOnCancel()
574 // purpose  :
575 //=================================================================================
576 void SMESHGUI_RevolutionDlg::ClickOnCancel()
577 {
578   disconnect(mySelectionMgr, 0, this, 0);
579   mySelectionMgr->clearFilters();
580   //mySelectionMgr->clearSelected();
581   if (SMESH::GetCurrentVtkView()) {
582     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
583     SMESH::SetPointRepresentation(false);
584   }
585   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
586     aViewWindow->SetSelectionMode(ActorSelection);
587   mySMESHGUI->ResetState();
588   reject();
589 }
590
591 //=================================================================================
592 // function : ClickOnHelp()
593 // purpose  :
594 //=================================================================================
595 void SMESHGUI_RevolutionDlg::ClickOnHelp()
596 {
597   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
598   if (app) 
599     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
600   else {
601     QString platform;
602 #ifdef WIN32
603     platform = "winapplication";
604 #else
605     platform = "application";
606 #endif
607     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
608                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
609                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
610                                                                  platform)).
611                              arg(myHelpFileName));
612   }
613 }
614
615 //=======================================================================
616 // function : onAngleTextChange()
617 // purpose  :
618 //=======================================================================
619 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
620 {
621   bool isNumber;
622   SpinBox_Angle->text().toDouble( &isNumber );
623   if( !isNumber )
624     RadioButton3->setChecked( true );
625   RadioButton4->setEnabled( isNumber );
626 }
627
628 //=======================================================================
629 // function : onTextChange()
630 // purpose  :
631 //=======================================================================
632 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
633 {
634   QLineEdit* send = (QLineEdit*)sender();
635
636   if (myBusy) return;
637   myBusy = true;
638
639   if (send == LineEditElements)
640     myNbOkElements = 0;
641
642   buttonOk->setEnabled(false);
643   buttonApply->setEnabled(false);
644
645   // hilight entered elements
646   SMDS_Mesh* aMesh = 0;
647   if (myActor)
648     aMesh = myActor->GetObject()->GetMesh();
649
650   if (aMesh) {
651     if (send == LineEditElements) {
652       Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
653
654       TColStd_MapOfInteger newIndices;
655
656       QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
657       
658       for (int i = 0; i < aListId.count(); i++) {
659         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
660         if (e)
661           newIndices.Add(e->GetID());
662         myNbOkElements++;
663       }
664
665       mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
666       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
667         aViewWindow->highlight( myActor->getIO(), true, true );
668       
669       myElementsId = theNewText;
670     }
671   }
672
673   if (myNbOkElements && IsAxisOk()) {
674     buttonOk->setEnabled(true);
675     buttonApply->setEnabled(true);
676   }
677   onDisplaySimulation(true);
678
679   myBusy = false;
680 }
681
682 //=================================================================================
683 // function : SelectionIntoArgument()
684 // purpose  : Called when selection as changed or other case
685 //=================================================================================
686 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
687 {
688   if (myBusy) return;
689
690   // clear
691   myActor = 0;
692   QString aString = "";
693
694   myBusy = true;
695   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
696     LineEditElements->setText(aString);
697     myNbOkElements = 0;
698     buttonOk->setEnabled(false);
699     buttonApply->setEnabled(false);
700   }
701   myBusy = false;
702
703   if (!GroupButtons->isEnabled()) // inactive
704     return;
705
706   // get selected mesh
707   const SALOME_ListIO& aList = mySelector->StoredIObjects();
708
709   int nbSel = aList.Extent();
710   if (nbSel != 1)
711     return;
712
713   Handle(SALOME_InteractiveObject) IO = aList.First();
714   myMesh = SMESH::GetMeshByIO(IO);
715   if (myMesh->_is_nil())
716     return;
717
718   myActor = SMESH::FindActorByObject(myMesh);
719   if (!myActor)
720     myActor = SMESH::FindActorByEntry(IO->getEntry());
721   if (!myActor)
722     return;
723
724   int aNbUnits = 0;
725
726   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
727     myElementsId = "";
728
729     // MakeGroups is available if there are groups
730     if ( myMesh->NbGroups() == 0 ) {
731       MakeGroupsCheck->setChecked(false);
732       MakeGroupsCheck->setEnabled(false);
733     } else {
734       MakeGroupsCheck->setEnabled(true);
735     }
736
737     if (CheckBoxMesh->isChecked()) {
738       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
739
740       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
741         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
742       else
743         return;
744     } else {
745       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
746       myElementsId = aString;
747       if (aNbUnits < 1)
748         return;
749     }
750     myNbOkElements = true;
751   } else {
752
753     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
754     if (!aMesh)
755       return;
756
757     bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
758                            (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
759                             myVectorDefinition==POINT_SELECT));
760
761     bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX && 
762                            myVectorDefinition==FACE_SELECT);
763
764     if(isNodeSelected) {
765       aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
766     }
767     else if(isFaceSelected){
768       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
769     }
770     
771     if (aNbUnits != 1)
772       return;
773
774     if(isNodeSelected) {
775       const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
776       if (!n)
777         return;
778
779       double x = n->X();
780       double y = n->Y();
781       double z = n->Z();
782
783       if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
784         SpinBox_X->SetValue(x);
785         SpinBox_Y->SetValue(y);
786         SpinBox_Z->SetValue(z);
787       } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
788         SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
789         SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
790         SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
791       }
792     }
793     else if(isFaceSelected){
794       const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
795       if (!face)
796         return;
797       
798       gp_XYZ aNormale = SMESH::getNormale(face);
799       SpinBox_DX->SetValue(aNormale.X());
800       SpinBox_DY->SetValue(aNormale.Y());
801       SpinBox_DZ->SetValue(aNormale.Z());
802       
803     }
804   }
805
806   myBusy = true;
807   if (myEditCurrentArgument == (QWidget*)LineEditElements)
808     LineEditElements->setText(aString);
809   myBusy = false;
810
811   // OK
812   if (myNbOkElements && IsAxisOk()) {
813     buttonOk->setEnabled(true);
814     buttonApply->setEnabled(true);
815   }
816
817   onDisplaySimulation(true);
818 }
819
820 //=================================================================================
821 // function : SetEditCurrentArgument()
822 // purpose  :
823 //=================================================================================
824 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
825 {
826   QPushButton* send = (QPushButton*)sender();
827
828   disconnect(mySelectionMgr, 0, this, 0);
829   mySelectionMgr->clearSelected();
830   mySelectionMgr->clearFilters();
831
832   if (send == SelectElementsButton) {
833     mySimulation->SetVisibility(false);
834     myEditCurrentArgument = (QWidget*)LineEditElements;
835     SMESH::SetPointRepresentation(false);
836     if (CheckBoxMesh->isChecked()) {
837       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
838         aViewWindow->SetSelectionMode(ActorSelection);
839       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
840     } else {
841       int aConstructorId = GetConstructorId();
842       myEditCurrentArgument = (QWidget*)SpinBox_X;
843       if (aConstructorId == 0)
844         {
845           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
846             aViewWindow->SetSelectionMode(EdgeSelection);
847         }
848       else if (aConstructorId == 1)
849         {
850           if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
851             aViewWindow->SetSelectionMode(FaceSelection);
852         }
853     }
854   } else if (send == SelectPointButton) {
855     myEditCurrentArgument = (QWidget*)SpinBox_X;
856     SMESH::SetPointRepresentation(true);
857     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
858       aViewWindow->SetSelectionMode(NodeSelection);
859   }
860
861   myEditCurrentArgument->setFocus();
862   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
863   SelectionIntoArgument();
864 }
865
866 //=================================================================================
867 // function : DeactivateActiveDialog()
868 // purpose  :
869 //=================================================================================
870 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
871 {
872   if (ConstructorsBox->isEnabled()) {
873     ConstructorsBox->setEnabled(false);
874     GroupArguments->setEnabled(false);
875     GroupButtons->setEnabled(false);
876     mySMESHGUI->ResetState();
877     mySMESHGUI->SetActiveDialogBox(0);
878   }
879 }
880
881 //=================================================================================
882 // function : ActivateThisDialog()
883 // purpose  :
884 //=================================================================================
885 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
886 {
887   /* Emit a signal to deactivate the active dialog */
888   mySMESHGUI->EmitSignalDeactivateDialog();
889   ConstructorsBox->setEnabled(true);
890   GroupArguments->setEnabled(true);
891   GroupButtons->setEnabled(true);
892
893   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
894
895   ConstructorsClicked(GetConstructorId());
896   SelectionIntoArgument();
897 }
898
899 //=================================================================================
900 // function : enterEvent()
901 // purpose  :
902 //=================================================================================
903 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
904 {
905   if (!ConstructorsBox->isEnabled())
906     ActivateThisDialog();
907 }
908
909 //=================================================================================
910 // function : closeEvent()
911 // purpose  :
912 //=================================================================================
913 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
914 {
915   /* same than click on cancel button */
916   ClickOnCancel();
917 }
918
919 //=======================================================================
920 // function : hideEvent()
921 // purpose  : caused by ESC key
922 //=======================================================================
923 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
924 {
925   if (!isMinimized())
926     ClickOnCancel();
927 }
928
929 //=======================================================================
930 //function : onSelectMesh
931 //purpose  :
932 //=======================================================================
933 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
934 {
935   if (toSelectMesh) {
936     myIDs = LineEditElements->text();
937     TextLabelElements->setText(tr("SMESH_NAME"));
938   }
939   else
940     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
941   myFilterBtn->setEnabled(!toSelectMesh);
942
943   if (myEditCurrentArgument != LineEditElements) {
944     LineEditElements->clear();
945     mySimulation->SetVisibility(false);
946     return;
947   }
948
949   mySelectionMgr->clearFilters();
950   SMESH::SetPointRepresentation(false);
951
952   if (toSelectMesh) {
953     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
954       aViewWindow->SetSelectionMode(ActorSelection);
955     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
956     LineEditElements->setReadOnly(true);
957     LineEditElements->setValidator(0);
958   } else {
959     int aConstructorId = GetConstructorId();
960     if (aConstructorId == 0)
961       {
962         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
963           aViewWindow->SetSelectionMode(EdgeSelection);
964       }
965     else if (aConstructorId == 1)
966       {
967         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
968           aViewWindow->SetSelectionMode(FaceSelection);
969       }
970
971     LineEditElements->setReadOnly(false);
972     LineEditElements->setValidator(myIdValidator);
973     onTextChange(LineEditElements->text());
974     mySimulation->SetVisibility(false);
975   }
976
977   SelectionIntoArgument();
978
979   if (!toSelectMesh)
980     LineEditElements->setText( myIDs );
981 }
982
983 //=================================================================================
984 // function : GetConstructorId()
985 // purpose  :
986 //=================================================================================
987 int SMESHGUI_RevolutionDlg::GetConstructorId()
988 {
989   return GroupConstructors->checkedId();
990 }
991
992 //=================================================================================
993 // function : IsAxisOk()
994 // purpose  :
995 //=================================================================================
996 bool SMESHGUI_RevolutionDlg::IsAxisOk()
997 {
998   return (SpinBox_DX->GetValue() != 0 ||
999           SpinBox_DY->GetValue() != 0 ||
1000           SpinBox_DZ->GetValue() != 0);
1001 }
1002
1003 //=================================================================================
1004 // function : onVectorChanged()
1005 // purpose  :
1006 //=================================================================================
1007 void SMESHGUI_RevolutionDlg::onVectorChanged()
1008 {
1009   if (IsAxisOk()) {
1010     buttonOk->setEnabled(true);
1011     buttonApply->setEnabled(true);
1012   } else {
1013     buttonOk->setEnabled(false);
1014     buttonApply->setEnabled(false);
1015   }
1016   onDisplaySimulation(true);
1017 }
1018
1019 //=================================================================================
1020 // function : keyPressEvent()
1021 // purpose  :
1022 //=================================================================================
1023 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1024 {
1025   QDialog::keyPressEvent( e );
1026   if ( e->isAccepted() )
1027     return;
1028
1029   if ( e->key() == Qt::Key_F1 ) {
1030     e->accept();
1031     ClickOnHelp();
1032   }
1033 }
1034
1035 //=================================================================================
1036 // function : toDisplaySimulation()
1037 // purpose  :
1038 //=================================================================================
1039 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1040 {
1041   onDisplaySimulation(true);
1042 }
1043
1044 //=================================================================================
1045 // function : onDisplaySimulation()
1046 // purpose  :
1047 //=================================================================================
1048 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1049 {
1050   if (CheckBoxPreview->isChecked() && toDisplayPreview)
1051   {
1052     //display preview
1053     if (myNbOkElements && IsAxisOk())
1054     {
1055       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1056       
1057       SMESH::long_array_var anElementsId = new SMESH::long_array;
1058       
1059       anElementsId->length(aListElementsId.count());
1060       for (int i = 0; i < aListElementsId.count(); i++)
1061         anElementsId[i] = aListElementsId[i].toInt();
1062       
1063       SMESH::AxisStruct anAxis;
1064       
1065       anAxis.x =  SpinBox_X->GetValue();
1066       anAxis.y =  SpinBox_Y->GetValue();
1067       anAxis.z =  SpinBox_Z->GetValue();
1068       anAxis.vx = SpinBox_DX->GetValue();
1069       anAxis.vy = SpinBox_DY->GetValue();
1070       anAxis.vz = SpinBox_DZ->GetValue();
1071       
1072       double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1073       long aNbSteps = (long)SpinBox_NbSteps->value();
1074       double aTolerance = SpinBox_Tolerance->GetValue();
1075       
1076       if (GroupAngle->checkedId() == 1)
1077         anAngle = anAngle/aNbSteps;
1078       
1079       try {
1080         SUIT_OverrideCursor aWaitCursor;
1081         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1082         if( CheckBoxMesh->isChecked() ) {
1083           if( GetConstructorId() == 0 )
1084             aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1085                                                anAngle, aNbSteps, aTolerance);
1086           else
1087             aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1088                                                anAngle, aNbSteps, aTolerance);
1089         }
1090         else
1091           aMeshEditor->RotationSweep(anElementsId.inout(), 
1092                                      anAxis, 
1093                                      anAngle, 
1094                                      aNbSteps, 
1095                                      aTolerance);
1096         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1097         mySimulation->SetData(aMeshPreviewStruct._retn());
1098       } catch (...) {}
1099     }
1100     else
1101     {
1102       mySimulation->SetVisibility(false);
1103     }
1104   }
1105   else
1106   {
1107     //erase preview
1108     mySimulation->SetVisibility(false);
1109   }
1110 }
1111
1112 //=================================================================================
1113 // function : onSelectVectorButton()
1114 // purpose  : [slot]
1115 //=================================================================================
1116 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1117   if(SelectVectorMenu) {
1118     SelectVectorMenu->exec( QCursor::pos() );
1119   }
1120 }
1121
1122 //=================================================================================
1123 // function : onSelectVectorMenu()
1124 // purpose  : [slot]
1125 //=================================================================================
1126 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1127   if(!action)
1128     return;
1129
1130   switch(myMenuActions[action]) {
1131   case POINT_SELECT: 
1132     SMESH::SetPointRepresentation(true);
1133     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1134       aViewWindow->SetSelectionMode(NodeSelection);
1135     break;
1136     
1137   case FACE_SELECT: 
1138     SMESH::SetPointRepresentation(false);
1139     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1140       aViewWindow->SetSelectionMode(FaceSelection);
1141     break;
1142   }
1143
1144   myVectorDefinition = myMenuActions[action];
1145   myEditCurrentArgument = (QWidget*)SpinBox_DX;
1146   myEditCurrentArgument->setFocus();
1147   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1148   SelectionIntoArgument();
1149 }
1150
1151 //=================================================================================
1152 // function : setFilters()
1153 // purpose  : SLOT. Called when "Filter" button pressed.
1154 //=================================================================================
1155 void SMESHGUI_RevolutionDlg::setFilters()
1156 {
1157   if(myMesh->_is_nil()) {
1158     SUIT_MessageBox::critical(this,
1159                               tr("SMESH_ERROR"),
1160                               tr("NO_MESH_SELECTED"));
1161    return;
1162   }
1163   if ( !myFilterDlg )
1164   {
1165     QList<int> types;  
1166     types.append( SMESH::EDGE );
1167     types.append( SMESH::FACE );
1168     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1169   }
1170   myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1171
1172   myFilterDlg->SetSelection();
1173   myFilterDlg->SetMesh( myMesh );
1174   myFilterDlg->SetSourceWg( LineEditElements );
1175
1176   myFilterDlg->show();
1177 }
1178
1179 //=================================================================================
1180 // function : isValid
1181 // purpose  :
1182 //=================================================================================
1183 bool SMESHGUI_RevolutionDlg::isValid()
1184 {
1185   QString msg;
1186   bool ok = true;
1187   ok = SpinBox_X->isValid( msg, true ) && ok;
1188   ok = SpinBox_Y->isValid( msg, true ) && ok;
1189   ok = SpinBox_Z->isValid( msg, true ) && ok;
1190   ok = SpinBox_DX->isValid( msg, true ) && ok;
1191   ok = SpinBox_DY->isValid( msg, true ) && ok;
1192   ok = SpinBox_DZ->isValid( msg, true ) && ok;
1193   ok = SpinBox_Angle->isValid( msg, true ) && ok;
1194   ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1195   ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1196
1197   if( !ok ) {
1198     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1199     if ( !msg.isEmpty() )
1200       str += "\n" + msg;
1201     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1202     return false;
1203   }
1204   return true;
1205 }