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_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
37 #include "SMESH_Actor.h"
38 #include "SMESH_TypeFilter.hxx"
39 #include "SMDS_Mesh.hxx"
41 #include "QAD_Application.h"
42 #include "QAD_Desktop.h"
43 #include "QAD_MessageBox.h"
44 #include "utilities.h"
47 #include <qapplication.h>
48 #include <qbuttongroup.h>
49 #include <qgroupbox.h>
51 #include <qlineedit.h>
52 #include <qpushbutton.h>
53 #include <qradiobutton.h>
54 #include <qcheckbox.h>
60 //=================================================================================
61 // class : SMESHGUI_RotationDlg()
63 //=================================================================================
64 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
65 bool modal, WFlags fl )
66 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
67 Qt::WDestructiveClose)
69 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ROTATION")));
70 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
73 setName( "SMESHGUI_RotationDlg" );
75 setCaption( tr( "SMESH_ROTATION_TITLE" ) );
76 setSizeGripEnabled( TRUE );
77 SMESHGUI_RotationDlgLayout = new QGridLayout( this );
78 SMESHGUI_RotationDlgLayout->setSpacing( 6 );
79 SMESHGUI_RotationDlgLayout->setMargin( 11 );
81 /***************************************************************/
82 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
83 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
84 GroupConstructors->setTitle( tr( "SMESH_ROTATION" ) );
85 GroupConstructors->setExclusive( TRUE );
86 GroupConstructors->setColumnLayout(0, Qt::Vertical );
87 GroupConstructors->layout()->setSpacing( 0 );
88 GroupConstructors->layout()->setMargin( 0 );
89 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
90 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
91 GroupConstructorsLayout->setSpacing( 6 );
92 GroupConstructorsLayout->setMargin( 11 );
93 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
94 RadioButton1->setText( tr( "" ) );
95 RadioButton1->setPixmap( image0 );
96 RadioButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, RadioButton1->sizePolicy().hasHeightForWidth() ) );
97 RadioButton1->setMinimumSize( QSize( 50, 0 ) );
98 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
99 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
100 GroupConstructorsLayout->addItem( spacer, 0, 1 );
101 SMESHGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
103 /***************************************************************/
104 GroupButtons = new QGroupBox( this, "GroupButtons" );
105 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
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_RotationDlgLayout->addWidget( GroupButtons, 2, 0 );
132 /***************************************************************/
133 GroupArguments = new QGroupBox( this, "GroupArguments" );
134 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
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( image1 );
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, 2 );
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( image1 );
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( image1 );
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, 2 );
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 "Create a copy" option
244 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
245 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
246 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
249 SMESHGUI_RotationDlgLayout->addWidget( GroupArguments, 1, 0 );
251 /* Initialisations */
252 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
253 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
254 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
255 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
256 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
259 SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
261 GroupArguments->show();
262 myConstructorId = 0 ;
263 RadioButton1->setChecked( TRUE );
266 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
267 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
269 // Costruction of the logical filter
270 SMESH_ListOfFilter aListOfFilters;
271 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
272 if ( !aMeshOrSubMeshFilter.IsNull() )
273 aListOfFilters.Append( aMeshOrSubMeshFilter );
274 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
275 if ( !aSmeshGroupFilter.IsNull() )
276 aListOfFilters.Append( aSmeshGroupFilter );
278 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
281 /* signals and slots connections */
282 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
283 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
284 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
285 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
287 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
288 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
289 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
291 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
292 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
293 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
295 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
296 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
297 /* to close dialog if study change */
298 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
299 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
300 SLOT( onTextChange( const QString& )));
301 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
302 SLOT( onSelectMesh( bool )));
304 /* Move widget on the botton right corner of main widget */
306 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
308 this->show() ; /* displays Dialog */
310 ConstructorsClicked(0);
314 //=================================================================================
315 // function : ~SMESHGUI_RotationDlg()
316 // purpose : Destroys the object and frees any allocated resources
317 //=================================================================================
318 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
320 // no need to delete child widgets, Qt does it all for us
324 //=================================================================================
327 //=================================================================================
328 void SMESHGUI_RotationDlg::Init( bool ResetControls )
332 myEditCurrentArgument = (QWidget*)LineEditElements;
333 LineEditElements->setFocus();
337 buttonOk->setEnabled( false );
338 buttonApply->setEnabled( false );
341 myMesh = SMESH::SMESH_Mesh::_nil();
345 SpinBox_X->SetValue(0.0);
346 SpinBox_Y->SetValue(0.0);
347 SpinBox_Z->SetValue(0.0);
348 SpinBox_DX->SetValue(0.0);
349 SpinBox_DY->SetValue(0.0);
350 SpinBox_DZ->SetValue(0.0);
352 SpinBox_Angle->SetValue(45);
354 CheckBoxCopy->setChecked(false);
355 CheckBoxMesh->setChecked(false);
358 onSelectMesh(CheckBoxMesh->isChecked());
362 //=================================================================================
363 // function : ConstructorsClicked()
364 // purpose : Radio button management
365 //=================================================================================
366 void SMESHGUI_RotationDlg::ConstructorsClicked(int constructorId)
372 //=================================================================================
373 // function : ClickOnApply()
375 //=================================================================================
376 void SMESHGUI_RotationDlg::ClickOnApply()
378 if (mySMESHGUI->ActiveStudyLocked())
381 if ( myNbOkElements && IsAxisOk())
383 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
385 SMESH::long_array_var anElementsId = new SMESH::long_array;
387 anElementsId->length( aListElementsId.count() );
388 for ( int i = 0; i < aListElementsId.count(); i++ )
389 anElementsId[i] = aListElementsId[i].toInt();
391 SMESH::AxisStruct anAxis;
393 anAxis.x = SpinBox_X->GetValue();
394 anAxis.y = SpinBox_Y->GetValue();
395 anAxis.z = SpinBox_Z->GetValue();;
396 anAxis.vx = SpinBox_DX->GetValue();
397 anAxis.vy = SpinBox_DY->GetValue();
398 anAxis.vz = SpinBox_DZ->GetValue();
400 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
401 bool toCreateCopy = CheckBoxCopy->isChecked();
405 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
406 QApplication::setOverrideCursor(Qt::waitCursor);
407 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
408 QApplication::restoreOverrideCursor();
414 mySelection->ClearIObjects();
420 //=================================================================================
421 // function : ClickOnOk()
423 //=================================================================================
424 void SMESHGUI_RotationDlg::ClickOnOk()
431 //=================================================================================
432 // function : ClickOnCancel()
434 //=================================================================================
435 void SMESHGUI_RotationDlg::ClickOnCancel()
437 mySelection->ClearFilters();
438 mySelection->ClearIObjects();
439 SMESH::SetPointRepresentation(false);
440 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
441 disconnect( mySelection, 0, this, 0 );
442 mySMESHGUI->ResetState() ;
446 //=======================================================================
447 //function : onTextChange
449 //=======================================================================
451 void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText)
453 QLineEdit* send = (QLineEdit*)sender();
455 if ( myBusy ) return;
458 if (send == LineEditElements)
461 buttonOk->setEnabled( false );
462 buttonApply->setEnabled( false );
464 // hilight entered elements
465 SMDS_Mesh* aMesh = 0;
467 aMesh = myActor->GetObject()->GetMesh();
471 mySelection->ClearIObjects();
472 mySelection->AddIObject( myActor->getIO() );
474 QStringList aListId = QStringList::split( " ", theNewText, false);
476 if (send == LineEditElements) {
477 for ( int i = 0; i < aListId.count(); i++ ) {
478 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
480 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
481 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
485 myElementsId = theNewText;
489 if ( myNbOkElements && IsAxisOk()) {
490 buttonOk->setEnabled( true );
491 buttonApply->setEnabled( true );
497 //=================================================================================
498 // function : SelectionIntoArgument()
499 // purpose : Called when selection as changed or other case
500 //=================================================================================
501 void SMESHGUI_RotationDlg::SelectionIntoArgument()
503 if ( myBusy ) return;
508 QString aString = "";
511 if (myEditCurrentArgument == (QWidget*)LineEditElements)
513 LineEditElements->setText( aString );
515 buttonOk->setEnabled( false );
516 buttonApply->setEnabled( false );
520 if ( !GroupButtons->isEnabled() ) // inactive
524 int nbSel = mySelection->IObjectCount();
528 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
529 myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
530 if(myMesh->_is_nil())
533 myActor = SMESH::FindActorByObject(myMesh);
535 myActor = SMESH::FindActorByEntry(IO->getEntry());
541 if (myEditCurrentArgument == (QWidget*)LineEditElements)
545 if (CheckBoxMesh->isChecked())
547 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
549 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
552 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
556 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
558 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
560 myElementsId += QString(" %1").arg(i);
565 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
568 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
570 // get IDs from submesh
571 SMESH::long_array_var anElementsIds = new SMESH::long_array;
572 anElementsIds = aSubMesh->GetElementsId();
573 for ( int i = 0; i < anElementsIds->length(); i++ )
574 myElementsId += QString(" %1").arg(anElementsIds[i]);
575 aNbUnits = anElementsIds->length();
580 SMESH::SMESH_GroupBase_var aGroup =
581 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
582 if (aGroup->_is_nil())
585 // get IDs from smesh group
586 SMESH::long_array_var anElementsIds = new SMESH::long_array;
587 anElementsIds = aGroup->GetListOfID();
588 for ( int i = 0; i < anElementsIds->length(); i++ )
589 myElementsId += QString(" %1").arg(anElementsIds[i]);
590 aNbUnits = anElementsIds->length();
595 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
596 myElementsId = aString;
602 myNbOkElements = true;
606 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
610 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
614 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
622 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
624 SpinBox_X->SetValue(x);
625 SpinBox_Y->SetValue(y);
626 SpinBox_Z->SetValue(z);
628 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
630 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
631 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
632 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
637 if (myEditCurrentArgument == (QWidget*)LineEditElements)
638 LineEditElements->setText( aString );
643 if(myNbOkElements && IsAxisOk())
645 buttonOk->setEnabled( true );
646 buttonApply->setEnabled( true );
651 //=================================================================================
652 // function : SetEditCurrentArgument()
654 //=================================================================================
655 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
657 QPushButton* send = (QPushButton*)sender();
659 disconnect( mySelection, 0, this, 0 );
660 mySelection->ClearIObjects();
661 mySelection->ClearFilters();
663 switch (myConstructorId)
665 case 0: /* default constructor */
667 if(send == SelectElementsButton) {
668 myEditCurrentArgument = (QWidget*)LineEditElements;
669 SMESH::SetPointRepresentation(false);
670 if (CheckBoxMesh->isChecked())
672 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
673 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
676 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
678 else if (send == SelectPointButton)
680 myEditCurrentArgument = (QWidget*)SpinBox_X;
681 SMESH::SetPointRepresentation(true);
682 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
684 else if (send == SelectVectorButton)
686 myEditCurrentArgument = (QWidget*)SpinBox_DX;
687 SMESH::SetPointRepresentation(true);
688 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
694 myEditCurrentArgument->setFocus();
695 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
696 SelectionIntoArgument() ;
699 //=================================================================================
700 // function : DeactivateActiveDialog()
702 //=================================================================================
703 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
705 if ( GroupConstructors->isEnabled() ) {
706 GroupConstructors->setEnabled(false) ;
707 GroupArguments->setEnabled(false) ;
708 GroupButtons->setEnabled(false) ;
709 mySMESHGUI->ResetState() ;
710 mySMESHGUI->SetActiveDialogBox(0) ;
715 //=================================================================================
716 // function : ActivateThisDialog()
718 //=================================================================================
719 void SMESHGUI_RotationDlg::ActivateThisDialog()
721 /* Emit a signal to deactivate the active dialog */
722 mySMESHGUI->EmitSignalDeactivateDialog() ;
723 GroupConstructors->setEnabled(true) ;
724 GroupArguments->setEnabled(true) ;
725 GroupButtons->setEnabled(true) ;
727 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
729 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
730 SelectionIntoArgument();
734 //=================================================================================
735 // function : enterEvent()
737 //=================================================================================
738 void SMESHGUI_RotationDlg::enterEvent(QEvent* e)
740 if ( GroupConstructors->isEnabled() )
742 ActivateThisDialog() ;
746 //=================================================================================
747 // function : closeEvent()
749 //=================================================================================
750 void SMESHGUI_RotationDlg::closeEvent( QCloseEvent* e )
752 /* same than click on cancel button */
753 this->ClickOnCancel() ;
757 //=======================================================================
758 //function : hideEvent
759 //purpose : caused by ESC key
760 //=======================================================================
762 void SMESHGUI_RotationDlg::hideEvent ( QHideEvent * e )
764 if ( !isMinimized() )
769 //=======================================================================
770 //function : onSelectMesh
772 //=======================================================================
773 void SMESHGUI_RotationDlg::onSelectMesh ( bool toSelectMesh )
776 TextLabelElements->setText( tr( "SMESH_NAME" ) );
778 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
780 if (myEditCurrentArgument != LineEditElements)
782 LineEditElements->clear();
786 mySelection->ClearFilters() ;
787 SMESH::SetPointRepresentation(false);
791 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
792 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
793 LineEditElements->setReadOnly(true);
797 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
798 LineEditElements->setReadOnly(false);
799 onTextChange(LineEditElements->text());
802 SelectionIntoArgument();
806 //=================================================================================
807 // function : IsAxisOk()
809 //=================================================================================
810 bool SMESHGUI_RotationDlg::IsAxisOk()
812 return (SpinBox_DX->GetValue() != 0 ||
813 SpinBox_DY->GetValue() != 0 ||
814 SpinBox_DZ->GetValue() != 0);
818 //=================================================================================
819 // function : onVectorChanged()
821 //=================================================================================
822 void SMESHGUI_RotationDlg::onVectorChanged()
826 buttonOk->setEnabled( true );
827 buttonApply->setEnabled( true );
831 buttonOk->setEnabled( false );
832 buttonApply->setEnabled( false );