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>
60 #include "SALOMEconfig.h"
61 #include CORBA_SERVER_HEADER(SMESH_Group)
65 //=================================================================================
66 // class : SMESHGUI_TranslationDlg()
68 //=================================================================================
69 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( 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_SMESH_TRANSLATION_POINTS")));
75 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_VECTOR")));
76 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
79 setName( "SMESHGUI_TranslationDlg" );
81 setCaption( tr( "SMESH_TRANSLATION" ) );
82 setSizeGripEnabled( TRUE );
83 SMESHGUI_TranslationDlgLayout = new QGridLayout( this );
84 SMESHGUI_TranslationDlgLayout->setSpacing( 6 );
85 SMESHGUI_TranslationDlgLayout->setMargin( 11 );
87 /***************************************************************/
88 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
89 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
90 GroupConstructors->setTitle( tr( "SMESH_TRANSLATION" ) );
91 GroupConstructors->setExclusive( TRUE );
92 GroupConstructors->setColumnLayout(0, Qt::Vertical );
93 GroupConstructors->layout()->setSpacing( 0 );
94 GroupConstructors->layout()->setMargin( 0 );
95 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
96 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
97 GroupConstructorsLayout->setSpacing( 6 );
98 GroupConstructorsLayout->setMargin( 11 );
99 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
100 RadioButton1->setText( tr( "" ) );
101 RadioButton1->setPixmap( image0 );
102 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
103 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
104 RadioButton2->setText( tr( "" ) );
105 RadioButton2->setPixmap( image1 );
106 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
107 SMESHGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
109 /***************************************************************/
110 GroupButtons = new QGroupBox( this, "GroupButtons" );
111 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
112 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
113 GroupButtons->setTitle( tr( "" ) );
114 GroupButtons->setColumnLayout(0, Qt::Vertical );
115 GroupButtons->layout()->setSpacing( 0 );
116 GroupButtons->layout()->setMargin( 0 );
117 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
118 GroupButtonsLayout->setAlignment( Qt::AlignTop );
119 GroupButtonsLayout->setSpacing( 6 );
120 GroupButtonsLayout->setMargin( 11 );
121 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
122 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
123 buttonCancel->setAutoDefault( TRUE );
124 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
125 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
126 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
127 buttonApply->setAutoDefault( TRUE );
128 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
129 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
130 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
131 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
132 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
133 buttonOk->setAutoDefault( TRUE );
134 buttonOk->setDefault( TRUE );
135 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
136 SMESHGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
138 /***************************************************************/
139 GroupArguments = new QGroupBox( this, "GroupArguments" );
140 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
141 GroupArguments->setColumnLayout(0, Qt::Vertical );
142 GroupArguments->layout()->setSpacing( 0 );
143 GroupArguments->layout()->setMargin( 0 );
144 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
145 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
146 GroupArgumentsLayout->setSpacing( 6 );
147 GroupArgumentsLayout->setMargin( 11 );
149 // Controls for elements selection
150 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
151 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
152 TextLabelElements->setFixedWidth(74);
153 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
155 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
156 SelectElementsButton->setText( tr( "" ) );
157 SelectElementsButton->setPixmap( image2 );
158 SelectElementsButton->setToggleButton( FALSE );
159 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
161 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
162 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
163 GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 );
165 // Control for the whole mesh selection
166 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
167 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
168 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 );
170 // Controls for vector and points selection
171 TextLabel1 = new QLabel( GroupArguments, "TextLabel1" );
172 GroupArgumentsLayout->addWidget( TextLabel1, 2, 0 );
174 SelectButton1 = new QPushButton( GroupArguments, "SelectButton1" );
175 SelectButton1->setText( tr( "" ) );
176 SelectButton1->setPixmap( image2 );
177 SelectButton1->setToggleButton( FALSE );
178 GroupArgumentsLayout->addWidget( SelectButton1, 2, 1 );
180 TextLabel1_1 = new QLabel( GroupArguments, "TextLabel1_1" );
181 GroupArgumentsLayout->addWidget( TextLabel1_1, 2, 2 );
183 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
184 GroupArgumentsLayout->addWidget( SpinBox1_1, 2, 3 );
186 TextLabel1_2 = new QLabel( GroupArguments, "TextLabel1_2" );
187 GroupArgumentsLayout->addWidget( TextLabel1_2, 2, 4 );
189 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
190 GroupArgumentsLayout->addWidget( SpinBox1_2, 2, 5 );
192 TextLabel1_3 = new QLabel( GroupArguments, "TextLabel1_3" );
193 GroupArgumentsLayout->addWidget( TextLabel1_3, 2, 6 );
195 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
196 GroupArgumentsLayout->addWidget( SpinBox1_3, 2, 7 );
198 TextLabel2 = new QLabel( GroupArguments, "TextLabel2" );
199 TextLabel2->setText( tr( "SMESH_POINT_2" ) );
200 GroupArgumentsLayout->addWidget( TextLabel2, 3, 0 );
202 SelectButton2 = new QPushButton( GroupArguments, "SelectButton2" );
203 SelectButton2->setText( tr( "" ) );
204 SelectButton2->setPixmap( image2 );
205 SelectButton2->setToggleButton( FALSE );
206 GroupArgumentsLayout->addWidget( SelectButton2, 3, 1 );
208 TextLabel2_1 = new QLabel( GroupArguments, "TextLabel2_1" );
209 TextLabel2_1->setText( tr( "SMESH_X" ) );
210 GroupArgumentsLayout->addWidget( TextLabel2_1, 3, 2 );
212 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
213 GroupArgumentsLayout->addWidget( SpinBox2_1, 3, 3 );
215 TextLabel2_2 = new QLabel( GroupArguments, "TextLabel2_2" );
216 TextLabel2_2->setText( tr( "SMESH_Y" ) );
217 GroupArgumentsLayout->addWidget( TextLabel2_2, 3, 4 );
219 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
220 GroupArgumentsLayout->addWidget( SpinBox2_2, 3, 5 );
222 TextLabel2_3 = new QLabel( GroupArguments, "TextLabel2_3" );
223 TextLabel2_3->setText( tr( "SMESH_Z" ) );
224 GroupArgumentsLayout->addWidget( TextLabel2_3, 3, 6 );
226 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
227 GroupArgumentsLayout->addWidget( SpinBox2_3, 3, 7 );
229 // Controls for "Create a copy" option
230 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
231 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
232 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
235 SMESHGUI_TranslationDlgLayout->addWidget( GroupArguments, 1, 0 );
237 /* Initialisations */
238 SpinBox1_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
239 SpinBox1_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
240 SpinBox1_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
241 SpinBox2_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
242 SpinBox2_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
243 SpinBox2_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
245 GroupArguments->show();
246 RadioButton1->setChecked( TRUE );
249 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
250 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
252 // Costruction of the logical filter
253 SMESH_ListOfFilter aListOfFilters;
254 Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
255 if ( !aMeshOrSubMeshFilter.IsNull() )
256 aListOfFilters.Append( aMeshOrSubMeshFilter );
257 Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
258 if ( !aSmeshGroupFilter.IsNull() )
259 aListOfFilters.Append( aSmeshGroupFilter );
261 myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
265 /* signals and slots connections */
266 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
267 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
268 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
269 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
271 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
272 connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
273 connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
275 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
276 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
277 /* to close dialog if study change */
278 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
279 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
280 SLOT( onTextChange( const QString& )));
281 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
282 SLOT( onSelectMesh( bool )));
284 /* Move widget on the botton right corner of main widget */
286 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
288 this->show() ; /* displays Dialog */
290 ConstructorsClicked(0);
293 //=================================================================================
294 // function : ~SMESHGUI_TranslationDlg()
295 // purpose : Destroys the object and frees any allocated resources
296 //=================================================================================
297 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
299 // no need to delete child widgets, Qt does it all for us
303 //=================================================================================
306 //=================================================================================
307 void SMESHGUI_TranslationDlg::Init( bool ResetControls )
311 myEditCurrentArgument = 0;
312 LineEditElements->clear();
316 buttonOk->setEnabled( false );
317 buttonApply->setEnabled( false );
320 myMesh = SMESH::SMESH_Mesh::_nil();
324 SpinBox1_1->SetValue(0.0);
325 SpinBox1_2->SetValue(0.0);
326 SpinBox1_3->SetValue(0.0);
327 SpinBox2_1->SetValue(0.0);
328 SpinBox2_2->SetValue(0.0);
329 SpinBox2_3->SetValue(0.0);
331 CheckBoxCopy->setChecked(false);
332 CheckBoxMesh->setChecked(false);
333 onSelectMesh( false );
338 //=================================================================================
339 // function : ConstructorsClicked()
340 // purpose : Radio button management
341 //=================================================================================
342 void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId)
344 disconnect(mySelection, 0, this, 0);
346 switch(constructorId)
350 TextLabel1->setText( tr( "SMESH_POINT_1" ) );
351 TextLabel1_1->setText( tr( "SMESH_X" ) );
352 TextLabel1_2->setText( tr( "SMESH_Y" ) );
353 TextLabel1_3->setText( tr( "SMESH_Z" ) );
355 SelectButton1->show();
357 SelectButton2->show();
358 TextLabel2_1->show();
360 TextLabel2_2->show();
362 TextLabel2_3->show();
368 TextLabel1->setText( tr( "SMESH_VECTOR" ) );
369 TextLabel1_1->setText( tr( "SMESH_DX" ) );
370 TextLabel1_2->setText( tr( "SMESH_DY" ) );
371 TextLabel1_3->setText( tr( "SMESH_DZ" ) );
373 SelectButton1->hide();
375 SelectButton2->hide();
376 TextLabel2_1->hide();
378 TextLabel2_2->hide();
380 TextLabel2_3->hide();
386 if (myEditCurrentArgument != (QWidget*)LineEditElements)
388 SMESH::SetPointRepresentation(false);
389 if (!CheckBoxMesh->isChecked())
390 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
393 myEditCurrentArgument = (QWidget*)LineEditElements;
394 LineEditElements->setFocus();
396 if (CheckBoxMesh->isChecked())
399 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
403 //=================================================================================
404 // function : ClickOnApply()
406 //=================================================================================
407 void SMESHGUI_TranslationDlg::ClickOnApply()
409 if (mySMESHGUI->ActiveStudyLocked())
414 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
416 SMESH::long_array_var anElementsId = new SMESH::long_array;
418 anElementsId->length( aListElementsId.count() );
419 for ( int i = 0; i < aListElementsId.count(); i++ )
420 anElementsId[i] = aListElementsId[i].toInt();
422 SMESH::DirStruct aVector;
423 if(GetConstructorId() == 0)
425 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
426 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
427 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
429 else if(GetConstructorId() == 1)
431 aVector.PS.x = SpinBox1_1->GetValue();
432 aVector.PS.y = SpinBox1_2->GetValue();
433 aVector.PS.z = SpinBox1_3->GetValue();
436 bool toCreateCopy = CheckBoxCopy->isChecked();
440 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
441 QApplication::setOverrideCursor(Qt::waitCursor);
442 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
443 QApplication::restoreOverrideCursor();
449 mySelection->ClearIObjects();
452 ConstructorsClicked( GetConstructorId() );
456 //=================================================================================
457 // function : ClickOnOk()
459 //=================================================================================
460 void SMESHGUI_TranslationDlg::ClickOnOk()
467 //=================================================================================
468 // function : ClickOnCancel()
470 //=================================================================================
471 void SMESHGUI_TranslationDlg::ClickOnCancel()
473 mySelection->ClearFilters();
474 mySelection->ClearIObjects();
475 SMESH::SetPointRepresentation(false);
476 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
477 disconnect( mySelection, 0, this, 0 );
478 mySMESHGUI->ResetState() ;
482 //=======================================================================
483 //function : onTextChange
485 //=======================================================================
487 void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText)
489 QLineEdit* send = (QLineEdit*)sender();
491 if ( myBusy ) return;
494 if (send == LineEditElements)
497 buttonOk->setEnabled( false );
498 buttonApply->setEnabled( false );
500 // hilight entered elements
501 SMDS_Mesh* aMesh = 0;
503 aMesh = myActor->GetObject()->GetMesh();
506 mySelection->ClearIObjects();
507 mySelection->AddIObject( myActor->getIO() );
509 QStringList aListId = QStringList::split( " ", theNewText, false);
511 if (send == LineEditElements) {
512 for ( int i = 0; i < aListId.count(); i++ ) {
513 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
515 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
516 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
520 myElementsId = theNewText;
524 if ( myNbOkElements ) {
525 buttonOk->setEnabled( true );
526 buttonApply->setEnabled( true );
532 //=================================================================================
533 // function : SelectionIntoArgument()
534 // purpose : Called when selection as changed or other case
535 //=================================================================================
536 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
538 if ( myBusy ) return;
542 QString aString = "";
545 if (myEditCurrentArgument == (QWidget*)LineEditElements)
547 LineEditElements->setText( aString );
549 buttonOk->setEnabled( false );
550 buttonApply->setEnabled( false );
554 if ( !GroupButtons->isEnabled() ) // inactive
559 int nbSel = mySelection->IObjectCount();
563 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
564 myMesh = SMESH::GetMeshByIO(IO);
565 if(myMesh->_is_nil())
568 myActor = SMESH::FindActorByObject(myMesh);
570 myActor = SMESH::FindActorByEntry(IO->getEntry());
576 if (myEditCurrentArgument == (QWidget*)LineEditElements)
580 if (CheckBoxMesh->isChecked())
582 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
584 if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
587 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
591 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
593 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
595 myElementsId += QString(" %1").arg(i);
600 else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
603 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
605 // get IDs from submesh
606 SMESH::long_array_var anElementsIds = new SMESH::long_array;
607 anElementsIds = aSubMesh->GetElementsId();
608 for ( int i = 0; i < anElementsIds->length(); i++ )
609 myElementsId += QString(" %1").arg(anElementsIds[i]);
610 aNbUnits = anElementsIds->length();
615 SMESH::SMESH_GroupBase_var aGroup =
616 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
617 if (aGroup->_is_nil())
620 // get IDs from smesh group
621 SMESH::long_array_var anElementsIds = new SMESH::long_array;
622 anElementsIds = aGroup->GetListOfID();
623 for ( int i = 0; i < anElementsIds->length(); i++ )
624 myElementsId += QString(" %1").arg(anElementsIds[i]);
625 aNbUnits = anElementsIds->length();
630 aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
631 myElementsId = aString;
637 myNbOkElements = true;
640 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString);
644 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
648 const SMDS_MeshNode * n = aMesh->FindNode( aString.toInt() );
656 if (myEditCurrentArgument == (QWidget*)SpinBox1_1)
658 SpinBox1_1->SetValue(x);
659 SpinBox1_2->SetValue(y);
660 SpinBox2_3->SetValue(z);
662 else if (myEditCurrentArgument == (QWidget*)SpinBox2_1)
664 SpinBox2_1->SetValue(x);
665 SpinBox2_2->SetValue(y);
666 SpinBox2_3->SetValue(z);
671 if (myEditCurrentArgument == (QWidget*)LineEditElements)
672 LineEditElements->setText( aString );
678 buttonOk->setEnabled( true );
679 buttonApply->setEnabled( true );
684 //=================================================================================
685 // function : SetEditCurrentArgument()
687 //=================================================================================
688 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
690 QPushButton* send = (QPushButton*)sender();
692 disconnect( mySelection, 0, this, 0 );
693 mySelection->ClearIObjects();
694 mySelection->ClearFilters();
696 if(send == SelectElementsButton) {
697 myEditCurrentArgument = (QWidget*)LineEditElements;
698 SMESH::SetPointRepresentation(false);
699 if (CheckBoxMesh->isChecked())
701 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
702 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
705 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
707 else if (send == SelectButton1)
709 myEditCurrentArgument = (QWidget*)SpinBox1_1;
710 SMESH::SetPointRepresentation(true);
711 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
713 else if (send == SelectButton2)
715 myEditCurrentArgument = (QWidget*)SpinBox2_1;
716 SMESH::SetPointRepresentation(true);
717 QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
720 myEditCurrentArgument->setFocus();
721 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
722 SelectionIntoArgument() ;
725 //=================================================================================
726 // function : DeactivateActiveDialog()
728 //=================================================================================
729 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
731 if ( GroupConstructors->isEnabled() ) {
732 GroupConstructors->setEnabled(false) ;
733 GroupArguments->setEnabled(false) ;
734 GroupButtons->setEnabled(false) ;
735 mySMESHGUI->ResetState() ;
736 mySMESHGUI->SetActiveDialogBox(0) ;
741 //=================================================================================
742 // function : ActivateThisDialog()
744 //=================================================================================
745 void SMESHGUI_TranslationDlg::ActivateThisDialog()
747 /* Emit a signal to deactivate the active dialog */
748 mySMESHGUI->EmitSignalDeactivateDialog() ;
749 GroupConstructors->setEnabled(true) ;
750 GroupArguments->setEnabled(true) ;
751 GroupButtons->setEnabled(true) ;
753 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
755 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
756 SelectionIntoArgument();
760 //=================================================================================
761 // function : enterEvent()
763 //=================================================================================
764 void SMESHGUI_TranslationDlg::enterEvent(QEvent* e)
766 if ( GroupConstructors->isEnabled() )
768 ActivateThisDialog() ;
772 //=================================================================================
773 // function : closeEvent()
775 //=================================================================================
776 void SMESHGUI_TranslationDlg::closeEvent( QCloseEvent* e )
778 /* same than click on cancel button */
779 this->ClickOnCancel() ;
783 //=======================================================================
784 //function : hideEvent
785 //purpose : caused by ESC key
786 //=======================================================================
788 void SMESHGUI_TranslationDlg::hideEvent ( QHideEvent * e )
790 if ( !isMinimized() )
795 //=======================================================================
796 //function : onSelectMesh
798 //=======================================================================
799 void SMESHGUI_TranslationDlg::onSelectMesh ( bool toSelectMesh )
802 TextLabelElements->setText( tr( "SMESH_NAME" ) );
804 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
806 if (myEditCurrentArgument != LineEditElements)
808 LineEditElements->clear();
812 mySelection->ClearFilters() ;
813 SMESH::SetPointRepresentation(false);
817 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
818 mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
819 LineEditElements->setReadOnly(true);
823 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
824 LineEditElements->setReadOnly(false);
825 onTextChange(LineEditElements->text());
828 SelectionIntoArgument();
832 //=================================================================================
833 // function : GetConstructorId()
835 //=================================================================================
836 int SMESHGUI_TranslationDlg::GetConstructorId()
838 if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
839 return GroupConstructors->id( GroupConstructors->selected() );