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>
60 #include "SALOMEconfig.h"
61 #include CORBA_SERVER_HEADER(SMESH_Group)
65 //=================================================================================
66 // class : SMESHGUI_RevolutionDlg()
68 //=================================================================================
69 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
70 bool modal, WFlags fl )
71 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
72 Qt::WDestructiveClose)
74 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE")));
75 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE")));
76 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
79 setName( "SMESHGUI_RevolutionDlg" );
81 setCaption( tr( "REVOLUTION_AROUND_AXIS" ) );
82 setSizeGripEnabled( TRUE );
83 SMESHGUI_RevolutionDlgLayout = new QGridLayout( this );
84 SMESHGUI_RevolutionDlgLayout->setSpacing( 6 );
85 SMESHGUI_RevolutionDlgLayout->setMargin( 11 );
87 /***************************************************************/
88 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
89 GroupConstructors->setTitle( tr( "SMESH_REVOLUTION" ) );
90 GroupConstructors->setExclusive( TRUE );
91 GroupConstructors->setColumnLayout(0, Qt::Vertical );
92 GroupConstructors->layout()->setSpacing( 0 );
93 GroupConstructors->layout()->setMargin( 0 );
94 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
95 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
96 GroupConstructorsLayout->setSpacing( 6 );
97 GroupConstructorsLayout->setMargin( 11 );
98 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
99 RadioButton1->setText( tr( "" ) );
100 RadioButton1->setPixmap( image0 );
101 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
102 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
103 RadioButton2->setText( tr( "" ) );
104 RadioButton2->setPixmap( image1 );
105 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
106 SMESHGUI_RevolutionDlgLayout->addWidget( GroupConstructors, 0, 0 );
108 /***************************************************************/
109 GroupButtons = new QGroupBox( this, "GroupButtons" );
110 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
111 GroupButtons->setTitle( tr( "" ) );
112 GroupButtons->setColumnLayout(0, Qt::Vertical );
113 GroupButtons->layout()->setSpacing( 0 );
114 GroupButtons->layout()->setMargin( 0 );
115 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
116 GroupButtonsLayout->setAlignment( Qt::AlignTop );
117 GroupButtonsLayout->setSpacing( 6 );
118 GroupButtonsLayout->setMargin( 11 );
119 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
120 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
121 buttonCancel->setAutoDefault( TRUE );
122 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
123 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
124 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
125 buttonApply->setAutoDefault( TRUE );
126 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
127 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
128 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
129 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
130 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
131 buttonOk->setAutoDefault( TRUE );
132 buttonOk->setDefault( TRUE );
133 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
134 SMESHGUI_RevolutionDlgLayout->addWidget( GroupButtons, 2, 0 );
136 /***************************************************************/
137 GroupArguments = new QGroupBox( this, "GroupArguments" );
138 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
139 GroupArguments->setColumnLayout(0, Qt::Vertical );
140 GroupArguments->layout()->setSpacing( 0 );
141 GroupArguments->layout()->setMargin( 0 );
142 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
143 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
144 GroupArgumentsLayout->setSpacing( 6 );
145 GroupArgumentsLayout->setMargin( 11 );
147 // Controls for elements selection
148 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
149 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
150 TextLabelElements->setFixedWidth(74);
151 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
153 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
154 SelectElementsButton->setText( tr( "" ) );
155 SelectElementsButton->setPixmap( image2 );
156 SelectElementsButton->setToggleButton( FALSE );
157 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
159 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
160 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
161 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
163 // Control for the whole mesh selection
164 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
165 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
166 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 3 );
168 // Controls for axis defining
169 GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" );
170 GroupAxis->setTitle( tr( "SMESH_AXIS" ) );
171 GroupAxis->setColumnLayout(0, Qt::Vertical );
172 GroupAxis->layout()->setSpacing( 0 );
173 GroupAxis->layout()->setMargin( 0 );
174 QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() );
175 GroupAxisLayout->setAlignment( Qt::AlignTop );
176 GroupAxisLayout->setSpacing( 6 );
177 GroupAxisLayout->setMargin( 11 );
179 TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" );
180 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
181 GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 );
183 SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" );
184 SelectPointButton->setPixmap( image2 );
185 GroupAxisLayout->addWidget( SelectPointButton, 0, 1 );
187 TextLabelX = new QLabel( GroupAxis, "TextLabelX" );
188 TextLabelX->setText( tr( "SMESH_X" ) );
189 GroupAxisLayout->addWidget( TextLabelX, 0, 2 );
191 SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X");
192 GroupAxisLayout->addWidget( SpinBox_X, 0, 3 );
194 TextLabelY = new QLabel( GroupAxis, "TextLabelY" );
195 TextLabelY->setText( tr( "SMESH_Y" ) );
196 GroupAxisLayout->addWidget( TextLabelY, 0, 4 );
198 SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y");
199 GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 );
201 TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" );
202 TextLabelZ->setText( tr( "SMESH_Z" ) );
203 GroupAxisLayout->addWidget( TextLabelZ, 0, 6 );
205 SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z");
206 GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 );
208 TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" );
209 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
210 GroupAxisLayout->addWidget( TextLabelVector, 1, 0 );
212 SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" );
213 SelectVectorButton->setPixmap( image2 );
214 GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 );
216 TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" );
217 TextLabelDX->setText( tr( "SMESH_DX" ) );
218 GroupAxisLayout->addWidget( TextLabelDX, 1, 2 );
220 SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX");
221 GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 );
223 TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" );
224 TextLabelDY->setText( tr( "SMESH_DY" ) );
225 GroupAxisLayout->addWidget( TextLabelDY, 1, 4 );
227 SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY");
228 GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 );
230 TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" );
231 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
232 GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 );
234 SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ");
235 GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 );
237 GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 3 );
239 // Controls for angle defining
240 TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" );
241 TextLabelAngle->setText( tr( "SMESH_ANGLE" ) );
242 GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 );
244 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
245 GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 );
247 // Controls for nb. steps defining
248 TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" );
249 TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) );
250 GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 4, 4, 0, 1 );
252 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
253 GroupArgumentsLayout->addWidget( SpinBox_NbSteps, 4, 2 );
255 // Controls for tolerance defining
256 TextLabelTolerance = new QLabel( GroupArguments, "TextLabelTolerance" );
257 TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) );
258 GroupArgumentsLayout->addMultiCellWidget( TextLabelTolerance, 5, 5, 0, 1 );
260 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
261 GroupArgumentsLayout->addWidget( SpinBox_Tolerance, 5, 2 );
263 SMESHGUI_RevolutionDlgLayout->addWidget( GroupArguments, 1, 0 );
265 /* Initialisations */
266 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
267 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
268 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
269 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
270 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
271 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
273 SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
275 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
276 SpinBox_NbSteps->setValidator(anIntValidator);
277 SpinBox_NbSteps->setRange( 1, 999999 );
279 SpinBox_Tolerance->RangeStepAndValidator( 0.0, +999999.999, 0.1, 6 );
281 GroupArguments->show();
282 RadioButton1->setChecked( TRUE );
285 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
286 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
288 // Costruction of the logical filter
289 SMESH_ListOfFilter aListOfFilters;
290 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
291 if ( !aMeshOrSubMeshFilter.IsNull() )
292 aListOfFilters.Append( aMeshOrSubMeshFilter );
293 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
294 if ( !aSmeshGroupFilter.IsNull() )
295 aListOfFilters.Append( aSmeshGroupFilter );
297 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
300 /* signals and slots connections */
301 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
302 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
303 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
304 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
306 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
307 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
308 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
310 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
311 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
312 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
314 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
315 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
316 /* to close dialog if study change */
317 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
318 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
319 SLOT( onTextChange( const QString& )));
320 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
321 SLOT( onSelectMesh( bool )));
323 /* Move widget on the botton right corner of main widget */
325 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
327 this->show() ; /* displays Dialog */
329 ConstructorsClicked(0);
332 //=================================================================================
333 // function : ~SMESHGUI_RevolutionDlg()
334 // purpose : Destroys the object and frees any allocated resources
335 //=================================================================================
336 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
338 // no need to delete child widgets, Qt does it all for us
342 //=================================================================================
345 //=================================================================================
346 void SMESHGUI_RevolutionDlg::Init( bool ResetControls )
350 myEditCurrentArgument = 0;
351 LineEditElements->clear();
356 myMesh = SMESH::SMESH_Mesh::_nil();
360 SpinBox_X->SetValue(0.0);
361 SpinBox_Y->SetValue(0.0);
362 SpinBox_Z->SetValue(0.0);
363 SpinBox_DX->SetValue(0.0);
364 SpinBox_DY->SetValue(0.0);
365 SpinBox_DZ->SetValue(0.0);
367 SpinBox_Angle->SetValue(45);
368 SpinBox_NbSteps->setValue(1);
369 SpinBox_Tolerance->SetValue(1e-05);
371 CheckBoxMesh->setChecked(false);
372 onSelectMesh( false );
377 //=================================================================================
378 // function : ConstructorsClicked()
379 // purpose : Radio button management
380 //=================================================================================
381 void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId)
383 disconnect(mySelection, 0, this, 0);
385 Selection_Mode aSelMode = ActorSelection;
387 switch(constructorId)
391 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
392 aSelMode = EdgeSelection;
397 GroupArguments->setTitle( tr( "REVOLUTION_2D" ) );
398 aSelMode = FaceSelection;
403 if (myEditCurrentArgument != (QWidget*)LineEditElements)
404 SMESH::SetPointRepresentation(false);
406 if (!CheckBoxMesh->isChecked())
407 QAD_Application::getDesktop()->SetSelectionMode( aSelMode, true );
409 myEditCurrentArgument = (QWidget*)LineEditElements;
410 LineEditElements->setFocus();
412 if (CheckBoxMesh->isChecked())
415 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
419 //=================================================================================
420 // function : ClickOnApply()
422 //=================================================================================
423 void SMESHGUI_RevolutionDlg::ClickOnApply()
425 if (mySMESHGUI->ActiveStudyLocked())
428 if ( myNbOkElements && IsAxisOk())
430 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
432 SMESH::long_array_var anElementsId = new SMESH::long_array;
434 anElementsId->length( aListElementsId.count() );
435 for ( int i = 0; i < aListElementsId.count(); i++ )
436 anElementsId[i] = aListElementsId[i].toInt();
438 SMESH::AxisStruct anAxis;
440 anAxis.x = SpinBox_X->GetValue();
441 anAxis.y = SpinBox_Y->GetValue();
442 anAxis.z = SpinBox_Z->GetValue();;
443 anAxis.vx = SpinBox_DX->GetValue();
444 anAxis.vy = SpinBox_DY->GetValue();
445 anAxis.vz = SpinBox_DZ->GetValue();
447 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
448 long aNbSteps = (long)SpinBox_NbSteps->value();
449 double aTolerance = SpinBox_Tolerance->GetValue();
453 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
454 QApplication::setOverrideCursor(Qt::waitCursor);
455 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
456 QApplication::restoreOverrideCursor();
462 mySelection->ClearIObjects();
465 ConstructorsClicked( GetConstructorId() );
469 //=================================================================================
470 // function : ClickOnOk()
472 //=================================================================================
473 void SMESHGUI_RevolutionDlg::ClickOnOk()
480 //=================================================================================
481 // function : ClickOnCancel()
483 //=================================================================================
484 void SMESHGUI_RevolutionDlg::ClickOnCancel()
486 mySelection->ClearFilters();
487 mySelection->ClearIObjects();
488 SMESH::SetPointRepresentation(false);
489 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
490 disconnect( mySelection, 0, this, 0 );
491 mySMESHGUI->ResetState() ;
495 //=======================================================================
496 //function : onTextChange
498 //=======================================================================
500 void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText)
502 QLineEdit* send = (QLineEdit*)sender();
504 if ( myBusy ) return;
507 if (send == LineEditElements)
510 buttonOk->setEnabled( false );
511 buttonApply->setEnabled( false );
513 // hilight entered elements
514 SMDS_Mesh* aMesh = 0;
516 aMesh = myActor->GetObject()->GetMesh();
519 mySelection->ClearIObjects();
520 mySelection->AddIObject( myActor->getIO() );
522 QStringList aListId = QStringList::split( " ", theNewText, false);
524 if (send == LineEditElements) {
525 for ( int i = 0; i < aListId.count(); i++ ) {
526 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
528 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
529 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
533 myElementsId = theNewText;
537 if ( myNbOkElements && IsAxisOk() ) {
538 buttonOk->setEnabled( true );
539 buttonApply->setEnabled( true );
545 //=================================================================================
546 // function : SelectionIntoArgument()
547 // purpose : Called when selection as changed or other case
548 //=================================================================================
549 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
551 if ( myBusy ) return;
555 QString aString = "";
558 if (myEditCurrentArgument == (QWidget*)LineEditElements)
560 LineEditElements->setText( aString );
562 buttonOk->setEnabled( false );
563 buttonApply->setEnabled( false );
567 if ( !GroupButtons->isEnabled() ) // inactive
571 int nbSel = mySelection->IObjectCount();
575 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
576 myMesh = SMESH::GetMeshByIO(IO);
577 if(myMesh->_is_nil())
579 myActor = SMESH::FindActorByObject(myMesh);
585 if (myEditCurrentArgument == (QWidget*)LineEditElements)
589 if (CheckBoxMesh->isChecked())
591 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
593 int aConstructorId = GetConstructorId();
595 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
598 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
602 if (aConstructorId == 0)
604 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
606 while ( anIter->more() )
608 const SMDS_MeshEdge * edge = anIter->next();
610 myElementsId += QString(" %1").arg(edge->GetID());
615 else if (aConstructorId == 1)
617 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
618 while ( anIter->more() )
620 const SMDS_MeshFace * face = anIter->next();
622 myElementsId += QString(" %1").arg(face->GetID());
628 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
631 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
633 // get IDs from submesh
634 SMESH::long_array_var anElementsIds = new SMESH::long_array;
635 if (aConstructorId == 0)
636 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
637 else if (aConstructorId == 1)
638 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
640 for ( int i = 0; i < anElementsIds->length(); i++ )
641 myElementsId += QString(" %1").arg(anElementsIds[i]);
642 aNbUnits = anElementsIds->length();
647 SMESH::SMESH_GroupBase_var aGroup =
648 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
649 if (aGroup->_is_nil())
652 if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
653 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) )
656 // get IDs from smesh group
657 SMESH::long_array_var anElementsIds = new SMESH::long_array;
658 anElementsIds = aGroup->GetListOfID();
659 for ( int i = 0; i < anElementsIds->length(); i++ )
660 myElementsId += QString(" %1").arg(anElementsIds[i]);
661 aNbUnits = anElementsIds->length();
666 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
667 myElementsId = aString;
673 myNbOkElements = true;
677 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
681 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
685 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
693 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
695 SpinBox_X->SetValue(x);
696 SpinBox_Y->SetValue(y);
697 SpinBox_Z->SetValue(z);
699 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
701 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
702 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
703 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
708 if (myEditCurrentArgument == (QWidget*)LineEditElements)
709 LineEditElements->setText( aString );
713 if(myNbOkElements && IsAxisOk())
715 buttonOk->setEnabled( true );
716 buttonApply->setEnabled( true );
721 //=================================================================================
722 // function : SetEditCurrentArgument()
724 //=================================================================================
725 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
727 QPushButton* send = (QPushButton*)sender();
729 disconnect( mySelection, 0, this, 0 );
730 mySelection->ClearIObjects();
731 mySelection->ClearFilters();
733 if(send == SelectElementsButton) {
734 myEditCurrentArgument = (QWidget*)LineEditElements;
735 SMESH::SetPointRepresentation(false);
736 if (CheckBoxMesh->isChecked())
738 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
739 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
743 int aConstructorId = GetConstructorId();
744 if (aConstructorId == 0)
745 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
746 else if (aConstructorId == 1)
747 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
750 else if (send == SelectPointButton)
752 myEditCurrentArgument = (QWidget*)SpinBox_X;
753 SMESH::SetPointRepresentation(true);
754 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
756 else if (send == SelectVectorButton)
758 myEditCurrentArgument = (QWidget*)SpinBox_DX;
759 SMESH::SetPointRepresentation(true);
760 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
763 myEditCurrentArgument->setFocus();
764 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
765 SelectionIntoArgument() ;
768 //=================================================================================
769 // function : DeactivateActiveDialog()
771 //=================================================================================
772 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
774 if ( GroupConstructors->isEnabled() ) {
775 GroupConstructors->setEnabled(false) ;
776 GroupArguments->setEnabled(false) ;
777 GroupButtons->setEnabled(false) ;
778 mySMESHGUI->ResetState() ;
779 mySMESHGUI->SetActiveDialogBox(0) ;
784 //=================================================================================
785 // function : ActivateThisDialog()
787 //=================================================================================
788 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
790 /* Emit a signal to deactivate the active dialog */
791 mySMESHGUI->EmitSignalDeactivateDialog() ;
792 GroupConstructors->setEnabled(true) ;
793 GroupArguments->setEnabled(true) ;
794 GroupButtons->setEnabled(true) ;
796 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
798 ConstructorsClicked(GetConstructorId());
799 SelectionIntoArgument();
803 //=================================================================================
804 // function : enterEvent()
806 //=================================================================================
807 void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e)
809 if ( GroupConstructors->isEnabled() )
811 ActivateThisDialog() ;
815 //=================================================================================
816 // function : closeEvent()
818 //=================================================================================
819 void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e )
821 /* same than click on cancel button */
822 this->ClickOnCancel() ;
827 //=======================================================================
828 //function : hideEvent
829 //purpose : caused by ESC key
830 //=======================================================================
832 void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e )
834 if ( !isMinimized() )
839 //=================================================================================
840 // function : GetConstructorId()
842 //=================================================================================
843 int SMESHGUI_RevolutionDlg::GetConstructorId()
845 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
846 return GroupConstructors->id( GroupConstructors->selected() );
851 //=================================================================================
852 // function : IsAxisOk()
854 //=================================================================================
855 bool SMESHGUI_RevolutionDlg::IsAxisOk()
857 return (SpinBox_DX->GetValue() != 0 ||
858 SpinBox_DY->GetValue() != 0 ||
859 SpinBox_DZ->GetValue() != 0);
863 //=================================================================================
864 // function : onVectorChanged()
866 //=================================================================================
867 void SMESHGUI_RevolutionDlg::onVectorChanged()
871 buttonOk->setEnabled( true );
872 buttonApply->setEnabled( true );
876 buttonOk->setEnabled( false );
877 buttonApply->setEnabled( false );
882 //=======================================================================
883 //function : onSelectMesh
885 //=======================================================================
886 void SMESHGUI_RevolutionDlg::onSelectMesh ( bool toSelectMesh )
889 TextLabelElements->setText( tr( "SMESH_NAME" ) );
891 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
893 if (myEditCurrentArgument != LineEditElements)
895 LineEditElements->clear();
899 mySelection->ClearFilters() ;
900 SMESH::SetPointRepresentation(false);
904 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
905 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
906 LineEditElements->setReadOnly(true);
910 int aConstructorId = GetConstructorId();
911 if (aConstructorId == 0)
912 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
913 else if (aConstructorId == 0)
914 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
916 LineEditElements->setReadOnly(false);
917 onTextChange(LineEditElements->text());
920 SelectionIntoArgument();