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 SMESHGUI_Helper( theModule ),
93 mySMESHGUI( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
95 myVectorDefinition(NONE_SELECT),
97 mySelectedObject(SMESH::SMESH_IDSource::_nil()),
100 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
102 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
103 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
104 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
105 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
108 setAttribute(Qt::WA_DeleteOnClose, true);
109 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
110 setSizeGripEnabled(true);
112 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
113 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
114 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
116 /***************************************************************/
117 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
118 GroupConstructors = new QButtonGroup(this);
119 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
120 ConstructorsBoxLayout->setSpacing(SPACING);
121 ConstructorsBoxLayout->setMargin(MARGIN);
123 RadioButton1 = new QRadioButton(ConstructorsBox);
124 RadioButton1->setIcon(image0);
125 RadioButton2 = new QRadioButton(ConstructorsBox);
126 RadioButton2->setIcon(image1);
128 ConstructorsBoxLayout->addWidget(RadioButton1);
129 ConstructorsBoxLayout->addWidget(RadioButton2);
130 GroupConstructors->addButton(RadioButton1, 0);
131 GroupConstructors->addButton(RadioButton2, 1);
133 /***************************************************************/
134 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
135 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
136 GroupArgumentsLayout->setSpacing(SPACING);
137 GroupArgumentsLayout->setMargin(MARGIN);
139 myIdValidator = new SMESHGUI_IdValidator(this);
141 // Controls for elements selection
142 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
144 SelectElementsButton = new QPushButton(GroupArguments);
145 SelectElementsButton->setIcon(image2);
147 LineEditElements = new QLineEdit(GroupArguments);
148 LineEditElements->setValidator(myIdValidator);
149 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
150 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
152 // Control for the whole mesh selection
153 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
155 // Controls for axis defining
156 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
157 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
158 GroupAxisLayout->setSpacing(SPACING);
159 GroupAxisLayout->setMargin(MARGIN);
161 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
162 SelectPointButton = new QPushButton(GroupAxis);
163 SelectPointButton->setIcon(image2);
165 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
166 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
168 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
169 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
171 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
172 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
174 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
175 SelectVectorButton = new QPushButton(GroupAxis);
176 SelectVectorButton->setIcon(image2);
178 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
179 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
181 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
182 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
184 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
185 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
187 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
188 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
189 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
190 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
191 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
192 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
193 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
194 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
195 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
196 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
197 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
198 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
199 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
200 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
201 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
202 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
204 // Controls for angle defining & number of steps defining
205 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
206 GroupAngle = new QButtonGroup(GroupAngleBox);
207 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
208 GroupAngleLayout->setSpacing(6);
209 GroupAngleLayout->setMargin(11);
211 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
212 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
213 GroupAngle->addButton(RadioButton3, 0);
214 GroupAngle->addButton(RadioButton4, 1);
216 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
217 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
219 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
220 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
222 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
223 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
224 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
225 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
226 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
227 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
229 // Controls for tolerance defining
230 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
231 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
233 // Control for mesh preview
234 CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
236 // CheckBox for groups generation
237 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
238 MakeGroupsCheck->setChecked(true);
240 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
241 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
242 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
243 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
244 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
245 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
246 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 4);
247 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
248 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2, 1, 2);
249 GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 4);
250 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
252 /***************************************************************/
253 GroupButtons = new QGroupBox(this);
254 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
255 GroupButtonsLayout->setSpacing(SPACING);
256 GroupButtonsLayout->setMargin(MARGIN);
258 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
259 buttonOk->setAutoDefault(true);
260 buttonOk->setDefault(true);
261 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
262 buttonApply->setAutoDefault(true);
263 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
264 buttonCancel->setAutoDefault(true);
265 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
266 buttonHelp->setAutoDefault(true);
268 GroupButtonsLayout->addWidget(buttonOk);
269 GroupButtonsLayout->addSpacing(10);
270 GroupButtonsLayout->addWidget(buttonApply);
271 GroupButtonsLayout->addSpacing(10);
272 GroupButtonsLayout->addStretch();
273 GroupButtonsLayout->addWidget(buttonCancel);
274 GroupButtonsLayout->addWidget(buttonHelp);
276 /***************************************************************/
277 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
278 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
279 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
281 /* Initialisations */
282 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
283 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
284 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
286 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
287 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
289 RadioButton3->setChecked(true);
291 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
293 SpinBox_NbSteps->setRange(1, 999999);
295 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
297 RadioButton1->setChecked(true);
299 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
301 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
303 // Costruction of the logical filter
304 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
305 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
307 QList<SUIT_SelectionFilter*> aListOfFilters;
308 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
309 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
311 myMeshOrSubMeshOrGroupFilter =
312 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
314 myHelpFileName = "revolution_page.html";
318 /*Create menu to vector selection*/
319 SelectVectorMenu = new QMenu(this);
320 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
321 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
322 connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
324 /* signals and slots connections */
325 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
326 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
327 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
328 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
329 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
331 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
332 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
333 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
335 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
337 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
339 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
340 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
341 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
343 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
344 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
345 /* to close dialog if study change */
346 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
347 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
348 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
350 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
351 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
352 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
353 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
354 connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
356 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
358 ConstructorsClicked(0);
359 SelectionIntoArgument();
362 //=================================================================================
363 // function : ~SMESHGUI_RevolutionDlg()
364 // purpose : Destroys the object and frees any allocated resources
365 //=================================================================================
366 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
370 myFilterDlg->setParent( 0 );
376 //=================================================================================
379 //=================================================================================
380 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
384 myEditCurrentArgument = 0;
385 LineEditElements->clear();
391 myMesh = SMESH::SMESH_Mesh::_nil();
394 SpinBox_X->SetValue(0.0);
395 SpinBox_Y->SetValue(0.0);
396 SpinBox_Z->SetValue(0.0);
397 SpinBox_DX->SetValue(0.0);
398 SpinBox_DY->SetValue(0.0);
399 SpinBox_DZ->SetValue(0.0);
401 SpinBox_Angle->SetValue(45);
402 SpinBox_NbSteps->setValue(1);
403 SpinBox_Tolerance->SetValue(1e-05);
405 CheckBoxMesh->setChecked(false);
407 CheckBoxPreview->setChecked(false);
408 onDisplaySimulation(false);
412 //=================================================================================
413 // function : ConstructorsClicked()
414 // purpose : Radio button management
415 //=================================================================================
416 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
418 disconnect(mySelectionMgr, 0, this, 0);
421 mySelectionMgr->selectedObjects( io );
423 mySelectionMgr->setSelectedObjects( aList );*/
425 buttonApply->setEnabled(false);
426 buttonOk->setEnabled(false);
427 mySimulation->SetVisibility(false);
429 Selection_Mode aSelMode = ActorSelection;
431 switch (constructorId) {
434 GroupArguments->setTitle(tr("REVOLUTION_1D"));
435 aSelMode = EdgeSelection;
440 GroupArguments->setTitle(tr("REVOLUTION_2D"));
441 aSelMode = FaceSelection;
446 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
447 SMESH::SetPointRepresentation(false);
450 if (!CheckBoxMesh->isChecked())
452 LineEditElements->clear();
455 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
456 aViewWindow->SetSelectionMode(aSelMode);
459 myEditCurrentArgument = (QWidget*)LineEditElements;
460 LineEditElements->setFocus();
462 if (CheckBoxMesh->isChecked())
465 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
466 // mySelectionMgr->setSelectedObjects( io );
469 //=================================================================================
470 // function : ClickOnApply()
472 //=================================================================================
473 bool SMESHGUI_RevolutionDlg::ClickOnApply()
475 if (mySMESHGUI->isActiveStudyLocked())
481 if (myNbOkElements && IsAxisOk()) {
482 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
484 SMESH::long_array_var anElementsId = new SMESH::long_array;
486 anElementsId->length(aListElementsId.count());
487 for (int i = 0; i < aListElementsId.count(); i++)
488 anElementsId[i] = aListElementsId[i].toInt();
490 SMESH::AxisStruct anAxis;
492 anAxis.x = SpinBox_X->GetValue();
493 anAxis.y = SpinBox_Y->GetValue();
494 anAxis.z = SpinBox_Z->GetValue();;
495 anAxis.vx = SpinBox_DX->GetValue();
496 anAxis.vy = SpinBox_DY->GetValue();
497 anAxis.vz = SpinBox_DZ->GetValue();
499 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
500 long aNbSteps = (long)SpinBox_NbSteps->value();
501 double aTolerance = SpinBox_Tolerance->GetValue();
503 if ( GroupAngle->checkedId() == 1 )
504 anAngle = anAngle/aNbSteps;
506 QStringList aParameters;
507 aParameters << SpinBox_X->text();
508 aParameters << SpinBox_Y->text();
509 aParameters << SpinBox_Z->text();
510 aParameters << SpinBox_DX->text();
511 aParameters << SpinBox_DY->text();
512 aParameters << SpinBox_DZ->text();
513 aParameters << SpinBox_Angle->text();
514 aParameters << SpinBox_NbSteps->text();
515 aParameters << SpinBox_Tolerance->text();
518 SUIT_OverrideCursor aWaitCursor;
519 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
521 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
522 if( CheckBoxMesh->isChecked() ) {
523 if( GetConstructorId() == 0 )
524 SMESH::ListOfGroups_var groups =
525 aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
526 anAngle, aNbSteps, aTolerance);
528 SMESH::ListOfGroups_var groups =
529 aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
530 anAngle, aNbSteps, aTolerance);
533 SMESH::ListOfGroups_var groups =
534 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
535 anAngle, aNbSteps, aTolerance);
538 if( CheckBoxMesh->isChecked() ) {
539 if( GetConstructorId() == 0 )
540 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
542 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
545 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
548 //asl: myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
553 SMESH::Update(myIO, SMESH::eDisplay);
554 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
555 mySMESHGUI->updateObjBrowser(true); // new groups may appear
557 ConstructorsClicked(GetConstructorId());
558 mySelectedObject = SMESH::SMESH_IDSource::_nil();
559 SelectionIntoArgument();
565 //=================================================================================
566 // function : ClickOnOk()
568 //=================================================================================
569 void SMESHGUI_RevolutionDlg::ClickOnOk()
575 //=================================================================================
576 // function : ClickOnCancel()
578 //=================================================================================
579 void SMESHGUI_RevolutionDlg::ClickOnCancel()
584 void SMESHGUI_RevolutionDlg::reject()
589 //=================================================================================
590 // function : ClickOnHelp()
592 //=================================================================================
593 void SMESHGUI_RevolutionDlg::ClickOnHelp()
595 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
597 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
601 platform = "winapplication";
603 platform = "application";
605 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
606 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
607 arg(app->resourceMgr()->stringValue("ExternalBrowser",
609 arg(myHelpFileName));
613 //=======================================================================
614 // function : onAngleTextChange()
616 //=======================================================================
617 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
620 SpinBox_Angle->text().toDouble( &isNumber );
622 RadioButton3->setChecked( true );
623 RadioButton4->setEnabled( isNumber );
626 //=======================================================================
627 // function : onTextChange()
629 //=======================================================================
630 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
632 QLineEdit* send = (QLineEdit*)sender();
637 if (send == LineEditElements)
640 buttonOk->setEnabled(false);
641 buttonApply->setEnabled(false);
643 // hilight entered elements
644 SMDS_Mesh* aMesh = 0;
646 aMesh = myActor->GetObject()->GetMesh();
649 if (send == LineEditElements) {
650 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
652 TColStd_MapOfInteger newIndices;
654 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
656 for (int i = 0; i < aListId.count(); i++) {
657 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
659 newIndices.Add(e->GetID());
663 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
664 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
665 aViewWindow->highlight( myActor->getIO(), true, true );
667 myElementsId = theNewText;
671 if (myNbOkElements && IsAxisOk()) {
672 buttonOk->setEnabled(true);
673 buttonApply->setEnabled(true);
675 onDisplaySimulation(true);
680 //=================================================================================
681 // function : SelectionIntoArgument()
682 // purpose : Called when selection as changed or other case
683 //=================================================================================
684 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 SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
712 if (aMeshVar->_is_nil())
715 SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
717 anActor = SMESH::FindActorByEntry(IO->getEntry());
723 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
729 // MakeGroups is available if there are groups
730 if ( myMesh->NbGroups() == 0 ) {
731 MakeGroupsCheck->setChecked(false);
732 MakeGroupsCheck->setEnabled(false);
734 MakeGroupsCheck->setEnabled(true);
737 if (CheckBoxMesh->isChecked()) {
738 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
740 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
741 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
745 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
746 myElementsId = aString;
750 myNbOkElements = true;
753 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
757 bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
758 (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
759 myVectorDefinition==POINT_SELECT));
761 bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
762 myVectorDefinition==FACE_SELECT);
765 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
767 else if(isFaceSelected){
768 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
775 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
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());
793 else if(isFaceSelected){
794 const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
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());
807 if (myEditCurrentArgument == (QWidget*)LineEditElements)
808 LineEditElements->setText(aString);
812 if (myNbOkElements && IsAxisOk()) {
813 buttonOk->setEnabled(true);
814 buttonApply->setEnabled(true);
817 onDisplaySimulation(true);
820 //=================================================================================
821 // function : SetEditCurrentArgument()
823 //=================================================================================
824 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
826 QPushButton* send = (QPushButton*)sender();
828 disconnect(mySelectionMgr, 0, this, 0);
829 mySelectionMgr->clearSelected();
830 mySelectionMgr->clearFilters();
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);
841 int aConstructorId = GetConstructorId();
842 if (aConstructorId == 0)
844 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
845 aViewWindow->SetSelectionMode(EdgeSelection);
847 else if (aConstructorId == 1)
849 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
850 aViewWindow->SetSelectionMode(FaceSelection);
853 } else if (send == SelectPointButton) {
854 myEditCurrentArgument = (QWidget*)SpinBox_X;
855 SMESH::SetPointRepresentation(true);
856 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
857 aViewWindow->SetSelectionMode(NodeSelection);
860 myEditCurrentArgument->setFocus();
861 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
862 SelectionIntoArgument();
865 //=================================================================================
866 // function : DeactivateActiveDialog()
868 //=================================================================================
869 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
871 if (ConstructorsBox->isEnabled()) {
872 ConstructorsBox->setEnabled(false);
873 GroupArguments->setEnabled(false);
874 GroupButtons->setEnabled(false);
875 mySMESHGUI->ResetState();
876 mySMESHGUI->SetActiveDialogBox(0);
880 //=================================================================================
881 // function : ActivateThisDialog()
883 //=================================================================================
884 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
886 /* Emit a signal to deactivate the active dialog */
887 mySMESHGUI->EmitSignalDeactivateDialog();
888 ConstructorsBox->setEnabled(true);
889 GroupArguments->setEnabled(true);
890 GroupButtons->setEnabled(true);
892 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
894 ConstructorsClicked(GetConstructorId());
895 SelectionIntoArgument();
898 //=================================================================================
899 // function : enterEvent()
901 //=================================================================================
902 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
904 if (!ConstructorsBox->isEnabled())
905 ActivateThisDialog();
908 //=================================================================================
909 // function : closeEvent()
911 //=================================================================================
912 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
914 /* same than click on cancel button */
915 disconnect(mySelectionMgr, 0, this, 0);
916 mySelectionMgr->clearFilters();
917 //mySelectionMgr->clearSelected();
918 if (SMESH::GetCurrentVtkView()) {
919 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
920 SMESH::SetPointRepresentation(false);
922 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
923 aViewWindow->SetSelectionMode(ActorSelection);
924 mySMESHGUI->ResetState();
927 //=======================================================================
928 //function : onSelectMesh
930 //=======================================================================
931 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
934 myIDs = LineEditElements->text();
935 TextLabelElements->setText(tr("SMESH_NAME"));
938 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
939 myFilterBtn->setEnabled(!toSelectMesh);
941 if (myEditCurrentArgument != LineEditElements) {
942 LineEditElements->clear();
943 mySimulation->SetVisibility(false);
947 mySelectionMgr->clearFilters();
948 SMESH::SetPointRepresentation(false);
951 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
952 aViewWindow->SetSelectionMode(ActorSelection);
953 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
954 LineEditElements->setReadOnly(true);
955 LineEditElements->setValidator(0);
957 int aConstructorId = GetConstructorId();
958 if (aConstructorId == 0)
960 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
961 aViewWindow->SetSelectionMode(EdgeSelection);
963 else if (aConstructorId == 1)
965 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
966 aViewWindow->SetSelectionMode(FaceSelection);
969 LineEditElements->setReadOnly(false);
970 LineEditElements->setValidator(myIdValidator);
971 onTextChange(LineEditElements->text());
972 mySimulation->SetVisibility(false);
975 SelectionIntoArgument();
978 LineEditElements->setText( myIDs );
981 //=================================================================================
982 // function : GetConstructorId()
984 //=================================================================================
985 int SMESHGUI_RevolutionDlg::GetConstructorId()
987 return GroupConstructors->checkedId();
990 //=================================================================================
991 // function : IsAxisOk()
993 //=================================================================================
994 bool SMESHGUI_RevolutionDlg::IsAxisOk()
996 return (SpinBox_DX->GetValue() != 0 ||
997 SpinBox_DY->GetValue() != 0 ||
998 SpinBox_DZ->GetValue() != 0);
1001 //=================================================================================
1002 // function : onVectorChanged()
1004 //=================================================================================
1005 void SMESHGUI_RevolutionDlg::onVectorChanged()
1008 buttonOk->setEnabled(true);
1009 buttonApply->setEnabled(true);
1011 buttonOk->setEnabled(false);
1012 buttonApply->setEnabled(false);
1014 onDisplaySimulation(true);
1017 //=================================================================================
1018 // function : keyPressEvent()
1020 //=================================================================================
1021 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1023 QDialog::keyPressEvent( e );
1024 if ( e->isAccepted() )
1027 if ( e->key() == Qt::Key_F1 ) {
1033 //=================================================================================
1034 // function : toDisplaySimulation()
1036 //=================================================================================
1037 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1039 onDisplaySimulation(true);
1042 //=================================================================================
1043 // function : onDisplaySimulation()
1045 //=================================================================================
1046 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1048 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1051 if (myNbOkElements && IsAxisOk())
1053 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1055 SMESH::long_array_var anElementsId = new SMESH::long_array;
1057 anElementsId->length(aListElementsId.count());
1058 for (int i = 0; i < aListElementsId.count(); i++)
1059 anElementsId[i] = aListElementsId[i].toInt();
1061 SMESH::AxisStruct anAxis;
1063 anAxis.x = SpinBox_X->GetValue();
1064 anAxis.y = SpinBox_Y->GetValue();
1065 anAxis.z = SpinBox_Z->GetValue();
1066 anAxis.vx = SpinBox_DX->GetValue();
1067 anAxis.vy = SpinBox_DY->GetValue();
1068 anAxis.vz = SpinBox_DZ->GetValue();
1070 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1071 long aNbSteps = (long)SpinBox_NbSteps->value();
1072 double aTolerance = SpinBox_Tolerance->GetValue();
1074 if (GroupAngle->checkedId() == 1)
1075 anAngle = anAngle/aNbSteps;
1078 SUIT_OverrideCursor aWaitCursor;
1079 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1080 if( CheckBoxMesh->isChecked() ) {
1081 if( GetConstructorId() == 0 )
1082 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1083 anAngle, aNbSteps, aTolerance);
1085 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1086 anAngle, aNbSteps, aTolerance);
1089 aMeshEditor->RotationSweep(anElementsId.inout(),
1094 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1095 mySimulation->SetData(aMeshPreviewStruct._retn());
1100 mySimulation->SetVisibility(false);
1106 mySimulation->SetVisibility(false);
1110 //=================================================================================
1111 // function : onSelectVectorButton()
1113 //=================================================================================
1114 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1115 if(SelectVectorMenu) {
1116 SelectVectorMenu->exec( QCursor::pos() );
1120 //=================================================================================
1121 // function : onSelectVectorMenu()
1123 //=================================================================================
1124 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1128 disconnect(mySelectionMgr, 0, this, 0);
1130 switch(myMenuActions[action]) {
1132 SMESH::SetPointRepresentation(true);
1133 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1134 aViewWindow->SetSelectionMode(NodeSelection);
1138 SMESH::SetPointRepresentation(false);
1139 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1140 aViewWindow->SetSelectionMode(FaceSelection);
1144 myVectorDefinition = myMenuActions[action];
1145 myEditCurrentArgument = (QWidget*)SpinBox_DX;
1146 myEditCurrentArgument->setFocus();
1147 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1148 SelectionIntoArgument();
1151 //=================================================================================
1152 // function : setFilters()
1153 // purpose : SLOT. Called when "Filter" button pressed.
1154 //=================================================================================
1155 void SMESHGUI_RevolutionDlg::setFilters()
1157 if(myMesh->_is_nil()) {
1158 SUIT_MessageBox::critical(this,
1160 tr("NO_MESH_SELECTED"));
1166 types.append( SMESH::EDGE );
1167 types.append( SMESH::FACE );
1168 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1170 myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1172 myFilterDlg->SetSelection();
1173 myFilterDlg->SetMesh( myMesh );
1174 myFilterDlg->SetSourceWg( LineEditElements );
1176 myFilterDlg->show();
1179 //=================================================================================
1180 // function : isValid
1182 //=================================================================================
1183 bool SMESHGUI_RevolutionDlg::isValid()
1185 return checkParameters( true, 9,
1186 SpinBox_X, SpinBox_Y, SpinBox_Z,
1187 SpinBox_DX, SpinBox_DY, SpinBox_DZ,
1188 SpinBox_Angle, SpinBox_NbSteps, SpinBox_Tolerance );