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 ) ),
86 myViewWindow( SMESH::GetViewWindow( theModule ) ),
87 mySelector( myViewWindow->GetSelector() )
89 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
90 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
91 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
92 QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
95 setName("SMESHGUI_SymmetryDlg");
97 setCaption(tr("SMESH_SYMMETRY"));
98 setSizeGripEnabled(TRUE);
99 SMESHGUI_SymmetryDlgLayout = new QGridLayout(this);
100 SMESHGUI_SymmetryDlgLayout->setSpacing(6);
101 SMESHGUI_SymmetryDlgLayout->setMargin(11);
103 /***************************************************************/
104 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
105 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
106 (QSizePolicy::SizeType)0, 0, 0,
107 GroupConstructors->sizePolicy().hasHeightForWidth()));
108 GroupConstructors->setTitle(tr("SMESH_SYMMETRY" ));
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 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
118 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
119 RadioButton1->setText(tr("" ));
120 RadioButton1->setPixmap(image0);
121 RBLayout->addWidget(RadioButton1);
122 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
123 RadioButton2->setText(tr("" ));
124 RadioButton2->setPixmap(image1);
125 RBLayout->addWidget(RadioButton2);
126 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
127 RadioButton3->setText(tr("" ));
128 RadioButton3->setPixmap(image2);
129 RBLayout->addWidget(RadioButton3);
130 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
131 SMESHGUI_SymmetryDlgLayout->addWidget(GroupConstructors, 0, 0);
133 /***************************************************************/
134 GroupButtons = new QGroupBox(this, "GroupButtons");
135 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
136 (QSizePolicy::SizeType)0, 0, 0,
137 GroupButtons->sizePolicy().hasHeightForWidth()));
138 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
139 GroupButtons->setTitle(tr("" ));
140 GroupButtons->setColumnLayout(0, Qt::Vertical);
141 GroupButtons->layout()->setSpacing(0);
142 GroupButtons->layout()->setMargin(0);
143 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
144 GroupButtonsLayout->setAlignment(Qt::AlignTop);
145 GroupButtonsLayout->setSpacing(6);
146 GroupButtonsLayout->setMargin(11);
147 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
148 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
149 buttonCancel->setAutoDefault(TRUE);
150 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
151 buttonApply = new QPushButton(GroupButtons, "buttonApply");
152 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
153 buttonApply->setAutoDefault(TRUE);
154 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
155 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
156 GroupButtonsLayout->addItem(spacer_9, 0, 2);
157 buttonOk = new QPushButton(GroupButtons, "buttonOk");
158 buttonOk->setText(tr("SMESH_BUT_OK" ));
159 buttonOk->setAutoDefault(TRUE);
160 buttonOk->setDefault(TRUE);
161 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
162 SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons, 2, 0);
164 /***************************************************************/
165 GroupArguments = new QGroupBox(this, "GroupArguments");
166 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
167 GroupArguments->setColumnLayout(0, Qt::Vertical);
168 GroupArguments->layout()->setSpacing(0);
169 GroupArguments->layout()->setMargin(0);
170 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
171 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
172 GroupArgumentsLayout->setSpacing(6);
173 GroupArgumentsLayout->setMargin(11);
175 // Controls for elements selection
176 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
177 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
178 TextLabelElements->setFixedWidth(74);
179 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
181 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
182 SelectElementsButton->setText(tr("" ));
183 SelectElementsButton->setPixmap(image3);
184 SelectElementsButton->setToggleButton(FALSE);
185 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
187 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
188 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
189 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
191 // Control for the whole mesh selection
192 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
193 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
194 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
196 // Controls for mirror selection
197 GroupMirror = new QGroupBox(GroupArguments, "GroupMirror");
198 GroupMirror->setColumnLayout(0, Qt::Vertical);
199 GroupMirror->layout()->setSpacing(0);
200 GroupMirror->layout()->setMargin(0);
201 QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror->layout());
202 GroupMirrorLayout->setAlignment(Qt::AlignTop);
203 GroupMirrorLayout->setSpacing(6);
204 GroupMirrorLayout->setMargin(11);
206 TextLabelPoint = new QLabel(GroupMirror, "TextLabelPoint");
207 TextLabelPoint->setText(tr("SMESH_POINT"));
208 GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0);
210 SelectPointButton = new QPushButton(GroupMirror, "SelectPointButton");
211 SelectPointButton->setPixmap(image3);
212 GroupMirrorLayout->addWidget(SelectPointButton, 0, 1);
214 TextLabelX = new QLabel(GroupMirror, "TextLabelX");
215 TextLabelX->setText(tr("SMESH_X"));
216 GroupMirrorLayout->addWidget(TextLabelX, 0, 2);
218 SpinBox_X = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_X");
219 GroupMirrorLayout->addWidget(SpinBox_X, 0, 3);
221 TextLabelY = new QLabel(GroupMirror, "TextLabelY");
222 TextLabelY->setText(tr("SMESH_Y"));
223 GroupMirrorLayout->addWidget(TextLabelY, 0, 4);
225 SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Y");
226 GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5);
228 TextLabelZ = new QLabel(GroupMirror, "TextLabelZ");
229 TextLabelZ->setText(tr("SMESH_Z"));
230 GroupMirrorLayout->addWidget(TextLabelZ, 0, 6);
232 SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Z");
233 GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7);
235 TextLabelVector = new QLabel(GroupMirror, "TextLabelVector");
236 GroupMirrorLayout->addWidget(TextLabelVector, 1, 0);
238 SelectVectorButton = new QPushButton(GroupMirror, "SelectVectorButton");
239 SelectVectorButton->setPixmap(image3);
240 GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
242 TextLabelDX = new QLabel(GroupMirror, "TextLabelDX");
243 TextLabelDX->setText(tr("SMESH_DX"));
244 GroupMirrorLayout->addWidget(TextLabelDX, 1, 2);
246 SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DX");
247 GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3);
249 TextLabelDY = new QLabel(GroupMirror, "TextLabelDY");
250 TextLabelDY->setText(tr("SMESH_DY"));
251 GroupMirrorLayout->addWidget(TextLabelDY, 1, 4);
253 SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DY");
254 GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5);
256 TextLabelDZ = new QLabel(GroupMirror, "TextLabelDZ");
257 TextLabelDZ->setText(tr("SMESH_DZ"));
258 GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6);
260 SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DZ");
261 GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7);
263 GroupArgumentsLayout->addMultiCellWidget(GroupMirror, 2, 2, 0, 2);
265 // Controls for "Create a copy" option
266 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
267 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
268 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 3, 3, 0, 2);
271 SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments, 1, 0);
273 /* Initialisations */
274 SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
275 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
276 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
277 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
278 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
279 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
281 GroupArguments->show();
282 RadioButton1->setChecked(TRUE);
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);
330 //=================================================================================
331 // function : ~SMESHGUI_SymmetryDlg()
332 // purpose : Destroys the object and frees any allocated resources
333 //=================================================================================
334 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
336 // no need to delete child widgets, Qt does it all for us
339 //=================================================================================
342 //=================================================================================
343 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
347 myEditCurrentArgument = 0;
348 LineEditElements->clear();
352 buttonOk->setEnabled(false);
353 buttonApply->setEnabled(false);
356 myMesh = SMESH::SMESH_Mesh::_nil();
359 SpinBox_X->SetValue(0.0);
360 SpinBox_Y->SetValue(0.0);
361 SpinBox_Z->SetValue(0.0);
362 SpinBox_DX->SetValue(0.0);
363 SpinBox_DY->SetValue(0.0);
364 SpinBox_DZ->SetValue(0.0);
366 CheckBoxCopy->setChecked(false);
367 CheckBoxMesh->setChecked(false);
372 //=================================================================================
373 // function : ConstructorsClicked()
374 // purpose : Radio button management
375 //=================================================================================
376 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
378 disconnect(mySelectionMgr, 0, this, 0);
380 if (constructorId != 0 && !TextLabelVector->isVisible()) {
381 TextLabelVector->show();
382 SelectVectorButton->show();
391 switch (constructorId) {
394 GroupMirror->setTitle(tr("SMESH_POINT"));
396 TextLabelVector->hide();
397 SelectVectorButton->hide();
408 GroupMirror->setTitle(tr("SMESH_AXIS"));
409 TextLabelVector->setText(tr("SMESH_VECTOR"));
414 GroupMirror->setTitle(tr("SMESH_PLANE"));
415 TextLabelVector->setText(tr("SMESH_NORMAL"));
420 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
421 SMESH::SetPointRepresentation(false);
422 if (!CheckBoxMesh->isChecked())
423 myViewWindow->SetSelectionMode(CellSelection);
426 myEditCurrentArgument = (QWidget*)LineEditElements;
427 LineEditElements->setFocus();
429 if (CheckBoxMesh->isChecked())
432 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
435 //=================================================================================
436 // function : ClickOnApply()
438 //=================================================================================
439 void SMESHGUI_SymmetryDlg::ClickOnApply()
441 if (mySMESHGUI->isActiveStudyLocked())
444 if (myNbOkElements && IsMirrorOk()) {
445 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
447 SMESH::long_array_var anElementsId = new SMESH::long_array;
449 anElementsId->length(aListElementsId.count());
450 for (int i = 0; i < aListElementsId.count(); i++)
451 anElementsId[i] = aListElementsId[i].toInt();
453 SMESH::AxisStruct aMirror;
455 aMirror.x = SpinBox_X->GetValue();
456 aMirror.y = SpinBox_Y->GetValue();
457 aMirror.z = SpinBox_Z->GetValue();
458 if (GetConstructorId() == 0) {
459 aMirror.vx = aMirror.vy = aMirror.vz = 0;
461 aMirror.vx = SpinBox_DX->GetValue();
462 aMirror.vy = SpinBox_DY->GetValue();
463 aMirror.vz = SpinBox_DZ->GetValue();
466 bool toCreateCopy = CheckBoxCopy->isChecked();
468 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
470 if (GetConstructorId() == 0)
471 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
472 if (GetConstructorId() == 1)
473 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
474 if (GetConstructorId() == 2)
475 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
478 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
479 QApplication::setOverrideCursor(Qt::waitCursor);
480 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
481 QApplication::restoreOverrideCursor();
485 mySelectionMgr->clearSelected();
488 ConstructorsClicked(GetConstructorId());
492 //=================================================================================
493 // function : ClickOnOk()
495 //=================================================================================
496 void SMESHGUI_SymmetryDlg::ClickOnOk()
502 //=================================================================================
503 // function : ClickOnCancel()
505 //=================================================================================
506 void SMESHGUI_SymmetryDlg::ClickOnCancel()
508 disconnect(mySelectionMgr, 0, this, 0);
509 mySelectionMgr->clearFilters();
510 mySelectionMgr->clearSelected();
511 SMESH::SetPointRepresentation(false);
512 myViewWindow->SetSelectionMode(ActorSelection);
513 mySMESHGUI->ResetState();
517 //=======================================================================
518 // function : onTextChange()
520 //=======================================================================
521 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
523 QLineEdit* send = (QLineEdit*)sender();
528 if (send == LineEditElements)
531 buttonOk->setEnabled(false);
532 buttonApply->setEnabled(false);
534 // hilight entered elements
535 SMDS_Mesh* aMesh = 0;
537 aMesh = myActor->GetObject()->GetMesh();
540 //mySelectionMgr->clearSelected();
541 //mySelectionMgr->AddIObject(myActor->getIO());
543 aList.Append(myActor->getIO());
544 mySelectionMgr->setSelectedObjects(aList, false);
546 TColStd_IndexedMapOfInteger selectedIndices;
547 TColStd_MapOfInteger newIndices;
548 mySelector->GetIndex(myActor->getIO(), selectedIndices);
550 QStringList aListId = QStringList::split(" ", theNewText, false);
552 if (send == LineEditElements) {
553 for (int i = 0; i < aListId.count(); i++) {
554 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
556 //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) {
557 if (selectedIndices.Add(e->GetID())) {
558 //mySelectionMgr->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true);
559 newIndices.Add(e->GetID());
565 if (newIndices.Extent() > 0){
566 mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true );
567 myViewWindow->highlight( myActor->getIO(), true, true );
570 myElementsId = theNewText;
574 if (myNbOkElements && IsMirrorOk()) {
575 buttonOk->setEnabled(true);
576 buttonApply->setEnabled(true);
582 //=================================================================================
583 // function : SelectionIntoArgument()
584 // purpose : Called when selection as changed or other case
585 //=================================================================================
586 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
592 QString aString = "";
595 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
596 LineEditElements->setText(aString);
598 buttonOk->setEnabled(false);
599 buttonApply->setEnabled(false);
603 if (!GroupButtons->isEnabled()) // inactive
608 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
610 int nbSel = aList.Extent();
614 Handle(SALOME_InteractiveObject) IO = aList.First();
615 myMesh = SMESH::GetMeshByIO(IO);
616 if(myMesh->_is_nil())
619 myActor = SMESH::FindActorByObject(myMesh);
621 myActor = SMESH::FindActorByEntry(IO->getEntry());
627 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
630 if (CheckBoxMesh->isChecked()) {
631 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
633 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
635 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
639 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
640 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
642 myElementsId += QString(" %1").arg(i);
646 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
648 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
650 // get IDs from submesh
651 SMESH::long_array_var anElementsIds = new SMESH::long_array;
652 anElementsIds = aSubMesh->GetElementsId();
653 for (int i = 0; i < anElementsIds->length(); i++) {
654 myElementsId += QString(" %1").arg(anElementsIds[i]);
656 aNbUnits = anElementsIds->length();
659 SMESH::SMESH_GroupBase_var aGroup =
660 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
661 if (aGroup->_is_nil())
664 // get IDs from smesh group
665 SMESH::long_array_var anElementsIds = new SMESH::long_array;
666 anElementsIds = aGroup->GetListOfID();
667 for (int i = 0; i < anElementsIds->length(); i++) {
668 myElementsId += QString(" %1").arg(anElementsIds[i]);
670 aNbUnits = anElementsIds->length();
673 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, myActor->getIO(), aString);
674 myElementsId = aString;
680 myNbOkElements = true;
682 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
686 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
690 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
698 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
699 SpinBox_X->SetValue(x);
700 SpinBox_Y->SetValue(y);
701 SpinBox_Z->SetValue(z);
702 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
703 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
704 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
705 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
710 if (myEditCurrentArgument == (QWidget*)LineEditElements)
711 LineEditElements->setText(aString);
715 if (myNbOkElements && IsMirrorOk()) {
716 buttonOk->setEnabled(true);
717 buttonApply->setEnabled(true);
721 //=================================================================================
722 // function : SetEditCurrentArgument()
724 //=================================================================================
725 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
727 QPushButton* send = (QPushButton*)sender();
729 disconnect(mySelectionMgr, 0, this, 0);
730 mySelectionMgr->clearSelected();
731 mySelectionMgr->clearFilters();
733 if (send == SelectElementsButton) {
734 myEditCurrentArgument = (QWidget*)LineEditElements;
735 SMESH::SetPointRepresentation(false);
736 if (CheckBoxMesh->isChecked()) {
737 myViewWindow->SetSelectionMode(ActorSelection);
738 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
740 myViewWindow->SetSelectionMode(CellSelection);
742 } else if (send == SelectPointButton) {
743 myEditCurrentArgument = (QWidget*)SpinBox_X;
744 SMESH::SetPointRepresentation(true);
745 myViewWindow->SetSelectionMode(NodeSelection);
746 } else if (send == SelectVectorButton) {
747 myEditCurrentArgument = (QWidget*)SpinBox_DX;
748 SMESH::SetPointRepresentation(true);
750 myViewWindow->SetSelectionMode(NodeSelection);
754 myEditCurrentArgument->setFocus();
755 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
756 SelectionIntoArgument();
759 //=================================================================================
760 // function : DeactivateActiveDialog()
762 //=================================================================================
763 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
765 if (GroupConstructors->isEnabled()) {
766 GroupConstructors->setEnabled(false);
767 GroupArguments->setEnabled(false);
768 GroupButtons->setEnabled(false);
769 mySMESHGUI->ResetState();
770 mySMESHGUI->SetActiveDialogBox(0);
774 //=================================================================================
775 // function : ActivateThisDialog()
777 //=================================================================================
778 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
780 /* Emit a signal to deactivate the active dialog */
781 mySMESHGUI->EmitSignalDeactivateDialog();
782 GroupConstructors->setEnabled(true);
783 GroupArguments->setEnabled(true);
784 GroupButtons->setEnabled(true);
786 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
788 myViewWindow->SetSelectionMode(CellSelection);
789 SelectionIntoArgument();
792 //=================================================================================
793 // function : enterEvent()
795 //=================================================================================
796 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
798 if (!GroupConstructors->isEnabled())
799 ActivateThisDialog();
802 //=================================================================================
803 // function : closeEvent()
805 //=================================================================================
806 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
808 /* same than click on cancel button */
809 this->ClickOnCancel();
812 //=======================================================================
813 // function : hideEvent()
814 // purpose : caused by ESC key
815 //=======================================================================
816 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
822 //=======================================================================
823 //function : onSelectMesh
825 //=======================================================================
826 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
829 TextLabelElements->setText(tr("SMESH_NAME"));
831 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
833 if (myEditCurrentArgument != LineEditElements) {
834 LineEditElements->clear();
838 mySelectionMgr->clearFilters();
839 SMESH::SetPointRepresentation(false);
842 myViewWindow->SetSelectionMode(ActorSelection);
843 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
844 LineEditElements->setReadOnly(true);
846 myViewWindow->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);