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_ExtrusionAlongPathDlg.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S.
27 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_MeshUtils.h"
33 #include "SMESHGUI_SpinBox.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_FilterDlg.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 // SALOME GEOM includes
47 // SALOME GUI includes
48 #include <SUIT_ResourceMgr.h>
49 #include <SUIT_OverrideCursor.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_MessageBox.h>
52 #include <SUIT_Session.h>
54 #include <LightApp_Application.h>
55 #include <LightApp_SelectionMgr.h>
57 #include <SVTK_ViewWindow.h>
60 #include <BRep_Tool.hxx>
61 #include <TopoDS_Vertex.hxx>
63 #include <TColStd_MapOfInteger.hxx>
66 #include <QButtonGroup>
70 #include <QPushButton>
71 #include <QToolButton>
72 #include <QRadioButton>
74 #include <QListWidget>
75 #include <QVBoxLayout>
76 #include <QHBoxLayout>
77 #include <QGridLayout>
81 #include <SALOMEconfig.h>
82 #include CORBA_SERVER_HEADER(SMESH_Group)
83 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
88 class SMESHGUI_ExtrusionAlongPathDlg::SetBusy
91 SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg )
99 myDlg->myBusy = false;
103 SMESHGUI_ExtrusionAlongPathDlg* myDlg;
106 //=================================================================================
107 // function : SMESHGUI_ExtrusionAlongPathDlg()
108 // purpose : constructor
109 //=================================================================================
110 SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule )
111 : QDialog( SMESH::GetDesktop( theModule ) ),
112 SMESHGUI_Helper( theModule ),
113 mySMESHGUI( theModule ),
114 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
117 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
118 QPixmap edgeImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
119 QPixmap faceImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
120 QPixmap selectImage ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
121 QPixmap addImage ( mgr->loadPixmap("SMESH", tr("ICON_APPEND")));
122 QPixmap removeImage ( mgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
127 setAttribute( Qt::WA_DeleteOnClose, true );
128 setWindowTitle(tr("EXTRUSION_ALONG_PATH"));
129 setSizeGripEnabled(true);
131 QVBoxLayout* topLayout = new QVBoxLayout(this);
132 topLayout->setSpacing(SPACING);
133 topLayout->setMargin(MARGIN);
135 /***************************************************************/
136 // Elements type group box (1d / 2d elements)
137 ConstructorsBox = new QGroupBox(tr("SMESH_EXTRUSION"), this);
138 GroupConstructors = new QButtonGroup(this);
139 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
140 ConstructorsBoxLayout->setSpacing(SPACING); ConstructorsBoxLayout->setMargin(MARGIN);
142 Elements1dRB = new QRadioButton(ConstructorsBox);
143 Elements1dRB->setIcon(edgeImage);
144 Elements2dRB = new QRadioButton(ConstructorsBox);
145 Elements2dRB->setIcon(faceImage);
146 Elements1dRB->setChecked(true);
149 ConstructorsBoxLayout->addWidget(Elements1dRB);
150 ConstructorsBoxLayout->addWidget(Elements2dRB);
151 GroupConstructors->addButton(Elements1dRB, 0);
152 GroupConstructors->addButton(Elements2dRB, 1);
154 /***************************************************************/
155 // Arguments group box
156 GroupArguments = new QGroupBox(tr("EXTRUSION_1D"), this);
157 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
158 GroupArgumentsLayout->setSpacing(SPACING); GroupArgumentsLayout->setMargin(MARGIN);
160 myIdValidator = new SMESHGUI_IdValidator(this);
162 // Controls for elements selection
163 ElementsLab = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
165 SelectElementsButton = new QToolButton(GroupArguments);
166 SelectElementsButton->setIcon(selectImage);
168 ElementsLineEdit = new QLineEdit(GroupArguments);
169 ElementsLineEdit->setValidator(myIdValidator);
170 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
171 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
173 // Controls for the whole mesh selection
174 MeshCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
176 // Controls for path selection
177 PathGrp = new QGroupBox(tr("SMESH_PATH"), GroupArguments);
178 QGridLayout* PathGrpLayout = new QGridLayout(PathGrp);
179 PathGrpLayout->setSpacing(SPACING); PathGrpLayout->setMargin(MARGIN);
181 // Controls for path mesh selection
182 QLabel* PathMeshLab = new QLabel(tr("SMESH_PATH_MESH"), PathGrp);
184 SelectPathMeshButton = new QToolButton(PathGrp);
185 SelectPathMeshButton->setIcon(selectImage);
187 PathMeshLineEdit = new QLineEdit(PathGrp);
188 PathMeshLineEdit->setReadOnly(true);
190 // Controls for path starting point selection
191 QLabel* StartPointLab = new QLabel(tr("SMESH_PATH_START"), PathGrp);
193 SelectStartPointButton = new QToolButton(PathGrp);
194 SelectStartPointButton->setIcon(selectImage);
196 StartPointLineEdit = new QLineEdit(PathGrp);
197 StartPointLineEdit->setValidator(new QIntValidator(this));
200 PathGrpLayout->addWidget(PathMeshLab, 0, 0);
201 PathGrpLayout->addWidget(SelectPathMeshButton, 0, 1);
202 PathGrpLayout->addWidget(PathMeshLineEdit, 0, 2);
203 PathGrpLayout->addWidget(StartPointLab, 1, 0);
204 PathGrpLayout->addWidget(SelectStartPointButton, 1, 1);
205 PathGrpLayout->addWidget(StartPointLineEdit, 1, 2);
207 BasePointGrp = new QGroupBox(tr("SMESH_BASE_POINT"), GroupArguments);
208 BasePointGrp->setCheckable(true);
209 BasePointGrp->setChecked(false);
210 QHBoxLayout* BasePointGrpLayout = new QHBoxLayout(BasePointGrp);
211 BasePointGrpLayout->setSpacing(SPACING); BasePointGrpLayout->setMargin(MARGIN);
213 SelectBasePointButton = new QToolButton(BasePointGrp);
214 SelectBasePointButton->setIcon(selectImage);
216 QLabel* XLab = new QLabel(tr("SMESH_X"), BasePointGrp);
217 XSpin = new SMESHGUI_SpinBox(BasePointGrp);
218 QLabel* YLab = new QLabel(tr("SMESH_Y"), BasePointGrp);
219 YSpin = new SMESHGUI_SpinBox(BasePointGrp);
220 QLabel* ZLab = new QLabel(tr("SMESH_Z"), BasePointGrp);
221 ZSpin = new SMESHGUI_SpinBox(BasePointGrp);
224 BasePointGrpLayout->addWidget(SelectBasePointButton);
225 BasePointGrpLayout->addWidget(XLab);
226 BasePointGrpLayout->addWidget(XSpin);
227 BasePointGrpLayout->addWidget(YLab);
228 BasePointGrpLayout->addWidget(YSpin);
229 BasePointGrpLayout->addWidget(ZLab);
230 BasePointGrpLayout->addWidget(ZSpin);
232 AnglesGrp = new QGroupBox(tr("SMESH_ANGLES"), GroupArguments);
233 AnglesGrp->setCheckable(true);
234 AnglesGrp->setChecked(false);
235 QGridLayout* AnglesGrpLayout = new QGridLayout(AnglesGrp);
236 AnglesGrpLayout->setSpacing(SPACING); AnglesGrpLayout->setMargin(MARGIN);
238 AnglesList = new QListWidget(AnglesGrp);
239 AnglesList->setSelectionMode(QListWidget::ExtendedSelection);
241 AddAngleButton = new QToolButton(AnglesGrp);
242 AddAngleButton->setIcon(addImage);
244 RemoveAngleButton = new QToolButton(AnglesGrp);
245 RemoveAngleButton->setIcon(removeImage);
247 AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
249 LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp);
252 AnglesGrpLayout->addWidget(AnglesList, 0, 0, 4, 1);
253 AnglesGrpLayout->addWidget(AddAngleButton, 0, 1);
254 AnglesGrpLayout->addWidget(RemoveAngleButton, 2, 1);
255 AnglesGrpLayout->addWidget(AngleSpin, 0, 2);
256 AnglesGrpLayout->addWidget(LinearAnglesCheck, 4, 0);
257 AnglesGrpLayout->setRowMinimumHeight(1, 10);
258 AnglesGrpLayout->setRowStretch(3, 10);
260 // CheckBox for groups generation
261 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
262 MakeGroupsCheck->setChecked(true);
265 GroupArgumentsLayout->addWidget(ElementsLab, 0, 0);
266 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
267 GroupArgumentsLayout->addWidget(ElementsLineEdit, 0, 2);
268 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
269 GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 4);
270 GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 4);
271 GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 4);
272 GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 4);
273 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 4);
275 /***************************************************************/
276 // common buttons group box
277 GroupButtons = new QGroupBox(this);
278 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
279 GroupButtonsLayout->setSpacing(SPACING); GroupButtonsLayout->setMargin(MARGIN);
281 OkButton = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
282 OkButton->setAutoDefault(true);
283 OkButton->setDefault(true);
285 ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
286 ApplyButton->setAutoDefault(true);
288 CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
289 CloseButton->setAutoDefault(true);
291 HelpButton = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
292 HelpButton->setAutoDefault(true);
295 GroupButtonsLayout->addWidget(OkButton);
296 GroupButtonsLayout->addSpacing(10);
297 GroupButtonsLayout->addWidget(ApplyButton);
298 GroupButtonsLayout->addSpacing(10);
299 GroupButtonsLayout->addStretch();
300 GroupButtonsLayout->addWidget(CloseButton);
301 GroupButtonsLayout->addWidget(HelpButton);
303 /***************************************************************/
305 topLayout->addWidget(ConstructorsBox);
306 topLayout->addWidget(GroupArguments);
307 topLayout->addWidget(GroupButtons);
309 /***************************************************************/
311 XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
312 YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
313 ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
314 AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, 3);
316 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
318 mySMESHGUI->SetActiveDialogBox(this);
320 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
321 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
322 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
324 QList<SUIT_SelectionFilter*> aListOfFilters;
325 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
326 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
328 myElementsFilter = new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
329 //myPathMeshFilter = new SMESH_TypeFilter (MESH);
330 myPathMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
332 myHelpFileName = "extrusion_along_path_page.html";
336 /***************************************************************/
337 // signals-slots connections
338 connect(OkButton, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
339 connect(CloseButton, SIGNAL(clicked()), this, SLOT(reject()));
340 connect(ApplyButton, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
341 connect(HelpButton, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
343 connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
344 connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
346 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
348 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
349 connect(SelectPathMeshButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
350 connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
351 connect(SelectBasePointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
353 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
354 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
355 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
357 connect(ElementsLineEdit, SIGNAL(textChanged(const QString&)),
358 SLOT(onTextChange(const QString&)));
359 connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)),
360 SLOT(onTextChange(const QString&)));
362 connect(MeshCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh()));
364 AnglesList->installEventFilter(this);
365 ElementsLineEdit->installEventFilter(this);
366 StartPointLineEdit->installEventFilter(this);
367 XSpin->editor()->installEventFilter(this);
368 YSpin->editor()->installEventFilter(this);
369 ZSpin->editor()->installEventFilter(this);
372 //=================================================================================
373 // function : ~SMESHGUI_ExtrusionAlongPathDlg()
374 // purpose : destructor
375 //=================================================================================
376 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
378 // no need to delete child widgets, Qt does it all for us
379 if ( myFilterDlg != 0 ) {
380 myFilterDlg->setParent( 0 );
385 //=================================================================================
387 // purpose : initialization
388 //=================================================================================
389 void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls)
392 myEditCurrentArgument = 0;
394 myMesh = SMESH::SMESH_Mesh::_nil();
395 myIDSource = SMESH::SMESH_IDSource::_nil();
397 myPath = SMESH::SMESH_IDSource::_nil();
399 ElementsLineEdit->clear();
400 PathMeshLineEdit->clear();
401 StartPointLineEdit->clear();
404 XSpin->SetValue(0.0);
405 YSpin->SetValue(0.0);
406 ZSpin->SetValue(0.0);
408 AngleSpin->SetValue(45);
409 MeshCheck->setChecked(false);
410 ConstructorsClicked(0);
413 SetEditCurrentArgument(0);
416 //=================================================================================
417 // function : ConstructorsClicked()
418 // purpose : Called when user changes type of elements (1d / 2d)
419 //=================================================================================
420 void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type)
422 if (myType == type) return;
424 disconnect(mySelectionMgr, 0, this, 0);
427 GroupArguments->setTitle(tr("EXTRUSION_1D"));
429 GroupArguments->setTitle(tr("EXTRUSION_2D"));
431 // clear elements ID list
432 if (!MeshCheck->isChecked()) {
433 ElementsLineEdit->clear();
435 // set selection mode if necessary
436 if (myEditCurrentArgument == ElementsLineEdit) {
437 mySelectionMgr->clearSelected();
438 mySelectionMgr->clearFilters();
439 SMESH::SetPickable();
441 SMESH::SetPointRepresentation(false);
442 if (MeshCheck->isChecked()) {
443 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
444 aViewWindow->SetSelectionMode(ActorSelection);
445 mySelectionMgr->installFilter(myElementsFilter);
449 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
450 aViewWindow->SetSelectionMode(EdgeSelection);
454 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
455 aViewWindow->SetSelectionMode(FaceSelection);
459 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
464 //=================================================================================
465 // function : ClickOnApply()
466 // purpose : Called when user presses <Apply> button
467 //=================================================================================
468 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
470 if (mySMESHGUI->isActiveStudyLocked())
473 //if (myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() ||
474 // !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil())
475 if ( myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() ||
476 !myMeshActor || myPath->_is_nil() )
482 SMESH::long_array_var anElementsId = new SMESH::long_array;
484 if (!MeshCheck->isChecked()) {
485 // If "Select whole mesh, submesh or group" check box is off ->
486 // use only elements of given type selected by user
488 SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh();
490 QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts);
491 anElementsId = new SMESH::long_array;
492 anElementsId->length(aListElementsId.count());
495 for (int i = 0; i < aListElementsId.count(); i++) {
496 long ind = aListElementsId[ i ].toLong(&bOk);
498 const SMDS_MeshElement* e = aMesh->FindElement(ind);
500 bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge ||
501 Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
503 anElementsId[ j++ ] = ind;
507 anElementsId->length(j);
510 if (anElementsId->length() <= 0) {
515 if (StartPointLineEdit->text().trimmed().isEmpty()) {
520 long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
525 QStringList aParameters;
528 SMESH::double_array_var anAngles = new SMESH::double_array;
529 if (AnglesGrp->isChecked()) {
530 anAngles->length(myAnglesList.count());
532 for (int i = 0; i < myAnglesList.count(); i++) {
533 double angle = myAnglesList[i];
534 anAngles[ j++ ] = angle*PI/180;
535 aParameters << AnglesList->item(i)->text();
541 SMESH::PointStruct aBasePoint;
542 if (BasePointGrp->isChecked()) {
543 aBasePoint.x = XSpin->GetValue();
544 aBasePoint.y = YSpin->GetValue();
545 aBasePoint.z = ZSpin->GetValue();
548 aParameters << XSpin->text();
549 aParameters << YSpin->text();
550 aParameters << ZSpin->text();
553 SUIT_OverrideCursor wc;
554 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
555 //if ( LinearAnglesCheck->isChecked() ) {
556 // anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
559 SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
561 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
562 if( MeshCheck->isChecked() ) {
563 if( GetConstructorId() == 0 )
564 SMESH::ListOfGroups_var groups =
565 aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh,
566 myPathShape, aNodeStart,
567 AnglesGrp->isChecked(), anAngles,
568 BasePointGrp->isChecked(), aBasePoint, retVal);
570 SMESH::ListOfGroups_var groups =
571 aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh,
572 myPathShape, aNodeStart,
573 AnglesGrp->isChecked(), anAngles,
574 BasePointGrp->isChecked(), aBasePoint, retVal);
577 SMESH::ListOfGroups_var groups =
578 aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
579 myPathShape, aNodeStart,
580 AnglesGrp->isChecked(), anAngles,
581 BasePointGrp->isChecked(), aBasePoint, retVal);
584 if( MeshCheck->isChecked() ) {
585 if( GetConstructorId() == 0 )
586 retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh,
587 myPathShape, aNodeStart,
588 AnglesGrp->isChecked(), anAngles,
589 BasePointGrp->isChecked(), aBasePoint);
591 retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh,
592 myPathShape, aNodeStart,
593 AnglesGrp->isChecked(), anAngles,
594 BasePointGrp->isChecked(), aBasePoint);
597 retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
598 myPathShape, aNodeStart,
599 AnglesGrp->isChecked(), anAngles,
600 BasePointGrp->isChecked(), aBasePoint);
604 bool NeedGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
605 SMESH::ElementType ElemType = SMESH::FACE;
606 if( GetConstructorId() == 0 )
607 ElemType = SMESH::EDGE;
608 if( !MeshCheck->isChecked() ) {
609 SMESH::ListOfGroups_var groups =
610 aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(),
611 anAngles, LinearAnglesCheck->isChecked(),
612 BasePointGrp->isChecked(), aBasePoint,
613 NeedGroups, ElemType, retVal);
616 SMESH::ListOfGroups_var groups =
617 aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(),
618 anAngles, LinearAnglesCheck->isChecked(),
619 BasePointGrp->isChecked(), aBasePoint,
620 NeedGroups, ElemType, retVal);
624 //asl: if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
625 //asl: myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
630 case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
631 SUIT_MessageBox::warning(this,
633 tr("NO_ELEMENTS_SELECTED"));
635 case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
636 SUIT_MessageBox::warning(this,
638 tr("SELECTED_PATH_IS_NOT_EDGE"));
640 case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
641 SUIT_MessageBox::warning(this,
643 tr("BAD_SHAPE_TYPE"));
645 case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
646 SUIT_MessageBox::warning(this,
648 tr("EXTR_BAD_STARTING_NODE"));
650 case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
651 SUIT_MessageBox::warning(this,
653 tr("WRONG_ANGLES_NUMBER"));
655 case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
656 SUIT_MessageBox::warning(this,
658 tr("CANT_GET_TANGENT"));
660 case SMESH::SMESH_MeshEditor::EXTR_OK:
667 //mySelectionMgr->clearSelected();
668 SMESH::Update( myMeshActor->getIO(), myMeshActor->GetVisibility() );
669 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
670 mySMESHGUI->updateObjBrowser(true); // new groups may appear
671 //SMESH::UpdateView();
673 ConstructorsClicked(GetConstructorId());
677 //=================================================================================
678 // function : ClickOnOk()
679 // purpose : Called when user presses <OK> button
680 //=================================================================================
681 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
687 //=================================================================================
688 // function : ClickOnHelp()
690 //=================================================================================
691 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp()
693 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
695 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
699 platform = "winapplication";
701 platform = "application";
703 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
704 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
705 arg(app->resourceMgr()->stringValue("ExternalBrowser",
707 arg(myHelpFileName));
711 //=================================================================================
712 // function : reject()
713 // purpose : Called when dialog box is closed
714 //=================================================================================
715 void SMESHGUI_ExtrusionAlongPathDlg::reject()
717 disconnect(mySelectionMgr, 0, this, 0);
718 mySelectionMgr->clearFilters();
719 //mySelectionMgr->clearSelected();
720 if (SMESH::GetCurrentVtkView()) {
721 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
722 SMESH::SetPointRepresentation(false);
723 SMESH::SetPickable();
725 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
726 aViewWindow->SetSelectionMode(ActorSelection);
727 mySMESHGUI->ResetState();
731 //=======================================================================
732 // function : onTextChange()
734 //=======================================================================
735 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
737 QLineEdit* send = (QLineEdit*)sender();
745 if (send != StartPointLineEdit && send != ElementsLineEdit)
746 send = ElementsLineEdit;
748 if (send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit) {
749 // hilight entered elements
750 SMDS_Mesh* aMesh = 0;
752 aMesh = myMeshActor->GetObject()->GetMesh();
755 //mySelectionMgr->clearSelected();
756 //mySelectionMgr->AddIObject(myMeshActor->getIO());
758 aList.Append(myMeshActor->getIO());
759 mySelectionMgr->setSelectedObjects(aList, false);
761 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
763 const Handle(SALOME_InteractiveObject)& anIO = myMeshActor->getIO();
764 TColStd_MapOfInteger newIndices;
765 for (int i = 0; i < aListId.count(); i++) {
766 long ind = aListId[ i ].toLong(&bOk);
768 const SMDS_MeshElement* e = aMesh->FindElement(ind);
770 // check also type of element
771 bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge ||
772 Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
774 newIndices.Add(e->GetID());
778 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
779 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
780 aViewWindow->highlight( anIO, true, true );
783 else if (send == StartPointLineEdit &&
784 myEditCurrentArgument == StartPointLineEdit) {
785 if (!myPath->_is_nil()) {
786 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
787 SMDS_Mesh* aMesh = 0;
789 aMesh = aPathActor->GetObject()->GetMesh();
791 //mySelectionMgr->clearSelected();
792 //mySelectionMgr->AddIObject(aPathActor->getIO());
794 aList.Append(aPathActor->getIO());
795 mySelectionMgr->setSelectedObjects(aList, false);
798 long ind = theNewText.toLong(&bOk);
800 const SMDS_MeshNode* n = aMesh->FindNode(ind);
802 //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) {
803 TColStd_MapOfInteger newIndices;
804 newIndices.Add(n->GetID());
805 mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false );
806 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
807 aViewWindow->highlight( aPathActor->getIO(), true, true );
815 //=================================================================================
816 // function : SelectionIntoArgument()
817 // purpose : Called when selection as changed or other case
818 //=================================================================================
819 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
823 // return if dialog box is inactive
824 if (!GroupButtons->isEnabled())
827 // selected objects count
828 const SALOME_ListIO& aList = mySelector->StoredIObjects();
829 int nbSel = aList.Extent();
836 if (myEditCurrentArgument == ElementsLineEdit) {
837 // we are now selecting mesh elements (or whole mesh/submesh/group)
839 ElementsLineEdit->clear();
840 myMesh = SMESH::SMESH_Mesh::_nil();
841 myIDSource = SMESH::SMESH_IDSource::_nil();
844 // try to get mesh from selection
845 Handle(SALOME_InteractiveObject) IO = aList.First();
846 myMesh = SMESH::GetMeshByIO(IO);
847 if (myMesh->_is_nil())
850 // MakeGroups is available if there are groups
851 if ( myMesh->NbGroups() == 0 ) {
852 MakeGroupsCheck->setChecked(false);
853 MakeGroupsCheck->setEnabled(false);
855 MakeGroupsCheck->setEnabled(true);
858 myMeshActor = SMESH::FindActorByObject(myMesh);
862 if (MeshCheck->isChecked()) {
863 // If "Select whole mesh, submesh or group" check box is on ->
864 // get ID source and put it's name to the edit box
866 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
868 myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
869 ElementsLineEdit->setText(aString);
871 // If "Select whole mesh, submesh or group" check box is off ->
872 // try to get selected elements IDs
874 //int aNbUnits = SMESH::GetNameOfSelectedElements(mySelectionMgr, aString);
875 SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
876 ElementsLineEdit->setText(aString);
879 else if (myEditCurrentArgument == PathMeshLineEdit) {
880 // we are now selecting path mesh
882 PathMeshLineEdit->clear();
883 myPath = SMESH::SMESH_IDSource::_nil();
884 StartPointLineEdit->clear();
886 // try to get mesh from selection
887 Handle(SALOME_InteractiveObject) IO = aList.First();
888 myPath = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
889 if( myPath->_is_nil() )
893 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
894 PathMeshLineEdit->setText(aString);
896 else if (myEditCurrentArgument == StartPointLineEdit) {
897 // we are now selecting start point of path
899 StartPointLineEdit->clear();
901 // return if path mesh or path shape is not yet selected
902 if( myPath->_is_nil() )
905 // try to get shape from selection
906 Handle(SALOME_InteractiveObject) IO = aList.First();
908 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
913 int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aPathActor->getIO(), aString);
915 StartPointLineEdit->setText(aString.trimmed());
917 } else if (myEditCurrentArgument == XSpin) {
918 // we are now selecting base point
919 // reset is not performed here!
921 // return if is not enabled
922 if (!BasePointGrp->isChecked())
925 // try to get shape from selection
926 Handle(SALOME_InteractiveObject) IO = aList.First();
928 // check if geom vertex is selected
929 GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
930 TopoDS_Vertex aVertex;
931 if (!aGeomObj->_is_nil()) {
932 if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) {
933 gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
934 XSpin->SetValue(aPnt.X());
935 YSpin->SetValue(aPnt.Y());
936 ZSpin->SetValue(aPnt.Z());
941 // check if smesh node is selected
942 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO);
943 if (aMesh->_is_nil())
947 int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myMeshActor->getIO(), aString);
948 // return if more than one node is selected
952 SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh);
956 SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
960 const SMDS_MeshNode* n = mesh->FindNode(aString.toLong());
964 XSpin->SetValue(n->X());
965 YSpin->SetValue(n->Y());
966 ZSpin->SetValue(n->Z());
970 //=================================================================================
971 // function : SetEditCurrentArgument()
973 //=================================================================================
974 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
976 QToolButton* send = (QToolButton*)sender();
977 if (send != SelectElementsButton &&
978 send != SelectPathMeshButton &&
979 send != SelectStartPointButton &&
980 send != SelectBasePointButton)
982 SetEditCurrentArgument(send);
985 //=================================================================================
986 // function : SetEditCurrentArgument()
988 //=================================================================================
989 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button)
991 disconnect(mySelectionMgr, 0, this, 0);
992 mySelectionMgr->clearSelected();
993 mySelectionMgr->clearFilters();
994 SMESH::SetPickable();
996 if (button == SelectElementsButton) {
997 myEditCurrentArgument = ElementsLineEdit;
998 SMESH::SetPointRepresentation(false);
999 if (MeshCheck->isChecked()) {
1000 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1001 aViewWindow->SetSelectionMode(ActorSelection);
1002 mySelectionMgr->installFilter(myElementsFilter);
1004 if (Elements1dRB->isChecked())
1006 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1007 aViewWindow->SetSelectionMode(EdgeSelection);
1009 else if (Elements2dRB->isChecked())
1011 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1012 aViewWindow->SetSelectionMode(FaceSelection);
1015 } else if (button == SelectPathMeshButton) {
1016 myEditCurrentArgument = PathMeshLineEdit;
1017 SMESH::SetPointRepresentation(false);
1018 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1019 aViewWindow->SetSelectionMode(ActorSelection);
1020 mySelectionMgr->installFilter(myPathMeshFilter);
1022 else if (button == SelectStartPointButton) {
1023 myEditCurrentArgument = StartPointLineEdit;
1024 //if (!myPathMesh->_is_nil()) {
1025 if (!myPath->_is_nil()) {
1026 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
1028 SMESH::SetPointRepresentation(true);
1029 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1030 aViewWindow->SetSelectionMode(NodeSelection);
1031 SMESH::SetPickable(aPathActor);
1035 else if (button == SelectBasePointButton) {
1036 myEditCurrentArgument = XSpin;
1037 SMESH::SetPointRepresentation(true);
1038 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1039 aViewWindow->SetSelectionMode(NodeSelection);
1041 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
1042 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter(GROUP);
1043 SMESH_NumberFilter* aVertexFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE,
1045 QList<SUIT_SelectionFilter*> aListOfFilters;
1046 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
1047 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
1048 if (aVertexFilter) aListOfFilters.append(aVertexFilter);
1050 mySelectionMgr->installFilter(new SMESH_LogicalFilter
1051 (aListOfFilters, SMESH_LogicalFilter::LO_OR));
1054 if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus())
1055 myEditCurrentArgument->setFocus();
1057 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1058 SelectionIntoArgument();
1061 //=================================================================================
1062 // function : DeactivateActiveDialog()
1063 // purpose : Deactivates this dialog
1064 //=================================================================================
1065 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1067 if (ConstructorsBox->isEnabled()) {
1068 ConstructorsBox->setEnabled(false);
1069 GroupArguments->setEnabled(false);
1070 GroupButtons->setEnabled(false);
1071 mySMESHGUI->ResetState();
1072 mySMESHGUI->SetActiveDialogBox(0);
1076 //=================================================================================
1077 // function : ActivateThisDialog()
1078 // purpose : Activates this dialog
1079 //=================================================================================
1080 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1082 // Emit a signal to deactivate the active dialog
1083 mySMESHGUI->EmitSignalDeactivateDialog();
1084 ConstructorsBox->setEnabled(true);
1085 GroupArguments->setEnabled(true);
1086 GroupButtons->setEnabled(true);
1088 mySMESHGUI->SetActiveDialogBox(this);
1090 ConstructorsClicked(GetConstructorId());
1091 SelectionIntoArgument();
1094 //=================================================================================
1095 // function : enterEvent()
1096 // purpose : Mouse enter event
1097 //=================================================================================
1098 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*)
1100 if (!ConstructorsBox->isEnabled())
1101 ActivateThisDialog();
1104 //=======================================================================
1105 // function : onSelectMesh()
1107 //=======================================================================
1108 void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
1110 bool toSelectMesh = MeshCheck->isChecked();
1112 ElementsLineEdit->setReadOnly(toSelectMesh);
1113 ElementsLineEdit->setValidator(toSelectMesh ? 0 : myIdValidator);
1114 ElementsLab->setText(toSelectMesh ? tr("SMESH_NAME") : tr("SMESH_ID_ELEMENTS"));
1115 ElementsLineEdit->clear();
1116 myFilterBtn->setEnabled(!toSelectMesh);
1118 SetEditCurrentArgument(SelectElementsButton);
1121 //=================================================================================
1122 // function : GetConstructorId()
1124 //=================================================================================
1125 int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1127 return GroupConstructors->checkedId();
1130 //=======================================================================
1131 // function : OnAngleAdded()
1132 // purpose : Called when user adds angle to the list
1133 //=======================================================================
1134 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
1136 if( !checkParameters( true, 1, AngleSpin ) )
1139 AnglesList->addItem(AngleSpin->text());
1140 myAnglesList.append(AngleSpin->GetValue());
1142 updateLinearAngles();
1145 //=======================================================================
1146 // function : OnAngleRemoved()
1147 // purpose : Called when user removes angle(s) from the list
1148 //=======================================================================
1149 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
1151 QList<QListWidgetItem*> aList = AnglesList->selectedItems();
1152 QListWidgetItem* anItem;
1153 foreach(anItem, aList) {
1154 myAnglesList.removeAt(AnglesList->row(anItem));
1158 updateLinearAngles();
1161 //=================================================================================
1162 // function : eventFilter()
1163 // purpose : event filter ???
1164 //=================================================================================
1165 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event)
1167 if (event->type() == QEvent::KeyPress) {
1168 QKeyEvent* ke = (QKeyEvent*)event;
1169 if (object == AnglesList) {
1170 if (ke->key() == Qt::Key_Delete)
1174 else if (event->type() == QEvent::FocusIn) {
1175 if (object == ElementsLineEdit) {
1176 if (myEditCurrentArgument != ElementsLineEdit)
1177 SetEditCurrentArgument(SelectElementsButton);
1179 else if (object == StartPointLineEdit) {
1180 if (myEditCurrentArgument != StartPointLineEdit)
1181 SetEditCurrentArgument(SelectStartPointButton);
1183 else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) {
1184 if (myEditCurrentArgument != XSpin)
1185 SetEditCurrentArgument(SelectBasePointButton);
1188 return QDialog::eventFilter(object, event);
1191 //=================================================================================
1192 // function : keyPressEvent()
1194 //=================================================================================
1195 void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e )
1197 QDialog::keyPressEvent( e );
1198 if ( e->isAccepted() )
1201 if ( e->key() == Qt::Key_F1 ) {
1207 //=================================================================================
1208 // function : setFilters()
1209 // purpose : SLOT. Called when "Filter" button pressed.
1210 //=================================================================================
1211 void SMESHGUI_ExtrusionAlongPathDlg::setFilters()
1213 if(myMesh->_is_nil()) {
1214 SUIT_MessageBox::critical(this,
1216 tr("NO_MESH_SELECTED"));
1222 types.append( SMESH::EDGE );
1223 types.append( SMESH::FACE );
1224 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1226 myFilterDlg->Init( Elements1dRB->isChecked() ? SMESH::EDGE : SMESH::FACE );
1228 myFilterDlg->SetSelection();
1229 myFilterDlg->SetMesh( myMesh );
1230 myFilterDlg->SetSourceWg( ElementsLineEdit );
1232 myFilterDlg->show();
1235 //=================================================================================
1236 // function : isValid
1238 //=================================================================================
1239 bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
1241 return checkParameters( true, 3, XSpin, YSpin, ZSpin );
1244 //=================================================================================
1245 // function : updateLinearAngles
1247 //=================================================================================
1248 void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
1250 bool enableLinear = true;
1251 for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
1252 if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
1253 enableLinear = false;
1254 anItem->text().toDouble(&enableLinear);
1260 LinearAnglesCheck->setChecked( false );
1261 LinearAnglesCheck->setEnabled( enableLinear );