1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_RevolutionDlg.cxx
24 // Author : Michael ZORIN
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"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
41 #include "SMDS_Mesh.hxx"
43 #include "SUIT_ResourceMgr.h"
44 #include "SUIT_Session.h"
45 #include "SUIT_MessageBox.h"
46 #include "SUIT_OverrideCursor.h"
48 #include "LightApp_Application.h"
49 #include "SalomeApp_Application.h"
51 #include "SVTK_ViewModel.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_Selector.h"
54 #include "SVTK_Selection.h"
55 #include "SALOME_ListIO.hxx"
56 #include "VTKViewer_CellLocationsArray.h"
58 #include "utilities.h"
61 #include <TColStd_MapOfInteger.hxx>
64 #include <qapplication.h>
65 #include <qbuttongroup.h>
66 #include <qgroupbox.h>
68 #include <qlineedit.h>
69 #include <qpushbutton.h>
70 #include <qradiobutton.h>
71 #include <qcheckbox.h>
74 #include <qvalidator.h>
78 #include "SALOMEconfig.h"
79 #include CORBA_SERVER_HEADER(SMESH_Group)
80 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
84 //=================================================================================
85 // class : SMESHGUI_RevolutionDlg()
87 //=================================================================================
89 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name,
90 bool modal, WFlags fl)
91 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
92 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
93 mySMESHGUI( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
96 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
98 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
99 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
100 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
101 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
104 setName("SMESHGUI_RevolutionDlg");
106 setCaption(tr("REVOLUTION_AROUND_AXIS"));
107 setSizeGripEnabled(TRUE);
108 SMESHGUI_RevolutionDlgLayout = new QGridLayout(this);
109 SMESHGUI_RevolutionDlgLayout->setSpacing(6);
110 SMESHGUI_RevolutionDlgLayout->setMargin(11);
112 /***************************************************************/
113 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
114 GroupConstructors->setTitle(tr("SMESH_REVOLUTION" ));
115 GroupConstructors->setExclusive(TRUE);
116 GroupConstructors->setColumnLayout(0, Qt::Vertical);
117 GroupConstructors->layout()->setSpacing(0);
118 GroupConstructors->layout()->setMargin(0);
119 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
120 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
121 GroupConstructorsLayout->setSpacing(6);
122 GroupConstructorsLayout->setMargin(11);
123 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
124 RadioButton1->setText(tr("" ));
125 RadioButton1->setPixmap(image0);
126 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
127 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
128 RadioButton2->setText(tr("" ));
129 RadioButton2->setPixmap(image1);
130 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
131 SMESHGUI_RevolutionDlgLayout->addWidget(GroupConstructors, 0, 0);
133 /***************************************************************/
134 GroupButtons = new QGroupBox(this, "GroupButtons");
135 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
136 GroupButtons->setTitle(tr("" ));
137 GroupButtons->setColumnLayout(0, Qt::Vertical);
138 GroupButtons->layout()->setSpacing(0);
139 GroupButtons->layout()->setMargin(0);
140 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
141 GroupButtonsLayout->setAlignment(Qt::AlignTop);
142 GroupButtonsLayout->setSpacing(6);
143 GroupButtonsLayout->setMargin(11);
144 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
145 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
146 buttonHelp->setAutoDefault(TRUE);
147 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
148 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
149 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
150 buttonCancel->setAutoDefault(TRUE);
151 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
152 buttonApply = new QPushButton(GroupButtons, "buttonApply");
153 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
154 buttonApply->setAutoDefault(TRUE);
155 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
156 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
157 GroupButtonsLayout->addItem(spacer_9, 0, 2);
158 buttonOk = new QPushButton(GroupButtons, "buttonOk");
159 buttonOk->setText(tr("SMESH_BUT_APPLY_AND_CLOSE" ));
160 buttonOk->setAutoDefault(TRUE);
161 buttonOk->setDefault(TRUE);
162 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
163 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons, 2, 0);
165 /***************************************************************/
166 GroupArguments = new QGroupBox(this, "GroupArguments");
167 GroupArguments->setTitle(tr("REVOLUTION_1D"));
168 GroupArguments->setColumnLayout(0, Qt::Vertical);
169 GroupArguments->layout()->setSpacing(0);
170 GroupArguments->layout()->setMargin(0);
171 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
172 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
173 GroupArgumentsLayout->setSpacing(6);
174 GroupArgumentsLayout->setMargin(11);
176 // Controls for elements selection
177 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
178 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
179 TextLabelElements->setFixedWidth(74);
180 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
182 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
183 SelectElementsButton->setText(tr("" ));
184 SelectElementsButton->setPixmap(image2);
185 SelectElementsButton->setToggleButton(FALSE);
186 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
188 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
189 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
190 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
192 // Control for the whole mesh selection
193 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
194 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
195 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 3);
197 // Controls for axis defining
198 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
199 GroupAxis->setTitle(tr("SMESH_AXIS"));
200 GroupAxis->setColumnLayout(0, Qt::Vertical);
201 GroupAxis->layout()->setSpacing(0);
202 GroupAxis->layout()->setMargin(0);
203 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
204 GroupAxisLayout->setAlignment(Qt::AlignTop);
205 GroupAxisLayout->setSpacing(6);
206 GroupAxisLayout->setMargin(11);
208 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
209 TextLabelPoint->setText(tr("SMESH_POINT"));
210 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
212 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
213 SelectPointButton->setPixmap(image2);
214 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
216 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
217 TextLabelX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
218 TextLabelX->setText(tr("SMESH_X"));
219 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
221 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
222 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
224 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
225 TextLabelY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
226 TextLabelY->setText(tr("SMESH_Y"));
227 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
229 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
230 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
232 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
233 TextLabelZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
234 TextLabelZ->setText(tr("SMESH_Z"));
235 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
237 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
238 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
240 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
241 TextLabelVector->setText(tr("SMESH_VECTOR"));
242 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
244 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
245 SelectVectorButton->setPixmap(image2);
246 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
248 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
249 TextLabelDX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
250 TextLabelDX->setText(tr("SMESH_DX"));
251 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
253 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
254 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
256 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
257 TextLabelDY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
258 TextLabelDY->setText(tr("SMESH_DY"));
259 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
261 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
262 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
264 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
265 TextLabelDZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
266 TextLabelDZ->setText(tr("SMESH_DZ"));
267 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
269 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
270 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
272 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3);
274 // Controls for angle defining
275 GroupAngle = new QButtonGroup(GroupArguments, "GroupAngle");
276 GroupAngle->setTitle(tr("SMESH_ANGLE"));
277 GroupAngle->setExclusive(TRUE);
278 GroupAngle->setColumnLayout(0, Qt::Horizontal);
279 GroupAngle->layout()->setSpacing(0);
280 GroupAngle->layout()->setMargin(0);
281 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngle->layout());
282 GroupAngleLayout->setAlignment(Qt::AlignTop);
283 GroupAngleLayout->setSpacing(6);
284 GroupAngleLayout->setMargin(11);
286 RadioButton3 = new QRadioButton(GroupAngle, "RadioButton3");
287 RadioButton3->setText(tr("ANGLE_BY_STEP"));
288 GroupAngleLayout->addMultiCellWidget(RadioButton3, 0, 0, 0, 1);
290 RadioButton4 = new QRadioButton(GroupAngle, "RadioButton4");
291 RadioButton4->setText(tr("TOTAL_ANGLE"));
292 GroupAngleLayout->addWidget(RadioButton4, 0, 2);
294 TextLabelAngle = new QLabel(GroupAngle, "TextLabelAngle");
295 TextLabelAngle->setText(tr("SMESH_ANGLE"));
296 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
298 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngle, "SpinBox_Angle");
299 GroupAngleLayout->addMultiCellWidget(SpinBox_Angle, 1, 1, 1, 2);
301 // Controls for number of steps defining
302 TextLabelNbSteps = new QLabel(GroupAngle, "TextLabelNbSteps");
303 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
304 TextLabelNbSteps->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
305 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
307 SpinBox_NbSteps = new QSpinBox(GroupAngle, "SpinBox_NbSteps");
308 GroupAngleLayout->addMultiCellWidget(SpinBox_NbSteps, 2, 2, 1, 2);
310 GroupArgumentsLayout->addMultiCellWidget(GroupAngle, 3, 3, 0, 3);
312 // Controls for tolerance defining
313 TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance");
314 TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
315 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0);
317 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
318 GroupArgumentsLayout->addMultiCellWidget(SpinBox_Tolerance, 4, 4, 1, 3);
320 // CheckBox for groups generation
321 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
322 MakeGroupsCheck->setChecked(true);
323 GroupArgumentsLayout->addMultiCellWidget(MakeGroupsCheck, 6, 6, 0, 3);
325 // Control for mesh preview
326 CheckBoxPreview = new QCheckBox(GroupArguments, "CheckBoxPreview");
327 CheckBoxPreview->setText(tr("PREVIEW" ));
328 GroupArgumentsLayout->addMultiCellWidget(CheckBoxPreview, 5, 5, 0, 3);
330 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0);
332 /* Initialisations */
333 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
334 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
335 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
336 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
337 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
338 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
340 RadioButton3->setChecked(TRUE);
342 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
344 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
345 SpinBox_NbSteps->setValidator(anIntValidator);
346 SpinBox_NbSteps->setRange(1, 999999);
348 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 6);
350 GroupArguments->show();
351 RadioButton1->setChecked(TRUE);
353 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
355 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
357 // Costruction of the logical filter
358 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
359 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
361 QPtrList<SUIT_SelectionFilter> aListOfFilters;
362 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
363 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
365 myMeshOrSubMeshOrGroupFilter =
366 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
368 myHelpFileName = "revolution_page.html";
372 /* signals and slots connections */
373 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
374 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
375 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
376 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
377 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
379 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
380 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
381 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
383 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
384 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
385 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
387 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
388 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
389 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
391 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
392 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
393 /* to close dialog if study change */
394 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
395 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
396 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
398 connect(GroupAngle, SIGNAL(clicked(int)), SLOT(toDisplaySimulation()));
399 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
400 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
401 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
402 connect(CheckBoxPreview, SIGNAL(toggled(bool)), SLOT(onDisplaySimulation(bool)));
404 this->show(); /* displays Dialog */
406 ConstructorsClicked(0);
407 SelectionIntoArgument();
411 //=================================================================================
412 // function : ~SMESHGUI_RevolutionDlg()
413 // purpose : Destroys the object and frees any allocated resources
414 //=================================================================================
415 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
418 // no need to delete child widgets, Qt does it all for us
421 //=================================================================================
424 //=================================================================================
425 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
429 myEditCurrentArgument = 0;
430 LineEditElements->clear();
435 myMesh = SMESH::SMESH_Mesh::_nil();
438 SpinBox_X->SetValue(0.0);
439 SpinBox_Y->SetValue(0.0);
440 SpinBox_Z->SetValue(0.0);
441 SpinBox_DX->SetValue(0.0);
442 SpinBox_DY->SetValue(0.0);
443 SpinBox_DZ->SetValue(0.0);
445 SpinBox_Angle->SetValue(45);
446 SpinBox_NbSteps->setValue(1);
447 SpinBox_Tolerance->SetValue(1e-05);
449 CheckBoxMesh->setChecked(false);
451 CheckBoxPreview->setChecked(false);
452 onDisplaySimulation(false);
456 //=================================================================================
457 // function : ConstructorsClicked()
458 // purpose : Radio button management
459 //=================================================================================
460 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
462 //disconnect(mySelectionMgr, 0, this, 0);
465 mySelectionMgr->selectedObjects( io );
467 mySelectionMgr->setSelectedObjects( aList );
468 // LineEditElements->clear();
470 buttonApply->setEnabled(false);
471 buttonOk->setEnabled(false);
472 mySimulation->SetVisibility(false);
474 Selection_Mode aSelMode = ActorSelection;
476 switch (constructorId) {
479 GroupArguments->setTitle(tr("REVOLUTION_1D"));
480 aSelMode = EdgeSelection;
485 GroupArguments->setTitle(tr("REVOLUTION_2D"));
486 aSelMode = FaceSelection;
491 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
492 SMESH::SetPointRepresentation(false);
495 if (!CheckBoxMesh->isChecked())
497 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
498 aViewWindow->SetSelectionMode(aSelMode);
501 myEditCurrentArgument = (QWidget*)LineEditElements;
502 LineEditElements->setFocus();
504 if (CheckBoxMesh->isChecked())
507 //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
508 mySelectionMgr->setSelectedObjects( io );
511 //=================================================================================
512 // function : ClickOnApply()
514 //=================================================================================
515 void SMESHGUI_RevolutionDlg::ClickOnApply()
517 if (mySMESHGUI->isActiveStudyLocked())
520 if (myNbOkElements && IsAxisOk()) {
521 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
523 SMESH::long_array_var anElementsId = new SMESH::long_array;
525 anElementsId->length(aListElementsId.count());
526 for (int i = 0; i < aListElementsId.count(); i++)
527 anElementsId[i] = aListElementsId[i].toInt();
529 SMESH::AxisStruct anAxis;
531 anAxis.x = SpinBox_X->GetValue();
532 anAxis.y = SpinBox_Y->GetValue();
533 anAxis.z = SpinBox_Z->GetValue();;
534 anAxis.vx = SpinBox_DX->GetValue();
535 anAxis.vy = SpinBox_DY->GetValue();
536 anAxis.vz = SpinBox_DZ->GetValue();
538 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
539 long aNbSteps = (long)SpinBox_NbSteps->value();
540 double aTolerance = SpinBox_Tolerance->GetValue();
542 if (GroupAngle->selectedId() == 1)
543 anAngle = anAngle/aNbSteps;
546 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
547 QApplication::setOverrideCursor(Qt::waitCursor);
549 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
550 SMESH::ListOfGroups_var groups =
551 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
552 anAngle, aNbSteps, aTolerance);
554 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
556 QApplication::restoreOverrideCursor();
561 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
562 mySMESHGUI->updateObjBrowser(true); // new groups may appear
564 ConstructorsClicked(GetConstructorId());
565 SelectionIntoArgument();
569 //=================================================================================
570 // function : ClickOnOk()
572 //=================================================================================
573 void SMESHGUI_RevolutionDlg::ClickOnOk()
579 //=================================================================================
580 // function : ClickOnCancel()
582 //=================================================================================
583 void SMESHGUI_RevolutionDlg::ClickOnCancel()
585 disconnect(mySelectionMgr, 0, this, 0);
586 mySelectionMgr->clearFilters();
587 //mySelectionMgr->clearSelected();
588 SMESH::SetPointRepresentation(false);
589 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
590 aViewWindow->SetSelectionMode(ActorSelection);
591 mySMESHGUI->ResetState();
595 //=================================================================================
596 // function : ClickOnHelp()
598 //=================================================================================
599 void SMESHGUI_RevolutionDlg::ClickOnHelp()
601 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
603 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
607 platform = "winapplication";
609 platform = "application";
611 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
612 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
613 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
614 QObject::tr("BUT_OK"));
618 //=======================================================================
619 // function : onTextChange()
621 //=======================================================================
622 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
624 QLineEdit* send = (QLineEdit*)sender();
629 if (send == LineEditElements)
632 buttonOk->setEnabled(false);
633 buttonApply->setEnabled(false);
635 // hilight entered elements
636 SMDS_Mesh* aMesh = 0;
638 aMesh = myActor->GetObject()->GetMesh();
641 if (send == LineEditElements) {
642 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
644 TColStd_MapOfInteger newIndices;
646 QStringList aListId = QStringList::split(" ", theNewText, false);
648 for (int i = 0; i < aListId.count(); i++) {
649 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
651 newIndices.Add(e->GetID());
655 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
656 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
657 aViewWindow->highlight( myActor->getIO(), true, true );
659 myElementsId = theNewText;
663 if (myNbOkElements && IsAxisOk()) {
664 buttonOk->setEnabled(true);
665 buttonApply->setEnabled(true);
667 onDisplaySimulation(true);
672 //=================================================================================
673 // function : SelectionIntoArgument()
674 // purpose : Called when selection as changed or other case
675 //=================================================================================
676 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
682 QString aString = "";
685 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
686 LineEditElements->setText(aString);
688 buttonOk->setEnabled(false);
689 buttonApply->setEnabled(false);
693 if (!GroupButtons->isEnabled()) // inactive
697 const SALOME_ListIO& aList = mySelector->StoredIObjects();
699 int nbSel = aList.Extent();
703 Handle(SALOME_InteractiveObject) IO = aList.First();
704 myMesh = SMESH::GetMeshByIO(IO);
705 if (myMesh->_is_nil())
708 myActor = SMESH::FindActorByObject(myMesh);
710 myActor = SMESH::FindActorByEntry(IO->getEntry());
716 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
719 // MakeGroups is available if there are groups
720 if ( myMesh->NbGroups() == 0 ) {
721 MakeGroupsCheck->setChecked(false);
722 MakeGroupsCheck->setEnabled(false);
724 MakeGroupsCheck->setEnabled(true);
727 if (CheckBoxMesh->isChecked()) {
728 int aConstructorId = GetConstructorId();
730 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
732 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
734 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
738 if (aConstructorId == 0) {
739 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
741 while (anIter->more()) {
742 const SMDS_MeshEdge * edge = anIter->next();
744 myElementsId += QString(" %1").arg(edge->GetID());
748 } else if (aConstructorId == 1) {
749 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
750 while (anIter->more()) {
751 const SMDS_MeshFace * face = anIter->next();
753 myElementsId += QString(" %1").arg(face->GetID());
758 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
760 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
762 // get IDs from submesh
763 SMESH::long_array_var anElementsIds = new SMESH::long_array;
764 if (aConstructorId == 0)
765 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
766 else if (aConstructorId == 1)
767 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
769 for (int i = 0; i < anElementsIds->length(); i++)
770 myElementsId += QString(" %1").arg(anElementsIds[i]);
771 aNbUnits = anElementsIds->length();
774 SMESH::SMESH_GroupBase_var aGroup =
775 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
776 if (aGroup->_is_nil())
779 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
780 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
783 // get IDs from smesh group
784 SMESH::long_array_var anElementsIds = new SMESH::long_array;
785 anElementsIds = aGroup->GetListOfID();
786 for (int i = 0; i < anElementsIds->length(); i++) {
787 myElementsId += QString(" %1").arg(anElementsIds[i]);
789 aNbUnits = anElementsIds->length();
792 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
793 myElementsId = aString;
799 myNbOkElements = true;
801 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
805 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
809 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
817 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
818 SpinBox_X->SetValue(x);
819 SpinBox_Y->SetValue(y);
820 SpinBox_Z->SetValue(z);
821 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
822 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
823 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
824 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
829 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
830 LineEditElements->setText(aString);
831 LineEditElements->repaint();
836 if (myNbOkElements && IsAxisOk()) {
837 buttonOk->setEnabled(true);
838 buttonApply->setEnabled(true);
841 onDisplaySimulation(true);
844 //=================================================================================
845 // function : SetEditCurrentArgument()
847 //=================================================================================
848 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
850 QPushButton* send = (QPushButton*)sender();
852 disconnect(mySelectionMgr, 0, this, 0);
853 mySelectionMgr->clearSelected();
854 mySelectionMgr->clearFilters();
856 if (send == SelectElementsButton) {
857 mySimulation->SetVisibility(false);
858 myEditCurrentArgument = (QWidget*)LineEditElements;
859 SMESH::SetPointRepresentation(false);
860 if (CheckBoxMesh->isChecked()) {
861 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
862 aViewWindow->SetSelectionMode(ActorSelection);
863 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
865 int aConstructorId = GetConstructorId();
866 if (aConstructorId == 0)
868 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
869 aViewWindow->SetSelectionMode(EdgeSelection);
871 else if (aConstructorId == 1)
873 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
874 aViewWindow->SetSelectionMode(FaceSelection);
878 } else if (send == SelectPointButton) {
879 myEditCurrentArgument = (QWidget*)SpinBox_X;
880 SMESH::SetPointRepresentation(true);
881 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
882 aViewWindow->SetSelectionMode(NodeSelection);
883 } else if (send == SelectVectorButton) {
884 myEditCurrentArgument = (QWidget*)SpinBox_DX;
885 SMESH::SetPointRepresentation(true);
886 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
887 aViewWindow->SetSelectionMode(NodeSelection);
891 myEditCurrentArgument->setFocus();
892 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
893 SelectionIntoArgument();
896 //=================================================================================
897 // function : DeactivateActiveDialog()
899 //=================================================================================
900 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
902 if (GroupConstructors->isEnabled()) {
903 GroupConstructors->setEnabled(false);
904 GroupArguments->setEnabled(false);
905 GroupButtons->setEnabled(false);
906 mySMESHGUI->ResetState();
907 mySMESHGUI->SetActiveDialogBox(0);
911 //=================================================================================
912 // function : ActivateThisDialog()
914 //=================================================================================
915 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
917 /* Emit a signal to deactivate the active dialog */
918 mySMESHGUI->EmitSignalDeactivateDialog();
919 GroupConstructors->setEnabled(true);
920 GroupArguments->setEnabled(true);
921 GroupButtons->setEnabled(true);
923 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
925 ConstructorsClicked(GetConstructorId());
926 SelectionIntoArgument();
929 //=================================================================================
930 // function : enterEvent()
932 //=================================================================================
933 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
935 if (!GroupConstructors->isEnabled())
936 ActivateThisDialog();
939 //=================================================================================
940 // function : closeEvent()
942 //=================================================================================
943 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
945 /* same than click on cancel button */
946 this->ClickOnCancel();
949 //=======================================================================
950 // function : hideEvent()
951 // purpose : caused by ESC key
952 //=======================================================================
953 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
959 //=======================================================================
960 //function : onSelectMesh
962 //=======================================================================
963 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
966 TextLabelElements->setText(tr("SMESH_NAME"));
968 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
970 if (myEditCurrentArgument != LineEditElements) {
971 LineEditElements->clear();
972 mySimulation->SetVisibility(false);
976 mySelectionMgr->clearFilters();
977 SMESH::SetPointRepresentation(false);
980 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
981 aViewWindow->SetSelectionMode(ActorSelection);
982 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
983 LineEditElements->setReadOnly(true);
985 int aConstructorId = GetConstructorId();
986 if (aConstructorId == 0)
988 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
989 aViewWindow->SetSelectionMode(EdgeSelection);
991 else if (aConstructorId == 0)
993 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
994 aViewWindow->SetSelectionMode(FaceSelection);
997 LineEditElements->setReadOnly(false);
998 onTextChange(LineEditElements->text());
999 mySimulation->SetVisibility(false);
1002 SelectionIntoArgument();
1005 //=================================================================================
1006 // function : GetConstructorId()
1008 //=================================================================================
1009 int SMESHGUI_RevolutionDlg::GetConstructorId()
1011 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
1012 return GroupConstructors->id(GroupConstructors->selected());
1016 //=================================================================================
1017 // function : IsAxisOk()
1019 //=================================================================================
1020 bool SMESHGUI_RevolutionDlg::IsAxisOk()
1022 return (SpinBox_DX->GetValue() != 0 ||
1023 SpinBox_DY->GetValue() != 0 ||
1024 SpinBox_DZ->GetValue() != 0);
1027 //=================================================================================
1028 // function : onVectorChanged()
1030 //=================================================================================
1031 void SMESHGUI_RevolutionDlg::onVectorChanged()
1034 buttonOk->setEnabled(true);
1035 buttonApply->setEnabled(true);
1037 buttonOk->setEnabled(false);
1038 buttonApply->setEnabled(false);
1040 onDisplaySimulation(true);
1043 //=================================================================================
1044 // function : keyPressEvent()
1046 //=================================================================================
1047 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
1049 QDialog::keyPressEvent( e );
1050 if ( e->isAccepted() )
1053 if ( e->key() == Key_F1 )
1060 //=================================================================================
1061 // function : toDisplaySimulation()
1063 //=================================================================================
1064 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
1066 onDisplaySimulation(true);
1069 //=================================================================================
1070 // function : onDisplaySimulation()
1072 //=================================================================================
1073 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1075 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1078 if (myNbOkElements && IsAxisOk()) {
1079 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
1081 SMESH::long_array_var anElementsId = new SMESH::long_array;
1083 anElementsId->length(aListElementsId.count());
1084 for (int i = 0; i < aListElementsId.count(); i++)
1085 anElementsId[i] = aListElementsId[i].toInt();
1087 SMESH::AxisStruct anAxis;
1089 anAxis.x = SpinBox_X->GetValue();
1090 anAxis.y = SpinBox_Y->GetValue();
1091 anAxis.z = SpinBox_Z->GetValue();
1092 anAxis.vx = SpinBox_DX->GetValue();
1093 anAxis.vy = SpinBox_DY->GetValue();
1094 anAxis.vz = SpinBox_DZ->GetValue();
1096 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1097 long aNbSteps = (long)SpinBox_NbSteps->value();
1098 double aTolerance = SpinBox_Tolerance->GetValue();
1100 if (GroupAngle->selectedId() == 1)
1101 anAngle = anAngle/aNbSteps;
1104 SUIT_OverrideCursor aWaitCursor;
1105 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1106 aMeshEditor->RotationSweep(anElementsId.inout(),
1111 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1112 mySimulation->SetData(aMeshPreviewStruct._retn());
1117 mySimulation->SetVisibility(false);
1123 mySimulation->SetVisibility(false);