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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_RevolutionDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_RevolutionDlg.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESH_Actor.h"
36 #include "SMDS_Mesh.hxx"
38 #include "QAD_Application.h"
39 #include "QAD_Desktop.h"
40 #include "QAD_MessageBox.h"
41 #include "utilities.h"
44 #include <qapplication.h>
45 #include <qbuttongroup.h>
46 #include <qgroupbox.h>
48 #include <qlineedit.h>
49 #include <qpushbutton.h>
50 #include <qradiobutton.h>
53 #include <qvalidator.h>
58 //=================================================================================
59 // class : SMESHGUI_RevolutionDlg()
61 //=================================================================================
62 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
63 bool modal, WFlags fl )
64 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
65 Qt::WDestructiveClose)
67 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE")));
68 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE")));
69 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
72 setName( "SMESHGUI_RevolutionDlg" );
74 setCaption( tr( "REVOLUTION_AROUND_AXIS" ) );
75 setSizeGripEnabled( TRUE );
76 SMESHGUI_RevolutionDlgLayout = new QGridLayout( this );
77 SMESHGUI_RevolutionDlgLayout->setSpacing( 6 );
78 SMESHGUI_RevolutionDlgLayout->setMargin( 11 );
80 /***************************************************************/
81 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
82 GroupConstructors->setTitle( tr( "SMESH_REVOLUTION" ) );
83 GroupConstructors->setExclusive( TRUE );
84 GroupConstructors->setColumnLayout(0, Qt::Vertical );
85 GroupConstructors->layout()->setSpacing( 0 );
86 GroupConstructors->layout()->setMargin( 0 );
87 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
88 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
89 GroupConstructorsLayout->setSpacing( 6 );
90 GroupConstructorsLayout->setMargin( 11 );
91 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
92 RadioButton1->setText( tr( "" ) );
93 RadioButton1->setPixmap( image0 );
94 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
95 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
96 RadioButton2->setText( tr( "" ) );
97 RadioButton2->setPixmap( image1 );
98 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
99 SMESHGUI_RevolutionDlgLayout->addWidget( GroupConstructors, 0, 0 );
101 /***************************************************************/
102 GroupButtons = new QGroupBox( this, "GroupButtons" );
103 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
104 GroupButtons->setTitle( tr( "" ) );
105 GroupButtons->setColumnLayout(0, Qt::Vertical );
106 GroupButtons->layout()->setSpacing( 0 );
107 GroupButtons->layout()->setMargin( 0 );
108 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
109 GroupButtonsLayout->setAlignment( Qt::AlignTop );
110 GroupButtonsLayout->setSpacing( 6 );
111 GroupButtonsLayout->setMargin( 11 );
112 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
113 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
114 buttonCancel->setAutoDefault( TRUE );
115 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
116 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
117 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
118 buttonApply->setAutoDefault( TRUE );
119 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
120 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
121 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
122 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
123 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
124 buttonOk->setAutoDefault( TRUE );
125 buttonOk->setDefault( TRUE );
126 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
127 SMESHGUI_RevolutionDlgLayout->addWidget( GroupButtons, 2, 0 );
129 /***************************************************************/
130 GroupArguments = new QGroupBox( this, "GroupArguments" );
131 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
132 GroupArguments->setColumnLayout(0, Qt::Vertical );
133 GroupArguments->layout()->setSpacing( 0 );
134 GroupArguments->layout()->setMargin( 0 );
135 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
136 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
137 GroupArgumentsLayout->setSpacing( 6 );
138 GroupArgumentsLayout->setMargin( 11 );
140 // Controls for elements selection
141 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
142 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
143 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
145 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
146 SelectElementsButton->setText( tr( "" ) );
147 SelectElementsButton->setPixmap( image2 );
148 SelectElementsButton->setToggleButton( FALSE );
149 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
151 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
152 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
153 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
155 // Controls for axis defining
156 GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" );
157 GroupAxis->setTitle( tr( "SMESH_AXIS" ) );
158 GroupAxis->setColumnLayout(0, Qt::Vertical );
159 GroupAxis->layout()->setSpacing( 0 );
160 GroupAxis->layout()->setMargin( 0 );
161 QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() );
162 GroupAxisLayout->setAlignment( Qt::AlignTop );
163 GroupAxisLayout->setSpacing( 6 );
164 GroupAxisLayout->setMargin( 11 );
166 TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" );
167 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
168 GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 );
170 SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" );
171 SelectPointButton->setPixmap( image2 );
172 GroupAxisLayout->addWidget( SelectPointButton, 0, 1 );
174 TextLabelX = new QLabel( GroupAxis, "TextLabelX" );
175 TextLabelX->setText( tr( "SMESH_X" ) );
176 GroupAxisLayout->addWidget( TextLabelX, 0, 2 );
178 SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X");
179 GroupAxisLayout->addWidget( SpinBox_X, 0, 3 );
181 TextLabelY = new QLabel( GroupAxis, "TextLabelY" );
182 TextLabelY->setText( tr( "SMESH_Y" ) );
183 GroupAxisLayout->addWidget( TextLabelY, 0, 4 );
185 SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y");
186 GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 );
188 TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" );
189 TextLabelZ->setText( tr( "SMESH_Z" ) );
190 GroupAxisLayout->addWidget( TextLabelZ, 0, 6 );
192 SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z");
193 GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 );
195 TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" );
196 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
197 GroupAxisLayout->addWidget( TextLabelVector, 1, 0 );
199 SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" );
200 SelectVectorButton->setPixmap( image2 );
201 GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 );
203 TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" );
204 TextLabelDX->setText( tr( "SMESH_DX" ) );
205 GroupAxisLayout->addWidget( TextLabelDX, 1, 2 );
207 SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX");
208 GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 );
210 TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" );
211 TextLabelDY->setText( tr( "SMESH_DY" ) );
212 GroupAxisLayout->addWidget( TextLabelDY, 1, 4 );
214 SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY");
215 GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 );
217 TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" );
218 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
219 GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 );
221 SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ");
222 GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 );
224 GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 1, 1, 0, 3 );
226 // Controls for angle defining
227 TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" );
228 TextLabelAngle->setText( tr( "SMESH_ANGLE" ) );
229 GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 2, 2, 0, 1 );
231 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
232 GroupArgumentsLayout->addWidget( SpinBox_Angle, 2, 2 );
234 // Controls for nb. steps defining
235 TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" );
236 TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) );
237 GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 3, 3, 0, 1 );
239 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
240 GroupArgumentsLayout->addWidget( SpinBox_NbSteps, 3, 2 );
242 // Controls for tolerance defining
243 TextLabelTolerance = new QLabel( GroupArguments, "TextLabelTolerance" );
244 TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) );
245 GroupArgumentsLayout->addMultiCellWidget( TextLabelTolerance, 4, 4, 0, 1 );
247 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
248 GroupArgumentsLayout->addWidget( SpinBox_Tolerance, 4, 2 );
250 SMESHGUI_RevolutionDlgLayout->addWidget( GroupArguments, 1, 0 );
252 /* Initialisations */
253 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
254 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
256 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
258 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
260 SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
262 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
263 SpinBox_NbSteps->setValidator(anIntValidator);
264 SpinBox_NbSteps->setRange( 1, 999999 );
266 SpinBox_Tolerance->RangeStepAndValidator( 0.0, +999999.999, 0.1, 6 );
268 GroupArguments->show();
269 RadioButton1->setChecked( TRUE );
272 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
273 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
276 /* signals and slots connections */
277 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
278 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
279 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
280 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
282 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
283 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
284 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
286 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
287 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
288 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
290 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
291 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
292 /* to close dialog if study change */
293 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
294 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
295 SLOT( onTextChange( const QString& )));
297 /* Move widget on the botton right corner of main widget */
299 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
301 this->show() ; /* displays Dialog */
303 ConstructorsClicked(0);
306 //=================================================================================
307 // function : ~SMESHGUI_RevolutionDlg()
308 // purpose : Destroys the object and frees any allocated resources
309 //=================================================================================
310 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
312 // no need to delete child widgets, Qt does it all for us
316 //=================================================================================
319 //=================================================================================
320 void SMESHGUI_RevolutionDlg::Init()
324 SpinBox_X->SetValue(0.0);
325 SpinBox_Y->SetValue(0.0);
326 SpinBox_Z->SetValue(0.0);
327 SpinBox_DX->SetValue(0.0);
328 SpinBox_DY->SetValue(0.0);
329 SpinBox_DZ->SetValue(0.0);
331 SpinBox_Angle->SetValue(45);
332 SpinBox_NbSteps->setValue(1);
333 SpinBox_Tolerance->SetValue(1e-05);
335 myEditCurrentArgument = (QWidget*)LineEditElements;
336 LineEditElements->setFocus();
339 myMesh = SMESH::SMESH_Mesh::_nil();
341 SelectionIntoArgument();
345 //=================================================================================
346 // function : ConstructorsClicked()
347 // purpose : Radio button management
348 //=================================================================================
349 void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId)
351 disconnect(mySelection, 0, this, 0);
352 mySelection->ClearIObjects();
353 mySelection->ClearFilters();
355 myEditCurrentArgument = (QWidget*)LineEditElements;
356 LineEditElements->setText("");
357 LineEditElements->setFocus();
359 switch(constructorId)
363 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
364 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
369 GroupArguments->setTitle( tr( "REVOLUTION_2D" ) );
370 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
374 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
378 //=================================================================================
379 // function : ClickOnApply()
381 //=================================================================================
382 void SMESHGUI_RevolutionDlg::ClickOnApply()
384 if (mySMESHGUI->ActiveStudyLocked())
387 if ( myNbOkElements && IsAxisOk())
389 QStringList aListElementsId = QStringList::split( " ", LineEditElements->text(), false);
391 SMESH::long_array_var anElementsId = new SMESH::long_array;
393 anElementsId->length( aListElementsId.count() );
394 for ( int i = 0; i < aListElementsId.count(); i++ )
395 anElementsId[i] = aListElementsId[i].toInt();
397 SMESH::AxisStruct anAxis;
399 anAxis.x = SpinBox_X->GetValue();
400 anAxis.y = SpinBox_Y->GetValue();
401 anAxis.z = SpinBox_Z->GetValue();;
402 anAxis.vx = SpinBox_DX->GetValue();
403 anAxis.vy = SpinBox_DY->GetValue();
404 anAxis.vz = SpinBox_DZ->GetValue();
406 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
407 long aNbSteps = (long)SpinBox_NbSteps->value();
408 double aTolerance = SpinBox_Tolerance->GetValue();
412 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
413 QApplication::setOverrideCursor(Qt::waitCursor);
414 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
415 QApplication::restoreOverrideCursor();
421 mySelection->ClearIObjects();
427 //=================================================================================
428 // function : ClickOnOk()
430 //=================================================================================
431 void SMESHGUI_RevolutionDlg::ClickOnOk()
433 this->ClickOnApply() ;
434 this->ClickOnCancel() ;
438 //=================================================================================
439 // function : ClickOnCancel()
441 //=================================================================================
442 void SMESHGUI_RevolutionDlg::ClickOnCancel()
444 mySelection->ClearFilters();
445 mySelection->ClearIObjects();
446 SMESH::SetPointRepresentation(false);
447 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
448 disconnect( mySelection, 0, this, 0 );
449 mySMESHGUI->ResetState() ;
453 //=======================================================================
454 //function : onTextChange
456 //=======================================================================
458 void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText)
460 QLineEdit* send = (QLineEdit*)sender();
462 if ( myBusy ) return;
465 if (send == LineEditElements)
468 buttonOk->setEnabled( false );
469 buttonApply->setEnabled( false );
471 // hilight entered elements
472 SMDS_Mesh* aMesh = 0;
474 aMesh = myActor->GetObject()->GetMesh();
478 mySelection->ClearIObjects();
479 mySelection->AddIObject( myActor->getIO() );
481 QStringList aListId = QStringList::split( " ", theNewText, false);
483 if (send == LineEditElements) {
484 for ( int i = 0; i < aListId.count(); i++ ) {
485 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
487 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
488 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
495 if ( myNbOkElements && IsAxisOk() ) {
496 buttonOk->setEnabled( true );
497 buttonApply->setEnabled( true );
503 //=================================================================================
504 // function : SelectionIntoArgument()
505 // purpose : Called when selection as changed or other case
506 //=================================================================================
507 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
509 if ( myBusy ) return;
514 QString aString = "";
517 if (myEditCurrentArgument == (QWidget*)LineEditElements)
518 LineEditElements->setText( aString );
521 if ( !GroupButtons->isEnabled() ) // inactive
525 int nbSel = mySelection->IObjectCount();
529 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
530 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
531 myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
533 if (myMesh->_is_nil() || !myActor)
538 if (myEditCurrentArgument == (QWidget*)LineEditElements)
540 buttonOk->setEnabled( false );
541 buttonApply->setEnabled( false );
543 // get selected elements
544 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString);
547 LineEditElements->setText( aString );
551 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
555 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
559 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
567 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
569 SpinBox_X->SetValue(x);
570 SpinBox_Y->SetValue(y);
571 SpinBox_Z->SetValue(z);
573 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
575 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
576 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
577 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
582 if (myEditCurrentArgument == (QWidget*)LineEditElements)
583 myNbOkElements = true;
585 if(myNbOkElements && IsAxisOk())
587 buttonOk->setEnabled( true );
588 buttonApply->setEnabled( true );
593 //=================================================================================
594 // function : SetEditCurrentArgument()
596 //=================================================================================
597 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
599 QPushButton* send = (QPushButton*)sender();
600 disconnect( mySelection, 0, this, 0 );
601 mySelection->ClearIObjects();
602 mySelection->ClearFilters();
604 if(send == SelectElementsButton) {
605 myEditCurrentArgument = (QWidget*)LineEditElements;
606 SMESH::SetPointRepresentation(false);
607 int aConstructorId = GetConstructorId();
608 if (aConstructorId == 0)
609 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
610 else if (aConstructorId == 1)
611 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
613 else if (send == SelectPointButton)
615 myEditCurrentArgument = (QWidget*)SpinBox_X;
616 SMESH::SetPointRepresentation(true);
617 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
619 else if (send == SelectVectorButton)
621 myEditCurrentArgument = (QWidget*)SpinBox_DX;
622 SMESH::SetPointRepresentation(true);
623 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
626 myEditCurrentArgument->setFocus();
627 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
628 SelectionIntoArgument() ;
631 //=================================================================================
632 // function : DeactivateActiveDialog()
634 //=================================================================================
635 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
637 if ( GroupConstructors->isEnabled() ) {
638 GroupConstructors->setEnabled(false) ;
639 GroupArguments->setEnabled(false) ;
640 GroupButtons->setEnabled(false) ;
641 mySMESHGUI->ResetState() ;
642 mySMESHGUI->SetActiveDialogBox(0) ;
648 //=================================================================================
649 // function : ActivateThisDialog()
651 //=================================================================================
652 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
654 /* Emit a signal to deactivate the active dialog */
655 mySMESHGUI->EmitSignalDeactivateDialog() ;
656 GroupConstructors->setEnabled(true) ;
657 GroupArguments->setEnabled(true) ;
658 GroupButtons->setEnabled(true) ;
660 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
662 ConstructorsClicked(GetConstructorId());
663 SelectionIntoArgument();
667 //=================================================================================
668 // function : enterEvent()
670 //=================================================================================
671 void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e)
673 if ( GroupConstructors->isEnabled() )
675 ActivateThisDialog() ;
680 //=================================================================================
681 // function : closeEvent()
683 //=================================================================================
684 void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e )
686 /* same than click on cancel button */
687 this->ClickOnCancel() ;
692 //=======================================================================
693 //function : hideEvent
694 //purpose : caused by ESC key
695 //=======================================================================
697 void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e )
699 if ( !isMinimized() )
704 //=================================================================================
705 // function : GetConstructorId()
707 //=================================================================================
708 int SMESHGUI_RevolutionDlg::GetConstructorId()
710 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
711 return GroupConstructors->id( GroupConstructors->selected() );
716 //=================================================================================
717 // function : IsAxisOk()
719 //=================================================================================
720 bool SMESHGUI_RevolutionDlg::IsAxisOk()
722 return (SpinBox_DX->GetValue() != 0 ||
723 SpinBox_DY->GetValue() != 0 ||
724 SpinBox_DZ->GetValue() != 0);
728 //=================================================================================
729 // function : onVectorChanged()
731 //=================================================================================
732 void SMESHGUI_RevolutionDlg::onVectorChanged()
736 buttonOk->setEnabled( true );
737 buttonApply->setEnabled( true );
741 buttonOk->setEnabled( false );
742 buttonApply->setEnabled( false );