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"
45 #include "SUIT_Session.h"
46 #include "SUIT_MessageBox.h"
48 #include "LightApp_Application.h"
50 #include "SVTK_ViewModel.h"
51 #include "SVTK_Selection.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_Selector.h"
54 #include "SALOME_ListIO.hxx"
56 #include "utilities.h"
59 #include <TColStd_MapOfInteger.hxx>
60 #include <TColStd_IndexedMapOfInteger.hxx>
63 #include <qapplication.h>
64 #include <qbuttongroup.h>
65 #include <qgroupbox.h>
67 #include <qlineedit.h>
68 #include <qpushbutton.h>
69 #include <qradiobutton.h>
70 #include <qcheckbox.h>
76 #include "SALOMEconfig.h"
77 #include CORBA_SERVER_HEADER(SMESH_Group)
81 //=================================================================================
82 // class : SMESHGUI_TranslationDlg()
84 //=================================================================================
85 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule, const char* name,
86 bool modal, WFlags fl)
87 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
88 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
89 mySMESHGUI( theModule ),
90 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
92 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
93 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
94 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
97 setName("SMESHGUI_TranslationDlg");
99 setCaption(tr("SMESH_TRANSLATION"));
100 setSizeGripEnabled(TRUE);
101 SMESHGUI_TranslationDlgLayout = new QGridLayout(this);
102 SMESHGUI_TranslationDlgLayout->setSpacing(6);
103 SMESHGUI_TranslationDlgLayout->setMargin(11);
105 /***************************************************************/
106 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
107 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth()));
108 GroupConstructors->setTitle(tr("SMESH_TRANSLATION" ));
109 GroupConstructors->setExclusive(TRUE);
110 GroupConstructors->setColumnLayout(0, Qt::Vertical);
111 GroupConstructors->layout()->setSpacing(0);
112 GroupConstructors->layout()->setMargin(0);
113 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
114 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
115 GroupConstructorsLayout->setSpacing(6);
116 GroupConstructorsLayout->setMargin(11);
117 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
118 RadioButton1->setText(tr("" ));
119 RadioButton1->setPixmap(image0);
120 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
121 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
122 RadioButton2->setText(tr("" ));
123 RadioButton2->setPixmap(image1);
124 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2 );
125 SMESHGUI_TranslationDlgLayout->addWidget(GroupConstructors, 0, 0);
127 /***************************************************************/
128 GroupButtons = new QGroupBox(this, "GroupButtons");
129 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth()));
130 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
131 GroupButtons->setTitle(tr("" ));
132 GroupButtons->setColumnLayout(0, Qt::Vertical);
133 GroupButtons->layout()->setSpacing(0);
134 GroupButtons->layout()->setMargin(0);
135 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
136 GroupButtonsLayout->setAlignment(Qt::AlignTop);
137 GroupButtonsLayout->setSpacing(6);
138 GroupButtonsLayout->setMargin(11);
139 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
140 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
141 buttonHelp->setAutoDefault(TRUE);
142 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
143 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
144 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
145 buttonCancel->setAutoDefault(TRUE);
146 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
147 buttonApply = new QPushButton(GroupButtons, "buttonApply");
148 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
149 buttonApply->setAutoDefault(TRUE);
150 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
151 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
152 GroupButtonsLayout->addItem(spacer_9, 0, 2);
153 buttonOk = new QPushButton(GroupButtons, "buttonOk");
154 buttonOk->setText(tr("SMESH_BUT_OK" ));
155 buttonOk->setAutoDefault(TRUE);
156 buttonOk->setDefault(TRUE);
157 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
158 SMESHGUI_TranslationDlgLayout->addWidget(GroupButtons, 2, 0);
160 /***************************************************************/
161 GroupArguments = new QGroupBox(this, "GroupArguments");
162 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
163 GroupArguments->setColumnLayout(0, Qt::Vertical);
164 GroupArguments->layout()->setSpacing(0);
165 GroupArguments->layout()->setMargin(0);
166 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
167 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
168 GroupArgumentsLayout->setSpacing(6);
169 GroupArgumentsLayout->setMargin(11);
171 // Controls for elements selection
172 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
173 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
174 TextLabelElements->setFixedWidth(74);
175 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
177 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
178 SelectElementsButton->setText(tr("" ));
179 SelectElementsButton->setPixmap(image2);
180 SelectElementsButton->setToggleButton(FALSE);
181 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
183 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
184 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
185 GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7);
187 // Control for the whole mesh selection
188 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
189 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
190 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7);
192 // Controls for vector and points selection
193 TextLabel1 = new QLabel(GroupArguments, "TextLabel1");
194 GroupArgumentsLayout->addWidget(TextLabel1, 2, 0);
196 SelectButton1 = new QPushButton(GroupArguments, "SelectButton1");
197 SelectButton1->setText(tr("" ));
198 SelectButton1->setPixmap(image2);
199 SelectButton1->setToggleButton(FALSE);
200 GroupArgumentsLayout->addWidget(SelectButton1, 2, 1);
202 TextLabel1_1 = new QLabel(GroupArguments, "TextLabel1_1");
203 GroupArgumentsLayout->addWidget(TextLabel1_1, 2, 2);
205 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
206 GroupArgumentsLayout->addWidget(SpinBox1_1, 2, 3);
208 TextLabel1_2 = new QLabel(GroupArguments, "TextLabel1_2");
209 GroupArgumentsLayout->addWidget(TextLabel1_2, 2, 4);
211 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
212 GroupArgumentsLayout->addWidget(SpinBox1_2, 2, 5);
214 TextLabel1_3 = new QLabel(GroupArguments, "TextLabel1_3");
215 GroupArgumentsLayout->addWidget(TextLabel1_3, 2, 6);
217 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
218 GroupArgumentsLayout->addWidget(SpinBox1_3, 2, 7);
220 TextLabel2 = new QLabel(GroupArguments, "TextLabel2");
221 TextLabel2->setText(tr("SMESH_POINT_2" ));
222 GroupArgumentsLayout->addWidget(TextLabel2, 3, 0);
224 SelectButton2 = new QPushButton(GroupArguments, "SelectButton2");
225 SelectButton2->setText(tr("" ));
226 SelectButton2->setPixmap(image2);
227 SelectButton2->setToggleButton(FALSE);
228 GroupArgumentsLayout->addWidget(SelectButton2, 3, 1);
230 TextLabel2_1 = new QLabel(GroupArguments, "TextLabel2_1");
231 TextLabel2_1->setText(tr("SMESH_X" ));
232 GroupArgumentsLayout->addWidget(TextLabel2_1, 3, 2);
234 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
235 GroupArgumentsLayout->addWidget(SpinBox2_1, 3, 3);
237 TextLabel2_2 = new QLabel(GroupArguments, "TextLabel2_2");
238 TextLabel2_2->setText(tr("SMESH_Y" ));
239 GroupArgumentsLayout->addWidget(TextLabel2_2, 3, 4);
241 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
242 GroupArgumentsLayout->addWidget(SpinBox2_2, 3, 5);
244 TextLabel2_3 = new QLabel(GroupArguments, "TextLabel2_3");
245 TextLabel2_3->setText(tr("SMESH_Z"));
246 GroupArgumentsLayout->addWidget(TextLabel2_3, 3, 6);
248 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
249 GroupArgumentsLayout->addWidget(SpinBox2_3, 3, 7);
251 // Controls for "Create a copy" option
252 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
253 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
254 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
257 SMESHGUI_TranslationDlgLayout->addWidget(GroupArguments, 1, 0);
259 /* Initialisations */
260 SpinBox1_1->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
261 SpinBox1_2->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
262 SpinBox1_3->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
263 SpinBox2_1->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
264 SpinBox2_2->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
265 SpinBox2_3->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
267 GroupArguments->show();
268 RadioButton1->setChecked(TRUE);
270 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
272 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
274 // Costruction of the logical filter
275 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
276 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
278 QPtrList<SUIT_SelectionFilter> aListOfFilters;
279 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
280 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
282 myMeshOrSubMeshOrGroupFilter =
283 new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
285 myHelpFileName = "/files/translation.htm";
289 /* signals and slots connections */
290 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
291 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
292 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
293 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
294 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
296 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
297 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
298 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
300 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
301 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
302 /* to close dialog if study change */
303 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
304 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
305 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
307 this->show(); /* displays Dialog */
309 ConstructorsClicked(0);
310 SelectionIntoArgument();
314 //=================================================================================
315 // function : ~SMESHGUI_TranslationDlg()
316 // purpose : Destroys the object and frees any allocated resources
317 //=================================================================================
318 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
320 // no need to delete child widgets, Qt does it all for us
323 //=================================================================================
326 //=================================================================================
327 void SMESHGUI_TranslationDlg::Init (bool ResetControls)
331 myEditCurrentArgument = 0;
332 LineEditElements->clear();
336 buttonOk->setEnabled(false);
337 buttonApply->setEnabled(false);
340 myMesh = SMESH::SMESH_Mesh::_nil();
343 SpinBox1_1->SetValue(0.0);
344 SpinBox1_2->SetValue(0.0);
345 SpinBox1_3->SetValue(0.0);
346 SpinBox2_1->SetValue(0.0);
347 SpinBox2_2->SetValue(0.0);
348 SpinBox2_3->SetValue(0.0);
350 CheckBoxCopy->setChecked(false);
351 CheckBoxMesh->setChecked(false);
356 //=================================================================================
357 // function : ConstructorsClicked()
358 // purpose : Radio button management
359 //=================================================================================
360 void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId)
362 disconnect(mySelectionMgr, 0, this, 0);
364 switch (constructorId) {
367 TextLabel1->setText(tr("SMESH_POINT_1"));
368 TextLabel1_1->setText(tr("SMESH_X"));
369 TextLabel1_2->setText(tr("SMESH_Y"));
370 TextLabel1_3->setText(tr("SMESH_Z"));
372 SelectButton1->show();
374 SelectButton2->show();
375 TextLabel2_1->show();
377 TextLabel2_2->show();
379 TextLabel2_3->show();
385 TextLabel1->setText(tr("SMESH_VECTOR"));
386 TextLabel1_1->setText(tr("SMESH_DX"));
387 TextLabel1_2->setText(tr("SMESH_DY"));
388 TextLabel1_3->setText(tr("SMESH_DZ"));
390 SelectButton1->hide();
392 SelectButton2->hide();
393 TextLabel2_1->hide();
395 TextLabel2_2->hide();
397 TextLabel2_3->hide();
403 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
404 SMESH::SetPointRepresentation(false);
405 if (!CheckBoxMesh->isChecked())
406 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
407 aViewWindow->SetSelectionMode( CellSelection );
410 myEditCurrentArgument = (QWidget*)LineEditElements;
411 LineEditElements->setFocus();
413 if (CheckBoxMesh->isChecked())
416 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
419 //=================================================================================
420 // function : ClickOnApply()
422 //=================================================================================
423 void SMESHGUI_TranslationDlg::ClickOnApply()
425 if (mySMESHGUI->isActiveStudyLocked())
428 if (myNbOkElements) {
429 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
431 SMESH::long_array_var anElementsId = new SMESH::long_array;
433 anElementsId->length(aListElementsId.count());
434 for (int i = 0; i < aListElementsId.count(); i++)
435 anElementsId[i] = aListElementsId[i].toInt();
437 SMESH::DirStruct aVector;
438 if (GetConstructorId() == 0) {
439 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
440 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
441 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
442 } else if (GetConstructorId() == 1) {
443 aVector.PS.x = SpinBox1_1->GetValue();
444 aVector.PS.y = SpinBox1_2->GetValue();
445 aVector.PS.z = SpinBox1_3->GetValue();
448 bool toCreateCopy = CheckBoxCopy->isChecked();
451 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
452 QApplication::setOverrideCursor(Qt::waitCursor);
453 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
454 QApplication::restoreOverrideCursor();
460 ConstructorsClicked(GetConstructorId());
461 SelectionIntoArgument();
465 //=================================================================================
466 // function : ClickOnOk()
468 //=================================================================================
469 void SMESHGUI_TranslationDlg::ClickOnOk()
475 //=================================================================================
476 // function : ClickOnCancel()
478 //=================================================================================
479 void SMESHGUI_TranslationDlg::ClickOnCancel()
481 disconnect(mySelectionMgr, 0, this, 0);
482 mySelectionMgr->clearFilters();
483 //mySelectionMgr->clearSelected();
484 SMESH::SetPointRepresentation(false);
485 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
486 aViewWindow->SetSelectionMode( ActorSelection );
487 mySMESHGUI->ResetState();
491 //=================================================================================
492 // function : ClickOnHelp()
494 //=================================================================================
495 void SMESHGUI_TranslationDlg::ClickOnHelp()
497 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
499 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
501 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
502 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
503 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
504 QObject::tr("BUT_OK"));
508 //=======================================================================
509 // function : onTextChange()
511 //=======================================================================
512 void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText)
514 QLineEdit* send = (QLineEdit*)sender();
519 if (send == LineEditElements)
522 buttonOk->setEnabled(false);
523 buttonApply->setEnabled(false);
525 // hilight entered elements
526 SMDS_Mesh* aMesh = 0;
528 aMesh = myActor->GetObject()->GetMesh();
531 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
533 TColStd_MapOfInteger newIndices;
535 QStringList aListId = QStringList::split(" ", theNewText, false);
537 if (send == LineEditElements) {
538 for (int i = 0; i < aListId.count(); i++) {
539 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
541 newIndices.Add(e->GetID());
546 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
547 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
548 aViewWindow->highlight( anIO, true, true );
550 myElementsId = theNewText;
553 if (myNbOkElements) {
554 buttonOk->setEnabled(true);
555 buttonApply->setEnabled(true);
561 //=================================================================================
562 // function : SelectionIntoArgument()
563 // purpose : Called when selection as changed or other case
564 //=================================================================================
565 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
571 QString aString = "";
574 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
575 LineEditElements->setText(aString);
577 buttonOk->setEnabled(false);
578 buttonApply->setEnabled(false);
582 if (!GroupButtons->isEnabled()) // inactive
587 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
589 int nbSel = aList.Extent();
593 Handle(SALOME_InteractiveObject) IO = aList.First();
594 myMesh = SMESH::GetMeshByIO(IO);
595 if (myMesh->_is_nil())
598 myActor = SMESH::FindActorByObject(myMesh);
600 myActor = SMESH::FindActorByEntry(IO->getEntry());
606 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
609 if (CheckBoxMesh->isChecked()) {
610 SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
612 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
614 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
618 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
619 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
621 myElementsId += QString(" %1").arg(i);
625 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
627 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
629 // get IDs from submesh
630 SMESH::long_array_var anElementsIds = new SMESH::long_array;
631 anElementsIds = aSubMesh->GetElementsId();
632 for (int i = 0; i < anElementsIds->length(); i++) {
633 myElementsId += QString(" %1").arg(anElementsIds[i]);
635 aNbUnits = anElementsIds->length();
638 SMESH::SMESH_GroupBase_var aGroup =
639 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
640 if (aGroup->_is_nil())
643 // get IDs from smesh group
644 SMESH::long_array_var anElementsIds = new SMESH::long_array;
645 anElementsIds = aGroup->GetListOfID();
646 for (int i = 0; i < anElementsIds->length(); i++) {
647 myElementsId += QString(" %1").arg(anElementsIds[i]);
649 aNbUnits = anElementsIds->length();
652 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
653 myElementsId = aString;
659 myNbOkElements = true;
661 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
665 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
669 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
677 if (myEditCurrentArgument == (QWidget*)SpinBox1_1) {
678 SpinBox1_1->SetValue(x);
679 SpinBox1_2->SetValue(y);
680 SpinBox1_3->SetValue(z);
681 } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) {
682 SpinBox2_1->SetValue(x);
683 SpinBox2_2->SetValue(y);
684 SpinBox2_3->SetValue(z);
689 if (myEditCurrentArgument == (QWidget*)LineEditElements)
690 LineEditElements->setText(aString);
694 if (myNbOkElements) {
695 buttonOk->setEnabled(true);
696 buttonApply->setEnabled(true);
700 //=================================================================================
701 // function : SetEditCurrentArgument()
703 //=================================================================================
704 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
706 QPushButton* send = (QPushButton*)sender();
708 disconnect(mySelectionMgr, 0, this, 0);
709 mySelectionMgr->clearSelected();
710 mySelectionMgr->clearFilters();
712 if (send == SelectElementsButton) {
713 myEditCurrentArgument = (QWidget*)LineEditElements;
714 SMESH::SetPointRepresentation(false);
715 if (CheckBoxMesh->isChecked()) {
716 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
717 aViewWindow->SetSelectionMode( ActorSelection );
718 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
721 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
722 aViewWindow->SetSelectionMode( CellSelection );
724 } else if (send == SelectButton1) {
725 myEditCurrentArgument = (QWidget*)SpinBox1_1;
726 SMESH::SetPointRepresentation(true);
728 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
729 aViewWindow->SetSelectionMode( NodeSelection );
730 } else if (send == SelectButton2) {
731 myEditCurrentArgument = (QWidget*)SpinBox2_1;
732 SMESH::SetPointRepresentation(true);
734 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
735 aViewWindow->SetSelectionMode( NodeSelection );
738 myEditCurrentArgument->setFocus();
739 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
740 SelectionIntoArgument();
743 //=================================================================================
744 // function : DeactivateActiveDialog()
746 //=================================================================================
747 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
749 if (GroupConstructors->isEnabled()) {
750 GroupConstructors->setEnabled(false);
751 GroupArguments->setEnabled(false);
752 GroupButtons->setEnabled(false);
753 mySMESHGUI->ResetState();
754 mySMESHGUI->SetActiveDialogBox(0);
758 //=================================================================================
759 // function : ActivateThisDialog()
761 //=================================================================================
762 void SMESHGUI_TranslationDlg::ActivateThisDialog()
764 /* Emit a signal to deactivate the active dialog */
765 mySMESHGUI->EmitSignalDeactivateDialog();
766 GroupConstructors->setEnabled(true);
767 GroupArguments->setEnabled(true);
768 GroupButtons->setEnabled(true);
770 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
772 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
773 aViewWindow->SetSelectionMode( CellSelection );
775 SelectionIntoArgument();
778 //=================================================================================
779 // function : enterEvent()
781 //=================================================================================
782 void SMESHGUI_TranslationDlg::enterEvent (QEvent*)
784 if (!GroupConstructors->isEnabled())
785 ActivateThisDialog();
788 //=================================================================================
789 // function : closeEvent()
791 //=================================================================================
792 void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*)
794 /* same than click on cancel button */
795 this->ClickOnCancel();
798 //=======================================================================
799 //function : hideEvent
800 //purpose : caused by ESC key
801 //=======================================================================
802 void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*)
808 //=======================================================================
809 //function : onSelectMesh
811 //=======================================================================
812 void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh)
815 TextLabelElements->setText(tr("SMESH_NAME"));
817 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
819 if (myEditCurrentArgument != LineEditElements) {
820 LineEditElements->clear();
824 mySelectionMgr->clearFilters();
825 SMESH::SetPointRepresentation(false);
828 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
829 aViewWindow->SetSelectionMode( ActorSelection );
830 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
831 LineEditElements->setReadOnly(true);
833 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
834 aViewWindow->SetSelectionMode( CellSelection );
835 LineEditElements->setReadOnly(false);
836 onTextChange(LineEditElements->text());
839 SelectionIntoArgument();
842 //=================================================================================
843 // function : GetConstructorId()
845 //=================================================================================
846 int SMESHGUI_TranslationDlg::GetConstructorId()
848 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
849 return GroupConstructors->id(GroupConstructors->selected());