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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 TextLabel1_1->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
204 GroupArgumentsLayout->addWidget(TextLabel1_1, 2, 2);
206 SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
207 GroupArgumentsLayout->addWidget(SpinBox1_1, 2, 3);
209 TextLabel1_2 = new QLabel(GroupArguments, "TextLabel1_2");
210 TextLabel1_2->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
211 GroupArgumentsLayout->addWidget(TextLabel1_2, 2, 4);
213 SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
214 GroupArgumentsLayout->addWidget(SpinBox1_2, 2, 5);
216 TextLabel1_3 = new QLabel(GroupArguments, "TextLabel1_3");
217 TextLabel1_3->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
218 GroupArgumentsLayout->addWidget(TextLabel1_3, 2, 6);
220 SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
221 GroupArgumentsLayout->addWidget(SpinBox1_3, 2, 7);
223 TextLabel2 = new QLabel(GroupArguments, "TextLabel2");
224 TextLabel2->setText(tr("SMESH_POINT_2" ));
225 GroupArgumentsLayout->addWidget(TextLabel2, 3, 0);
227 SelectButton2 = new QPushButton(GroupArguments, "SelectButton2");
228 SelectButton2->setText(tr("" ));
229 SelectButton2->setPixmap(image2);
230 SelectButton2->setToggleButton(FALSE);
231 GroupArgumentsLayout->addWidget(SelectButton2, 3, 1);
233 TextLabel2_1 = new QLabel(GroupArguments, "TextLabel2_1");
234 TextLabel2_1->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
235 TextLabel2_1->setText(tr("SMESH_X" ));
236 GroupArgumentsLayout->addWidget(TextLabel2_1, 3, 2);
238 SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
239 GroupArgumentsLayout->addWidget(SpinBox2_1, 3, 3);
241 TextLabel2_2 = new QLabel(GroupArguments, "TextLabel2_2");
242 TextLabel2_2->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
243 TextLabel2_2->setText(tr("SMESH_Y" ));
244 GroupArgumentsLayout->addWidget(TextLabel2_2, 3, 4);
246 SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
247 GroupArgumentsLayout->addWidget(SpinBox2_2, 3, 5);
249 TextLabel2_3 = new QLabel(GroupArguments, "TextLabel2_3");
250 TextLabel2_3->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
251 TextLabel2_3->setText(tr("SMESH_Z"));
252 GroupArgumentsLayout->addWidget(TextLabel2_3, 3, 6);
254 SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
255 GroupArgumentsLayout->addWidget(SpinBox2_3, 3, 7);
257 // Controls for "Create a copy" option
258 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
259 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
260 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
263 SMESHGUI_TranslationDlgLayout->addWidget(GroupArguments, 1, 0);
265 /* Initialisations */
266 SpinBox1_1->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
267 SpinBox1_2->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
268 SpinBox1_3->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
269 SpinBox2_1->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
270 SpinBox2_2->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
271 SpinBox2_3->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
273 GroupArguments->show();
274 RadioButton1->setChecked(TRUE);
276 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
278 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
280 // Costruction of the logical filter
281 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
282 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
284 QPtrList<SUIT_SelectionFilter> aListOfFilters;
285 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
286 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
288 myMeshOrSubMeshOrGroupFilter =
289 new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
291 myHelpFileName = "/files/translation.htm";
295 /* signals and slots connections */
296 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
297 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
298 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
299 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
300 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
302 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
303 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
304 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
306 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
307 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
308 /* to close dialog if study change */
309 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
310 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
311 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
313 this->show(); /* displays Dialog */
315 ConstructorsClicked(0);
316 SelectionIntoArgument();
320 //=================================================================================
321 // function : ~SMESHGUI_TranslationDlg()
322 // purpose : Destroys the object and frees any allocated resources
323 //=================================================================================
324 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
326 // no need to delete child widgets, Qt does it all for us
329 //=================================================================================
332 //=================================================================================
333 void SMESHGUI_TranslationDlg::Init (bool ResetControls)
337 myEditCurrentArgument = 0;
338 LineEditElements->clear();
342 buttonOk->setEnabled(false);
343 buttonApply->setEnabled(false);
346 myMesh = SMESH::SMESH_Mesh::_nil();
349 SpinBox1_1->SetValue(0.0);
350 SpinBox1_2->SetValue(0.0);
351 SpinBox1_3->SetValue(0.0);
352 SpinBox2_1->SetValue(0.0);
353 SpinBox2_2->SetValue(0.0);
354 SpinBox2_3->SetValue(0.0);
356 CheckBoxCopy->setChecked(false);
357 CheckBoxMesh->setChecked(false);
362 //=================================================================================
363 // function : ConstructorsClicked()
364 // purpose : Radio button management
365 //=================================================================================
366 void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId)
368 disconnect(mySelectionMgr, 0, this, 0);
370 switch (constructorId) {
373 TextLabel1->setText(tr("SMESH_POINT_1"));
374 TextLabel1_1->setText(tr("SMESH_X"));
375 TextLabel1_2->setText(tr("SMESH_Y"));
376 TextLabel1_3->setText(tr("SMESH_Z"));
378 SelectButton1->show();
380 SelectButton2->show();
381 TextLabel2_1->show();
383 TextLabel2_2->show();
385 TextLabel2_3->show();
391 TextLabel1->setText(tr("SMESH_VECTOR"));
392 TextLabel1_1->setText(tr("SMESH_DX"));
393 TextLabel1_2->setText(tr("SMESH_DY"));
394 TextLabel1_3->setText(tr("SMESH_DZ"));
396 SelectButton1->hide();
398 SelectButton2->hide();
399 TextLabel2_1->hide();
401 TextLabel2_2->hide();
403 TextLabel2_3->hide();
409 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
410 SMESH::SetPointRepresentation(false);
411 if (!CheckBoxMesh->isChecked())
412 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
413 aViewWindow->SetSelectionMode( CellSelection );
416 myEditCurrentArgument = (QWidget*)LineEditElements;
417 LineEditElements->setFocus();
419 if (CheckBoxMesh->isChecked())
422 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
425 //=================================================================================
426 // function : ClickOnApply()
428 //=================================================================================
429 void SMESHGUI_TranslationDlg::ClickOnApply()
431 if (mySMESHGUI->isActiveStudyLocked())
434 if (myNbOkElements) {
435 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
437 SMESH::long_array_var anElementsId = new SMESH::long_array;
439 anElementsId->length(aListElementsId.count());
440 for (int i = 0; i < aListElementsId.count(); i++)
441 anElementsId[i] = aListElementsId[i].toInt();
443 SMESH::DirStruct aVector;
444 if (GetConstructorId() == 0) {
445 aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
446 aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
447 aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
448 } else if (GetConstructorId() == 1) {
449 aVector.PS.x = SpinBox1_1->GetValue();
450 aVector.PS.y = SpinBox1_2->GetValue();
451 aVector.PS.z = SpinBox1_3->GetValue();
454 bool toCreateCopy = CheckBoxCopy->isChecked();
457 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
458 QApplication::setOverrideCursor(Qt::waitCursor);
459 aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
460 QApplication::restoreOverrideCursor();
466 ConstructorsClicked(GetConstructorId());
467 SelectionIntoArgument();
471 //=================================================================================
472 // function : ClickOnOk()
474 //=================================================================================
475 void SMESHGUI_TranslationDlg::ClickOnOk()
481 //=================================================================================
482 // function : ClickOnCancel()
484 //=================================================================================
485 void SMESHGUI_TranslationDlg::ClickOnCancel()
487 disconnect(mySelectionMgr, 0, this, 0);
488 mySelectionMgr->clearFilters();
489 //mySelectionMgr->clearSelected();
490 SMESH::SetPointRepresentation(false);
491 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
492 aViewWindow->SetSelectionMode( ActorSelection );
493 mySMESHGUI->ResetState();
497 //=================================================================================
498 // function : ClickOnHelp()
500 //=================================================================================
501 void SMESHGUI_TranslationDlg::ClickOnHelp()
503 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
505 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
507 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
508 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
509 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
510 QObject::tr("BUT_OK"));
514 //=======================================================================
515 // function : onTextChange()
517 //=======================================================================
518 void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText)
520 QLineEdit* send = (QLineEdit*)sender();
525 if (send == LineEditElements)
528 buttonOk->setEnabled(false);
529 buttonApply->setEnabled(false);
531 // hilight entered elements
532 SMDS_Mesh* aMesh = 0;
534 aMesh = myActor->GetObject()->GetMesh();
537 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
539 TColStd_MapOfInteger newIndices;
541 QStringList aListId = QStringList::split(" ", theNewText, false);
543 if (send == LineEditElements) {
544 for (int i = 0; i < aListId.count(); i++) {
545 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
547 newIndices.Add(e->GetID());
552 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
553 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
554 aViewWindow->highlight( anIO, true, true );
556 myElementsId = theNewText;
559 if (myNbOkElements) {
560 buttonOk->setEnabled(true);
561 buttonApply->setEnabled(true);
567 //=================================================================================
568 // function : SelectionIntoArgument()
569 // purpose : Called when selection as changed or other case
570 //=================================================================================
571 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
577 QString aString = "";
580 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
581 LineEditElements->setText(aString);
583 buttonOk->setEnabled(false);
584 buttonApply->setEnabled(false);
588 if (!GroupButtons->isEnabled()) // inactive
593 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
595 int nbSel = aList.Extent();
599 Handle(SALOME_InteractiveObject) IO = aList.First();
600 myMesh = SMESH::GetMeshByIO(IO);
601 if (myMesh->_is_nil())
604 myActor = SMESH::FindActorByObject(myMesh);
606 myActor = SMESH::FindActorByEntry(IO->getEntry());
612 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
615 if (CheckBoxMesh->isChecked()) {
616 SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
618 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
620 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
624 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
625 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
627 myElementsId += QString(" %1").arg(i);
631 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
633 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
635 // get IDs from submesh
636 SMESH::long_array_var anElementsIds = new SMESH::long_array;
637 anElementsIds = aSubMesh->GetElementsId();
638 for (int i = 0; i < anElementsIds->length(); i++) {
639 myElementsId += QString(" %1").arg(anElementsIds[i]);
641 aNbUnits = anElementsIds->length();
644 SMESH::SMESH_GroupBase_var aGroup =
645 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
646 if (aGroup->_is_nil())
649 // get IDs from smesh group
650 SMESH::long_array_var anElementsIds = new SMESH::long_array;
651 anElementsIds = aGroup->GetListOfID();
652 for (int i = 0; i < anElementsIds->length(); i++) {
653 myElementsId += QString(" %1").arg(anElementsIds[i]);
655 aNbUnits = anElementsIds->length();
658 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
659 myElementsId = aString;
665 myNbOkElements = true;
667 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
671 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
675 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
683 if (myEditCurrentArgument == (QWidget*)SpinBox1_1) {
684 SpinBox1_1->SetValue(x);
685 SpinBox1_2->SetValue(y);
686 SpinBox1_3->SetValue(z);
687 } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) {
688 SpinBox2_1->SetValue(x);
689 SpinBox2_2->SetValue(y);
690 SpinBox2_3->SetValue(z);
695 if (myEditCurrentArgument == (QWidget*)LineEditElements)
696 LineEditElements->setText(aString);
700 if (myNbOkElements) {
701 buttonOk->setEnabled(true);
702 buttonApply->setEnabled(true);
706 //=================================================================================
707 // function : SetEditCurrentArgument()
709 //=================================================================================
710 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
712 QPushButton* send = (QPushButton*)sender();
714 disconnect(mySelectionMgr, 0, this, 0);
715 mySelectionMgr->clearSelected();
716 mySelectionMgr->clearFilters();
718 if (send == SelectElementsButton) {
719 myEditCurrentArgument = (QWidget*)LineEditElements;
720 SMESH::SetPointRepresentation(false);
721 if (CheckBoxMesh->isChecked()) {
722 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
723 aViewWindow->SetSelectionMode( ActorSelection );
724 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
727 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
728 aViewWindow->SetSelectionMode( CellSelection );
730 } else if (send == SelectButton1) {
731 myEditCurrentArgument = (QWidget*)SpinBox1_1;
732 SMESH::SetPointRepresentation(true);
734 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
735 aViewWindow->SetSelectionMode( NodeSelection );
736 } else if (send == SelectButton2) {
737 myEditCurrentArgument = (QWidget*)SpinBox2_1;
738 SMESH::SetPointRepresentation(true);
740 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
741 aViewWindow->SetSelectionMode( NodeSelection );
744 myEditCurrentArgument->setFocus();
745 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
746 SelectionIntoArgument();
749 //=================================================================================
750 // function : DeactivateActiveDialog()
752 //=================================================================================
753 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
755 if (GroupConstructors->isEnabled()) {
756 GroupConstructors->setEnabled(false);
757 GroupArguments->setEnabled(false);
758 GroupButtons->setEnabled(false);
759 mySMESHGUI->ResetState();
760 mySMESHGUI->SetActiveDialogBox(0);
764 //=================================================================================
765 // function : ActivateThisDialog()
767 //=================================================================================
768 void SMESHGUI_TranslationDlg::ActivateThisDialog()
770 /* Emit a signal to deactivate the active dialog */
771 mySMESHGUI->EmitSignalDeactivateDialog();
772 GroupConstructors->setEnabled(true);
773 GroupArguments->setEnabled(true);
774 GroupButtons->setEnabled(true);
776 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
778 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
779 aViewWindow->SetSelectionMode( CellSelection );
781 SelectionIntoArgument();
784 //=================================================================================
785 // function : enterEvent()
787 //=================================================================================
788 void SMESHGUI_TranslationDlg::enterEvent (QEvent*)
790 if (!GroupConstructors->isEnabled())
791 ActivateThisDialog();
794 //=================================================================================
795 // function : closeEvent()
797 //=================================================================================
798 void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*)
800 /* same than click on cancel button */
801 this->ClickOnCancel();
804 //=======================================================================
805 //function : hideEvent
806 //purpose : caused by ESC key
807 //=======================================================================
808 void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*)
814 //=======================================================================
815 //function : onSelectMesh
817 //=======================================================================
818 void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh)
821 TextLabelElements->setText(tr("SMESH_NAME"));
823 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
825 if (myEditCurrentArgument != LineEditElements) {
826 LineEditElements->clear();
830 mySelectionMgr->clearFilters();
831 SMESH::SetPointRepresentation(false);
834 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
835 aViewWindow->SetSelectionMode( ActorSelection );
836 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
837 LineEditElements->setReadOnly(true);
839 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
840 aViewWindow->SetSelectionMode( CellSelection );
841 LineEditElements->setReadOnly(false);
842 onTextChange(LineEditElements->text());
845 SelectionIntoArgument();
848 //=================================================================================
849 // function : GetConstructorId()
851 //=================================================================================
852 int SMESHGUI_TranslationDlg::GetConstructorId()
854 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
855 return GroupConstructors->id(GroupConstructors->selected());
859 //=================================================================================
860 // function : keyPressEvent()
862 //=================================================================================
863 void SMESHGUI_TranslationDlg::keyPressEvent( QKeyEvent* e )
865 QDialog::keyPressEvent( e );
866 if ( e->isAccepted() )
869 if ( e->key() == Key_F1 )