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_RevolutionDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_RevolutionDlg.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_ResourceMgr.h"
44 #include "SUIT_Session.h"
45 #include "SUIT_MessageBox.h"
47 #include "LightApp_Application.h"
49 #include "SVTK_ViewModel.h"
50 #include "SVTK_ViewWindow.h"
51 #include "SVTK_Selector.h"
52 #include "SVTK_Selection.h"
53 #include "SALOME_ListIO.hxx"
55 #include "utilities.h"
58 #include <TColStd_MapOfInteger.hxx>
59 #include <TColStd_IndexedMapOfInteger.hxx>
62 #include <qapplication.h>
63 #include <qbuttongroup.h>
64 #include <qgroupbox.h>
66 #include <qlineedit.h>
67 #include <qpushbutton.h>
68 #include <qradiobutton.h>
69 #include <qcheckbox.h>
72 #include <qvalidator.h>
76 #include "SALOMEconfig.h"
77 #include CORBA_SERVER_HEADER(SMESH_Group)
81 //=================================================================================
82 // class : SMESHGUI_RevolutionDlg()
84 //=================================================================================
85 SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* name,
86 bool modal, WFlags fl)
87 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
88 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
89 mySMESHGUI( theModule ),
90 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
92 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
93 QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
94 QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
95 QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
98 setName("SMESHGUI_RevolutionDlg");
100 setCaption(tr("REVOLUTION_AROUND_AXIS"));
101 setSizeGripEnabled(TRUE);
102 SMESHGUI_RevolutionDlgLayout = new QGridLayout(this);
103 SMESHGUI_RevolutionDlgLayout->setSpacing(6);
104 SMESHGUI_RevolutionDlgLayout->setMargin(11);
106 /***************************************************************/
107 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
108 GroupConstructors->setTitle(tr("SMESH_REVOLUTION" ));
109 GroupConstructors->setExclusive(TRUE);
110 GroupConstructors->setColumnLayout(0, Qt::Vertical);
111 GroupConstructors->layout()->setSpacing(0);
112 GroupConstructors->layout()->setMargin(0);
113 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
114 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
115 GroupConstructorsLayout->setSpacing(6);
116 GroupConstructorsLayout->setMargin(11);
117 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
118 RadioButton1->setText(tr("" ));
119 RadioButton1->setPixmap(image0);
120 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
121 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
122 RadioButton2->setText(tr("" ));
123 RadioButton2->setPixmap(image1);
124 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
125 SMESHGUI_RevolutionDlgLayout->addWidget(GroupConstructors, 0, 0);
127 /***************************************************************/
128 GroupButtons = new QGroupBox(this, "GroupButtons");
129 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
130 GroupButtons->setTitle(tr("" ));
131 GroupButtons->setColumnLayout(0, Qt::Vertical);
132 GroupButtons->layout()->setSpacing(0);
133 GroupButtons->layout()->setMargin(0);
134 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
135 GroupButtonsLayout->setAlignment(Qt::AlignTop);
136 GroupButtonsLayout->setSpacing(6);
137 GroupButtonsLayout->setMargin(11);
138 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
139 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
140 buttonHelp->setAutoDefault(TRUE);
141 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
142 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
143 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
144 buttonCancel->setAutoDefault(TRUE);
145 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
146 buttonApply = new QPushButton(GroupButtons, "buttonApply");
147 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
148 buttonApply->setAutoDefault(TRUE);
149 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
150 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
151 GroupButtonsLayout->addItem(spacer_9, 0, 2);
152 buttonOk = new QPushButton(GroupButtons, "buttonOk");
153 buttonOk->setText(tr("SMESH_BUT_OK" ));
154 buttonOk->setAutoDefault(TRUE);
155 buttonOk->setDefault(TRUE);
156 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
157 SMESHGUI_RevolutionDlgLayout->addWidget(GroupButtons, 2, 0);
159 /***************************************************************/
160 GroupArguments = new QGroupBox(this, "GroupArguments");
161 GroupArguments->setTitle(tr("REVOLUTION_1D"));
162 GroupArguments->setColumnLayout(0, Qt::Vertical);
163 GroupArguments->layout()->setSpacing(0);
164 GroupArguments->layout()->setMargin(0);
165 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
166 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
167 GroupArgumentsLayout->setSpacing(6);
168 GroupArgumentsLayout->setMargin(11);
170 // Controls for elements selection
171 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
172 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
173 TextLabelElements->setFixedWidth(74);
174 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
176 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
177 SelectElementsButton->setText(tr("" ));
178 SelectElementsButton->setPixmap(image2);
179 SelectElementsButton->setToggleButton(FALSE);
180 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
182 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
183 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
184 GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
186 // Control for the whole mesh selection
187 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
188 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
189 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 3);
191 // Controls for axis defining
192 GroupAxis = new QGroupBox(GroupArguments, "GroupAxis");
193 GroupAxis->setTitle(tr("SMESH_AXIS"));
194 GroupAxis->setColumnLayout(0, Qt::Vertical);
195 GroupAxis->layout()->setSpacing(0);
196 GroupAxis->layout()->setMargin(0);
197 QGridLayout* GroupAxisLayout = new QGridLayout(GroupAxis->layout());
198 GroupAxisLayout->setAlignment(Qt::AlignTop);
199 GroupAxisLayout->setSpacing(6);
200 GroupAxisLayout->setMargin(11);
202 TextLabelPoint = new QLabel(GroupAxis, "TextLabelPoint");
203 TextLabelPoint->setText(tr("SMESH_POINT"));
204 GroupAxisLayout->addWidget(TextLabelPoint, 0, 0);
206 SelectPointButton = new QPushButton(GroupAxis, "SelectPointButton");
207 SelectPointButton->setPixmap(image2);
208 GroupAxisLayout->addWidget(SelectPointButton, 0, 1);
210 TextLabelX = new QLabel(GroupAxis, "TextLabelX");
211 TextLabelX->setText(tr("SMESH_X"));
212 GroupAxisLayout->addWidget(TextLabelX, 0, 2);
214 SpinBox_X = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_X");
215 GroupAxisLayout->addWidget(SpinBox_X, 0, 3);
217 TextLabelY = new QLabel(GroupAxis, "TextLabelY");
218 TextLabelY->setText(tr("SMESH_Y"));
219 GroupAxisLayout->addWidget(TextLabelY, 0, 4);
221 SpinBox_Y = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Y");
222 GroupAxisLayout->addWidget(SpinBox_Y, 0, 5);
224 TextLabelZ = new QLabel(GroupAxis, "TextLabelZ");
225 TextLabelZ->setText(tr("SMESH_Z"));
226 GroupAxisLayout->addWidget(TextLabelZ, 0, 6);
228 SpinBox_Z = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_Z");
229 GroupAxisLayout->addWidget(SpinBox_Z, 0, 7);
231 TextLabelVector = new QLabel(GroupAxis, "TextLabelVector");
232 TextLabelVector->setText(tr("SMESH_VECTOR"));
233 GroupAxisLayout->addWidget(TextLabelVector, 1, 0);
235 SelectVectorButton = new QPushButton(GroupAxis, "SelectVectorButton");
236 SelectVectorButton->setPixmap(image2);
237 GroupAxisLayout->addWidget(SelectVectorButton, 1, 1);
239 TextLabelDX = new QLabel(GroupAxis, "TextLabelDX");
240 TextLabelDX->setText(tr("SMESH_DX"));
241 GroupAxisLayout->addWidget(TextLabelDX, 1, 2);
243 SpinBox_DX = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DX");
244 GroupAxisLayout->addWidget(SpinBox_DX, 1, 3);
246 TextLabelDY = new QLabel(GroupAxis, "TextLabelDY");
247 TextLabelDY->setText(tr("SMESH_DY"));
248 GroupAxisLayout->addWidget(TextLabelDY, 1, 4);
250 SpinBox_DY = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DY");
251 GroupAxisLayout->addWidget(SpinBox_DY, 1, 5);
253 TextLabelDZ = new QLabel(GroupAxis, "TextLabelDZ");
254 TextLabelDZ->setText(tr("SMESH_DZ"));
255 GroupAxisLayout->addWidget(TextLabelDZ, 1, 6);
257 SpinBox_DZ = new SMESHGUI_SpinBox(GroupAxis, "SpinBox_DZ");
258 GroupAxisLayout->addWidget(SpinBox_DZ, 1, 7);
260 GroupArgumentsLayout->addMultiCellWidget(GroupAxis, 2, 2, 0, 3);
262 // Controls for angle defining
263 TextLabelAngle = new QLabel(GroupArguments, "TextLabelAngle");
264 TextLabelAngle->setText(tr("SMESH_ANGLE" ));
265 GroupArgumentsLayout->addMultiCellWidget(TextLabelAngle, 3, 3, 0, 1);
267 SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle");
268 GroupArgumentsLayout->addWidget(SpinBox_Angle, 3, 2);
270 // Controls for nb. steps defining
271 TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps");
272 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
273 GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 4, 4, 0, 1);
275 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
276 GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 4, 2);
278 // Controls for tolerance defining
279 TextLabelTolerance = new QLabel(GroupArguments, "TextLabelTolerance");
280 TextLabelTolerance->setText(tr("SMESH_TOLERANCE"));
281 GroupArgumentsLayout->addMultiCellWidget(TextLabelTolerance, 5, 5, 0, 1);
283 SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance");
284 GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 5, 2);
286 SMESHGUI_RevolutionDlgLayout->addWidget(GroupArguments, 1, 0);
288 /* Initialisations */
289 SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
290 SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
291 SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
292 SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
293 SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
294 SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
296 SpinBox_Angle->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5.0, 3);
298 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
299 SpinBox_NbSteps->setValidator(anIntValidator);
300 SpinBox_NbSteps->setRange(1, 999999);
302 SpinBox_Tolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.1, 6);
304 GroupArguments->show();
305 RadioButton1->setChecked(TRUE);
307 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
309 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
311 // Costruction of the logical filter
312 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
313 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
315 QPtrList<SUIT_SelectionFilter> aListOfFilters;
316 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
317 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
319 myMeshOrSubMeshOrGroupFilter =
320 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
322 myHelpFileName = "revolution.htm";
326 /* signals and slots connections */
327 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
328 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
329 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
330 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
331 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
333 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
334 connect(SelectPointButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
335 connect(SelectVectorButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
337 connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
338 connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
339 connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
341 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
342 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
343 /* to close dialog if study change */
344 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
345 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
346 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
348 this->show(); /* displays Dialog */
350 ConstructorsClicked(0);
351 SelectionIntoArgument();
355 //=================================================================================
356 // function : ~SMESHGUI_RevolutionDlg()
357 // purpose : Destroys the object and frees any allocated resources
358 //=================================================================================
359 SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
361 // no need to delete child widgets, Qt does it all for us
364 //=================================================================================
367 //=================================================================================
368 void SMESHGUI_RevolutionDlg::Init (bool ResetControls)
372 myEditCurrentArgument = 0;
373 LineEditElements->clear();
378 myMesh = SMESH::SMESH_Mesh::_nil();
381 SpinBox_X->SetValue(0.0);
382 SpinBox_Y->SetValue(0.0);
383 SpinBox_Z->SetValue(0.0);
384 SpinBox_DX->SetValue(0.0);
385 SpinBox_DY->SetValue(0.0);
386 SpinBox_DZ->SetValue(0.0);
388 SpinBox_Angle->SetValue(45);
389 SpinBox_NbSteps->setValue(1);
390 SpinBox_Tolerance->SetValue(1e-05);
392 CheckBoxMesh->setChecked(false);
397 //=================================================================================
398 // function : ConstructorsClicked()
399 // purpose : Radio button management
400 //=================================================================================
401 void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId)
403 disconnect(mySelectionMgr, 0, this, 0);
405 Selection_Mode aSelMode = ActorSelection;
407 switch (constructorId) {
410 GroupArguments->setTitle(tr("REVOLUTION_1D"));
411 aSelMode = EdgeSelection;
416 GroupArguments->setTitle(tr("REVOLUTION_2D"));
417 aSelMode = FaceSelection;
422 if (myEditCurrentArgument != (QWidget*)LineEditElements) {
423 SMESH::SetPointRepresentation(false);
426 if (!CheckBoxMesh->isChecked())
428 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
429 aViewWindow->SetSelectionMode(aSelMode);
432 myEditCurrentArgument = (QWidget*)LineEditElements;
433 LineEditElements->setFocus();
435 if (CheckBoxMesh->isChecked())
438 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
441 //=================================================================================
442 // function : ClickOnApply()
444 //=================================================================================
445 void SMESHGUI_RevolutionDlg::ClickOnApply()
447 if (mySMESHGUI->isActiveStudyLocked())
450 if (myNbOkElements && IsAxisOk()) {
451 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
453 SMESH::long_array_var anElementsId = new SMESH::long_array;
455 anElementsId->length(aListElementsId.count());
456 for (int i = 0; i < aListElementsId.count(); i++)
457 anElementsId[i] = aListElementsId[i].toInt();
459 SMESH::AxisStruct anAxis;
461 anAxis.x = SpinBox_X->GetValue();
462 anAxis.y = SpinBox_Y->GetValue();
463 anAxis.z = SpinBox_Z->GetValue();;
464 anAxis.vx = SpinBox_DX->GetValue();
465 anAxis.vy = SpinBox_DY->GetValue();
466 anAxis.vz = SpinBox_DZ->GetValue();
468 double anAngle = (SpinBox_Angle->GetValue())*PI/180;
469 long aNbSteps = (long)SpinBox_NbSteps->value();
470 double aTolerance = SpinBox_Tolerance->GetValue();
473 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
474 QApplication::setOverrideCursor(Qt::waitCursor);
475 aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance);
476 QApplication::restoreOverrideCursor();
482 ConstructorsClicked(GetConstructorId());
483 SelectionIntoArgument();
487 //=================================================================================
488 // function : ClickOnOk()
490 //=================================================================================
491 void SMESHGUI_RevolutionDlg::ClickOnOk()
497 //=================================================================================
498 // function : ClickOnCancel()
500 //=================================================================================
501 void SMESHGUI_RevolutionDlg::ClickOnCancel()
503 disconnect(mySelectionMgr, 0, this, 0);
504 mySelectionMgr->clearFilters();
505 //mySelectionMgr->clearSelected();
506 SMESH::SetPointRepresentation(false);
507 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
508 aViewWindow->SetSelectionMode(ActorSelection);
509 mySMESHGUI->ResetState();
513 //=================================================================================
514 // function : ClickOnHelp()
516 //=================================================================================
517 void SMESHGUI_RevolutionDlg::ClickOnHelp()
519 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
521 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
525 platform = "winapplication";
527 platform = "application";
529 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
530 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
531 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
532 QObject::tr("BUT_OK"));
536 //=======================================================================
537 // function : onTextChange()
539 //=======================================================================
540 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
542 QLineEdit* send = (QLineEdit*)sender();
547 if (send == LineEditElements)
550 buttonOk->setEnabled(false);
551 buttonApply->setEnabled(false);
553 // hilight entered elements
554 SMDS_Mesh* aMesh = 0;
556 aMesh = myActor->GetObject()->GetMesh();
559 if (send == LineEditElements) {
560 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
562 TColStd_MapOfInteger newIndices;
564 QStringList aListId = QStringList::split(" ", theNewText, false);
566 for (int i = 0; i < aListId.count(); i++) {
567 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
569 newIndices.Add(e->GetID());
573 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
574 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
575 aViewWindow->highlight( myActor->getIO(), true, true );
577 myElementsId = theNewText;
581 if (myNbOkElements && IsAxisOk()) {
582 buttonOk->setEnabled(true);
583 buttonApply->setEnabled(true);
589 //=================================================================================
590 // function : SelectionIntoArgument()
591 // purpose : Called when selection as changed or other case
592 //=================================================================================
593 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
599 QString aString = "";
602 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
603 LineEditElements->setText(aString);
605 buttonOk->setEnabled(false);
606 buttonApply->setEnabled(false);
610 if (!GroupButtons->isEnabled()) // inactive
614 const SALOME_ListIO& aList = mySelector->StoredIObjects();
616 int nbSel = aList.Extent();
620 Handle(SALOME_InteractiveObject) IO = aList.First();
621 myMesh = SMESH::GetMeshByIO(IO);
622 if (myMesh->_is_nil())
625 myActor = SMESH::FindActorByObject(myMesh);
627 myActor = SMESH::FindActorByEntry(IO->getEntry());
633 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
636 if (CheckBoxMesh->isChecked()) {
637 int aConstructorId = GetConstructorId();
639 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
641 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
643 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
647 if (aConstructorId == 0) {
648 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
650 while (anIter->more()) {
651 const SMDS_MeshEdge * edge = anIter->next();
653 myElementsId += QString(" %1").arg(edge->GetID());
657 } else if (aConstructorId == 1) {
658 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
659 while (anIter->more()) {
660 const SMDS_MeshFace * face = anIter->next();
662 myElementsId += QString(" %1").arg(face->GetID());
667 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
669 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
671 // get IDs from submesh
672 SMESH::long_array_var anElementsIds = new SMESH::long_array;
673 if (aConstructorId == 0)
674 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
675 else if (aConstructorId == 1)
676 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
678 for (int i = 0; i < anElementsIds->length(); i++)
679 myElementsId += QString(" %1").arg(anElementsIds[i]);
680 aNbUnits = anElementsIds->length();
683 SMESH::SMESH_GroupBase_var aGroup =
684 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
685 if (aGroup->_is_nil())
688 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
689 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
692 // get IDs from smesh group
693 SMESH::long_array_var anElementsIds = new SMESH::long_array;
694 anElementsIds = aGroup->GetListOfID();
695 for (int i = 0; i < anElementsIds->length(); i++) {
696 myElementsId += QString(" %1").arg(anElementsIds[i]);
698 aNbUnits = anElementsIds->length();
701 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
702 myElementsId = aString;
708 myNbOkElements = true;
710 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
714 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
718 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
726 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
727 SpinBox_X->SetValue(x);
728 SpinBox_Y->SetValue(y);
729 SpinBox_Z->SetValue(z);
730 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
731 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
732 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
733 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
738 if (myEditCurrentArgument == (QWidget*)LineEditElements)
739 LineEditElements->setText(aString);
743 if (myNbOkElements && IsAxisOk()) {
744 buttonOk->setEnabled(true);
745 buttonApply->setEnabled(true);
749 //=================================================================================
750 // function : SetEditCurrentArgument()
752 //=================================================================================
753 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
755 QPushButton* send = (QPushButton*)sender();
757 disconnect(mySelectionMgr, 0, this, 0);
758 mySelectionMgr->clearSelected();
759 mySelectionMgr->clearFilters();
761 if (send == SelectElementsButton) {
762 myEditCurrentArgument = (QWidget*)LineEditElements;
763 SMESH::SetPointRepresentation(false);
764 if (CheckBoxMesh->isChecked()) {
765 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
766 aViewWindow->SetSelectionMode(ActorSelection);
767 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
769 int aConstructorId = GetConstructorId();
770 if (aConstructorId == 0)
772 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
773 aViewWindow->SetSelectionMode(EdgeSelection);
775 else if (aConstructorId == 1)
777 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
778 aViewWindow->SetSelectionMode(FaceSelection);
781 } else if (send == SelectPointButton) {
782 myEditCurrentArgument = (QWidget*)SpinBox_X;
783 SMESH::SetPointRepresentation(true);
784 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
785 aViewWindow->SetSelectionMode(NodeSelection);
786 } else if (send == SelectVectorButton) {
787 myEditCurrentArgument = (QWidget*)SpinBox_DX;
788 SMESH::SetPointRepresentation(true);
789 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
790 aViewWindow->SetSelectionMode(NodeSelection);
794 myEditCurrentArgument->setFocus();
795 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
796 SelectionIntoArgument();
799 //=================================================================================
800 // function : DeactivateActiveDialog()
802 //=================================================================================
803 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
805 if (GroupConstructors->isEnabled()) {
806 GroupConstructors->setEnabled(false);
807 GroupArguments->setEnabled(false);
808 GroupButtons->setEnabled(false);
809 mySMESHGUI->ResetState();
810 mySMESHGUI->SetActiveDialogBox(0);
814 //=================================================================================
815 // function : ActivateThisDialog()
817 //=================================================================================
818 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
820 /* Emit a signal to deactivate the active dialog */
821 mySMESHGUI->EmitSignalDeactivateDialog();
822 GroupConstructors->setEnabled(true);
823 GroupArguments->setEnabled(true);
824 GroupButtons->setEnabled(true);
826 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
828 ConstructorsClicked(GetConstructorId());
829 SelectionIntoArgument();
832 //=================================================================================
833 // function : enterEvent()
835 //=================================================================================
836 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
838 if (!GroupConstructors->isEnabled())
839 ActivateThisDialog();
842 //=================================================================================
843 // function : closeEvent()
845 //=================================================================================
846 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
848 /* same than click on cancel button */
849 this->ClickOnCancel();
852 //=======================================================================
853 // function : hideEvent()
854 // purpose : caused by ESC key
855 //=======================================================================
856 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
862 //=======================================================================
863 //function : onSelectMesh
865 //=======================================================================
866 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
869 TextLabelElements->setText(tr("SMESH_NAME"));
871 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
873 if (myEditCurrentArgument != LineEditElements) {
874 LineEditElements->clear();
878 mySelectionMgr->clearFilters();
879 SMESH::SetPointRepresentation(false);
882 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
883 aViewWindow->SetSelectionMode(ActorSelection);
884 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
885 LineEditElements->setReadOnly(true);
887 int aConstructorId = GetConstructorId();
888 if (aConstructorId == 0)
890 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
891 aViewWindow->SetSelectionMode(EdgeSelection);
893 else if (aConstructorId == 0)
895 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
896 aViewWindow->SetSelectionMode(FaceSelection);
899 LineEditElements->setReadOnly(false);
900 onTextChange(LineEditElements->text());
903 SelectionIntoArgument();
906 //=================================================================================
907 // function : GetConstructorId()
909 //=================================================================================
910 int SMESHGUI_RevolutionDlg::GetConstructorId()
912 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
913 return GroupConstructors->id(GroupConstructors->selected());
917 //=================================================================================
918 // function : IsAxisOk()
920 //=================================================================================
921 bool SMESHGUI_RevolutionDlg::IsAxisOk()
923 return (SpinBox_DX->GetValue() != 0 ||
924 SpinBox_DY->GetValue() != 0 ||
925 SpinBox_DZ->GetValue() != 0);
928 //=================================================================================
929 // function : onVectorChanged()
931 //=================================================================================
932 void SMESHGUI_RevolutionDlg::onVectorChanged()
935 buttonOk->setEnabled(true);
936 buttonApply->setEnabled(true);
938 buttonOk->setEnabled(false);
939 buttonApply->setEnabled(false);
943 //=================================================================================
944 // function : keyPressEvent()
946 //=================================================================================
947 void SMESHGUI_RevolutionDlg::keyPressEvent( QKeyEvent* e )
949 QDialog::keyPressEvent( e );
950 if ( e->isAccepted() )
953 if ( e->key() == Key_F1 )