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"
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->setText(tr("SMESH_X"));
222 GroupMirrorLayout->addWidget(TextLabelX, 0, 2);
224 SpinBox_X = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_X");
225 GroupMirrorLayout->addWidget(SpinBox_X, 0, 3);
227 TextLabelY = new QLabel(GroupMirror, "TextLabelY");
228 TextLabelY->setText(tr("SMESH_Y"));
229 GroupMirrorLayout->addWidget(TextLabelY, 0, 4);
231 SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Y");
232 GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5);
234 TextLabelZ = new QLabel(GroupMirror, "TextLabelZ");
235 TextLabelZ->setText(tr("SMESH_Z"));
236 GroupMirrorLayout->addWidget(TextLabelZ, 0, 6);
238 SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_Z");
239 GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7);
241 TextLabelVector = new QLabel(GroupMirror, "TextLabelVector");
242 GroupMirrorLayout->addWidget(TextLabelVector, 1, 0);
244 SelectVectorButton = new QPushButton(GroupMirror, "SelectVectorButton");
245 SelectVectorButton->setPixmap(image3);
246 GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
248 TextLabelDX = new QLabel(GroupMirror, "TextLabelDX");
249 TextLabelDX->setText(tr("SMESH_DX"));
250 GroupMirrorLayout->addWidget(TextLabelDX, 1, 2);
252 SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DX");
253 GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3);
255 TextLabelDY = new QLabel(GroupMirror, "TextLabelDY");
256 TextLabelDY->setText(tr("SMESH_DY"));
257 GroupMirrorLayout->addWidget(TextLabelDY, 1, 4);
259 SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DY");
260 GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5);
262 TextLabelDZ = new QLabel(GroupMirror, "TextLabelDZ");
263 TextLabelDZ->setText(tr("SMESH_DZ"));
264 GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6);
266 SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror, "SpinBox_DZ");
267 GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7);
269 GroupArgumentsLayout->addMultiCellWidget(GroupMirror, 2, 2, 0, 2);
271 // Controls for "Create a copy" option
272 CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
273 CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
274 GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 3, 3, 0, 2);
277 SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments, 1, 0);
279 /* Initialisations */
280 SpinBox_X->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
281 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
282 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
283 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
284 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
285 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
287 GroupArguments->show();
288 RadioButton1->setChecked(TRUE);
290 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
292 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
294 // Costruction of the logical filter
295 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
296 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
298 QPtrList<SUIT_SelectionFilter> aListOfFilters;
299 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
300 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
302 myMeshOrSubMeshOrGroupFilter =
303 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
305 myHelpFileName = "/files/symmetry.htm";
309 /* signals and slots connections */
310 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
311 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
312 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
313 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
314 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
316 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
317 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
318 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
320 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
321 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
322 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
324 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
325 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
326 /* to close dialog if study change */
327 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
328 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
329 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
331 this->show(); /* displays Dialog */
333 ConstructorsClicked(0);
334 SelectionIntoArgument();
338 //=================================================================================
339 // function : ~SMESHGUI_SymmetryDlg()
340 // purpose : Destroys the object and frees any allocated resources
341 //=================================================================================
342 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
344 // no need to delete child widgets, Qt does it all for us
347 //=================================================================================
350 //=================================================================================
351 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
355 myEditCurrentArgument = 0;
356 LineEditElements->clear();
360 buttonOk->setEnabled(false);
361 buttonApply->setEnabled(false);
364 myMesh = SMESH::SMESH_Mesh::_nil();
367 SpinBox_X->SetValue(0.0);
368 SpinBox_Y->SetValue(0.0);
369 SpinBox_Z->SetValue(0.0);
370 SpinBox_DX->SetValue(0.0);
371 SpinBox_DY->SetValue(0.0);
372 SpinBox_DZ->SetValue(0.0);
374 CheckBoxCopy->setChecked(false);
375 CheckBoxMesh->setChecked(false);
380 //=================================================================================
381 // function : ConstructorsClicked()
382 // purpose : Radio button management
383 //=================================================================================
384 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
386 disconnect(mySelectionMgr, 0, this, 0);
388 if (constructorId != 0 && !TextLabelVector->isVisible()) {
389 TextLabelVector->show();
390 SelectVectorButton->show();
399 switch (constructorId) {
402 GroupMirror->setTitle(tr("SMESH_POINT"));
404 TextLabelVector->hide();
405 SelectVectorButton->hide();
416 GroupMirror->setTitle(tr("SMESH_AXIS"));
417 TextLabelVector->setText(tr("SMESH_VECTOR"));
422 GroupMirror->setTitle(tr("SMESH_PLANE"));
423 TextLabelVector->setText(tr("SMESH_NORMAL"));
428 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
429 SMESH::SetPointRepresentation(false);
430 if (!CheckBoxMesh->isChecked())
432 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
433 aViewWindow->SetSelectionMode(CellSelection);
437 myEditCurrentArgument = (QWidget*)LineEditElements;
438 LineEditElements->setFocus();
440 if (CheckBoxMesh->isChecked())
443 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
446 //=================================================================================
447 // function : ClickOnApply()
449 //=================================================================================
450 void SMESHGUI_SymmetryDlg::ClickOnApply()
452 if (mySMESHGUI->isActiveStudyLocked())
455 if (myNbOkElements && IsMirrorOk()) {
456 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
458 SMESH::long_array_var anElementsId = new SMESH::long_array;
460 anElementsId->length(aListElementsId.count());
461 for (int i = 0; i < aListElementsId.count(); i++)
462 anElementsId[i] = aListElementsId[i].toInt();
464 SMESH::AxisStruct aMirror;
466 aMirror.x = SpinBox_X->GetValue();
467 aMirror.y = SpinBox_Y->GetValue();
468 aMirror.z = SpinBox_Z->GetValue();
469 if (GetConstructorId() == 0) {
470 aMirror.vx = aMirror.vy = aMirror.vz = 0;
472 aMirror.vx = SpinBox_DX->GetValue();
473 aMirror.vy = SpinBox_DY->GetValue();
474 aMirror.vz = SpinBox_DZ->GetValue();
477 bool toCreateCopy = CheckBoxCopy->isChecked();
479 SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
481 if (GetConstructorId() == 0)
482 aMirrorType = SMESH::SMESH_MeshEditor::POINT;
483 if (GetConstructorId() == 1)
484 aMirrorType = SMESH::SMESH_MeshEditor::AXIS;
485 if (GetConstructorId() == 2)
486 aMirrorType = SMESH::SMESH_MeshEditor::PLANE;
489 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
490 QApplication::setOverrideCursor(Qt::waitCursor);
491 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy);
492 QApplication::restoreOverrideCursor();
498 ConstructorsClicked(GetConstructorId());
499 SelectionIntoArgument();
503 //=================================================================================
504 // function : ClickOnOk()
506 //=================================================================================
507 void SMESHGUI_SymmetryDlg::ClickOnOk()
513 //=================================================================================
514 // function : ClickOnCancel()
516 //=================================================================================
517 void SMESHGUI_SymmetryDlg::ClickOnCancel()
519 disconnect(mySelectionMgr, 0, this, 0);
520 mySelectionMgr->clearFilters();
521 //mySelectionMgr->clearSelected();
522 SMESH::SetPointRepresentation(false);
523 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
524 aViewWindow->SetSelectionMode(ActorSelection);
525 mySMESHGUI->ResetState();
529 //=================================================================================
530 // function : ClickOnHelp()
532 //=================================================================================
533 void SMESHGUI_SymmetryDlg::ClickOnHelp()
535 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
537 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
539 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
540 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
541 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
542 QObject::tr("BUT_OK"));
546 //=======================================================================
547 // function : onTextChange()
549 //=======================================================================
550 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
552 QLineEdit* send = (QLineEdit*)sender();
557 if (send == LineEditElements)
560 buttonOk->setEnabled(false);
561 buttonApply->setEnabled(false);
563 // hilight entered elements
564 SMDS_Mesh* aMesh = 0;
566 aMesh = myActor->GetObject()->GetMesh();
569 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
571 TColStd_MapOfInteger newIndices;
573 QStringList aListId = QStringList::split(" ", theNewText, false);
575 if (send == LineEditElements) {
576 for (int i = 0; i < aListId.count(); i++) {
577 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
579 newIndices.Add(e->GetID());
583 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
584 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
585 aViewWindow->highlight( anIO, true, true );
587 myElementsId = theNewText;
591 if (myNbOkElements && IsMirrorOk()) {
592 buttonOk->setEnabled(true);
593 buttonApply->setEnabled(true);
599 //=================================================================================
600 // function : SelectionIntoArgument()
601 // purpose : Called when selection as changed or other case
602 //=================================================================================
603 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
609 QString aString = "";
612 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
613 LineEditElements->setText(aString);
615 buttonOk->setEnabled(false);
616 buttonApply->setEnabled(false);
620 if (!GroupButtons->isEnabled()) // inactive
625 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
627 int nbSel = aList.Extent();
631 Handle(SALOME_InteractiveObject) IO = aList.First();
632 myMesh = SMESH::GetMeshByIO(IO);
633 if(myMesh->_is_nil())
636 myActor = SMESH::FindActorByObject(myMesh);
638 myActor = SMESH::FindActorByEntry(IO->getEntry());
644 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
647 if (CheckBoxMesh->isChecked()) {
648 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
650 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
652 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
656 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
657 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
659 myElementsId += QString(" %1").arg(i);
663 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
665 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
667 // get IDs from submesh
668 SMESH::long_array_var anElementsIds = new SMESH::long_array;
669 anElementsIds = aSubMesh->GetElementsId();
670 for (int i = 0; i < anElementsIds->length(); i++) {
671 myElementsId += QString(" %1").arg(anElementsIds[i]);
673 aNbUnits = anElementsIds->length();
676 SMESH::SMESH_GroupBase_var aGroup =
677 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
678 if (aGroup->_is_nil())
681 // get IDs from smesh group
682 SMESH::long_array_var anElementsIds = new SMESH::long_array;
683 anElementsIds = aGroup->GetListOfID();
684 for (int i = 0; i < anElementsIds->length(); i++) {
685 myElementsId += QString(" %1").arg(anElementsIds[i]);
687 aNbUnits = anElementsIds->length();
690 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, myActor->getIO(), aString);
691 myElementsId = aString;
697 myNbOkElements = true;
699 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
703 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
707 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
715 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
716 SpinBox_X->SetValue(x);
717 SpinBox_Y->SetValue(y);
718 SpinBox_Z->SetValue(z);
719 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
720 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
721 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
722 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
727 if (myEditCurrentArgument == (QWidget*)LineEditElements)
728 LineEditElements->setText(aString);
732 if (myNbOkElements && IsMirrorOk()) {
733 buttonOk->setEnabled(true);
734 buttonApply->setEnabled(true);
738 //=================================================================================
739 // function : SetEditCurrentArgument()
741 //=================================================================================
742 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
744 QPushButton* send = (QPushButton*)sender();
746 disconnect(mySelectionMgr, 0, this, 0);
747 mySelectionMgr->clearSelected();
748 mySelectionMgr->clearFilters();
750 if (send == SelectElementsButton) {
751 myEditCurrentArgument = (QWidget*)LineEditElements;
752 SMESH::SetPointRepresentation(false);
753 if (CheckBoxMesh->isChecked()) {
754 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
755 aViewWindow->SetSelectionMode(ActorSelection);
756 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
758 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
759 aViewWindow->SetSelectionMode(CellSelection);
761 } else if (send == SelectPointButton) {
762 myEditCurrentArgument = (QWidget*)SpinBox_X;
763 SMESH::SetPointRepresentation(true);
764 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
765 aViewWindow->SetSelectionMode(NodeSelection);
766 } else if (send == SelectVectorButton) {
767 myEditCurrentArgument = (QWidget*)SpinBox_DX;
768 SMESH::SetPointRepresentation(true);
770 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
771 aViewWindow->SetSelectionMode(NodeSelection);
775 myEditCurrentArgument->setFocus();
776 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
777 SelectionIntoArgument();
780 //=================================================================================
781 // function : DeactivateActiveDialog()
783 //=================================================================================
784 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
786 if (GroupConstructors->isEnabled()) {
787 GroupConstructors->setEnabled(false);
788 GroupArguments->setEnabled(false);
789 GroupButtons->setEnabled(false);
790 mySMESHGUI->ResetState();
791 mySMESHGUI->SetActiveDialogBox(0);
795 //=================================================================================
796 // function : ActivateThisDialog()
798 //=================================================================================
799 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
801 /* Emit a signal to deactivate the active dialog */
802 mySMESHGUI->EmitSignalDeactivateDialog();
803 GroupConstructors->setEnabled(true);
804 GroupArguments->setEnabled(true);
805 GroupButtons->setEnabled(true);
807 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
809 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
810 aViewWindow->SetSelectionMode(CellSelection);
811 SelectionIntoArgument();
814 //=================================================================================
815 // function : enterEvent()
817 //=================================================================================
818 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
820 if (!GroupConstructors->isEnabled())
821 ActivateThisDialog();
824 //=================================================================================
825 // function : closeEvent()
827 //=================================================================================
828 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
830 /* same than click on cancel button */
831 this->ClickOnCancel();
834 //=======================================================================
835 // function : hideEvent()
836 // purpose : caused by ESC key
837 //=======================================================================
838 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
844 //=======================================================================
845 //function : onSelectMesh
847 //=======================================================================
848 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
851 TextLabelElements->setText(tr("SMESH_NAME"));
853 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
855 if (myEditCurrentArgument != LineEditElements) {
856 LineEditElements->clear();
860 mySelectionMgr->clearFilters();
861 SMESH::SetPointRepresentation(false);
864 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
865 aViewWindow->SetSelectionMode(ActorSelection);
866 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
867 LineEditElements->setReadOnly(true);
869 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
870 aViewWindow->SetSelectionMode(CellSelection);
871 LineEditElements->setReadOnly(false);
872 onTextChange(LineEditElements->text());
875 SelectionIntoArgument();
878 //=================================================================================
879 // function : GetConstructorId()
881 //=================================================================================
882 int SMESHGUI_SymmetryDlg::GetConstructorId()
884 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
885 return GroupConstructors->id(GroupConstructors->selected());
889 //=================================================================================
890 // function : IsMirrorOk()
892 //=================================================================================
893 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
897 if (GetConstructorId() != 0)
898 isOk = (SpinBox_DX->GetValue() != 0 ||
899 SpinBox_DY->GetValue() != 0 ||
900 SpinBox_DZ->GetValue() != 0);
905 //=================================================================================
906 // function : onVectorChanged()
908 //=================================================================================
909 void SMESHGUI_SymmetryDlg::onVectorChanged()
912 buttonOk->setEnabled(true);
913 buttonApply->setEnabled(true);
915 buttonOk->setEnabled(false);
916 buttonApply->setEnabled(false);