1 // Copyright (C) 2007-2008 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 : QDialog( SMESH::GetDesktop( theModule ) ),
92 mySMESHGUI( theModule ),
93 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
94 myVectorDefinition(NONE_SELECT),
96 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 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
148 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
150 // Control for the whole mesh selection
151 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
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);
159 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
160 SelectPointButton = new QPushButton(GroupAxis);
161 SelectPointButton->setIcon(image2);
163 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
164 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
166 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
167 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
169 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
170 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
172 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
173 SelectVectorButton = new QPushButton(GroupAxis);
174 SelectVectorButton->setIcon(image2);
176 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
177 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
179 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
180 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
182 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
183 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
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);
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);
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);
214 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
215 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
217 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
218 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
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);
227 // Controls for tolerance defining
228 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
229 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
231 // Control for mesh preview
232 CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
234 // CheckBox for groups generation
235 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
236 MakeGroupsCheck->setChecked(true);
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);
250 /***************************************************************/
251 GroupButtons = new QGroupBox(this);
252 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
253 GroupButtonsLayout->setSpacing(SPACING);
254 GroupButtonsLayout->setMargin(MARGIN);
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);
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);
274 /***************************************************************/
275 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
276 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
277 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
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);
287 RadioButton3->setChecked(true);
289 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
291 SpinBox_NbSteps->setRange(1, 999999);
293 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
295 RadioButton1->setChecked(true);
297 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
299 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
301 // Costruction of the logical filter
302 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
303 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
305 QList<SUIT_SelectionFilter*> aListOfFilters;
306 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
307 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
309 myMeshOrSubMeshOrGroupFilter =
310 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
312 myHelpFileName = "revolution_page.html";
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* ) ) );
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)));
329 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
330 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
331 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
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()));
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()));
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)));
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)));
354 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
356 ConstructorsClicked(0);
357 SelectionIntoArgument();
360 //=================================================================================
361 // function : ~SMESHGUI_RevolutionDlg()
362 // purpose : Destroys the object and frees any allocated resources
363 //=================================================================================
364 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
368 myFilterDlg->setParent( 0 );
374 //=================================================================================
377 //=================================================================================
378 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
382 myEditCurrentArgument = 0;
383 LineEditElements->clear();
388 myMesh = SMESH::SMESH_Mesh::_nil();
391 SpinBox_X->SetValue(0.0);
392 SpinBox_Y->SetValue(0.0);
393 SpinBox_Z->SetValue(0.0);
394 SpinBox_DX->SetValue(0.0);
395 SpinBox_DY->SetValue(0.0);
396 SpinBox_DZ->SetValue(0.0);
398 SpinBox_Angle->SetValue(45);
399 SpinBox_NbSteps->setValue(1);
400 SpinBox_Tolerance->SetValue(1e-05);
402 CheckBoxMesh->setChecked(false);
404 CheckBoxPreview->setChecked(false);
405 onDisplaySimulation(false);
409 //=================================================================================
410 // function : ConstructorsClicked()
411 // purpose : Radio button management
412 //=================================================================================
413 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
415 //disconnect(mySelectionMgr, 0, this, 0);
418 mySelectionMgr->selectedObjects( io );
420 mySelectionMgr->setSelectedObjects( aList );
421 // LineEditElements->clear();
423 buttonApply->setEnabled(false);
424 buttonOk->setEnabled(false);
425 mySimulation->SetVisibility(false);
427 Selection_Mode aSelMode = ActorSelection;
429 switch (constructorId) {
432 GroupArguments->setTitle(tr("REVOLUTION_1D"));
433 aSelMode = EdgeSelection;
438 GroupArguments->setTitle(tr("REVOLUTION_2D"));
439 aSelMode = FaceSelection;
444 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
445 SMESH::SetPointRepresentation(false);
448 if (!CheckBoxMesh->isChecked())
450 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
451 aViewWindow->SetSelectionMode(aSelMode);
454 myEditCurrentArgument = (QWidget*)LineEditElements;
455 LineEditElements->setFocus();
457 if (CheckBoxMesh->isChecked())
460 //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
461 mySelectionMgr->setSelectedObjects( io );
464 //=================================================================================
465 // function : ClickOnApply()
467 //=================================================================================
468 bool SMESHGUI_RevolutionDlg::ClickOnApply()
470 if (mySMESHGUI->isActiveStudyLocked())
476 if (myNbOkElements && IsAxisOk()) {
477 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
479 SMESH::long_array_var anElementsId = new SMESH::long_array;
481 anElementsId->length(aListElementsId.count());
482 for (int i = 0; i < aListElementsId.count(); i++)
483 anElementsId[i] = aListElementsId[i].toInt();
485 SMESH::AxisStruct anAxis;
487 anAxis.x = SpinBox_X->GetValue();
488 anAxis.y = SpinBox_Y->GetValue();
489 anAxis.z = SpinBox_Z->GetValue();;
490 anAxis.vx = SpinBox_DX->GetValue();
491 anAxis.vy = SpinBox_DY->GetValue();
492 anAxis.vz = SpinBox_DZ->GetValue();
494 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
495 long aNbSteps = (long)SpinBox_NbSteps->value();
496 double aTolerance = SpinBox_Tolerance->GetValue();
498 if ( GroupAngle->checkedId() == 1 )
499 anAngle = anAngle/aNbSteps;
501 QStringList aParameters;
502 aParameters << SpinBox_X->text();
503 aParameters << SpinBox_Y->text();
504 aParameters << SpinBox_Z->text();
505 aParameters << SpinBox_DX->text();
506 aParameters << SpinBox_DY->text();
507 aParameters << SpinBox_DZ->text();
508 aParameters << SpinBox_Angle->text();
509 aParameters << SpinBox_NbSteps->text();
510 aParameters << SpinBox_Tolerance->text();
513 SUIT_OverrideCursor aWaitCursor;
514 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
516 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
517 if( CheckBoxMesh->isChecked() ) {
518 if( GetConstructorId() == 0 )
519 SMESH::ListOfGroups_var groups =
520 aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
521 anAngle, aNbSteps, aTolerance);
523 SMESH::ListOfGroups_var groups =
524 aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
525 anAngle, aNbSteps, aTolerance);
528 SMESH::ListOfGroups_var groups =
529 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
530 anAngle, aNbSteps, aTolerance);
533 if( CheckBoxMesh->isChecked() ) {
534 if( GetConstructorId() == 0 )
535 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
537 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
540 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
543 myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
548 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
549 mySMESHGUI->updateObjBrowser(true); // new groups may appear
551 ConstructorsClicked(GetConstructorId());
552 mySelectedObject = SMESH::SMESH_IDSource::_nil();
553 SelectionIntoArgument();
559 //=================================================================================
560 // function : ClickOnOk()
562 //=================================================================================
563 void SMESHGUI_RevolutionDlg::ClickOnOk()
569 //=================================================================================
570 // function : ClickOnCancel()
572 //=================================================================================
573 void SMESHGUI_RevolutionDlg::ClickOnCancel()
575 disconnect(mySelectionMgr, 0, this, 0);
576 mySelectionMgr->clearFilters();
577 //mySelectionMgr->clearSelected();
578 if (SMESH::GetCurrentVtkView()) {
579 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
580 SMESH::SetPointRepresentation(false);
582 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
583 aViewWindow->SetSelectionMode(ActorSelection);
584 mySMESHGUI->ResetState();
588 //=================================================================================
589 // function : ClickOnHelp()
591 //=================================================================================
592 void SMESHGUI_RevolutionDlg::ClickOnHelp()
594 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
596 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
600 platform = "winapplication";
602 platform = "application";
604 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
605 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
606 arg(app->resourceMgr()->stringValue("ExternalBrowser",
608 arg(myHelpFileName));
612 //=======================================================================
613 // function : onAngleTextChange()
615 //=======================================================================
616 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
619 SpinBox_Angle->text().toDouble( &isNumber );
621 RadioButton3->setChecked( true );
622 RadioButton4->setEnabled( isNumber );
625 //=======================================================================
626 // function : onTextChange()
628 //=======================================================================
629 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
631 QLineEdit* send = (QLineEdit*)sender();
636 if (send == LineEditElements)
639 buttonOk->setEnabled(false);
640 buttonApply->setEnabled(false);
642 // hilight entered elements
643 SMDS_Mesh* aMesh = 0;
645 aMesh = myActor->GetObject()->GetMesh();
648 if (send == LineEditElements) {
649 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
651 TColStd_MapOfInteger newIndices;
653 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
655 for (int i = 0; i < aListId.count(); i++) {
656 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
658 newIndices.Add(e->GetID());
662 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
663 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
664 aViewWindow->highlight( myActor->getIO(), true, true );
666 myElementsId = theNewText;
670 if (myNbOkElements && IsAxisOk()) {
671 buttonOk->setEnabled(true);
672 buttonApply->setEnabled(true);
674 onDisplaySimulation(true);
679 //=================================================================================
680 // function : SelectionIntoArgument()
681 // purpose : Called when selection as changed or other case
682 //=================================================================================
683 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
689 QString aString = "";
692 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
693 LineEditElements->setText(aString);
695 buttonOk->setEnabled(false);
696 buttonApply->setEnabled(false);
700 if (!GroupButtons->isEnabled()) // inactive
704 const SALOME_ListIO& aList = mySelector->StoredIObjects();
706 int nbSel = aList.Extent();
710 Handle(SALOME_InteractiveObject) IO = aList.First();
711 myMesh = SMESH::GetMeshByIO(IO);
712 if (myMesh->_is_nil())
715 myActor = SMESH::FindActorByObject(myMesh);
717 myActor = SMESH::FindActorByEntry(IO->getEntry());
723 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
726 // MakeGroups is available if there are groups
727 if ( myMesh->NbGroups() == 0 ) {
728 MakeGroupsCheck->setChecked(false);
729 MakeGroupsCheck->setEnabled(false);
731 MakeGroupsCheck->setEnabled(true);
734 if (CheckBoxMesh->isChecked()) {
735 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
737 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
738 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
742 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
743 myElementsId = aString;
747 myNbOkElements = true;
750 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
754 bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
755 (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
756 myVectorDefinition==POINT_SELECT));
758 bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
759 myVectorDefinition==FACE_SELECT);
762 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
764 else if(isFaceSelected){
765 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
772 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
780 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
781 SpinBox_X->SetValue(x);
782 SpinBox_Y->SetValue(y);
783 SpinBox_Z->SetValue(z);
784 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
785 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
786 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
787 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
790 else if(isFaceSelected){
791 const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
795 gp_XYZ aNormale = SMESH::getNormale(face);
796 SpinBox_DX->SetValue(aNormale.X());
797 SpinBox_DY->SetValue(aNormale.Y());
798 SpinBox_DZ->SetValue(aNormale.Z());
804 if (myEditCurrentArgument == (QWidget*)LineEditElements)
805 LineEditElements->setText(aString);
809 if (myNbOkElements && IsAxisOk()) {
810 buttonOk->setEnabled(true);
811 buttonApply->setEnabled(true);
814 onDisplaySimulation(true);
817 //=================================================================================
818 // function : SetEditCurrentArgument()
820 //=================================================================================
821 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
823 QPushButton* send = (QPushButton*)sender();
825 disconnect(mySelectionMgr, 0, this, 0);
826 mySelectionMgr->clearSelected();
827 mySelectionMgr->clearFilters();
829 if (send == SelectElementsButton) {
830 mySimulation->SetVisibility(false);
831 myEditCurrentArgument = (QWidget*)LineEditElements;
832 SMESH::SetPointRepresentation(false);
833 if (CheckBoxMesh->isChecked()) {
834 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
835 aViewWindow->SetSelectionMode(ActorSelection);
836 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
838 int aConstructorId = GetConstructorId();
839 if (aConstructorId == 0)
841 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
842 aViewWindow->SetSelectionMode(EdgeSelection);
844 else if (aConstructorId == 1)
846 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
847 aViewWindow->SetSelectionMode(FaceSelection);
850 } else if (send == SelectPointButton) {
851 myEditCurrentArgument = (QWidget*)SpinBox_X;
852 SMESH::SetPointRepresentation(true);
853 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
854 aViewWindow->SetSelectionMode(NodeSelection);
857 myEditCurrentArgument->setFocus();
858 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
859 SelectionIntoArgument();
862 //=================================================================================
863 // function : DeactivateActiveDialog()
865 //=================================================================================
866 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
868 if (ConstructorsBox->isEnabled()) {
869 ConstructorsBox->setEnabled(false);
870 GroupArguments->setEnabled(false);
871 GroupButtons->setEnabled(false);
872 mySMESHGUI->ResetState();
873 mySMESHGUI->SetActiveDialogBox(0);
877 //=================================================================================
878 // function : ActivateThisDialog()
880 //=================================================================================
881 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
883 /* Emit a signal to deactivate the active dialog */
884 mySMESHGUI->EmitSignalDeactivateDialog();
885 ConstructorsBox->setEnabled(true);
886 GroupArguments->setEnabled(true);
887 GroupButtons->setEnabled(true);
889 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
891 ConstructorsClicked(GetConstructorId());
892 SelectionIntoArgument();
895 //=================================================================================
896 // function : enterEvent()
898 //=================================================================================
899 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
901 if (!ConstructorsBox->isEnabled())
902 ActivateThisDialog();
905 //=================================================================================
906 // function : closeEvent()
908 //=================================================================================
909 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
911 /* same than click on cancel button */
915 //=======================================================================
916 // function : hideEvent()
917 // purpose : caused by ESC key
918 //=======================================================================
919 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
925 //=======================================================================
926 //function : onSelectMesh
928 //=======================================================================
929 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
932 TextLabelElements->setText(tr("SMESH_NAME"));
934 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
935 myFilterBtn->setEnabled(!toSelectMesh);
937 if (myEditCurrentArgument != LineEditElements) {
938 LineEditElements->clear();
939 mySimulation->SetVisibility(false);
943 mySelectionMgr->clearFilters();
944 SMESH::SetPointRepresentation(false);
947 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
948 aViewWindow->SetSelectionMode(ActorSelection);
949 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
950 LineEditElements->setReadOnly(true);
951 LineEditElements->setValidator(0);
953 int aConstructorId = GetConstructorId();
954 if (aConstructorId == 0)
956 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
957 aViewWindow->SetSelectionMode(EdgeSelection);
959 else if (aConstructorId == 0)
961 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
962 aViewWindow->SetSelectionMode(FaceSelection);
965 LineEditElements->setReadOnly(false);
966 LineEditElements->setValidator(myIdValidator);
967 onTextChange(LineEditElements->text());
968 mySimulation->SetVisibility(false);
971 SelectionIntoArgument();
974 //=================================================================================
975 // function : GetConstructorId()
977 //=================================================================================
978 int SMESHGUI_RevolutionDlg::GetConstructorId()
980 return GroupConstructors->checkedId();
983 //=================================================================================
984 // function : IsAxisOk()
986 //=================================================================================
987 bool SMESHGUI_RevolutionDlg::IsAxisOk()
989 return (SpinBox_DX->GetValue() != 0 ||
990 SpinBox_DY->GetValue() != 0 ||
991 SpinBox_DZ->GetValue() != 0);
994 //=================================================================================
995 // function : onVectorChanged()
997 //=================================================================================
998 void SMESHGUI_RevolutionDlg::onVectorChanged()
1001 buttonOk->setEnabled(true);
1002 buttonApply->setEnabled(true);
1004 buttonOk->setEnabled(false);
1005 buttonApply->setEnabled(false);
1007 onDisplaySimulation(true);
1010 //=================================================================================
1011 // function : keyPressEvent()
1013 //=================================================================================
1014 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1016 QDialog::keyPressEvent( e );
1017 if ( e->isAccepted() )
1020 if ( e->key() == Qt::Key_F1 ) {
1026 //=================================================================================
1027 // function : toDisplaySimulation()
1029 //=================================================================================
1030 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1032 onDisplaySimulation(true);
1035 //=================================================================================
1036 // function : onDisplaySimulation()
1038 //=================================================================================
1039 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1041 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1044 if (myNbOkElements && IsAxisOk())
1046 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1048 SMESH::long_array_var anElementsId = new SMESH::long_array;
1050 anElementsId->length(aListElementsId.count());
1051 for (int i = 0; i < aListElementsId.count(); i++)
1052 anElementsId[i] = aListElementsId[i].toInt();
1054 SMESH::AxisStruct anAxis;
1056 anAxis.x = SpinBox_X->GetValue();
1057 anAxis.y = SpinBox_Y->GetValue();
1058 anAxis.z = SpinBox_Z->GetValue();
1059 anAxis.vx = SpinBox_DX->GetValue();
1060 anAxis.vy = SpinBox_DY->GetValue();
1061 anAxis.vz = SpinBox_DZ->GetValue();
1063 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1064 long aNbSteps = (long)SpinBox_NbSteps->value();
1065 double aTolerance = SpinBox_Tolerance->GetValue();
1067 if (GroupAngle->checkedId() == 1)
1068 anAngle = anAngle/aNbSteps;
1071 SUIT_OverrideCursor aWaitCursor;
1072 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1073 if( CheckBoxMesh->isChecked() ) {
1074 if( GetConstructorId() == 0 )
1075 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1076 anAngle, aNbSteps, aTolerance);
1078 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1079 anAngle, aNbSteps, aTolerance);
1082 aMeshEditor->RotationSweep(anElementsId.inout(),
1087 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1088 mySimulation->SetData(aMeshPreviewStruct._retn());
1093 mySimulation->SetVisibility(false);
1099 mySimulation->SetVisibility(false);
1103 //=================================================================================
1104 // function : onSelectVectorButton()
1106 //=================================================================================
1107 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1108 if(SelectVectorMenu) {
1109 SelectVectorMenu->exec( QCursor::pos() );
1113 //=================================================================================
1114 // function : onSelectVectorMenu()
1116 //=================================================================================
1117 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1121 switch(myMenuActions[action]) {
1123 SMESH::SetPointRepresentation(true);
1124 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1125 aViewWindow->SetSelectionMode(NodeSelection);
1129 SMESH::SetPointRepresentation(false);
1130 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1131 aViewWindow->SetSelectionMode(FaceSelection);
1135 myVectorDefinition = myMenuActions[action];
1136 myEditCurrentArgument = (QWidget*)SpinBox_DX;
1137 myEditCurrentArgument->setFocus();
1138 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1139 SelectionIntoArgument();
1142 //=================================================================================
1143 // function : setFilters()
1144 // purpose : SLOT. Called when "Filter" button pressed.
1145 //=================================================================================
1146 void SMESHGUI_RevolutionDlg::setFilters()
1148 if(myMesh->_is_nil()) {
1149 SUIT_MessageBox::critical(this,
1151 tr("NO_MESH_SELECTED"));
1157 types.append( SMESH::EDGE );
1158 types.append( SMESH::FACE );
1159 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1161 myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1163 myFilterDlg->SetSelection();
1164 myFilterDlg->SetMesh( myMesh );
1165 myFilterDlg->SetSourceWg( LineEditElements );
1167 myFilterDlg->show();
1170 //=================================================================================
1171 // function : isValid
1173 //=================================================================================
1174 bool SMESHGUI_RevolutionDlg::isValid()
1178 ok = SpinBox_X->isValid( msg, true ) && ok;
1179 ok = SpinBox_Y->isValid( msg, true ) && ok;
1180 ok = SpinBox_Z->isValid( msg, true ) && ok;
1181 ok = SpinBox_DX->isValid( msg, true ) && ok;
1182 ok = SpinBox_DY->isValid( msg, true ) && ok;
1183 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1184 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1185 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1186 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1189 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1190 if ( !msg.isEmpty() )
1192 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );