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>
59 #include "SALOMEconfig.h"
60 #include CORBA_SERVER_HEADER(SMESH_Group)
64 //=================================================================================
65 // class : SMESHGUI_RotationDlg()
67 //=================================================================================
68 SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
69 bool modal, WFlags fl )
70 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
71 Qt::WDestructiveClose)
73 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ROTATION")));
74 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
77 setName( "SMESHGUI_RotationDlg" );
79 setCaption( tr( "SMESH_ROTATION_TITLE" ) );
80 setSizeGripEnabled( TRUE );
81 SMESHGUI_RotationDlgLayout = new QGridLayout( this );
82 SMESHGUI_RotationDlgLayout->setSpacing( 6 );
83 SMESHGUI_RotationDlgLayout->setMargin( 11 );
85 /***************************************************************/
86 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
87 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
88 GroupConstructors->setTitle( tr( "SMESH_ROTATION" ) );
89 GroupConstructors->setExclusive( TRUE );
90 GroupConstructors->setColumnLayout(0, Qt::Vertical );
91 GroupConstructors->layout()->setSpacing( 0 );
92 GroupConstructors->layout()->setMargin( 0 );
93 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
94 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
95 GroupConstructorsLayout->setSpacing( 6 );
96 GroupConstructorsLayout->setMargin( 11 );
97 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
98 RadioButton1->setText( tr( "" ) );
99 RadioButton1->setPixmap( image0 );
100 RadioButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, RadioButton1->sizePolicy().hasHeightForWidth() ) );
101 RadioButton1->setMinimumSize( QSize( 50, 0 ) );
102 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
103 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
104 GroupConstructorsLayout->addItem( spacer, 0, 1 );
105 SMESHGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 0 );
107 /***************************************************************/
108 GroupButtons = new QGroupBox( this, "GroupButtons" );
109 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
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_RotationDlgLayout->addWidget( GroupButtons, 2, 0 );
136 /***************************************************************/
137 GroupArguments = new QGroupBox( this, "GroupArguments" );
138 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
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( image1 );
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, 2 );
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( image1 );
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( image1 );
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, 2 );
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 "Create a copy" option
248 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
249 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
250 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
253 SMESHGUI_RotationDlgLayout->addWidget( GroupArguments, 1, 0 );
255 /* Initialisations */
256 SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
257 SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
258 SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
259 SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
260 SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
261 SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
263 SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
265 GroupArguments->show();
266 myConstructorId = 0 ;
267 RadioButton1->setChecked( TRUE );
270 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
271 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
273 // Costruction of the logical filter
274 SMESH_ListOfFilter aListOfFilters;
275 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
276 if ( !aMeshOrSubMeshFilter.IsNull() )
277 aListOfFilters.Append( aMeshOrSubMeshFilter );
278 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
279 if ( !aSmeshGroupFilter.IsNull() )
280 aListOfFilters.Append( aSmeshGroupFilter );
282 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
285 /* signals and slots connections */
286 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
287 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
288 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
289 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
291 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
292 connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
293 connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
295 connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
296 connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
297 connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) );
299 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
300 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
301 /* to close dialog if study change */
302 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
303 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
304 SLOT( onTextChange( const QString& )));
305 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
306 SLOT( onSelectMesh( bool )));
308 /* Move widget on the botton right corner of main widget */
310 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
312 this->show() ; /* displays Dialog */
314 ConstructorsClicked(0);
318 //=================================================================================
319 // function : ~SMESHGUI_RotationDlg()
320 // purpose : Destroys the object and frees any allocated resources
321 //=================================================================================
322 SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
324 // no need to delete child widgets, Qt does it all for us
328 //=================================================================================
331 //=================================================================================
332 void SMESHGUI_RotationDlg::Init( bool ResetControls )
336 myEditCurrentArgument = (QWidget*)LineEditElements;
337 LineEditElements->setFocus();
341 buttonOk->setEnabled( false );
342 buttonApply->setEnabled( false );
345 myMesh = SMESH::SMESH_Mesh::_nil();
349 SpinBox_X->SetValue(0.0);
350 SpinBox_Y->SetValue(0.0);
351 SpinBox_Z->SetValue(0.0);
352 SpinBox_DX->SetValue(0.0);
353 SpinBox_DY->SetValue(0.0);
354 SpinBox_DZ->SetValue(0.0);
356 SpinBox_Angle->SetValue(45);
358 CheckBoxCopy->setChecked(false);
359 CheckBoxMesh->setChecked(false);
362 onSelectMesh(CheckBoxMesh->isChecked());
366 //=================================================================================
367 // function : ConstructorsClicked()
368 // purpose : Radio button management
369 //=================================================================================
370 void SMESHGUI_RotationDlg::ConstructorsClicked(int constructorId)
376 //=================================================================================
377 // function : ClickOnApply()
379 //=================================================================================
380 void SMESHGUI_RotationDlg::ClickOnApply()
382 if (mySMESHGUI->ActiveStudyLocked())
385 if ( myNbOkElements && IsAxisOk())
387 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
389 SMESH::long_array_var anElementsId = new SMESH::long_array;
391 anElementsId->length( aListElementsId.count() );
392 for ( int i = 0; i < aListElementsId.count(); i++ )
393 anElementsId[i] = aListElementsId[i].toInt();
395 SMESH::AxisStruct anAxis;
397 anAxis.x = SpinBox_X->GetValue();
398 anAxis.y = SpinBox_Y->GetValue();
399 anAxis.z = SpinBox_Z->GetValue();;
400 anAxis.vx = SpinBox_DX->GetValue();
401 anAxis.vy = SpinBox_DY->GetValue();
402 anAxis.vz = SpinBox_DZ->GetValue();
404 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
405 bool toCreateCopy = CheckBoxCopy->isChecked();
409 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
410 QApplication::setOverrideCursor(Qt::waitCursor);
411 aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy);
412 QApplication::restoreOverrideCursor();
418 mySelection->ClearIObjects();
424 //=================================================================================
425 // function : ClickOnOk()
427 //=================================================================================
428 void SMESHGUI_RotationDlg::ClickOnOk()
435 //=================================================================================
436 // function : ClickOnCancel()
438 //=================================================================================
439 void SMESHGUI_RotationDlg::ClickOnCancel()
441 mySelection->ClearFilters();
442 mySelection->ClearIObjects();
443 SMESH::SetPointRepresentation(false);
444 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
445 disconnect( mySelection, 0, this, 0 );
446 mySMESHGUI->ResetState() ;
450 //=======================================================================
451 //function : onTextChange
453 //=======================================================================
455 void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText)
457 QLineEdit* send = (QLineEdit*)sender();
459 if ( myBusy ) return;
462 if (send == LineEditElements)
465 buttonOk->setEnabled( false );
466 buttonApply->setEnabled( false );
468 // hilight entered elements
469 SMDS_Mesh* aMesh = 0;
471 aMesh = myActor->GetObject()->GetMesh();
475 mySelection->ClearIObjects();
476 mySelection->AddIObject( myActor->getIO() );
478 QStringList aListId = QStringList::split( " ", theNewText, false);
480 if (send == LineEditElements) {
481 for ( int i = 0; i < aListId.count(); i++ ) {
482 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
484 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
485 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
489 myElementsId = theNewText;
493 if ( myNbOkElements && IsAxisOk()) {
494 buttonOk->setEnabled( true );
495 buttonApply->setEnabled( true );
501 //=================================================================================
502 // function : SelectionIntoArgument()
503 // purpose : Called when selection as changed or other case
504 //=================================================================================
505 void SMESHGUI_RotationDlg::SelectionIntoArgument()
507 if ( myBusy ) return;
512 QString aString = "";
515 if (myEditCurrentArgument == (QWidget*)LineEditElements)
517 LineEditElements->setText( aString );
519 buttonOk->setEnabled( false );
520 buttonApply->setEnabled( false );
524 if ( !GroupButtons->isEnabled() ) // inactive
528 int nbSel = mySelection->IObjectCount();
532 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
533 myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
534 if(myMesh->_is_nil())
537 myActor = SMESH::FindActorByObject(myMesh);
539 myActor = SMESH::FindActorByEntry(IO->getEntry());
545 if (myEditCurrentArgument == (QWidget*)LineEditElements)
549 if (CheckBoxMesh->isChecked())
551 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
553 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
556 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
560 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
562 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
564 myElementsId += QString(" %1").arg(i);
569 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
572 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
574 // get IDs from submesh
575 SMESH::long_array_var anElementsIds = new SMESH::long_array;
576 anElementsIds = aSubMesh->GetElementsId();
577 for ( int i = 0; i < anElementsIds->length(); i++ )
578 myElementsId += QString(" %1").arg(anElementsIds[i]);
579 aNbUnits = anElementsIds->length();
584 SMESH::SMESH_GroupBase_var aGroup =
585 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
586 if (aGroup->_is_nil())
589 // get IDs from smesh group
590 SMESH::long_array_var anElementsIds = new SMESH::long_array;
591 anElementsIds = aGroup->GetListOfID();
592 for ( int i = 0; i < anElementsIds->length(); i++ )
593 myElementsId += QString(" %1").arg(anElementsIds[i]);
594 aNbUnits = anElementsIds->length();
599 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
600 myElementsId = aString;
606 myNbOkElements = true;
610 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
614 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
618 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
626 if (myEditCurrentArgument == (QWidget*)SpinBox_X)
628 SpinBox_X->SetValue(x);
629 SpinBox_Y->SetValue(y);
630 SpinBox_Z->SetValue(z);
632 else if (myEditCurrentArgument == (QWidget*)SpinBox_DX)
634 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
635 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
636 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
641 if (myEditCurrentArgument == (QWidget*)LineEditElements)
642 LineEditElements->setText( aString );
647 if(myNbOkElements && IsAxisOk())
649 buttonOk->setEnabled( true );
650 buttonApply->setEnabled( true );
655 //=================================================================================
656 // function : SetEditCurrentArgument()
658 //=================================================================================
659 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
661 QPushButton* send = (QPushButton*)sender();
663 disconnect( mySelection, 0, this, 0 );
664 mySelection->ClearIObjects();
665 mySelection->ClearFilters();
667 switch (myConstructorId)
669 case 0: /* default constructor */
671 if(send == SelectElementsButton) {
672 myEditCurrentArgument = (QWidget*)LineEditElements;
673 SMESH::SetPointRepresentation(false);
674 if (CheckBoxMesh->isChecked())
676 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
677 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
680 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
682 else if (send == SelectPointButton)
684 myEditCurrentArgument = (QWidget*)SpinBox_X;
685 SMESH::SetPointRepresentation(true);
686 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
688 else if (send == SelectVectorButton)
690 myEditCurrentArgument = (QWidget*)SpinBox_DX;
691 SMESH::SetPointRepresentation(true);
692 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
698 myEditCurrentArgument->setFocus();
699 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
700 SelectionIntoArgument() ;
703 //=================================================================================
704 // function : DeactivateActiveDialog()
706 //=================================================================================
707 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
709 if ( GroupConstructors->isEnabled() ) {
710 GroupConstructors->setEnabled(false) ;
711 GroupArguments->setEnabled(false) ;
712 GroupButtons->setEnabled(false) ;
713 mySMESHGUI->ResetState() ;
714 mySMESHGUI->SetActiveDialogBox(0) ;
719 //=================================================================================
720 // function : ActivateThisDialog()
722 //=================================================================================
723 void SMESHGUI_RotationDlg::ActivateThisDialog()
725 /* Emit a signal to deactivate the active dialog */
726 mySMESHGUI->EmitSignalDeactivateDialog() ;
727 GroupConstructors->setEnabled(true) ;
728 GroupArguments->setEnabled(true) ;
729 GroupButtons->setEnabled(true) ;
731 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
733 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
734 SelectionIntoArgument();
738 //=================================================================================
739 // function : enterEvent()
741 //=================================================================================
742 void SMESHGUI_RotationDlg::enterEvent(QEvent* e)
744 if ( GroupConstructors->isEnabled() )
746 ActivateThisDialog() ;
750 //=================================================================================
751 // function : closeEvent()
753 //=================================================================================
754 void SMESHGUI_RotationDlg::closeEvent( QCloseEvent* e )
756 /* same than click on cancel button */
757 this->ClickOnCancel() ;
761 //=======================================================================
762 //function : hideEvent
763 //purpose : caused by ESC key
764 //=======================================================================
766 void SMESHGUI_RotationDlg::hideEvent ( QHideEvent * e )
768 if ( !isMinimized() )
773 //=======================================================================
774 //function : onSelectMesh
776 //=======================================================================
777 void SMESHGUI_RotationDlg::onSelectMesh ( bool toSelectMesh )
780 TextLabelElements->setText( tr( "SMESH_NAME" ) );
782 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
784 if (myEditCurrentArgument != LineEditElements)
786 LineEditElements->clear();
790 mySelection->ClearFilters() ;
791 SMESH::SetPointRepresentation(false);
795 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
796 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
797 LineEditElements->setReadOnly(true);
801 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
802 LineEditElements->setReadOnly(false);
803 onTextChange(LineEditElements->text());
806 SelectionIntoArgument();
810 //=================================================================================
811 // function : IsAxisOk()
813 //=================================================================================
814 bool SMESHGUI_RotationDlg::IsAxisOk()
816 return (SpinBox_DX->GetValue() != 0 ||
817 SpinBox_DY->GetValue() != 0 ||
818 SpinBox_DZ->GetValue() != 0);
822 //=================================================================================
823 // function : onVectorChanged()
825 //=================================================================================
826 void SMESHGUI_RotationDlg::onVectorChanged()
830 buttonOk->setEnabled( true );
831 buttonApply->setEnabled( true );
835 buttonOk->setEnabled( false );
836 buttonApply->setEnabled( false );