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"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMDS_Mesh.hxx"
42 #include "QAD_Application.h"
43 #include "QAD_Desktop.h"
44 #include "QAD_MessageBox.h"
45 #include "utilities.h"
48 #include <qapplication.h>
49 #include <qbuttongroup.h>
50 #include <qgroupbox.h>
52 #include <qlineedit.h>
53 #include <qpushbutton.h>
54 #include <qradiobutton.h>
55 #include <qcheckbox.h>
60 #include "SALOMEconfig.h"
61 #include CORBA_SERVER_HEADER(SMESH_Group)
65 //=================================================================================
66 // class : SMESHGUI_RotationDlg()
68 //=================================================================================
69 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( 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_ROTATION")));
75 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
78 setName( "SMESHGUI_RotationDlg" );
80 setCaption( tr( "SMESH_ROTATION_TITLE" ) );
81 setSizeGripEnabled( TRUE );
82 SMESHGUI_RotationDlgLayout = new QGridLayout( this );
83 SMESHGUI_RotationDlgLayout->setSpacing( 6 );
84 SMESHGUI_RotationDlgLayout->setMargin( 11 );
86 /***************************************************************/
87 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
88 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
89 GroupConstructors->setTitle( tr( "SMESH_ROTATION" ) );
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 RadioButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, RadioButton1->sizePolicy().hasHeightForWidth() ) );
102 RadioButton1->setMinimumSize( QSize( 50, 0 ) );
103 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
104 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
105 GroupConstructorsLayout->addItem( spacer, 0, 1 );
106 SMESHGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
108 /***************************************************************/
109 GroupButtons = new QGroupBox( this, "GroupButtons" );
110 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
111 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
112 GroupButtons->setTitle( tr( "" ) );
113 GroupButtons->setColumnLayout(0, Qt::Vertical );
114 GroupButtons->layout()->setSpacing( 0 );
115 GroupButtons->layout()->setMargin( 0 );
116 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
117 GroupButtonsLayout->setAlignment( Qt::AlignTop );
118 GroupButtonsLayout->setSpacing( 6 );
119 GroupButtonsLayout->setMargin( 11 );
120 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
121 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
122 buttonCancel->setAutoDefault( TRUE );
123 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
124 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
125 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
126 buttonApply->setAutoDefault( TRUE );
127 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
128 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
129 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
130 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
131 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
132 buttonOk->setAutoDefault( TRUE );
133 buttonOk->setDefault( TRUE );
134 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
135 SMESHGUI_RotationDlgLayout->addWidget( GroupButtons, 2, 0 );
137 /***************************************************************/
138 GroupArguments = new QGroupBox( this, "GroupArguments" );
139 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
140 GroupArguments->setColumnLayout(0, Qt::Vertical );
141 GroupArguments->layout()->setSpacing( 0 );
142 GroupArguments->layout()->setMargin( 0 );
143 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
144 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
145 GroupArgumentsLayout->setSpacing( 6 );
146 GroupArgumentsLayout->setMargin( 11 );
148 // Controls for elements selection
149 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
150 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
151 TextLabelElements->setFixedWidth(74);
152 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
154 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
155 SelectElementsButton->setText( tr( "" ) );
156 SelectElementsButton->setPixmap( image1 );
157 SelectElementsButton->setToggleButton( FALSE );
158 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
160 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
161 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
162 GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 );
164 // Control for the whole mesh selection
165 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
166 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
167 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 );
169 // Controls for axis defining
170 GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" );
171 GroupAxis->setTitle( tr( "SMESH_AXIS" ) );
172 GroupAxis->setColumnLayout(0, Qt::Vertical );
173 GroupAxis->layout()->setSpacing( 0 );
174 GroupAxis->layout()->setMargin( 0 );
175 QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() );
176 GroupAxisLayout->setAlignment( Qt::AlignTop );
177 GroupAxisLayout->setSpacing( 6 );
178 GroupAxisLayout->setMargin( 11 );
180 TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" );
181 TextLabelPoint->setText( tr( "SMESH_POINT" ) );
182 GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 );
184 SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" );
185 SelectPointButton->setPixmap( image1 );
186 GroupAxisLayout->addWidget( SelectPointButton, 0, 1 );
188 TextLabelX = new QLabel( GroupAxis, "TextLabelX" );
189 TextLabelX->setText( tr( "SMESH_X" ) );
190 GroupAxisLayout->addWidget( TextLabelX, 0, 2 );
192 SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X");
193 GroupAxisLayout->addWidget( SpinBox_X, 0, 3 );
195 TextLabelY = new QLabel( GroupAxis, "TextLabelY" );
196 TextLabelY->setText( tr( "SMESH_Y" ) );
197 GroupAxisLayout->addWidget( TextLabelY, 0, 4 );
199 SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y");
200 GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 );
202 TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" );
203 TextLabelZ->setText( tr( "SMESH_Z" ) );
204 GroupAxisLayout->addWidget( TextLabelZ, 0, 6 );
206 SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z");
207 GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 );
209 TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" );
210 TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
211 GroupAxisLayout->addWidget( TextLabelVector, 1, 0 );
213 SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" );
214 SelectVectorButton->setPixmap( image1 );
215 GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 );
217 TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" );
218 TextLabelDX->setText( tr( "SMESH_DX" ) );
219 GroupAxisLayout->addWidget( TextLabelDX, 1, 2 );
221 SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX");
222 GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 );
224 TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" );
225 TextLabelDY->setText( tr( "SMESH_DY" ) );
226 GroupAxisLayout->addWidget( TextLabelDY, 1, 4 );
228 SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY");
229 GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 );
231 TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" );
232 TextLabelDZ->setText( tr( "SMESH_DZ" ) );
233 GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 );
235 SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ");
236 GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 );
238 GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 2 );
240 // Controls for angle defining
241 TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" );
242 TextLabelAngle->setText( tr( "SMESH_ANGLE" ) );
243 GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 );
245 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
246 GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 );
248 // Controls for "Create a copy" option
249 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
250 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
251 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
254 SMESHGUI_RotationDlgLayout->addWidget( GroupArguments, 1, 0 );
256 /* Initialisations */
257 SpinBox_X->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
258 SpinBox_Y->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
259 SpinBox_Z->RangeStepAndValidator ( COORD_MIN, COORD_MAX, 10.0, 3 );
260 SpinBox_DX->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
261 SpinBox_DY->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
262 SpinBox_DZ->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
264 SpinBox_Angle->RangeStepAndValidator( COORD_MIN, COORD_MAX, 5.0, 3 );
265 //??SpinBox_Angle->RangeStepAndValidator( -360., +360., 5.0, 3 );
267 GroupArguments->show();
268 myConstructorId = 0 ;
269 RadioButton1->setChecked( TRUE );
272 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
273 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
275 // Costruction of the logical filter
276 SMESH_ListOfFilter aListOfFilters;
277 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
278 if ( !aMeshOrSubMeshFilter.IsNull() )
279 aListOfFilters.Append( aMeshOrSubMeshFilter );
280 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
281 if ( !aSmeshGroupFilter.IsNull() )
282 aListOfFilters.Append( aSmeshGroupFilter );
284 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
287 /* signals and slots connections */
288 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
289 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
290 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
291 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
293 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
294 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
295 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
297 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
298 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
299 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
301 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
302 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
303 /* to close dialog if study change */
304 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
305 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
306 SLOT( onTextChange( const QString& )));
307 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
308 SLOT( onSelectMesh( bool )));
310 /* Move widget on the botton right corner of main widget */
312 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
314 this->show() ; /* displays Dialog */
316 ConstructorsClicked(0);
320 //=================================================================================
321 // function : ~SMESHGUI_RotationDlg()
322 // purpose : Destroys the object and frees any allocated resources
323 //=================================================================================
324 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
326 // no need to delete child widgets, Qt does it all for us
330 //=================================================================================
333 //=================================================================================
334 void SMESHGUI_RotationDlg::Init( bool ResetControls )
338 myEditCurrentArgument = (QWidget*)LineEditElements;
339 LineEditElements->setFocus();
343 buttonOk->setEnabled( false );
344 buttonApply->setEnabled( false );
347 myMesh = SMESH::SMESH_Mesh::_nil();
351 SpinBox_X->SetValue(0.0);
352 SpinBox_Y->SetValue(0.0);
353 SpinBox_Z->SetValue(0.0);
354 SpinBox_DX->SetValue(0.0);
355 SpinBox_DY->SetValue(0.0);
356 SpinBox_DZ->SetValue(0.0);
358 SpinBox_Angle->SetValue(45);
360 CheckBoxCopy->setChecked(false);
361 CheckBoxMesh->setChecked(false);
364 onSelectMesh(CheckBoxMesh->isChecked());
368 //=================================================================================
369 // function : ConstructorsClicked()
370 // purpose : Radio button management
371 //=================================================================================
372 void SMESHGUI_RotationDlg::ConstructorsClicked(int constructorId)
378 //=================================================================================
379 // function : ClickOnApply()
381 //=================================================================================
382 void SMESHGUI_RotationDlg::ClickOnApply()
384 if (mySMESHGUI->ActiveStudyLocked())
387 if ( myNbOkElements && IsAxisOk())
389 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
391 SMESH::long_array_var anElementsId = new SMESH::long_array;
393 anElementsId->length( aListElementsId.count() );
394 for ( int i = 0; i < aListElementsId.count(); i++ )
395 anElementsId[i] = aListElementsId[i].toInt();
397 SMESH::AxisStruct anAxis;
399 anAxis.x = SpinBox_X->GetValue();
400 anAxis.y = SpinBox_Y->GetValue();
401 anAxis.z = SpinBox_Z->GetValue();;
402 anAxis.vx = SpinBox_DX->GetValue();
403 anAxis.vy = SpinBox_DY->GetValue();
404 anAxis.vz = SpinBox_DZ->GetValue();
406 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
407 bool toCreateCopy = CheckBoxCopy->isChecked();
411 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
412 QApplication::setOverrideCursor(Qt::waitCursor);
413 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
414 QApplication::restoreOverrideCursor();
420 mySelection->ClearIObjects();
426 //=================================================================================
427 // function : ClickOnOk()
429 //=================================================================================
430 void SMESHGUI_RotationDlg::ClickOnOk()
437 //=================================================================================
438 // function : ClickOnCancel()
440 //=================================================================================
441 void SMESHGUI_RotationDlg::ClickOnCancel()
443 mySelection->ClearFilters();
444 mySelection->ClearIObjects();
445 SMESH::SetPointRepresentation(false);
446 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
447 disconnect( mySelection, 0, this, 0 );
448 mySMESHGUI->ResetState() ;
452 //=======================================================================
453 //function : onTextChange
455 //=======================================================================
457 void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText)
459 QLineEdit* send = (QLineEdit*)sender();
461 if ( myBusy ) return;
464 if (send == LineEditElements)
467 buttonOk->setEnabled( false );
468 buttonApply->setEnabled( false );
470 // hilight entered elements
471 SMDS_Mesh* aMesh = 0;
473 aMesh = myActor->GetObject()->GetMesh();
477 mySelection->ClearIObjects();
478 mySelection->AddIObject( myActor->getIO() );
480 QStringList aListId = QStringList::split( " ", theNewText, false);
482 if (send == LineEditElements) {
483 for ( int i = 0; i < aListId.count(); i++ ) {
484 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
486 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
487 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
491 myElementsId = theNewText;
495 if ( myNbOkElements && IsAxisOk()) {
496 buttonOk->setEnabled( true );
497 buttonApply->setEnabled( true );
503 //=================================================================================
504 // function : SelectionIntoArgument()
505 // purpose : Called when selection as changed or other case
506 //=================================================================================
507 void SMESHGUI_RotationDlg::SelectionIntoArgument()
509 if ( myBusy ) return;
514 QString aString = "";
517 if (myEditCurrentArgument == (QWidget*)LineEditElements)
519 LineEditElements->setText( aString );
521 buttonOk->setEnabled( false );
522 buttonApply->setEnabled( false );
526 if ( !GroupButtons->isEnabled() ) // inactive
530 int nbSel = mySelection->IObjectCount();
534 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
535 myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
536 if(myMesh->_is_nil())
539 myActor = SMESH::FindActorByObject(myMesh);
541 myActor = SMESH::FindActorByEntry(IO->getEntry());
547 if (myEditCurrentArgument == (QWidget*)LineEditElements)
551 if (CheckBoxMesh->isChecked())
553 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
555 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
558 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
562 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
564 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
566 myElementsId += QString(" %1").arg(i);
571 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
574 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
576 // get IDs from submesh
577 SMESH::long_array_var anElementsIds = new SMESH::long_array;
578 anElementsIds = aSubMesh->GetElementsId();
579 for ( int i = 0; i < anElementsIds->length(); i++ )
580 myElementsId += QString(" %1").arg(anElementsIds[i]);
581 aNbUnits = anElementsIds->length();
586 SMESH::SMESH_GroupBase_var aGroup =
587 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
588 if (aGroup->_is_nil())
591 // get IDs from smesh group
592 SMESH::long_array_var anElementsIds = new SMESH::long_array;
593 anElementsIds = aGroup->GetListOfID();
594 for ( int i = 0; i < anElementsIds->length(); i++ )
595 myElementsId += QString(" %1").arg(anElementsIds[i]);
596 aNbUnits = anElementsIds->length();
601 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
602 myElementsId = aString;
608 myNbOkElements = true;
612 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
616 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
620 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
628 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
630 SpinBox_X->SetValue(x);
631 SpinBox_Y->SetValue(y);
632 SpinBox_Z->SetValue(z);
634 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
636 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
637 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
638 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
643 if (myEditCurrentArgument == (QWidget*)LineEditElements)
644 LineEditElements->setText( aString );
649 if(myNbOkElements && IsAxisOk())
651 buttonOk->setEnabled( true );
652 buttonApply->setEnabled( true );
657 //=================================================================================
658 // function : SetEditCurrentArgument()
660 //=================================================================================
661 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
663 QPushButton* send = (QPushButton*)sender();
665 disconnect( mySelection, 0, this, 0 );
666 mySelection->ClearIObjects();
667 mySelection->ClearFilters();
669 switch (myConstructorId)
671 case 0: /* default constructor */
673 if(send == SelectElementsButton) {
674 myEditCurrentArgument = (QWidget*)LineEditElements;
675 SMESH::SetPointRepresentation(false);
676 if (CheckBoxMesh->isChecked())
678 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
679 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
682 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
684 else if (send == SelectPointButton)
686 myEditCurrentArgument = (QWidget*)SpinBox_X;
687 SMESH::SetPointRepresentation(true);
688 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
690 else if (send == SelectVectorButton)
692 myEditCurrentArgument = (QWidget*)SpinBox_DX;
693 SMESH::SetPointRepresentation(true);
694 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
700 myEditCurrentArgument->setFocus();
701 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
702 SelectionIntoArgument() ;
705 //=================================================================================
706 // function : DeactivateActiveDialog()
708 //=================================================================================
709 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
711 if ( GroupConstructors->isEnabled() ) {
712 GroupConstructors->setEnabled(false) ;
713 GroupArguments->setEnabled(false) ;
714 GroupButtons->setEnabled(false) ;
715 mySMESHGUI->ResetState() ;
716 mySMESHGUI->SetActiveDialogBox(0) ;
721 //=================================================================================
722 // function : ActivateThisDialog()
724 //=================================================================================
725 void SMESHGUI_RotationDlg::ActivateThisDialog()
727 /* Emit a signal to deactivate the active dialog */
728 mySMESHGUI->EmitSignalDeactivateDialog() ;
729 GroupConstructors->setEnabled(true) ;
730 GroupArguments->setEnabled(true) ;
731 GroupButtons->setEnabled(true) ;
733 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
735 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
736 SelectionIntoArgument();
740 //=================================================================================
741 // function : enterEvent()
743 //=================================================================================
744 void SMESHGUI_RotationDlg::enterEvent(QEvent* e)
746 if ( GroupConstructors->isEnabled() )
748 ActivateThisDialog() ;
752 //=================================================================================
753 // function : closeEvent()
755 //=================================================================================
756 void SMESHGUI_RotationDlg::closeEvent( QCloseEvent* e )
758 /* same than click on cancel button */
759 this->ClickOnCancel() ;
763 //=======================================================================
764 //function : hideEvent
765 //purpose : caused by ESC key
766 //=======================================================================
768 void SMESHGUI_RotationDlg::hideEvent ( QHideEvent * e )
770 if ( !isMinimized() )
775 //=======================================================================
776 //function : onSelectMesh
778 //=======================================================================
779 void SMESHGUI_RotationDlg::onSelectMesh ( bool toSelectMesh )
782 TextLabelElements->setText( tr( "SMESH_NAME" ) );
784 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
786 if (myEditCurrentArgument != LineEditElements)
788 LineEditElements->clear();
792 mySelection->ClearFilters() ;
793 SMESH::SetPointRepresentation(false);
797 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
798 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
799 LineEditElements->setReadOnly(true);
803 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
804 LineEditElements->setReadOnly(false);
805 onTextChange(LineEditElements->text());
808 SelectionIntoArgument();
812 //=================================================================================
813 // function : IsAxisOk()
815 //=================================================================================
816 bool SMESHGUI_RotationDlg::IsAxisOk()
818 return (SpinBox_DX->GetValue() != 0 ||
819 SpinBox_DY->GetValue() != 0 ||
820 SpinBox_DZ->GetValue() != 0);
824 //=================================================================================
825 // function : onVectorChanged()
827 //=================================================================================
828 void SMESHGUI_RotationDlg::onVectorChanged()
832 buttonOk->setEnabled( true );
833 buttonApply->setEnabled( true );
837 buttonOk->setEnabled( false );
838 buttonApply->setEnabled( false );