1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_SymmetryDlg.cxx
24 // Author : Michael ZORIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_SymmetryDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_FilterDlg.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TypeFilter.hxx>
39 #include <SMESH_LogicalFilter.hxx>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_Desktop.h>
44 #include <SUIT_ResourceMgr.h>
45 #include <SUIT_Session.h>
46 #include <SUIT_MessageBox.h>
47 #include <SUIT_OverrideCursor.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_SelectionMgr.h>
52 #include <SVTK_ViewModel.h>
53 #include <SVTK_ViewWindow.h>
54 #include <SALOME_ListIO.hxx>
56 // SALOME KERNEL includes
57 #include <SALOMEDSClient_SObject.hxx>
60 #include <TColStd_MapOfInteger.hxx>
63 #include <QApplication>
64 #include <QButtonGroup>
68 #include <QPushButton>
69 #include <QRadioButton>
71 #include <QHBoxLayout>
72 #include <QVBoxLayout>
73 #include <QGridLayout>
77 #include <SALOMEconfig.h>
78 #include CORBA_SERVER_HEADER(SMESH_Group)
79 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
81 enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action type
86 //=================================================================================
87 // class : SMESHGUI_SymmetryDlg()
89 //=================================================================================
91 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule )
92 : QDialog( SMESH::GetDesktop( theModule ) ),
93 mySMESHGUI( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
97 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
98 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
99 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
100 QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
103 setAttribute(Qt::WA_DeleteOnClose, true);
104 setWindowTitle(tr("SMESH_SYMMETRY"));
105 setSizeGripEnabled(true);
107 QVBoxLayout* SMESHGUI_SymmetryDlgLayout = new QVBoxLayout(this);
108 SMESHGUI_SymmetryDlgLayout->setSpacing(SPACING);
109 SMESHGUI_SymmetryDlgLayout->setMargin(MARGIN);
111 /***************************************************************/
112 ConstructorsBox = new QGroupBox(tr("SMESH_SYMMETRY"), this);
113 GroupConstructors = new QButtonGroup(this);
114 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
115 ConstructorsBoxLayout->setSpacing(SPACING);
116 ConstructorsBoxLayout->setMargin(MARGIN);
118 RadioButton1 = new QRadioButton(ConstructorsBox);
119 RadioButton1->setIcon(image0);
120 RadioButton2 = new QRadioButton(ConstructorsBox);
121 RadioButton2->setIcon(image1);
122 RadioButton3 = new QRadioButton(ConstructorsBox);
123 RadioButton3->setIcon(image2);
125 ConstructorsBoxLayout->addWidget(RadioButton1);
126 ConstructorsBoxLayout->addWidget(RadioButton2);
127 ConstructorsBoxLayout->addWidget(RadioButton3);
128 GroupConstructors->addButton(RadioButton1, 0);
129 GroupConstructors->addButton(RadioButton2, 1);
130 GroupConstructors->addButton(RadioButton3, 2);
132 /***************************************************************/
133 GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
134 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
135 GroupArgumentsLayout->setSpacing(SPACING);
136 GroupArgumentsLayout->setMargin(MARGIN);
138 myIdValidator = new SMESHGUI_IdValidator(this);
140 // Controls for elements selection
141 TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
142 SelectElementsButton = new QPushButton(GroupArguments);
143 SelectElementsButton->setIcon(image3);
144 LineEditElements = new QLineEdit(GroupArguments);
145 LineEditElements->setValidator(myIdValidator);
146 QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
147 connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
149 // Control for the whole mesh selection
150 CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
152 // Controls for mirror selection
153 GroupMirror = new QGroupBox(GroupArguments);
154 QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror);
155 GroupMirrorLayout->setSpacing(SPACING);
156 GroupMirrorLayout->setMargin(MARGIN);
158 TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupMirror);
159 SelectPointButton = new QPushButton(GroupMirror);
160 SelectPointButton->setIcon(image3);
162 TextLabelX = new QLabel(tr("SMESH_X"), GroupMirror);
163 SpinBox_X = new SMESHGUI_SpinBox(GroupMirror);
164 TextLabelY = new QLabel(tr("SMESH_Y"), GroupMirror);
165 SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror);
166 TextLabelZ = new QLabel(tr("SMESH_Z"), GroupMirror);
167 SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror);
169 TextLabelVector = new QLabel(GroupMirror);
170 SelectVectorButton = new QPushButton(GroupMirror);
171 SelectVectorButton->setIcon(image3);
173 TextLabelDX = new QLabel(tr("SMESH_DX"), GroupMirror);
174 SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror);
175 TextLabelDY = new QLabel(tr("SMESH_DY"), GroupMirror);
176 SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror);
177 TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupMirror);
178 SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror);
180 GroupMirrorLayout->addWidget(TextLabelPoint, 0, 0);
181 GroupMirrorLayout->addWidget(SelectPointButton, 0, 1);
182 GroupMirrorLayout->addWidget(TextLabelX, 0, 2);
183 GroupMirrorLayout->addWidget(SpinBox_X, 0, 3);
184 GroupMirrorLayout->addWidget(TextLabelY, 0, 4);
185 GroupMirrorLayout->addWidget(SpinBox_Y, 0, 5);
186 GroupMirrorLayout->addWidget(TextLabelZ, 0, 6);
187 GroupMirrorLayout->addWidget(SpinBox_Z, 0, 7);
188 GroupMirrorLayout->addWidget(TextLabelVector, 1, 0);
189 GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
190 GroupMirrorLayout->addWidget(TextLabelDX, 1, 2);
191 GroupMirrorLayout->addWidget(SpinBox_DX, 1, 3);
192 GroupMirrorLayout->addWidget(TextLabelDY, 1, 4);
193 GroupMirrorLayout->addWidget(SpinBox_DY, 1, 5);
194 GroupMirrorLayout->addWidget(TextLabelDZ, 1, 6);
195 GroupMirrorLayout->addWidget(SpinBox_DZ, 1, 7);
197 // switch of action type
198 ActionBox = new QGroupBox(GroupArguments);
199 ActionGroup = new QButtonGroup(GroupArguments);
200 QVBoxLayout* ActionBoxLayout = new QVBoxLayout(ActionBox);
201 ActionBoxLayout->addSpacing(SPACING);
202 ActionBoxLayout->setMargin(MARGIN);
204 QRadioButton* aMoveElements = new QRadioButton(tr("SMESH_MOVE_ELEMENTS"), ActionBox);
205 QRadioButton* aCopyElements = new QRadioButton(tr("SMESH_COPY_ELEMENTS"), ActionBox);
206 QRadioButton* aCreateMesh = new QRadioButton(tr("SMESH_CREATE_MESH"), ActionBox);
208 ActionBoxLayout->addWidget(aMoveElements);
209 ActionBoxLayout->addWidget(aCopyElements);
210 ActionBoxLayout->addWidget(aCreateMesh);
211 ActionGroup->addButton(aMoveElements, MOVE_ELEMS_BUTTON);
212 ActionGroup->addButton(aCopyElements, COPY_ELEMS_BUTTON);
213 ActionGroup->addButton(aCreateMesh, MAKE_MESH_BUTTON);
215 // CheckBox for groups generation
216 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
217 MakeGroupsCheck->setChecked(false);
219 // Name of a mesh to create
220 LineEditNewMesh = new QLineEdit(GroupArguments);
223 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
224 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
225 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 1);
226 GroupArgumentsLayout->addWidget(filterBtn, 0, 3);
227 GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
228 GroupArgumentsLayout->addWidget(GroupMirror, 2, 0, 1, 4);
229 GroupArgumentsLayout->addWidget(ActionBox, 3, 0, 3, 3);
230 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 4, 3);
231 GroupArgumentsLayout->addWidget(LineEditNewMesh, 5, 3);
233 /***************************************************************/
234 GroupButtons = new QGroupBox(this);
235 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
236 GroupButtonsLayout->setSpacing(SPACING);
237 GroupButtonsLayout->setMargin(MARGIN);
239 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
240 buttonOk->setAutoDefault(true);
241 buttonOk->setDefault(true);
242 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
243 buttonApply->setAutoDefault(true);
244 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
245 buttonCancel->setAutoDefault(true);
246 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
247 buttonHelp->setAutoDefault(true);
249 GroupButtonsLayout->addWidget(buttonOk);
250 GroupButtonsLayout->addSpacing(10);
251 GroupButtonsLayout->addWidget(buttonApply);
252 GroupButtonsLayout->addSpacing(10);
253 GroupButtonsLayout->addStretch();
254 GroupButtonsLayout->addWidget(buttonCancel);
255 GroupButtonsLayout->addWidget(buttonHelp);
257 /***************************************************************/
258 SMESHGUI_SymmetryDlgLayout->addWidget(ConstructorsBox);
259 SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments);
260 SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons);
262 /* Initialisations */
263 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
264 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
265 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
266 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
267 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
268 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
270 RadioButton1->setChecked(true);
272 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
274 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
276 // Costruction of the logical filter
277 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
278 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
280 QList<SUIT_SelectionFilter*> aListOfFilters;
281 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
282 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
284 myMeshOrSubMeshOrGroupFilter =
285 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
287 myHelpFileName = "symmetry_page.html";
291 /* signals and slots connections */
292 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
293 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
294 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
295 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
296 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
298 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
299 connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
300 connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
302 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
303 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
304 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
306 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
307 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
308 /* to close dialog if study change */
309 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
310 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
311 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
312 connect(ActionGroup, SIGNAL(buttonClicked(int)), SLOT(onActionClicked(int)));
314 ConstructorsClicked(0);
315 SelectionIntoArgument();
316 onActionClicked(MOVE_ELEMS_BUTTON);
319 //=================================================================================
320 // function : ~SMESHGUI_SymmetryDlg()
321 // purpose : Destroys the object and frees any allocated resources
322 //=================================================================================
323 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
325 if ( myFilterDlg != 0 ) {
326 myFilterDlg->setParent( 0 );
331 //=================================================================================
334 //=================================================================================
335 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
339 myEditCurrentArgument = 0;
340 LineEditElements->clear();
344 buttonOk->setEnabled(false);
345 buttonApply->setEnabled(false);
348 myMesh = SMESH::SMESH_Mesh::_nil();
351 SpinBox_X->SetValue(0.0);
352 SpinBox_Y->SetValue(0.0);
353 SpinBox_Z->SetValue(0.0);
354 SpinBox_DX->SetValue(0.0);
355 SpinBox_DY->SetValue(0.0);
356 SpinBox_DZ->SetValue(0.0);
358 ActionGroup->button( MOVE_ELEMS_BUTTON )->setChecked(true);
359 CheckBoxMesh->setChecked(false);
360 // MakeGroupsCheck->setChecked(false);
361 // MakeGroupsCheck->setEnabled(false);
366 //=================================================================================
367 // function : ConstructorsClicked()
368 // purpose : Radio button management
369 //=================================================================================
370 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
372 disconnect(mySelectionMgr, 0, this, 0);
374 if (constructorId != 0 && !TextLabelVector->isVisible()) {
375 TextLabelVector->show();
376 SelectVectorButton->show();
385 switch (constructorId) {
388 GroupMirror->setTitle(tr("SMESH_POINT"));
390 TextLabelVector->hide();
391 SelectVectorButton->hide();
402 GroupMirror->setTitle(tr("SMESH_AXIS"));
403 TextLabelVector->setText(tr("SMESH_VECTOR"));
408 GroupMirror->setTitle(tr("SMESH_PLANE"));
409 TextLabelVector->setText(tr("SMESH_NORMAL"));
414 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
415 SMESH::SetPointRepresentation(false);
416 if (!CheckBoxMesh->isChecked())
418 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
419 aViewWindow->SetSelectionMode(CellSelection);
423 myEditCurrentArgument = (QWidget*)LineEditElements;
424 LineEditElements->setFocus();
426 if (CheckBoxMesh->isChecked())
429 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
431 QApplication::instance()->processEvents();
433 resize( minimumSize() );
436 //=================================================================================
437 // function : ClickOnApply()
439 //=================================================================================
440 void SMESHGUI_SymmetryDlg::ClickOnApply()
442 if (mySMESHGUI->isActiveStudyLocked())
445 if (myNbOkElements && IsMirrorOk()) {
446 QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
448 SMESH::long_array_var anElementsId = new SMESH::long_array;
450 anElementsId->length(aListElementsId.count());
451 for (int i = 0; i < aListElementsId.count(); i++)
452 anElementsId[i] = aListElementsId[i].toInt();
454 SMESH::AxisStruct aMirror;
456 aMirror.x = SpinBox_X->GetValue();
457 aMirror.y = SpinBox_Y->GetValue();
458 aMirror.z = SpinBox_Z->GetValue();
459 if (GetConstructorId() == 0) {
460 aMirror.vx = aMirror.vy = aMirror.vz = 0;
462 aMirror.vx = SpinBox_DX->GetValue();
463 aMirror.vy = SpinBox_DY->GetValue();
464 aMirror.vz = SpinBox_DZ->GetValue();
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;
477 int actionButton = ActionGroup->checkedId();
478 bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
481 SUIT_OverrideCursor aWaitCursor;
482 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
484 switch ( actionButton ) {
485 case MOVE_ELEMS_BUTTON:
486 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
488 case COPY_ELEMS_BUTTON:
490 SMESH::ListOfGroups_var groups =
491 aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType);
493 aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
495 case MAKE_MESH_BUTTON:
496 SMESH::SMESH_Mesh_var mesh =
497 aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
498 LineEditNewMesh->text().toLatin1().data());
504 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
505 actionButton == MAKE_MESH_BUTTON )
506 mySMESHGUI->updateObjBrowser(true); // new groups may appear
508 ConstructorsClicked(GetConstructorId());
509 SelectionIntoArgument();
513 //=================================================================================
514 // function : ClickOnOk()
516 //=================================================================================
517 void SMESHGUI_SymmetryDlg::ClickOnOk()
523 //=================================================================================
524 // function : ClickOnCancel()
526 //=================================================================================
527 void SMESHGUI_SymmetryDlg::ClickOnCancel()
529 disconnect(mySelectionMgr, 0, this, 0);
530 mySelectionMgr->clearFilters();
531 //mySelectionMgr->clearSelected();
532 if (SMESH::GetCurrentVtkView()) {
533 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
534 SMESH::SetPointRepresentation(false);
536 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
537 aViewWindow->SetSelectionMode(ActorSelection);
538 mySMESHGUI->ResetState();
542 //=================================================================================
543 // function : ClickOnHelp()
545 //=================================================================================
546 void SMESHGUI_SymmetryDlg::ClickOnHelp()
548 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
550 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
554 platform = "winapplication";
556 platform = "application";
558 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
559 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
560 arg(app->resourceMgr()->stringValue("ExternalBrowser",
562 arg(myHelpFileName));
566 //=======================================================================
567 // function : onTextChange()
569 //=======================================================================
570 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
572 QLineEdit* send = (QLineEdit*)sender();
577 if (send == LineEditElements)
580 buttonOk->setEnabled(false);
581 buttonApply->setEnabled(false);
583 // hilight entered elements
584 SMDS_Mesh* aMesh = 0;
586 aMesh = myActor->GetObject()->GetMesh();
589 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
591 TColStd_MapOfInteger newIndices;
593 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
595 if (send == LineEditElements) {
596 for (int i = 0; i < aListId.count(); i++) {
597 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
599 newIndices.Add(e->GetID());
603 mySelector->AddOrRemoveIndex( anIO, newIndices, false );
604 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
605 aViewWindow->highlight( anIO, true, true );
607 myElementsId = theNewText;
611 if (myNbOkElements && IsMirrorOk()) {
612 buttonOk->setEnabled(true);
613 buttonApply->setEnabled(true);
619 //=================================================================================
620 // function : SelectionIntoArgument()
621 // purpose : Called when selection as changed or other case
622 //=================================================================================
623 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
629 QString aString = "";
632 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
633 LineEditElements->setText(aString);
635 buttonOk->setEnabled(false);
636 buttonApply->setEnabled(false);
640 if (!GroupButtons->isEnabled()) // inactive
645 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
647 int nbSel = aList.Extent();
651 Handle(SALOME_InteractiveObject) IO = aList.First();
652 myMesh = SMESH::GetMeshByIO(IO);
653 if(myMesh->_is_nil())
656 myActor = SMESH::FindActorByObject(myMesh);
658 myActor = SMESH::FindActorByEntry(IO->getEntry());
664 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
667 // MakeGroups is available if there are groups and "Copy"
668 if ( myMesh->NbGroups() == 0 ) {
669 MakeGroupsCheck->setChecked(false);
670 MakeGroupsCheck->setEnabled(false);
672 else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
673 MakeGroupsCheck->setEnabled(true);
675 if (CheckBoxMesh->isChecked()) {
676 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
678 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
680 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
684 for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
685 const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
687 myElementsId += QString(" %1").arg(i);
691 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
693 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
695 // get IDs from submesh
696 SMESH::long_array_var anElementsIds = new SMESH::long_array;
697 anElementsIds = aSubMesh->GetElementsId();
698 for (int i = 0; i < anElementsIds->length(); i++) {
699 myElementsId += QString(" %1").arg(anElementsIds[i]);
701 aNbUnits = anElementsIds->length();
704 SMESH::SMESH_GroupBase_var aGroup =
705 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
706 if (aGroup->_is_nil())
709 // get IDs from smesh group
710 SMESH::long_array_var anElementsIds = new SMESH::long_array;
711 anElementsIds = aGroup->GetListOfID();
712 for (int i = 0; i < anElementsIds->length(); i++) {
713 myElementsId += QString(" %1").arg(anElementsIds[i]);
715 aNbUnits = anElementsIds->length();
718 aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString);
719 myElementsId = aString;
725 myNbOkElements = true;
727 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
731 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
735 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
743 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
744 SpinBox_X->SetValue(x);
745 SpinBox_Y->SetValue(y);
746 SpinBox_Z->SetValue(z);
747 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
748 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
749 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
750 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
755 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
756 LineEditElements->setText(aString);
757 LineEditElements->repaint();
758 LineEditElements->setEnabled(false); // to update lineedit IPAL 19809
759 LineEditElements->setEnabled(true);
765 if (myNbOkElements && IsMirrorOk()) {
766 buttonOk->setEnabled(true);
767 buttonApply->setEnabled(true);
771 //=================================================================================
772 // function : SetEditCurrentArgument()
774 //=================================================================================
775 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
777 QPushButton* send = (QPushButton*)sender();
779 disconnect(mySelectionMgr, 0, this, 0);
780 mySelectionMgr->clearSelected();
781 mySelectionMgr->clearFilters();
783 if (send == SelectElementsButton) {
784 myEditCurrentArgument = (QWidget*)LineEditElements;
785 SMESH::SetPointRepresentation(false);
786 if (CheckBoxMesh->isChecked()) {
787 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
788 aViewWindow->SetSelectionMode(ActorSelection);
789 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
791 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
792 aViewWindow->SetSelectionMode(CellSelection);
794 } else if (send == SelectPointButton) {
795 myEditCurrentArgument = (QWidget*)SpinBox_X;
796 SMESH::SetPointRepresentation(true);
797 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
798 aViewWindow->SetSelectionMode(NodeSelection);
799 } else if (send == SelectVectorButton) {
800 myEditCurrentArgument = (QWidget*)SpinBox_DX;
801 SMESH::SetPointRepresentation(true);
803 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
804 aViewWindow->SetSelectionMode(NodeSelection);
808 myEditCurrentArgument->setFocus();
809 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
810 SelectionIntoArgument();
813 //=================================================================================
814 // function : DeactivateActiveDialog()
816 //=================================================================================
817 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
819 if (ConstructorsBox->isEnabled()) {
820 ConstructorsBox->setEnabled(false);
821 GroupArguments->setEnabled(false);
822 GroupButtons->setEnabled(false);
823 mySMESHGUI->ResetState();
824 mySMESHGUI->SetActiveDialogBox(0);
828 //=================================================================================
829 // function : ActivateThisDialog()
831 //=================================================================================
832 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
834 /* Emit a signal to deactivate the active dialog */
835 mySMESHGUI->EmitSignalDeactivateDialog();
836 ConstructorsBox->setEnabled(true);
837 GroupArguments->setEnabled(true);
838 GroupButtons->setEnabled(true);
840 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
842 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
843 aViewWindow->SetSelectionMode(CellSelection);
844 SelectionIntoArgument();
847 //=================================================================================
848 // function : enterEvent()
850 //=================================================================================
851 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
853 if (!ConstructorsBox->isEnabled())
854 ActivateThisDialog();
857 //=================================================================================
858 // function : closeEvent()
860 //=================================================================================
861 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
863 /* same than click on cancel button */
867 //=======================================================================
868 // function : hideEvent()
869 // purpose : caused by ESC key
870 //=======================================================================
871 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
877 //=======================================================================
878 //function : onSelectMesh
880 //=======================================================================
881 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
884 TextLabelElements->setText(tr("SMESH_NAME"));
886 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
888 if (myEditCurrentArgument != LineEditElements) {
889 LineEditElements->clear();
893 mySelectionMgr->clearFilters();
894 SMESH::SetPointRepresentation(false);
897 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
898 aViewWindow->SetSelectionMode(ActorSelection);
899 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
900 LineEditElements->setReadOnly(true);
901 LineEditElements->setValidator(0);
903 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
904 aViewWindow->SetSelectionMode(CellSelection);
905 LineEditElements->setReadOnly(false);
906 LineEditElements->setValidator(myIdValidator);
907 onTextChange(LineEditElements->text());
910 SelectionIntoArgument();
913 //=================================================================================
914 // function : GetConstructorId()
916 //=================================================================================
917 int SMESHGUI_SymmetryDlg::GetConstructorId()
919 return GroupConstructors->checkedId();
922 //=================================================================================
923 // function : IsMirrorOk()
925 //=================================================================================
926 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
930 if (GetConstructorId() != 0)
931 isOk = (SpinBox_DX->GetValue() != 0 ||
932 SpinBox_DY->GetValue() != 0 ||
933 SpinBox_DZ->GetValue() != 0);
938 //=================================================================================
939 // function : onVectorChanged()
941 //=================================================================================
942 void SMESHGUI_SymmetryDlg::onVectorChanged()
945 buttonOk->setEnabled(true);
946 buttonApply->setEnabled(true);
948 buttonOk->setEnabled(false);
949 buttonApply->setEnabled(false);
953 //=======================================================================
954 //function : onActionClicked
955 //purpose : slot called when an action type changed
956 //=======================================================================
958 void SMESHGUI_SymmetryDlg::onActionClicked(int button)
961 case MOVE_ELEMS_BUTTON:
962 MakeGroupsCheck->setEnabled(false);
963 LineEditNewMesh->setEnabled(false);
965 case COPY_ELEMS_BUTTON:
966 LineEditNewMesh->setEnabled(false);
967 MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
968 if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
969 MakeGroupsCheck->setEnabled(true);
971 MakeGroupsCheck->setEnabled(false);
973 case MAKE_MESH_BUTTON:
974 LineEditNewMesh->setEnabled(true);
975 MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
976 if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
977 MakeGroupsCheck->setEnabled(true);
979 MakeGroupsCheck->setEnabled(false);
985 //=======================================================================
986 //function : setNewMeshName
987 //purpose : update contents of LineEditNewMesh
988 //=======================================================================
990 void SMESHGUI_SymmetryDlg::setNewMeshName()
992 LineEditNewMesh->setText("");
993 if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
995 if ( CheckBoxMesh->isChecked() ) {
996 name = LineEditElements->text();
999 _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
1000 name = meshSO->GetName().c_str();
1002 if ( !name.isEmpty() )
1003 LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "mirrored"));
1007 //=================================================================================
1008 // function : keyPressEvent()
1010 //=================================================================================
1011 void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
1013 QDialog::keyPressEvent( e );
1014 if ( e->isAccepted() )
1017 if ( e->key() == Qt::Key_F1 ) {
1023 //=================================================================================
1024 // function : setFilters()
1025 // purpose : SLOT. Called when "Filter" button pressed.
1026 //=================================================================================
1027 void SMESHGUI_SymmetryDlg::setFilters()
1030 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
1032 myFilterDlg->SetSelection();
1033 myFilterDlg->SetMesh( myMesh );
1034 myFilterDlg->SetSourceWg( LineEditElements );
1036 myFilterDlg->show();