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_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)
82 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
86 //=================================================================================
87 // function : SMESHGUI_ExtrusionDlg()
88 // purpose : constructor
89 //=================================================================================
90 SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule,
92 : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_ExtrusionDlg", modal, WStyle_Customize |
93 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
94 mySMESHGUI( theModule ),
95 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
97 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
98 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
99 QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
102 setCaption(tr("EXTRUSION_ALONG_LINE"));
103 setSizeGripEnabled(TRUE);
105 QGridLayout* SMESHGUI_ExtrusionDlgLayout = new QGridLayout(this);
106 SMESHGUI_ExtrusionDlgLayout->setSpacing(6);
107 SMESHGUI_ExtrusionDlgLayout->setMargin(11);
109 /***************************************************************/
110 GroupConstructors = new QButtonGroup("GroupConstructors", this);
111 GroupConstructors->setTitle(tr("SMESH_EXTRUSION"));
112 GroupConstructors->setExclusive(TRUE);
113 GroupConstructors->setColumnLayout(0, Qt::Vertical);
114 GroupConstructors->layout()->setSpacing(0);
115 GroupConstructors->layout()->setMargin(0);
116 QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
117 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
118 GroupConstructorsLayout->setSpacing(6);
119 GroupConstructorsLayout->setMargin(11);
120 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
121 RadioButton1->setText(tr(""));
122 RadioButton1->setPixmap(image0);
123 GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
124 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
125 RadioButton2->setText(tr(""));
126 RadioButton2->setPixmap(image1);
127 GroupConstructorsLayout->addWidget(RadioButton2, 0, 2);
128 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupConstructors, 0, 0);
130 /***************************************************************/
131 GroupButtons = new QGroupBox(this, "GroupButtons");
132 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
133 GroupButtons->setTitle(tr(""));
134 GroupButtons->setColumnLayout(0, Qt::Vertical);
135 GroupButtons->layout()->setSpacing(0);
136 GroupButtons->layout()->setMargin(0);
137 QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
138 GroupButtonsLayout->setAlignment(Qt::AlignTop);
139 GroupButtonsLayout->setSpacing(6);
140 GroupButtonsLayout->setMargin(11);
141 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
142 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
143 buttonHelp->setAutoDefault(TRUE);
144 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
145 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
146 buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
147 buttonCancel->setAutoDefault(TRUE);
148 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
149 buttonApply = new QPushButton(GroupButtons, "buttonApply");
150 buttonApply->setText(tr("SMESH_BUT_APPLY" ));
151 buttonApply->setAutoDefault(TRUE);
152 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
153 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
154 GroupButtonsLayout->addItem(spacer_9, 0, 2);
155 buttonOk = new QPushButton(GroupButtons, "buttonOk");
156 buttonOk->setText(tr("SMESH_BUT_OK" ));
157 buttonOk->setAutoDefault(TRUE);
158 buttonOk->setDefault(TRUE);
159 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
160 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons, 2, 0);
162 /***************************************************************/
163 GroupArguments = new QGroupBox(this, "GroupArguments");
164 GroupArguments->setTitle(tr("EXTRUSION_1D"));
165 GroupArguments->setColumnLayout(0, Qt::Vertical);
166 GroupArguments->layout()->setSpacing(0);
167 GroupArguments->layout()->setMargin(0);
168 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
169 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
170 GroupArgumentsLayout->setSpacing(6);
171 GroupArgumentsLayout->setMargin(11);
173 // Controls for elements selection
174 TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
175 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
176 TextLabelElements->setFixedWidth(74);
177 GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
179 SelectElementsButton = new QPushButton(GroupArguments, "SelectElementsButton");
180 SelectElementsButton->setText(tr("" ));
181 SelectElementsButton->setPixmap(image2);
182 SelectElementsButton->setToggleButton(FALSE);
183 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
185 LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
186 LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
187 GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7);
189 // Control for the whole mesh selection
190 CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
191 CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
192 GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7);
194 // Controls for vector selection
195 TextLabelVector = new QLabel(GroupArguments, "TextLabelVector");
196 TextLabelVector->setText(tr("SMESH_VECTOR"));
197 GroupArgumentsLayout->addWidget(TextLabelVector, 2, 0);
199 TextLabelDx = new QLabel(GroupArguments, "TextLabelDx");
200 TextLabelDx->setText(tr("SMESH_DX"));
201 GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2);
203 SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dx");
204 GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3);
206 TextLabelDy = new QLabel(GroupArguments, "TextLabelDy");
207 TextLabelDy->setText(tr("SMESH_DY"));
208 GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4);
210 SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dy");
211 GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5);
213 TextLabelDz = new QLabel(GroupArguments, "TextLabelDz");
214 TextLabelDz->setText(tr("SMESH_DZ"));
215 GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6);
217 SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dz");
218 GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7);
220 // Controls for nb. steps defining
221 TextLabelNbSteps = new QLabel(GroupArguments, "TextLabelNbSteps");
222 TextLabelNbSteps->setText(tr("SMESH_NUMBEROFSTEPS" ));
223 GroupArgumentsLayout->addMultiCellWidget(TextLabelNbSteps, 3, 3, 0, 1);
225 SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
226 GroupArgumentsLayout->addMultiCellWidget(SpinBox_NbSteps, 3, 3, 2, 7);
228 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupArguments, 1, 0);
230 /* Initialisations */
231 SpinBox_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
232 SpinBox_Dy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
233 SpinBox_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
235 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
236 SpinBox_NbSteps->setValidator(anIntValidator);
237 SpinBox_NbSteps->setRange(1, 999999);
239 GroupArguments->show();
240 RadioButton1->setChecked(TRUE);
242 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
244 mySMESHGUI->SetActiveDialogBox(this);
246 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
247 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
248 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
250 QPtrList<SUIT_SelectionFilter> aListOfFilters;
251 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
252 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
254 myMeshOrSubMeshOrGroupFilter =
255 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
257 myHelpFileName = "extrusion.htm";
261 /***************************************************************/
262 // signals and slots connections
263 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
264 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
265 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
266 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
268 // to update state of the Ok & Apply buttons
269 connect(SpinBox_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
270 connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
271 connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
273 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
274 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
275 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
276 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
277 /* to close dialog if study change */
278 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
279 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
280 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
282 /***************************************************************/
284 this->show(); // displays Dialog
286 ConstructorsClicked(0);
287 SelectionIntoArgument();
290 //=================================================================================
291 // function : ~SMESHGUI_ExtrusionDlg()
292 // purpose : destructor
293 //=================================================================================
294 SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
296 // no need to delete child widgets, Qt does it all for us
299 //=================================================================================
301 // purpose : initialization
302 //=================================================================================
303 void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
307 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) {
394 SMESH::DirStruct aVector;
395 aVector.PS.x = SpinBox_Dx->GetValue();
396 aVector.PS.y = SpinBox_Dy->GetValue();
397 aVector.PS.z = SpinBox_Dz->GetValue();
399 long aNbSteps = (long)SpinBox_NbSteps->value();
402 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
403 QApplication::setOverrideCursor(Qt::waitCursor);
404 aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
405 QApplication::restoreOverrideCursor();
411 ConstructorsClicked(GetConstructorId());
412 SelectionIntoArgument();
417 //=================================================================================
418 // function : ClickOnOk()
419 // purpose : Called when user presses <OK> button
420 //=================================================================================
421 void SMESHGUI_ExtrusionDlg::ClickOnOk()
427 //=================================================================================
428 // function : ClickOnCancel()
429 // purpose : Called when dialog box is closed
430 //=================================================================================
431 void SMESHGUI_ExtrusionDlg::ClickOnCancel()
433 disconnect(mySelectionMgr, 0, this, 0);
434 mySelectionMgr->clearFilters();
435 //mySelectionMgr->clearSelected();
436 SMESH::SetPickable(); // ???
437 SMESH::SetPointRepresentation(false);
438 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
439 aViewWindow->SetSelectionMode(ActorSelection);
440 mySMESHGUI->ResetState();
444 //=================================================================================
445 // function : ClickOnHelp()
447 //=================================================================================
448 void SMESHGUI_ExtrusionDlg::ClickOnHelp()
450 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
452 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
456 platform = "winapplication";
458 platform = "application";
460 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
461 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
462 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
463 QObject::tr("BUT_OK"));
467 //=================================================================================
468 // function : onTextChange()
470 //=================================================================================
471 void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
473 QLineEdit* send = (QLineEdit*)sender();
481 if (send == LineEditElements)
484 // hilight entered elements/nodes
486 if (!myIO.IsNull()) {
487 QStringList aListId = QStringList::split(" ", theNewText, false);
489 if (send == LineEditElements)
491 SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
492 SMESH::ElementType SMESHType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE;
493 SMDSAbs_ElementType SMDSType = GetConstructorId() ? SMDSAbs_Face: SMDSAbs_Edge;
495 myElementsId = new SMESH::long_array;
496 myElementsId->length( aListId.count() );
497 TColStd_MapOfInteger newIndices;
498 for (int i = 0; i < aListId.count(); i++) {
499 int id = aListId[ i ].toInt();
500 bool validId = false;
503 const SMDS_MeshElement * e = aMesh->FindElement( id );
504 validId = ( e && e->GetType() == SMDSType );
506 validId = ( myMesh->GetElementType( id, true ) == SMESHType );
509 if ( validId && newIndices.Add( id ))
510 myElementsId[ newIndices.Extent()-1 ] = id;
512 myElementsId->length( myNbOkElements = newIndices.Extent() );
513 mySelector->AddOrRemoveIndex(myIO, newIndices, false);
514 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
515 aViewWindow->highlight( myIO, true, true );
524 //=================================================================================
525 // function : SelectionIntoArgument()
526 // purpose : Called when selection as changed or other case
527 //=================================================================================
528 void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
532 // return if dialog box is inactive
533 if (!GroupButtons->isEnabled())
539 QString aString = "";
544 myEditCurrentArgument->setText(aString);
550 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
551 int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
555 Handle(SALOME_InteractiveObject) IO = aList.First();
556 myMesh = SMESH::GetMeshByIO(IO);
557 if (myMesh->_is_nil())
560 myActor = SMESH::FindActorByObject(myMesh);
562 if (myEditCurrentArgument == LineEditElements) {
565 if (CheckBoxMesh->isChecked()) {
566 SMESH::ElementType neededType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE;
568 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
570 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
572 if (!mesh->_is_nil()) { //MESH
573 // get elements from mesh
574 myElementsId = mesh->GetElementsByType(neededType);
575 aNbElements = myElementsId->length();
577 SMESH::SMESH_subMesh_var aSubMesh =
578 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
580 if (!aSubMesh->_is_nil()) { //SUBMESH
581 // get IDs from submesh
582 myElementsId = aSubMesh->GetElementsByType(neededType);
583 aNbElements = myElementsId->length();
585 SMESH::SMESH_GroupBase_var aGroup =
586 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
588 if (!aGroup->_is_nil() && aGroup->GetType() == neededType) { // GROUP
589 // get IDs from smesh group
590 myElementsId = aGroup->GetListOfID();
591 aNbElements = myElementsId->length();
596 // get indices of selcted elements
597 TColStd_IndexedMapOfInteger aMapIndex;
598 mySelector->GetIndex(IO,aMapIndex);
599 aNbElements = aMapIndex.Extent();
601 myElementsId = new SMESH::long_array;
602 myElementsId->length( aNbElements );
604 for ( int i = 0; i < aNbElements; ++i )
605 aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) );
611 myNbOkElements = true;
615 myEditCurrentArgument->setText(aString);
622 //=================================================================================
623 // function : SetEditCurrentArgument()
625 //=================================================================================
626 void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
628 QPushButton* send = (QPushButton*)sender();
630 disconnect(mySelectionMgr, 0, this, 0);
631 mySelectionMgr->clearSelected();
632 mySelectionMgr->clearFilters();
634 if (send == SelectElementsButton) {
635 myEditCurrentArgument = LineEditElements;
636 if (CheckBoxMesh->isChecked()) {
637 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
638 aViewWindow->SetSelectionMode(ActorSelection);
639 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
641 int aConstructorId = GetConstructorId();
642 if (aConstructorId == 0)
644 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
645 aViewWindow->SetSelectionMode(EdgeSelection);
647 else if (aConstructorId == 1)
649 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
650 aViewWindow->SetSelectionMode(FaceSelection);
655 myEditCurrentArgument->setFocus();
656 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
657 SelectionIntoArgument();
660 //=================================================================================
661 // function : DeactivateActiveDialog()
662 // purpose : Deactivates this dialog
663 //=================================================================================
664 void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
666 if (GroupConstructors->isEnabled()) {
667 GroupConstructors->setEnabled(false);
668 GroupArguments->setEnabled(false);
669 GroupButtons->setEnabled(false);
670 mySMESHGUI->ResetState();
671 mySMESHGUI->SetActiveDialogBox(0);
675 //=================================================================================
676 // function : ActivateThisDialog()
677 // purpose : Activates this dialog
678 //=================================================================================
679 void SMESHGUI_ExtrusionDlg::ActivateThisDialog()
681 // Emit a signal to deactivate the active dialog
682 mySMESHGUI->EmitSignalDeactivateDialog();
683 GroupConstructors->setEnabled(true);
684 GroupArguments->setEnabled(true);
685 GroupButtons->setEnabled(true);
687 mySMESHGUI->SetActiveDialogBox(this);
689 ConstructorsClicked(GetConstructorId());
690 SelectionIntoArgument();
693 //=================================================================================
694 // function : enterEvent()
695 // purpose : Mouse enter event
696 //=================================================================================
697 void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*)
699 if (!GroupConstructors->isEnabled())
700 ActivateThisDialog();
703 //=================================================================================
704 // function : closeEvent()
706 //=================================================================================
707 //void SMESHGUI_ExtrusionDlg::closeEvent (QCloseEvent*)
709 // /* same than click on cancel button */
710 // this->ClickOnCancel();
713 //=================================================================================
714 // function : hideEvent()
715 // purpose : caused by ESC key
716 //=================================================================================
717 //void SMESHGUI_ExtrusionDlg::hideEvent (QHideEvent*)
719 // if (!isMinimized())
723 //=================================================================================
724 // function : onSelectMesh()
726 //=================================================================================
727 void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
730 TextLabelElements->setText(tr("SMESH_NAME"));
732 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
734 if (myEditCurrentArgument != LineEditElements) {
735 LineEditElements->clear();
739 mySelectionMgr->clearFilters();
742 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
743 aViewWindow->SetSelectionMode(ActorSelection);
744 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
745 LineEditElements->setReadOnly(true);
747 int aConstructorId = GetConstructorId();
748 if (aConstructorId == 0)
750 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
751 aViewWindow->SetSelectionMode(EdgeSelection);
753 else if (aConstructorId == 0)
755 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
756 aViewWindow->SetSelectionMode(FaceSelection);
759 LineEditElements->setReadOnly(false);
760 onTextChange(LineEditElements->text());
763 SelectionIntoArgument();
766 //=================================================================================
767 // function : GetConstructorId()
769 //=================================================================================
770 int SMESHGUI_ExtrusionDlg::GetConstructorId()
772 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
773 return GroupConstructors->id(GroupConstructors->selected());
777 //=================================================================================
778 // function : keyPressEvent()
780 //=================================================================================
781 void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e )
783 QDialog::keyPressEvent( e );
784 if ( e->isAccepted() )
787 if ( e->key() == Key_F1 )