1 // Copyright (C) 2007-2013 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_RevolutionDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_RevolutionDlg.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESHGUI_MeshEditPreview.h"
37 #include "SMESHGUI_FilterDlg.h"
39 #include <SMESH_Actor.h>
40 #include <SMESH_TypeFilter.hxx>
41 #include <SMESH_LogicalFilter.hxx>
42 #include <SMDS_Mesh.hxx>
44 // SALOME GUI includes
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SUIT_MessageBox.h>
48 #include <SUIT_Desktop.h>
49 #include <SUIT_OverrideCursor.h>
51 #include <LightApp_Application.h>
52 #include <LightApp_SelectionMgr.h>
53 #include <SalomeApp_Application.h>
54 #include <SalomeApp_IntSpinBox.h>
56 #include <SVTK_ViewWindow.h>
57 #include <SVTK_Selector.h>
58 #include <SALOME_ListIO.hxx>
59 #include <VTKViewer_CellLocationsArray.h>
62 #include <TColStd_MapOfInteger.hxx>
65 #include <QApplication>
66 #include <QButtonGroup>
70 #include <QPushButton>
71 #include <QRadioButton>
73 #include <QHBoxLayout>
74 #include <QVBoxLayout>
75 #include <QGridLayout>
80 #include <SALOMEconfig.h>
81 #include CORBA_SERVER_HEADER(SMESH_Group)
82 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
87 //=================================================================================
88 // class : SMESHGUI_RevolutionDlg()
90 //=================================================================================
91 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
92 : SMESHGUI_PreviewDlg( 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 LineEditElements->setMaxLength(-1);
149 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
150 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
152 // Control for the whole mesh selection
153 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
155 // Controls for axis defining
156 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
157 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
158 GroupAxisLayout->setSpacing(SPACING);
159 GroupAxisLayout->setMargin(MARGIN);
161 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
162 SelectPointButton = new QPushButton(GroupAxis);
163 SelectPointButton->setIcon(image2);
165 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
166 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
168 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
169 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
171 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
172 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
174 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
175 SelectVectorButton = new QPushButton(GroupAxis);
176 SelectVectorButton->setIcon(image2);
178 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
179 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
181 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
182 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
184 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
185 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
187 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
188 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
189 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
190 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
191 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
192 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
193 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
194 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
195 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
196 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
197 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
198 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
199 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
200 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
201 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
202 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
204 // Controls for angle defining & number of steps defining
205 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
206 GroupAngle = new QButtonGroup(GroupAngleBox);
207 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
208 GroupAngleLayout->setSpacing(6);
209 GroupAngleLayout->setMargin(11);
211 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
212 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
213 GroupAngle->addButton(RadioButton3, 0);
214 GroupAngle->addButton(RadioButton4, 1);
216 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
217 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
219 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
220 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
222 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
223 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
224 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
225 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
226 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
227 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
229 // Controls for tolerance defining
230 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
231 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
233 // Control for mesh preview
234 myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
236 // CheckBox for groups generation
237 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
238 MakeGroupsCheck->setChecked(true);
240 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
241 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
242 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
243 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
244 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
245 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
246 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 4);
247 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
248 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2, 1, 2);
249 GroupArgumentsLayout->addWidget(myPreviewCheckBox, 5, 0, 1, 4);
250 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
252 /***************************************************************/
253 GroupButtons = new QGroupBox(this);
254 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
255 GroupButtonsLayout->setSpacing(SPACING);
256 GroupButtonsLayout->setMargin(MARGIN);
258 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
259 buttonOk->setAutoDefault(true);
260 buttonOk->setDefault(true);
261 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
262 buttonApply->setAutoDefault(true);
263 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
264 buttonCancel->setAutoDefault(true);
265 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
266 buttonHelp->setAutoDefault(true);
268 GroupButtonsLayout->addWidget(buttonOk);
269 GroupButtonsLayout->addSpacing(10);
270 GroupButtonsLayout->addWidget(buttonApply);
271 GroupButtonsLayout->addSpacing(10);
272 GroupButtonsLayout->addStretch();
273 GroupButtonsLayout->addWidget(buttonCancel);
274 GroupButtonsLayout->addWidget(buttonHelp);
276 /***************************************************************/
277 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
278 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
279 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
281 /* Initialisations */
282 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
283 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
284 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
285 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
286 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
287 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
289 RadioButton3->setChecked(true);
291 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, "angle_precision");
293 SpinBox_NbSteps->setRange(1, 999999);
295 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
297 RadioButton1->setChecked(true);
299 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
301 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
303 // Costruction of the logical filter
304 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (SMESH::MESHorSUBMESH);
305 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (SMESH::GROUP);
307 QList<SUIT_SelectionFilter*> aListOfFilters;
308 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
309 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
311 myMeshOrSubMeshOrGroupFilter =
312 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
314 myHelpFileName = "revolution_page.html";
318 /*Create menu to vector selection*/
319 SelectVectorMenu = new QMenu(this);
320 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
321 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
322 connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
324 /* signals and slots connections */
325 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
326 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
327 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
328 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
329 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
331 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
332 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
333 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
335 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
337 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
339 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
340 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
341 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
343 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
344 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
345 /* to close dialog if study change */
346 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
347 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
348 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
350 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
351 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
352 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
353 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
355 //To Connect preview check box
356 connectPreviewControl();
358 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
360 ConstructorsClicked(0);
361 SelectionIntoArgument();
364 //=================================================================================
365 // function : ~SMESHGUI_RevolutionDlg()
366 // purpose : Destroys the object and frees any allocated resources
367 //=================================================================================
368 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
372 myFilterDlg->setParent( 0 );
378 //=================================================================================
381 //=================================================================================
382 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
386 myEditCurrentArgument = 0;
387 LineEditElements->clear();
393 myMesh = SMESH::SMESH_Mesh::_nil();
396 SpinBox_X->SetValue(0.0);
397 SpinBox_Y->SetValue(0.0);
398 SpinBox_Z->SetValue(0.0);
399 SpinBox_DX->SetValue(0.0);
400 SpinBox_DY->SetValue(0.0);
401 SpinBox_DZ->SetValue(0.0);
403 SpinBox_Angle->SetValue(45);
404 SpinBox_NbSteps->setValue(1);
405 SpinBox_Tolerance->SetValue(1e-05);
407 CheckBoxMesh->setChecked(false);
409 myPreviewCheckBox->setChecked(false);
410 onDisplaySimulation(false);
414 //=================================================================================
415 // function : ConstructorsClicked()
416 // purpose : Radio button management
417 //=================================================================================
418 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
420 disconnect(mySelectionMgr, 0, this, 0);
423 mySelectionMgr->selectedObjects( io );
425 mySelectionMgr->setSelectedObjects( aList );*/
427 buttonApply->setEnabled(false);
428 buttonOk->setEnabled(false);
429 mySimulation->SetVisibility(false);
431 Selection_Mode aSelMode = ActorSelection;
433 switch (constructorId) {
436 GroupArguments->setTitle(tr("REVOLUTION_1D"));
437 aSelMode = EdgeSelection;
442 GroupArguments->setTitle(tr("REVOLUTION_2D"));
443 aSelMode = FaceSelection;
448 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
449 SMESH::SetPointRepresentation(false);
452 if (!CheckBoxMesh->isChecked())
454 LineEditElements->clear();
457 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
458 aViewWindow->SetSelectionMode(aSelMode);
461 myEditCurrentArgument = (QWidget*)LineEditElements;
462 LineEditElements->setFocus();
464 if (CheckBoxMesh->isChecked())
467 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
468 // mySelectionMgr->setSelectedObjects( io );
471 //=================================================================================
472 // function : ClickOnApply()
474 //=================================================================================
475 bool SMESHGUI_RevolutionDlg::ClickOnApply()
477 if (mySMESHGUI->isActiveStudyLocked())
483 if (myNbOkElements && IsAxisOk()) {
484 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
486 SMESH::long_array_var anElementsId = new SMESH::long_array;
488 anElementsId->length(aListElementsId.count());
489 for (int i = 0; i < aListElementsId.count(); i++)
490 anElementsId[i] = aListElementsId[i].toInt();
492 SMESH::AxisStruct anAxis;
494 anAxis.x = SpinBox_X->GetValue();
495 anAxis.y = SpinBox_Y->GetValue();
496 anAxis.z = SpinBox_Z->GetValue();;
497 anAxis.vx = SpinBox_DX->GetValue();
498 anAxis.vy = SpinBox_DY->GetValue();
499 anAxis.vz = SpinBox_DZ->GetValue();
501 double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
502 long aNbSteps = (long)SpinBox_NbSteps->value();
503 double aTolerance = SpinBox_Tolerance->GetValue();
505 if ( GroupAngle->checkedId() == 1 )
506 anAngle = anAngle/aNbSteps;
508 QStringList aParameters;
509 aParameters << SpinBox_X->text();
510 aParameters << SpinBox_Y->text();
511 aParameters << SpinBox_Z->text();
512 aParameters << SpinBox_DX->text();
513 aParameters << SpinBox_DY->text();
514 aParameters << SpinBox_DZ->text();
515 aParameters << SpinBox_Angle->text();
516 aParameters << SpinBox_NbSteps->text();
517 aParameters << SpinBox_Tolerance->text();
520 SUIT_OverrideCursor aWaitCursor;
521 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
523 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
525 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
526 if( CheckBoxMesh->isChecked() ) {
527 if( GetConstructorId() == 0 )
528 SMESH::ListOfGroups_var groups =
529 aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis,
530 anAngle, aNbSteps, aTolerance);
532 SMESH::ListOfGroups_var groups =
533 aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis,
534 anAngle, aNbSteps, aTolerance);
537 SMESH::ListOfGroups_var groups =
538 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
539 anAngle, aNbSteps, aTolerance);
542 if( CheckBoxMesh->isChecked() ) {
543 if( GetConstructorId() == 0 )
544 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
546 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance);
549 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
556 SMESH::Update(myIO, SMESH::eDisplay);
557 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
558 mySMESHGUI->updateObjBrowser(true); // new groups may appear
560 ConstructorsClicked(GetConstructorId());
561 mySelectedObject = SMESH::SMESH_IDSource::_nil();
562 SelectionIntoArgument();
564 SMESHGUI::Modified();
570 //=================================================================================
571 // function : ClickOnOk()
573 //=================================================================================
574 void SMESHGUI_RevolutionDlg::ClickOnOk()
580 //=================================================================================
581 // function : reject()
583 //=================================================================================
584 void SMESHGUI_RevolutionDlg::reject()
586 disconnect(mySelectionMgr, 0, this, 0);
587 mySelectionMgr->clearFilters();
588 //mySelectionMgr->clearSelected();
589 if (SMESH::GetCurrentVtkView()) {
590 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
591 SMESH::SetPointRepresentation(false);
593 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
594 aViewWindow->SetSelectionMode(ActorSelection);
595 mySMESHGUI->ResetState();
600 //=================================================================================
601 // function : ClickOnHelp()
603 //=================================================================================
604 void SMESHGUI_RevolutionDlg::ClickOnHelp()
606 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
608 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
612 platform = "winapplication";
614 platform = "application";
616 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
617 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
618 arg(app->resourceMgr()->stringValue("ExternalBrowser",
620 arg(myHelpFileName));
624 //=======================================================================
625 // function : onAngleTextChange()
627 //=======================================================================
628 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
631 SpinBox_Angle->text().toDouble( &isNumber );
633 RadioButton3->setChecked( true );
634 RadioButton4->setEnabled( isNumber );
637 //=======================================================================
638 // function : onTextChange()
640 //=======================================================================
641 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
643 QLineEdit* send = (QLineEdit*)sender();
648 if (send == LineEditElements)
651 buttonOk->setEnabled(false);
652 buttonApply->setEnabled(false);
654 // hilight entered elements
655 SMDS_Mesh* aMesh = 0;
657 aMesh = myActor->GetObject()->GetMesh();
660 if (send == LineEditElements) {
661 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
663 TColStd_MapOfInteger newIndices;
665 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
667 for (int i = 0; i < aListId.count(); i++) {
668 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
670 newIndices.Add(e->GetID());
674 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
675 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
676 aViewWindow->highlight( myActor->getIO(), true, true );
678 myElementsId = theNewText;
682 if (myNbOkElements && IsAxisOk()) {
683 buttonOk->setEnabled(true);
684 buttonApply->setEnabled(true);
686 onDisplaySimulation(true);
691 //=================================================================================
692 // function : SelectionIntoArgument()
693 // purpose : Called when selection as changed or other case
694 //=================================================================================
695 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
700 QString aString = "";
703 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
704 LineEditElements->setText(aString);
706 buttonOk->setEnabled(false);
707 buttonApply->setEnabled(false);
711 if (!GroupButtons->isEnabled()) // inactive
715 const SALOME_ListIO& aList = mySelector->StoredIObjects();
717 int nbSel = aList.Extent();
721 Handle(SALOME_InteractiveObject) IO = aList.First();
722 SMESH::SMESH_Mesh_var aMeshVar = SMESH::GetMeshByIO(IO);
723 if (aMeshVar->_is_nil())
726 SMESH_Actor* anActor = SMESH::FindActorByObject(aMeshVar);
728 anActor = SMESH::FindActorByEntry(IO->getEntry());
729 if (!anActor && !CheckBoxMesh->isChecked())
734 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
740 // MakeGroups is available if there are groups
741 if ( myMesh->NbGroups() == 0 ) {
742 MakeGroupsCheck->setChecked(false);
743 MakeGroupsCheck->setEnabled(false);
745 MakeGroupsCheck->setEnabled(true);
748 if (CheckBoxMesh->isChecked()) {
749 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
751 if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
752 mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
756 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
757 myElementsId = aString;
761 myNbOkElements = true;
764 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
768 bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
769 (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
770 myVectorDefinition==POINT_SELECT));
772 bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
773 myVectorDefinition==FACE_SELECT);
776 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
778 else if(isFaceSelected){
779 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
786 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
794 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
795 SpinBox_X->SetValue(x);
796 SpinBox_Y->SetValue(y);
797 SpinBox_Z->SetValue(z);
798 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
799 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
800 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
801 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
804 else if(isFaceSelected){
805 const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
809 gp_XYZ aNormale = SMESH::getNormale(face);
810 SpinBox_DX->SetValue(aNormale.X());
811 SpinBox_DY->SetValue(aNormale.Y());
812 SpinBox_DZ->SetValue(aNormale.Z());
818 if (myEditCurrentArgument == (QWidget*)LineEditElements)
819 LineEditElements->setText(aString);
823 if (myNbOkElements && IsAxisOk()) {
824 buttonOk->setEnabled(true);
825 buttonApply->setEnabled(true);
828 onDisplaySimulation(true);
831 //=================================================================================
832 // function : SetEditCurrentArgument()
834 //=================================================================================
835 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
837 QPushButton* send = (QPushButton*)sender();
839 disconnect(mySelectionMgr, 0, this, 0);
840 mySelectionMgr->clearSelected();
841 mySelectionMgr->clearFilters();
843 if (send == SelectElementsButton) {
844 mySimulation->SetVisibility(false);
845 myEditCurrentArgument = (QWidget*)LineEditElements;
846 SMESH::SetPointRepresentation(false);
847 if (CheckBoxMesh->isChecked()) {
848 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
849 aViewWindow->SetSelectionMode(ActorSelection);
850 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
852 int aConstructorId = GetConstructorId();
853 if (aConstructorId == 0)
855 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
856 aViewWindow->SetSelectionMode(EdgeSelection);
858 else if (aConstructorId == 1)
860 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861 aViewWindow->SetSelectionMode(FaceSelection);
864 } else if (send == SelectPointButton) {
865 myEditCurrentArgument = (QWidget*)SpinBox_X;
866 SMESH::SetPointRepresentation(true);
867 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
868 aViewWindow->SetSelectionMode(NodeSelection);
871 myEditCurrentArgument->setFocus();
872 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
873 SelectionIntoArgument();
876 //=================================================================================
877 // function : DeactivateActiveDialog()
879 //=================================================================================
880 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
882 if (ConstructorsBox->isEnabled()) {
883 ConstructorsBox->setEnabled(false);
884 GroupArguments->setEnabled(false);
885 GroupButtons->setEnabled(false);
886 mySMESHGUI->ResetState();
887 mySMESHGUI->SetActiveDialogBox(0);
891 //=================================================================================
892 // function : ActivateThisDialog()
894 //=================================================================================
895 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
897 /* Emit a signal to deactivate the active dialog */
898 mySMESHGUI->EmitSignalDeactivateDialog();
899 ConstructorsBox->setEnabled(true);
900 GroupArguments->setEnabled(true);
901 GroupButtons->setEnabled(true);
903 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
905 ConstructorsClicked(GetConstructorId());
906 SelectionIntoArgument();
909 //=================================================================================
910 // function : enterEvent()
912 //=================================================================================
913 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
915 if (!ConstructorsBox->isEnabled())
916 ActivateThisDialog();
919 //=======================================================================
920 //function : onSelectMesh
922 //=======================================================================
923 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
926 myIDs = LineEditElements->text();
927 TextLabelElements->setText(tr("SMESH_NAME"));
930 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
931 myFilterBtn->setEnabled(!toSelectMesh);
933 if (myEditCurrentArgument != LineEditElements) {
934 LineEditElements->clear();
935 mySimulation->SetVisibility(false);
939 mySelectionMgr->clearFilters();
940 SMESH::SetPointRepresentation(false);
943 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
944 aViewWindow->SetSelectionMode(ActorSelection);
945 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
946 LineEditElements->setReadOnly(true);
947 LineEditElements->setValidator(0);
949 int aConstructorId = GetConstructorId();
950 if (aConstructorId == 0)
952 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
953 aViewWindow->SetSelectionMode(EdgeSelection);
955 else if (aConstructorId == 1)
957 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
958 aViewWindow->SetSelectionMode(FaceSelection);
961 LineEditElements->setReadOnly(false);
962 LineEditElements->setValidator(myIdValidator);
963 onTextChange(LineEditElements->text());
964 mySimulation->SetVisibility(false);
967 SelectionIntoArgument();
970 LineEditElements->setText( myIDs );
973 //=================================================================================
974 // function : GetConstructorId()
976 //=================================================================================
977 int SMESHGUI_RevolutionDlg::GetConstructorId()
979 return GroupConstructors->checkedId();
982 //=================================================================================
983 // function : IsAxisOk()
985 //=================================================================================
986 bool SMESHGUI_RevolutionDlg::IsAxisOk()
988 return (SpinBox_DX->GetValue() != 0 ||
989 SpinBox_DY->GetValue() != 0 ||
990 SpinBox_DZ->GetValue() != 0);
993 //=================================================================================
994 // function : onVectorChanged()
996 //=================================================================================
997 void SMESHGUI_RevolutionDlg::onVectorChanged()
1000 buttonOk->setEnabled(true);
1001 buttonApply->setEnabled(true);
1003 buttonOk->setEnabled(false);
1004 buttonApply->setEnabled(false);
1006 onDisplaySimulation(true);
1009 //=================================================================================
1010 // function : keyPressEvent()
1012 //=================================================================================
1013 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1015 QDialog::keyPressEvent( e );
1016 if ( e->isAccepted() )
1019 if ( e->key() == Qt::Key_F1 ) {
1025 //=================================================================================
1026 // function : onDisplaySimulation()
1027 // purpose : Show/Hide preview
1028 //=================================================================================
1029 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1031 if (myPreviewCheckBox->isChecked() && toDisplayPreview)
1034 if (myNbOkElements && IsAxisOk())
1036 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1038 SMESH::long_array_var anElementsId = new SMESH::long_array;
1040 anElementsId->length(aListElementsId.count());
1041 for (int i = 0; i < aListElementsId.count(); i++)
1042 anElementsId[i] = aListElementsId[i].toInt();
1044 SMESH::AxisStruct anAxis;
1046 anAxis.x = SpinBox_X->GetValue();
1047 anAxis.y = SpinBox_Y->GetValue();
1048 anAxis.z = SpinBox_Z->GetValue();
1049 anAxis.vx = SpinBox_DX->GetValue();
1050 anAxis.vy = SpinBox_DY->GetValue();
1051 anAxis.vz = SpinBox_DZ->GetValue();
1053 double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
1054 long aNbSteps = (long)SpinBox_NbSteps->value();
1055 double aTolerance = SpinBox_Tolerance->GetValue();
1057 if (GroupAngle->checkedId() == 1)
1058 anAngle = anAngle/aNbSteps;
1061 SUIT_OverrideCursor aWaitCursor;
1062 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1063 if( CheckBoxMesh->isChecked() ) {
1064 if( GetConstructorId() == 0 )
1065 aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis,
1066 anAngle, aNbSteps, aTolerance);
1068 aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis,
1069 anAngle, aNbSteps, aTolerance);
1072 aMeshEditor->RotationSweep(anElementsId.inout(),
1077 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1078 mySimulation->SetData(aMeshPreviewStruct._retn());
1083 mySimulation->SetVisibility(false);
1089 mySimulation->SetVisibility(false);
1093 //=================================================================================
1094 // function : onSelectVectorButton()
1096 //=================================================================================
1097 void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
1098 if(SelectVectorMenu) {
1099 SelectVectorMenu->exec( QCursor::pos() );
1103 //=================================================================================
1104 // function : onSelectVectorMenu()
1106 //=================================================================================
1107 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
1111 disconnect(mySelectionMgr, 0, this, 0);
1113 switch(myMenuActions[action]) {
1115 SMESH::SetPointRepresentation(true);
1116 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1117 aViewWindow->SetSelectionMode(NodeSelection);
1121 SMESH::SetPointRepresentation(false);
1122 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1123 aViewWindow->SetSelectionMode(FaceSelection);
1127 myVectorDefinition = myMenuActions[action];
1128 myEditCurrentArgument = (QWidget*)SpinBox_DX;
1129 myEditCurrentArgument->setFocus();
1130 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1131 SelectionIntoArgument();
1134 //=================================================================================
1135 // function : setFilters()
1136 // purpose : SLOT. Called when "Filter" button pressed.
1137 //=================================================================================
1138 void SMESHGUI_RevolutionDlg::setFilters()
1140 if(myMesh->_is_nil()) {
1141 SUIT_MessageBox::critical(this,
1143 tr("NO_MESH_SELECTED"));
1149 types.append( SMESH::EDGE );
1150 types.append( SMESH::FACE );
1151 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1153 myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
1155 myFilterDlg->SetSelection();
1156 myFilterDlg->SetMesh( myMesh );
1157 myFilterDlg->SetSourceWg( LineEditElements );
1159 myFilterDlg->show();
1162 //=================================================================================
1163 // function : isValid
1165 //=================================================================================
1166 bool SMESHGUI_RevolutionDlg::isValid()
1170 ok = SpinBox_X->isValid( msg, true ) && ok;
1171 ok = SpinBox_Y->isValid( msg, true ) && ok;
1172 ok = SpinBox_Z->isValid( msg, true ) && ok;
1173 ok = SpinBox_DX->isValid( msg, true ) && ok;
1174 ok = SpinBox_DY->isValid( msg, true ) && ok;
1175 ok = SpinBox_DZ->isValid( msg, true ) && ok;
1176 ok = SpinBox_Angle->isValid( msg, true ) && ok;
1177 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
1178 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
1181 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1182 if ( !msg.isEmpty() )
1184 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );