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);
521 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
524 myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) );
529 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
530 mySMESHGUI->updateObjBrowser(true); // new groups may appear
532 ConstructorsClicked(GetConstructorId());
533 mySelectedObject = SMESH::SMESH_IDSource::_nil();
534 SelectionIntoArgument();
540 //=================================================================================
541 // function : ClickOnOk()
543 //=================================================================================
544 void SMESHGUI_RevolutionDlg::ClickOnOk()
550 //=================================================================================
551 // function : ClickOnCancel()
553 //=================================================================================
554 void SMESHGUI_RevolutionDlg::ClickOnCancel()
556 disconnect(mySelectionMgr, 0, this, 0);
557 mySelectionMgr->clearFilters();
558 //mySelectionMgr->clearSelected();
559 SMESH::SetPointRepresentation(false);
560 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
561 aViewWindow->SetSelectionMode(ActorSelection);
562 mySMESHGUI->ResetState();
566 //=================================================================================
567 // function : ClickOnHelp()
569 //=================================================================================
570 void SMESHGUI_RevolutionDlg::ClickOnHelp()
572 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
574 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
578 platform = "winapplication";
580 platform = "application";
582 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
583 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
584 arg(app->resourceMgr()->stringValue("ExternalBrowser",
586 arg(myHelpFileName));
590 //=======================================================================
591 // function : onAngleTextChange()
593 //=======================================================================
594 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
597 SpinBox_Angle->text().toDouble( &isNumber );
599 RadioButton3->setChecked( true );
600 RadioButton4->setEnabled( isNumber );
603 //=======================================================================
604 // function : onTextChange()
606 //=======================================================================
607 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
609 QLineEdit* send = (QLineEdit*)sender();
614 if (send == LineEditElements)
617 buttonOk->setEnabled(false);
618 buttonApply->setEnabled(false);
620 // hilight entered elements
621 SMDS_Mesh* aMesh = 0;
623 aMesh = myActor->GetObject()->GetMesh();
626 if (send == LineEditElements) {
627 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
629 TColStd_MapOfInteger newIndices;
631 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
633 for (int i = 0; i < aListId.count(); i++) {
634 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
636 newIndices.Add(e->GetID());
640 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
641 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
642 aViewWindow->highlight( myActor->getIO(), true, true );
644 myElementsId = theNewText;
648 if (myNbOkElements && IsAxisOk()) {
649 buttonOk->setEnabled(true);
650 buttonApply->setEnabled(true);
652 onDisplaySimulation(true);
657 //=================================================================================
658 // function : SelectionIntoArgument()
659 // purpose : Called when selection as changed or other case
660 //=================================================================================
661 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
667 QString aString = "";
670 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
671 LineEditElements->setText(aString);
673 buttonOk->setEnabled(false);
674 buttonApply->setEnabled(false);
678 if (!GroupButtons->isEnabled()) // inactive
682 const SALOME_ListIO& aList = mySelector->StoredIObjects();
684 int nbSel = aList.Extent();
688 Handle(SALOME_InteractiveObject) IO = aList.First();
689 myMesh = SMESH::GetMeshByIO(IO);
690 if (myMesh->_is_nil())
693 myActor = SMESH::FindActorByObject(myMesh);
695 myActor = SMESH::FindActorByEntry(IO->getEntry());
701 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
704 // MakeGroups is available if there are groups
705 if ( myMesh->NbGroups() == 0 ) {
706 MakeGroupsCheck->setChecked(false);
707 MakeGroupsCheck->setEnabled(false);
709 MakeGroupsCheck->setEnabled(true);
712 if (CheckBoxMesh->isChecked()) {
713 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
715 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
716 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
720 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
721 myElementsId = aString;
725 myNbOkElements = true;
727 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
731 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
735 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
743 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
744 SpinBox_X->SetValue(x);
745 SpinBox_Y->SetValue(y);
746 SpinBox_Z->SetValue(z);
747 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
748 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
749 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
750 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
755 if (myEditCurrentArgument == (QWidget*)LineEditElements)
756 LineEditElements->setText(aString);
760 if (myNbOkElements && IsAxisOk()) {
761 buttonOk->setEnabled(true);
762 buttonApply->setEnabled(true);
765 onDisplaySimulation(true);
768 //=================================================================================
769 // function : SetEditCurrentArgument()
771 //=================================================================================
772 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
774 QPushButton* send = (QPushButton*)sender();
776 disconnect(mySelectionMgr, 0, this, 0);
777 mySelectionMgr->clearSelected();
778 mySelectionMgr->clearFilters();
780 if (send == SelectElementsButton) {
781 mySimulation->SetVisibility(false);
782 myEditCurrentArgument = (QWidget*)LineEditElements;
783 SMESH::SetPointRepresentation(false);
784 if (CheckBoxMesh->isChecked()) {
785 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
786 aViewWindow->SetSelectionMode(ActorSelection);
787 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
789 int aConstructorId = GetConstructorId();
790 if (aConstructorId == 0)
792 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
793 aViewWindow->SetSelectionMode(EdgeSelection);
795 else if (aConstructorId == 1)
797 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
798 aViewWindow->SetSelectionMode(FaceSelection);
801 } else if (send == SelectPointButton) {
802 myEditCurrentArgument = (QWidget*)SpinBox_X;
803 SMESH::SetPointRepresentation(true);
804 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
805 aViewWindow->SetSelectionMode(NodeSelection);
806 } else if (send == SelectVectorButton) {
807 myEditCurrentArgument = (QWidget*)SpinBox_DX;
808 SMESH::SetPointRepresentation(true);
809 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
810 aViewWindow->SetSelectionMode(NodeSelection);
814 myEditCurrentArgument->setFocus();
815 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
816 SelectionIntoArgument();
819 //=================================================================================
820 // function : DeactivateActiveDialog()
822 //=================================================================================
823 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
825 if (ConstructorsBox->isEnabled()) {
826 ConstructorsBox->setEnabled(false);
827 GroupArguments->setEnabled(false);
828 GroupButtons->setEnabled(false);
829 mySMESHGUI->ResetState();
830 mySMESHGUI->SetActiveDialogBox(0);
834 //=================================================================================
835 // function : ActivateThisDialog()
837 //=================================================================================
838 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
840 /* Emit a signal to deactivate the active dialog */
841 mySMESHGUI->EmitSignalDeactivateDialog();
842 ConstructorsBox->setEnabled(true);
843 GroupArguments->setEnabled(true);
844 GroupButtons->setEnabled(true);
846 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
848 ConstructorsClicked(GetConstructorId());
849 SelectionIntoArgument();
852 //=================================================================================
853 // function : enterEvent()
855 //=================================================================================
856 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
858 if (!ConstructorsBox->isEnabled())
859 ActivateThisDialog();
862 //=================================================================================
863 // function : closeEvent()
865 //=================================================================================
866 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
868 /* same than click on cancel button */
872 //=======================================================================
873 // function : hideEvent()
874 // purpose : caused by ESC key
875 //=======================================================================
876 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
882 //=======================================================================
883 //function : onSelectMesh
885 //=======================================================================
886 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
889 TextLabelElements->setText(tr("SMESH_NAME"));
891 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
893 if (myEditCurrentArgument != LineEditElements) {
894 LineEditElements->clear();
895 mySimulation->SetVisibility(false);
899 mySelectionMgr->clearFilters();
900 SMESH::SetPointRepresentation(false);
903 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
904 aViewWindow->SetSelectionMode(ActorSelection);
905 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
906 LineEditElements->setReadOnly(true);
907 LineEditElements->setValidator(0);
909 int aConstructorId = GetConstructorId();
910 if (aConstructorId == 0)
912 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
913 aViewWindow->SetSelectionMode(EdgeSelection);
915 else if (aConstructorId == 0)
917 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
918 aViewWindow->SetSelectionMode(FaceSelection);
921 LineEditElements->setReadOnly(false);
922 LineEditElements->setValidator(myIdValidator);
923 onTextChange(LineEditElements->text());
924 mySimulation->SetVisibility(false);
927 SelectionIntoArgument();
930 //=================================================================================
931 // function : GetConstructorId()
933 //=================================================================================
934 int SMESHGUI_RevolutionDlg::GetConstructorId()
936 return GroupConstructors->checkedId();
939 //=================================================================================
940 // function : IsAxisOk()
942 //=================================================================================
943 bool SMESHGUI_RevolutionDlg::IsAxisOk()
945 return (SpinBox_DX->GetValue() != 0 ||
946 SpinBox_DY->GetValue() != 0 ||
947 SpinBox_DZ->GetValue() != 0);
950 //=================================================================================
951 // function : onVectorChanged()
953 //=================================================================================
954 void SMESHGUI_RevolutionDlg::onVectorChanged()
957 buttonOk->setEnabled(true);
958 buttonApply->setEnabled(true);
960 buttonOk->setEnabled(false);
961 buttonApply->setEnabled(false);
963 onDisplaySimulation(true);
966 //=================================================================================
967 // function : keyPressEvent()
969 //=================================================================================
970 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
972 QDialog::keyPressEvent( e );
973 if ( e->isAccepted() )
976 if ( e->key() == Qt::Key_F1 ) {
982 //=================================================================================
983 // function : toDisplaySimulation()
985 //=================================================================================
986 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
988 onDisplaySimulation(true);
991 //=================================================================================
992 // function : onDisplaySimulation()
994 //=================================================================================
995 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
997 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1000 if (myNbOkElements && IsAxisOk())
1002 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1004 SMESH::long_array_var anElementsId = new SMESH::long_array;
1006 anElementsId->length(aListElementsId.count());
1007 for (int i = 0; i < aListElementsId.count(); i++)
1008 anElementsId[i] = aListElementsId[i].toInt();
1010 SMESH::AxisStruct anAxis;
1012 anAxis.x = SpinBox_X->GetValue();
1013 anAxis.y = SpinBox_Y->GetValue();
1014 anAxis.z = SpinBox_Z->GetValue();
1015 anAxis.vx = SpinBox_DX->GetValue();
1016 anAxis.vy = SpinBox_DY->GetValue();
1017 anAxis.vz = SpinBox_DZ->GetValue();
1019 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1020 long aNbSteps = (long)SpinBox_NbSteps->value();
1021 double aTolerance = SpinBox_Tolerance->GetValue();
1023 if (GroupAngle->checkedId() == 1)
1024 anAngle = anAngle/aNbSteps;
1027 SUIT_OverrideCursor aWaitCursor;
1028 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1029 if( CheckBoxMesh->isChecked() ) {
1030 if( GetConstructorId() == 0 )
1031 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1032 anAngle, aNbSteps, aTolerance);
1034 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1035 anAngle, aNbSteps, aTolerance);
1038 aMeshEditor->RotationSweep(anElementsId.inout(),
1043 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1044 mySimulation->SetData(aMeshPreviewStruct._retn());
1049 mySimulation->SetVisibility(false);
1055 mySimulation->SetVisibility(false);
1060 //=================================================================================
1061 // function : isValid
1063 //=================================================================================
1064 bool SMESHGUI_RevolutionDlg::isValid()
1068 ok = SpinBox_X->isValid( msg, true ) && ok;
1069 ok = SpinBox_Y->isValid( msg, true ) && ok;
1070 ok = SpinBox_Z->isValid( msg, true ) && ok;
1071 ok = SpinBox_DX->isValid( msg, true ) && ok;
1072 ok = SpinBox_DY->isValid( msg, true ) && ok;
1073 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1074 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1075 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1076 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1079 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1080 if ( !msg.isEmpty() )
1082 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );