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_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"
46 #include "SVTK_ViewModel.h"
47 #include "SVTK_ViewWindow.h"
48 #include "SVTK_Selector.h"
49 #include "SVTK_Selection.h"
50 #include "SALOME_ListIO.hxx"
52 #include "utilities.h"
55 #include <TColStd_MapOfInteger.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
59 #include <qapplication.h>
60 #include <qbuttongroup.h>
61 #include <qgroupbox.h>
63 #include <qlineedit.h>
64 #include <qpushbutton.h>
65 #include <qradiobutton.h>
66 #include <qcheckbox.h>
71 #include "SALOMEconfig.h"
72 #include CORBA_SERVER_HEADER(SMESH_Group)
76 //=================================================================================
77 // class : SMESHGUI_SymmetryDlg()
79 //=================================================================================
80 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule, const char* name,
81 bool modal, WFlags fl)
82 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
83 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
84 mySMESHGUI( theModule ),
85 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
87 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
88 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
89 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
90 QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
93 setName("SMESHGUI_SymmetryDlg");
95 setCaption(tr("SMESH_SYMMETRY"));
96 setSizeGripEnabled(TRUE);
97 SMESHGUI_SymmetryDlgLayout = new QGridLayout(this);
98 SMESHGUI_SymmetryDlgLayout->setSpacing(6);
99 SMESHGUI_SymmetryDlgLayout->setMargin(11);
101 /***************************************************************/
102 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
103 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
104 (QSizePolicy::SizeType)0, 0, 0,
105 GroupConstructors->sizePolicy().hasHeightForWidth()));
106 GroupConstructors->setTitle(tr("SMESH_SYMMETRY" ));
107 GroupConstructors->setExclusive(TRUE);
108 GroupConstructors->setColumnLayout(0, Qt::Vertical);
109 GroupConstructors->layout()->setSpacing(0);
110 GroupConstructors->layout()->setMargin(0);
111 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
112 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
113 GroupConstructorsLayout->setSpacing(6);
114 GroupConstructorsLayout->setMargin(11);
115 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
116 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
117 RadioButton1->setText(tr("" ));
118 RadioButton1->setPixmap(image0);
119 RBLayout->addWidget(RadioButton1);
120 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
121 RadioButton2->setText(tr("" ));
122 RadioButton2->setPixmap(image1);
123 RBLayout->addWidget(RadioButton2);
124 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
125 RadioButton3->setText(tr("" ));
126 RadioButton3->setPixmap(image2);
127 RBLayout->addWidget(RadioButton3);
128 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
129 SMESHGUI_SymmetryDlgLayout->addWidget(GroupConstructors, 0, 0);
131 /***************************************************************/
132 GroupButtons = new QGroupBox(this, "GroupButtons");
133 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
134 (QSizePolicy::SizeType)0, 0, 0,
135 GroupButtons->sizePolicy().hasHeightForWidth()));
136 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
137 GroupButtons->setTitle(tr("" ));
138 GroupButtons->setColumnLayout(0, Qt::Vertical);
139 GroupButtons->layout()->setSpacing(0);
140 GroupButtons->layout()->setMargin(0);
141 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
142 GroupButtonsLayout->setAlignment(Qt::AlignTop);
143 GroupButtonsLayout->setSpacing(6);
144 GroupButtonsLayout->setMargin(11);
145 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
146 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
147 buttonCancel->setAutoDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
149 buttonApply = new QPushButton(GroupButtons, "buttonApply");
150 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
151 buttonApply->setAutoDefault(TRUE);
152 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
153 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
154 GroupButtonsLayout->addItem(spacer_9, 0, 2);
155 buttonOk = new QPushButton(GroupButtons, "buttonOk");
156 buttonOk->setText(tr("SMESH_BUT_OK" ));
157 buttonOk->setAutoDefault(TRUE);
158 buttonOk->setDefault(TRUE);
159 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
160 SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons, 2, 0);
162 /***************************************************************/
163 GroupArguments = new QGroupBox(this, "GroupArguments");
164 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
165 GroupArguments->setColumnLayout(0, Qt::Vertical);
166 GroupArguments->layout()->setSpacing(0);
167 GroupArguments->layout()->setMargin(0);
168 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
169 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
170 GroupArgumentsLayout->setSpacing(6);
171 GroupArgumentsLayout->setMargin(11);
173 // Controls for elements selection
174 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
175 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
176 TextLabelElements->setFixedWidth(74);
177 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
179 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
180 SelectElementsButton->setText(tr("" ));
181 SelectElementsButton->setPixmap(image3);
182 SelectElementsButton->setToggleButton(FALSE);
183 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
185 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
186 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
187 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
189 // Control for the whole mesh selection
190 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
191 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
192 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
194 // Controls for mirror selection
195 GroupMirror = new QGroupBox(GroupArguments, "GroupMirror");
196 GroupMirror->setColumnLayout(0, Qt::Vertical);
197 GroupMirror->layout()->setSpacing(0);
198 GroupMirror->layout()->setMargin(0);
199 QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror->layout());
200 GroupMirrorLayout->setAlignment(Qt::AlignTop);
201 GroupMirrorLayout->setSpacing(6);
202 GroupMirrorLayout->setMargin(11);
204 TextLabelPoint = new QLabel(GroupMirror, "TextLabelPoint");
205 TextLabelPoint->setText(tr("SMESH_POINT"));
206 GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0);
208 SelectPointButton = new QPushButton(GroupMirror, "SelectPointButton");
209 SelectPointButton->setPixmap(image3);
210 GroupMirrorLayout->addWidget(SelectPointButton, 0, 1);
212 TextLabelX = new QLabel(GroupMirror, "TextLabelX");
213 TextLabelX->setText(tr("SMESH_X"));
214 GroupMirrorLayout->addWidget(TextLabelX, 0, 2);
216 SpinBox_X = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_X");
217 GroupMirrorLayout->addWidget(SpinBox_X, 0, 3);
219 TextLabelY = new QLabel(GroupMirror, "TextLabelY");
220 TextLabelY->setText(tr("SMESH_Y"));
221 GroupMirrorLayout->addWidget(TextLabelY, 0, 4);
223 SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Y");
224 GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5);
226 TextLabelZ = new QLabel(GroupMirror, "TextLabelZ");
227 TextLabelZ->setText(tr("SMESH_Z"));
228 GroupMirrorLayout->addWidget(TextLabelZ, 0, 6);
230 SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Z");
231 GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7);
233 TextLabelVector = new QLabel(GroupMirror, "TextLabelVector");
234 GroupMirrorLayout->addWidget(TextLabelVector, 1, 0);
236 SelectVectorButton = new QPushButton(GroupMirror, "SelectVectorButton");
237 SelectVectorButton->setPixmap(image3);
238 GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
240 TextLabelDX = new QLabel(GroupMirror, "TextLabelDX");
241 TextLabelDX->setText(tr("SMESH_DX"));
242 GroupMirrorLayout->addWidget(TextLabelDX, 1, 2);
244 SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DX");
245 GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3);
247 TextLabelDY = new QLabel(GroupMirror, "TextLabelDY");
248 TextLabelDY->setText(tr("SMESH_DY"));
249 GroupMirrorLayout->addWidget(TextLabelDY, 1, 4);
251 SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DY");
252 GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5);
254 TextLabelDZ = new QLabel(GroupMirror, "TextLabelDZ");
255 TextLabelDZ->setText(tr("SMESH_DZ"));
256 GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6);
258 SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DZ");
259 GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7);
261 GroupArgumentsLayout->addMultiCellWidget(GroupMirror, 2, 2, 0, 2);
263 // Controls for "Create a copy" option
264 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
265 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
266 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 3, 3, 0, 2);
269 SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments, 1, 0);
271 /* Initialisations */
272 SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
273 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
274 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
275 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
276 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
277 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
279 GroupArguments->show();
280 RadioButton1->setChecked(TRUE);
282 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
284 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
286 // Costruction of the logical filter
287 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
288 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
290 QPtrList<SUIT_SelectionFilter> aListOfFilters;
291 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
292 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
294 myMeshOrSubMeshOrGroupFilter =
295 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
299 /* signals and slots connections */
300 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
301 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
302 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
303 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
305 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
306 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
307 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
309 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
310 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
311 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
313 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
314 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
315 /* to close dialog if study change */
316 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
317 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
318 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
320 /* Move widget on the botton right corner of main widget */
322 mySMESHGUI->DefineDlgPosition(this, x, y);
324 this->show(); /* displays Dialog */
326 ConstructorsClicked(0);
327 SelectionIntoArgument();
331 //=================================================================================
332 // function : ~SMESHGUI_SymmetryDlg()
333 // purpose : Destroys the object and frees any allocated resources
334 //=================================================================================
335 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
337 // no need to delete child widgets, Qt does it all for us
340 //=================================================================================
343 //=================================================================================
344 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
348 myEditCurrentArgument = 0;
349 LineEditElements->clear();
353 buttonOk->setEnabled(false);
354 buttonApply->setEnabled(false);
357 myMesh = SMESH::SMESH_Mesh::_nil();
360 SpinBox_X->SetValue(0.0);
361 SpinBox_Y->SetValue(0.0);
362 SpinBox_Z->SetValue(0.0);
363 SpinBox_DX->SetValue(0.0);
364 SpinBox_DY->SetValue(0.0);
365 SpinBox_DZ->SetValue(0.0);
367 CheckBoxCopy->setChecked(false);
368 CheckBoxMesh->setChecked(false);
373 //=================================================================================
374 // function : ConstructorsClicked()
375 // purpose : Radio button management
376 //=================================================================================
377 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
379 disconnect(mySelectionMgr, 0, this, 0);
381 if (constructorId != 0 && !TextLabelVector->isVisible()) {
382 TextLabelVector->show();
383 SelectVectorButton->show();
392 switch (constructorId) {
395 GroupMirror->setTitle(tr("SMESH_POINT"));
397 TextLabelVector->hide();
398 SelectVectorButton->hide();
409 GroupMirror->setTitle(tr("SMESH_AXIS"));
410 TextLabelVector->setText(tr("SMESH_VECTOR"));
415 GroupMirror->setTitle(tr("SMESH_PLANE"));
416 TextLabelVector->setText(tr("SMESH_NORMAL"));
421 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
422 SMESH::SetPointRepresentation(false);
423 if (!CheckBoxMesh->isChecked())
425 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
426 aViewWindow->SetSelectionMode(CellSelection);
430 myEditCurrentArgument = (QWidget*)LineEditElements;
431 LineEditElements->setFocus();
433 if (CheckBoxMesh->isChecked())
436 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
439 //=================================================================================
440 // function : ClickOnApply()
442 //=================================================================================
443 void SMESHGUI_SymmetryDlg::ClickOnApply()
445 if (mySMESHGUI->isActiveStudyLocked())
448 if (myNbOkElements && IsMirrorOk()) {
449 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
451 SMESH::long_array_var anElementsId = new SMESH::long_array;
453 anElementsId->length(aListElementsId.count());
454 for (int i = 0; i < aListElementsId.count(); i++)
455 anElementsId[i] = aListElementsId[i].toInt();
457 SMESH::AxisStruct aMirror;
459 aMirror.x = SpinBox_X->GetValue();
460 aMirror.y = SpinBox_Y->GetValue();
461 aMirror.z = SpinBox_Z->GetValue();
462 if (GetConstructorId() == 0) {
463 aMirror.vx = aMirror.vy = aMirror.vz = 0;
465 aMirror.vx = SpinBox_DX->GetValue();
466 aMirror.vy = SpinBox_DY->GetValue();
467 aMirror.vz = SpinBox_DZ->GetValue();
470 bool toCreateCopy = CheckBoxCopy->isChecked();
472 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
474 if (GetConstructorId() == 0)
475 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
476 if (GetConstructorId() == 1)
477 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
478 if (GetConstructorId() == 2)
479 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
482 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
483 QApplication::setOverrideCursor(Qt::waitCursor);
484 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
485 QApplication::restoreOverrideCursor();
491 ConstructorsClicked(GetConstructorId());
492 SelectionIntoArgument();
496 //=================================================================================
497 // function : ClickOnOk()
499 //=================================================================================
500 void SMESHGUI_SymmetryDlg::ClickOnOk()
506 //=================================================================================
507 // function : ClickOnCancel()
509 //=================================================================================
510 void SMESHGUI_SymmetryDlg::ClickOnCancel()
512 disconnect(mySelectionMgr, 0, this, 0);
513 mySelectionMgr->clearFilters();
514 //mySelectionMgr->clearSelected();
515 SMESH::SetPointRepresentation(false);
516 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
517 aViewWindow->SetSelectionMode(ActorSelection);
518 mySMESHGUI->ResetState();
522 //=======================================================================
523 // function : onTextChange()
525 //=======================================================================
526 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
528 QLineEdit* send = (QLineEdit*)sender();
533 if (send == LineEditElements)
536 buttonOk->setEnabled(false);
537 buttonApply->setEnabled(false);
539 // hilight entered elements
540 SMDS_Mesh* aMesh = 0;
542 aMesh = myActor->GetObject()->GetMesh();
545 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
547 TColStd_MapOfInteger newIndices;
549 QStringList aListId = QStringList::split(" ", theNewText, false);
551 if (send == LineEditElements) {
552 for (int i = 0; i < aListId.count(); i++) {
553 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
555 newIndices.Add(e->GetID());
559 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
560 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
561 aViewWindow->highlight( anIO, true, true );
563 myElementsId = theNewText;
567 if (myNbOkElements && IsMirrorOk()) {
568 buttonOk->setEnabled(true);
569 buttonApply->setEnabled(true);
575 //=================================================================================
576 // function : SelectionIntoArgument()
577 // purpose : Called when selection as changed or other case
578 //=================================================================================
579 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
585 QString aString = "";
588 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
589 LineEditElements->setText(aString);
591 buttonOk->setEnabled(false);
592 buttonApply->setEnabled(false);
596 if (!GroupButtons->isEnabled()) // inactive
601 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
603 int nbSel = aList.Extent();
607 Handle(SALOME_InteractiveObject) IO = aList.First();
608 myMesh = SMESH::GetMeshByIO(IO);
609 if(myMesh->_is_nil())
612 myActor = SMESH::FindActorByObject(myMesh);
614 myActor = SMESH::FindActorByEntry(IO->getEntry());
620 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
623 if (CheckBoxMesh->isChecked()) {
624 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
626 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
628 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
632 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
633 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
635 myElementsId += QString(" %1").arg(i);
639 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
641 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
643 // get IDs from submesh
644 SMESH::long_array_var anElementsIds = new SMESH::long_array;
645 anElementsIds = aSubMesh->GetElementsId();
646 for (int i = 0; i < anElementsIds->length(); i++) {
647 myElementsId += QString(" %1").arg(anElementsIds[i]);
649 aNbUnits = anElementsIds->length();
652 SMESH::SMESH_GroupBase_var aGroup =
653 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
654 if (aGroup->_is_nil())
657 // get IDs from smesh group
658 SMESH::long_array_var anElementsIds = new SMESH::long_array;
659 anElementsIds = aGroup->GetListOfID();
660 for (int i = 0; i < anElementsIds->length(); i++) {
661 myElementsId += QString(" %1").arg(anElementsIds[i]);
663 aNbUnits = anElementsIds->length();
666 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, myActor->getIO(), aString);
667 myElementsId = aString;
673 myNbOkElements = true;
675 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
679 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
683 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
691 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
692 SpinBox_X->SetValue(x);
693 SpinBox_Y->SetValue(y);
694 SpinBox_Z->SetValue(z);
695 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
696 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
697 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
698 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
703 if (myEditCurrentArgument == (QWidget*)LineEditElements)
704 LineEditElements->setText(aString);
708 if (myNbOkElements && IsMirrorOk()) {
709 buttonOk->setEnabled(true);
710 buttonApply->setEnabled(true);
714 //=================================================================================
715 // function : SetEditCurrentArgument()
717 //=================================================================================
718 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
720 QPushButton* send = (QPushButton*)sender();
722 disconnect(mySelectionMgr, 0, this, 0);
723 mySelectionMgr->clearSelected();
724 mySelectionMgr->clearFilters();
726 if (send == SelectElementsButton) {
727 myEditCurrentArgument = (QWidget*)LineEditElements;
728 SMESH::SetPointRepresentation(false);
729 if (CheckBoxMesh->isChecked()) {
730 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
731 aViewWindow->SetSelectionMode(ActorSelection);
732 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
734 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
735 aViewWindow->SetSelectionMode(CellSelection);
737 } else if (send == SelectPointButton) {
738 myEditCurrentArgument = (QWidget*)SpinBox_X;
739 SMESH::SetPointRepresentation(true);
740 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
741 aViewWindow->SetSelectionMode(NodeSelection);
742 } else if (send == SelectVectorButton) {
743 myEditCurrentArgument = (QWidget*)SpinBox_DX;
744 SMESH::SetPointRepresentation(true);
746 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
747 aViewWindow->SetSelectionMode(NodeSelection);
751 myEditCurrentArgument->setFocus();
752 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
753 SelectionIntoArgument();
756 //=================================================================================
757 // function : DeactivateActiveDialog()
759 //=================================================================================
760 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
762 if (GroupConstructors->isEnabled()) {
763 GroupConstructors->setEnabled(false);
764 GroupArguments->setEnabled(false);
765 GroupButtons->setEnabled(false);
766 mySMESHGUI->ResetState();
767 mySMESHGUI->SetActiveDialogBox(0);
771 //=================================================================================
772 // function : ActivateThisDialog()
774 //=================================================================================
775 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
777 /* Emit a signal to deactivate the active dialog */
778 mySMESHGUI->EmitSignalDeactivateDialog();
779 GroupConstructors->setEnabled(true);
780 GroupArguments->setEnabled(true);
781 GroupButtons->setEnabled(true);
783 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
785 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
786 aViewWindow->SetSelectionMode(CellSelection);
787 SelectionIntoArgument();
790 //=================================================================================
791 // function : enterEvent()
793 //=================================================================================
794 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
796 if (!GroupConstructors->isEnabled())
797 ActivateThisDialog();
800 //=================================================================================
801 // function : closeEvent()
803 //=================================================================================
804 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
806 /* same than click on cancel button */
807 this->ClickOnCancel();
810 //=======================================================================
811 // function : hideEvent()
812 // purpose : caused by ESC key
813 //=======================================================================
814 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
820 //=======================================================================
821 //function : onSelectMesh
823 //=======================================================================
824 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
827 TextLabelElements->setText(tr("SMESH_NAME"));
829 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
831 if (myEditCurrentArgument != LineEditElements) {
832 LineEditElements->clear();
836 mySelectionMgr->clearFilters();
837 SMESH::SetPointRepresentation(false);
840 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
841 aViewWindow->SetSelectionMode(ActorSelection);
842 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
843 LineEditElements->setReadOnly(true);
845 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
846 aViewWindow->SetSelectionMode(CellSelection);
847 LineEditElements->setReadOnly(false);
848 onTextChange(LineEditElements->text());
851 SelectionIntoArgument();
854 //=================================================================================
855 // function : GetConstructorId()
857 //=================================================================================
858 int SMESHGUI_SymmetryDlg::GetConstructorId()
860 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
861 return GroupConstructors->id(GroupConstructors->selected());
865 //=================================================================================
866 // function : IsMirrorOk()
868 //=================================================================================
869 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
873 if (GetConstructorId() != 0)
874 isOk = (SpinBox_DX->GetValue() != 0 ||
875 SpinBox_DY->GetValue() != 0 ||
876 SpinBox_DZ->GetValue() != 0);
881 //=================================================================================
882 // function : onVectorChanged()
884 //=================================================================================
885 void SMESHGUI_SymmetryDlg::onVectorChanged()
888 buttonOk->setEnabled(true);
889 buttonApply->setEnabled(true);
891 buttonOk->setEnabled(false);
892 buttonApply->setEnabled(false);