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_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
41 #include "SMDS_Mesh.hxx"
43 #include "SUIT_Desktop.h"
44 #include "SUIT_ResourceMgr.h"
46 #include "SVTK_ViewModel.h"
47 #include "SVTK_Selection.h"
48 #include "SVTK_ViewWindow.h"
49 #include "SVTK_Selector.h"
50 #include "SALOME_ListIO.hxx"
52 #include "utilities.h"
55 #include <TColStd_MapOfInteger.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
59 #include <qapplication.h>
60 #include <qbuttongroup.h>
61 #include <qgroupbox.h>
63 #include <qlineedit.h>
64 #include <qpushbutton.h>
65 #include <qradiobutton.h>
66 #include <qcheckbox.h>
72 #include "SALOMEconfig.h"
73 #include CORBA_SERVER_HEADER(SMESH_Group)
77 //=================================================================================
78 // class : SMESHGUI_TranslationDlg()
80 //=================================================================================
81 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule, const char* name,
82 bool modal, WFlags fl)
83 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
84 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
85 mySMESHGUI( theModule ),
86 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
88 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
89 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
90 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
93 setName("SMESHGUI_TranslationDlg");
95 setCaption(tr("SMESH_TRANSLATION"));
96 setSizeGripEnabled(TRUE);
97 SMESHGUI_TranslationDlgLayout = new QGridLayout(this);
98 SMESHGUI_TranslationDlgLayout->setSpacing(6);
99 SMESHGUI_TranslationDlgLayout->setMargin(11);
101 /***************************************************************/
102 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
103 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth()));
104 GroupConstructors->setTitle(tr("SMESH_TRANSLATION" ));
105 GroupConstructors->setExclusive(TRUE);
106 GroupConstructors->setColumnLayout(0, Qt::Vertical);
107 GroupConstructors->layout()->setSpacing(0);
108 GroupConstructors->layout()->setMargin(0);
109 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
110 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
111 GroupConstructorsLayout->setSpacing(6);
112 GroupConstructorsLayout->setMargin(11);
113 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
114 RadioButton1->setText(tr("" ));
115 RadioButton1->setPixmap(image0);
116 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
117 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
118 RadioButton2->setText(tr("" ));
119 RadioButton2->setPixmap(image1);
120 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2 );
121 SMESHGUI_TranslationDlgLayout->addWidget(GroupConstructors, 0, 0);
123 /***************************************************************/
124 GroupButtons = new QGroupBox(this, "GroupButtons");
125 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth()));
126 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
127 GroupButtons->setTitle(tr("" ));
128 GroupButtons->setColumnLayout(0, Qt::Vertical);
129 GroupButtons->layout()->setSpacing(0);
130 GroupButtons->layout()->setMargin(0);
131 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
132 GroupButtonsLayout->setAlignment(Qt::AlignTop);
133 GroupButtonsLayout->setSpacing(6);
134 GroupButtonsLayout->setMargin(11);
135 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
136 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
137 buttonCancel->setAutoDefault(TRUE);
138 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
139 buttonApply = new QPushButton(GroupButtons, "buttonApply");
140 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
141 buttonApply->setAutoDefault(TRUE);
142 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
143 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
144 GroupButtonsLayout->addItem(spacer_9, 0, 2);
145 buttonOk = new QPushButton(GroupButtons, "buttonOk");
146 buttonOk->setText(tr("SMESH_BUT_OK" ));
147 buttonOk->setAutoDefault(TRUE);
148 buttonOk->setDefault(TRUE);
149 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
150 SMESHGUI_TranslationDlgLayout->addWidget(GroupButtons, 2, 0);
152 /***************************************************************/
153 GroupArguments = new QGroupBox(this, "GroupArguments");
154 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
155 GroupArguments->setColumnLayout(0, Qt::Vertical);
156 GroupArguments->layout()->setSpacing(0);
157 GroupArguments->layout()->setMargin(0);
158 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
159 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
160 GroupArgumentsLayout->setSpacing(6);
161 GroupArgumentsLayout->setMargin(11);
163 // Controls for elements selection
164 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
165 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
166 TextLabelElements->setFixedWidth(74);
167 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
169 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
170 SelectElementsButton->setText(tr("" ));
171 SelectElementsButton->setPixmap(image2);
172 SelectElementsButton->setToggleButton(FALSE);
173 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
175 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
176 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
177 GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7);
179 // Control for the whole mesh selection
180 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
181 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
182 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7);
184 // Controls for vector and points selection
185 TextLabel1 = new QLabel(GroupArguments, "TextLabel1");
186 GroupArgumentsLayout->addWidget(TextLabel1, 2, 0);
188 SelectButton1 = new QPushButton(GroupArguments, "SelectButton1");
189 SelectButton1->setText(tr("" ));
190 SelectButton1->setPixmap(image2);
191 SelectButton1->setToggleButton(FALSE);
192 GroupArgumentsLayout->addWidget(SelectButton1, 2, 1);
194 TextLabel1_1 = new QLabel(GroupArguments, "TextLabel1_1");
195 GroupArgumentsLayout->addWidget(TextLabel1_1, 2, 2);
197 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
198 GroupArgumentsLayout->addWidget(SpinBox1_1, 2, 3);
200 TextLabel1_2 = new QLabel(GroupArguments, "TextLabel1_2");
201 GroupArgumentsLayout->addWidget(TextLabel1_2, 2, 4);
203 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
204 GroupArgumentsLayout->addWidget(SpinBox1_2, 2, 5);
206 TextLabel1_3 = new QLabel(GroupArguments, "TextLabel1_3");
207 GroupArgumentsLayout->addWidget(TextLabel1_3, 2, 6);
209 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
210 GroupArgumentsLayout->addWidget(SpinBox1_3, 2, 7);
212 TextLabel2 = new QLabel(GroupArguments, "TextLabel2");
213 TextLabel2->setText(tr("SMESH_POINT_2" ));
214 GroupArgumentsLayout->addWidget(TextLabel2, 3, 0);
216 SelectButton2 = new QPushButton(GroupArguments, "SelectButton2");
217 SelectButton2->setText(tr("" ));
218 SelectButton2->setPixmap(image2);
219 SelectButton2->setToggleButton(FALSE);
220 GroupArgumentsLayout->addWidget(SelectButton2, 3, 1);
222 TextLabel2_1 = new QLabel(GroupArguments, "TextLabel2_1");
223 TextLabel2_1->setText(tr("SMESH_X" ));
224 GroupArgumentsLayout->addWidget(TextLabel2_1, 3, 2);
226 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
227 GroupArgumentsLayout->addWidget(SpinBox2_1, 3, 3);
229 TextLabel2_2 = new QLabel(GroupArguments, "TextLabel2_2");
230 TextLabel2_2->setText(tr("SMESH_Y" ));
231 GroupArgumentsLayout->addWidget(TextLabel2_2, 3, 4);
233 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
234 GroupArgumentsLayout->addWidget(SpinBox2_2, 3, 5);
236 TextLabel2_3 = new QLabel(GroupArguments, "TextLabel2_3");
237 TextLabel2_3->setText(tr("SMESH_Z"));
238 GroupArgumentsLayout->addWidget(TextLabel2_3, 3, 6);
240 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
241 GroupArgumentsLayout->addWidget(SpinBox2_3, 3, 7);
243 // Controls for "Create a copy" option
244 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
245 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
246 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
249 SMESHGUI_TranslationDlgLayout->addWidget(GroupArguments, 1, 0);
251 /* Initialisations */
252 SpinBox1_1->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
253 SpinBox1_2->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
254 SpinBox1_3->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
255 SpinBox2_1->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
256 SpinBox2_2->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
257 SpinBox2_3->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
259 GroupArguments->show();
260 RadioButton1->setChecked(TRUE);
262 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
264 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
266 // Costruction of the logical filter
267 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
268 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
270 QPtrList<SUIT_SelectionFilter> aListOfFilters;
271 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
272 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
274 myMeshOrSubMeshOrGroupFilter =
275 new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
279 /* signals and slots connections */
280 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
281 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
282 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
283 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
285 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
286 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
287 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
289 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
290 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
291 /* to close dialog if study change */
292 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
293 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
294 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
296 /* Move widget on the botton right corner of main widget */
298 mySMESHGUI->DefineDlgPosition(this, x, y);
300 this->show(); /* displays Dialog */
302 ConstructorsClicked(0);
303 SelectionIntoArgument();
307 //=================================================================================
308 // function : ~SMESHGUI_TranslationDlg()
309 // purpose : Destroys the object and frees any allocated resources
310 //=================================================================================
311 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
313 // no need to delete child widgets, Qt does it all for us
316 //=================================================================================
319 //=================================================================================
320 void SMESHGUI_TranslationDlg::Init (bool ResetControls)
324 myEditCurrentArgument = 0;
325 LineEditElements->clear();
329 buttonOk->setEnabled(false);
330 buttonApply->setEnabled(false);
333 myMesh = SMESH::SMESH_Mesh::_nil();
336 SpinBox1_1->SetValue(0.0);
337 SpinBox1_2->SetValue(0.0);
338 SpinBox1_3->SetValue(0.0);
339 SpinBox2_1->SetValue(0.0);
340 SpinBox2_2->SetValue(0.0);
341 SpinBox2_3->SetValue(0.0);
343 CheckBoxCopy->setChecked(false);
344 CheckBoxMesh->setChecked(false);
349 //=================================================================================
350 // function : ConstructorsClicked()
351 // purpose : Radio button management
352 //=================================================================================
353 void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId)
355 disconnect(mySelectionMgr, 0, this, 0);
357 switch (constructorId) {
360 TextLabel1->setText(tr("SMESH_POINT_1"));
361 TextLabel1_1->setText(tr("SMESH_X"));
362 TextLabel1_2->setText(tr("SMESH_Y"));
363 TextLabel1_3->setText(tr("SMESH_Z"));
365 SelectButton1->show();
367 SelectButton2->show();
368 TextLabel2_1->show();
370 TextLabel2_2->show();
372 TextLabel2_3->show();
378 TextLabel1->setText(tr("SMESH_VECTOR"));
379 TextLabel1_1->setText(tr("SMESH_DX"));
380 TextLabel1_2->setText(tr("SMESH_DY"));
381 TextLabel1_3->setText(tr("SMESH_DZ"));
383 SelectButton1->hide();
385 SelectButton2->hide();
386 TextLabel2_1->hide();
388 TextLabel2_2->hide();
390 TextLabel2_3->hide();
396 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
397 SMESH::SetPointRepresentation(false);
398 if (!CheckBoxMesh->isChecked())
399 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
400 aViewWindow->SetSelectionMode( CellSelection );
403 myEditCurrentArgument = (QWidget*)LineEditElements;
404 LineEditElements->setFocus();
406 if (CheckBoxMesh->isChecked())
409 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
412 //=================================================================================
413 // function : ClickOnApply()
415 //=================================================================================
416 void SMESHGUI_TranslationDlg::ClickOnApply()
418 if (mySMESHGUI->isActiveStudyLocked())
421 if (myNbOkElements) {
422 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
424 SMESH::long_array_var anElementsId = new SMESH::long_array;
426 anElementsId->length(aListElementsId.count());
427 for (int i = 0; i < aListElementsId.count(); i++)
428 anElementsId[i] = aListElementsId[i].toInt();
430 SMESH::DirStruct aVector;
431 if (GetConstructorId() == 0) {
432 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
433 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
434 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
435 } else if (GetConstructorId() == 1) {
436 aVector.PS.x = SpinBox1_1->GetValue();
437 aVector.PS.y = SpinBox1_2->GetValue();
438 aVector.PS.z = SpinBox1_3->GetValue();
441 bool toCreateCopy = CheckBoxCopy->isChecked();
444 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
445 QApplication::setOverrideCursor(Qt::waitCursor);
446 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
447 QApplication::restoreOverrideCursor();
453 ConstructorsClicked(GetConstructorId());
454 SelectionIntoArgument();
458 //=================================================================================
459 // function : ClickOnOk()
461 //=================================================================================
462 void SMESHGUI_TranslationDlg::ClickOnOk()
468 //=================================================================================
469 // function : ClickOnCancel()
471 //=================================================================================
472 void SMESHGUI_TranslationDlg::ClickOnCancel()
474 disconnect(mySelectionMgr, 0, this, 0);
475 mySelectionMgr->clearFilters();
476 mySelectionMgr->clearSelected();
477 SMESH::SetPointRepresentation(false);
478 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
479 aViewWindow->SetSelectionMode( ActorSelection );
480 mySMESHGUI->ResetState();
484 //=======================================================================
485 // function : onTextChange()
487 //=======================================================================
488 void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText)
490 QLineEdit* send = (QLineEdit*)sender();
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 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
509 TColStd_MapOfInteger newIndices;
511 QStringList aListId = QStringList::split(" ", theNewText, false);
513 if (send == LineEditElements) {
514 for (int i = 0; i < aListId.count(); i++) {
515 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
517 newIndices.Add(e->GetID());
522 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
523 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
524 aViewWindow->highlight( anIO, true, true );
526 myElementsId = theNewText;
529 if (myNbOkElements) {
530 buttonOk->setEnabled(true);
531 buttonApply->setEnabled(true);
537 //=================================================================================
538 // function : SelectionIntoArgument()
539 // purpose : Called when selection as changed or other case
540 //=================================================================================
541 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
547 QString aString = "";
550 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
551 LineEditElements->setText(aString);
553 buttonOk->setEnabled(false);
554 buttonApply->setEnabled(false);
558 if (!GroupButtons->isEnabled()) // inactive
563 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
565 int nbSel = aList.Extent();
569 Handle(SALOME_InteractiveObject) IO = aList.First();
570 myMesh = SMESH::GetMeshByIO(IO);
571 if (myMesh->_is_nil())
574 myActor = SMESH::FindActorByObject(myMesh);
576 myActor = SMESH::FindActorByEntry(IO->getEntry());
582 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
585 if (CheckBoxMesh->isChecked()) {
586 SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
588 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
590 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
594 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
595 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
597 myElementsId += QString(" %1").arg(i);
601 } 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]);
611 aNbUnits = anElementsIds->length();
614 SMESH::SMESH_GroupBase_var aGroup =
615 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
616 if (aGroup->_is_nil())
619 // get IDs from smesh group
620 SMESH::long_array_var anElementsIds = new SMESH::long_array;
621 anElementsIds = aGroup->GetListOfID();
622 for (int i = 0; i < anElementsIds->length(); i++) {
623 myElementsId += QString(" %1").arg(anElementsIds[i]);
625 aNbUnits = anElementsIds->length();
628 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
629 myElementsId = aString;
635 myNbOkElements = true;
637 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
641 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
645 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
653 if (myEditCurrentArgument == (QWidget*)SpinBox1_1) {
654 SpinBox1_1->SetValue(x);
655 SpinBox1_2->SetValue(y);
656 SpinBox2_3->SetValue(z);
657 } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) {
658 SpinBox2_1->SetValue(x);
659 SpinBox2_2->SetValue(y);
660 SpinBox2_3->SetValue(z);
665 if (myEditCurrentArgument == (QWidget*)LineEditElements)
666 LineEditElements->setText(aString);
670 if (myNbOkElements) {
671 buttonOk->setEnabled(true);
672 buttonApply->setEnabled(true);
676 //=================================================================================
677 // function : SetEditCurrentArgument()
679 //=================================================================================
680 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
682 QPushButton* send = (QPushButton*)sender();
684 disconnect(mySelectionMgr, 0, this, 0);
685 mySelectionMgr->clearSelected();
686 mySelectionMgr->clearFilters();
688 if (send == SelectElementsButton) {
689 myEditCurrentArgument = (QWidget*)LineEditElements;
690 SMESH::SetPointRepresentation(false);
691 if (CheckBoxMesh->isChecked()) {
692 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
693 aViewWindow->SetSelectionMode( ActorSelection );
694 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
697 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
698 aViewWindow->SetSelectionMode( CellSelection );
700 } else if (send == SelectButton1) {
701 myEditCurrentArgument = (QWidget*)SpinBox1_1;
702 SMESH::SetPointRepresentation(true);
704 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
705 aViewWindow->SetSelectionMode( NodeSelection );
706 } else if (send == SelectButton2) {
707 myEditCurrentArgument = (QWidget*)SpinBox2_1;
708 SMESH::SetPointRepresentation(true);
710 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
711 aViewWindow->SetSelectionMode( NodeSelection );
714 myEditCurrentArgument->setFocus();
715 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
716 SelectionIntoArgument();
719 //=================================================================================
720 // function : DeactivateActiveDialog()
722 //=================================================================================
723 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
725 if (GroupConstructors->isEnabled()) {
726 GroupConstructors->setEnabled(false);
727 GroupArguments->setEnabled(false);
728 GroupButtons->setEnabled(false);
729 mySMESHGUI->ResetState();
730 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 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
749 aViewWindow->SetSelectionMode( CellSelection );
751 SelectionIntoArgument();
754 //=================================================================================
755 // function : enterEvent()
757 //=================================================================================
758 void SMESHGUI_TranslationDlg::enterEvent (QEvent*)
760 if (!GroupConstructors->isEnabled())
761 ActivateThisDialog();
764 //=================================================================================
765 // function : closeEvent()
767 //=================================================================================
768 void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*)
770 /* same than click on cancel button */
771 this->ClickOnCancel();
774 //=======================================================================
775 //function : hideEvent
776 //purpose : caused by ESC key
777 //=======================================================================
778 void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*)
784 //=======================================================================
785 //function : onSelectMesh
787 //=======================================================================
788 void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh)
791 TextLabelElements->setText(tr("SMESH_NAME"));
793 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
795 if (myEditCurrentArgument != LineEditElements) {
796 LineEditElements->clear();
800 mySelectionMgr->clearFilters();
801 SMESH::SetPointRepresentation(false);
804 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
805 aViewWindow->SetSelectionMode( ActorSelection );
806 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
807 LineEditElements->setReadOnly(true);
809 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
810 aViewWindow->SetSelectionMode( CellSelection );
811 LineEditElements->setReadOnly(false);
812 onTextChange(LineEditElements->text());
815 SelectionIntoArgument();
818 //=================================================================================
819 // function : GetConstructorId()
821 //=================================================================================
822 int SMESHGUI_TranslationDlg::GetConstructorId()
824 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
825 return GroupConstructors->id(GroupConstructors->selected());