1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 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 // File : SMESHGUI_RevolutionDlg.cxx
23 // 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"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TypeFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_Desktop.h>
47 #include <SUIT_OverrideCursor.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_SelectionMgr.h>
51 #include <SalomeApp_Application.h>
52 #include <SalomeApp_IntSpinBox.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SVTK_Selector.h>
56 #include <SALOME_ListIO.hxx>
57 #include <VTKViewer_CellLocationsArray.h>
60 #include <TColStd_MapOfInteger.hxx>
63 #include <QApplication>
64 #include <QButtonGroup>
68 #include <QPushButton>
69 #include <QRadioButton>
71 #include <QHBoxLayout>
72 #include <QVBoxLayout>
73 #include <QGridLayout>
77 #include <SALOMEconfig.h>
78 #include CORBA_SERVER_HEADER(SMESH_Group)
79 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
84 //=================================================================================
85 // class : SMESHGUI_RevolutionDlg()
87 //=================================================================================
88 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
89 : QDialog( SMESH::GetDesktop( theModule ) ),
90 mySMESHGUI( theModule ),
91 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
92 mySelectedObject(SMESH::SMESH_IDSource::_nil())
94 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
96 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
97 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
98 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
99 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
102 setAttribute(Qt::WA_DeleteOnClose, true);
103 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
104 setSizeGripEnabled(true);
106 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
107 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
108 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
110 /***************************************************************/
111 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
112 GroupConstructors = new QButtonGroup(this);
113 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
114 ConstructorsBoxLayout->setSpacing(SPACING);
115 ConstructorsBoxLayout->setMargin(MARGIN);
117 RadioButton1 = new QRadioButton(ConstructorsBox);
118 RadioButton1->setIcon(image0);
119 RadioButton2 = new QRadioButton(ConstructorsBox);
120 RadioButton2->setIcon(image1);
122 ConstructorsBoxLayout->addWidget(RadioButton1);
123 ConstructorsBoxLayout->addWidget(RadioButton2);
124 GroupConstructors->addButton(RadioButton1, 0);
125 GroupConstructors->addButton(RadioButton2, 1);
127 /***************************************************************/
128 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
129 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
130 GroupArgumentsLayout->setSpacing(SPACING);
131 GroupArgumentsLayout->setMargin(MARGIN);
133 myIdValidator = new SMESHGUI_IdValidator(this);
135 // Controls for elements selection
136 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
138 SelectElementsButton = new QPushButton(GroupArguments);
139 SelectElementsButton->setIcon(image2);
141 LineEditElements = new QLineEdit(GroupArguments);
142 LineEditElements->setValidator(myIdValidator);
144 // Control for the whole mesh selection
145 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
147 // Controls for axis defining
148 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
149 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
150 GroupAxisLayout->setSpacing(SPACING);
151 GroupAxisLayout->setMargin(MARGIN);
153 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
154 SelectPointButton = new QPushButton(GroupAxis);
155 SelectPointButton->setIcon(image2);
157 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
158 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
160 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
161 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
163 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
164 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
166 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
167 SelectVectorButton = new QPushButton(GroupAxis);
168 SelectVectorButton->setIcon(image2);
170 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
171 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
173 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
174 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
176 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
177 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
179 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
180 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
181 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
182 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
183 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
184 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
185 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
186 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
187 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
188 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
189 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
190 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
191 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
192 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
193 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
194 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
196 // Controls for angle defining & number of steps defining
197 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
198 GroupAngle = new QButtonGroup(GroupAngleBox);
199 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
200 GroupAngleLayout->setSpacing(6);
201 GroupAngleLayout->setMargin(11);
203 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
204 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
205 GroupAngle->addButton(RadioButton3, 0);
206 GroupAngle->addButton(RadioButton4, 1);
208 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
209 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
211 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
212 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
214 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
215 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
216 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
217 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
218 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
219 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
221 // Controls for tolerance defining
222 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
223 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
225 // Control for mesh preview
226 CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
228 // CheckBox for groups generation
229 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
230 MakeGroupsCheck->setChecked(true);
232 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
233 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
234 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
235 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
236 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 3);
237 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 3);
238 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
239 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2);
240 GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 3);
241 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 3);
243 /***************************************************************/
244 GroupButtons = new QGroupBox(this);
245 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
246 GroupButtonsLayout->setSpacing(SPACING);
247 GroupButtonsLayout->setMargin(MARGIN);
249 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
250 buttonOk->setAutoDefault(true);
251 buttonOk->setDefault(true);
252 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
253 buttonApply->setAutoDefault(true);
254 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
255 buttonCancel->setAutoDefault(true);
256 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
257 buttonHelp->setAutoDefault(true);
259 GroupButtonsLayout->addWidget(buttonOk);
260 GroupButtonsLayout->addSpacing(10);
261 GroupButtonsLayout->addWidget(buttonApply);
262 GroupButtonsLayout->addSpacing(10);
263 GroupButtonsLayout->addStretch();
264 GroupButtonsLayout->addWidget(buttonCancel);
265 GroupButtonsLayout->addWidget(buttonHelp);
267 /***************************************************************/
268 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
269 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
270 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
272 /* Initialisations */
273 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
274 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
275 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
276 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
277 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
278 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
280 RadioButton3->setChecked(true);
282 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
284 SpinBox_NbSteps->setRange(1, 999999);
286 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
288 RadioButton1->setChecked(true);
290 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
292 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
294 // Costruction of the logical filter
295 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
296 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
298 QList<SUIT_SelectionFilter*> aListOfFilters;
299 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
300 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
302 myMeshOrSubMeshOrGroupFilter =
303 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
305 myHelpFileName = "revolution_page.html";
309 /* signals and slots connections */
310 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
311 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
312 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
313 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
314 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
316 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
317 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
318 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
320 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
321 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
322 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
324 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
325 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
326 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
328 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
329 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
330 /* to close dialog if study change */
331 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
332 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
333 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
335 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
337 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
338 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
339 connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
341 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
343 ConstructorsClicked(0);
344 SelectionIntoArgument();
347 //=================================================================================
348 // function : ~SMESHGUI_RevolutionDlg()
349 // purpose : Destroys the object and frees any allocated resources
350 //=================================================================================
351 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
356 //=================================================================================
359 //=================================================================================
360 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
364 myEditCurrentArgument = 0;
365 LineEditElements->clear();
370 myMesh = SMESH::SMESH_Mesh::_nil();
373 SpinBox_X->SetValue(0.0);
374 SpinBox_Y->SetValue(0.0);
375 SpinBox_Z->SetValue(0.0);
376 SpinBox_DX->SetValue(0.0);
377 SpinBox_DY->SetValue(0.0);
378 SpinBox_DZ->SetValue(0.0);
380 SpinBox_Angle->SetValue(45);
381 SpinBox_NbSteps->setValue(1);
382 SpinBox_Tolerance->SetValue(1e-05);
384 CheckBoxMesh->setChecked(false);
386 CheckBoxPreview->setChecked(false);
387 onDisplaySimulation(false);
391 //=================================================================================
392 // function : ConstructorsClicked()
393 // purpose : Radio button management
394 //=================================================================================
395 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
397 //disconnect(mySelectionMgr, 0, this, 0);
400 mySelectionMgr->selectedObjects( io );
402 mySelectionMgr->setSelectedObjects( aList );
403 // LineEditElements->clear();
405 buttonApply->setEnabled(false);
406 buttonOk->setEnabled(false);
407 mySimulation->SetVisibility(false);
409 Selection_Mode aSelMode = ActorSelection;
411 switch (constructorId) {
414 GroupArguments->setTitle(tr("REVOLUTION_1D"));
415 aSelMode = EdgeSelection;
420 GroupArguments->setTitle(tr("REVOLUTION_2D"));
421 aSelMode = FaceSelection;
426 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
427 SMESH::SetPointRepresentation(false);
430 if (!CheckBoxMesh->isChecked())
432 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
433 aViewWindow->SetSelectionMode(aSelMode);
436 myEditCurrentArgument = (QWidget*)LineEditElements;
437 LineEditElements->setFocus();
439 if (CheckBoxMesh->isChecked())
442 //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
443 mySelectionMgr->setSelectedObjects( io );
446 //=================================================================================
447 // function : ClickOnApply()
449 //=================================================================================
450 bool SMESHGUI_RevolutionDlg::ClickOnApply()
452 if (mySMESHGUI->isActiveStudyLocked())
458 if (myNbOkElements && IsAxisOk()) {
459 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
461 SMESH::long_array_var anElementsId = new SMESH::long_array;
463 anElementsId->length(aListElementsId.count());
464 for (int i = 0; i < aListElementsId.count(); i++)
465 anElementsId[i] = aListElementsId[i].toInt();
467 SMESH::AxisStruct anAxis;
469 anAxis.x = SpinBox_X->GetValue();
470 anAxis.y = SpinBox_Y->GetValue();
471 anAxis.z = SpinBox_Z->GetValue();;
472 anAxis.vx = SpinBox_DX->GetValue();
473 anAxis.vy = SpinBox_DY->GetValue();
474 anAxis.vz = SpinBox_DZ->GetValue();
476 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
477 long aNbSteps = (long)SpinBox_NbSteps->value();
478 double aTolerance = SpinBox_Tolerance->GetValue();
480 if ( GroupAngle->checkedId() == 1 )
481 anAngle = anAngle/aNbSteps;
483 QStringList aParameters;
484 aParameters << SpinBox_X->text();
485 aParameters << SpinBox_Y->text();
486 aParameters << SpinBox_Z->text();
487 aParameters << SpinBox_DX->text();
488 aParameters << SpinBox_DY->text();
489 aParameters << SpinBox_DZ->text();
490 aParameters << SpinBox_Angle->text();
491 aParameters << SpinBox_NbSteps->text();
492 aParameters << SpinBox_Tolerance->text();
495 SUIT_OverrideCursor aWaitCursor;
496 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
498 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
499 if( CheckBoxMesh->isChecked() ) {
500 if( GetConstructorId() == 0 )
501 SMESH::ListOfGroups_var groups =
502 aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
503 anAngle, aNbSteps, aTolerance);
505 SMESH::ListOfGroups_var groups =
506 aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
507 anAngle, aNbSteps, aTolerance);
510 SMESH::ListOfGroups_var groups =
511 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
512 anAngle, aNbSteps, aTolerance);
515 if( CheckBoxMesh->isChecked() ) {
516 if( GetConstructorId() == 0 )
517 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
519 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
522 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
525 myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
530 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
531 mySMESHGUI->updateObjBrowser(true); // new groups may appear
533 ConstructorsClicked(GetConstructorId());
534 mySelectedObject = SMESH::SMESH_IDSource::_nil();
535 SelectionIntoArgument();
541 //=================================================================================
542 // function : ClickOnOk()
544 //=================================================================================
545 void SMESHGUI_RevolutionDlg::ClickOnOk()
551 //=================================================================================
552 // function : ClickOnCancel()
554 //=================================================================================
555 void SMESHGUI_RevolutionDlg::ClickOnCancel()
557 disconnect(mySelectionMgr, 0, this, 0);
558 mySelectionMgr->clearFilters();
559 //mySelectionMgr->clearSelected();
560 SMESH::SetPointRepresentation(false);
561 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
562 aViewWindow->SetSelectionMode(ActorSelection);
563 mySMESHGUI->ResetState();
567 //=================================================================================
568 // function : ClickOnHelp()
570 //=================================================================================
571 void SMESHGUI_RevolutionDlg::ClickOnHelp()
573 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
575 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
579 platform = "winapplication";
581 platform = "application";
583 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
584 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
585 arg(app->resourceMgr()->stringValue("ExternalBrowser",
587 arg(myHelpFileName));
591 //=======================================================================
592 // function : onAngleTextChange()
594 //=======================================================================
595 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
598 SpinBox_Angle->text().toDouble( &isNumber );
600 RadioButton3->setChecked( true );
601 RadioButton4->setEnabled( isNumber );
604 //=======================================================================
605 // function : onTextChange()
607 //=======================================================================
608 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
610 QLineEdit* send = (QLineEdit*)sender();
615 if (send == LineEditElements)
618 buttonOk->setEnabled(false);
619 buttonApply->setEnabled(false);
621 // hilight entered elements
622 SMDS_Mesh* aMesh = 0;
624 aMesh = myActor->GetObject()->GetMesh();
627 if (send == LineEditElements) {
628 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
630 TColStd_MapOfInteger newIndices;
632 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
634 for (int i = 0; i < aListId.count(); i++) {
635 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
637 newIndices.Add(e->GetID());
641 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
642 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
643 aViewWindow->highlight( myActor->getIO(), true, true );
645 myElementsId = theNewText;
649 if (myNbOkElements && IsAxisOk()) {
650 buttonOk->setEnabled(true);
651 buttonApply->setEnabled(true);
653 onDisplaySimulation(true);
658 //=================================================================================
659 // function : SelectionIntoArgument()
660 // purpose : Called when selection as changed or other case
661 //=================================================================================
662 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
668 QString aString = "";
671 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
672 LineEditElements->setText(aString);
674 buttonOk->setEnabled(false);
675 buttonApply->setEnabled(false);
679 if (!GroupButtons->isEnabled()) // inactive
683 const SALOME_ListIO& aList = mySelector->StoredIObjects();
685 int nbSel = aList.Extent();
689 Handle(SALOME_InteractiveObject) IO = aList.First();
690 myMesh = SMESH::GetMeshByIO(IO);
691 if (myMesh->_is_nil())
694 myActor = SMESH::FindActorByObject(myMesh);
696 myActor = SMESH::FindActorByEntry(IO->getEntry());
702 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
705 // MakeGroups is available if there are groups
706 if ( myMesh->NbGroups() == 0 ) {
707 MakeGroupsCheck->setChecked(false);
708 MakeGroupsCheck->setEnabled(false);
710 MakeGroupsCheck->setEnabled(true);
713 if (CheckBoxMesh->isChecked()) {
714 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
716 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
717 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
721 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
722 myElementsId = aString;
726 myNbOkElements = true;
728 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
732 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
736 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
744 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
745 SpinBox_X->SetValue(x);
746 SpinBox_Y->SetValue(y);
747 SpinBox_Z->SetValue(z);
748 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
749 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
750 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
751 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
756 if (myEditCurrentArgument == (QWidget*)LineEditElements)
757 LineEditElements->setText(aString);
761 if (myNbOkElements && IsAxisOk()) {
762 buttonOk->setEnabled(true);
763 buttonApply->setEnabled(true);
766 onDisplaySimulation(true);
769 //=================================================================================
770 // function : SetEditCurrentArgument()
772 //=================================================================================
773 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
775 QPushButton* send = (QPushButton*)sender();
777 disconnect(mySelectionMgr, 0, this, 0);
778 mySelectionMgr->clearSelected();
779 mySelectionMgr->clearFilters();
781 if (send == SelectElementsButton) {
782 mySimulation->SetVisibility(false);
783 myEditCurrentArgument = (QWidget*)LineEditElements;
784 SMESH::SetPointRepresentation(false);
785 if (CheckBoxMesh->isChecked()) {
786 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
787 aViewWindow->SetSelectionMode(ActorSelection);
788 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
790 int aConstructorId = GetConstructorId();
791 if (aConstructorId == 0)
793 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
794 aViewWindow->SetSelectionMode(EdgeSelection);
796 else if (aConstructorId == 1)
798 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
799 aViewWindow->SetSelectionMode(FaceSelection);
802 } else if (send == SelectPointButton) {
803 myEditCurrentArgument = (QWidget*)SpinBox_X;
804 SMESH::SetPointRepresentation(true);
805 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
806 aViewWindow->SetSelectionMode(NodeSelection);
807 } else if (send == SelectVectorButton) {
808 myEditCurrentArgument = (QWidget*)SpinBox_DX;
809 SMESH::SetPointRepresentation(true);
810 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
811 aViewWindow->SetSelectionMode(NodeSelection);
815 myEditCurrentArgument->setFocus();
816 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
817 SelectionIntoArgument();
820 //=================================================================================
821 // function : DeactivateActiveDialog()
823 //=================================================================================
824 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
826 if (ConstructorsBox->isEnabled()) {
827 ConstructorsBox->setEnabled(false);
828 GroupArguments->setEnabled(false);
829 GroupButtons->setEnabled(false);
830 mySMESHGUI->ResetState();
831 mySMESHGUI->SetActiveDialogBox(0);
835 //=================================================================================
836 // function : ActivateThisDialog()
838 //=================================================================================
839 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
841 /* Emit a signal to deactivate the active dialog */
842 mySMESHGUI->EmitSignalDeactivateDialog();
843 ConstructorsBox->setEnabled(true);
844 GroupArguments->setEnabled(true);
845 GroupButtons->setEnabled(true);
847 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
849 ConstructorsClicked(GetConstructorId());
850 SelectionIntoArgument();
853 //=================================================================================
854 // function : enterEvent()
856 //=================================================================================
857 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
859 if (!ConstructorsBox->isEnabled())
860 ActivateThisDialog();
863 //=================================================================================
864 // function : closeEvent()
866 //=================================================================================
867 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
869 /* same than click on cancel button */
873 //=======================================================================
874 // function : hideEvent()
875 // purpose : caused by ESC key
876 //=======================================================================
877 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
883 //=======================================================================
884 //function : onSelectMesh
886 //=======================================================================
887 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
890 TextLabelElements->setText(tr("SMESH_NAME"));
892 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
894 if (myEditCurrentArgument != LineEditElements) {
895 LineEditElements->clear();
896 mySimulation->SetVisibility(false);
900 mySelectionMgr->clearFilters();
901 SMESH::SetPointRepresentation(false);
904 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
905 aViewWindow->SetSelectionMode(ActorSelection);
906 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
907 LineEditElements->setReadOnly(true);
908 LineEditElements->setValidator(0);
910 int aConstructorId = GetConstructorId();
911 if (aConstructorId == 0)
913 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
914 aViewWindow->SetSelectionMode(EdgeSelection);
916 else if (aConstructorId == 0)
918 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
919 aViewWindow->SetSelectionMode(FaceSelection);
922 LineEditElements->setReadOnly(false);
923 LineEditElements->setValidator(myIdValidator);
924 onTextChange(LineEditElements->text());
925 mySimulation->SetVisibility(false);
928 SelectionIntoArgument();
931 //=================================================================================
932 // function : GetConstructorId()
934 //=================================================================================
935 int SMESHGUI_RevolutionDlg::GetConstructorId()
937 return GroupConstructors->checkedId();
940 //=================================================================================
941 // function : IsAxisOk()
943 //=================================================================================
944 bool SMESHGUI_RevolutionDlg::IsAxisOk()
946 return (SpinBox_DX->GetValue() != 0 ||
947 SpinBox_DY->GetValue() != 0 ||
948 SpinBox_DZ->GetValue() != 0);
951 //=================================================================================
952 // function : onVectorChanged()
954 //=================================================================================
955 void SMESHGUI_RevolutionDlg::onVectorChanged()
958 buttonOk->setEnabled(true);
959 buttonApply->setEnabled(true);
961 buttonOk->setEnabled(false);
962 buttonApply->setEnabled(false);
964 onDisplaySimulation(true);
967 //=================================================================================
968 // function : keyPressEvent()
970 //=================================================================================
971 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
973 QDialog::keyPressEvent( e );
974 if ( e->isAccepted() )
977 if ( e->key() == Qt::Key_F1 ) {
983 //=================================================================================
984 // function : toDisplaySimulation()
986 //=================================================================================
987 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
989 onDisplaySimulation(true);
992 //=================================================================================
993 // function : onDisplaySimulation()
995 //=================================================================================
996 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
998 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1001 if (myNbOkElements && IsAxisOk())
1003 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1005 SMESH::long_array_var anElementsId = new SMESH::long_array;
1007 anElementsId->length(aListElementsId.count());
1008 for (int i = 0; i < aListElementsId.count(); i++)
1009 anElementsId[i] = aListElementsId[i].toInt();
1011 SMESH::AxisStruct anAxis;
1013 anAxis.x = SpinBox_X->GetValue();
1014 anAxis.y = SpinBox_Y->GetValue();
1015 anAxis.z = SpinBox_Z->GetValue();
1016 anAxis.vx = SpinBox_DX->GetValue();
1017 anAxis.vy = SpinBox_DY->GetValue();
1018 anAxis.vz = SpinBox_DZ->GetValue();
1020 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1021 long aNbSteps = (long)SpinBox_NbSteps->value();
1022 double aTolerance = SpinBox_Tolerance->GetValue();
1024 if (GroupAngle->checkedId() == 1)
1025 anAngle = anAngle/aNbSteps;
1028 SUIT_OverrideCursor aWaitCursor;
1029 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1030 if( CheckBoxMesh->isChecked() ) {
1031 if( GetConstructorId() == 0 )
1032 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1033 anAngle, aNbSteps, aTolerance);
1035 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1036 anAngle, aNbSteps, aTolerance);
1039 aMeshEditor->RotationSweep(anElementsId.inout(),
1044 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1045 mySimulation->SetData(aMeshPreviewStruct._retn());
1050 mySimulation->SetVisibility(false);
1056 mySimulation->SetVisibility(false);
1061 //=================================================================================
1062 // function : isValid
1064 //=================================================================================
1065 bool SMESHGUI_RevolutionDlg::isValid()
1069 ok = SpinBox_X->isValid( msg, true ) && ok;
1070 ok = SpinBox_Y->isValid( msg, true ) && ok;
1071 ok = SpinBox_Z->isValid( msg, true ) && ok;
1072 ok = SpinBox_DX->isValid( msg, true ) && ok;
1073 ok = SpinBox_DY->isValid( msg, true ) && ok;
1074 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1075 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1076 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1077 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1080 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1081 if ( !msg.isEmpty() )
1083 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );