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"
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>
61 #include "SALOMEconfig.h"
62 #include CORBA_SERVER_HEADER(SMESH_Group)
66 //=================================================================================
67 // class : SMESHGUI_TranslationDlg()
69 //=================================================================================
70 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
71 bool modal, WFlags fl )
72 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
73 Qt::WDestructiveClose)
75 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_POINTS")));
76 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_VECTOR")));
77 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
80 setName( "SMESHGUI_TranslationDlg" );
82 setCaption( tr( "SMESH_TRANSLATION" ) );
83 setSizeGripEnabled( TRUE );
84 SMESHGUI_TranslationDlgLayout = new QGridLayout( this );
85 SMESHGUI_TranslationDlgLayout->setSpacing( 6 );
86 SMESHGUI_TranslationDlgLayout->setMargin( 11 );
88 /***************************************************************/
89 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
90 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
91 GroupConstructors->setTitle( tr( "SMESH_TRANSLATION" ) );
92 GroupConstructors->setExclusive( TRUE );
93 GroupConstructors->setColumnLayout(0, Qt::Vertical );
94 GroupConstructors->layout()->setSpacing( 0 );
95 GroupConstructors->layout()->setMargin( 0 );
96 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
97 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
98 GroupConstructorsLayout->setSpacing( 6 );
99 GroupConstructorsLayout->setMargin( 11 );
100 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
101 RadioButton1->setText( tr( "" ) );
102 RadioButton1->setPixmap( image0 );
103 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
104 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
105 RadioButton2->setText( tr( "" ) );
106 RadioButton2->setPixmap( image1 );
107 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
108 SMESHGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
110 /***************************************************************/
111 GroupButtons = new QGroupBox( this, "GroupButtons" );
112 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
113 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
114 GroupButtons->setTitle( tr( "" ) );
115 GroupButtons->setColumnLayout(0, Qt::Vertical );
116 GroupButtons->layout()->setSpacing( 0 );
117 GroupButtons->layout()->setMargin( 0 );
118 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
119 GroupButtonsLayout->setAlignment( Qt::AlignTop );
120 GroupButtonsLayout->setSpacing( 6 );
121 GroupButtonsLayout->setMargin( 11 );
122 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
123 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
124 buttonCancel->setAutoDefault( TRUE );
125 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
126 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
127 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
128 buttonApply->setAutoDefault( TRUE );
129 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
130 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
131 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
132 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
133 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
134 buttonOk->setAutoDefault( TRUE );
135 buttonOk->setDefault( TRUE );
136 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
137 SMESHGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
139 /***************************************************************/
140 GroupArguments = new QGroupBox( this, "GroupArguments" );
141 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
142 GroupArguments->setColumnLayout(0, Qt::Vertical );
143 GroupArguments->layout()->setSpacing( 0 );
144 GroupArguments->layout()->setMargin( 0 );
145 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
146 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
147 GroupArgumentsLayout->setSpacing( 6 );
148 GroupArgumentsLayout->setMargin( 11 );
150 // Controls for elements selection
151 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
152 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
153 TextLabelElements->setFixedWidth(74);
154 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
156 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
157 SelectElementsButton->setText( tr( "" ) );
158 SelectElementsButton->setPixmap( image2 );
159 SelectElementsButton->setToggleButton( FALSE );
160 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
162 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
163 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
164 GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 );
166 // Control for the whole mesh selection
167 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
168 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
169 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 );
171 // Controls for vector and points selection
172 TextLabel1 = new QLabel( GroupArguments, "TextLabel1" );
173 GroupArgumentsLayout->addWidget( TextLabel1, 2, 0 );
175 SelectButton1 = new QPushButton( GroupArguments, "SelectButton1" );
176 SelectButton1->setText( tr( "" ) );
177 SelectButton1->setPixmap( image2 );
178 SelectButton1->setToggleButton( FALSE );
179 GroupArgumentsLayout->addWidget( SelectButton1, 2, 1 );
181 TextLabel1_1 = new QLabel( GroupArguments, "TextLabel1_1" );
182 GroupArgumentsLayout->addWidget( TextLabel1_1, 2, 2 );
184 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
185 GroupArgumentsLayout->addWidget( SpinBox1_1, 2, 3 );
187 TextLabel1_2 = new QLabel( GroupArguments, "TextLabel1_2" );
188 GroupArgumentsLayout->addWidget( TextLabel1_2, 2, 4 );
190 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
191 GroupArgumentsLayout->addWidget( SpinBox1_2, 2, 5 );
193 TextLabel1_3 = new QLabel( GroupArguments, "TextLabel1_3" );
194 GroupArgumentsLayout->addWidget( TextLabel1_3, 2, 6 );
196 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
197 GroupArgumentsLayout->addWidget( SpinBox1_3, 2, 7 );
199 TextLabel2 = new QLabel( GroupArguments, "TextLabel2" );
200 TextLabel2->setText( tr( "SMESH_POINT_2" ) );
201 GroupArgumentsLayout->addWidget( TextLabel2, 3, 0 );
203 SelectButton2 = new QPushButton( GroupArguments, "SelectButton2" );
204 SelectButton2->setText( tr( "" ) );
205 SelectButton2->setPixmap( image2 );
206 SelectButton2->setToggleButton( FALSE );
207 GroupArgumentsLayout->addWidget( SelectButton2, 3, 1 );
209 TextLabel2_1 = new QLabel( GroupArguments, "TextLabel2_1" );
210 TextLabel2_1->setText( tr( "SMESH_X" ) );
211 GroupArgumentsLayout->addWidget( TextLabel2_1, 3, 2 );
213 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
214 GroupArgumentsLayout->addWidget( SpinBox2_1, 3, 3 );
216 TextLabel2_2 = new QLabel( GroupArguments, "TextLabel2_2" );
217 TextLabel2_2->setText( tr( "SMESH_Y" ) );
218 GroupArgumentsLayout->addWidget( TextLabel2_2, 3, 4 );
220 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
221 GroupArgumentsLayout->addWidget( SpinBox2_2, 3, 5 );
223 TextLabel2_3 = new QLabel( GroupArguments, "TextLabel2_3" );
224 TextLabel2_3->setText( tr( "SMESH_Z" ) );
225 GroupArgumentsLayout->addWidget( TextLabel2_3, 3, 6 );
227 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
228 GroupArgumentsLayout->addWidget( SpinBox2_3, 3, 7 );
230 // Controls for "Create a copy" option
231 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
232 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
233 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
236 SMESHGUI_TranslationDlgLayout->addWidget( GroupArguments, 1, 0 );
238 /* Initialisations */
239 SpinBox1_1->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
240 SpinBox1_2->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
241 SpinBox1_3->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
242 SpinBox2_1->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
243 SpinBox2_2->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
244 SpinBox2_3->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
246 GroupArguments->show();
247 RadioButton1->setChecked( TRUE );
250 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
251 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
253 // Costruction of the logical filter
254 SMESH_ListOfFilter aListOfFilters;
255 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
256 if ( !aMeshOrSubMeshFilter.IsNull() )
257 aListOfFilters.Append( aMeshOrSubMeshFilter );
258 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
259 if ( !aSmeshGroupFilter.IsNull() )
260 aListOfFilters.Append( aSmeshGroupFilter );
262 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
266 /* signals and slots connections */
267 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
268 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
269 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
270 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
272 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
273 connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
274 connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
276 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
277 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
278 /* to close dialog if study change */
279 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
280 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
281 SLOT( onTextChange( const QString& )));
282 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
283 SLOT( onSelectMesh( bool )));
285 /* Move widget on the botton right corner of main widget */
287 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
289 this->show() ; /* displays Dialog */
291 ConstructorsClicked(0);
294 //=================================================================================
295 // function : ~SMESHGUI_TranslationDlg()
296 // purpose : Destroys the object and frees any allocated resources
297 //=================================================================================
298 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
300 // no need to delete child widgets, Qt does it all for us
304 //=================================================================================
307 //=================================================================================
308 void SMESHGUI_TranslationDlg::Init( bool ResetControls )
312 myEditCurrentArgument = 0;
313 LineEditElements->clear();
317 buttonOk->setEnabled( false );
318 buttonApply->setEnabled( false );
321 myMesh = SMESH::SMESH_Mesh::_nil();
325 SpinBox1_1->SetValue(0.0);
326 SpinBox1_2->SetValue(0.0);
327 SpinBox1_3->SetValue(0.0);
328 SpinBox2_1->SetValue(0.0);
329 SpinBox2_2->SetValue(0.0);
330 SpinBox2_3->SetValue(0.0);
332 CheckBoxCopy->setChecked(false);
333 CheckBoxMesh->setChecked(false);
334 onSelectMesh( false );
339 //=================================================================================
340 // function : ConstructorsClicked()
341 // purpose : Radio button management
342 //=================================================================================
343 void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId)
345 disconnect(mySelection, 0, this, 0);
347 switch(constructorId)
351 TextLabel1->setText( tr( "SMESH_POINT_1" ) );
352 TextLabel1_1->setText( tr( "SMESH_X" ) );
353 TextLabel1_2->setText( tr( "SMESH_Y" ) );
354 TextLabel1_3->setText( tr( "SMESH_Z" ) );
356 SelectButton1->show();
358 SelectButton2->show();
359 TextLabel2_1->show();
361 TextLabel2_2->show();
363 TextLabel2_3->show();
369 TextLabel1->setText( tr( "SMESH_VECTOR" ) );
370 TextLabel1_1->setText( tr( "SMESH_DX" ) );
371 TextLabel1_2->setText( tr( "SMESH_DY" ) );
372 TextLabel1_3->setText( tr( "SMESH_DZ" ) );
374 SelectButton1->hide();
376 SelectButton2->hide();
377 TextLabel2_1->hide();
379 TextLabel2_2->hide();
381 TextLabel2_3->hide();
387 if (myEditCurrentArgument != (QWidget*)LineEditElements)
389 SMESH::SetPointRepresentation(false);
390 if (!CheckBoxMesh->isChecked())
391 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
394 myEditCurrentArgument = (QWidget*)LineEditElements;
395 LineEditElements->setFocus();
397 if (CheckBoxMesh->isChecked())
400 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
404 //=================================================================================
405 // function : ClickOnApply()
407 //=================================================================================
408 void SMESHGUI_TranslationDlg::ClickOnApply()
410 if (mySMESHGUI->ActiveStudyLocked())
415 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
417 SMESH::long_array_var anElementsId = new SMESH::long_array;
419 anElementsId->length( aListElementsId.count() );
420 for ( int i = 0; i < aListElementsId.count(); i++ )
421 anElementsId[i] = aListElementsId[i].toInt();
423 SMESH::DirStruct aVector;
424 if(GetConstructorId() == 0)
426 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
427 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
428 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
430 else if(GetConstructorId() == 1)
432 aVector.PS.x = SpinBox1_1->GetValue();
433 aVector.PS.y = SpinBox1_2->GetValue();
434 aVector.PS.z = SpinBox1_3->GetValue();
437 bool toCreateCopy = CheckBoxCopy->isChecked();
441 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
442 QApplication::setOverrideCursor(Qt::waitCursor);
443 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
444 QApplication::restoreOverrideCursor();
450 mySelection->ClearIObjects();
453 ConstructorsClicked( GetConstructorId() );
457 //=================================================================================
458 // function : ClickOnOk()
460 //=================================================================================
461 void SMESHGUI_TranslationDlg::ClickOnOk()
468 //=================================================================================
469 // function : ClickOnCancel()
471 //=================================================================================
472 void SMESHGUI_TranslationDlg::ClickOnCancel()
474 mySelection->ClearFilters();
475 mySelection->ClearIObjects();
476 SMESH::SetPointRepresentation(false);
477 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
478 disconnect( mySelection, 0, this, 0 );
479 mySMESHGUI->ResetState() ;
483 //=======================================================================
484 //function : onTextChange
486 //=======================================================================
488 void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText)
490 QLineEdit* send = (QLineEdit*)sender();
492 if ( myBusy ) return;
495 if (send == LineEditElements)
498 buttonOk->setEnabled( false );
499 buttonApply->setEnabled( false );
501 // hilight entered elements
502 SMDS_Mesh* aMesh = 0;
504 aMesh = myActor->GetObject()->GetMesh();
507 mySelection->ClearIObjects();
508 mySelection->AddIObject( myActor->getIO() );
510 QStringList aListId = QStringList::split( " ", theNewText, false);
512 if (send == LineEditElements) {
513 for ( int i = 0; i < aListId.count(); i++ ) {
514 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
516 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
517 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
521 myElementsId = theNewText;
525 if ( myNbOkElements ) {
526 buttonOk->setEnabled( true );
527 buttonApply->setEnabled( true );
533 //=================================================================================
534 // function : SelectionIntoArgument()
535 // purpose : Called when selection as changed or other case
536 //=================================================================================
537 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
539 if ( myBusy ) return;
543 QString aString = "";
546 if (myEditCurrentArgument == (QWidget*)LineEditElements)
548 LineEditElements->setText( aString );
550 buttonOk->setEnabled( false );
551 buttonApply->setEnabled( false );
555 if ( !GroupButtons->isEnabled() ) // inactive
560 int nbSel = mySelection->IObjectCount();
564 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
565 myMesh = SMESH::GetMeshByIO(IO);
566 if(myMesh->_is_nil())
569 myActor = SMESH::FindActorByObject(myMesh);
571 myActor = SMESH::FindActorByEntry(IO->getEntry());
577 if (myEditCurrentArgument == (QWidget*)LineEditElements)
581 if (CheckBoxMesh->isChecked())
583 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
585 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
588 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
592 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
594 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
596 myElementsId += QString(" %1").arg(i);
601 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
604 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
606 // get IDs from submesh
607 SMESH::long_array_var anElementsIds = new SMESH::long_array;
608 anElementsIds = aSubMesh->GetElementsId();
609 for ( int i = 0; i < anElementsIds->length(); i++ )
610 myElementsId += QString(" %1").arg(anElementsIds[i]);
611 aNbUnits = anElementsIds->length();
616 SMESH::SMESH_GroupBase_var aGroup =
617 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
618 if (aGroup->_is_nil())
621 // get IDs from smesh group
622 SMESH::long_array_var anElementsIds = new SMESH::long_array;
623 anElementsIds = aGroup->GetListOfID();
624 for ( int i = 0; i < anElementsIds->length(); i++ )
625 myElementsId += QString(" %1").arg(anElementsIds[i]);
626 aNbUnits = anElementsIds->length();
631 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
632 myElementsId = aString;
638 myNbOkElements = true;
641 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
645 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
649 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
657 if (myEditCurrentArgument == (QWidget*)SpinBox1_1)
659 SpinBox1_1->SetValue(x);
660 SpinBox1_2->SetValue(y);
661 SpinBox2_3->SetValue(z);
663 else if (myEditCurrentArgument == (QWidget*)SpinBox2_1)
665 SpinBox2_1->SetValue(x);
666 SpinBox2_2->SetValue(y);
667 SpinBox2_3->SetValue(z);
672 if (myEditCurrentArgument == (QWidget*)LineEditElements)
673 LineEditElements->setText( aString );
679 buttonOk->setEnabled( true );
680 buttonApply->setEnabled( true );
685 //=================================================================================
686 // function : SetEditCurrentArgument()
688 //=================================================================================
689 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
691 QPushButton* send = (QPushButton*)sender();
693 disconnect( mySelection, 0, this, 0 );
694 mySelection->ClearIObjects();
695 mySelection->ClearFilters();
697 if(send == SelectElementsButton) {
698 myEditCurrentArgument = (QWidget*)LineEditElements;
699 SMESH::SetPointRepresentation(false);
700 if (CheckBoxMesh->isChecked())
702 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
703 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
706 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
708 else if (send == SelectButton1)
710 myEditCurrentArgument = (QWidget*)SpinBox1_1;
711 SMESH::SetPointRepresentation(true);
712 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
714 else if (send == SelectButton2)
716 myEditCurrentArgument = (QWidget*)SpinBox2_1;
717 SMESH::SetPointRepresentation(true);
718 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
721 myEditCurrentArgument->setFocus();
722 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
723 SelectionIntoArgument() ;
726 //=================================================================================
727 // function : DeactivateActiveDialog()
729 //=================================================================================
730 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
732 if ( GroupConstructors->isEnabled() ) {
733 GroupConstructors->setEnabled(false) ;
734 GroupArguments->setEnabled(false) ;
735 GroupButtons->setEnabled(false) ;
736 mySMESHGUI->ResetState() ;
737 mySMESHGUI->SetActiveDialogBox(0) ;
742 //=================================================================================
743 // function : ActivateThisDialog()
745 //=================================================================================
746 void SMESHGUI_TranslationDlg::ActivateThisDialog()
748 /* Emit a signal to deactivate the active dialog */
749 mySMESHGUI->EmitSignalDeactivateDialog() ;
750 GroupConstructors->setEnabled(true) ;
751 GroupArguments->setEnabled(true) ;
752 GroupButtons->setEnabled(true) ;
754 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
756 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
757 SelectionIntoArgument();
761 //=================================================================================
762 // function : enterEvent()
764 //=================================================================================
765 void SMESHGUI_TranslationDlg::enterEvent(QEvent* e)
767 if ( GroupConstructors->isEnabled() )
769 ActivateThisDialog() ;
773 //=================================================================================
774 // function : closeEvent()
776 //=================================================================================
777 void SMESHGUI_TranslationDlg::closeEvent( QCloseEvent* e )
779 /* same than click on cancel button */
780 this->ClickOnCancel() ;
784 //=======================================================================
785 //function : hideEvent
786 //purpose : caused by ESC key
787 //=======================================================================
789 void SMESHGUI_TranslationDlg::hideEvent ( QHideEvent * e )
791 if ( !isMinimized() )
796 //=======================================================================
797 //function : onSelectMesh
799 //=======================================================================
800 void SMESHGUI_TranslationDlg::onSelectMesh ( bool toSelectMesh )
803 TextLabelElements->setText( tr( "SMESH_NAME" ) );
805 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
807 if (myEditCurrentArgument != LineEditElements)
809 LineEditElements->clear();
813 mySelection->ClearFilters() ;
814 SMESH::SetPointRepresentation(false);
818 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
819 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
820 LineEditElements->setReadOnly(true);
824 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
825 LineEditElements->setReadOnly(false);
826 onTextChange(LineEditElements->text());
829 SelectionIntoArgument();
833 //=================================================================================
834 // function : GetConstructorId()
836 //=================================================================================
837 int SMESHGUI_TranslationDlg::GetConstructorId()
839 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
840 return GroupConstructors->id( GroupConstructors->selected() );