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_IdValidator.h"
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_Actor.h"
37 #include "SMDS_Mesh.hxx"
39 #include "QAD_Application.h"
40 #include "QAD_Desktop.h"
41 #include "QAD_MessageBox.h"
42 #include "utilities.h"
45 #include <qapplication.h>
46 #include <qbuttongroup.h>
47 #include <qgroupbox.h>
49 #include <qlineedit.h>
50 #include <qpushbutton.h>
51 #include <qradiobutton.h>
52 #include <qcheckbox.h>
59 //=================================================================================
60 // class : SMESHGUI_TranslationDlg()
62 //=================================================================================
63 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
64 bool modal, WFlags fl )
65 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
66 Qt::WDestructiveClose)
68 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_POINTS")));
69 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_VECTOR")));
70 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
73 setName( "SMESHGUI_TranslationDlg" );
75 setCaption( tr( "SMESH_TRANSLATION" ) );
76 setSizeGripEnabled( TRUE );
77 SMESHGUI_TranslationDlgLayout = new QGridLayout( this );
78 SMESHGUI_TranslationDlgLayout->setSpacing( 6 );
79 SMESHGUI_TranslationDlgLayout->setMargin( 11 );
81 /***************************************************************/
82 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
83 GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
84 GroupConstructors->setTitle( tr( "SMESH_TRANSLATION" ) );
85 GroupConstructors->setExclusive( TRUE );
86 GroupConstructors->setColumnLayout(0, Qt::Vertical );
87 GroupConstructors->layout()->setSpacing( 0 );
88 GroupConstructors->layout()->setMargin( 0 );
89 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
90 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
91 GroupConstructorsLayout->setSpacing( 6 );
92 GroupConstructorsLayout->setMargin( 11 );
93 RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
94 RadioButton1->setText( tr( "" ) );
95 RadioButton1->setPixmap( image0 );
96 GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
97 RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
98 RadioButton2->setText( tr( "" ) );
99 RadioButton2->setPixmap( image1 );
100 GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
101 SMESHGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
103 /***************************************************************/
104 GroupButtons = new QGroupBox( this, "GroupButtons" );
105 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
106 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
107 GroupButtons->setTitle( tr( "" ) );
108 GroupButtons->setColumnLayout(0, Qt::Vertical );
109 GroupButtons->layout()->setSpacing( 0 );
110 GroupButtons->layout()->setMargin( 0 );
111 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
112 GroupButtonsLayout->setAlignment( Qt::AlignTop );
113 GroupButtonsLayout->setSpacing( 6 );
114 GroupButtonsLayout->setMargin( 11 );
115 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
116 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
117 buttonCancel->setAutoDefault( TRUE );
118 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
119 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
120 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
121 buttonApply->setAutoDefault( TRUE );
122 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
123 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
124 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
125 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
126 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
127 buttonOk->setAutoDefault( TRUE );
128 buttonOk->setDefault( TRUE );
129 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
130 SMESHGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
132 /***************************************************************/
133 GroupArguments = new QGroupBox( this, "GroupArguments" );
134 GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) );
135 GroupArguments->setColumnLayout(0, Qt::Vertical );
136 GroupArguments->layout()->setSpacing( 0 );
137 GroupArguments->layout()->setMargin( 0 );
138 GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() );
139 GroupArgumentsLayout->setAlignment( Qt::AlignTop );
140 GroupArgumentsLayout->setSpacing( 6 );
141 GroupArgumentsLayout->setMargin( 11 );
143 // Controls for elements selection
144 TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
145 TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
146 TextLabelElements->setFixedWidth(74);
147 GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
149 SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
150 SelectElementsButton->setText( tr( "" ) );
151 SelectElementsButton->setPixmap( image2 );
152 SelectElementsButton->setToggleButton( FALSE );
153 GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 );
155 LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" );
156 LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
157 GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 );
159 // Control for the whole mesh selection
160 CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
161 CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
162 GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 );
164 // Controls for vector and points selection
165 TextLabel1 = new QLabel( GroupArguments, "TextLabel1" );
166 GroupArgumentsLayout->addWidget( TextLabel1, 2, 0 );
168 SelectButton1 = new QPushButton( GroupArguments, "SelectButton1" );
169 SelectButton1->setText( tr( "" ) );
170 SelectButton1->setPixmap( image2 );
171 SelectButton1->setToggleButton( FALSE );
172 GroupArgumentsLayout->addWidget( SelectButton1, 2, 1 );
174 TextLabel1_1 = new QLabel( GroupArguments, "TextLabel1_1" );
175 GroupArgumentsLayout->addWidget( TextLabel1_1, 2, 2 );
177 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
178 GroupArgumentsLayout->addWidget( SpinBox1_1, 2, 3 );
180 TextLabel1_2 = new QLabel( GroupArguments, "TextLabel1_2" );
181 GroupArgumentsLayout->addWidget( TextLabel1_2, 2, 4 );
183 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
184 GroupArgumentsLayout->addWidget( SpinBox1_2, 2, 5 );
186 TextLabel1_3 = new QLabel( GroupArguments, "TextLabel1_3" );
187 GroupArgumentsLayout->addWidget( TextLabel1_3, 2, 6 );
189 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
190 GroupArgumentsLayout->addWidget( SpinBox1_3, 2, 7 );
192 TextLabel2 = new QLabel( GroupArguments, "TextLabel2" );
193 TextLabel2->setText( tr( "SMESH_POINT_2" ) );
194 GroupArgumentsLayout->addWidget( TextLabel2, 3, 0 );
196 SelectButton2 = new QPushButton( GroupArguments, "SelectButton2" );
197 SelectButton2->setText( tr( "" ) );
198 SelectButton2->setPixmap( image2 );
199 SelectButton2->setToggleButton( FALSE );
200 GroupArgumentsLayout->addWidget( SelectButton2, 3, 1 );
202 TextLabel2_1 = new QLabel( GroupArguments, "TextLabel2_1" );
203 TextLabel2_1->setText( tr( "SMESH_X" ) );
204 GroupArgumentsLayout->addWidget( TextLabel2_1, 3, 2 );
206 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
207 GroupArgumentsLayout->addWidget( SpinBox2_1, 3, 3 );
209 TextLabel2_2 = new QLabel( GroupArguments, "TextLabel2_2" );
210 TextLabel2_2->setText( tr( "SMESH_Y" ) );
211 GroupArgumentsLayout->addWidget( TextLabel2_2, 3, 4 );
213 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
214 GroupArgumentsLayout->addWidget( SpinBox2_2, 3, 5 );
216 TextLabel2_3 = new QLabel( GroupArguments, "TextLabel2_3" );
217 TextLabel2_3->setText( tr( "SMESH_Z" ) );
218 GroupArgumentsLayout->addWidget( TextLabel2_3, 3, 6 );
220 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
221 GroupArgumentsLayout->addWidget( SpinBox2_3, 3, 7 );
223 // Controls for "Create a copy" option
224 CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" );
225 CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) );
226 GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 );
229 SMESHGUI_TranslationDlgLayout->addWidget( GroupArguments, 1, 0 );
231 /* Initialisations */
232 SpinBox1_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
233 SpinBox1_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
234 SpinBox1_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
235 SpinBox2_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
236 SpinBox2_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
237 SpinBox2_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
239 GroupArguments->show();
240 RadioButton1->setChecked( TRUE );
243 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
244 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
246 myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
250 /* signals and slots connections */
251 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
252 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
253 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
254 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
256 connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
257 connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
258 connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
260 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
261 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
262 /* to close dialog if study change */
263 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
264 connect( LineEditElements, SIGNAL( textChanged( const QString& )),
265 SLOT( onTextChange( const QString& )));
266 connect( CheckBoxMesh, SIGNAL( toggled( bool )),
267 SLOT( onSelectMesh( bool )));
269 /* Move widget on the botton right corner of main widget */
271 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
273 this->show() ; /* displays Dialog */
275 ConstructorsClicked(0);
278 //=================================================================================
279 // function : ~SMESHGUI_TranslationDlg()
280 // purpose : Destroys the object and frees any allocated resources
281 //=================================================================================
282 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
284 // no need to delete child widgets, Qt does it all for us
288 //=================================================================================
291 //=================================================================================
292 void SMESHGUI_TranslationDlg::Init( bool ResetControls )
296 myEditCurrentArgument = 0;
297 LineEditElements->clear();
301 buttonOk->setEnabled( false );
302 buttonApply->setEnabled( false );
305 myMesh = SMESH::SMESH_Mesh::_nil();
309 SpinBox1_1->SetValue(0.0);
310 SpinBox1_2->SetValue(0.0);
311 SpinBox1_3->SetValue(0.0);
312 SpinBox2_1->SetValue(0.0);
313 SpinBox2_2->SetValue(0.0);
314 SpinBox2_3->SetValue(0.0);
316 CheckBoxCopy->setChecked(false);
317 CheckBoxMesh->setChecked(false);
318 onSelectMesh( false );
323 //=================================================================================
324 // function : ConstructorsClicked()
325 // purpose : Radio button management
326 //=================================================================================
327 void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId)
329 disconnect(mySelection, 0, this, 0);
331 switch(constructorId)
335 TextLabel1->setText( tr( "SMESH_POINT_1" ) );
336 TextLabel1_1->setText( tr( "SMESH_X" ) );
337 TextLabel1_2->setText( tr( "SMESH_Y" ) );
338 TextLabel1_3->setText( tr( "SMESH_Z" ) );
340 SelectButton1->show();
342 SelectButton2->show();
343 TextLabel2_1->show();
345 TextLabel2_2->show();
347 TextLabel2_3->show();
353 TextLabel1->setText( tr( "SMESH_VECTOR" ) );
354 TextLabel1_1->setText( tr( "SMESH_DX" ) );
355 TextLabel1_2->setText( tr( "SMESH_DY" ) );
356 TextLabel1_3->setText( tr( "SMESH_DZ" ) );
358 SelectButton1->hide();
360 SelectButton2->hide();
361 TextLabel2_1->hide();
363 TextLabel2_2->hide();
365 TextLabel2_3->hide();
371 if (myEditCurrentArgument != (QWidget*)LineEditElements)
373 SMESH::SetPointRepresentation(false);
374 if (!CheckBoxMesh->isChecked())
375 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
378 myEditCurrentArgument = (QWidget*)LineEditElements;
379 LineEditElements->setFocus();
381 if (CheckBoxMesh->isChecked())
384 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
388 //=================================================================================
389 // function : ClickOnApply()
391 //=================================================================================
392 void SMESHGUI_TranslationDlg::ClickOnApply()
394 if (mySMESHGUI->ActiveStudyLocked())
399 QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
401 SMESH::long_array_var anElementsId = new SMESH::long_array;
403 anElementsId->length( aListElementsId.count() );
404 for ( int i = 0; i < aListElementsId.count(); i++ )
405 anElementsId[i] = aListElementsId[i].toInt();
407 SMESH::DirStruct aVector;
408 if(GetConstructorId() == 0)
410 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
411 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
412 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
414 else if(GetConstructorId() == 1)
416 aVector.PS.x = SpinBox1_1->GetValue();
417 aVector.PS.y = SpinBox1_2->GetValue();
418 aVector.PS.z = SpinBox1_3->GetValue();
421 bool toCreateCopy = CheckBoxCopy->isChecked();
425 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
426 QApplication::setOverrideCursor(Qt::waitCursor);
427 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
428 QApplication::restoreOverrideCursor();
434 mySelection->ClearIObjects();
437 ConstructorsClicked( GetConstructorId() );
441 //=================================================================================
442 // function : ClickOnOk()
444 //=================================================================================
445 void SMESHGUI_TranslationDlg::ClickOnOk()
452 //=================================================================================
453 // function : ClickOnCancel()
455 //=================================================================================
456 void SMESHGUI_TranslationDlg::ClickOnCancel()
458 mySelection->ClearFilters();
459 mySelection->ClearIObjects();
460 SMESH::SetPointRepresentation(false);
461 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
462 disconnect( mySelection, 0, this, 0 );
463 mySMESHGUI->ResetState() ;
467 //=======================================================================
468 //function : onTextChange
470 //=======================================================================
472 void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText)
474 QLineEdit* send = (QLineEdit*)sender();
476 if ( myBusy ) return;
479 if (send == LineEditElements)
482 buttonOk->setEnabled( false );
483 buttonApply->setEnabled( false );
485 // hilight entered elements
486 SMDS_Mesh* aMesh = 0;
488 aMesh = myActor->GetObject()->GetMesh();
492 mySelection->ClearIObjects();
493 mySelection->AddIObject( myActor->getIO() );
495 QStringList aListId = QStringList::split( " ", theNewText, false);
497 if (send == LineEditElements) {
498 for ( int i = 0; i < aListId.count(); i++ ) {
499 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
501 if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() ))
502 mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
506 myElementsId = theNewText;
510 if ( myNbOkElements ) {
511 buttonOk->setEnabled( true );
512 buttonApply->setEnabled( true );
518 //=================================================================================
519 // function : SelectionIntoArgument()
520 // purpose : Called when selection as changed or other case
521 //=================================================================================
522 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
524 if ( myBusy ) return;
528 QString aString = "";
531 if (myEditCurrentArgument == (QWidget*)LineEditElements)
533 LineEditElements->setText( aString );
535 buttonOk->setEnabled( false );
536 buttonApply->setEnabled( false );
540 if ( !GroupButtons->isEnabled() ) // inactive
545 int nbSel = mySelection->IObjectCount();
549 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
550 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
551 myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
555 if (myEditCurrentArgument == (QWidget*)LineEditElements)
559 if (CheckBoxMesh->isChecked())
561 SMESH::GetNameOfSelectedIObjects(mySelection, aString);
562 if(!myMesh->_is_nil())
568 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
572 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ )
574 const SMDS_MeshElement * e = aSMDSMesh->FindElement( i );
576 myElementsId += QString(" %1").arg(i);
584 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
585 if(aSubMesh->_is_nil())
588 myMesh = aSubMesh->GetFather();
589 if(myMesh->_is_nil())
592 myActor = SMESH::FindActorByObject(myMesh);
596 // get IDs from submesh
597 SMESH::long_array_var anElementsIds = new SMESH::long_array;
598 anElementsIds = aSubMesh->GetElementsId();
599 for ( int i = 0; i < anElementsIds->length(); i++ )
600 myElementsId += QString(" %1").arg(anElementsIds[i]);
601 aNbUnits = anElementsIds->length();
606 if(myMesh->_is_nil())
609 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
610 if(!aSubMesh->_is_nil())
611 myMesh = aSubMesh->GetFather(); // get mesh from submesh
615 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO);
616 if ( !aGroup->_is_nil() )
617 myMesh = aGroup->GetMesh(); // get mesh from group
620 if(myMesh->_is_nil())
624 myActor = SMESH::FindActorByObject(myMesh);
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 );
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(myMeshOrSubMeshFilter) ;
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(myMeshOrSubMeshFilter);
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() );