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_SymmetryDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_SymmetryDlg.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_ViewWindow.h"
52 #include "SVTK_Selector.h"
53 #include "SVTK_Selection.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>
75 #include "SALOMEconfig.h"
76 #include CORBA_SERVER_HEADER(SMESH_Group)
80 //=================================================================================
81 // class : SMESHGUI_SymmetryDlg()
83 //=================================================================================
84 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule, const char* name,
85 bool modal, WFlags fl)
86 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
87 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
88 mySMESHGUI( theModule ),
89 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
91 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
92 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
93 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
94 QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
97 setName("SMESHGUI_SymmetryDlg");
99 setCaption(tr("SMESH_SYMMETRY"));
100 setSizeGripEnabled(TRUE);
101 SMESHGUI_SymmetryDlgLayout = new QGridLayout(this);
102 SMESHGUI_SymmetryDlgLayout->setSpacing(6);
103 SMESHGUI_SymmetryDlgLayout->setMargin(11);
105 /***************************************************************/
106 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
107 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
108 (QSizePolicy::SizeType)0, 0, 0,
109 GroupConstructors->sizePolicy().hasHeightForWidth()));
110 GroupConstructors->setTitle(tr("SMESH_SYMMETRY" ));
111 GroupConstructors->setExclusive(TRUE);
112 GroupConstructors->setColumnLayout(0, Qt::Vertical);
113 GroupConstructors->layout()->setSpacing(0);
114 GroupConstructors->layout()->setMargin(0);
115 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
116 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
117 GroupConstructorsLayout->setSpacing(6);
118 GroupConstructorsLayout->setMargin(11);
119 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
120 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
121 RadioButton1->setText(tr("" ));
122 RadioButton1->setPixmap(image0);
123 RBLayout->addWidget(RadioButton1);
124 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
125 RadioButton2->setText(tr("" ));
126 RadioButton2->setPixmap(image1);
127 RBLayout->addWidget(RadioButton2);
128 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
129 RadioButton3->setText(tr("" ));
130 RadioButton3->setPixmap(image2);
131 RBLayout->addWidget(RadioButton3);
132 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
133 SMESHGUI_SymmetryDlgLayout->addWidget(GroupConstructors, 0, 0);
135 /***************************************************************/
136 GroupButtons = new QGroupBox(this, "GroupButtons");
137 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
138 (QSizePolicy::SizeType)0, 0, 0,
139 GroupButtons->sizePolicy().hasHeightForWidth()));
140 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
141 GroupButtons->setTitle(tr("" ));
142 GroupButtons->setColumnLayout(0, Qt::Vertical);
143 GroupButtons->layout()->setSpacing(0);
144 GroupButtons->layout()->setMargin(0);
145 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
146 GroupButtonsLayout->setAlignment(Qt::AlignTop);
147 GroupButtonsLayout->setSpacing(6);
148 GroupButtonsLayout->setMargin(11);
149 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
150 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
151 buttonHelp->setAutoDefault(TRUE);
152 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
153 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
154 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
155 buttonCancel->setAutoDefault(TRUE);
156 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
157 buttonApply = new QPushButton(GroupButtons, "buttonApply");
158 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
159 buttonApply->setAutoDefault(TRUE);
160 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
161 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
162 GroupButtonsLayout->addItem(spacer_9, 0, 2);
163 buttonOk = new QPushButton(GroupButtons, "buttonOk");
164 buttonOk->setText(tr("SMESH_BUT_OK" ));
165 buttonOk->setAutoDefault(TRUE);
166 buttonOk->setDefault(TRUE);
167 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
168 SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons, 2, 0);
170 /***************************************************************/
171 GroupArguments = new QGroupBox(this, "GroupArguments");
172 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
173 GroupArguments->setColumnLayout(0, Qt::Vertical);
174 GroupArguments->layout()->setSpacing(0);
175 GroupArguments->layout()->setMargin(0);
176 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
177 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
178 GroupArgumentsLayout->setSpacing(6);
179 GroupArgumentsLayout->setMargin(11);
181 // Controls for elements selection
182 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
183 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
184 TextLabelElements->setFixedWidth(74);
185 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
187 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
188 SelectElementsButton->setText(tr("" ));
189 SelectElementsButton->setPixmap(image3);
190 SelectElementsButton->setToggleButton(FALSE);
191 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
193 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
194 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
195 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
197 // Control for the whole mesh selection
198 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
199 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
200 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
202 // Controls for mirror selection
203 GroupMirror = new QGroupBox(GroupArguments, "GroupMirror");
204 GroupMirror->setColumnLayout(0, Qt::Vertical);
205 GroupMirror->layout()->setSpacing(0);
206 GroupMirror->layout()->setMargin(0);
207 QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror->layout());
208 GroupMirrorLayout->setAlignment(Qt::AlignTop);
209 GroupMirrorLayout->setSpacing(6);
210 GroupMirrorLayout->setMargin(11);
212 TextLabelPoint = new QLabel(GroupMirror, "TextLabelPoint");
213 TextLabelPoint->setText(tr("SMESH_POINT"));
214 GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0);
216 SelectPointButton = new QPushButton(GroupMirror, "SelectPointButton");
217 SelectPointButton->setPixmap(image3);
218 GroupMirrorLayout->addWidget(SelectPointButton, 0, 1);
220 TextLabelX = new QLabel(GroupMirror, "TextLabelX");
221 TextLabelX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
222 TextLabelX->setText(tr("SMESH_X"));
223 GroupMirrorLayout->addWidget(TextLabelX, 0, 2);
225 SpinBox_X = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_X");
226 GroupMirrorLayout->addWidget(SpinBox_X, 0, 3);
228 TextLabelY = new QLabel(GroupMirror, "TextLabelY");
229 TextLabelY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
230 TextLabelY->setText(tr("SMESH_Y"));
231 GroupMirrorLayout->addWidget(TextLabelY, 0, 4);
233 SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Y");
234 GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5);
236 TextLabelZ = new QLabel(GroupMirror, "TextLabelZ");
237 TextLabelZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
238 TextLabelZ->setText(tr("SMESH_Z"));
239 GroupMirrorLayout->addWidget(TextLabelZ, 0, 6);
241 SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Z");
242 GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7);
244 TextLabelVector = new QLabel(GroupMirror, "TextLabelVector");
245 GroupMirrorLayout->addWidget(TextLabelVector, 1, 0);
247 SelectVectorButton = new QPushButton(GroupMirror, "SelectVectorButton");
248 SelectVectorButton->setPixmap(image3);
249 GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
251 TextLabelDX = new QLabel(GroupMirror, "TextLabelDX");
252 TextLabelDX->setText(tr("SMESH_DX"));
253 GroupMirrorLayout->addWidget(TextLabelDX, 1, 2);
255 SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DX");
256 GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3);
258 TextLabelDY = new QLabel(GroupMirror, "TextLabelDY");
259 TextLabelDY->setText(tr("SMESH_DY"));
260 GroupMirrorLayout->addWidget(TextLabelDY, 1, 4);
262 SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DY");
263 GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5);
265 TextLabelDZ = new QLabel(GroupMirror, "TextLabelDZ");
266 TextLabelDZ->setText(tr("SMESH_DZ"));
267 GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6);
269 SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DZ");
270 GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7);
272 GroupArgumentsLayout->addMultiCellWidget(GroupMirror, 2, 2, 0, 2);
274 // Controls for "Create a copy" option
275 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
276 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
277 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 3, 3, 0, 2);
280 SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments, 1, 0);
282 /* Initialisations */
283 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
284 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
286 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
287 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
288 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
290 GroupArguments->show();
291 RadioButton1->setChecked(TRUE);
293 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
295 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
297 // Costruction of the logical filter
298 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
299 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
301 QPtrList<SUIT_SelectionFilter> aListOfFilters;
302 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
303 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
305 myMeshOrSubMeshOrGroupFilter =
306 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
308 myHelpFileName = "/files/symmetry.htm";
312 /* signals and slots connections */
313 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
314 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
315 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
316 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
317 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
319 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
320 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
321 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
323 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
324 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
325 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
327 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
328 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
329 /* to close dialog if study change */
330 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
331 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
332 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
334 this->show(); /* displays Dialog */
336 ConstructorsClicked(0);
337 SelectionIntoArgument();
341 //=================================================================================
342 // function : ~SMESHGUI_SymmetryDlg()
343 // purpose : Destroys the object and frees any allocated resources
344 //=================================================================================
345 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
347 // no need to delete child widgets, Qt does it all for us
350 //=================================================================================
353 //=================================================================================
354 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
358 myEditCurrentArgument = 0;
359 LineEditElements->clear();
363 buttonOk->setEnabled(false);
364 buttonApply->setEnabled(false);
367 myMesh = SMESH::SMESH_Mesh::_nil();
370 SpinBox_X->SetValue(0.0);
371 SpinBox_Y->SetValue(0.0);
372 SpinBox_Z->SetValue(0.0);
373 SpinBox_DX->SetValue(0.0);
374 SpinBox_DY->SetValue(0.0);
375 SpinBox_DZ->SetValue(0.0);
377 CheckBoxCopy->setChecked(false);
378 CheckBoxMesh->setChecked(false);
383 //=================================================================================
384 // function : ConstructorsClicked()
385 // purpose : Radio button management
386 //=================================================================================
387 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
389 disconnect(mySelectionMgr, 0, this, 0);
391 if (constructorId != 0 && !TextLabelVector->isVisible()) {
392 TextLabelVector->show();
393 SelectVectorButton->show();
402 switch (constructorId) {
405 GroupMirror->setTitle(tr("SMESH_POINT"));
407 TextLabelVector->hide();
408 SelectVectorButton->hide();
419 GroupMirror->setTitle(tr("SMESH_AXIS"));
420 TextLabelVector->setText(tr("SMESH_VECTOR"));
425 GroupMirror->setTitle(tr("SMESH_PLANE"));
426 TextLabelVector->setText(tr("SMESH_NORMAL"));
431 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
432 SMESH::SetPointRepresentation(false);
433 if (!CheckBoxMesh->isChecked())
435 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
436 aViewWindow->SetSelectionMode(CellSelection);
440 myEditCurrentArgument = (QWidget*)LineEditElements;
441 LineEditElements->setFocus();
443 if (CheckBoxMesh->isChecked())
446 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
449 //=================================================================================
450 // function : ClickOnApply()
452 //=================================================================================
453 void SMESHGUI_SymmetryDlg::ClickOnApply()
455 if (mySMESHGUI->isActiveStudyLocked())
458 if (myNbOkElements && IsMirrorOk()) {
459 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
461 SMESH::long_array_var anElementsId = new SMESH::long_array;
463 anElementsId->length(aListElementsId.count());
464 for (int i = 0; i < aListElementsId.count(); i++)
465 anElementsId[i] = aListElementsId[i].toInt();
467 SMESH::AxisStruct aMirror;
469 aMirror.x = SpinBox_X->GetValue();
470 aMirror.y = SpinBox_Y->GetValue();
471 aMirror.z = SpinBox_Z->GetValue();
472 if (GetConstructorId() == 0) {
473 aMirror.vx = aMirror.vy = aMirror.vz = 0;
475 aMirror.vx = SpinBox_DX->GetValue();
476 aMirror.vy = SpinBox_DY->GetValue();
477 aMirror.vz = SpinBox_DZ->GetValue();
480 bool toCreateCopy = CheckBoxCopy->isChecked();
482 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
484 if (GetConstructorId() == 0)
485 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
486 if (GetConstructorId() == 1)
487 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
488 if (GetConstructorId() == 2)
489 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
492 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
493 QApplication::setOverrideCursor(Qt::waitCursor);
494 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
495 QApplication::restoreOverrideCursor();
501 ConstructorsClicked(GetConstructorId());
502 SelectionIntoArgument();
506 //=================================================================================
507 // function : ClickOnOk()
509 //=================================================================================
510 void SMESHGUI_SymmetryDlg::ClickOnOk()
516 //=================================================================================
517 // function : ClickOnCancel()
519 //=================================================================================
520 void SMESHGUI_SymmetryDlg::ClickOnCancel()
522 disconnect(mySelectionMgr, 0, this, 0);
523 mySelectionMgr->clearFilters();
524 //mySelectionMgr->clearSelected();
525 SMESH::SetPointRepresentation(false);
526 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
527 aViewWindow->SetSelectionMode(ActorSelection);
528 mySMESHGUI->ResetState();
532 //=================================================================================
533 // function : ClickOnHelp()
535 //=================================================================================
536 void SMESHGUI_SymmetryDlg::ClickOnHelp()
538 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
540 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
542 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
543 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
544 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
545 QObject::tr("BUT_OK"));
549 //=======================================================================
550 // function : onTextChange()
552 //=======================================================================
553 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
555 QLineEdit* send = (QLineEdit*)sender();
560 if (send == LineEditElements)
563 buttonOk->setEnabled(false);
564 buttonApply->setEnabled(false);
566 // hilight entered elements
567 SMDS_Mesh* aMesh = 0;
569 aMesh = myActor->GetObject()->GetMesh();
572 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
574 TColStd_MapOfInteger newIndices;
576 QStringList aListId = QStringList::split(" ", theNewText, false);
578 if (send == LineEditElements) {
579 for (int i = 0; i < aListId.count(); i++) {
580 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
582 newIndices.Add(e->GetID());
586 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
587 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
588 aViewWindow->highlight( anIO, true, true );
590 myElementsId = theNewText;
594 if (myNbOkElements && IsMirrorOk()) {
595 buttonOk->setEnabled(true);
596 buttonApply->setEnabled(true);
602 //=================================================================================
603 // function : SelectionIntoArgument()
604 // purpose : Called when selection as changed or other case
605 //=================================================================================
606 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
612 QString aString = "";
615 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
616 LineEditElements->setText(aString);
618 buttonOk->setEnabled(false);
619 buttonApply->setEnabled(false);
623 if (!GroupButtons->isEnabled()) // inactive
628 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
630 int nbSel = aList.Extent();
634 Handle(SALOME_InteractiveObject) IO = aList.First();
635 myMesh = SMESH::GetMeshByIO(IO);
636 if(myMesh->_is_nil())
639 myActor = SMESH::FindActorByObject(myMesh);
641 myActor = SMESH::FindActorByEntry(IO->getEntry());
647 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
650 if (CheckBoxMesh->isChecked()) {
651 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
653 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
655 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
659 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
660 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
662 myElementsId += QString(" %1").arg(i);
666 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
668 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
670 // get IDs from submesh
671 SMESH::long_array_var anElementsIds = new SMESH::long_array;
672 anElementsIds = aSubMesh->GetElementsId();
673 for (int i = 0; i < anElementsIds->length(); i++) {
674 myElementsId += QString(" %1").arg(anElementsIds[i]);
676 aNbUnits = anElementsIds->length();
679 SMESH::SMESH_GroupBase_var aGroup =
680 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
681 if (aGroup->_is_nil())
684 // get IDs from smesh group
685 SMESH::long_array_var anElementsIds = new SMESH::long_array;
686 anElementsIds = aGroup->GetListOfID();
687 for (int i = 0; i < anElementsIds->length(); i++) {
688 myElementsId += QString(" %1").arg(anElementsIds[i]);
690 aNbUnits = anElementsIds->length();
693 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString);
694 myElementsId = aString;
700 myNbOkElements = true;
702 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
706 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
710 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
718 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
719 SpinBox_X->SetValue(x);
720 SpinBox_Y->SetValue(y);
721 SpinBox_Z->SetValue(z);
722 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
723 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
724 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
725 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
730 if (myEditCurrentArgument == (QWidget*)LineEditElements)
731 LineEditElements->setText(aString);
735 if (myNbOkElements && IsMirrorOk()) {
736 buttonOk->setEnabled(true);
737 buttonApply->setEnabled(true);
741 //=================================================================================
742 // function : SetEditCurrentArgument()
744 //=================================================================================
745 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
747 QPushButton* send = (QPushButton*)sender();
749 disconnect(mySelectionMgr, 0, this, 0);
750 mySelectionMgr->clearSelected();
751 mySelectionMgr->clearFilters();
753 if (send == SelectElementsButton) {
754 myEditCurrentArgument = (QWidget*)LineEditElements;
755 SMESH::SetPointRepresentation(false);
756 if (CheckBoxMesh->isChecked()) {
757 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
758 aViewWindow->SetSelectionMode(ActorSelection);
759 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
761 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
762 aViewWindow->SetSelectionMode(CellSelection);
764 } else if (send == SelectPointButton) {
765 myEditCurrentArgument = (QWidget*)SpinBox_X;
766 SMESH::SetPointRepresentation(true);
767 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
768 aViewWindow->SetSelectionMode(NodeSelection);
769 } else if (send == SelectVectorButton) {
770 myEditCurrentArgument = (QWidget*)SpinBox_DX;
771 SMESH::SetPointRepresentation(true);
773 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
774 aViewWindow->SetSelectionMode(NodeSelection);
778 myEditCurrentArgument->setFocus();
779 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
780 SelectionIntoArgument();
783 //=================================================================================
784 // function : DeactivateActiveDialog()
786 //=================================================================================
787 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
789 if (GroupConstructors->isEnabled()) {
790 GroupConstructors->setEnabled(false);
791 GroupArguments->setEnabled(false);
792 GroupButtons->setEnabled(false);
793 mySMESHGUI->ResetState();
794 mySMESHGUI->SetActiveDialogBox(0);
798 //=================================================================================
799 // function : ActivateThisDialog()
801 //=================================================================================
802 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
804 /* Emit a signal to deactivate the active dialog */
805 mySMESHGUI->EmitSignalDeactivateDialog();
806 GroupConstructors->setEnabled(true);
807 GroupArguments->setEnabled(true);
808 GroupButtons->setEnabled(true);
810 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
812 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
813 aViewWindow->SetSelectionMode(CellSelection);
814 SelectionIntoArgument();
817 //=================================================================================
818 // function : enterEvent()
820 //=================================================================================
821 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
823 if (!GroupConstructors->isEnabled())
824 ActivateThisDialog();
827 //=================================================================================
828 // function : closeEvent()
830 //=================================================================================
831 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
833 /* same than click on cancel button */
834 this->ClickOnCancel();
837 //=======================================================================
838 // function : hideEvent()
839 // purpose : caused by ESC key
840 //=======================================================================
841 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
847 //=======================================================================
848 //function : onSelectMesh
850 //=======================================================================
851 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
854 TextLabelElements->setText(tr("SMESH_NAME"));
856 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
858 if (myEditCurrentArgument != LineEditElements) {
859 LineEditElements->clear();
863 mySelectionMgr->clearFilters();
864 SMESH::SetPointRepresentation(false);
867 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
868 aViewWindow->SetSelectionMode(ActorSelection);
869 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
870 LineEditElements->setReadOnly(true);
872 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
873 aViewWindow->SetSelectionMode(CellSelection);
874 LineEditElements->setReadOnly(false);
875 onTextChange(LineEditElements->text());
878 SelectionIntoArgument();
881 //=================================================================================
882 // function : GetConstructorId()
884 //=================================================================================
885 int SMESHGUI_SymmetryDlg::GetConstructorId()
887 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
888 return GroupConstructors->id(GroupConstructors->selected());
892 //=================================================================================
893 // function : IsMirrorOk()
895 //=================================================================================
896 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
900 if (GetConstructorId() != 0)
901 isOk = (SpinBox_DX->GetValue() != 0 ||
902 SpinBox_DY->GetValue() != 0 ||
903 SpinBox_DZ->GetValue() != 0);
908 //=================================================================================
909 // function : onVectorChanged()
911 //=================================================================================
912 void SMESHGUI_SymmetryDlg::onVectorChanged()
915 buttonOk->setEnabled(true);
916 buttonApply->setEnabled(true);
918 buttonOk->setEnabled(false);
919 buttonApply->setEnabled(false);
923 //=================================================================================
924 // function : keyPressEvent()
926 //=================================================================================
927 void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
929 QDialog::keyPressEvent( e );
930 if ( e->isAccepted() )
933 if ( e->key() == Key_F1 )