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_ExtrusionDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_ExtrusionDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESHGUI_IdValidator.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_NumberFilter.hxx"
41 #include "SMESH_LogicalFilter.hxx"
43 #include "SMDS_Mesh.hxx"
45 #include "SUIT_ResourceMgr.h"
46 #include "SUIT_OverrideCursor.h"
47 #include "SUIT_Desktop.h"
48 #include "SUIT_MessageBox.h"
49 #include "SUIT_Session.h"
51 #include "LightApp_Application.h"
53 #include "SVTK_ViewModel.h"
54 #include "SVTK_ViewWindow.h"
55 #include "SVTK_Selector.h"
56 #include "SVTK_Selection.h"
57 #include "SALOME_ListIO.hxx"
59 #include "utilities.h"
62 #include <TColStd_MapOfInteger.hxx>
63 #include <TColStd_IndexedMapOfInteger.hxx>
66 #include <qapplication.h>
67 #include <qbuttongroup.h>
68 #include <qgroupbox.h>
70 #include <qlineedit.h>
71 #include <qpushbutton.h>
72 #include <qradiobutton.h>
73 #include <qcheckbox.h>
76 #include <qvalidator.h>
80 #include "SALOMEconfig.h"
81 #include CORBA_SERVER_HEADER(SMESH_Group)
85 //=================================================================================
86 // function : SMESHGUI_ExtrusionDlg()
87 // purpose : constructor
88 //=================================================================================
89 SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule,
91 : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_ExtrusionDlg", modal, WStyle_Customize |
92 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
93 mySMESHGUI( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
96 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
97 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
98 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
101 setCaption(tr("EXTRUSION_ALONG_LINE"));
102 setSizeGripEnabled(TRUE);
104 QGridLayout* SMESHGUI_ExtrusionDlgLayout = new QGridLayout(this);
105 SMESHGUI_ExtrusionDlgLayout->setSpacing(6);
106 SMESHGUI_ExtrusionDlgLayout->setMargin(11);
108 /***************************************************************/
109 GroupConstructors = new QButtonGroup("GroupConstructors", this);
110 GroupConstructors->setTitle(tr("SMESH_EXTRUSION"));
111 GroupConstructors->setExclusive(TRUE);
112 GroupConstructors->setColumnLayout(0, Qt::Vertical);
113 GroupConstructors->layout()->setSpacing(0);
114 GroupConstructors->layout()->setMargin(0);
115 QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
116 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
117 GroupConstructorsLayout->setSpacing(6);
118 GroupConstructorsLayout->setMargin(11);
119 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
120 RadioButton1->setText(tr(""));
121 RadioButton1->setPixmap(image0);
122 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
123 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
124 RadioButton2->setText(tr(""));
125 RadioButton2->setPixmap(image1);
126 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
127 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupConstructors, 0, 0);
129 /***************************************************************/
130 GroupButtons = new QGroupBox(this, "GroupButtons");
131 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
132 GroupButtons->setTitle(tr(""));
133 GroupButtons->setColumnLayout(0, Qt::Vertical);
134 GroupButtons->layout()->setSpacing(0);
135 GroupButtons->layout()->setMargin(0);
136 QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
137 GroupButtonsLayout->setAlignment(Qt::AlignTop);
138 GroupButtonsLayout->setSpacing(6);
139 GroupButtonsLayout->setMargin(11);
140 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
141 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
142 buttonHelp->setAutoDefault(TRUE);
143 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
144 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
145 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
146 buttonCancel->setAutoDefault(TRUE);
147 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
148 buttonApply = new QPushButton(GroupButtons, "buttonApply");
149 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
150 buttonApply->setAutoDefault(TRUE);
151 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
152 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
153 GroupButtonsLayout->addItem(spacer_9, 0, 2);
154 buttonOk = new QPushButton(GroupButtons, "buttonOk");
155 buttonOk->setText(tr("SMESH_BUT_OK" ));
156 buttonOk->setAutoDefault(TRUE);
157 buttonOk->setDefault(TRUE);
158 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
159 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons, 2, 0);
161 /***************************************************************/
162 GroupArguments = new QGroupBox(this, "GroupArguments");
163 GroupArguments->setTitle(tr("EXTRUSION_1D"));
164 GroupArguments->setColumnLayout(0, Qt::Vertical);
165 GroupArguments->layout()->setSpacing(0);
166 GroupArguments->layout()->setMargin(0);
167 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
168 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
169 GroupArgumentsLayout->setSpacing(6);
170 GroupArgumentsLayout->setMargin(11);
172 // Controls for elements selection
173 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
174 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
175 TextLabelElements->setFixedWidth(74);
176 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
178 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
179 SelectElementsButton->setText(tr("" ));
180 SelectElementsButton->setPixmap(image2);
181 SelectElementsButton->setToggleButton(FALSE);
182 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
184 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
185 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
186 GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7);
188 // Control for the whole mesh selection
189 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
190 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
191 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7);
193 // Controls for vector selection
194 TextLabelVector = new QLabel(GroupArguments, "TextLabelVector");
195 TextLabelVector->setText(tr("SMESH_VECTOR"));
196 GroupArgumentsLayout->addWidget(TextLabelVector, 2, 0);
198 TextLabelDx = new QLabel(GroupArguments, "TextLabelDx");
199 TextLabelDx->setText(tr("SMESH_DX"));
200 GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2);
202 SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dx");
203 GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3);
205 TextLabelDy = new QLabel(GroupArguments, "TextLabelDy");
206 TextLabelDy->setText(tr("SMESH_DY"));
207 GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4);
209 SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dy");
210 GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5);
212 TextLabelDz = new QLabel(GroupArguments, "TextLabelDz");
213 TextLabelDz->setText(tr("SMESH_DZ"));
214 GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6);
216 SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dz");
217 GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7);
219 // Controls for nb. steps defining
220 TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps");
221 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
222 GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 3, 3, 0, 1);
224 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
225 GroupArgumentsLayout->addMultiCellWidget(SpinBox_NbSteps, 3, 3, 2, 7);
227 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupArguments, 1, 0);
229 /* Initialisations */
230 SpinBox_Dx->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
231 SpinBox_Dy->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
232 SpinBox_Dz->RangeStepAndValidator(-999999.999, +999999.999, 10.0, 3);
234 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
235 SpinBox_NbSteps->setValidator(anIntValidator);
236 SpinBox_NbSteps->setRange(1, 999999);
238 GroupArguments->show();
239 RadioButton1->setChecked(TRUE);
241 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
243 mySMESHGUI->SetActiveDialogBox(this);
245 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
246 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
247 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
249 QPtrList<SUIT_SelectionFilter> aListOfFilters;
250 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
251 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
253 myMeshOrSubMeshOrGroupFilter =
254 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
256 myHelpFileName = "extrusion.htm";
260 /***************************************************************/
261 // signals and slots connections
262 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
263 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
264 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
265 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
267 // to update state of the Ok & Apply buttons
268 connect(SpinBox_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
269 connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
270 connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
272 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
273 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
274 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
275 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
276 /* to close dialog if study change */
277 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
278 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
279 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
281 /***************************************************************/
283 this->show(); // displays Dialog
285 ConstructorsClicked(0);
286 SelectionIntoArgument();
289 //=================================================================================
290 // function : ~SMESHGUI_ExtrusionDlg()
291 // purpose : destructor
292 //=================================================================================
293 SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
295 // no need to delete child widgets, Qt does it all for us
298 //=================================================================================
300 // purpose : initialization
301 //=================================================================================
302 void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
306 LineEditElements->clear();
311 myMesh = SMESH::SMESH_Mesh::_nil();
314 SpinBox_NbSteps->setValue(1);
315 SpinBox_Dx->SetValue(0);
316 SpinBox_Dy->SetValue(0);
317 SpinBox_Dz->SetValue(0);
319 CheckBoxMesh->setChecked(false);
326 //=================================================================================
327 // function : CheckIsEnable()
328 // purpose : Check whether the Ok and Apply buttons should be enabled or not
329 //=================================================================================
330 void SMESHGUI_ExtrusionDlg::CheckIsEnable()
332 double aX = SpinBox_Dx->GetValue();
333 double aY = SpinBox_Dy->GetValue();
334 double aZ = SpinBox_Dz->GetValue();
335 double aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
337 bool anIsEnable = myNbOkElements > 0 && aModule > 1.0E-38;
339 buttonOk->setEnabled(anIsEnable);
340 buttonApply->setEnabled(anIsEnable);
343 //=================================================================================
344 // function : ConstructorsClicked()
345 // purpose : Radio button management
346 //=================================================================================
347 void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
349 disconnect(mySelectionMgr, 0, this, 0);
351 switch (constructorId) {
354 GroupArguments->setTitle(tr("EXTRUSION_1D"));
355 if (!CheckBoxMesh->isChecked())
357 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
358 aViewWindow->SetSelectionMode(EdgeSelection);
364 GroupArguments->setTitle(tr("EXTRUSION_2D"));
365 if (!CheckBoxMesh->isChecked())
367 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
368 aViewWindow->SetSelectionMode(FaceSelection);
374 myEditCurrentArgument = LineEditElements;
375 LineEditElements->setFocus();
377 if (CheckBoxMesh->isChecked())
380 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
383 //=================================================================================
384 // function : ClickOnApply()
385 // purpose : Called when user presses <Apply> button
386 //=================================================================================
387 bool SMESHGUI_ExtrusionDlg::ClickOnApply()
389 if (mySMESHGUI->isActiveStudyLocked())
392 if (myNbOkElements) {
393 QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
395 SMESH::long_array_var anElementsId = new SMESH::long_array;
397 anElementsId->length(aListElementsId.count());
398 for (int i = 0; i < aListElementsId.count(); i++)
399 anElementsId[i] = aListElementsId[i].toInt();
401 SMESH::DirStruct aVector;
402 aVector.PS.x = SpinBox_Dx->GetValue();
403 aVector.PS.y = SpinBox_Dy->GetValue();
404 aVector.PS.z = SpinBox_Dz->GetValue();
406 long aNbSteps = (long)SpinBox_NbSteps->value();
409 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
410 QApplication::setOverrideCursor(Qt::waitCursor);
411 aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps);
412 QApplication::restoreOverrideCursor();
418 ConstructorsClicked(GetConstructorId());
419 SelectionIntoArgument();
424 //=================================================================================
425 // function : ClickOnOk()
426 // purpose : Called when user presses <OK> button
427 //=================================================================================
428 void SMESHGUI_ExtrusionDlg::ClickOnOk()
434 //=================================================================================
435 // function : ClickOnCancel()
436 // purpose : Called when dialog box is closed
437 //=================================================================================
438 void SMESHGUI_ExtrusionDlg::ClickOnCancel()
440 disconnect(mySelectionMgr, 0, this, 0);
441 mySelectionMgr->clearFilters();
442 //mySelectionMgr->clearSelected();
443 SMESH::SetPickable(); // ???
444 SMESH::SetPointRepresentation(false);
445 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
446 aViewWindow->SetSelectionMode(ActorSelection);
447 mySMESHGUI->ResetState();
451 //=================================================================================
452 // function : ClickOnHelp()
454 //=================================================================================
455 void SMESHGUI_ExtrusionDlg::ClickOnHelp()
457 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
459 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
461 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
462 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
463 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
464 QObject::tr("BUT_OK"));
468 //=================================================================================
469 // function : onTextChange()
471 //=================================================================================
472 void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
474 QLineEdit* send = (QLineEdit*)sender();
482 if (send == LineEditElements)
485 // hilight entered elements/nodes
486 SMDS_Mesh* aMesh = 0;
488 aMesh = myActor->GetObject()->GetMesh();
491 QStringList aListId = QStringList::split(" ", theNewText, false);
493 if (send == LineEditElements) {
494 const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
495 TColStd_MapOfInteger newIndices;
496 for (int i = 0; i < aListId.count(); i++) {
497 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
499 newIndices.Add(e->GetID());
502 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
503 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
504 aViewWindow->highlight( anIO, true, true );
505 myElementsId = theNewText;
514 //=================================================================================
515 // function : SelectionIntoArgument()
516 // purpose : Called when selection as changed or other case
517 //=================================================================================
518 void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
522 // return if dialog box is inactive
523 if (!GroupButtons->isEnabled())
528 QString aString = "";
533 myEditCurrentArgument->setText(aString);
539 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
540 int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
544 Handle(SALOME_InteractiveObject) IO = aList.First();
545 myMesh = SMESH::GetMeshByIO(IO);
546 if (myMesh->_is_nil())
549 myActor = SMESH::FindActorByObject(myMesh);
553 if (myEditCurrentArgument == LineEditElements) {
557 if (CheckBoxMesh->isChecked()) {
558 int aConstructorId = GetConstructorId();
560 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
562 if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
564 SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
568 if (aConstructorId == 0) {
569 SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
571 while (anIter->more()) {
572 const SMDS_MeshEdge * edge = anIter->next();
574 myElementsId += QString(" %1").arg(edge->GetID());
578 } else if (aConstructorId == 1) {
579 SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
580 while (anIter->more()) {
581 const SMDS_MeshFace * face = anIter->next();
583 myElementsId += QString(" %1").arg(face->GetID());
588 } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
590 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
592 // get IDs from submesh
593 SMESH::long_array_var anElementsIds = new SMESH::long_array;
594 if (aConstructorId == 0)
595 anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
596 else if (aConstructorId == 1)
597 anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
599 for (int i = 0; i < anElementsIds->length(); i++)
600 myElementsId += QString(" %1").arg(anElementsIds[i]);
601 aNbElements = anElementsIds->length();
604 SMESH::SMESH_GroupBase_var aGroup =
605 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
606 if (aGroup->_is_nil())
609 if ((aConstructorId == 0 && aGroup->GetType() != SMESH::EDGE) ||
610 (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE))
613 // get IDs from smesh group
614 SMESH::long_array_var anElementsIds = new SMESH::long_array;
615 anElementsIds = aGroup->GetListOfID();
616 for (int i = 0; i < anElementsIds->length(); i++)
617 myElementsId += QString(" %1").arg(anElementsIds[i]);
618 aNbElements = anElementsIds->length();
621 aNbElements = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
622 myElementsId = aString;
628 myNbOkElements = true;
632 myEditCurrentArgument->setText(aString);
639 //=================================================================================
640 // function : SetEditCurrentArgument()
642 //=================================================================================
643 void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
645 QPushButton* send = (QPushButton*)sender();
647 disconnect(mySelectionMgr, 0, this, 0);
648 mySelectionMgr->clearSelected();
649 mySelectionMgr->clearFilters();
651 if (send == SelectElementsButton) {
652 myEditCurrentArgument = LineEditElements;
653 if (CheckBoxMesh->isChecked()) {
654 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
655 aViewWindow->SetSelectionMode(ActorSelection);
656 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
658 int aConstructorId = GetConstructorId();
659 if (aConstructorId == 0)
661 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
662 aViewWindow->SetSelectionMode(EdgeSelection);
664 else if (aConstructorId == 1)
666 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
667 aViewWindow->SetSelectionMode(FaceSelection);
672 myEditCurrentArgument->setFocus();
673 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
674 SelectionIntoArgument();
677 //=================================================================================
678 // function : DeactivateActiveDialog()
679 // purpose : Deactivates this dialog
680 //=================================================================================
681 void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
683 if (GroupConstructors->isEnabled()) {
684 GroupConstructors->setEnabled(false);
685 GroupArguments->setEnabled(false);
686 GroupButtons->setEnabled(false);
687 mySMESHGUI->ResetState();
688 mySMESHGUI->SetActiveDialogBox(0);
692 //=================================================================================
693 // function : ActivateThisDialog()
694 // purpose : Activates this dialog
695 //=================================================================================
696 void SMESHGUI_ExtrusionDlg::ActivateThisDialog()
698 // Emit a signal to deactivate the active dialog
699 mySMESHGUI->EmitSignalDeactivateDialog();
700 GroupConstructors->setEnabled(true);
701 GroupArguments->setEnabled(true);
702 GroupButtons->setEnabled(true);
704 mySMESHGUI->SetActiveDialogBox(this);
706 ConstructorsClicked(GetConstructorId());
707 SelectionIntoArgument();
710 //=================================================================================
711 // function : enterEvent()
712 // purpose : Mouse enter event
713 //=================================================================================
714 void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*)
716 if (!GroupConstructors->isEnabled())
717 ActivateThisDialog();
720 //=================================================================================
721 // function : closeEvent()
723 //=================================================================================
724 //void SMESHGUI_ExtrusionDlg::closeEvent (QCloseEvent*)
726 // /* same than click on cancel button */
727 // this->ClickOnCancel();
730 //=================================================================================
731 // function : hideEvent()
732 // purpose : caused by ESC key
733 //=================================================================================
734 //void SMESHGUI_ExtrusionDlg::hideEvent (QHideEvent*)
736 // if (!isMinimized())
740 //=================================================================================
741 // function : onSelectMesh()
743 //=================================================================================
744 void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
747 TextLabelElements->setText(tr("SMESH_NAME"));
749 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
751 if (myEditCurrentArgument != LineEditElements) {
752 LineEditElements->clear();
756 mySelectionMgr->clearFilters();
759 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
760 aViewWindow->SetSelectionMode(ActorSelection);
761 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
762 LineEditElements->setReadOnly(true);
764 int aConstructorId = GetConstructorId();
765 if (aConstructorId == 0)
767 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
768 aViewWindow->SetSelectionMode(EdgeSelection);
770 else if (aConstructorId == 0)
772 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
773 aViewWindow->SetSelectionMode(FaceSelection);
776 LineEditElements->setReadOnly(false);
777 onTextChange(LineEditElements->text());
780 SelectionIntoArgument();
783 //=================================================================================
784 // function : GetConstructorId()
786 //=================================================================================
787 int SMESHGUI_ExtrusionDlg::GetConstructorId()
789 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
790 return GroupConstructors->id(GroupConstructors->selected());