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)
77 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
81 //=================================================================================
82 // class : SMESHGUI_SymmetryDlg()
84 //=================================================================================
85 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( 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_SYMMETRY_POINT")));
93 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
94 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
95 QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
98 setName("SMESHGUI_SymmetryDlg");
100 setCaption(tr("SMESH_SYMMETRY"));
101 setSizeGripEnabled(TRUE);
102 SMESHGUI_SymmetryDlgLayout = new QGridLayout(this);
103 SMESHGUI_SymmetryDlgLayout->setSpacing(6);
104 SMESHGUI_SymmetryDlgLayout->setMargin(11);
106 /***************************************************************/
107 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
108 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
109 (QSizePolicy::SizeType)0, 0, 0,
110 GroupConstructors->sizePolicy().hasHeightForWidth()));
111 GroupConstructors->setTitle(tr("SMESH_SYMMETRY" ));
112 GroupConstructors->setExclusive(TRUE);
113 GroupConstructors->setColumnLayout(0, Qt::Vertical);
114 GroupConstructors->layout()->setSpacing(0);
115 GroupConstructors->layout()->setMargin(0);
116 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
117 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
118 GroupConstructorsLayout->setSpacing(6);
119 GroupConstructorsLayout->setMargin(11);
120 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
121 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
122 RadioButton1->setText(tr("" ));
123 RadioButton1->setPixmap(image0);
124 RBLayout->addWidget(RadioButton1);
125 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
126 RadioButton2->setText(tr("" ));
127 RadioButton2->setPixmap(image1);
128 RBLayout->addWidget(RadioButton2);
129 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
130 RadioButton3->setText(tr("" ));
131 RadioButton3->setPixmap(image2);
132 RBLayout->addWidget(RadioButton3);
133 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
134 SMESHGUI_SymmetryDlgLayout->addWidget(GroupConstructors, 0, 0);
136 /***************************************************************/
137 GroupButtons = new QGroupBox(this, "GroupButtons");
138 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
139 (QSizePolicy::SizeType)0, 0, 0,
140 GroupButtons->sizePolicy().hasHeightForWidth()));
141 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
142 GroupButtons->setTitle(tr("" ));
143 GroupButtons->setColumnLayout(0, Qt::Vertical);
144 GroupButtons->layout()->setSpacing(0);
145 GroupButtons->layout()->setMargin(0);
146 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
147 GroupButtonsLayout->setAlignment(Qt::AlignTop);
148 GroupButtonsLayout->setSpacing(6);
149 GroupButtonsLayout->setMargin(11);
150 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
151 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
152 buttonHelp->setAutoDefault(TRUE);
153 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
154 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
155 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
156 buttonCancel->setAutoDefault(TRUE);
157 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
158 buttonApply = new QPushButton(GroupButtons, "buttonApply");
159 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
160 buttonApply->setAutoDefault(TRUE);
161 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
162 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
163 GroupButtonsLayout->addItem(spacer_9, 0, 2);
164 buttonOk = new QPushButton(GroupButtons, "buttonOk");
165 buttonOk->setText(tr("SMESH_BUT_OK" ));
166 buttonOk->setAutoDefault(TRUE);
167 buttonOk->setDefault(TRUE);
168 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
169 SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons, 2, 0);
171 /***************************************************************/
172 GroupArguments = new QGroupBox(this, "GroupArguments");
173 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
174 GroupArguments->setColumnLayout(0, Qt::Vertical);
175 GroupArguments->layout()->setSpacing(0);
176 GroupArguments->layout()->setMargin(0);
177 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
178 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
179 GroupArgumentsLayout->setSpacing(6);
180 GroupArgumentsLayout->setMargin(11);
182 // Controls for elements selection
183 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
184 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
185 TextLabelElements->setFixedWidth(74);
186 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
188 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
189 SelectElementsButton->setText(tr("" ));
190 SelectElementsButton->setPixmap(image3);
191 SelectElementsButton->setToggleButton(FALSE);
192 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
194 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
195 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
196 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
198 // Control for the whole mesh selection
199 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
200 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
201 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
203 // Controls for mirror selection
204 GroupMirror = new QGroupBox(GroupArguments, "GroupMirror");
205 GroupMirror->setColumnLayout(0, Qt::Vertical);
206 GroupMirror->layout()->setSpacing(0);
207 GroupMirror->layout()->setMargin(0);
208 QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror->layout());
209 GroupMirrorLayout->setAlignment(Qt::AlignTop);
210 GroupMirrorLayout->setSpacing(6);
211 GroupMirrorLayout->setMargin(11);
213 TextLabelPoint = new QLabel(GroupMirror, "TextLabelPoint");
214 TextLabelPoint->setText(tr("SMESH_POINT"));
215 GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0);
217 SelectPointButton = new QPushButton(GroupMirror, "SelectPointButton");
218 SelectPointButton->setPixmap(image3);
219 GroupMirrorLayout->addWidget(SelectPointButton, 0, 1);
221 TextLabelX = new QLabel(GroupMirror, "TextLabelX");
222 TextLabelX->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
223 TextLabelX->setText(tr("SMESH_X"));
224 GroupMirrorLayout->addWidget(TextLabelX, 0, 2);
226 SpinBox_X = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_X");
227 GroupMirrorLayout->addWidget(SpinBox_X, 0, 3);
229 TextLabelY = new QLabel(GroupMirror, "TextLabelY");
230 TextLabelY->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
231 TextLabelY->setText(tr("SMESH_Y"));
232 GroupMirrorLayout->addWidget(TextLabelY, 0, 4);
234 SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Y");
235 GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5);
237 TextLabelZ = new QLabel(GroupMirror, "TextLabelZ");
238 TextLabelZ->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
239 TextLabelZ->setText(tr("SMESH_Z"));
240 GroupMirrorLayout->addWidget(TextLabelZ, 0, 6);
242 SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Z");
243 GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7);
245 TextLabelVector = new QLabel(GroupMirror, "TextLabelVector");
246 GroupMirrorLayout->addWidget(TextLabelVector, 1, 0);
248 SelectVectorButton = new QPushButton(GroupMirror, "SelectVectorButton");
249 SelectVectorButton->setPixmap(image3);
250 GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
252 TextLabelDX = new QLabel(GroupMirror, "TextLabelDX");
253 TextLabelDX->setText(tr("SMESH_DX"));
254 GroupMirrorLayout->addWidget(TextLabelDX, 1, 2);
256 SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DX");
257 GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3);
259 TextLabelDY = new QLabel(GroupMirror, "TextLabelDY");
260 TextLabelDY->setText(tr("SMESH_DY"));
261 GroupMirrorLayout->addWidget(TextLabelDY, 1, 4);
263 SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DY");
264 GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5);
266 TextLabelDZ = new QLabel(GroupMirror, "TextLabelDZ");
267 TextLabelDZ->setText(tr("SMESH_DZ"));
268 GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6);
270 SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DZ");
271 GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7);
273 GroupArgumentsLayout->addMultiCellWidget(GroupMirror, 2, 2, 0, 2);
275 // Controls for "Create a copy" option
276 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
277 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
278 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 3, 3, 0, 2);
281 SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments, 1, 0);
283 /* Initialisations */
284 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
286 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
287 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
288 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
289 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
291 GroupArguments->show();
292 RadioButton1->setChecked(TRUE);
294 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
296 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
298 // Costruction of the logical filter
299 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
300 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
302 QPtrList<SUIT_SelectionFilter> aListOfFilters;
303 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
304 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
306 myMeshOrSubMeshOrGroupFilter =
307 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
309 myHelpFileName = "/files/symmetry.htm";
313 /* signals and slots connections */
314 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
315 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
316 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
317 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
318 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
320 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
321 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
322 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
324 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
325 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
326 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
328 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
329 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
330 /* to close dialog if study change */
331 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
332 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
333 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
335 this->show(); /* displays Dialog */
337 ConstructorsClicked(0);
338 SelectionIntoArgument();
342 //=================================================================================
343 // function : ~SMESHGUI_SymmetryDlg()
344 // purpose : Destroys the object and frees any allocated resources
345 //=================================================================================
346 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
348 // no need to delete child widgets, Qt does it all for us
351 //=================================================================================
354 //=================================================================================
355 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
359 myEditCurrentArgument = 0;
360 LineEditElements->clear();
364 buttonOk->setEnabled(false);
365 buttonApply->setEnabled(false);
368 myMesh = SMESH::SMESH_Mesh::_nil();
371 SpinBox_X->SetValue(0.0);
372 SpinBox_Y->SetValue(0.0);
373 SpinBox_Z->SetValue(0.0);
374 SpinBox_DX->SetValue(0.0);
375 SpinBox_DY->SetValue(0.0);
376 SpinBox_DZ->SetValue(0.0);
378 CheckBoxCopy->setChecked(false);
379 CheckBoxMesh->setChecked(false);
384 //=================================================================================
385 // function : ConstructorsClicked()
386 // purpose : Radio button management
387 //=================================================================================
388 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
390 disconnect(mySelectionMgr, 0, this, 0);
392 if (constructorId != 0 && !TextLabelVector->isVisible()) {
393 TextLabelVector->show();
394 SelectVectorButton->show();
403 switch (constructorId) {
406 GroupMirror->setTitle(tr("SMESH_POINT"));
408 TextLabelVector->hide();
409 SelectVectorButton->hide();
420 GroupMirror->setTitle(tr("SMESH_AXIS"));
421 TextLabelVector->setText(tr("SMESH_VECTOR"));
426 GroupMirror->setTitle(tr("SMESH_PLANE"));
427 TextLabelVector->setText(tr("SMESH_NORMAL"));
432 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
433 SMESH::SetPointRepresentation(false);
434 if (!CheckBoxMesh->isChecked())
436 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
437 aViewWindow->SetSelectionMode(CellSelection);
441 myEditCurrentArgument = (QWidget*)LineEditElements;
442 LineEditElements->setFocus();
444 if (CheckBoxMesh->isChecked())
447 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
450 //=================================================================================
451 // function : ClickOnApply()
453 //=================================================================================
454 void SMESHGUI_SymmetryDlg::ClickOnApply()
456 if (mySMESHGUI->isActiveStudyLocked())
459 if (myNbOkElements && IsMirrorOk()) {
460 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
462 SMESH::long_array_var anElementsId = new SMESH::long_array;
464 anElementsId->length(aListElementsId.count());
465 for (int i = 0; i < aListElementsId.count(); i++)
466 anElementsId[i] = aListElementsId[i].toInt();
468 SMESH::AxisStruct aMirror;
470 aMirror.x = SpinBox_X->GetValue();
471 aMirror.y = SpinBox_Y->GetValue();
472 aMirror.z = SpinBox_Z->GetValue();
473 if (GetConstructorId() == 0) {
474 aMirror.vx = aMirror.vy = aMirror.vz = 0;
476 aMirror.vx = SpinBox_DX->GetValue();
477 aMirror.vy = SpinBox_DY->GetValue();
478 aMirror.vz = SpinBox_DZ->GetValue();
481 bool toCreateCopy = CheckBoxCopy->isChecked();
483 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
485 if (GetConstructorId() == 0)
486 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
487 if (GetConstructorId() == 1)
488 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
489 if (GetConstructorId() == 2)
490 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
493 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
494 QApplication::setOverrideCursor(Qt::waitCursor);
495 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
496 QApplication::restoreOverrideCursor();
502 ConstructorsClicked(GetConstructorId());
503 SelectionIntoArgument();
507 //=================================================================================
508 // function : ClickOnOk()
510 //=================================================================================
511 void SMESHGUI_SymmetryDlg::ClickOnOk()
517 //=================================================================================
518 // function : ClickOnCancel()
520 //=================================================================================
521 void SMESHGUI_SymmetryDlg::ClickOnCancel()
523 disconnect(mySelectionMgr, 0, this, 0);
524 mySelectionMgr->clearFilters();
525 //mySelectionMgr->clearSelected();
526 SMESH::SetPointRepresentation(false);
527 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
528 aViewWindow->SetSelectionMode(ActorSelection);
529 mySMESHGUI->ResetState();
533 //=================================================================================
534 // function : ClickOnHelp()
536 //=================================================================================
537 void SMESHGUI_SymmetryDlg::ClickOnHelp()
539 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
541 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
543 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
544 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
545 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
546 QObject::tr("BUT_OK"));
550 //=======================================================================
551 // function : onTextChange()
553 //=======================================================================
554 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
556 QLineEdit* send = (QLineEdit*)sender();
561 if (send == LineEditElements)
564 buttonOk->setEnabled(false);
565 buttonApply->setEnabled(false);
567 // hilight entered elements
568 SMDS_Mesh* aMesh = 0;
570 aMesh = myActor->GetObject()->GetMesh();
573 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
575 TColStd_MapOfInteger newIndices;
577 QStringList aListId = QStringList::split(" ", theNewText, false);
579 if (send == LineEditElements) {
580 for (int i = 0; i < aListId.count(); i++) {
581 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
583 newIndices.Add(e->GetID());
587 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
588 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
589 aViewWindow->highlight( anIO, true, true );
591 myElementsId = theNewText;
595 if (myNbOkElements && IsMirrorOk()) {
596 buttonOk->setEnabled(true);
597 buttonApply->setEnabled(true);
603 //=================================================================================
604 // function : SelectionIntoArgument()
605 // purpose : Called when selection as changed or other case
606 //=================================================================================
607 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
613 QString aString = "";
616 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
617 LineEditElements->setText(aString);
619 buttonOk->setEnabled(false);
620 buttonApply->setEnabled(false);
624 if (!GroupButtons->isEnabled()) // inactive
629 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
631 int nbSel = aList.Extent();
635 Handle(SALOME_InteractiveObject) IO = aList.First();
636 myMesh = SMESH::GetMeshByIO(IO);
637 if(myMesh->_is_nil())
640 myActor = SMESH::FindActorByObject(myMesh);
642 myActor = SMESH::FindActorByEntry(IO->getEntry());
648 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
651 if (CheckBoxMesh->isChecked()) {
652 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
654 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
656 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
660 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
661 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
663 myElementsId += QString(" %1").arg(i);
667 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
669 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
671 // get IDs from submesh
672 SMESH::long_array_var anElementsIds = new SMESH::long_array;
673 anElementsIds = aSubMesh->GetElementsId();
674 for (int i = 0; i < anElementsIds->length(); i++) {
675 myElementsId += QString(" %1").arg(anElementsIds[i]);
677 aNbUnits = anElementsIds->length();
680 SMESH::SMESH_GroupBase_var aGroup =
681 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
682 if (aGroup->_is_nil())
685 // get IDs from smesh group
686 SMESH::long_array_var anElementsIds = new SMESH::long_array;
687 anElementsIds = aGroup->GetListOfID();
688 for (int i = 0; i < anElementsIds->length(); i++) {
689 myElementsId += QString(" %1").arg(anElementsIds[i]);
691 aNbUnits = anElementsIds->length();
694 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString);
695 myElementsId = aString;
701 myNbOkElements = true;
703 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
707 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
711 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
719 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
720 SpinBox_X->SetValue(x);
721 SpinBox_Y->SetValue(y);
722 SpinBox_Z->SetValue(z);
723 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
724 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
725 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
726 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
731 if (myEditCurrentArgument == (QWidget*)LineEditElements)
732 LineEditElements->setText(aString);
736 if (myNbOkElements && IsMirrorOk()) {
737 buttonOk->setEnabled(true);
738 buttonApply->setEnabled(true);
742 //=================================================================================
743 // function : SetEditCurrentArgument()
745 //=================================================================================
746 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
748 QPushButton* send = (QPushButton*)sender();
750 disconnect(mySelectionMgr, 0, this, 0);
751 mySelectionMgr->clearSelected();
752 mySelectionMgr->clearFilters();
754 if (send == SelectElementsButton) {
755 myEditCurrentArgument = (QWidget*)LineEditElements;
756 SMESH::SetPointRepresentation(false);
757 if (CheckBoxMesh->isChecked()) {
758 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
759 aViewWindow->SetSelectionMode(ActorSelection);
760 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
762 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
763 aViewWindow->SetSelectionMode(CellSelection);
765 } else if (send == SelectPointButton) {
766 myEditCurrentArgument = (QWidget*)SpinBox_X;
767 SMESH::SetPointRepresentation(true);
768 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
769 aViewWindow->SetSelectionMode(NodeSelection);
770 } else if (send == SelectVectorButton) {
771 myEditCurrentArgument = (QWidget*)SpinBox_DX;
772 SMESH::SetPointRepresentation(true);
774 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
775 aViewWindow->SetSelectionMode(NodeSelection);
779 myEditCurrentArgument->setFocus();
780 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
781 SelectionIntoArgument();
784 //=================================================================================
785 // function : DeactivateActiveDialog()
787 //=================================================================================
788 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
790 if (GroupConstructors->isEnabled()) {
791 GroupConstructors->setEnabled(false);
792 GroupArguments->setEnabled(false);
793 GroupButtons->setEnabled(false);
794 mySMESHGUI->ResetState();
795 mySMESHGUI->SetActiveDialogBox(0);
799 //=================================================================================
800 // function : ActivateThisDialog()
802 //=================================================================================
803 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
805 /* Emit a signal to deactivate the active dialog */
806 mySMESHGUI->EmitSignalDeactivateDialog();
807 GroupConstructors->setEnabled(true);
808 GroupArguments->setEnabled(true);
809 GroupButtons->setEnabled(true);
811 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
813 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
814 aViewWindow->SetSelectionMode(CellSelection);
815 SelectionIntoArgument();
818 //=================================================================================
819 // function : enterEvent()
821 //=================================================================================
822 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
824 if (!GroupConstructors->isEnabled())
825 ActivateThisDialog();
828 //=================================================================================
829 // function : closeEvent()
831 //=================================================================================
832 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
834 /* same than click on cancel button */
835 this->ClickOnCancel();
838 //=======================================================================
839 // function : hideEvent()
840 // purpose : caused by ESC key
841 //=======================================================================
842 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
848 //=======================================================================
849 //function : onSelectMesh
851 //=======================================================================
852 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
855 TextLabelElements->setText(tr("SMESH_NAME"));
857 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
859 if (myEditCurrentArgument != LineEditElements) {
860 LineEditElements->clear();
864 mySelectionMgr->clearFilters();
865 SMESH::SetPointRepresentation(false);
868 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
869 aViewWindow->SetSelectionMode(ActorSelection);
870 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
871 LineEditElements->setReadOnly(true);
873 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
874 aViewWindow->SetSelectionMode(CellSelection);
875 LineEditElements->setReadOnly(false);
876 onTextChange(LineEditElements->text());
879 SelectionIntoArgument();
882 //=================================================================================
883 // function : GetConstructorId()
885 //=================================================================================
886 int SMESHGUI_SymmetryDlg::GetConstructorId()
888 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
889 return GroupConstructors->id(GroupConstructors->selected());
893 //=================================================================================
894 // function : IsMirrorOk()
896 //=================================================================================
897 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
901 if (GetConstructorId() != 0)
902 isOk = (SpinBox_DX->GetValue() != 0 ||
903 SpinBox_DY->GetValue() != 0 ||
904 SpinBox_DZ->GetValue() != 0);
909 //=================================================================================
910 // function : onVectorChanged()
912 //=================================================================================
913 void SMESHGUI_SymmetryDlg::onVectorChanged()
916 buttonOk->setEnabled(true);
917 buttonApply->setEnabled(true);
919 buttonOk->setEnabled(false);
920 buttonApply->setEnabled(false);
924 //=================================================================================
925 // function : keyPressEvent()
927 //=================================================================================
928 void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
930 QDialog::keyPressEvent( e );
931 if ( e->isAccepted() )
934 if ( e->key() == Key_F1 )