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 ( COORD_MIN, COORD_MAX, 10.0, 3 );
267 SpinBox_Y->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
268 SpinBox_Z->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
269 SpinBox_DX->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
270 SpinBox_DY->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
271 SpinBox_DZ->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
273 SpinBox_Angle->RangeStepAndValidator( COORD_MIN, COORD_MAX, 5.0, 3 );
274 //??SpinBox_Angle->RangeStepAndValidator( -360., +360., 5.0, 3 );
276 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
277 SpinBox_NbSteps->setValidator(anIntValidator);
278 SpinBox_NbSteps->setRange( 1, 999999 );
280 SpinBox_Tolerance->RangeStepAndValidator( 0.0, COORD_MAX, 0.1, 6 );
282 GroupArguments->show();
283 RadioButton1->setChecked( TRUE );
286 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
287 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
289 // Costruction of the logical filter
290 SMESH_ListOfFilter aListOfFilters;
291 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
292 if ( !aMeshOrSubMeshFilter.IsNull() )
293 aListOfFilters.Append( aMeshOrSubMeshFilter );
294 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
295 if ( !aSmeshGroupFilter.IsNull() )
296 aListOfFilters.Append( aSmeshGroupFilter );
298 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
301 /* signals and slots connections */
302 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
303 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
304 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
305 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
307 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
308 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
309 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
311 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
312 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
313 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
315 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
316 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
317 /* to close dialog if study change */
318 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
319 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
320 SLOT( onTextChange( const QString& )));
321 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
322 SLOT( onSelectMesh( bool )));
324 /* Move widget on the botton right corner of main widget */
326 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
328 this->show() ; /* displays Dialog */
330 ConstructorsClicked(0);
333 //=================================================================================
334 // function : ~SMESHGUI_RevolutionDlg()
335 // purpose : Destroys the object and frees any allocated resources
336 //=================================================================================
337 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
339 // no need to delete child widgets, Qt does it all for us
343 //=================================================================================
346 //=================================================================================
347 void SMESHGUI_RevolutionDlg::Init( bool ResetControls )
351 myEditCurrentArgument = 0;
352 LineEditElements->clear();
357 myMesh = SMESH::SMESH_Mesh::_nil();
361 SpinBox_X->SetValue(0.0);
362 SpinBox_Y->SetValue(0.0);
363 SpinBox_Z->SetValue(0.0);
364 SpinBox_DX->SetValue(0.0);
365 SpinBox_DY->SetValue(0.0);
366 SpinBox_DZ->SetValue(0.0);
368 SpinBox_Angle->SetValue(45);
369 SpinBox_NbSteps->setValue(1);
370 SpinBox_Tolerance->SetValue(1e-05);
372 CheckBoxMesh->setChecked(false);
373 onSelectMesh( false );
378 //=================================================================================
379 // function : ConstructorsClicked()
380 // purpose : Radio button management
381 //=================================================================================
382 void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId)
384 disconnect(mySelection, 0, this, 0);
386 Selection_Mode aSelMode = ActorSelection;
388 switch(constructorId)
392 GroupArguments->setTitle( tr( "REVOLUTION_1D" ) );
393 aSelMode = EdgeSelection;
398 GroupArguments->setTitle( tr( "REVOLUTION_2D" ) );
399 aSelMode = FaceSelection;
404 if (myEditCurrentArgument != (QWidget*)LineEditElements)
405 SMESH::SetPointRepresentation(false);
407 if (!CheckBoxMesh->isChecked())
408 QAD_Application::getDesktop()->SetSelectionMode( aSelMode, true );
410 myEditCurrentArgument = (QWidget*)LineEditElements;
411 LineEditElements->setFocus();
413 if (CheckBoxMesh->isChecked())
416 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
420 //=================================================================================
421 // function : ClickOnApply()
423 //=================================================================================
424 void SMESHGUI_RevolutionDlg::ClickOnApply()
426 if (mySMESHGUI->ActiveStudyLocked())
429 if ( myNbOkElements && IsAxisOk())
431 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
433 SMESH::long_array_var anElementsId = new SMESH::long_array;
435 anElementsId->length( aListElementsId.count() );
436 for ( int i = 0; i < aListElementsId.count(); i++ )
437 anElementsId[i] = aListElementsId[i].toInt();
439 SMESH::AxisStruct anAxis;
441 anAxis.x = SpinBox_X->GetValue();
442 anAxis.y = SpinBox_Y->GetValue();
443 anAxis.z = SpinBox_Z->GetValue();;
444 anAxis.vx = SpinBox_DX->GetValue();
445 anAxis.vy = SpinBox_DY->GetValue();
446 anAxis.vz = SpinBox_DZ->GetValue();
448 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
449 long aNbSteps = (long)SpinBox_NbSteps->value();
450 double aTolerance = SpinBox_Tolerance->GetValue();
454 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
455 QApplication::setOverrideCursor(Qt::waitCursor);
456 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
457 QApplication::restoreOverrideCursor();
463 mySelection->ClearIObjects();
466 ConstructorsClicked( GetConstructorId() );
470 //=================================================================================
471 // function : ClickOnOk()
473 //=================================================================================
474 void SMESHGUI_RevolutionDlg::ClickOnOk()
481 //=================================================================================
482 // function : ClickOnCancel()
484 //=================================================================================
485 void SMESHGUI_RevolutionDlg::ClickOnCancel()
487 mySelection->ClearFilters();
488 mySelection->ClearIObjects();
489 SMESH::SetPointRepresentation(false);
490 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
491 disconnect( mySelection, 0, this, 0 );
492 mySMESHGUI->ResetState() ;
496 //=======================================================================
497 //function : onTextChange
499 //=======================================================================
501 void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText)
503 QLineEdit* send = (QLineEdit*)sender();
505 if ( myBusy ) return;
508 if (send == LineEditElements)
511 buttonOk->setEnabled( false );
512 buttonApply->setEnabled( false );
514 // hilight entered elements
515 SMDS_Mesh* aMesh = 0;
517 aMesh = myActor->GetObject()->GetMesh();
520 mySelection->ClearIObjects();
521 mySelection->AddIObject( myActor->getIO() );
523 QStringList aListId = QStringList::split( " ", theNewText, false);
525 if (send == LineEditElements) {
526 for ( int i = 0; i < aListId.count(); i++ ) {
527 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
529 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
530 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
534 myElementsId = theNewText;
538 if ( myNbOkElements && IsAxisOk() ) {
539 buttonOk->setEnabled( true );
540 buttonApply->setEnabled( true );
546 //=================================================================================
547 // function : SelectionIntoArgument()
548 // purpose : Called when selection as changed or other case
549 //=================================================================================
550 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
552 if ( myBusy ) return;
556 QString aString = "";
559 if (myEditCurrentArgument == (QWidget*)LineEditElements)
561 LineEditElements->setText( aString );
563 buttonOk->setEnabled( false );
564 buttonApply->setEnabled( false );
568 if ( !GroupButtons->isEnabled() ) // inactive
572 int nbSel = mySelection->IObjectCount();
576 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
577 myMesh = SMESH::GetMeshByIO(IO);
578 if(myMesh->_is_nil())
580 myActor = SMESH::FindActorByObject(myMesh);
586 if (myEditCurrentArgument == (QWidget*)LineEditElements)
590 if (CheckBoxMesh->isChecked())
592 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
594 int aConstructorId = GetConstructorId();
596 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
599 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
603 if (aConstructorId == 0)
605 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
607 while ( anIter->more() )
609 const SMDS_MeshEdge * edge = anIter->next();
611 myElementsId += QString(" %1").arg(edge->GetID());
616 else if (aConstructorId == 1)
618 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
619 while ( anIter->more() )
621 const SMDS_MeshFace * face = anIter->next();
623 myElementsId += QString(" %1").arg(face->GetID());
629 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
632 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
634 // get IDs from submesh
635 SMESH::long_array_var anElementsIds = new SMESH::long_array;
636 if (aConstructorId == 0)
637 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
638 else if (aConstructorId == 1)
639 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
641 for ( int i = 0; i < anElementsIds->length(); i++ )
642 myElementsId += QString(" %1").arg(anElementsIds[i]);
643 aNbUnits = anElementsIds->length();
648 SMESH::SMESH_GroupBase_var aGroup =
649 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
650 if (aGroup->_is_nil())
653 if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
654 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) )
657 // get IDs from smesh group
658 SMESH::long_array_var anElementsIds = new SMESH::long_array;
659 anElementsIds = aGroup->GetListOfID();
660 for ( int i = 0; i < anElementsIds->length(); i++ )
661 myElementsId += QString(" %1").arg(anElementsIds[i]);
662 aNbUnits = anElementsIds->length();
667 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
668 myElementsId = aString;
674 myNbOkElements = true;
678 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
682 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
686 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
694 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
696 SpinBox_X->SetValue(x);
697 SpinBox_Y->SetValue(y);
698 SpinBox_Z->SetValue(z);
700 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
702 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
703 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
704 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
709 if (myEditCurrentArgument == (QWidget*)LineEditElements)
710 LineEditElements->setText( aString );
714 if(myNbOkElements && IsAxisOk())
716 buttonOk->setEnabled( true );
717 buttonApply->setEnabled( true );
722 //=================================================================================
723 // function : SetEditCurrentArgument()
725 //=================================================================================
726 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
728 QPushButton* send = (QPushButton*)sender();
730 disconnect( mySelection, 0, this, 0 );
731 mySelection->ClearIObjects();
732 mySelection->ClearFilters();
734 if(send == SelectElementsButton) {
735 myEditCurrentArgument = (QWidget*)LineEditElements;
736 SMESH::SetPointRepresentation(false);
737 if (CheckBoxMesh->isChecked())
739 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
740 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
744 int aConstructorId = GetConstructorId();
745 if (aConstructorId == 0)
746 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
747 else if (aConstructorId == 1)
748 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
751 else if (send == SelectPointButton)
753 myEditCurrentArgument = (QWidget*)SpinBox_X;
754 SMESH::SetPointRepresentation(true);
755 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
757 else if (send == SelectVectorButton)
759 myEditCurrentArgument = (QWidget*)SpinBox_DX;
760 SMESH::SetPointRepresentation(true);
761 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
764 myEditCurrentArgument->setFocus();
765 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
766 SelectionIntoArgument() ;
769 //=================================================================================
770 // function : DeactivateActiveDialog()
772 //=================================================================================
773 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
775 if ( GroupConstructors->isEnabled() ) {
776 GroupConstructors->setEnabled(false) ;
777 GroupArguments->setEnabled(false) ;
778 GroupButtons->setEnabled(false) ;
779 mySMESHGUI->ResetState() ;
780 mySMESHGUI->SetActiveDialogBox(0) ;
785 //=================================================================================
786 // function : ActivateThisDialog()
788 //=================================================================================
789 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
791 /* Emit a signal to deactivate the active dialog */
792 mySMESHGUI->EmitSignalDeactivateDialog() ;
793 GroupConstructors->setEnabled(true) ;
794 GroupArguments->setEnabled(true) ;
795 GroupButtons->setEnabled(true) ;
797 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
799 ConstructorsClicked(GetConstructorId());
800 SelectionIntoArgument();
804 //=================================================================================
805 // function : enterEvent()
807 //=================================================================================
808 void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e)
810 if ( GroupConstructors->isEnabled() )
812 ActivateThisDialog() ;
816 //=================================================================================
817 // function : closeEvent()
819 //=================================================================================
820 void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e )
822 /* same than click on cancel button */
823 this->ClickOnCancel() ;
828 //=======================================================================
829 //function : hideEvent
830 //purpose : caused by ESC key
831 //=======================================================================
833 void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e )
835 if ( !isMinimized() )
840 //=================================================================================
841 // function : GetConstructorId()
843 //=================================================================================
844 int SMESHGUI_RevolutionDlg::GetConstructorId()
846 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
847 return GroupConstructors->id( GroupConstructors->selected() );
852 //=================================================================================
853 // function : IsAxisOk()
855 //=================================================================================
856 bool SMESHGUI_RevolutionDlg::IsAxisOk()
858 return (SpinBox_DX->GetValue() != 0 ||
859 SpinBox_DY->GetValue() != 0 ||
860 SpinBox_DZ->GetValue() != 0);
864 //=================================================================================
865 // function : onVectorChanged()
867 //=================================================================================
868 void SMESHGUI_RevolutionDlg::onVectorChanged()
872 buttonOk->setEnabled( true );
873 buttonApply->setEnabled( true );
877 buttonOk->setEnabled( false );
878 buttonApply->setEnabled( false );
883 //=======================================================================
884 //function : onSelectMesh
886 //=======================================================================
887 void SMESHGUI_RevolutionDlg::onSelectMesh ( bool toSelectMesh )
890 TextLabelElements->setText( tr( "SMESH_NAME" ) );
892 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
894 if (myEditCurrentArgument != LineEditElements)
896 LineEditElements->clear();
900 mySelection->ClearFilters() ;
901 SMESH::SetPointRepresentation(false);
905 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
906 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
907 LineEditElements->setReadOnly(true);
911 int aConstructorId = GetConstructorId();
912 if (aConstructorId == 0)
913 QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
914 else if (aConstructorId == 0)
915 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
917 LineEditElements->setReadOnly(false);
918 onTextChange(LineEditElements->text());
921 SelectionIntoArgument();