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_TranslationDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_TranslationDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESHGUI_SpinBox.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>
61 //=================================================================================
62 // class : SMESHGUI_TranslationDlg()
64 //=================================================================================
65 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
66 bool modal, WFlags fl )
67 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
68 Qt::WDestructiveClose)
70 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_POINTS")));
71 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_VECTOR")));
72 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
75 setName( "SMESHGUI_TranslationDlg" );
77 setCaption( tr( "SMESH_TRANSLATION" ) );
78 setSizeGripEnabled( TRUE );
79 SMESHGUI_TranslationDlgLayout = new QGridLayout( this );
80 SMESHGUI_TranslationDlgLayout->setSpacing( 6 );
81 SMESHGUI_TranslationDlgLayout->setMargin( 11 );
83 /***************************************************************/
84 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
85 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
86 GroupConstructors->setTitle( tr( "SMESH_TRANSLATION" ) );
87 GroupConstructors->setExclusive( TRUE );
88 GroupConstructors->setColumnLayout(0, Qt::Vertical );
89 GroupConstructors->layout()->setSpacing( 0 );
90 GroupConstructors->layout()->setMargin( 0 );
91 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
92 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
93 GroupConstructorsLayout->setSpacing( 6 );
94 GroupConstructorsLayout->setMargin( 11 );
95 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
96 RadioButton1->setText( tr( "" ) );
97 RadioButton1->setPixmap( image0 );
98 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
99 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
100 RadioButton2->setText( tr( "" ) );
101 RadioButton2->setPixmap( image1 );
102 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
103 SMESHGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
105 /***************************************************************/
106 GroupButtons = new QGroupBox( this, "GroupButtons" );
107 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
108 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
109 GroupButtons->setTitle( tr( "" ) );
110 GroupButtons->setColumnLayout(0, Qt::Vertical );
111 GroupButtons->layout()->setSpacing( 0 );
112 GroupButtons->layout()->setMargin( 0 );
113 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
114 GroupButtonsLayout->setAlignment( Qt::AlignTop );
115 GroupButtonsLayout->setSpacing( 6 );
116 GroupButtonsLayout->setMargin( 11 );
117 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
118 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
119 buttonCancel->setAutoDefault( TRUE );
120 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
121 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
122 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
123 buttonApply->setAutoDefault( TRUE );
124 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
125 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
126 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
127 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
128 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
129 buttonOk->setAutoDefault( TRUE );
130 buttonOk->setDefault( TRUE );
131 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
132 SMESHGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
134 /***************************************************************/
135 GroupArguments = new QGroupBox( this, "GroupArguments" );
136 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
137 GroupArguments->setColumnLayout(0, Qt::Vertical );
138 GroupArguments->layout()->setSpacing( 0 );
139 GroupArguments->layout()->setMargin( 0 );
140 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
141 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
142 GroupArgumentsLayout->setSpacing( 6 );
143 GroupArgumentsLayout->setMargin( 11 );
145 // Controls for elements selection
146 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
147 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
148 TextLabelElements->setFixedWidth(74);
149 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
151 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
152 SelectElementsButton->setText( tr( "" ) );
153 SelectElementsButton->setPixmap( image2 );
154 SelectElementsButton->setToggleButton( FALSE );
155 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
157 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
158 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
159 GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 );
161 // Control for the whole mesh selection
162 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
163 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
164 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 );
166 // Controls for vector and points selection
167 TextLabel1 = new QLabel( GroupArguments, "TextLabel1" );
168 GroupArgumentsLayout->addWidget( TextLabel1, 2, 0 );
170 SelectButton1 = new QPushButton( GroupArguments, "SelectButton1" );
171 SelectButton1->setText( tr( "" ) );
172 SelectButton1->setPixmap( image2 );
173 SelectButton1->setToggleButton( FALSE );
174 GroupArgumentsLayout->addWidget( SelectButton1, 2, 1 );
176 TextLabel1_1 = new QLabel( GroupArguments, "TextLabel1_1" );
177 GroupArgumentsLayout->addWidget( TextLabel1_1, 2, 2 );
179 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
180 GroupArgumentsLayout->addWidget( SpinBox1_1, 2, 3 );
182 TextLabel1_2 = new QLabel( GroupArguments, "TextLabel1_2" );
183 GroupArgumentsLayout->addWidget( TextLabel1_2, 2, 4 );
185 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
186 GroupArgumentsLayout->addWidget( SpinBox1_2, 2, 5 );
188 TextLabel1_3 = new QLabel( GroupArguments, "TextLabel1_3" );
189 GroupArgumentsLayout->addWidget( TextLabel1_3, 2, 6 );
191 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
192 GroupArgumentsLayout->addWidget( SpinBox1_3, 2, 7 );
194 TextLabel2 = new QLabel( GroupArguments, "TextLabel2" );
195 TextLabel2->setText( tr( "SMESH_POINT_2" ) );
196 GroupArgumentsLayout->addWidget( TextLabel2, 3, 0 );
198 SelectButton2 = new QPushButton( GroupArguments, "SelectButton2" );
199 SelectButton2->setText( tr( "" ) );
200 SelectButton2->setPixmap( image2 );
201 SelectButton2->setToggleButton( FALSE );
202 GroupArgumentsLayout->addWidget( SelectButton2, 3, 1 );
204 TextLabel2_1 = new QLabel( GroupArguments, "TextLabel2_1" );
205 TextLabel2_1->setText( tr( "SMESH_X" ) );
206 GroupArgumentsLayout->addWidget( TextLabel2_1, 3, 2 );
208 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
209 GroupArgumentsLayout->addWidget( SpinBox2_1, 3, 3 );
211 TextLabel2_2 = new QLabel( GroupArguments, "TextLabel2_2" );
212 TextLabel2_2->setText( tr( "SMESH_Y" ) );
213 GroupArgumentsLayout->addWidget( TextLabel2_2, 3, 4 );
215 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
216 GroupArgumentsLayout->addWidget( SpinBox2_2, 3, 5 );
218 TextLabel2_3 = new QLabel( GroupArguments, "TextLabel2_3" );
219 TextLabel2_3->setText( tr( "SMESH_Z" ) );
220 GroupArgumentsLayout->addWidget( TextLabel2_3, 3, 6 );
222 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
223 GroupArgumentsLayout->addWidget( SpinBox2_3, 3, 7 );
225 // Controls for "Create a copy" option
226 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
227 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
228 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
231 SMESHGUI_TranslationDlgLayout->addWidget( GroupArguments, 1, 0 );
233 /* Initialisations */
234 SpinBox1_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
235 SpinBox1_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
236 SpinBox1_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
237 SpinBox2_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
238 SpinBox2_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
239 SpinBox2_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
241 GroupArguments->show();
242 RadioButton1->setChecked( TRUE );
245 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
246 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
248 // Costruction of the logical filter
249 SMESH_ListOfFilter aListOfFilters;
250 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
251 if ( !aMeshOrSubMeshFilter.IsNull() )
252 aListOfFilters.Append( aMeshOrSubMeshFilter );
253 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
254 if ( !aSmeshGroupFilter.IsNull() )
255 aListOfFilters.Append( aSmeshGroupFilter );
257 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
261 /* signals and slots connections */
262 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
263 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
264 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
265 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
267 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
268 connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
269 connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
271 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
272 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
273 /* to close dialog if study change */
274 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
275 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
276 SLOT( onTextChange( const QString& )));
277 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
278 SLOT( onSelectMesh( bool )));
280 /* Move widget on the botton right corner of main widget */
282 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
284 this->show() ; /* displays Dialog */
286 ConstructorsClicked(0);
289 //=================================================================================
290 // function : ~SMESHGUI_TranslationDlg()
291 // purpose : Destroys the object and frees any allocated resources
292 //=================================================================================
293 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
295 // no need to delete child widgets, Qt does it all for us
299 //=================================================================================
302 //=================================================================================
303 void SMESHGUI_TranslationDlg::Init( bool ResetControls )
307 myEditCurrentArgument = 0;
308 LineEditElements->clear();
312 buttonOk->setEnabled( false );
313 buttonApply->setEnabled( false );
316 myMesh = SMESH::SMESH_Mesh::_nil();
320 SpinBox1_1->SetValue(0.0);
321 SpinBox1_2->SetValue(0.0);
322 SpinBox1_3->SetValue(0.0);
323 SpinBox2_1->SetValue(0.0);
324 SpinBox2_2->SetValue(0.0);
325 SpinBox2_3->SetValue(0.0);
327 CheckBoxCopy->setChecked(false);
328 CheckBoxMesh->setChecked(false);
329 onSelectMesh( false );
334 //=================================================================================
335 // function : ConstructorsClicked()
336 // purpose : Radio button management
337 //=================================================================================
338 void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId)
340 disconnect(mySelection, 0, this, 0);
342 switch(constructorId)
346 TextLabel1->setText( tr( "SMESH_POINT_1" ) );
347 TextLabel1_1->setText( tr( "SMESH_X" ) );
348 TextLabel1_2->setText( tr( "SMESH_Y" ) );
349 TextLabel1_3->setText( tr( "SMESH_Z" ) );
351 SelectButton1->show();
353 SelectButton2->show();
354 TextLabel2_1->show();
356 TextLabel2_2->show();
358 TextLabel2_3->show();
364 TextLabel1->setText( tr( "SMESH_VECTOR" ) );
365 TextLabel1_1->setText( tr( "SMESH_DX" ) );
366 TextLabel1_2->setText( tr( "SMESH_DY" ) );
367 TextLabel1_3->setText( tr( "SMESH_DZ" ) );
369 SelectButton1->hide();
371 SelectButton2->hide();
372 TextLabel2_1->hide();
374 TextLabel2_2->hide();
376 TextLabel2_3->hide();
382 if (myEditCurrentArgument != (QWidget*)LineEditElements)
384 SMESH::SetPointRepresentation(false);
385 if (!CheckBoxMesh->isChecked())
386 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
389 myEditCurrentArgument = (QWidget*)LineEditElements;
390 LineEditElements->setFocus();
392 if (CheckBoxMesh->isChecked())
395 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
399 //=================================================================================
400 // function : ClickOnApply()
402 //=================================================================================
403 void SMESHGUI_TranslationDlg::ClickOnApply()
405 if (mySMESHGUI->ActiveStudyLocked())
410 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
412 SMESH::long_array_var anElementsId = new SMESH::long_array;
414 anElementsId->length( aListElementsId.count() );
415 for ( int i = 0; i < aListElementsId.count(); i++ )
416 anElementsId[i] = aListElementsId[i].toInt();
418 SMESH::DirStruct aVector;
419 if(GetConstructorId() == 0)
421 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
422 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
423 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
425 else if(GetConstructorId() == 1)
427 aVector.PS.x = SpinBox1_1->GetValue();
428 aVector.PS.y = SpinBox1_2->GetValue();
429 aVector.PS.z = SpinBox1_3->GetValue();
432 bool toCreateCopy = CheckBoxCopy->isChecked();
436 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
437 QApplication::setOverrideCursor(Qt::waitCursor);
438 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
439 QApplication::restoreOverrideCursor();
445 mySelection->ClearIObjects();
448 ConstructorsClicked( GetConstructorId() );
452 //=================================================================================
453 // function : ClickOnOk()
455 //=================================================================================
456 void SMESHGUI_TranslationDlg::ClickOnOk()
463 //=================================================================================
464 // function : ClickOnCancel()
466 //=================================================================================
467 void SMESHGUI_TranslationDlg::ClickOnCancel()
469 mySelection->ClearFilters();
470 mySelection->ClearIObjects();
471 SMESH::SetPointRepresentation(false);
472 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
473 disconnect( mySelection, 0, this, 0 );
474 mySMESHGUI->ResetState() ;
478 //=======================================================================
479 //function : onTextChange
481 //=======================================================================
483 void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText)
485 QLineEdit* send = (QLineEdit*)sender();
487 if ( myBusy ) return;
490 if (send == LineEditElements)
493 buttonOk->setEnabled( false );
494 buttonApply->setEnabled( false );
496 // hilight entered elements
497 SMDS_Mesh* aMesh = 0;
499 aMesh = myActor->GetObject()->GetMesh();
502 mySelection->ClearIObjects();
503 mySelection->AddIObject( myActor->getIO() );
505 QStringList aListId = QStringList::split( " ", theNewText, false);
507 if (send == LineEditElements) {
508 for ( int i = 0; i < aListId.count(); i++ ) {
509 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
511 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
512 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
516 myElementsId = theNewText;
520 if ( myNbOkElements ) {
521 buttonOk->setEnabled( true );
522 buttonApply->setEnabled( true );
528 //=================================================================================
529 // function : SelectionIntoArgument()
530 // purpose : Called when selection as changed or other case
531 //=================================================================================
532 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
534 if ( myBusy ) return;
538 QString aString = "";
541 if (myEditCurrentArgument == (QWidget*)LineEditElements)
543 LineEditElements->setText( aString );
545 buttonOk->setEnabled( false );
546 buttonApply->setEnabled( false );
550 if ( !GroupButtons->isEnabled() ) // inactive
555 int nbSel = mySelection->IObjectCount();
559 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
560 myMesh = SMESH::GetMeshByIO(IO);
561 if(myMesh->_is_nil())
563 myActor = SMESH::FindActorByObject(myMesh);
569 if (myEditCurrentArgument == (QWidget*)LineEditElements)
573 if (CheckBoxMesh->isChecked())
575 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
577 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
580 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
584 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
586 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
588 myElementsId += QString(" %1").arg(i);
593 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
596 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
598 // get IDs from submesh
599 SMESH::long_array_var anElementsIds = new SMESH::long_array;
600 anElementsIds = aSubMesh->GetElementsId();
601 for ( int i = 0; i < anElementsIds->length(); i++ )
602 myElementsId += QString(" %1").arg(anElementsIds[i]);
603 aNbUnits = anElementsIds->length();
608 SMESH::SMESH_GroupBase_var aGroup =
609 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
610 if (aGroup->_is_nil())
613 // get IDs from smesh group
614 SMESH::long_array_var anElementsIds = new SMESH::long_array;
615 anElementsIds = aGroup->GetListOfID();
616 for ( int i = 0; i < anElementsIds->length(); i++ )
617 myElementsId += QString(" %1").arg(anElementsIds[i]);
618 aNbUnits = anElementsIds->length();
623 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
624 myElementsId = aString;
630 myNbOkElements = true;
633 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
637 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
641 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
649 if (myEditCurrentArgument == (QWidget*)SpinBox1_1)
651 SpinBox1_1->SetValue(x);
652 SpinBox1_2->SetValue(y);
653 SpinBox2_3->SetValue(z);
655 else if (myEditCurrentArgument == (QWidget*)SpinBox2_1)
657 SpinBox2_1->SetValue(x);
658 SpinBox2_2->SetValue(y);
659 SpinBox2_3->SetValue(z);
664 if (myEditCurrentArgument == (QWidget*)LineEditElements)
665 LineEditElements->setText( aString );
671 buttonOk->setEnabled( true );
672 buttonApply->setEnabled( true );
677 //=================================================================================
678 // function : SetEditCurrentArgument()
680 //=================================================================================
681 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
683 QPushButton* send = (QPushButton*)sender();
685 disconnect( mySelection, 0, this, 0 );
686 mySelection->ClearIObjects();
687 mySelection->ClearFilters();
689 if(send == SelectElementsButton) {
690 myEditCurrentArgument = (QWidget*)LineEditElements;
691 SMESH::SetPointRepresentation(false);
692 if (CheckBoxMesh->isChecked())
694 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
695 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
698 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
700 else if (send == SelectButton1)
702 myEditCurrentArgument = (QWidget*)SpinBox1_1;
703 SMESH::SetPointRepresentation(true);
704 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
706 else if (send == SelectButton2)
708 myEditCurrentArgument = (QWidget*)SpinBox2_1;
709 SMESH::SetPointRepresentation(true);
710 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
713 myEditCurrentArgument->setFocus();
714 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
715 SelectionIntoArgument() ;
718 //=================================================================================
719 // function : DeactivateActiveDialog()
721 //=================================================================================
722 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
724 if ( GroupConstructors->isEnabled() ) {
725 GroupConstructors->setEnabled(false) ;
726 GroupArguments->setEnabled(false) ;
727 GroupButtons->setEnabled(false) ;
728 mySMESHGUI->ResetState() ;
729 mySMESHGUI->SetActiveDialogBox(0) ;
734 //=================================================================================
735 // function : ActivateThisDialog()
737 //=================================================================================
738 void SMESHGUI_TranslationDlg::ActivateThisDialog()
740 /* Emit a signal to deactivate the active dialog */
741 mySMESHGUI->EmitSignalDeactivateDialog() ;
742 GroupConstructors->setEnabled(true) ;
743 GroupArguments->setEnabled(true) ;
744 GroupButtons->setEnabled(true) ;
746 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
748 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
749 SelectionIntoArgument();
753 //=================================================================================
754 // function : enterEvent()
756 //=================================================================================
757 void SMESHGUI_TranslationDlg::enterEvent(QEvent* e)
759 if ( GroupConstructors->isEnabled() )
761 ActivateThisDialog() ;
765 //=================================================================================
766 // function : closeEvent()
768 //=================================================================================
769 void SMESHGUI_TranslationDlg::closeEvent( QCloseEvent* e )
771 /* same than click on cancel button */
772 this->ClickOnCancel() ;
776 //=======================================================================
777 //function : hideEvent
778 //purpose : caused by ESC key
779 //=======================================================================
781 void SMESHGUI_TranslationDlg::hideEvent ( QHideEvent * e )
783 if ( !isMinimized() )
788 //=======================================================================
789 //function : onSelectMesh
791 //=======================================================================
792 void SMESHGUI_TranslationDlg::onSelectMesh ( bool toSelectMesh )
795 TextLabelElements->setText( tr( "SMESH_NAME" ) );
797 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
799 if (myEditCurrentArgument != LineEditElements)
801 LineEditElements->clear();
805 mySelection->ClearFilters() ;
806 SMESH::SetPointRepresentation(false);
810 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
811 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
812 LineEditElements->setReadOnly(true);
816 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
817 LineEditElements->setReadOnly(false);
818 onTextChange(LineEditElements->text());
821 SelectionIntoArgument();
825 //=================================================================================
826 // function : GetConstructorId()
828 //=================================================================================
829 int SMESHGUI_TranslationDlg::GetConstructorId()
831 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
832 return GroupConstructors->id( GroupConstructors->selected() );