1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_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(-999999.999, +999999.999, 10.0, 3);
290 SpinBox_Y->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
291 SpinBox_Z->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
292 SpinBox_DX->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
293 SpinBox_DY->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
294 SpinBox_DZ->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
296 SpinBox_Angle->RangeStepAndValidator(-999999.999, +999999.999, 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, +999999.999, 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);
523 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
524 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
525 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
526 QObject::tr("BUT_OK"));
530 //=======================================================================
531 // function : onTextChange()
533 //=======================================================================
534 void SMESHGUI_RevolutionDlg::onTextChange (const QString& theNewText)
536 QLineEdit* send = (QLineEdit*)sender();
541 if (send == LineEditElements)
544 buttonOk->setEnabled(false);
545 buttonApply->setEnabled(false);
547 // hilight entered elements
548 SMDS_Mesh* aMesh = 0;
550 aMesh = myActor->GetObject()->GetMesh();
553 if (send == LineEditElements) {
554 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
556 TColStd_MapOfInteger newIndices;
558 QStringList aListId = QStringList::split(" ", theNewText, false);
560 for (int i = 0; i < aListId.count(); i++) {
561 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
563 newIndices.Add(e->GetID());
567 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
568 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
569 aViewWindow->highlight( myActor->getIO(), true, true );
571 myElementsId = theNewText;
575 if (myNbOkElements && IsAxisOk()) {
576 buttonOk->setEnabled(true);
577 buttonApply->setEnabled(true);
583 //=================================================================================
584 // function : SelectionIntoArgument()
585 // purpose : Called when selection as changed or other case
586 //=================================================================================
587 void SMESHGUI_RevolutionDlg::SelectionIntoArgument()
593 QString aString = "";
596 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
597 LineEditElements->setText(aString);
599 buttonOk->setEnabled(false);
600 buttonApply->setEnabled(false);
604 if (!GroupButtons->isEnabled()) // inactive
608 const SALOME_ListIO& aList = mySelector->StoredIObjects();
610 int nbSel = aList.Extent();
614 Handle(SALOME_InteractiveObject) IO = aList.First();
615 myMesh = SMESH::GetMeshByIO(IO);
616 if (myMesh->_is_nil())
619 myActor = SMESH::FindActorByObject(myMesh);
621 myActor = SMESH::FindActorByEntry(IO->getEntry());
627 if (myEditCurrentArgument == (QWidget*)LineEditElements) {
630 if (CheckBoxMesh->isChecked()) {
631 int aConstructorId = GetConstructorId();
633 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
635 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
637 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
641 if (aConstructorId == 0) {
642 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
644 while (anIter->more()) {
645 const SMDS_MeshEdge * edge = anIter->next();
647 myElementsId += QString(" %1").arg(edge->GetID());
651 } else if (aConstructorId == 1) {
652 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
653 while (anIter->more()) {
654 const SMDS_MeshFace * face = anIter->next();
656 myElementsId += QString(" %1").arg(face->GetID());
661 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
663 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
665 // get IDs from submesh
666 SMESH::long_array_var anElementsIds = new SMESH::long_array;
667 if (aConstructorId == 0)
668 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
669 else if (aConstructorId == 1)
670 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
672 for (int i = 0; i < anElementsIds->length(); i++)
673 myElementsId += QString(" %1").arg(anElementsIds[i]);
674 aNbUnits = anElementsIds->length();
677 SMESH::SMESH_GroupBase_var aGroup =
678 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
679 if (aGroup->_is_nil())
682 if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
683 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
686 // get IDs from smesh group
687 SMESH::long_array_var anElementsIds = new SMESH::long_array;
688 anElementsIds = aGroup->GetListOfID();
689 for (int i = 0; i < anElementsIds->length(); i++) {
690 myElementsId += QString(" %1").arg(anElementsIds[i]);
692 aNbUnits = anElementsIds->length();
695 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
696 myElementsId = aString;
702 myNbOkElements = true;
704 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
708 SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
712 const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
720 if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
721 SpinBox_X->SetValue(x);
722 SpinBox_Y->SetValue(y);
723 SpinBox_Z->SetValue(z);
724 } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
725 SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
726 SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
727 SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
732 if (myEditCurrentArgument == (QWidget*)LineEditElements)
733 LineEditElements->setText(aString);
737 if (myNbOkElements && IsAxisOk()) {
738 buttonOk->setEnabled(true);
739 buttonApply->setEnabled(true);
743 //=================================================================================
744 // function : SetEditCurrentArgument()
746 //=================================================================================
747 void SMESHGUI_RevolutionDlg::SetEditCurrentArgument()
749 QPushButton* send = (QPushButton*)sender();
751 disconnect(mySelectionMgr, 0, this, 0);
752 mySelectionMgr->clearSelected();
753 mySelectionMgr->clearFilters();
755 if (send == SelectElementsButton) {
756 myEditCurrentArgument = (QWidget*)LineEditElements;
757 SMESH::SetPointRepresentation(false);
758 if (CheckBoxMesh->isChecked()) {
759 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
760 aViewWindow->SetSelectionMode(ActorSelection);
761 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
763 int aConstructorId = GetConstructorId();
764 if (aConstructorId == 0)
766 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
767 aViewWindow->SetSelectionMode(EdgeSelection);
769 else if (aConstructorId == 1)
771 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
772 aViewWindow->SetSelectionMode(FaceSelection);
775 } else if (send == SelectPointButton) {
776 myEditCurrentArgument = (QWidget*)SpinBox_X;
777 SMESH::SetPointRepresentation(true);
778 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
779 aViewWindow->SetSelectionMode(NodeSelection);
780 } else if (send == SelectVectorButton) {
781 myEditCurrentArgument = (QWidget*)SpinBox_DX;
782 SMESH::SetPointRepresentation(true);
783 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
784 aViewWindow->SetSelectionMode(NodeSelection);
788 myEditCurrentArgument->setFocus();
789 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
790 SelectionIntoArgument();
793 //=================================================================================
794 // function : DeactivateActiveDialog()
796 //=================================================================================
797 void SMESHGUI_RevolutionDlg::DeactivateActiveDialog()
799 if (GroupConstructors->isEnabled()) {
800 GroupConstructors->setEnabled(false);
801 GroupArguments->setEnabled(false);
802 GroupButtons->setEnabled(false);
803 mySMESHGUI->ResetState();
804 mySMESHGUI->SetActiveDialogBox(0);
808 //=================================================================================
809 // function : ActivateThisDialog()
811 //=================================================================================
812 void SMESHGUI_RevolutionDlg::ActivateThisDialog()
814 /* Emit a signal to deactivate the active dialog */
815 mySMESHGUI->EmitSignalDeactivateDialog();
816 GroupConstructors->setEnabled(true);
817 GroupArguments->setEnabled(true);
818 GroupButtons->setEnabled(true);
820 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
822 ConstructorsClicked(GetConstructorId());
823 SelectionIntoArgument();
826 //=================================================================================
827 // function : enterEvent()
829 //=================================================================================
830 void SMESHGUI_RevolutionDlg::enterEvent (QEvent*)
832 if (!GroupConstructors->isEnabled())
833 ActivateThisDialog();
836 //=================================================================================
837 // function : closeEvent()
839 //=================================================================================
840 void SMESHGUI_RevolutionDlg::closeEvent (QCloseEvent*)
842 /* same than click on cancel button */
843 this->ClickOnCancel();
846 //=======================================================================
847 // function : hideEvent()
848 // purpose : caused by ESC key
849 //=======================================================================
850 void SMESHGUI_RevolutionDlg::hideEvent (QHideEvent*)
856 //=======================================================================
857 //function : onSelectMesh
859 //=======================================================================
860 void SMESHGUI_RevolutionDlg::onSelectMesh (bool toSelectMesh)
863 TextLabelElements->setText(tr("SMESH_NAME"));
865 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
867 if (myEditCurrentArgument != LineEditElements) {
868 LineEditElements->clear();
872 mySelectionMgr->clearFilters();
873 SMESH::SetPointRepresentation(false);
876 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
877 aViewWindow->SetSelectionMode(ActorSelection);
878 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
879 LineEditElements->setReadOnly(true);
881 int aConstructorId = GetConstructorId();
882 if (aConstructorId == 0)
884 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
885 aViewWindow->SetSelectionMode(EdgeSelection);
887 else if (aConstructorId == 0)
889 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
890 aViewWindow->SetSelectionMode(FaceSelection);
893 LineEditElements->setReadOnly(false);
894 onTextChange(LineEditElements->text());
897 SelectionIntoArgument();
900 //=================================================================================
901 // function : GetConstructorId()
903 //=================================================================================
904 int SMESHGUI_RevolutionDlg::GetConstructorId()
906 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
907 return GroupConstructors->id(GroupConstructors->selected());
911 //=================================================================================
912 // function : IsAxisOk()
914 //=================================================================================
915 bool SMESHGUI_RevolutionDlg::IsAxisOk()
917 return (SpinBox_DX->GetValue() != 0 ||
918 SpinBox_DY->GetValue() != 0 ||
919 SpinBox_DZ->GetValue() != 0);
922 //=================================================================================
923 // function : onVectorChanged()
925 //=================================================================================
926 void SMESHGUI_RevolutionDlg::onVectorChanged()
929 buttonOk->setEnabled(true);
930 buttonApply->setEnabled(true);
932 buttonOk->setEnabled(false);
933 buttonApply->setEnabled(false);