1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_ExtrusionDlg.cxx
24 // Author : Michael ZORIN
28 #include "SMESHGUI_ExtrusionDlg.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_SpinBox.h"
35 #include "SMESHGUI_IdValidator.h"
37 #include "SMESH_Actor.h"
38 #include "SMESH_TypeFilter.hxx"
39 #include "SMESH_NumberFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
42 #include "SMDS_Mesh.hxx"
44 #include "SUIT_ResourceMgr.h"
45 #include "SUIT_OverrideCursor.h"
46 #include "SUIT_Desktop.h"
47 #include "SUIT_MessageBox.h"
48 #include "SUIT_Session.h"
50 #include "LightApp_Application.h"
52 #include "SVTK_ViewModel.h"
53 #include "SVTK_ViewWindow.h"
54 #include "SVTK_Selector.h"
55 #include "SVTK_Selection.h"
56 #include "SALOME_ListIO.hxx"
58 #include "utilities.h"
61 #include <TColStd_MapOfInteger.hxx>
62 #include <TColStd_IndexedMapOfInteger.hxx>
65 #include <qapplication.h>
66 #include <qbuttongroup.h>
67 #include <qgroupbox.h>
69 #include <qlineedit.h>
70 #include <qpushbutton.h>
71 #include <qradiobutton.h>
72 #include <qcheckbox.h>
75 #include <qvalidator.h>
79 #include "SALOMEconfig.h"
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
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_APPLY_AND_CLOSE" ));
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 // CheckBox for groups generation
228 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
229 MakeGroupsCheck->setChecked(true);
230 GroupArgumentsLayout->addMultiCellWidget(MakeGroupsCheck, 4, 4, 0, 7);
233 SMESHGUI_ExtrusionDlgLayout->addWidget(GroupArguments, 1, 0);
235 /* Initialisations */
236 SpinBox_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
237 SpinBox_Dy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
238 SpinBox_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
240 QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps);
241 SpinBox_NbSteps->setValidator(anIntValidator);
242 SpinBox_NbSteps->setRange(1, 999999);
244 GroupArguments->show();
245 RadioButton1->setChecked(TRUE);
247 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
249 mySMESHGUI->SetActiveDialogBox(this);
251 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
252 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
253 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
255 QPtrList<SUIT_SelectionFilter> aListOfFilters;
256 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
257 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
259 myMeshOrSubMeshOrGroupFilter =
260 new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
262 myHelpFileName = "extrusion_page.html";
266 /***************************************************************/
267 // signals and slots connections
268 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
269 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
270 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
271 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
273 // to update state of the Ok & Apply buttons
274 connect(SpinBox_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
275 connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
276 connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
278 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
279 connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
280 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
281 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
282 /* to close dialog if study change */
283 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
284 connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
285 connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
287 /***************************************************************/
289 this->show(); // displays Dialog
291 ConstructorsClicked(0);
292 SelectionIntoArgument();
295 //=================================================================================
296 // function : ~SMESHGUI_ExtrusionDlg()
297 // purpose : destructor
298 //=================================================================================
299 SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
301 // no need to delete child widgets, Qt does it all for us
304 //=================================================================================
306 // purpose : initialization
307 //=================================================================================
308 void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
312 LineEditElements->clear();
316 myMesh = SMESH::SMESH_Mesh::_nil();
319 SpinBox_NbSteps->setValue(1);
320 SpinBox_Dx->SetValue(0);
321 SpinBox_Dy->SetValue(0);
322 SpinBox_Dz->SetValue(0);
324 CheckBoxMesh->setChecked(false);
331 //=================================================================================
332 // function : CheckIsEnable()
333 // purpose : Check whether the Ok and Apply buttons should be enabled or not
334 //=================================================================================
335 void SMESHGUI_ExtrusionDlg::CheckIsEnable()
337 double aX = SpinBox_Dx->GetValue();
338 double aY = SpinBox_Dy->GetValue();
339 double aZ = SpinBox_Dz->GetValue();
340 double aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
342 bool anIsEnable = myNbOkElements > 0 && aModule > 1.0E-38;
344 buttonOk->setEnabled(anIsEnable);
345 buttonApply->setEnabled(anIsEnable);
348 //=================================================================================
349 // function : ConstructorsClicked()
350 // purpose : Radio button management
351 //=================================================================================
352 void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
354 disconnect(mySelectionMgr, 0, this, 0);
356 switch (constructorId) {
359 GroupArguments->setTitle(tr("EXTRUSION_1D"));
360 if (!CheckBoxMesh->isChecked())
362 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
363 aViewWindow->SetSelectionMode(EdgeSelection);
369 GroupArguments->setTitle(tr("EXTRUSION_2D"));
370 if (!CheckBoxMesh->isChecked())
372 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
373 aViewWindow->SetSelectionMode(FaceSelection);
379 myEditCurrentArgument = LineEditElements;
380 LineEditElements->setFocus();
382 if (CheckBoxMesh->isChecked())
385 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
388 //=================================================================================
389 // function : ClickOnApply()
390 // purpose : Called when user presses <Apply> button
391 //=================================================================================
392 bool SMESHGUI_ExtrusionDlg::ClickOnApply()
394 if (mySMESHGUI->isActiveStudyLocked())
397 if (myNbOkElements) {
399 SMESH::DirStruct aVector;
400 aVector.PS.x = SpinBox_Dx->GetValue();
401 aVector.PS.y = SpinBox_Dy->GetValue();
402 aVector.PS.z = SpinBox_Dz->GetValue();
404 long aNbSteps = (long)SpinBox_NbSteps->value();
407 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
408 QApplication::setOverrideCursor(Qt::waitCursor);
410 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
411 SMESH::ListOfGroups_var groups =
412 aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps);
414 aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps);
416 QApplication::restoreOverrideCursor();
421 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
422 mySMESHGUI->updateObjBrowser(true); // new groups may appear
424 ConstructorsClicked(GetConstructorId());
425 SelectionIntoArgument();
430 //=================================================================================
431 // function : ClickOnOk()
432 // purpose : Called when user presses <OK> button
433 //=================================================================================
434 void SMESHGUI_ExtrusionDlg::ClickOnOk()
440 //=================================================================================
441 // function : ClickOnCancel()
442 // purpose : Called when dialog box is closed
443 //=================================================================================
444 void SMESHGUI_ExtrusionDlg::ClickOnCancel()
446 disconnect(mySelectionMgr, 0, this, 0);
447 mySelectionMgr->clearFilters();
448 //mySelectionMgr->clearSelected();
449 SMESH::SetPickable(); // ???
450 SMESH::SetPointRepresentation(false);
451 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
452 aViewWindow->SetSelectionMode(ActorSelection);
453 mySMESHGUI->ResetState();
457 //=================================================================================
458 // function : ClickOnHelp()
460 //=================================================================================
461 void SMESHGUI_ExtrusionDlg::ClickOnHelp()
463 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
465 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
469 platform = "winapplication";
471 platform = "application";
473 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
474 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
475 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
476 QObject::tr("BUT_OK"));
480 //=================================================================================
481 // function : onTextChange()
483 //=================================================================================
484 void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
486 QLineEdit* send = (QLineEdit*)sender();
494 if (send == LineEditElements)
497 // hilight entered elements/nodes
499 if (!myIO.IsNull()) {
500 QStringList aListId = QStringList::split(" ", theNewText, false);
502 if (send == LineEditElements)
504 SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
505 SMESH::ElementType SMESHType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE;
506 SMDSAbs_ElementType SMDSType = GetConstructorId() ? SMDSAbs_Face: SMDSAbs_Edge;
508 myElementsId = new SMESH::long_array;
509 myElementsId->length( aListId.count() );
510 TColStd_MapOfInteger newIndices;
511 for (int i = 0; i < aListId.count(); i++) {
512 int id = aListId[ i ].toInt();
513 bool validId = false;
516 const SMDS_MeshElement * e = aMesh->FindElement( id );
517 validId = ( e && e->GetType() == SMDSType );
519 validId = ( myMesh->GetElementType( id, true ) == SMESHType );
522 if ( validId && newIndices.Add( id ))
523 myElementsId[ newIndices.Extent()-1 ] = id;
525 myElementsId->length( myNbOkElements = newIndices.Extent() );
526 mySelector->AddOrRemoveIndex(myIO, newIndices, false);
527 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
528 aViewWindow->highlight( myIO, true, true );
537 //=================================================================================
538 // function : SelectionIntoArgument()
539 // purpose : Called when selection as changed or other case
540 //=================================================================================
541 void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
545 // return if dialog box is inactive
546 if (!GroupButtons->isEnabled())
552 QString aString = "";
557 myEditCurrentArgument->setText(aString);
563 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
564 int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
568 Handle(SALOME_InteractiveObject) IO = aList.First();
569 myMesh = SMESH::GetMeshByIO(IO);
570 if (myMesh->_is_nil())
573 myActor = SMESH::FindActorByObject(myMesh);
575 if (myEditCurrentArgument == LineEditElements) {
578 // MakeGroups is available if there are groups
579 if ( myMesh->NbGroups() == 0 ) {
580 MakeGroupsCheck->setChecked(false);
581 MakeGroupsCheck->setEnabled(false);
583 MakeGroupsCheck->setEnabled(true);
586 if (CheckBoxMesh->isChecked()) {
587 SMESH::ElementType neededType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE;
589 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
591 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
593 if (!mesh->_is_nil()) { //MESH
594 // get elements from mesh
595 myElementsId = mesh->GetElementsByType(neededType);
596 aNbElements = myElementsId->length();
598 SMESH::SMESH_subMesh_var aSubMesh =
599 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
601 if (!aSubMesh->_is_nil()) { //SUBMESH
602 // get IDs from submesh
603 myElementsId = aSubMesh->GetElementsByType(neededType);
604 aNbElements = myElementsId->length();
606 SMESH::SMESH_GroupBase_var aGroup =
607 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
609 if (!aGroup->_is_nil() && aGroup->GetType() == neededType) { // GROUP
610 // get IDs from smesh group
611 myElementsId = aGroup->GetListOfID();
612 aNbElements = myElementsId->length();
617 // get indices of selcted elements
618 TColStd_IndexedMapOfInteger aMapIndex;
619 mySelector->GetIndex(IO,aMapIndex);
620 aNbElements = aMapIndex.Extent();
622 myElementsId = new SMESH::long_array;
623 myElementsId->length( aNbElements );
625 for ( int i = 0; i < aNbElements; ++i )
626 aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) );
632 myNbOkElements = true;
636 myEditCurrentArgument->setText(aString);
643 //=================================================================================
644 // function : SetEditCurrentArgument()
646 //=================================================================================
647 void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
649 QPushButton* send = (QPushButton*)sender();
651 disconnect(mySelectionMgr, 0, this, 0);
652 mySelectionMgr->clearSelected();
653 mySelectionMgr->clearFilters();
655 if (send == SelectElementsButton) {
656 myEditCurrentArgument = LineEditElements;
657 if (CheckBoxMesh->isChecked()) {
658 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
659 aViewWindow->SetSelectionMode(ActorSelection);
660 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
662 int aConstructorId = GetConstructorId();
663 if (aConstructorId == 0)
665 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
666 aViewWindow->SetSelectionMode(EdgeSelection);
668 else if (aConstructorId == 1)
670 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
671 aViewWindow->SetSelectionMode(FaceSelection);
676 myEditCurrentArgument->setFocus();
677 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
678 SelectionIntoArgument();
681 //=================================================================================
682 // function : DeactivateActiveDialog()
683 // purpose : Deactivates this dialog
684 //=================================================================================
685 void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
687 if (GroupConstructors->isEnabled()) {
688 GroupConstructors->setEnabled(false);
689 GroupArguments->setEnabled(false);
690 GroupButtons->setEnabled(false);
691 mySMESHGUI->ResetState();
692 mySMESHGUI->SetActiveDialogBox(0);
696 //=================================================================================
697 // function : ActivateThisDialog()
698 // purpose : Activates this dialog
699 //=================================================================================
700 void SMESHGUI_ExtrusionDlg::ActivateThisDialog()
702 // Emit a signal to deactivate the active dialog
703 mySMESHGUI->EmitSignalDeactivateDialog();
704 GroupConstructors->setEnabled(true);
705 GroupArguments->setEnabled(true);
706 GroupButtons->setEnabled(true);
708 mySMESHGUI->SetActiveDialogBox(this);
710 ConstructorsClicked(GetConstructorId());
711 SelectionIntoArgument();
714 //=================================================================================
715 // function : enterEvent()
716 // purpose : Mouse enter event
717 //=================================================================================
718 void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*)
720 if (!GroupConstructors->isEnabled())
721 ActivateThisDialog();
724 //=================================================================================
725 // function : closeEvent()
727 //=================================================================================
728 //void SMESHGUI_ExtrusionDlg::closeEvent (QCloseEvent*)
730 // /* same than click on cancel button */
731 // this->ClickOnCancel();
734 //=================================================================================
735 // function : hideEvent()
736 // purpose : caused by ESC key
737 //=================================================================================
738 //void SMESHGUI_ExtrusionDlg::hideEvent (QHideEvent*)
740 // if (!isMinimized())
744 //=================================================================================
745 // function : onSelectMesh()
747 //=================================================================================
748 void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
751 TextLabelElements->setText(tr("SMESH_NAME"));
753 TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
755 if (myEditCurrentArgument != LineEditElements) {
756 LineEditElements->clear();
760 mySelectionMgr->clearFilters();
763 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
764 aViewWindow->SetSelectionMode(ActorSelection);
765 mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
766 LineEditElements->setReadOnly(true);
768 int aConstructorId = GetConstructorId();
769 if (aConstructorId == 0)
771 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
772 aViewWindow->SetSelectionMode(EdgeSelection);
774 else if (aConstructorId == 0)
776 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
777 aViewWindow->SetSelectionMode(FaceSelection);
780 LineEditElements->setReadOnly(false);
781 onTextChange(LineEditElements->text());
784 SelectionIntoArgument();
787 //=================================================================================
788 // function : GetConstructorId()
790 //=================================================================================
791 int SMESHGUI_ExtrusionDlg::GetConstructorId()
793 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
794 return GroupConstructors->id(GroupConstructors->selected());
798 //=================================================================================
799 // function : keyPressEvent()
801 //=================================================================================
802 void SMESHGUI_ExtrusionDlg::keyPressEvent( QKeyEvent* e )
804 QDialog::keyPressEvent( e );
805 if ( e->isAccepted() )
808 if ( e->key() == Key_F1 )