1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_RevolutionDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_RevolutionDlg.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESHGUI_MeshEditPreview.h"
37 #include "SMESHGUI_FilterDlg.h"
38 #include "SMESHGUI_ExtrusionDlg.h"
40 #include <SMESH_Actor.h>
41 #include <SMESH_TypeFilter.hxx>
42 #include <SMESH_LogicalFilter.hxx>
43 #include <SMDS_Mesh.hxx>
45 // SALOME GUI includes
46 #include <SUIT_ResourceMgr.h>
47 #include <SUIT_Session.h>
48 #include <SUIT_MessageBox.h>
49 #include <SUIT_Desktop.h>
50 #include <SUIT_OverrideCursor.h>
52 #include <LightApp_Application.h>
53 #include <LightApp_SelectionMgr.h>
54 #include <SalomeApp_Application.h>
55 #include <SalomeApp_IntSpinBox.h>
57 #include <SVTK_ViewWindow.h>
58 #include <SVTK_Selector.h>
59 #include <SALOME_ListIO.hxx>
60 #include <VTKViewer_CellLocationsArray.h>
63 #include <TColStd_MapOfInteger.hxx>
66 #include <QApplication>
67 #include <QButtonGroup>
71 #include <QPushButton>
72 #include <QRadioButton>
74 #include <QHBoxLayout>
75 #include <QVBoxLayout>
76 #include <QGridLayout>
81 #include <SALOMEconfig.h>
82 #include CORBA_SERVER_HEADER(SMESH_Group)
83 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
88 //=================================================================================
89 // class : SMESHGUI_RevolutionDlg()
91 //=================================================================================
92 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
93 : SMESHGUI_PreviewDlg( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
95 myVectorDefinition(NONE_SELECT)
97 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
98 QPixmap image ( 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 GroupArguments = new QGroupBox(tr("REVOLUTION"), this);
111 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
112 GroupArgumentsLayout->setSpacing(SPACING);
113 GroupArgumentsLayout->setMargin(MARGIN);
115 // Controls for elements selection
116 SelectorWdg = new SMESHGUI_3TypesSelector( GroupArguments );
118 // Controls for axis defining
119 GroupAxis = new QGroupBox(tr("SMESH_AXIS"), GroupArguments);
120 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis);
121 GroupAxisLayout->setSpacing(SPACING);
122 GroupAxisLayout->setMargin(MARGIN);
124 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupAxis);
125 SelectPointButton = new QPushButton(GroupAxis);
126 SelectPointButton->setIcon(image);
127 SelectPointButton->setCheckable(true);
129 TextLabelX = new QLabel(tr("SMESH_X"), GroupAxis);
130 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis);
132 TextLabelY = new QLabel(tr("SMESH_Y"), GroupAxis);
133 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis);
135 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupAxis);
136 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis);
138 TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupAxis);
139 SelectVectorButton = new QPushButton(GroupAxis);
140 SelectVectorButton->setIcon(image);
141 SelectVectorButton->setCheckable(true);
143 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupAxis);
144 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis);
146 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupAxis);
147 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis);
149 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupAxis);
150 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis);
152 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
153 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
154 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
155 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
156 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
157 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
158 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
159 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
160 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
161 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
162 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
163 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
164 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
165 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
166 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
167 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
169 // Controls for angle defining & number of steps defining
170 GroupAngleBox = new QGroupBox(tr("SMESH_ANGLE"), GroupArguments);
171 GroupAngle = new QButtonGroup(GroupAngleBox);
172 QGridLayout* GroupAngleLayout = new QGridLayout(GroupAngleBox);
173 GroupAngleLayout->setSpacing(6);
174 GroupAngleLayout->setMargin(11);
176 RadioButton3 = new QRadioButton(tr("ANGLE_BY_STEP"), GroupAngleBox);
177 RadioButton4 = new QRadioButton(tr("TOTAL_ANGLE"), GroupAngleBox);
178 GroupAngle->addButton(RadioButton3, 0);
179 GroupAngle->addButton(RadioButton4, 1);
181 TextLabelAngle = new QLabel(tr("SMESH_ANGLE"), GroupAngleBox);
182 SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox);
184 TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox);
185 SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox);
187 GroupAngleLayout->addWidget(RadioButton3, 0, 0);
188 GroupAngleLayout->addWidget(RadioButton4, 0, 1);
189 GroupAngleLayout->addWidget(TextLabelAngle, 1, 0);
190 GroupAngleLayout->addWidget(SpinBox_Angle, 1, 1);
191 GroupAngleLayout->addWidget(TextLabelNbSteps, 2, 0);
192 GroupAngleLayout->addWidget(SpinBox_NbSteps, 2, 1);
194 // Controls for tolerance defining
195 TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), GroupArguments);
196 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments);
198 // Control for mesh preview
199 myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
201 // CheckBox for groups generation
202 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
203 MakeGroupsCheck->setChecked(true);
205 GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 1, 4);
206 GroupArgumentsLayout->addWidget(GroupAxis, 1, 0, 1, 4);
207 GroupArgumentsLayout->addWidget(GroupAngleBox, 2, 0, 1, 4);
208 GroupArgumentsLayout->addWidget(TextLabelTolerance, 3, 0, 1, 2);
209 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 3, 2, 1, 2);
210 GroupArgumentsLayout->addWidget(myPreviewCheckBox, 4, 0, 1, 4);
211 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 4);
213 SelectorWdg->GetButtonGroup()->addButton( SelectVectorButton );
214 SelectorWdg->GetButtonGroup()->addButton( SelectPointButton );
216 /***************************************************************/
217 GroupButtons = new QGroupBox(this);
218 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
219 GroupButtonsLayout->setSpacing(SPACING);
220 GroupButtonsLayout->setMargin(MARGIN);
222 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
223 buttonOk->setAutoDefault(true);
224 buttonOk->setDefault(true);
225 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
226 buttonApply->setAutoDefault(true);
227 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
228 buttonCancel->setAutoDefault(true);
229 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
230 buttonHelp->setAutoDefault(true);
232 GroupButtonsLayout->addWidget(buttonOk);
233 GroupButtonsLayout->addSpacing(10);
234 GroupButtonsLayout->addWidget(buttonApply);
235 GroupButtonsLayout->addSpacing(10);
236 GroupButtonsLayout->addStretch();
237 GroupButtonsLayout->addWidget(buttonCancel);
238 GroupButtonsLayout->addWidget(buttonHelp);
240 /***************************************************************/
241 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments);
242 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons);
244 /* Initialisations */
245 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
246 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
247 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
248 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
249 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
250 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
252 RadioButton3->setChecked(true);
254 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, "angle_precision");
256 SpinBox_NbSteps->setRange(1, 999999);
258 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
260 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
262 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
264 myHelpFileName = "revolution_page.html";
268 /*Create menu to vector selection*/
269 SelectVectorMenu = new QMenu(this);
270 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
271 myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
272 connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
274 /* signals and slots connections */
275 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
276 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
277 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
278 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
280 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
281 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
283 connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
284 connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
285 connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
287 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(CheckIsEnable()));
288 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(CheckIsEnable()));
289 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(CheckIsEnable()));
290 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
291 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
292 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
294 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
295 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
296 connect(SelectorWdg, SIGNAL(selectionChanged()), this, SLOT(toDisplaySimulation()));
297 connect(SelectorWdg, SIGNAL(selectionChanged()), this, SLOT(CheckIsEnable()));
298 /* to close dialog if study change */
299 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
301 connect(GroupAngle, SIGNAL(buttonClicked(int)), this, SLOT(toDisplaySimulation()));
302 connect(SpinBox_Angle, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
303 connect(SpinBox_NbSteps, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
304 connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
306 //To Connect preview check box
307 connectPreviewControl();
309 connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&)));
314 //=================================================================================
315 // function : ~SMESHGUI_RevolutionDlg()
316 // purpose : Destroys the object and frees any allocated resources
317 //=================================================================================
318 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
322 //=================================================================================
325 //=================================================================================
326 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
329 SpinBox_X->SetValue(0.0);
330 SpinBox_Y->SetValue(0.0);
331 SpinBox_Z->SetValue(0.0);
332 SpinBox_DX->SetValue(0.0);
333 SpinBox_DY->SetValue(0.0);
334 SpinBox_DZ->SetValue(0.0);
336 SpinBox_Angle->SetValue(45);
337 SpinBox_NbSteps->setValue(1);
338 SpinBox_Tolerance->SetValue(1e-05);
340 myPreviewCheckBox->setChecked(false);
341 onDisplaySimulation(false);
343 SelectorWdg->Clear();
346 //=================================================================================
347 // function : CheckIsEnable()
348 // purpose : Check whether the Ok and Apply buttons should be enabled or not
349 //=================================================================================
351 void SMESHGUI_RevolutionDlg::CheckIsEnable()
353 bool anIsEnable = SelectorWdg->IsAnythingSelected() && IsAxisOk();
355 buttonOk->setEnabled(anIsEnable);
356 buttonApply->setEnabled(anIsEnable);
359 //=================================================================================
360 // function : isValid
361 // purpose : Return true in case if values entered into dialog are valid
362 //=================================================================================
363 bool SMESHGUI_RevolutionDlg::isValid()
367 ok = SpinBox_X->isValid( msg, true ) && ok;
368 ok = SpinBox_Y->isValid( msg, true ) && ok;
369 ok = SpinBox_Z->isValid( msg, true ) && ok;
370 ok = SpinBox_DX->isValid( msg, true ) && ok;
371 ok = SpinBox_DY->isValid( msg, true ) && ok;
372 ok = SpinBox_DZ->isValid( msg, true ) && ok;
373 ok = SpinBox_Angle->isValid( msg, true ) && ok;
374 ok = SpinBox_NbSteps->isValid( msg, true ) && ok;
375 ok = SpinBox_Tolerance->isValid( msg, true ) && ok;
378 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
379 if ( !msg.isEmpty() )
381 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
387 //=================================================================================
388 // function : ClickOnApply()
390 //=================================================================================
391 bool SMESHGUI_RevolutionDlg::ClickOnApply()
393 if (mySMESHGUI->isActiveStudyLocked())
399 if ( SelectorWdg->IsAnythingSelected() && IsAxisOk() ) {
401 SMESH::AxisStruct anAxis;
403 anAxis.x = SpinBox_X->GetValue();
404 anAxis.y = SpinBox_Y->GetValue();
405 anAxis.z = SpinBox_Z->GetValue();;
406 anAxis.vx = SpinBox_DX->GetValue();
407 anAxis.vy = SpinBox_DY->GetValue();
408 anAxis.vz = SpinBox_DZ->GetValue();
410 double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
411 long aNbSteps = (long)SpinBox_NbSteps->value();
412 double aTolerance = SpinBox_Tolerance->GetValue();
414 if ( GroupAngle->checkedId() == 1 )
415 anAngle = anAngle/aNbSteps;
417 QStringList aParameters;
418 aParameters << SpinBox_X->text();
419 aParameters << SpinBox_Y->text();
420 aParameters << SpinBox_Z->text();
421 aParameters << SpinBox_DX->text();
422 aParameters << SpinBox_DY->text();
423 aParameters << SpinBox_DZ->text();
424 aParameters << SpinBox_Angle->text();
425 aParameters << SpinBox_NbSteps->text();
426 aParameters << SpinBox_Tolerance->text();
428 bool meshHadNewTypeBefore = true;
430 const bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
433 SUIT_OverrideCursor aWaitCursor;
435 SMESH::SMESH_Mesh_var mesh = SelectorWdg->GetMesh();
437 mesh->SetParameters( aParameters.join(":").toLatin1().constData() );
439 SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources();
440 SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources();
441 SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources();
442 maxSelType = SelectorWdg->GetSelected( nodes, edges, faces );
444 // is it necessary to switch on the next Display Mode?
445 SMESH::ElementType newType = (SMESH::ElementType)( maxSelType + 1 );
446 SMESH::array_of_ElementType_var oldTypes = mesh->GetTypes();
447 meshHadNewTypeBefore = false;
448 for ( size_t i = 0; i < oldTypes->length() && !meshHadNewTypeBefore; ++i )
449 meshHadNewTypeBefore = ( oldTypes[i] >= newType );
451 SMESH::SMESH_MeshEditor_var aMeshEditor = mesh->GetMeshEditor();
453 SMESH::ListOfGroups_var groups =
454 aMeshEditor->RotationSweepObjects( nodes, edges, faces, anAxis,
455 anAngle, aNbSteps, aTolerance, makeGroups);
460 SMESH_Actor* actor = SelectorWdg->GetActor();
461 if ( actor && !meshHadNewTypeBefore )
463 unsigned int aMode = actor->GetEntityMode();
464 switch ( maxSelType ) {
465 case SMESH::NODE: // extrude node -> edges
466 actor->SetRepresentation(SMESH_Actor::eEdge);
467 actor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break;
468 case SMESH::EDGE: // edge -> faces
469 actor->SetRepresentation(SMESH_Actor::eSurface);
470 actor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break;
471 case SMESH::FACE: // faces -> volumes
472 actor->SetRepresentation(SMESH_Actor::eSurface);
473 actor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break;
477 SMESH::Update( actor->getIO(), actor->GetVisibility() );
479 mySMESHGUI->updateObjBrowser(true); // new groups may appear
481 mySelectionMgr->clearSelected();
482 SelectorWdg->Clear();
484 SMESHGUI::Modified();
490 //=================================================================================
491 // function : ClickOnOk()
493 //=================================================================================
494 void SMESHGUI_RevolutionDlg::ClickOnOk()
500 //=================================================================================
501 // function : reject()
503 //=================================================================================
504 void SMESHGUI_RevolutionDlg::reject()
506 disconnect(mySelectionMgr, 0, this, 0);
507 mySelectionMgr->clearFilters();
508 //mySelectionMgr->clearSelected();
509 if (SMESH::GetCurrentVtkView()) {
510 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
511 SMESH::SetPointRepresentation(false);
513 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
514 aViewWindow->SetSelectionMode(ActorSelection);
515 mySMESHGUI->ResetState();
520 //=================================================================================
521 // function : ClickOnHelp()
523 //=================================================================================
524 void SMESHGUI_RevolutionDlg::ClickOnHelp()
526 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
528 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
532 platform = "winapplication";
534 platform = "application";
536 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
537 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
538 arg(app->resourceMgr()->stringValue("ExternalBrowser",
540 arg(myHelpFileName));
544 //=======================================================================
545 // function : onAngleTextChange()
547 //=======================================================================
548 void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText)
551 SpinBox_Angle->text().toDouble( &isNumber );
553 RadioButton3->setChecked( true );
554 RadioButton4->setEnabled( isNumber );
557 //=================================================================================
558 // function : SelectionIntoArgument()
559 // purpose : Called when selection as changed or other case
560 //=================================================================================
561 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
563 if (!GroupButtons->isEnabled()) // inactive
566 if ( SelectVectorButton->isChecked() ||
567 SelectPointButton->isChecked() )
571 mySelectionMgr->selectedObjects(aList);
572 int nbSel = aList.Extent();
576 Handle(SALOME_InteractiveObject) IO = aList.First();
577 TColStd_IndexedMapOfInteger aMapIndex;
578 mySelector->GetIndex(IO,aMapIndex);
579 if ( aMapIndex.Extent() != 1 )
582 SMESH_Actor* anActor = SMESH::FindActorByEntry( IO->getEntry() );
583 SMDS_Mesh* aMesh = anActor ? anActor->GetObject()->GetMesh() : 0;
589 bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
590 (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
591 myVectorDefinition==POINT_SELECT));
593 bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
594 myVectorDefinition==FACE_SELECT);
596 if ( isNodeSelected )
598 const SMDS_MeshNode * n = aMesh->FindNode( aMapIndex(1) );
605 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
606 SpinBox_X->SetValue(x);
607 SpinBox_Y->SetValue(y);
608 SpinBox_Z->SetValue(z);
609 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
610 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
611 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
612 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
615 else if ( isFaceSelected )
617 const SMDS_MeshFace* face =
618 dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aMapIndex(1)));
621 gp_XYZ aNormale = SMESH::getNormale(face);
622 SpinBox_DX->SetValue(aNormale.X());
623 SpinBox_DY->SetValue(aNormale.Y());
624 SpinBox_DZ->SetValue(aNormale.Z());
630 onDisplaySimulation(true);
633 //=================================================================================
634 // function : SetEditCurrentArgument()
636 //=================================================================================
637 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
639 QPushButton* send = (QPushButton*)sender();
641 disconnect(mySelectionMgr, 0, this, 0);
642 mySelectionMgr->clearSelected();
643 mySelectionMgr->clearFilters();
645 if (send == SelectPointButton) {
646 myEditCurrentArgument = (QWidget*)SpinBox_X;
647 myEditCurrentArgument->setFocus();
648 SMESH::SetPointRepresentation(true);
649 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
650 aViewWindow->SetSelectionMode(NodeSelection);
652 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
653 SelectionIntoArgument();
656 //=================================================================================
657 // function : DeactivateActiveDialog()
659 //=================================================================================
660 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
662 if (GroupButtons->isEnabled())
664 GroupArguments->setEnabled(false);
665 GroupButtons->setEnabled(false);
666 SelectorWdg->setEnabled(false);
667 mySMESHGUI->ResetState();
668 mySMESHGUI->SetActiveDialogBox(0);
672 //=================================================================================
673 // function : ActivateThisDialog()
675 //=================================================================================
676 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
678 /* Emit a signal to deactivate the active dialog */
679 mySMESHGUI->EmitSignalDeactivateDialog();
680 GroupArguments->setEnabled(true);
681 GroupButtons->setEnabled(true);
682 SelectorWdg->setEnabled(true);
684 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
687 //=================================================================================
688 // function : enterEvent()
690 //=================================================================================
691 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
693 if (!GroupButtons->isEnabled())
694 ActivateThisDialog();
697 //=================================================================================
698 // function : IsAxisOk()
700 //=================================================================================
701 bool SMESHGUI_RevolutionDlg::IsAxisOk()
703 return (SpinBox_DX->GetValue() != 0 ||
704 SpinBox_DY->GetValue() != 0 ||
705 SpinBox_DZ->GetValue() != 0);
708 //=================================================================================
709 // function : keyPressEvent()
711 //=================================================================================
712 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
714 QDialog::keyPressEvent( e );
715 if ( e->isAccepted() )
718 if ( e->key() == Qt::Key_F1 ) {
724 //=================================================================================
725 // function : onDisplaySimulation()
726 // purpose : Show/Hide preview
727 //=================================================================================
728 void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview)
730 if (myPreviewCheckBox->isChecked() && toDisplayPreview)
732 if (SelectorWdg->IsAnythingSelected() && IsAxisOk())
734 SMESH::AxisStruct anAxis;
736 anAxis.x = SpinBox_X->GetValue();
737 anAxis.y = SpinBox_Y->GetValue();
738 anAxis.z = SpinBox_Z->GetValue();
739 anAxis.vx = SpinBox_DX->GetValue();
740 anAxis.vy = SpinBox_DY->GetValue();
741 anAxis.vz = SpinBox_DZ->GetValue();
743 double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
744 long aNbSteps = (long)SpinBox_NbSteps->value();
745 double aTolerance = SpinBox_Tolerance->GetValue();
747 if (GroupAngle->checkedId() == 1)
748 anAngle = anAngle/aNbSteps;
752 SUIT_OverrideCursor aWaitCursor;
754 SMESH::SMESH_Mesh_var mesh = SelectorWdg->GetMesh();
755 SMESH::SMESH_MeshEditor_var meshEditor = mesh->GetMeshEditPreviewer();
756 SMESH::ListOfGroups_var groups;
758 SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources();
759 SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources();
760 SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources();
761 SelectorWdg->GetSelected( nodes, edges, faces );
762 const bool makeGroups = false;
764 meshEditor->RotationSweepObjects(nodes, edges, faces,
765 anAxis, anAngle, aNbSteps, aTolerance, makeGroups );
767 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = meshEditor->GetPreviewData();
768 mySimulation->SetData( aMeshPreviewStruct._retn() );
774 mySimulation->SetVisibility(false);
780 mySimulation->SetVisibility(false);
784 //=================================================================================
785 // function : onSelectVectorButton()
787 //=================================================================================
788 void SMESHGUI_RevolutionDlg::onSelectVectorButton()
790 if(SelectVectorMenu) {
791 SelectVectorMenu->exec( QCursor::pos() );
795 //=================================================================================
796 // function : onSelectVectorMenu()
798 //=================================================================================
799 void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action)
804 disconnect(mySelectionMgr, 0, this, 0);
806 switch(myMenuActions[action]) {
808 SMESH::SetPointRepresentation(true);
809 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
810 aViewWindow->SetSelectionMode(NodeSelection);
814 SMESH::SetPointRepresentation(false);
815 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
816 aViewWindow->SetSelectionMode(FaceSelection);
820 myVectorDefinition = myMenuActions[action];
821 myEditCurrentArgument = (QWidget*)SpinBox_DX;
822 myEditCurrentArgument->setFocus();
823 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
824 SelectionIntoArgument();