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
24 // File : SMESHGUI_RevolutionDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_RevolutionDlg.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
37 #include "SMESHGUI_MeshEditPreview.h"
39 #include "SMESH_Actor.h"
40 #include "SMESH_TypeFilter.hxx"
41 #include "SMESH_LogicalFilter.hxx"
42 #include "SMDS_Mesh.hxx"
44 #include "SUIT_ResourceMgr.h"
45 #include "SUIT_Session.h"
46 #include "SUIT_MessageBox.h"
47 #include "SUIT_OverrideCursor.h"
49 #include "LightApp_Application.h"
50 #include "SalomeApp_Application.h"
52 #include "SVTK_ViewModel.h"
53 #include "SVTK_ViewWindow.h"
54 #include "SVTK_Selector.h"
55 #include "SVTK_Selection.h"
56 #include "SALOME_ListIO.hxx"
57 #include "VTKViewer_CellLocationsArray.h"
59 #include "utilities.h"
62 #include <TColStd_MapOfInteger.hxx>
65 #include <qapplication.h>
66 #include <qbuttongroup.h>
67 #include <qgroupbox.h>
69 #include <qlineedit.h>
70 #include <qpushbutton.h>
71 #include <qradiobutton.h>
72 #include <qcheckbox.h>
75 #include <qvalidator.h>
79 #include "SALOMEconfig.h"
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
85 //=================================================================================
86 // class : SMESHGUI_RevolutionDlg()
88 //=================================================================================
90 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name,
91 bool modal, WFlags fl)
92 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
93 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
94 mySMESHGUI( theModule ),
95 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
97 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
99 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
100 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
101 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
102 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
105 setName("SMESHGUI_RevolutionDlg");
107 setCaption(tr("REVOLUTION_AROUND_AXIS"));
108 setSizeGripEnabled(TRUE);
109 SMESHGUI_RevolutionDlgLayout = new QGridLayout(this);
110 SMESHGUI_RevolutionDlgLayout->setSpacing(6);
111 SMESHGUI_RevolutionDlgLayout->setMargin(11);
113 /***************************************************************/
114 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
115 GroupConstructors->setTitle(tr("SMESH_REVOLUTION" ));
116 GroupConstructors->setExclusive(TRUE);
117 GroupConstructors->setColumnLayout(0, Qt::Vertical);
118 GroupConstructors->layout()->setSpacing(0);
119 GroupConstructors->layout()->setMargin(0);
120 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
121 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
122 GroupConstructorsLayout->setSpacing(6);
123 GroupConstructorsLayout->setMargin(11);
124 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
125 RadioButton1->setText(tr("" ));
126 RadioButton1->setPixmap(image0);
127 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
128 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
129 RadioButton2->setText(tr("" ));
130 RadioButton2->setPixmap(image1);
131 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
132 SMESHGUI_RevolutionDlgLayout->addWidget(GroupConstructors, 0, 0);
134 /***************************************************************/
135 GroupButtons = new QGroupBox(this, "GroupButtons");
136 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
137 GroupButtons->setTitle(tr("" ));
138 GroupButtons->setColumnLayout(0, Qt::Vertical);
139 GroupButtons->layout()->setSpacing(0);
140 GroupButtons->layout()->setMargin(0);
141 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
142 GroupButtonsLayout->setAlignment(Qt::AlignTop);
143 GroupButtonsLayout->setSpacing(6);
144 GroupButtonsLayout->setMargin(11);
145 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
146 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
147 buttonHelp->setAutoDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
149 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
150 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
151 buttonCancel->setAutoDefault(TRUE);
152 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
153 buttonApply = new QPushButton(GroupButtons, "buttonApply");
154 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
155 buttonApply->setAutoDefault(TRUE);
156 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
157 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
158 GroupButtonsLayout->addItem(spacer_9, 0, 2);
159 buttonOk = new QPushButton(GroupButtons, "buttonOk");
160 buttonOk->setText(tr("SMESH_BUT_OK" ));
161 buttonOk->setAutoDefault(TRUE);
162 buttonOk->setDefault(TRUE);
163 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
164 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons, 2, 0);
166 /***************************************************************/
167 GroupArguments = new QGroupBox(this, "GroupArguments");
168 GroupArguments->setTitle(tr("REVOLUTION_1D"));
169 GroupArguments->setColumnLayout(0, Qt::Vertical);
170 GroupArguments->layout()->setSpacing(0);
171 GroupArguments->layout()->setMargin(0);
172 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
173 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
174 GroupArgumentsLayout->setSpacing(6);
175 GroupArgumentsLayout->setMargin(11);
177 // Controls for elements selection
178 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
179 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
180 TextLabelElements->setFixedWidth(74);
181 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
183 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
184 SelectElementsButton->setText(tr("" ));
185 SelectElementsButton->setPixmap(image2);
186 SelectElementsButton->setToggleButton(FALSE);
187 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
189 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
190 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
191 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
193 // Control for the whole mesh selection
194 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
195 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
196 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 3);
198 // Controls for axis defining
199 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
200 GroupAxis->setTitle(tr("SMESH_AXIS"));
201 GroupAxis->setColumnLayout(0, Qt::Vertical);
202 GroupAxis->layout()->setSpacing(0);
203 GroupAxis->layout()->setMargin(0);
204 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
205 GroupAxisLayout->setAlignment(Qt::AlignTop);
206 GroupAxisLayout->setSpacing(6);
207 GroupAxisLayout->setMargin(11);
209 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
210 TextLabelPoint->setText(tr("SMESH_POINT"));
211 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
213 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
214 SelectPointButton->setPixmap(image2);
215 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
217 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
218 TextLabelX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
219 TextLabelX->setText(tr("SMESH_X"));
220 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
222 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
223 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
225 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
226 TextLabelY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
227 TextLabelY->setText(tr("SMESH_Y"));
228 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
230 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
231 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
233 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
234 TextLabelZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
235 TextLabelZ->setText(tr("SMESH_Z"));
236 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
238 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
239 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
241 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
242 TextLabelVector->setText(tr("SMESH_VECTOR"));
243 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
245 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
246 SelectVectorButton->setPixmap(image2);
247 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
249 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
250 TextLabelDX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
251 TextLabelDX->setText(tr("SMESH_DX"));
252 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
254 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
255 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
257 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
258 TextLabelDY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
259 TextLabelDY->setText(tr("SMESH_DY"));
260 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
262 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
263 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
265 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
266 TextLabelDZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
267 TextLabelDZ->setText(tr("SMESH_DZ"));
268 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
270 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
271 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
273 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3);
275 // Controls for angle defining
276 GroupAngle = new QButtonGroup(GroupArguments, "GroupAngle");
277 GroupAngle->setTitle(tr("SMESH_ANGLE"));
278 GroupAngle->setExclusive(TRUE);
279 GroupAngle->setColumnLayout(0, Qt::Horizontal);
280 GroupAngle->layout()->setSpacing(0);
281 GroupAngle->layout()->setMargin(0);
282 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngle->layout());
283 GroupAngleLayout->setAlignment(Qt::AlignTop);
284 GroupAngleLayout->setSpacing(6);
285 GroupAngleLayout->setMargin(11);
287 RadioButton3 = new QRadioButton(GroupAngle, "RadioButton3");
288 RadioButton3->setText(tr("ANGLE_BY_STEP"));
289 GroupAngleLayout->addMultiCellWidget(RadioButton3, 0, 0, 0, 1);
291 RadioButton4 = new QRadioButton(GroupAngle, "RadioButton4");
292 RadioButton4->setText(tr("TOTAL_ANGLE"));
293 GroupAngleLayout->addWidget(RadioButton4, 0, 2);
295 TextLabelAngle = new QLabel(GroupAngle, "TextLabelAngle");
296 TextLabelAngle->setText(tr("SMESH_ANGLE"));
297 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
299 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngle, "SpinBox_Angle");
300 GroupAngleLayout->addMultiCellWidget(SpinBox_Angle, 1, 1, 1, 2);
302 // Controls for number of steps defining
303 TextLabelNbSteps = new QLabel(GroupAngle, "TextLabelNbSteps");
304 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
305 TextLabelNbSteps->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
306 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
308 SpinBox_NbSteps = new QSpinBox(GroupAngle, "SpinBox_NbSteps");
309 GroupAngleLayout->addMultiCellWidget(SpinBox_NbSteps, 2, 2, 1, 2);
311 GroupArgumentsLayout->addMultiCellWidget(GroupAngle, 3, 3, 0, 3);
313 // Controls for tolerance defining
314 TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance");
315 TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
316 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0);
318 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
319 GroupArgumentsLayout->addMultiCellWidget(SpinBox_Tolerance, 4, 4, 1, 3);
321 // CheckBox for groups generation
322 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
323 MakeGroupsCheck->setChecked(true);
324 GroupArgumentsLayout->addMultiCellWidget(MakeGroupsCheck, 6, 6, 0, 3);
326 // Control for mesh preview
327 CheckBoxPreview = new QCheckBox(GroupArguments, "CheckBoxPreview");
328 CheckBoxPreview->setText(tr("PREVIEW" ));
329 GroupArgumentsLayout->addMultiCellWidget(CheckBoxPreview, 5, 5, 0, 3);
331 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0);
333 /* Initialisations */
334 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
335 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
336 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
337 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
338 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
339 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
341 RadioButton3->setChecked(TRUE);
343 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
345 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
346 SpinBox_NbSteps->setValidator(anIntValidator);
347 SpinBox_NbSteps->setRange(1, 999999);
349 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 6);
351 GroupArguments->show();
352 RadioButton1->setChecked(TRUE);
354 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
356 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
358 // Costruction of the logical filter
359 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
360 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
362 QPtrList<SUIT_SelectionFilter> aListOfFilters;
363 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
364 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
366 myMeshOrSubMeshOrGroupFilter =
367 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
369 myHelpFileName = "revolution_page.html";
373 /* signals and slots connections */
374 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
375 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
376 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
377 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
378 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
380 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
381 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
382 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
384 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
385 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
386 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
388 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
389 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
390 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
392 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
393 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
394 /* to close dialog if study change */
395 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
396 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
397 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
399 connect(GroupAngle, SIGNAL(clicked(int)), SLOT(toDisplaySimulation()));
400 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
401 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
402 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
403 connect(CheckBoxPreview, SIGNAL(toggled(bool)), SLOT(onDisplaySimulation(bool)));
405 this->show(); /* displays Dialog */
407 ConstructorsClicked(0);
408 SelectionIntoArgument();
412 //=================================================================================
413 // function : ~SMESHGUI_RevolutionDlg()
414 // purpose : Destroys the object and frees any allocated resources
415 //=================================================================================
416 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
419 // no need to delete child widgets, Qt does it all for us
422 //=================================================================================
425 //=================================================================================
426 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
430 myEditCurrentArgument = 0;
431 LineEditElements->clear();
436 myMesh = SMESH::SMESH_Mesh::_nil();
439 SpinBox_X->SetValue(0.0);
440 SpinBox_Y->SetValue(0.0);
441 SpinBox_Z->SetValue(0.0);
442 SpinBox_DX->SetValue(0.0);
443 SpinBox_DY->SetValue(0.0);
444 SpinBox_DZ->SetValue(0.0);
446 SpinBox_Angle->SetValue(45);
447 SpinBox_NbSteps->setValue(1);
448 SpinBox_Tolerance->SetValue(1e-05);
450 CheckBoxMesh->setChecked(false);
452 CheckBoxPreview->setChecked(false);
453 onDisplaySimulation(false);
457 //=================================================================================
458 // function : ConstructorsClicked()
459 // purpose : Radio button management
460 //=================================================================================
461 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
463 //disconnect(mySelectionMgr, 0, this, 0);
466 mySelectionMgr->selectedObjects( io );
468 mySelectionMgr->setSelectedObjects( aList );
469 // LineEditElements->clear();
471 buttonApply->setEnabled(false);
472 buttonOk->setEnabled(false);
473 mySimulation->SetVisibility(false);
475 Selection_Mode aSelMode = ActorSelection;
477 switch (constructorId) {
480 GroupArguments->setTitle(tr("REVOLUTION_1D"));
481 aSelMode = EdgeSelection;
486 GroupArguments->setTitle(tr("REVOLUTION_2D"));
487 aSelMode = FaceSelection;
492 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
493 SMESH::SetPointRepresentation(false);
496 if (!CheckBoxMesh->isChecked())
498 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
499 aViewWindow->SetSelectionMode(aSelMode);
502 myEditCurrentArgument = (QWidget*)LineEditElements;
503 LineEditElements->setFocus();
505 if (CheckBoxMesh->isChecked())
508 //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
509 mySelectionMgr->setSelectedObjects( io );
512 //=================================================================================
513 // function : ClickOnApply()
515 //=================================================================================
516 void SMESHGUI_RevolutionDlg::ClickOnApply()
518 if (mySMESHGUI->isActiveStudyLocked())
521 if (myNbOkElements && IsAxisOk()) {
522 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
524 SMESH::long_array_var anElementsId = new SMESH::long_array;
526 anElementsId->length(aListElementsId.count());
527 for (int i = 0; i < aListElementsId.count(); i++)
528 anElementsId[i] = aListElementsId[i].toInt();
530 SMESH::AxisStruct anAxis;
532 anAxis.x = SpinBox_X->GetValue();
533 anAxis.y = SpinBox_Y->GetValue();
534 anAxis.z = SpinBox_Z->GetValue();;
535 anAxis.vx = SpinBox_DX->GetValue();
536 anAxis.vy = SpinBox_DY->GetValue();
537 anAxis.vz = SpinBox_DZ->GetValue();
539 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
540 long aNbSteps = (long)SpinBox_NbSteps->value();
541 double aTolerance = SpinBox_Tolerance->GetValue();
543 if (GroupAngle->selectedId() == 1)
544 anAngle = anAngle/aNbSteps;
547 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
548 QApplication::setOverrideCursor(Qt::waitCursor);
550 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
551 SMESH::ListOfGroups_var groups =
552 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
553 anAngle, aNbSteps, aTolerance);
555 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
557 QApplication::restoreOverrideCursor();
562 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
563 mySMESHGUI->updateObjBrowser(true); // new groups may appear
565 ConstructorsClicked(GetConstructorId());
566 SelectionIntoArgument();
570 //=================================================================================
571 // function : ClickOnOk()
573 //=================================================================================
574 void SMESHGUI_RevolutionDlg::ClickOnOk()
580 //=================================================================================
581 // function : ClickOnCancel()
583 //=================================================================================
584 void SMESHGUI_RevolutionDlg::ClickOnCancel()
586 disconnect(mySelectionMgr, 0, this, 0);
587 mySelectionMgr->clearFilters();
588 //mySelectionMgr->clearSelected();
589 SMESH::SetPointRepresentation(false);
590 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
591 aViewWindow->SetSelectionMode(ActorSelection);
592 mySMESHGUI->ResetState();
596 //=================================================================================
597 // function : ClickOnHelp()
599 //=================================================================================
600 void SMESHGUI_RevolutionDlg::ClickOnHelp()
602 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
604 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
608 platform = "winapplication";
610 platform = "application";
612 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
613 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
614 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
615 QObject::tr("BUT_OK"));
619 //=======================================================================
620 // function : onTextChange()
622 //=======================================================================
623 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
625 QLineEdit* send = (QLineEdit*)sender();
630 if (send == LineEditElements)
633 buttonOk->setEnabled(false);
634 buttonApply->setEnabled(false);
636 // hilight entered elements
637 SMDS_Mesh* aMesh = 0;
639 aMesh = myActor->GetObject()->GetMesh();
642 if (send == LineEditElements) {
643 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
645 TColStd_MapOfInteger newIndices;
647 QStringList aListId = QStringList::split(" ", theNewText, false);
649 for (int i = 0; i < aListId.count(); i++) {
650 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
652 newIndices.Add(e->GetID());
656 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
657 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
658 aViewWindow->highlight( myActor->getIO(), true, true );
660 myElementsId = theNewText;
664 if (myNbOkElements && IsAxisOk()) {
665 buttonOk->setEnabled(true);
666 buttonApply->setEnabled(true);
668 onDisplaySimulation(true);
673 //=================================================================================
674 // function : SelectionIntoArgument()
675 // purpose : Called when selection as changed or other case
676 //=================================================================================
677 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
683 QString aString = "";
686 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
687 LineEditElements->setText(aString);
689 buttonOk->setEnabled(false);
690 buttonApply->setEnabled(false);
694 if (!GroupButtons->isEnabled()) // inactive
698 const SALOME_ListIO& aList = mySelector->StoredIObjects();
700 int nbSel = aList.Extent();
704 Handle(SALOME_InteractiveObject) IO = aList.First();
705 myMesh = SMESH::GetMeshByIO(IO);
706 if (myMesh->_is_nil())
709 myActor = SMESH::FindActorByObject(myMesh);
711 myActor = SMESH::FindActorByEntry(IO->getEntry());
717 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
720 // MakeGroups is available if there are groups
721 if ( myMesh->NbGroups() == 0 ) {
722 MakeGroupsCheck->setChecked(false);
723 MakeGroupsCheck->setEnabled(false);
725 MakeGroupsCheck->setEnabled(true);
728 if (CheckBoxMesh->isChecked()) {
729 int aConstructorId = GetConstructorId();
731 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
733 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
735 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
739 if (aConstructorId == 0) {
740 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
742 while (anIter->more()) {
743 const SMDS_MeshEdge * edge = anIter->next();
745 myElementsId += QString(" %1").arg(edge->GetID());
749 } else if (aConstructorId == 1) {
750 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
751 while (anIter->more()) {
752 const SMDS_MeshFace * face = anIter->next();
754 myElementsId += QString(" %1").arg(face->GetID());
759 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
761 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
763 // get IDs from submesh
764 SMESH::long_array_var anElementsIds = new SMESH::long_array;
765 if (aConstructorId == 0)
766 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
767 else if (aConstructorId == 1)
768 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
770 for (int i = 0; i < anElementsIds->length(); i++)
771 myElementsId += QString(" %1").arg(anElementsIds[i]);
772 aNbUnits = anElementsIds->length();
775 SMESH::SMESH_GroupBase_var aGroup =
776 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
777 if (aGroup->_is_nil())
780 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
781 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
784 // get IDs from smesh group
785 SMESH::long_array_var anElementsIds = new SMESH::long_array;
786 anElementsIds = aGroup->GetListOfID();
787 for (int i = 0; i < anElementsIds->length(); i++) {
788 myElementsId += QString(" %1").arg(anElementsIds[i]);
790 aNbUnits = anElementsIds->length();
793 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
794 myElementsId = aString;
800 myNbOkElements = true;
802 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
806 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
810 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
818 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
819 SpinBox_X->SetValue(x);
820 SpinBox_Y->SetValue(y);
821 SpinBox_Z->SetValue(z);
822 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
823 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
824 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
825 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
830 if (myEditCurrentArgument == (QWidget*)LineEditElements)
831 LineEditElements->setText(aString);
835 if (myNbOkElements && IsAxisOk()) {
836 buttonOk->setEnabled(true);
837 buttonApply->setEnabled(true);
840 onDisplaySimulation(true);
843 //=================================================================================
844 // function : SetEditCurrentArgument()
846 //=================================================================================
847 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
849 QPushButton* send = (QPushButton*)sender();
851 disconnect(mySelectionMgr, 0, this, 0);
852 mySelectionMgr->clearSelected();
853 mySelectionMgr->clearFilters();
855 if (send == SelectElementsButton) {
856 mySimulation->SetVisibility(false);
857 myEditCurrentArgument = (QWidget*)LineEditElements;
858 SMESH::SetPointRepresentation(false);
859 if (CheckBoxMesh->isChecked()) {
860 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861 aViewWindow->SetSelectionMode(ActorSelection);
862 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
864 int aConstructorId = GetConstructorId();
865 if (aConstructorId == 0)
867 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
868 aViewWindow->SetSelectionMode(EdgeSelection);
870 else if (aConstructorId == 1)
872 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
873 aViewWindow->SetSelectionMode(FaceSelection);
877 } else if (send == SelectPointButton) {
878 myEditCurrentArgument = (QWidget*)SpinBox_X;
879 SMESH::SetPointRepresentation(true);
880 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
881 aViewWindow->SetSelectionMode(NodeSelection);
882 } else if (send == SelectVectorButton) {
883 myEditCurrentArgument = (QWidget*)SpinBox_DX;
884 SMESH::SetPointRepresentation(true);
885 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
886 aViewWindow->SetSelectionMode(NodeSelection);
890 myEditCurrentArgument->setFocus();
891 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
892 SelectionIntoArgument();
895 //=================================================================================
896 // function : DeactivateActiveDialog()
898 //=================================================================================
899 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
901 if (GroupConstructors->isEnabled()) {
902 GroupConstructors->setEnabled(false);
903 GroupArguments->setEnabled(false);
904 GroupButtons->setEnabled(false);
905 mySMESHGUI->ResetState();
906 mySMESHGUI->SetActiveDialogBox(0);
910 //=================================================================================
911 // function : ActivateThisDialog()
913 //=================================================================================
914 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
916 /* Emit a signal to deactivate the active dialog */
917 mySMESHGUI->EmitSignalDeactivateDialog();
918 GroupConstructors->setEnabled(true);
919 GroupArguments->setEnabled(true);
920 GroupButtons->setEnabled(true);
922 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
924 ConstructorsClicked(GetConstructorId());
925 SelectionIntoArgument();
928 //=================================================================================
929 // function : enterEvent()
931 //=================================================================================
932 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
934 if (!GroupConstructors->isEnabled())
935 ActivateThisDialog();
938 //=================================================================================
939 // function : closeEvent()
941 //=================================================================================
942 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
944 /* same than click on cancel button */
945 this->ClickOnCancel();
948 //=======================================================================
949 // function : hideEvent()
950 // purpose : caused by ESC key
951 //=======================================================================
952 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
958 //=======================================================================
959 //function : onSelectMesh
961 //=======================================================================
962 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
965 TextLabelElements->setText(tr("SMESH_NAME"));
967 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
969 if (myEditCurrentArgument != LineEditElements) {
970 LineEditElements->clear();
971 mySimulation->SetVisibility(false);
975 mySelectionMgr->clearFilters();
976 SMESH::SetPointRepresentation(false);
979 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
980 aViewWindow->SetSelectionMode(ActorSelection);
981 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
982 LineEditElements->setReadOnly(true);
984 int aConstructorId = GetConstructorId();
985 if (aConstructorId == 0)
987 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
988 aViewWindow->SetSelectionMode(EdgeSelection);
990 else if (aConstructorId == 0)
992 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
993 aViewWindow->SetSelectionMode(FaceSelection);
996 LineEditElements->setReadOnly(false);
997 onTextChange(LineEditElements->text());
998 mySimulation->SetVisibility(false);
1001 SelectionIntoArgument();
1004 //=================================================================================
1005 // function : GetConstructorId()
1007 //=================================================================================
1008 int SMESHGUI_RevolutionDlg::GetConstructorId()
1010 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
1011 return GroupConstructors->id(GroupConstructors->selected());
1015 //=================================================================================
1016 // function : IsAxisOk()
1018 //=================================================================================
1019 bool SMESHGUI_RevolutionDlg::IsAxisOk()
1021 return (SpinBox_DX->GetValue() != 0 ||
1022 SpinBox_DY->GetValue() != 0 ||
1023 SpinBox_DZ->GetValue() != 0);
1026 //=================================================================================
1027 // function : onVectorChanged()
1029 //=================================================================================
1030 void SMESHGUI_RevolutionDlg::onVectorChanged()
1033 buttonOk->setEnabled(true);
1034 buttonApply->setEnabled(true);
1036 buttonOk->setEnabled(false);
1037 buttonApply->setEnabled(false);
1039 onDisplaySimulation(true);
1042 //=================================================================================
1043 // function : keyPressEvent()
1045 //=================================================================================
1046 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1048 QDialog::keyPressEvent( e );
1049 if ( e->isAccepted() )
1052 if ( e->key() == Key_F1 )
1059 //=================================================================================
1060 // function : toDisplaySimulation()
1062 //=================================================================================
1063 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1065 onDisplaySimulation(true);
1068 //=================================================================================
1069 // function : onDisplaySimulation()
1071 //=================================================================================
1072 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1074 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1077 if (myNbOkElements && IsAxisOk()) {
1078 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
1080 SMESH::long_array_var anElementsId = new SMESH::long_array;
1082 anElementsId->length(aListElementsId.count());
1083 for (int i = 0; i < aListElementsId.count(); i++)
1084 anElementsId[i] = aListElementsId[i].toInt();
1086 SMESH::AxisStruct anAxis;
1088 anAxis.x = SpinBox_X->GetValue();
1089 anAxis.y = SpinBox_Y->GetValue();
1090 anAxis.z = SpinBox_Z->GetValue();
1091 anAxis.vx = SpinBox_DX->GetValue();
1092 anAxis.vy = SpinBox_DY->GetValue();
1093 anAxis.vz = SpinBox_DZ->GetValue();
1095 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1096 long aNbSteps = (long)SpinBox_NbSteps->value();
1097 double aTolerance = SpinBox_Tolerance->GetValue();
1099 if (GroupAngle->selectedId() == 1)
1100 anAngle = anAngle/aNbSteps;
1103 SUIT_OverrideCursor aWaitCursor;
1104 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1105 aMeshEditor->RotationSweep(anElementsId.inout(),
1110 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1111 mySimulation->SetData(aMeshPreviewStruct._retn());
1116 mySimulation->SetVisibility(false);
1122 mySimulation->SetVisibility(false);