1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_RevolutionDlg.cxx
23 // Author : Michael ZORIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_RevolutionDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_MeshEditPreview.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TypeFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_Desktop.h>
47 #include <SUIT_OverrideCursor.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_SelectionMgr.h>
51 #include <SalomeApp_Application.h>
53 #include <SVTK_ViewWindow.h>
54 #include <SVTK_Selector.h>
55 #include <SALOME_ListIO.hxx>
56 #include <VTKViewer_CellLocationsArray.h>
59 #include <TColStd_MapOfInteger.hxx>
62 #include <QApplication>
63 #include <QButtonGroup>
67 #include <QPushButton>
68 #include <QRadioButton>
70 #include <QHBoxLayout>
71 #include <QVBoxLayout>
72 #include <QGridLayout>
77 #include <SALOMEconfig.h>
78 #include CORBA_SERVER_HEADER(SMESH_Group)
79 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
84 //=================================================================================
85 // class : SMESHGUI_RevolutionDlg()
87 //=================================================================================
88 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
89 : QDialog( SMESH::GetDesktop( theModule ) ),
90 mySMESHGUI( theModule ),
91 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
93 mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
95 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
96 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
97 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
98 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
101 setAttribute(Qt::WA_DeleteOnClose, true);
102 setWindowTitle(tr("REVOLUTION_AROUND_AXIS"));
103 setSizeGripEnabled(true);
105 QVBoxLayout* SMESHGUI_RevolutionDlgLayout = new QVBoxLayout(this);
106 SMESHGUI_RevolutionDlgLayout->setSpacing(SPACING);
107 SMESHGUI_RevolutionDlgLayout->setMargin(MARGIN);
109 /***************************************************************/
110 ConstructorsBox = new QGroupBox(tr("SMESH_REVOLUTION"), this);
111 GroupConstructors = new QButtonGroup(this);
112 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
113 ConstructorsBoxLayout->setSpacing(SPACING);
114 ConstructorsBoxLayout->setMargin(MARGIN);
116 RadioButton1 = new QRadioButton(ConstructorsBox);
117 RadioButton1->setIcon(image0);
118 RadioButton2 = new QRadioButton(ConstructorsBox);
119 RadioButton2->setIcon(image1);
121 ConstructorsBoxLayout->addWidget(RadioButton1);
122 ConstructorsBoxLayout->addWidget(RadioButton2);
123 GroupConstructors->addButton(RadioButton1, 0);
124 GroupConstructors->addButton(RadioButton2, 1);
126 /***************************************************************/
127 GroupArguments = new QGroupBox(tr("REVOLUTION_1D"), this);
128 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
129 GroupArgumentsLayout->setSpacing(SPACING);
130 GroupArgumentsLayout->setMargin(MARGIN);
132 myIdValidator = new SMESHGUI_IdValidator(this);
134 // Controls for elements selection
135 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
137 SelectElementsButton = new QPushButton(GroupArguments);
138 SelectElementsButton->setIcon(image2);
140 LineEditElements = new QLineEdit(GroupArguments);
141 LineEditElements->setValidator(myIdValidator);
143 // Control for the whole mesh selection
144 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
146 // Controls for axis defining
147 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
148 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
149 GroupAxisLayout->setSpacing(SPACING);
150 GroupAxisLayout->setMargin(MARGIN);
152 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
153 SelectPointButton = new QPushButton(GroupAxis);
154 SelectPointButton->setIcon(image2);
156 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
157 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
159 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
160 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
162 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
163 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
165 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
166 SelectVectorButton = new QPushButton(GroupAxis);
167 SelectVectorButton->setIcon(image2);
169 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
170 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
172 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
173 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
175 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
176 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
178 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
179 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
180 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
181 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
182 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
183 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
184 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
185 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
186 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
187 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
188 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
189 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
190 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
191 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
192 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
193 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
195 // Controls for angle defining & number of steps defining
196 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
197 GroupAngle = new QButtonGroup(GroupAngleBox);
198 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
199 GroupAngleLayout->setSpacing(6);
200 GroupAngleLayout->setMargin(11);
202 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
203 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
204 GroupAngle->addButton(RadioButton3, 0);
205 GroupAngle->addButton(RadioButton4, 1);
207 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
208 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
210 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
211 SpinBox_NbSteps = new QSpinBox(GroupAngleBox);
213 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
214 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
215 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
216 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
217 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
218 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
220 // Controls for tolerance defining
221 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
222 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
224 // Control for mesh preview
225 CheckBoxPreview = new QCheckBox(tr("PREVIEW"), GroupArguments);
227 // CheckBox for groups generation
228 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
229 MakeGroupsCheck->setChecked(true);
231 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
232 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
233 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
234 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
235 GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 3);
236 GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 3);
237 GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
238 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2);
239 GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 3);
240 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 3);
242 /***************************************************************/
243 GroupButtons = new QGroupBox(this);
244 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
245 GroupButtonsLayout->setSpacing(SPACING);
246 GroupButtonsLayout->setMargin(MARGIN);
248 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
249 buttonOk->setAutoDefault(true);
250 buttonOk->setDefault(true);
251 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
252 buttonApply->setAutoDefault(true);
253 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
254 buttonCancel->setAutoDefault(true);
255 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
256 buttonHelp->setAutoDefault(true);
258 GroupButtonsLayout->addWidget(buttonOk);
259 GroupButtonsLayout->addSpacing(10);
260 GroupButtonsLayout->addWidget(buttonApply);
261 GroupButtonsLayout->addSpacing(10);
262 GroupButtonsLayout->addStretch();
263 GroupButtonsLayout->addWidget(buttonCancel);
264 GroupButtonsLayout->addWidget(buttonHelp);
266 /***************************************************************/
267 SMESHGUI_RevolutionDlgLayout->addWidget(ConstructorsBox);
268 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
269 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
271 /* Initialisations */
272 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
273 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
274 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
275 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
276 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
277 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
279 RadioButton3->setChecked(true);
281 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
283 SpinBox_NbSteps->setRange(1, 999999);
285 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, 6);
287 RadioButton1->setChecked(true);
289 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
291 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
293 // Costruction of the logical filter
294 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
295 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
297 QList<SUIT_SelectionFilter*> aListOfFilters;
298 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
299 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
301 myMeshOrSubMeshOrGroupFilter =
302 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
304 myHelpFileName = "revolution_page.html";
308 /* signals and slots connections */
309 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
310 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
311 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
312 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
313 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
315 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
316 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
317 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
319 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
320 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
321 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
323 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
324 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
325 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
327 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
328 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
329 /* to close dialog if study change */
330 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
331 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
332 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
334 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
335 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
336 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
337 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
338 connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool)));
340 ConstructorsClicked(0);
341 SelectionIntoArgument();
344 //=================================================================================
345 // function : ~SMESHGUI_RevolutionDlg()
346 // purpose : Destroys the object and frees any allocated resources
347 //=================================================================================
348 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
353 //=================================================================================
356 //=================================================================================
357 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
361 myEditCurrentArgument = 0;
362 LineEditElements->clear();
367 myMesh = SMESH::SMESH_Mesh::_nil();
370 SpinBox_X->SetValue(0.0);
371 SpinBox_Y->SetValue(0.0);
372 SpinBox_Z->SetValue(0.0);
373 SpinBox_DX->SetValue(0.0);
374 SpinBox_DY->SetValue(0.0);
375 SpinBox_DZ->SetValue(0.0);
377 SpinBox_Angle->SetValue(45);
378 SpinBox_NbSteps->setValue(1);
379 SpinBox_Tolerance->SetValue(1e-05);
381 CheckBoxMesh->setChecked(false);
383 CheckBoxPreview->setChecked(false);
384 onDisplaySimulation(false);
388 //=================================================================================
389 // function : ConstructorsClicked()
390 // purpose : Radio button management
391 //=================================================================================
392 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
394 //disconnect(mySelectionMgr, 0, this, 0);
397 mySelectionMgr->selectedObjects( io );
399 mySelectionMgr->setSelectedObjects( aList );
400 // LineEditElements->clear();
402 buttonApply->setEnabled(false);
403 buttonOk->setEnabled(false);
404 mySimulation->SetVisibility(false);
406 Selection_Mode aSelMode = ActorSelection;
408 switch (constructorId) {
411 GroupArguments->setTitle(tr("REVOLUTION_1D"));
412 aSelMode = EdgeSelection;
417 GroupArguments->setTitle(tr("REVOLUTION_2D"));
418 aSelMode = FaceSelection;
423 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
424 SMESH::SetPointRepresentation(false);
427 if (!CheckBoxMesh->isChecked())
429 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
430 aViewWindow->SetSelectionMode(aSelMode);
433 myEditCurrentArgument = (QWidget*)LineEditElements;
434 LineEditElements->setFocus();
436 if (CheckBoxMesh->isChecked())
439 //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
440 mySelectionMgr->setSelectedObjects( io );
443 //=================================================================================
444 // function : ClickOnApply()
446 //=================================================================================
447 void SMESHGUI_RevolutionDlg::ClickOnApply()
449 if (mySMESHGUI->isActiveStudyLocked())
452 if (myNbOkElements && IsAxisOk()) {
453 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
455 SMESH::long_array_var anElementsId = new SMESH::long_array;
457 anElementsId->length(aListElementsId.count());
458 for (int i = 0; i < aListElementsId.count(); i++)
459 anElementsId[i] = aListElementsId[i].toInt();
461 SMESH::AxisStruct anAxis;
463 anAxis.x = SpinBox_X->GetValue();
464 anAxis.y = SpinBox_Y->GetValue();
465 anAxis.z = SpinBox_Z->GetValue();;
466 anAxis.vx = SpinBox_DX->GetValue();
467 anAxis.vy = SpinBox_DY->GetValue();
468 anAxis.vz = SpinBox_DZ->GetValue();
470 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
471 long aNbSteps = (long)SpinBox_NbSteps->value();
472 double aTolerance = SpinBox_Tolerance->GetValue();
474 if ( GroupAngle->checkedId() == 1 )
475 anAngle = anAngle/aNbSteps;
478 SUIT_OverrideCursor aWaitCursor;
479 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
481 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
482 SMESH::ListOfGroups_var groups =
483 aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis,
484 anAngle, aNbSteps, aTolerance);
486 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
491 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
492 mySMESHGUI->updateObjBrowser(true); // new groups may appear
494 ConstructorsClicked(GetConstructorId());
495 SelectionIntoArgument();
499 //=================================================================================
500 // function : ClickOnOk()
502 //=================================================================================
503 void SMESHGUI_RevolutionDlg::ClickOnOk()
509 //=================================================================================
510 // function : ClickOnCancel()
512 //=================================================================================
513 void SMESHGUI_RevolutionDlg::ClickOnCancel()
515 disconnect(mySelectionMgr, 0, this, 0);
516 mySelectionMgr->clearFilters();
517 //mySelectionMgr->clearSelected();
518 SMESH::SetPointRepresentation(false);
519 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
520 aViewWindow->SetSelectionMode(ActorSelection);
521 mySMESHGUI->ResetState();
525 //=================================================================================
526 // function : ClickOnHelp()
528 //=================================================================================
529 void SMESHGUI_RevolutionDlg::ClickOnHelp()
531 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
533 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
537 platform = "winapplication";
539 platform = "application";
541 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
542 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
543 arg(app->resourceMgr()->stringValue("ExternalBrowser",
545 arg(myHelpFileName));
549 //=======================================================================
550 // function : onTextChange()
552 //=======================================================================
553 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
555 QLineEdit* send = (QLineEdit*)sender();
560 if (send == LineEditElements)
563 buttonOk->setEnabled(false);
564 buttonApply->setEnabled(false);
566 // hilight entered elements
567 SMDS_Mesh* aMesh = 0;
569 aMesh = myActor->GetObject()->GetMesh();
572 if (send == LineEditElements) {
573 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
575 TColStd_MapOfInteger newIndices;
577 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
579 for (int i = 0; i < aListId.count(); i++) {
580 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
582 newIndices.Add(e->GetID());
586 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
587 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
588 aViewWindow->highlight( myActor->getIO(), true, true );
590 myElementsId = theNewText;
594 if (myNbOkElements && IsAxisOk()) {
595 buttonOk->setEnabled(true);
596 buttonApply->setEnabled(true);
598 onDisplaySimulation(true);
603 //=================================================================================
604 // function : SelectionIntoArgument()
605 // purpose : Called when selection as changed or other case
606 //=================================================================================
607 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
613 QString aString = "";
616 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
617 LineEditElements->setText(aString);
619 buttonOk->setEnabled(false);
620 buttonApply->setEnabled(false);
624 if (!GroupButtons->isEnabled()) // inactive
628 const SALOME_ListIO& aList = mySelector->StoredIObjects();
630 int nbSel = aList.Extent();
634 Handle(SALOME_InteractiveObject) IO = aList.First();
635 myMesh = SMESH::GetMeshByIO(IO);
636 if (myMesh->_is_nil())
639 myActor = SMESH::FindActorByObject(myMesh);
641 myActor = SMESH::FindActorByEntry(IO->getEntry());
647 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
650 // MakeGroups is available if there are groups
651 if ( myMesh->NbGroups() == 0 ) {
652 MakeGroupsCheck->setChecked(false);
653 MakeGroupsCheck->setEnabled(false);
655 MakeGroupsCheck->setEnabled(true);
658 if (CheckBoxMesh->isChecked()) {
659 int aConstructorId = GetConstructorId();
661 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
663 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
665 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
669 if (aConstructorId == 0) {
670 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
672 while (anIter->more()) {
673 const SMDS_MeshEdge * edge = anIter->next();
675 myElementsId += QString(" %1").arg(edge->GetID());
679 } else if (aConstructorId == 1) {
680 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
681 while (anIter->more()) {
682 const SMDS_MeshFace * face = anIter->next();
684 myElementsId += QString(" %1").arg(face->GetID());
689 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
691 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
693 // get IDs from submesh
694 SMESH::long_array_var anElementsIds = new SMESH::long_array;
695 if (aConstructorId == 0)
696 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
697 else if (aConstructorId == 1)
698 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
700 for (int i = 0; i < anElementsIds->length(); i++)
701 myElementsId += QString(" %1").arg(anElementsIds[i]);
702 aNbUnits = anElementsIds->length();
705 SMESH::SMESH_GroupBase_var aGroup =
706 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
707 if (aGroup->_is_nil())
710 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
711 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
714 // get IDs from smesh group
715 SMESH::long_array_var anElementsIds = new SMESH::long_array;
716 anElementsIds = aGroup->GetListOfID();
717 for (int i = 0; i < anElementsIds->length(); i++) {
718 myElementsId += QString(" %1").arg(anElementsIds[i]);
720 aNbUnits = anElementsIds->length();
723 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
724 myElementsId = aString;
730 myNbOkElements = true;
732 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
736 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
740 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
748 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
749 SpinBox_X->SetValue(x);
750 SpinBox_Y->SetValue(y);
751 SpinBox_Z->SetValue(z);
752 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
753 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
754 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
755 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
760 if (myEditCurrentArgument == (QWidget*)LineEditElements)
761 LineEditElements->setText(aString);
765 if (myNbOkElements && IsAxisOk()) {
766 buttonOk->setEnabled(true);
767 buttonApply->setEnabled(true);
770 onDisplaySimulation(true);
773 //=================================================================================
774 // function : SetEditCurrentArgument()
776 //=================================================================================
777 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
779 QPushButton* send = (QPushButton*)sender();
781 disconnect(mySelectionMgr, 0, this, 0);
782 mySelectionMgr->clearSelected();
783 mySelectionMgr->clearFilters();
785 if (send == SelectElementsButton) {
786 mySimulation->SetVisibility(false);
787 myEditCurrentArgument = (QWidget*)LineEditElements;
788 SMESH::SetPointRepresentation(false);
789 if (CheckBoxMesh->isChecked()) {
790 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
791 aViewWindow->SetSelectionMode(ActorSelection);
792 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
794 int aConstructorId = GetConstructorId();
795 if (aConstructorId == 0)
797 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
798 aViewWindow->SetSelectionMode(EdgeSelection);
800 else if (aConstructorId == 1)
802 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
803 aViewWindow->SetSelectionMode(FaceSelection);
806 } else if (send == SelectPointButton) {
807 myEditCurrentArgument = (QWidget*)SpinBox_X;
808 SMESH::SetPointRepresentation(true);
809 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
810 aViewWindow->SetSelectionMode(NodeSelection);
811 } else if (send == SelectVectorButton) {
812 myEditCurrentArgument = (QWidget*)SpinBox_DX;
813 SMESH::SetPointRepresentation(true);
814 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
815 aViewWindow->SetSelectionMode(NodeSelection);
819 myEditCurrentArgument->setFocus();
820 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
821 SelectionIntoArgument();
824 //=================================================================================
825 // function : DeactivateActiveDialog()
827 //=================================================================================
828 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
830 if (ConstructorsBox->isEnabled()) {
831 ConstructorsBox->setEnabled(false);
832 GroupArguments->setEnabled(false);
833 GroupButtons->setEnabled(false);
834 mySMESHGUI->ResetState();
835 mySMESHGUI->SetActiveDialogBox(0);
839 //=================================================================================
840 // function : ActivateThisDialog()
842 //=================================================================================
843 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
845 /* Emit a signal to deactivate the active dialog */
846 mySMESHGUI->EmitSignalDeactivateDialog();
847 ConstructorsBox->setEnabled(true);
848 GroupArguments->setEnabled(true);
849 GroupButtons->setEnabled(true);
851 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
853 ConstructorsClicked(GetConstructorId());
854 SelectionIntoArgument();
857 //=================================================================================
858 // function : enterEvent()
860 //=================================================================================
861 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
863 if (!ConstructorsBox->isEnabled())
864 ActivateThisDialog();
867 //=================================================================================
868 // function : closeEvent()
870 //=================================================================================
871 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
873 /* same than click on cancel button */
877 //=======================================================================
878 // function : hideEvent()
879 // purpose : caused by ESC key
880 //=======================================================================
881 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
887 //=======================================================================
888 //function : onSelectMesh
890 //=======================================================================
891 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
894 TextLabelElements->setText(tr("SMESH_NAME"));
896 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
898 if (myEditCurrentArgument != LineEditElements) {
899 LineEditElements->clear();
900 mySimulation->SetVisibility(false);
904 mySelectionMgr->clearFilters();
905 SMESH::SetPointRepresentation(false);
908 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
909 aViewWindow->SetSelectionMode(ActorSelection);
910 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
911 LineEditElements->setReadOnly(true);
912 LineEditElements->setValidator(0);
914 int aConstructorId = GetConstructorId();
915 if (aConstructorId == 0)
917 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
918 aViewWindow->SetSelectionMode(EdgeSelection);
920 else if (aConstructorId == 0)
922 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
923 aViewWindow->SetSelectionMode(FaceSelection);
926 LineEditElements->setReadOnly(false);
927 LineEditElements->setValidator(myIdValidator);
928 onTextChange(LineEditElements->text());
929 mySimulation->SetVisibility(false);
932 SelectionIntoArgument();
935 //=================================================================================
936 // function : GetConstructorId()
938 //=================================================================================
939 int SMESHGUI_RevolutionDlg::GetConstructorId()
941 return GroupConstructors->checkedId();
944 //=================================================================================
945 // function : IsAxisOk()
947 //=================================================================================
948 bool SMESHGUI_RevolutionDlg::IsAxisOk()
950 return (SpinBox_DX->GetValue() != 0 ||
951 SpinBox_DY->GetValue() != 0 ||
952 SpinBox_DZ->GetValue() != 0);
955 //=================================================================================
956 // function : onVectorChanged()
958 //=================================================================================
959 void SMESHGUI_RevolutionDlg::onVectorChanged()
962 buttonOk->setEnabled(true);
963 buttonApply->setEnabled(true);
965 buttonOk->setEnabled(false);
966 buttonApply->setEnabled(false);
968 onDisplaySimulation(true);
971 //=================================================================================
972 // function : keyPressEvent()
974 //=================================================================================
975 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
977 QDialog::keyPressEvent( e );
978 if ( e->isAccepted() )
981 if ( e->key() == Qt::Key_F1 ) {
987 //=================================================================================
988 // function : toDisplaySimulation()
990 //=================================================================================
991 void SMESHGUI_RevolutionDlg::toDisplaySimulation()
993 onDisplaySimulation(true);
996 //=================================================================================
997 // function : onDisplaySimulation()
999 //=================================================================================
1000 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
1002 if (CheckBoxPreview->isChecked() && toDisplayPreview)
1005 if (myNbOkElements && IsAxisOk())
1007 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1009 SMESH::long_array_var anElementsId = new SMESH::long_array;
1011 anElementsId->length(aListElementsId.count());
1012 for (int i = 0; i < aListElementsId.count(); i++)
1013 anElementsId[i] = aListElementsId[i].toInt();
1015 SMESH::AxisStruct anAxis;
1017 anAxis.x = SpinBox_X->GetValue();
1018 anAxis.y = SpinBox_Y->GetValue();
1019 anAxis.z = SpinBox_Z->GetValue();
1020 anAxis.vx = SpinBox_DX->GetValue();
1021 anAxis.vy = SpinBox_DY->GetValue();
1022 anAxis.vz = SpinBox_DZ->GetValue();
1024 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
1025 long aNbSteps = (long)SpinBox_NbSteps->value();
1026 double aTolerance = SpinBox_Tolerance->GetValue();
1028 if (GroupAngle->checkedId() == 1)
1029 anAngle = anAngle/aNbSteps;
1032 SUIT_OverrideCursor aWaitCursor;
1033 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1034 aMeshEditor->RotationSweep(anElementsId.inout(),
1039 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1040 mySimulation->SetData(aMeshPreviewStruct._retn());
1045 mySimulation->SetVisibility(false);
1051 mySimulation->SetVisibility(false);