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_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESH_Actor.h"
37 #include "SMESH_TypeFilter.hxx"
38 #include "SMDS_Mesh.hxx"
40 #include "QAD_Application.h"
41 #include "QAD_Desktop.h"
42 #include "QAD_MessageBox.h"
43 #include "utilities.h"
46 #include <qapplication.h>
47 #include <qbuttongroup.h>
48 #include <qgroupbox.h>
50 #include <qlineedit.h>
51 #include <qpushbutton.h>
52 #include <qradiobutton.h>
53 #include <qcheckbox.h>
56 #include <qvalidator.h>
61 //=================================================================================
62 // class : SMESHGUI_RevolutionDlg()
64 //=================================================================================
65 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
66 bool modal, WFlags fl )
67 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
68 Qt::WDestructiveClose)
70 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE")));
71 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE")));
72 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
75 setName( "SMESHGUI_RevolutionDlg" );
77 setCaption( tr( "REVOLUTION_AROUND_AXIS" ) );
78 setSizeGripEnabled( TRUE );
79 SMESHGUI_RevolutionDlgLayout = new QGridLayout( this );
80 SMESHGUI_RevolutionDlgLayout->setSpacing( 6 );
81 SMESHGUI_RevolutionDlgLayout->setMargin( 11 );
83 /***************************************************************/
84 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
85 GroupConstructors->setTitle( tr( "SMESH_REVOLUTION" ) );
86 GroupConstructors->setExclusive( TRUE );
87 GroupConstructors->setColumnLayout(0, Qt::Vertical );
88 GroupConstructors->layout()->setSpacing( 0 );
89 GroupConstructors->layout()->setMargin( 0 );
90 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
91 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
92 GroupConstructorsLayout->setSpacing( 6 );
93 GroupConstructorsLayout->setMargin( 11 );
94 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
95 RadioButton1->setText( tr( "" ) );
96 RadioButton1->setPixmap( image0 );
97 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
98 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
99 RadioButton2->setText( tr( "" ) );
100 RadioButton2->setPixmap( image1 );
101 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
102 SMESHGUI_RevolutionDlgLayout->addWidget( GroupConstructors, 0, 0 );
104 /***************************************************************/
105 GroupButtons = new QGroupBox( this, "GroupButtons" );
106 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
107 GroupButtons->setTitle( tr( "" ) );
108 GroupButtons->setColumnLayout(0, Qt::Vertical );
109 GroupButtons->layout()->setSpacing( 0 );
110 GroupButtons->layout()->setMargin( 0 );
111 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
112 GroupButtonsLayout->setAlignment( Qt::AlignTop );
113 GroupButtonsLayout->setSpacing( 6 );
114 GroupButtonsLayout->setMargin( 11 );
115 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
116 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
117 buttonCancel->setAutoDefault( TRUE );
118 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
119 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
120 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
121 buttonApply->setAutoDefault( TRUE );
122 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
123 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
124 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
125 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
126 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
127 buttonOk->setAutoDefault( TRUE );
128 buttonOk->setDefault( TRUE );
129 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
130 SMESHGUI_RevolutionDlgLayout->addWidget( GroupButtons, 2, 0 );
132 /***************************************************************/
133 GroupArguments = new QGroupBox( this, "GroupArguments" );
134 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
135 GroupArguments->setColumnLayout(0, Qt::Vertical );
136 GroupArguments->layout()->setSpacing( 0 );
137 GroupArguments->layout()->setMargin( 0 );
138 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
139 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
140 GroupArgumentsLayout->setSpacing( 6 );
141 GroupArgumentsLayout->setMargin( 11 );
143 // Controls for elements selection
144 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
145 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
146 TextLabelElements->setFixedWidth(74);
147 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
149 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
150 SelectElementsButton->setText( tr( "" ) );
151 SelectElementsButton->setPixmap( image2 );
152 SelectElementsButton->setToggleButton( FALSE );
153 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
155 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
156 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
157 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
159 // Control for the whole mesh selection
160 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
161 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
162 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 3 );
164 // Controls for axis defining
165 GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" );
166 GroupAxis->setTitle( tr( "SMESH_AXIS" ) );
167 GroupAxis->setColumnLayout(0, Qt::Vertical );
168 GroupAxis->layout()->setSpacing( 0 );
169 GroupAxis->layout()->setMargin( 0 );
170 QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() );
171 GroupAxisLayout->setAlignment( Qt::AlignTop );
172 GroupAxisLayout->setSpacing( 6 );
173 GroupAxisLayout->setMargin( 11 );
175 TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" );
176 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
177 GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 );
179 SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" );
180 SelectPointButton->setPixmap( image2 );
181 GroupAxisLayout->addWidget( SelectPointButton, 0, 1 );
183 TextLabelX = new QLabel( GroupAxis, "TextLabelX" );
184 TextLabelX->setText( tr( "SMESH_X" ) );
185 GroupAxisLayout->addWidget( TextLabelX, 0, 2 );
187 SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X");
188 GroupAxisLayout->addWidget( SpinBox_X, 0, 3 );
190 TextLabelY = new QLabel( GroupAxis, "TextLabelY" );
191 TextLabelY->setText( tr( "SMESH_Y" ) );
192 GroupAxisLayout->addWidget( TextLabelY, 0, 4 );
194 SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y");
195 GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 );
197 TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" );
198 TextLabelZ->setText( tr( "SMESH_Z" ) );
199 GroupAxisLayout->addWidget( TextLabelZ, 0, 6 );
201 SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z");
202 GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 );
204 TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" );
205 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
206 GroupAxisLayout->addWidget( TextLabelVector, 1, 0 );
208 SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" );
209 SelectVectorButton->setPixmap( image2 );
210 GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 );
212 TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" );
213 TextLabelDX->setText( tr( "SMESH_DX" ) );
214 GroupAxisLayout->addWidget( TextLabelDX, 1, 2 );
216 SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX");
217 GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 );
219 TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" );
220 TextLabelDY->setText( tr( "SMESH_DY" ) );
221 GroupAxisLayout->addWidget( TextLabelDY, 1, 4 );
223 SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY");
224 GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 );
226 TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" );
227 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
228 GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 );
230 SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ");
231 GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 );
233 GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 3 );
235 // Controls for angle defining
236 TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" );
237 TextLabelAngle->setText( tr( "SMESH_ANGLE" ) );
238 GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 );
240 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
241 GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 );
243 // Controls for nb. steps defining
244 TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" );
245 TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) );
246 GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 4, 4, 0, 1 );
248 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
249 GroupArgumentsLayout->addWidget( SpinBox_NbSteps, 4, 2 );
251 // Controls for tolerance defining
252 TextLabelTolerance = new QLabel( GroupArguments, "TextLabelTolerance" );
253 TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) );
254 GroupArgumentsLayout->addMultiCellWidget( TextLabelTolerance, 5, 5, 0, 1 );
256 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
257 GroupArgumentsLayout->addWidget( SpinBox_Tolerance, 5, 2 );
259 SMESHGUI_RevolutionDlgLayout->addWidget( GroupArguments, 1, 0 );
261 /* Initialisations */
262 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
263 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
264 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
265 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
266 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
267 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
269 SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
271 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
272 SpinBox_NbSteps->setValidator(anIntValidator);
273 SpinBox_NbSteps->setRange( 1, 999999 );
275 SpinBox_Tolerance->RangeStepAndValidator( 0.0, +999999.999, 0.1, 6 );
277 GroupArguments->show();
278 RadioButton1->setChecked( TRUE );
281 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
282 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
284 // Costruction of the logical filter
285 SMESH_ListOfFilter aListOfFilters;
286 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
287 if ( !aMeshOrSubMeshFilter.IsNull() )
288 aListOfFilters.Append( aMeshOrSubMeshFilter );
289 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
290 if ( !aSmeshGroupFilter.IsNull() )
291 aListOfFilters.Append( aSmeshGroupFilter );
293 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
296 /* signals and slots connections */
297 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
298 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
299 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
300 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
302 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
303 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
304 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
306 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
307 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
308 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
310 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
311 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
312 /* to close dialog if study change */
313 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
314 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
315 SLOT( onTextChange( const QString& )));
316 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
317 SLOT( onSelectMesh( bool )));
319 /* Move widget on the botton right corner of main widget */
321 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
323 this->show() ; /* displays Dialog */
325 ConstructorsClicked(0);
328 //=================================================================================
329 // function : ~SMESHGUI_RevolutionDlg()
330 // purpose : Destroys the object and frees any allocated resources
331 //=================================================================================
332 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
334 // no need to delete child widgets, Qt does it all for us
338 //=================================================================================
341 //=================================================================================
342 void SMESHGUI_RevolutionDlg::Init( bool ResetControls )
346 myEditCurrentArgument = 0;
347 LineEditElements->clear();
352 myMesh = SMESH::SMESH_Mesh::_nil();
356 SpinBox_X->SetValue(0.0);
357 SpinBox_Y->SetValue(0.0);
358 SpinBox_Z->SetValue(0.0);
359 SpinBox_DX->SetValue(0.0);
360 SpinBox_DY->SetValue(0.0);
361 SpinBox_DZ->SetValue(0.0);
363 SpinBox_Angle->SetValue(45);
364 SpinBox_NbSteps->setValue(1);
365 SpinBox_Tolerance->SetValue(1e-05);
367 CheckBoxMesh->setChecked(false);
368 onSelectMesh( false );
373 //=================================================================================
374 // function : ConstructorsClicked()
375 // purpose : Radio button management
376 //=================================================================================
377 void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId)
379 disconnect(mySelection, 0, this, 0);
381 Selection_Mode aSelMode = ActorSelection;
383 switch(constructorId)
387 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
388 aSelMode = EdgeSelection;
393 GroupArguments->setTitle( tr( "REVOLUTION_2D" ) );
394 aSelMode = FaceSelection;
399 if (myEditCurrentArgument != (QWidget*)LineEditElements)
400 SMESH::SetPointRepresentation(false);
402 if (!CheckBoxMesh->isChecked())
403 QAD_Application::getDesktop()->SetSelectionMode( aSelMode, true );
405 myEditCurrentArgument = (QWidget*)LineEditElements;
406 LineEditElements->setFocus();
408 if (CheckBoxMesh->isChecked())
411 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
415 //=================================================================================
416 // function : ClickOnApply()
418 //=================================================================================
419 void SMESHGUI_RevolutionDlg::ClickOnApply()
421 if (mySMESHGUI->ActiveStudyLocked())
424 if ( myNbOkElements && IsAxisOk())
426 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
428 SMESH::long_array_var anElementsId = new SMESH::long_array;
430 anElementsId->length( aListElementsId.count() );
431 for ( int i = 0; i < aListElementsId.count(); i++ )
432 anElementsId[i] = aListElementsId[i].toInt();
434 SMESH::AxisStruct anAxis;
436 anAxis.x = SpinBox_X->GetValue();
437 anAxis.y = SpinBox_Y->GetValue();
438 anAxis.z = SpinBox_Z->GetValue();;
439 anAxis.vx = SpinBox_DX->GetValue();
440 anAxis.vy = SpinBox_DY->GetValue();
441 anAxis.vz = SpinBox_DZ->GetValue();
443 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
444 long aNbSteps = (long)SpinBox_NbSteps->value();
445 double aTolerance = SpinBox_Tolerance->GetValue();
449 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
450 QApplication::setOverrideCursor(Qt::waitCursor);
451 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
452 QApplication::restoreOverrideCursor();
458 mySelection->ClearIObjects();
461 ConstructorsClicked( GetConstructorId() );
465 //=================================================================================
466 // function : ClickOnOk()
468 //=================================================================================
469 void SMESHGUI_RevolutionDlg::ClickOnOk()
476 //=================================================================================
477 // function : ClickOnCancel()
479 //=================================================================================
480 void SMESHGUI_RevolutionDlg::ClickOnCancel()
482 mySelection->ClearFilters();
483 mySelection->ClearIObjects();
484 SMESH::SetPointRepresentation(false);
485 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
486 disconnect( mySelection, 0, this, 0 );
487 mySMESHGUI->ResetState() ;
491 //=======================================================================
492 //function : onTextChange
494 //=======================================================================
496 void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText)
498 QLineEdit* send = (QLineEdit*)sender();
500 if ( myBusy ) return;
503 if (send == LineEditElements)
506 buttonOk->setEnabled( false );
507 buttonApply->setEnabled( false );
509 // hilight entered elements
510 SMDS_Mesh* aMesh = 0;
512 aMesh = myActor->GetObject()->GetMesh();
515 mySelection->ClearIObjects();
516 mySelection->AddIObject( myActor->getIO() );
518 QStringList aListId = QStringList::split( " ", theNewText, false);
520 if (send == LineEditElements) {
521 for ( int i = 0; i < aListId.count(); i++ ) {
522 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
524 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
525 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
529 myElementsId = theNewText;
533 if ( myNbOkElements && IsAxisOk() ) {
534 buttonOk->setEnabled( true );
535 buttonApply->setEnabled( true );
541 //=================================================================================
542 // function : SelectionIntoArgument()
543 // purpose : Called when selection as changed or other case
544 //=================================================================================
545 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
547 if ( myBusy ) return;
551 QString aString = "";
554 if (myEditCurrentArgument == (QWidget*)LineEditElements)
556 LineEditElements->setText( aString );
558 buttonOk->setEnabled( false );
559 buttonApply->setEnabled( false );
563 if ( !GroupButtons->isEnabled() ) // inactive
567 int nbSel = mySelection->IObjectCount();
571 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
572 myMesh = SMESH::GetMeshByIO(IO);
573 if(myMesh->_is_nil())
575 myActor = SMESH::FindActorByObject(myMesh);
581 if (myEditCurrentArgument == (QWidget*)LineEditElements)
585 if (CheckBoxMesh->isChecked())
587 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
589 int aConstructorId = GetConstructorId();
591 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
594 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
598 if (aConstructorId == 0)
600 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
602 while ( anIter->more() )
604 const SMDS_MeshEdge * edge = anIter->next();
606 myElementsId += QString(" %1").arg(edge->GetID());
611 else if (aConstructorId == 1)
613 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
614 while ( anIter->more() )
616 const SMDS_MeshFace * face = anIter->next();
618 myElementsId += QString(" %1").arg(face->GetID());
624 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
627 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
629 // get IDs from submesh
630 SMESH::long_array_var anElementsIds = new SMESH::long_array;
631 if (aConstructorId == 0)
632 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
633 else if (aConstructorId == 1)
634 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
636 for ( int i = 0; i < anElementsIds->length(); i++ )
637 myElementsId += QString(" %1").arg(anElementsIds[i]);
638 aNbUnits = anElementsIds->length();
643 SMESH::SMESH_GroupBase_var aGroup =
644 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
645 if (aGroup->_is_nil())
648 if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
649 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) )
652 // get IDs from smesh group
653 SMESH::long_array_var anElementsIds = new SMESH::long_array;
654 anElementsIds = aGroup->GetListOfID();
655 for ( int i = 0; i < anElementsIds->length(); i++ )
656 myElementsId += QString(" %1").arg(anElementsIds[i]);
657 aNbUnits = anElementsIds->length();
662 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
663 myElementsId = aString;
669 myNbOkElements = true;
673 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
677 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
681 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
689 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
691 SpinBox_X->SetValue(x);
692 SpinBox_Y->SetValue(y);
693 SpinBox_Z->SetValue(z);
695 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
697 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
698 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
699 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
704 if (myEditCurrentArgument == (QWidget*)LineEditElements)
705 LineEditElements->setText( aString );
709 if(myNbOkElements && IsAxisOk())
711 buttonOk->setEnabled( true );
712 buttonApply->setEnabled( true );
717 //=================================================================================
718 // function : SetEditCurrentArgument()
720 //=================================================================================
721 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
723 QPushButton* send = (QPushButton*)sender();
725 disconnect( mySelection, 0, this, 0 );
726 mySelection->ClearIObjects();
727 mySelection->ClearFilters();
729 if(send == SelectElementsButton) {
730 myEditCurrentArgument = (QWidget*)LineEditElements;
731 SMESH::SetPointRepresentation(false);
732 if (CheckBoxMesh->isChecked())
734 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
735 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
739 int aConstructorId = GetConstructorId();
740 if (aConstructorId == 0)
741 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
742 else if (aConstructorId == 1)
743 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
746 else if (send == SelectPointButton)
748 myEditCurrentArgument = (QWidget*)SpinBox_X;
749 SMESH::SetPointRepresentation(true);
750 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
752 else if (send == SelectVectorButton)
754 myEditCurrentArgument = (QWidget*)SpinBox_DX;
755 SMESH::SetPointRepresentation(true);
756 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
759 myEditCurrentArgument->setFocus();
760 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
761 SelectionIntoArgument() ;
764 //=================================================================================
765 // function : DeactivateActiveDialog()
767 //=================================================================================
768 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
770 if ( GroupConstructors->isEnabled() ) {
771 GroupConstructors->setEnabled(false) ;
772 GroupArguments->setEnabled(false) ;
773 GroupButtons->setEnabled(false) ;
774 mySMESHGUI->ResetState() ;
775 mySMESHGUI->SetActiveDialogBox(0) ;
780 //=================================================================================
781 // function : ActivateThisDialog()
783 //=================================================================================
784 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
786 /* Emit a signal to deactivate the active dialog */
787 mySMESHGUI->EmitSignalDeactivateDialog() ;
788 GroupConstructors->setEnabled(true) ;
789 GroupArguments->setEnabled(true) ;
790 GroupButtons->setEnabled(true) ;
792 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
794 ConstructorsClicked(GetConstructorId());
795 SelectionIntoArgument();
799 //=================================================================================
800 // function : enterEvent()
802 //=================================================================================
803 void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e)
805 if ( GroupConstructors->isEnabled() )
807 ActivateThisDialog() ;
811 //=================================================================================
812 // function : closeEvent()
814 //=================================================================================
815 void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e )
817 /* same than click on cancel button */
818 this->ClickOnCancel() ;
823 //=======================================================================
824 //function : hideEvent
825 //purpose : caused by ESC key
826 //=======================================================================
828 void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e )
830 if ( !isMinimized() )
835 //=================================================================================
836 // function : GetConstructorId()
838 //=================================================================================
839 int SMESHGUI_RevolutionDlg::GetConstructorId()
841 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
842 return GroupConstructors->id( GroupConstructors->selected() );
847 //=================================================================================
848 // function : IsAxisOk()
850 //=================================================================================
851 bool SMESHGUI_RevolutionDlg::IsAxisOk()
853 return (SpinBox_DX->GetValue() != 0 ||
854 SpinBox_DY->GetValue() != 0 ||
855 SpinBox_DZ->GetValue() != 0);
859 //=================================================================================
860 // function : onVectorChanged()
862 //=================================================================================
863 void SMESHGUI_RevolutionDlg::onVectorChanged()
867 buttonOk->setEnabled( true );
868 buttonApply->setEnabled( true );
872 buttonOk->setEnabled( false );
873 buttonApply->setEnabled( false );
878 //=======================================================================
879 //function : onSelectMesh
881 //=======================================================================
882 void SMESHGUI_RevolutionDlg::onSelectMesh ( bool toSelectMesh )
885 TextLabelElements->setText( tr( "SMESH_NAME" ) );
887 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
889 if (myEditCurrentArgument != LineEditElements)
891 LineEditElements->clear();
895 mySelection->ClearFilters() ;
896 SMESH::SetPointRepresentation(false);
900 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
901 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
902 LineEditElements->setReadOnly(true);
906 int aConstructorId = GetConstructorId();
907 if (aConstructorId == 0)
908 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
909 else if (aConstructorId == 0)
910 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
912 LineEditElements->setReadOnly(false);
913 onTextChange(LineEditElements->text());
916 SelectionIntoArgument();