1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESHGUI_SymmetryDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_SymmetryDlg.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
41 #include "SMDS_Mesh.hxx"
43 #include "SUIT_Desktop.h"
44 #include "SUIT_ResourceMgr.h"
45 #include "SUIT_Session.h"
46 #include "SUIT_MessageBox.h"
48 #include "LightApp_Application.h"
50 #include "SVTK_ViewModel.h"
51 #include "SVTK_ViewWindow.h"
52 #include "SVTK_Selector.h"
53 #include "SVTK_Selection.h"
54 #include "SALOME_ListIO.hxx"
56 #include "utilities.h"
59 #include <TColStd_MapOfInteger.hxx>
60 #include <TColStd_IndexedMapOfInteger.hxx>
63 #include <qapplication.h>
64 #include <qbuttongroup.h>
65 #include <qgroupbox.h>
67 #include <qlineedit.h>
68 #include <qpushbutton.h>
69 #include <qradiobutton.h>
70 #include <qcheckbox.h>
75 #include "SALOMEconfig.h"
76 #include CORBA_SERVER_HEADER(SMESH_Group)
80 //=================================================================================
81 // class : SMESHGUI_SymmetryDlg()
83 //=================================================================================
84 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule, const char* name,
85 bool modal, WFlags fl)
86 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
87 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
88 mySMESHGUI( theModule ),
89 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
91 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
92 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
93 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
94 QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
97 setName("SMESHGUI_SymmetryDlg");
99 setCaption(tr("SMESH_SYMMETRY"));
100 setSizeGripEnabled(TRUE);
101 SMESHGUI_SymmetryDlgLayout = new QGridLayout(this);
102 SMESHGUI_SymmetryDlgLayout->setSpacing(6);
103 SMESHGUI_SymmetryDlgLayout->setMargin(11);
105 /***************************************************************/
106 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
107 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
108 (QSizePolicy::SizeType)0, 0, 0,
109 GroupConstructors->sizePolicy().hasHeightForWidth()));
110 GroupConstructors->setTitle(tr("SMESH_SYMMETRY" ));
111 GroupConstructors->setExclusive(TRUE);
112 GroupConstructors->setColumnLayout(0, Qt::Vertical);
113 GroupConstructors->layout()->setSpacing(0);
114 GroupConstructors->layout()->setMargin(0);
115 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
116 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
117 GroupConstructorsLayout->setSpacing(6);
118 GroupConstructorsLayout->setMargin(11);
119 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
120 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
121 RadioButton1->setText(tr("" ));
122 RadioButton1->setPixmap(image0);
123 RBLayout->addWidget(RadioButton1);
124 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
125 RadioButton2->setText(tr("" ));
126 RadioButton2->setPixmap(image1);
127 RBLayout->addWidget(RadioButton2);
128 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
129 RadioButton3->setText(tr("" ));
130 RadioButton3->setPixmap(image2);
131 RBLayout->addWidget(RadioButton3);
132 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
133 SMESHGUI_SymmetryDlgLayout->addWidget(GroupConstructors, 0, 0);
135 /***************************************************************/
136 GroupButtons = new QGroupBox(this, "GroupButtons");
137 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
138 (QSizePolicy::SizeType)0, 0, 0,
139 GroupButtons->sizePolicy().hasHeightForWidth()));
140 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
141 GroupButtons->setTitle(tr("" ));
142 GroupButtons->setColumnLayout(0, Qt::Vertical);
143 GroupButtons->layout()->setSpacing(0);
144 GroupButtons->layout()->setMargin(0);
145 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
146 GroupButtonsLayout->setAlignment(Qt::AlignTop);
147 GroupButtonsLayout->setSpacing(6);
148 GroupButtonsLayout->setMargin(11);
149 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
150 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
151 buttonHelp->setAutoDefault(TRUE);
152 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
153 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
154 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
155 buttonCancel->setAutoDefault(TRUE);
156 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
157 buttonApply = new QPushButton(GroupButtons, "buttonApply");
158 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
159 buttonApply->setAutoDefault(TRUE);
160 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
161 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
162 GroupButtonsLayout->addItem(spacer_9, 0, 2);
163 buttonOk = new QPushButton(GroupButtons, "buttonOk");
164 buttonOk->setText(tr("SMESH_BUT_OK" ));
165 buttonOk->setAutoDefault(TRUE);
166 buttonOk->setDefault(TRUE);
167 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
168 SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons, 2, 0);
170 /***************************************************************/
171 GroupArguments = new QGroupBox(this, "GroupArguments");
172 GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
173 GroupArguments->setColumnLayout(0, Qt::Vertical);
174 GroupArguments->layout()->setSpacing(0);
175 GroupArguments->layout()->setMargin(0);
176 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
177 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
178 GroupArgumentsLayout->setSpacing(6);
179 GroupArgumentsLayout->setMargin(11);
181 // Controls for elements selection
182 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
183 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
184 TextLabelElements->setFixedWidth(74);
185 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
187 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
188 SelectElementsButton->setText(tr("" ));
189 SelectElementsButton->setPixmap(image3);
190 SelectElementsButton->setToggleButton(FALSE);
191 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
193 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
194 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
195 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
197 // Control for the whole mesh selection
198 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
199 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
200 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 2);
202 // Controls for mirror selection
203 GroupMirror = new QGroupBox(GroupArguments, "GroupMirror");
204 GroupMirror->setColumnLayout(0, Qt::Vertical);
205 GroupMirror->layout()->setSpacing(0);
206 GroupMirror->layout()->setMargin(0);
207 QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror->layout());
208 GroupMirrorLayout->setAlignment(Qt::AlignTop);
209 GroupMirrorLayout->setSpacing(6);
210 GroupMirrorLayout->setMargin(11);
212 TextLabelPoint = new QLabel(GroupMirror, "TextLabelPoint");
213 TextLabelPoint->setText(tr("SMESH_POINT"));
214 GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0);
216 SelectPointButton = new QPushButton(GroupMirror, "SelectPointButton");
217 SelectPointButton->setPixmap(image3);
218 GroupMirrorLayout->addWidget(SelectPointButton, 0, 1);
220 TextLabelX = new QLabel(GroupMirror, "TextLabelX");
221 TextLabelX->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(COORD_MIN, COORD_MAX, 10.0, 3);
281 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
282 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
283 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
284 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
285 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 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);
541 platform = "winapplication";
543 platform = "application";
545 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
546 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
547 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
548 QObject::tr("BUT_OK"));
552 //=======================================================================
553 // function : onTextChange()
555 //=======================================================================
556 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
558 QLineEdit* send = (QLineEdit*)sender();
563 if (send == LineEditElements)
566 buttonOk->setEnabled(false);
567 buttonApply->setEnabled(false);
569 // hilight entered elements
570 SMDS_Mesh* aMesh = 0;
572 aMesh = myActor->GetObject()->GetMesh();
575 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
577 TColStd_MapOfInteger newIndices;
579 QStringList aListId = QStringList::split(" ", theNewText, false);
581 if (send == LineEditElements) {
582 for (int i = 0; i < aListId.count(); i++) {
583 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
585 newIndices.Add(e->GetID());
589 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
590 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
591 aViewWindow->highlight( anIO, true, true );
593 myElementsId = theNewText;
597 if (myNbOkElements && IsMirrorOk()) {
598 buttonOk->setEnabled(true);
599 buttonApply->setEnabled(true);
605 //=================================================================================
606 // function : SelectionIntoArgument()
607 // purpose : Called when selection as changed or other case
608 //=================================================================================
609 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
615 QString aString = "";
618 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
619 LineEditElements->setText(aString);
621 buttonOk->setEnabled(false);
622 buttonApply->setEnabled(false);
626 if (!GroupButtons->isEnabled()) // inactive
631 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
633 int nbSel = aList.Extent();
637 Handle(SALOME_InteractiveObject) IO = aList.First();
638 myMesh = SMESH::GetMeshByIO(IO);
639 if(myMesh->_is_nil())
642 myActor = SMESH::FindActorByObject(myMesh);
644 myActor = SMESH::FindActorByEntry(IO->getEntry());
650 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
653 if (CheckBoxMesh->isChecked()) {
654 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
656 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
658 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
662 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
663 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
665 myElementsId += QString(" %1").arg(i);
669 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
671 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
673 // get IDs from submesh
674 SMESH::long_array_var anElementsIds = new SMESH::long_array;
675 anElementsIds = aSubMesh->GetElementsId();
676 for (int i = 0; i < anElementsIds->length(); i++) {
677 myElementsId += QString(" %1").arg(anElementsIds[i]);
679 aNbUnits = anElementsIds->length();
682 SMESH::SMESH_GroupBase_var aGroup =
683 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
684 if (aGroup->_is_nil())
687 // get IDs from smesh group
688 SMESH::long_array_var anElementsIds = new SMESH::long_array;
689 anElementsIds = aGroup->GetListOfID();
690 for (int i = 0; i < anElementsIds->length(); i++) {
691 myElementsId += QString(" %1").arg(anElementsIds[i]);
693 aNbUnits = anElementsIds->length();
696 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, myActor->getIO(), aString);
697 myElementsId = aString;
703 myNbOkElements = true;
705 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
709 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
713 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
721 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
722 SpinBox_X->SetValue(x);
723 SpinBox_Y->SetValue(y);
724 SpinBox_Z->SetValue(z);
725 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
726 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
727 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
728 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
733 if (myEditCurrentArgument == (QWidget*)LineEditElements)
734 LineEditElements->setText(aString);
738 if (myNbOkElements && IsMirrorOk()) {
739 buttonOk->setEnabled(true);
740 buttonApply->setEnabled(true);
744 //=================================================================================
745 // function : SetEditCurrentArgument()
747 //=================================================================================
748 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
750 QPushButton* send = (QPushButton*)sender();
752 disconnect(mySelectionMgr, 0, this, 0);
753 mySelectionMgr->clearSelected();
754 mySelectionMgr->clearFilters();
756 if (send == SelectElementsButton) {
757 myEditCurrentArgument = (QWidget*)LineEditElements;
758 SMESH::SetPointRepresentation(false);
759 if (CheckBoxMesh->isChecked()) {
760 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
761 aViewWindow->SetSelectionMode(ActorSelection);
762 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
764 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
765 aViewWindow->SetSelectionMode(CellSelection);
767 } else if (send == SelectPointButton) {
768 myEditCurrentArgument = (QWidget*)SpinBox_X;
769 SMESH::SetPointRepresentation(true);
770 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
771 aViewWindow->SetSelectionMode(NodeSelection);
772 } else if (send == SelectVectorButton) {
773 myEditCurrentArgument = (QWidget*)SpinBox_DX;
774 SMESH::SetPointRepresentation(true);
776 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
777 aViewWindow->SetSelectionMode(NodeSelection);
781 myEditCurrentArgument->setFocus();
782 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
783 SelectionIntoArgument();
786 //=================================================================================
787 // function : DeactivateActiveDialog()
789 //=================================================================================
790 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
792 if (GroupConstructors->isEnabled()) {
793 GroupConstructors->setEnabled(false);
794 GroupArguments->setEnabled(false);
795 GroupButtons->setEnabled(false);
796 mySMESHGUI->ResetState();
797 mySMESHGUI->SetActiveDialogBox(0);
801 //=================================================================================
802 // function : ActivateThisDialog()
804 //=================================================================================
805 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
807 /* Emit a signal to deactivate the active dialog */
808 mySMESHGUI->EmitSignalDeactivateDialog();
809 GroupConstructors->setEnabled(true);
810 GroupArguments->setEnabled(true);
811 GroupButtons->setEnabled(true);
813 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
815 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
816 aViewWindow->SetSelectionMode(CellSelection);
817 SelectionIntoArgument();
820 //=================================================================================
821 // function : enterEvent()
823 //=================================================================================
824 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
826 if (!GroupConstructors->isEnabled())
827 ActivateThisDialog();
830 //=================================================================================
831 // function : closeEvent()
833 //=================================================================================
834 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
836 /* same than click on cancel button */
837 this->ClickOnCancel();
840 //=======================================================================
841 // function : hideEvent()
842 // purpose : caused by ESC key
843 //=======================================================================
844 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
850 //=======================================================================
851 //function : onSelectMesh
853 //=======================================================================
854 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
857 TextLabelElements->setText(tr("SMESH_NAME"));
859 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
861 if (myEditCurrentArgument != LineEditElements) {
862 LineEditElements->clear();
866 mySelectionMgr->clearFilters();
867 SMESH::SetPointRepresentation(false);
870 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
871 aViewWindow->SetSelectionMode(ActorSelection);
872 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
873 LineEditElements->setReadOnly(true);
875 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
876 aViewWindow->SetSelectionMode(CellSelection);
877 LineEditElements->setReadOnly(false);
878 onTextChange(LineEditElements->text());
881 SelectionIntoArgument();
884 //=================================================================================
885 // function : GetConstructorId()
887 //=================================================================================
888 int SMESHGUI_SymmetryDlg::GetConstructorId()
890 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
891 return GroupConstructors->id(GroupConstructors->selected());
895 //=================================================================================
896 // function : IsMirrorOk()
898 //=================================================================================
899 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
903 if (GetConstructorId() != 0)
904 isOk = (SpinBox_DX->GetValue() != 0 ||
905 SpinBox_DY->GetValue() != 0 ||
906 SpinBox_DZ->GetValue() != 0);
911 //=================================================================================
912 // function : onVectorChanged()
914 //=================================================================================
915 void SMESHGUI_SymmetryDlg::onVectorChanged()
918 buttonOk->setEnabled(true);
919 buttonApply->setEnabled(true);
921 buttonOk->setEnabled(false);
922 buttonApply->setEnabled(false);
926 //=================================================================================
927 // function : keyPressEvent()
929 //=================================================================================
930 void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
932 QDialog::keyPressEvent( e );
933 if ( e->isAccepted() )
936 if ( e->key() == Key_F1 )