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()),
99 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
101 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
102 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
103 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
104 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
107 setAttribute(Qt::WA_DeleteOnClose, true);
108 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
109 setSizeGripEnabled(true);
111 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
112 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
113 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
115 /***************************************************************/
116 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
117 GroupConstructors = new QButtonGroup(this);
118 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
119 ConstructorsBoxLayout->setSpacing(SPACING);
120 ConstructorsBoxLayout->setMargin(MARGIN);
122 RadioButton1 = new QRadioButton(ConstructorsBox);
123 RadioButton1->setIcon(image0);
124 RadioButton2 = new QRadioButton(ConstructorsBox);
125 RadioButton2->setIcon(image1);
127 ConstructorsBoxLayout->addWidget(RadioButton1);
128 ConstructorsBoxLayout->addWidget(RadioButton2);
129 GroupConstructors->addButton(RadioButton1, 0);
130 GroupConstructors->addButton(RadioButton2, 1);
132 /***************************************************************/
133 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
134 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
135 GroupArgumentsLayout->setSpacing(SPACING);
136 GroupArgumentsLayout->setMargin(MARGIN);
138 myIdValidator = new SMESHGUI_IdValidator(this);
140 // Controls for elements selection
141 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
143 SelectElementsButton = new QPushButton(GroupArguments);
144 SelectElementsButton->setIcon(image2);
146 LineEditElements = new QLineEdit(GroupArguments);
147 LineEditElements->setValidator(myIdValidator);
148 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
149 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
151 // Control for the whole mesh selection
152 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
154 // Controls for axis defining
155 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
156 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
157 GroupAxisLayout->setSpacing(SPACING);
158 GroupAxisLayout->setMargin(MARGIN);
160 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
161 SelectPointButton = new QPushButton(GroupAxis);
162 SelectPointButton->setIcon(image2);
164 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
165 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
167 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
168 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
170 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
171 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
173 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
174 SelectVectorButton = new QPushButton(GroupAxis);
175 SelectVectorButton->setIcon(image2);
177 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
178 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
180 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
181 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
183 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
184 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
186 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
187 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
188 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
189 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
190 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
191 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
192 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
193 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
194 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
195 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
196 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
197 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
198 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
199 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
200 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
201 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
203 // Controls for angle defining & number of steps defining
204 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
205 GroupAngle = new QButtonGroup(GroupAngleBox);
206 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
207 GroupAngleLayout->setSpacing(6);
208 GroupAngleLayout->setMargin(11);
210 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
211 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
212 GroupAngle->addButton(RadioButton3, 0);
213 GroupAngle->addButton(RadioButton4, 1);
215 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
216 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
218 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
219 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
221 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
222 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
223 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
224 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
225 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
226 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
228 // Controls for tolerance defining
229 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
230 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
232 // Control for mesh preview
233 CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
235 // CheckBox for groups generation
236 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
237 MakeGroupsCheck->setChecked(true);
239 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
240 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
241 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
242 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
243 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
244 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
245 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 4);
246 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
247 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2, 1, 2);
248 GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 4);
249 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
251 /***************************************************************/
252 GroupButtons = new QGroupBox(this);
253 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
254 GroupButtonsLayout->setSpacing(SPACING);
255 GroupButtonsLayout->setMargin(MARGIN);
257 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
258 buttonOk->setAutoDefault(true);
259 buttonOk->setDefault(true);
260 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
261 buttonApply->setAutoDefault(true);
262 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
263 buttonCancel->setAutoDefault(true);
264 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
265 buttonHelp->setAutoDefault(true);
267 GroupButtonsLayout->addWidget(buttonOk);
268 GroupButtonsLayout->addSpacing(10);
269 GroupButtonsLayout->addWidget(buttonApply);
270 GroupButtonsLayout->addSpacing(10);
271 GroupButtonsLayout->addStretch();
272 GroupButtonsLayout->addWidget(buttonCancel);
273 GroupButtonsLayout->addWidget(buttonHelp);
275 /***************************************************************/
276 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
277 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
278 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
280 /* Initialisations */
281 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
282 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
283 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
284 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
286 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
288 RadioButton3->setChecked(true);
290 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
292 SpinBox_NbSteps->setRange(1, 999999);
294 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
296 RadioButton1->setChecked(true);
298 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
300 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
302 // Costruction of the logical filter
303 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
304 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
306 QList<SUIT_SelectionFilter*> aListOfFilters;
307 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
308 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
310 myMeshOrSubMeshOrGroupFilter =
311 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
313 myHelpFileName = "revolution_page.html";
317 /*Create menu to vector selection*/
318 SelectVectorMenu = new QMenu(this);
319 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
320 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
321 connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
323 /* signals and slots connections */
324 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
325 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
326 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
327 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
328 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
330 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
331 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
332 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
334 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
335 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
338 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
339 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
340 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
342 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
343 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
344 /* to close dialog if study change */
345 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
346 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
347 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
349 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
350 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
351 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
352 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
353 connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
355 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
357 ConstructorsClicked(0);
358 SelectionIntoArgument();
361 //=================================================================================
362 // function : ~SMESHGUI_RevolutionDlg()
363 // purpose : Destroys the object and frees any allocated resources
364 //=================================================================================
365 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
369 myFilterDlg->setParent( 0 );
375 //=================================================================================
378 //=================================================================================
379 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
383 myEditCurrentArgument = 0;
384 LineEditElements->clear();
390 myMesh = SMESH::SMESH_Mesh::_nil();
393 SpinBox_X->SetValue(0.0);
394 SpinBox_Y->SetValue(0.0);
395 SpinBox_Z->SetValue(0.0);
396 SpinBox_DX->SetValue(0.0);
397 SpinBox_DY->SetValue(0.0);
398 SpinBox_DZ->SetValue(0.0);
400 SpinBox_Angle->SetValue(45);
401 SpinBox_NbSteps->setValue(1);
402 SpinBox_Tolerance->SetValue(1e-05);
404 CheckBoxMesh->setChecked(false);
406 CheckBoxPreview->setChecked(false);
407 onDisplaySimulation(false);
411 //=================================================================================
412 // function : ConstructorsClicked()
413 // purpose : Radio button management
414 //=================================================================================
415 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
417 disconnect(mySelectionMgr, 0, this, 0);
420 mySelectionMgr->selectedObjects( io );
422 mySelectionMgr->setSelectedObjects( aList );*/
424 buttonApply->setEnabled(false);
425 buttonOk->setEnabled(false);
426 mySimulation->SetVisibility(false);
428 Selection_Mode aSelMode = ActorSelection;
430 switch (constructorId) {
433 GroupArguments->setTitle(tr("REVOLUTION_1D"));
434 aSelMode = EdgeSelection;
439 GroupArguments->setTitle(tr("REVOLUTION_2D"));
440 aSelMode = FaceSelection;
445 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
446 SMESH::SetPointRepresentation(false);
449 if (!CheckBoxMesh->isChecked())
451 LineEditElements->clear();
454 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
455 aViewWindow->SetSelectionMode(aSelMode);
458 myEditCurrentArgument = (QWidget*)LineEditElements;
459 LineEditElements->setFocus();
461 if (CheckBoxMesh->isChecked())
464 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
465 // mySelectionMgr->setSelectedObjects( io );
468 //=================================================================================
469 // function : ClickOnApply()
471 //=================================================================================
472 bool SMESHGUI_RevolutionDlg::ClickOnApply()
474 if (mySMESHGUI->isActiveStudyLocked())
480 if (myNbOkElements && IsAxisOk()) {
481 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
483 SMESH::long_array_var anElementsId = new SMESH::long_array;
485 anElementsId->length(aListElementsId.count());
486 for (int i = 0; i < aListElementsId.count(); i++)
487 anElementsId[i] = aListElementsId[i].toInt();
489 SMESH::AxisStruct anAxis;
491 anAxis.x = SpinBox_X->GetValue();
492 anAxis.y = SpinBox_Y->GetValue();
493 anAxis.z = SpinBox_Z->GetValue();;
494 anAxis.vx = SpinBox_DX->GetValue();
495 anAxis.vy = SpinBox_DY->GetValue();
496 anAxis.vz = SpinBox_DZ->GetValue();
498 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
499 long aNbSteps = (long)SpinBox_NbSteps->value();
500 double aTolerance = SpinBox_Tolerance->GetValue();
502 if ( GroupAngle->checkedId() == 1 )
503 anAngle = anAngle/aNbSteps;
505 QStringList aParameters;
506 aParameters << SpinBox_X->text();
507 aParameters << SpinBox_Y->text();
508 aParameters << SpinBox_Z->text();
509 aParameters << SpinBox_DX->text();
510 aParameters << SpinBox_DY->text();
511 aParameters << SpinBox_DZ->text();
512 aParameters << SpinBox_Angle->text();
513 aParameters << SpinBox_NbSteps->text();
514 aParameters << SpinBox_Tolerance->text();
517 SUIT_OverrideCursor aWaitCursor;
518 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
520 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
521 if( CheckBoxMesh->isChecked() ) {
522 if( GetConstructorId() == 0 )
523 SMESH::ListOfGroups_var groups =
524 aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
525 anAngle, aNbSteps, aTolerance);
527 SMESH::ListOfGroups_var groups =
528 aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
529 anAngle, aNbSteps, aTolerance);
532 SMESH::ListOfGroups_var groups =
533 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
534 anAngle, aNbSteps, aTolerance);
537 if( CheckBoxMesh->isChecked() ) {
538 if( GetConstructorId() == 0 )
539 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
541 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
544 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
547 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
552 SMESH::Update(myIO, SMESH::eDisplay);
553 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
554 mySMESHGUI->updateObjBrowser(true); // new groups may appear
556 ConstructorsClicked(GetConstructorId());
557 mySelectedObject = SMESH::SMESH_IDSource::_nil();
558 SelectionIntoArgument();
564 //=================================================================================
565 // function : ClickOnOk()
567 //=================================================================================
568 void SMESHGUI_RevolutionDlg::ClickOnOk()
574 //=================================================================================
575 // function : ClickOnCancel()
577 //=================================================================================
578 void SMESHGUI_RevolutionDlg::ClickOnCancel()
583 void SMESHGUI_RevolutionDlg::reject()
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()
688 QString aString = "";
691 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
692 LineEditElements->setText(aString);
694 buttonOk->setEnabled(false);
695 buttonApply->setEnabled(false);
699 if (!GroupButtons->isEnabled()) // inactive
703 const SALOME_ListIO& aList = mySelector->StoredIObjects();
705 int nbSel = aList.Extent();
709 Handle(SALOME_InteractiveObject) IO = aList.First();
710 SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
711 if (aMeshVar->_is_nil())
714 SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
716 anActor = SMESH::FindActorByEntry(IO->getEntry());
722 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
728 // MakeGroups is available if there are groups
729 if ( myMesh->NbGroups() == 0 ) {
730 MakeGroupsCheck->setChecked(false);
731 MakeGroupsCheck->setEnabled(false);
733 MakeGroupsCheck->setEnabled(true);
736 if (CheckBoxMesh->isChecked()) {
737 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
739 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
740 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
744 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
745 myElementsId = aString;
749 myNbOkElements = true;
752 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
756 bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
757 (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
758 myVectorDefinition==POINT_SELECT));
760 bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
761 myVectorDefinition==FACE_SELECT);
764 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
766 else if(isFaceSelected){
767 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
774 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
782 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
783 SpinBox_X->SetValue(x);
784 SpinBox_Y->SetValue(y);
785 SpinBox_Z->SetValue(z);
786 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
787 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
788 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
789 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
792 else if(isFaceSelected){
793 const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
797 gp_XYZ aNormale = SMESH::getNormale(face);
798 SpinBox_DX->SetValue(aNormale.X());
799 SpinBox_DY->SetValue(aNormale.Y());
800 SpinBox_DZ->SetValue(aNormale.Z());
806 if (myEditCurrentArgument == (QWidget*)LineEditElements)
807 LineEditElements->setText(aString);
811 if (myNbOkElements && IsAxisOk()) {
812 buttonOk->setEnabled(true);
813 buttonApply->setEnabled(true);
816 onDisplaySimulation(true);
819 //=================================================================================
820 // function : SetEditCurrentArgument()
822 //=================================================================================
823 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
825 QPushButton* send = (QPushButton*)sender();
827 disconnect(mySelectionMgr, 0, this, 0);
828 mySelectionMgr->clearSelected();
829 mySelectionMgr->clearFilters();
831 if (send == SelectElementsButton) {
832 mySimulation->SetVisibility(false);
833 myEditCurrentArgument = (QWidget*)LineEditElements;
834 SMESH::SetPointRepresentation(false);
835 if (CheckBoxMesh->isChecked()) {
836 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
837 aViewWindow->SetSelectionMode(ActorSelection);
838 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
840 int aConstructorId = GetConstructorId();
841 if (aConstructorId == 0)
843 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
844 aViewWindow->SetSelectionMode(EdgeSelection);
846 else if (aConstructorId == 1)
848 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
849 aViewWindow->SetSelectionMode(FaceSelection);
852 } else if (send == SelectPointButton) {
853 myEditCurrentArgument = (QWidget*)SpinBox_X;
854 SMESH::SetPointRepresentation(true);
855 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
856 aViewWindow->SetSelectionMode(NodeSelection);
859 myEditCurrentArgument->setFocus();
860 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
861 SelectionIntoArgument();
864 //=================================================================================
865 // function : DeactivateActiveDialog()
867 //=================================================================================
868 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
870 if (ConstructorsBox->isEnabled()) {
871 ConstructorsBox->setEnabled(false);
872 GroupArguments->setEnabled(false);
873 GroupButtons->setEnabled(false);
874 mySMESHGUI->ResetState();
875 mySMESHGUI->SetActiveDialogBox(0);
879 //=================================================================================
880 // function : ActivateThisDialog()
882 //=================================================================================
883 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
885 /* Emit a signal to deactivate the active dialog */
886 mySMESHGUI->EmitSignalDeactivateDialog();
887 ConstructorsBox->setEnabled(true);
888 GroupArguments->setEnabled(true);
889 GroupButtons->setEnabled(true);
891 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
893 ConstructorsClicked(GetConstructorId());
894 SelectionIntoArgument();
897 //=================================================================================
898 // function : enterEvent()
900 //=================================================================================
901 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
903 if (!ConstructorsBox->isEnabled())
904 ActivateThisDialog();
907 //=================================================================================
908 // function : closeEvent()
910 //=================================================================================
911 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
913 /* same than click on cancel button */
914 disconnect(mySelectionMgr, 0, this, 0);
915 mySelectionMgr->clearFilters();
916 //mySelectionMgr->clearSelected();
917 if (SMESH::GetCurrentVtkView()) {
918 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
919 SMESH::SetPointRepresentation(false);
921 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
922 aViewWindow->SetSelectionMode(ActorSelection);
923 mySMESHGUI->ResetState();
926 //=======================================================================
927 //function : onSelectMesh
929 //=======================================================================
930 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
933 myIDs = LineEditElements->text();
934 TextLabelElements->setText(tr("SMESH_NAME"));
937 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
938 myFilterBtn->setEnabled(!toSelectMesh);
940 if (myEditCurrentArgument != LineEditElements) {
941 LineEditElements->clear();
942 mySimulation->SetVisibility(false);
946 mySelectionMgr->clearFilters();
947 SMESH::SetPointRepresentation(false);
950 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
951 aViewWindow->SetSelectionMode(ActorSelection);
952 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
953 LineEditElements->setReadOnly(true);
954 LineEditElements->setValidator(0);
956 int aConstructorId = GetConstructorId();
957 if (aConstructorId == 0)
959 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
960 aViewWindow->SetSelectionMode(EdgeSelection);
962 else if (aConstructorId == 1)
964 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
965 aViewWindow->SetSelectionMode(FaceSelection);
968 LineEditElements->setReadOnly(false);
969 LineEditElements->setValidator(myIdValidator);
970 onTextChange(LineEditElements->text());
971 mySimulation->SetVisibility(false);
974 SelectionIntoArgument();
977 LineEditElements->setText( myIDs );
980 //=================================================================================
981 // function : GetConstructorId()
983 //=================================================================================
984 int SMESHGUI_RevolutionDlg::GetConstructorId()
986 return GroupConstructors->checkedId();
989 //=================================================================================
990 // function : IsAxisOk()
992 //=================================================================================
993 bool SMESHGUI_RevolutionDlg::IsAxisOk()
995 return (SpinBox_DX->GetValue() != 0 ||
996 SpinBox_DY->GetValue() != 0 ||
997 SpinBox_DZ->GetValue() != 0);
1000 //=================================================================================
1001 // function : onVectorChanged()
1003 //=================================================================================
1004 void SMESHGUI_RevolutionDlg::onVectorChanged()
1007 buttonOk->setEnabled(true);
1008 buttonApply->setEnabled(true);
1010 buttonOk->setEnabled(false);
1011 buttonApply->setEnabled(false);
1013 onDisplaySimulation(true);
1016 //=================================================================================
1017 // function : keyPressEvent()
1019 //=================================================================================
1020 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1022 QDialog::keyPressEvent( e );
1023 if ( e->isAccepted() )
1026 if ( e->key() == Qt::Key_F1 ) {
1032 //=================================================================================
1033 // function : toDisplaySimulation()
1035 //=================================================================================
1036 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1038 onDisplaySimulation(true);
1041 //=================================================================================
1042 // function : onDisplaySimulation()
1044 //=================================================================================
1045 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1047 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1050 if (myNbOkElements && IsAxisOk())
1052 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1054 SMESH::long_array_var anElementsId = new SMESH::long_array;
1056 anElementsId->length(aListElementsId.count());
1057 for (int i = 0; i < aListElementsId.count(); i++)
1058 anElementsId[i] = aListElementsId[i].toInt();
1060 SMESH::AxisStruct anAxis;
1062 anAxis.x = SpinBox_X->GetValue();
1063 anAxis.y = SpinBox_Y->GetValue();
1064 anAxis.z = SpinBox_Z->GetValue();
1065 anAxis.vx = SpinBox_DX->GetValue();
1066 anAxis.vy = SpinBox_DY->GetValue();
1067 anAxis.vz = SpinBox_DZ->GetValue();
1069 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1070 long aNbSteps = (long)SpinBox_NbSteps->value();
1071 double aTolerance = SpinBox_Tolerance->GetValue();
1073 if (GroupAngle->checkedId() == 1)
1074 anAngle = anAngle/aNbSteps;
1077 SUIT_OverrideCursor aWaitCursor;
1078 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1079 if( CheckBoxMesh->isChecked() ) {
1080 if( GetConstructorId() == 0 )
1081 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1082 anAngle, aNbSteps, aTolerance);
1084 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1085 anAngle, aNbSteps, aTolerance);
1088 aMeshEditor->RotationSweep(anElementsId.inout(),
1093 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1094 mySimulation->SetData(aMeshPreviewStruct._retn());
1099 mySimulation->SetVisibility(false);
1105 mySimulation->SetVisibility(false);
1109 //=================================================================================
1110 // function : onSelectVectorButton()
1112 //=================================================================================
1113 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1114 if(SelectVectorMenu) {
1115 SelectVectorMenu->exec( QCursor::pos() );
1119 //=================================================================================
1120 // function : onSelectVectorMenu()
1122 //=================================================================================
1123 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1127 disconnect(mySelectionMgr, 0, this, 0);
1129 switch(myMenuActions[action]) {
1131 SMESH::SetPointRepresentation(true);
1132 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1133 aViewWindow->SetSelectionMode(NodeSelection);
1137 SMESH::SetPointRepresentation(false);
1138 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1139 aViewWindow->SetSelectionMode(FaceSelection);
1143 myVectorDefinition = myMenuActions[action];
1144 myEditCurrentArgument = (QWidget*)SpinBox_DX;
1145 myEditCurrentArgument->setFocus();
1146 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1147 SelectionIntoArgument();
1150 //=================================================================================
1151 // function : setFilters()
1152 // purpose : SLOT. Called when "Filter" button pressed.
1153 //=================================================================================
1154 void SMESHGUI_RevolutionDlg::setFilters()
1156 if(myMesh->_is_nil()) {
1157 SUIT_MessageBox::critical(this,
1159 tr("NO_MESH_SELECTED"));
1165 types.append( SMESH::EDGE );
1166 types.append( SMESH::FACE );
1167 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1169 myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1171 myFilterDlg->SetSelection();
1172 myFilterDlg->SetMesh( myMesh );
1173 myFilterDlg->SetSourceWg( LineEditElements );
1175 myFilterDlg->show();
1178 //=================================================================================
1179 // function : isValid
1181 //=================================================================================
1182 bool SMESHGUI_RevolutionDlg::isValid()
1186 ok = SpinBox_X->isValid( msg, true ) && ok;
1187 ok = SpinBox_Y->isValid( msg, true ) && ok;
1188 ok = SpinBox_Z->isValid( msg, true ) && ok;
1189 ok = SpinBox_DX->isValid( msg, true ) && ok;
1190 ok = SpinBox_DY->isValid( msg, true ) && ok;
1191 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1192 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1193 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1194 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1197 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1198 if ( !msg.isEmpty() )
1200 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );