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_RotationDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_RotationDlg.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESH_Actor.h"
37 #include "SMDS_Mesh.hxx"
39 #include "QAD_Application.h"
40 #include "QAD_Desktop.h"
41 #include "QAD_MessageBox.h"
42 #include "utilities.h"
45 #include <qapplication.h>
46 #include <qbuttongroup.h>
47 #include <qgroupbox.h>
49 #include <qlineedit.h>
50 #include <qpushbutton.h>
51 #include <qradiobutton.h>
52 #include <qcheckbox.h>
58 //=================================================================================
59 // class : SMESHGUI_RotationDlg()
61 //=================================================================================
62 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( 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_ROTATION")));
68 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
71 setName( "SMESHGUI_RotationDlg" );
73 setCaption( tr( "SMESH_ROTATION_TITLE" ) );
74 setSizeGripEnabled( TRUE );
75 SMESHGUI_RotationDlgLayout = new QGridLayout( this );
76 SMESHGUI_RotationDlgLayout->setSpacing( 6 );
77 SMESHGUI_RotationDlgLayout->setMargin( 11 );
79 /***************************************************************/
80 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
81 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
82 GroupConstructors->setTitle( tr( "SMESH_ROTATION" ) );
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 RadioButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, RadioButton1->sizePolicy().hasHeightForWidth() ) );
95 RadioButton1->setMinimumSize( QSize( 50, 0 ) );
96 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
97 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
98 GroupConstructorsLayout->addItem( spacer, 0, 1 );
99 SMESHGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
101 /***************************************************************/
102 GroupButtons = new QGroupBox( this, "GroupButtons" );
103 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
104 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
105 GroupButtons->setTitle( tr( "" ) );
106 GroupButtons->setColumnLayout(0, Qt::Vertical );
107 GroupButtons->layout()->setSpacing( 0 );
108 GroupButtons->layout()->setMargin( 0 );
109 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
110 GroupButtonsLayout->setAlignment( Qt::AlignTop );
111 GroupButtonsLayout->setSpacing( 6 );
112 GroupButtonsLayout->setMargin( 11 );
113 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
114 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
115 buttonCancel->setAutoDefault( TRUE );
116 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
117 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
118 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
119 buttonApply->setAutoDefault( TRUE );
120 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
121 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
122 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
123 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
124 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
125 buttonOk->setAutoDefault( TRUE );
126 buttonOk->setDefault( TRUE );
127 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
128 SMESHGUI_RotationDlgLayout->addWidget( GroupButtons, 2, 0 );
130 /***************************************************************/
131 GroupArguments = new QGroupBox( this, "GroupArguments" );
132 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
133 GroupArguments->setColumnLayout(0, Qt::Vertical );
134 GroupArguments->layout()->setSpacing( 0 );
135 GroupArguments->layout()->setMargin( 0 );
136 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
137 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
138 GroupArgumentsLayout->setSpacing( 6 );
139 GroupArgumentsLayout->setMargin( 11 );
141 // Controls for elements selection
142 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
143 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
144 TextLabelElements->setFixedWidth(74);
145 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
147 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
148 SelectElementsButton->setText( tr( "" ) );
149 SelectElementsButton->setPixmap( image1 );
150 SelectElementsButton->setToggleButton( FALSE );
151 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
153 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
154 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
155 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
157 // Control for the whole mesh selection
158 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
159 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
160 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 );
162 // Controls for axis defining
163 GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" );
164 GroupAxis->setTitle( tr( "SMESH_AXIS" ) );
165 GroupAxis->setColumnLayout(0, Qt::Vertical );
166 GroupAxis->layout()->setSpacing( 0 );
167 GroupAxis->layout()->setMargin( 0 );
168 QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() );
169 GroupAxisLayout->setAlignment( Qt::AlignTop );
170 GroupAxisLayout->setSpacing( 6 );
171 GroupAxisLayout->setMargin( 11 );
173 TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" );
174 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
175 GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 );
177 SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" );
178 SelectPointButton->setPixmap( image1 );
179 GroupAxisLayout->addWidget( SelectPointButton, 0, 1 );
181 TextLabelX = new QLabel( GroupAxis, "TextLabelX" );
182 TextLabelX->setText( tr( "SMESH_X" ) );
183 GroupAxisLayout->addWidget( TextLabelX, 0, 2 );
185 SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X");
186 GroupAxisLayout->addWidget( SpinBox_X, 0, 3 );
188 TextLabelY = new QLabel( GroupAxis, "TextLabelY" );
189 TextLabelY->setText( tr( "SMESH_Y" ) );
190 GroupAxisLayout->addWidget( TextLabelY, 0, 4 );
192 SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y");
193 GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 );
195 TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" );
196 TextLabelZ->setText( tr( "SMESH_Z" ) );
197 GroupAxisLayout->addWidget( TextLabelZ, 0, 6 );
199 SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z");
200 GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 );
202 TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" );
203 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
204 GroupAxisLayout->addWidget( TextLabelVector, 1, 0 );
206 SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" );
207 SelectVectorButton->setPixmap( image1 );
208 GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 );
210 TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" );
211 TextLabelDX->setText( tr( "SMESH_DX" ) );
212 GroupAxisLayout->addWidget( TextLabelDX, 1, 2 );
214 SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX");
215 GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 );
217 TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" );
218 TextLabelDY->setText( tr( "SMESH_DY" ) );
219 GroupAxisLayout->addWidget( TextLabelDY, 1, 4 );
221 SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY");
222 GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 );
224 TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" );
225 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
226 GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 );
228 SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ");
229 GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 );
231 GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 2 );
233 // Controls for angle defining
234 TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" );
235 TextLabelAngle->setText( tr( "SMESH_ANGLE" ) );
236 GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 );
238 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
239 GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 );
241 // Controls for "Create a copy" option
242 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
243 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
244 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
247 SMESHGUI_RotationDlgLayout->addWidget( GroupArguments, 1, 0 );
249 /* Initialisations */
250 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
251 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
252 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
253 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
254 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257 SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
259 GroupArguments->show();
260 myConstructorId = 0 ;
261 RadioButton1->setChecked( TRUE );
264 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
265 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
267 myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
270 /* signals and slots connections */
271 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
272 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
273 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
274 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
276 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
277 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
278 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
280 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
281 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
282 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
284 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
285 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
286 /* to close dialog if study change */
287 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
288 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
289 SLOT( onTextChange( const QString& )));
290 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
291 SLOT( onSelectMesh( bool )));
293 /* Move widget on the botton right corner of main widget */
295 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
297 this->show() ; /* displays Dialog */
299 ConstructorsClicked(0);
303 //=================================================================================
304 // function : ~SMESHGUI_RotationDlg()
305 // purpose : Destroys the object and frees any allocated resources
306 //=================================================================================
307 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
309 // no need to delete child widgets, Qt does it all for us
313 //=================================================================================
316 //=================================================================================
317 void SMESHGUI_RotationDlg::Init( bool ResetControls )
321 myEditCurrentArgument = (QWidget*)LineEditElements;
322 LineEditElements->setFocus();
326 buttonOk->setEnabled( false );
327 buttonApply->setEnabled( false );
330 myMesh = SMESH::SMESH_Mesh::_nil();
334 SpinBox_X->SetValue(0.0);
335 SpinBox_Y->SetValue(0.0);
336 SpinBox_Z->SetValue(0.0);
337 SpinBox_DX->SetValue(0.0);
338 SpinBox_DY->SetValue(0.0);
339 SpinBox_DZ->SetValue(0.0);
341 SpinBox_Angle->SetValue(45);
343 CheckBoxCopy->setChecked(false);
344 CheckBoxMesh->setChecked(false);
347 onSelectMesh(CheckBoxMesh->isChecked());
351 //=================================================================================
352 // function : ConstructorsClicked()
353 // purpose : Radio button management
354 //=================================================================================
355 void SMESHGUI_RotationDlg::ConstructorsClicked(int constructorId)
361 //=================================================================================
362 // function : ClickOnApply()
364 //=================================================================================
365 void SMESHGUI_RotationDlg::ClickOnApply()
367 if (mySMESHGUI->ActiveStudyLocked())
370 if ( myNbOkElements && IsAxisOk())
372 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
374 SMESH::long_array_var anElementsId = new SMESH::long_array;
376 anElementsId->length( aListElementsId.count() );
377 for ( int i = 0; i < aListElementsId.count(); i++ )
378 anElementsId[i] = aListElementsId[i].toInt();
380 SMESH::AxisStruct anAxis;
382 anAxis.x = SpinBox_X->GetValue();
383 anAxis.y = SpinBox_Y->GetValue();
384 anAxis.z = SpinBox_Z->GetValue();;
385 anAxis.vx = SpinBox_DX->GetValue();
386 anAxis.vy = SpinBox_DY->GetValue();
387 anAxis.vz = SpinBox_DZ->GetValue();
389 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
390 bool toCreateCopy = CheckBoxCopy->isChecked();
394 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
395 QApplication::setOverrideCursor(Qt::waitCursor);
396 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
397 QApplication::restoreOverrideCursor();
403 mySelection->ClearIObjects();
409 //=================================================================================
410 // function : ClickOnOk()
412 //=================================================================================
413 void SMESHGUI_RotationDlg::ClickOnOk()
420 //=================================================================================
421 // function : ClickOnCancel()
423 //=================================================================================
424 void SMESHGUI_RotationDlg::ClickOnCancel()
426 mySelection->ClearFilters();
427 mySelection->ClearIObjects();
428 SMESH::SetPointRepresentation(false);
429 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
430 disconnect( mySelection, 0, this, 0 );
431 mySMESHGUI->ResetState() ;
435 //=======================================================================
436 //function : onTextChange
438 //=======================================================================
440 void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText)
442 QLineEdit* send = (QLineEdit*)sender();
444 if ( myBusy ) return;
447 if (send == LineEditElements)
450 buttonOk->setEnabled( false );
451 buttonApply->setEnabled( false );
453 // hilight entered elements
454 SMDS_Mesh* aMesh = 0;
456 aMesh = myActor->GetObject()->GetMesh();
460 mySelection->ClearIObjects();
461 mySelection->AddIObject( myActor->getIO() );
463 QStringList aListId = QStringList::split( " ", theNewText, false);
465 if (send == LineEditElements) {
466 for ( int i = 0; i < aListId.count(); i++ ) {
467 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
469 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
470 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
474 myElementsId = theNewText;
478 if ( myNbOkElements && IsAxisOk()) {
479 buttonOk->setEnabled( true );
480 buttonApply->setEnabled( true );
486 //=================================================================================
487 // function : SelectionIntoArgument()
488 // purpose : Called when selection as changed or other case
489 //=================================================================================
490 void SMESHGUI_RotationDlg::SelectionIntoArgument()
492 if ( myBusy ) return;
497 QString aString = "";
500 if (myEditCurrentArgument == (QWidget*)LineEditElements)
502 LineEditElements->setText( aString );
504 buttonOk->setEnabled( false );
505 buttonApply->setEnabled( false );
509 if ( !GroupButtons->isEnabled() ) // inactive
513 int nbSel = mySelection->IObjectCount();
517 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
518 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
519 myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
523 if (myEditCurrentArgument == (QWidget*)LineEditElements)
527 // get selected elements
528 if (CheckBoxMesh->isChecked())
530 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
531 if(!myMesh->_is_nil())
537 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
540 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
542 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
544 myElementsId += QString(" %1").arg(i);
551 // get IDs from submesh
552 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
553 if(aSubMesh->_is_nil())
556 myMesh = aSubMesh->GetFather();
557 if(myMesh->_is_nil())
560 myActor = SMESH::FindActorByObject(myMesh);
564 SMESH::long_array_var anElementsIds = new SMESH::long_array;
565 anElementsIds = aSubMesh->GetElementsId();
566 for ( int i = 0; i < anElementsIds->length(); i++ )
567 myElementsId += QString(" %1").arg(anElementsIds[i]);
568 aNbUnits = anElementsIds->length();
573 if(myMesh->_is_nil())
576 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
577 if(!aSubMesh->_is_nil())
578 myMesh = aSubMesh->GetFather(); // get mesh from submesh
582 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO);
583 if ( !aGroup->_is_nil() )
584 myMesh = aGroup->GetMesh(); // get mesh from group
587 if(myMesh->_is_nil())
591 myActor = SMESH::FindActorByObject(myMesh);
597 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
598 myElementsId = aString;
604 myNbOkElements = true;
608 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
612 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
616 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
624 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
626 SpinBox_X->SetValue(x);
627 SpinBox_Y->SetValue(y);
628 SpinBox_Z->SetValue(z);
630 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
632 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
633 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
634 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
639 if (myEditCurrentArgument == (QWidget*)LineEditElements)
640 LineEditElements->setText( aString );
645 if(myNbOkElements && IsAxisOk())
647 buttonOk->setEnabled( true );
648 buttonApply->setEnabled( true );
653 //=================================================================================
654 // function : SetEditCurrentArgument()
656 //=================================================================================
657 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
659 QPushButton* send = (QPushButton*)sender();
661 disconnect( mySelection, 0, this, 0 );
662 mySelection->ClearIObjects();
663 mySelection->ClearFilters();
665 switch (myConstructorId)
667 case 0: /* default constructor */
669 if(send == SelectElementsButton) {
670 myEditCurrentArgument = (QWidget*)LineEditElements;
671 SMESH::SetPointRepresentation(false);
672 if (CheckBoxMesh->isChecked())
674 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
675 mySelection->AddFilter(myMeshOrSubMeshFilter) ;
678 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
680 else if (send == SelectPointButton)
682 myEditCurrentArgument = (QWidget*)SpinBox_X;
683 SMESH::SetPointRepresentation(true);
684 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
686 else if (send == SelectVectorButton)
688 myEditCurrentArgument = (QWidget*)SpinBox_DX;
689 SMESH::SetPointRepresentation(true);
690 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
696 myEditCurrentArgument->setFocus();
697 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
698 SelectionIntoArgument() ;
701 //=================================================================================
702 // function : DeactivateActiveDialog()
704 //=================================================================================
705 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
707 if ( GroupConstructors->isEnabled() ) {
708 GroupConstructors->setEnabled(false) ;
709 GroupArguments->setEnabled(false) ;
710 GroupButtons->setEnabled(false) ;
711 mySMESHGUI->ResetState() ;
712 mySMESHGUI->SetActiveDialogBox(0) ;
717 //=================================================================================
718 // function : ActivateThisDialog()
720 //=================================================================================
721 void SMESHGUI_RotationDlg::ActivateThisDialog()
723 /* Emit a signal to deactivate the active dialog */
724 mySMESHGUI->EmitSignalDeactivateDialog() ;
725 GroupConstructors->setEnabled(true) ;
726 GroupArguments->setEnabled(true) ;
727 GroupButtons->setEnabled(true) ;
729 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
731 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
732 SelectionIntoArgument();
736 //=================================================================================
737 // function : enterEvent()
739 //=================================================================================
740 void SMESHGUI_RotationDlg::enterEvent(QEvent* e)
742 if ( GroupConstructors->isEnabled() )
744 ActivateThisDialog() ;
748 //=================================================================================
749 // function : closeEvent()
751 //=================================================================================
752 void SMESHGUI_RotationDlg::closeEvent( QCloseEvent* e )
754 /* same than click on cancel button */
755 this->ClickOnCancel() ;
759 //=======================================================================
760 //function : hideEvent
761 //purpose : caused by ESC key
762 //=======================================================================
764 void SMESHGUI_RotationDlg::hideEvent ( QHideEvent * e )
766 if ( !isMinimized() )
771 //=======================================================================
772 //function : onSelectMesh
774 //=======================================================================
775 void SMESHGUI_RotationDlg::onSelectMesh ( bool toSelectMesh )
778 TextLabelElements->setText( tr( "SMESH_NAME" ) );
780 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
782 if (myEditCurrentArgument != LineEditElements)
784 LineEditElements->clear();
788 mySelection->ClearFilters() ;
789 SMESH::SetPointRepresentation(false);
793 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
794 mySelection->AddFilter(myMeshOrSubMeshFilter);
795 LineEditElements->setReadOnly(true);
799 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
800 LineEditElements->setReadOnly(false);
801 onTextChange(LineEditElements->text());
804 SelectionIntoArgument();
808 //=================================================================================
809 // function : IsAxisOk()
811 //=================================================================================
812 bool SMESHGUI_RotationDlg::IsAxisOk()
814 return (SpinBox_DX->GetValue() != 0 ||
815 SpinBox_DY->GetValue() != 0 ||
816 SpinBox_DZ->GetValue() != 0);
820 //=================================================================================
821 // function : onVectorChanged()
823 //=================================================================================
824 void SMESHGUI_RotationDlg::onVectorChanged()
828 buttonOk->setEnabled( true );
829 buttonApply->setEnabled( true );
833 buttonOk->setEnabled( false );
834 buttonApply->setEnabled( false );