1 // Copyright (C) 2007-2011 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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_ExtrusionAlongPathDlg.cxx
25 // Author : Vadim SANDLER, Open CASCADE S.A.S.
28 #include "SMESHGUI_ExtrusionAlongPathDlg.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"
36 #include "SMESHGUI_FilterDlg.h"
37 #include "SMESHGUI_MeshEditPreview.h"
39 #include <SMESH_Actor.h>
40 #include <SMESH_TypeFilter.hxx>
41 #include <SMESH_NumberFilter.hxx>
42 #include <SMESH_LogicalFilter.hxx>
44 #include <SMDS_Mesh.hxx>
46 // SALOME GEOM includes
49 // SALOME GUI includes
50 #include <SUIT_ResourceMgr.h>
51 #include <SUIT_OverrideCursor.h>
52 #include <SUIT_Desktop.h>
53 #include <SUIT_MessageBox.h>
54 #include <SUIT_Session.h>
56 #include <LightApp_Application.h>
57 #include <LightApp_SelectionMgr.h>
59 #include <SVTK_ViewWindow.h>
62 #include <BRep_Tool.hxx>
63 #include <TopoDS_Vertex.hxx>
65 #include <TColStd_MapOfInteger.hxx>
68 #include <QButtonGroup>
72 #include <QPushButton>
73 #include <QToolButton>
74 #include <QRadioButton>
76 #include <QListWidget>
77 #include <QVBoxLayout>
78 #include <QHBoxLayout>
79 #include <QGridLayout>
83 #include <SALOMEconfig.h>
84 #include CORBA_SERVER_HEADER(SMESH_Group)
85 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
90 class SMESHGUI_ExtrusionAlongPathDlg::SetBusy
93 SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg )
101 myDlg->myBusy = false;
105 SMESHGUI_ExtrusionAlongPathDlg* myDlg;
108 //=================================================================================
109 // function : SMESHGUI_ExtrusionAlongPathDlg()
110 // purpose : constructor
111 //=================================================================================
112 SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule )
113 : SMESHGUI_PreviewDlg( 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 ElementsLineEdit->setMaxLength(-1);
171 myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
172 connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
174 // Controls for the whole mesh selection
175 MeshCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
177 // Controls for path selection
178 PathGrp = new QGroupBox(tr("SMESH_PATH"), GroupArguments);
179 QGridLayout* PathGrpLayout = new QGridLayout(PathGrp);
180 PathGrpLayout->setSpacing(SPACING); PathGrpLayout->setMargin(MARGIN);
182 // Controls for path mesh selection
183 QLabel* PathMeshLab = new QLabel(tr("SMESH_PATH_MESH"), PathGrp);
185 SelectPathMeshButton = new QToolButton(PathGrp);
186 SelectPathMeshButton->setIcon(selectImage);
188 PathMeshLineEdit = new QLineEdit(PathGrp);
189 PathMeshLineEdit->setReadOnly(true);
191 // Controls for path starting point selection
192 QLabel* StartPointLab = new QLabel(tr("SMESH_PATH_START"), PathGrp);
194 SelectStartPointButton = new QToolButton(PathGrp);
195 SelectStartPointButton->setIcon(selectImage);
197 StartPointLineEdit = new QLineEdit(PathGrp);
198 StartPointLineEdit->setValidator(new QIntValidator(this));
201 PathGrpLayout->addWidget(PathMeshLab, 0, 0);
202 PathGrpLayout->addWidget(SelectPathMeshButton, 0, 1);
203 PathGrpLayout->addWidget(PathMeshLineEdit, 0, 2);
204 PathGrpLayout->addWidget(StartPointLab, 1, 0);
205 PathGrpLayout->addWidget(SelectStartPointButton, 1, 1);
206 PathGrpLayout->addWidget(StartPointLineEdit, 1, 2);
208 BasePointGrp = new QGroupBox(tr("SMESH_BASE_POINT"), GroupArguments);
209 BasePointGrp->setCheckable(true);
210 BasePointGrp->setChecked(false);
211 QHBoxLayout* BasePointGrpLayout = new QHBoxLayout(BasePointGrp);
212 BasePointGrpLayout->setSpacing(SPACING); BasePointGrpLayout->setMargin(MARGIN);
214 SelectBasePointButton = new QToolButton(BasePointGrp);
215 SelectBasePointButton->setIcon(selectImage);
217 QLabel* XLab = new QLabel(tr("SMESH_X"), BasePointGrp);
218 XSpin = new SMESHGUI_SpinBox(BasePointGrp);
219 QLabel* YLab = new QLabel(tr("SMESH_Y"), BasePointGrp);
220 YSpin = new SMESHGUI_SpinBox(BasePointGrp);
221 QLabel* ZLab = new QLabel(tr("SMESH_Z"), BasePointGrp);
222 ZSpin = new SMESHGUI_SpinBox(BasePointGrp);
225 BasePointGrpLayout->addWidget(SelectBasePointButton);
226 BasePointGrpLayout->addWidget(XLab);
227 BasePointGrpLayout->addWidget(XSpin);
228 BasePointGrpLayout->addWidget(YLab);
229 BasePointGrpLayout->addWidget(YSpin);
230 BasePointGrpLayout->addWidget(ZLab);
231 BasePointGrpLayout->addWidget(ZSpin);
233 AnglesGrp = new QGroupBox(tr("SMESH_ANGLES"), GroupArguments);
234 AnglesGrp->setCheckable(true);
235 AnglesGrp->setChecked(false);
236 QGridLayout* AnglesGrpLayout = new QGridLayout(AnglesGrp);
237 AnglesGrpLayout->setSpacing(SPACING); AnglesGrpLayout->setMargin(MARGIN);
239 AnglesList = new QListWidget(AnglesGrp);
240 AnglesList->setSelectionMode(QListWidget::ExtendedSelection);
242 AddAngleButton = new QToolButton(AnglesGrp);
243 AddAngleButton->setIcon(addImage);
245 RemoveAngleButton = new QToolButton(AnglesGrp);
246 RemoveAngleButton->setIcon(removeImage);
248 AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
250 LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp);
253 AnglesGrpLayout->addWidget(AnglesList, 0, 0, 4, 1);
254 AnglesGrpLayout->addWidget(AddAngleButton, 0, 1);
255 AnglesGrpLayout->addWidget(RemoveAngleButton, 2, 1);
256 AnglesGrpLayout->addWidget(AngleSpin, 0, 2);
257 AnglesGrpLayout->addWidget(LinearAnglesCheck, 4, 0);
258 AnglesGrpLayout->setRowMinimumHeight(1, 10);
259 AnglesGrpLayout->setRowStretch(3, 10);
261 // CheckBox for groups generation
262 MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
263 MakeGroupsCheck->setChecked(true);
266 myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
269 GroupArgumentsLayout->addWidget(ElementsLab, 0, 0);
270 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
271 GroupArgumentsLayout->addWidget(ElementsLineEdit, 0, 2);
272 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
273 GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 4);
274 GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 4);
275 GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 4);
276 GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 4);
277 GroupArgumentsLayout->addWidget(myPreviewCheckBox, 5, 0, 1, 4);
278 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
280 /***************************************************************/
281 // common buttons group box
282 GroupButtons = new QGroupBox(this);
283 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
284 GroupButtonsLayout->setSpacing(SPACING); GroupButtonsLayout->setMargin(MARGIN);
286 OkButton = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
287 OkButton->setAutoDefault(true);
288 OkButton->setDefault(true);
290 ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
291 ApplyButton->setAutoDefault(true);
293 CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
294 CloseButton->setAutoDefault(true);
296 HelpButton = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
297 HelpButton->setAutoDefault(true);
300 GroupButtonsLayout->addWidget(OkButton);
301 GroupButtonsLayout->addSpacing(10);
302 GroupButtonsLayout->addWidget(ApplyButton);
303 GroupButtonsLayout->addSpacing(10);
304 GroupButtonsLayout->addStretch();
305 GroupButtonsLayout->addWidget(CloseButton);
306 GroupButtonsLayout->addWidget(HelpButton);
308 /***************************************************************/
310 topLayout->addWidget(ConstructorsBox);
311 topLayout->addWidget(GroupArguments);
312 topLayout->addWidget(GroupButtons);
314 /***************************************************************/
316 XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
317 YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
318 ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
319 AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, "angle_precision");
321 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
323 mySMESHGUI->SetActiveDialogBox(this);
325 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
326 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
327 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
329 QList<SUIT_SelectionFilter*> aListOfFilters;
330 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
331 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
333 myElementsFilter = new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
334 //myPathMeshFilter = new SMESH_TypeFilter (MESH);
335 myPathMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
337 myHelpFileName = "extrusion_along_path_page.html";
341 /***************************************************************/
342 // signals-slots connections
343 connect(OkButton, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
344 connect(CloseButton, SIGNAL(clicked()), this, SLOT(reject()));
345 connect(ApplyButton, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
346 connect(HelpButton, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
348 connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
349 connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
351 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
353 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
354 connect(SelectPathMeshButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
355 connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
356 connect(SelectBasePointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
358 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
359 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
360 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
362 connect(ElementsLineEdit, SIGNAL(textChanged(const QString&)),
363 SLOT(onTextChange(const QString&)));
364 connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)),
365 SLOT(onTextChange(const QString&)));
367 connect(MeshCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh()));
369 connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
370 connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
371 connect(ZSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
372 connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
373 connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
374 connect(LinearAnglesCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh()));
377 //To Connect preview check box
378 connectPreviewControl();
380 AnglesList->installEventFilter(this);
381 ElementsLineEdit->installEventFilter(this);
382 StartPointLineEdit->installEventFilter(this);
383 XSpin->editor()->installEventFilter(this);
384 YSpin->editor()->installEventFilter(this);
385 ZSpin->editor()->installEventFilter(this);
388 //=================================================================================
389 // function : ~SMESHGUI_ExtrusionAlongPathDlg()
390 // purpose : destructor
391 //=================================================================================
392 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
394 // no need to delete child widgets, Qt does it all for us
395 if ( myFilterDlg != 0 ) {
396 myFilterDlg->setParent( 0 );
401 //=================================================================================
403 // purpose : initialization
404 //=================================================================================
405 void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls)
408 myEditCurrentArgument = 0;
410 myMesh = SMESH::SMESH_Mesh::_nil();
411 myIDSource = SMESH::SMESH_IDSource::_nil();
413 myPath = SMESH::SMESH_IDSource::_nil();
415 ElementsLineEdit->clear();
416 PathMeshLineEdit->clear();
417 StartPointLineEdit->clear();
420 XSpin->SetValue(0.0);
421 YSpin->SetValue(0.0);
422 ZSpin->SetValue(0.0);
424 AngleSpin->SetValue(45);
425 MeshCheck->setChecked(false);
426 ConstructorsClicked(0);
428 myPreviewCheckBox->setChecked(false);
429 onDisplaySimulation(false);
431 SetEditCurrentArgument(0);
434 //=================================================================================
435 // function : ConstructorsClicked()
436 // purpose : Called when user changes type of elements (1d / 2d)
437 //=================================================================================
438 void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type)
440 if (myType == type) return;
442 disconnect(mySelectionMgr, 0, this, 0);
447 GroupArguments->setTitle(tr("EXTRUSION_1D"));
449 GroupArguments->setTitle(tr("EXTRUSION_2D"));
451 // clear elements ID list
452 if (!MeshCheck->isChecked()) {
453 ElementsLineEdit->clear();
455 // set selection mode if necessary
456 if (myEditCurrentArgument == ElementsLineEdit) {
457 mySelectionMgr->clearSelected();
458 mySelectionMgr->clearFilters();
459 SMESH::SetPickable();
461 SMESH::SetPointRepresentation(false);
462 if (MeshCheck->isChecked()) {
463 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
464 aViewWindow->SetSelectionMode(ActorSelection);
465 mySelectionMgr->installFilter(myElementsFilter);
469 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
470 aViewWindow->SetSelectionMode(EdgeSelection);
474 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
475 aViewWindow->SetSelectionMode(FaceSelection);
479 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
484 //=================================================================================
485 // function : ClickOnApply()
486 // purpose : Called when user presses <Apply> button
487 //=================================================================================
488 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
490 if (mySMESHGUI->isActiveStudyLocked())
493 //if (myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() ||
494 // !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil())
495 if ( myMesh->_is_nil() || (MeshCheck->isChecked() && myIDSource->_is_nil()) ||
496 /*!myMeshActor ||*/ myPath->_is_nil() )
502 SMESH::long_array_var anElementsId = getSelectedElements();
504 if (StartPointLineEdit->text().trimmed().isEmpty()) {
509 long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
514 QStringList aParameters;
517 SMESH::double_array_var anAngles = getAngles();
519 for (int i = 0; i < myAnglesList.count(); i++)
520 aParameters << AnglesList->item(i)->text();
524 SMESH::PointStruct aBasePoint;
525 if (BasePointGrp->isChecked()) {
526 aBasePoint.x = XSpin->GetValue();
527 aBasePoint.y = YSpin->GetValue();
528 aBasePoint.z = ZSpin->GetValue();
531 aParameters << XSpin->text();
532 aParameters << YSpin->text();
533 aParameters << ZSpin->text();
536 SUIT_OverrideCursor wc;
537 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
538 //if ( LinearAnglesCheck->isChecked() ) {
539 // anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
542 SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
544 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
545 if( MeshCheck->isChecked() ) {
546 if( GetConstructorId() == 0 )
547 SMESH::ListOfGroups_var groups =
548 aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh,
549 myPathShape, aNodeStart,
550 AnglesGrp->isChecked(), anAngles,
551 BasePointGrp->isChecked(), aBasePoint, retVal);
553 SMESH::ListOfGroups_var groups =
554 aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh,
555 myPathShape, aNodeStart,
556 AnglesGrp->isChecked(), anAngles,
557 BasePointGrp->isChecked(), aBasePoint, retVal);
560 SMESH::ListOfGroups_var groups =
561 aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
562 myPathShape, aNodeStart,
563 AnglesGrp->isChecked(), anAngles,
564 BasePointGrp->isChecked(), aBasePoint, retVal);
567 if( MeshCheck->isChecked() ) {
568 if( GetConstructorId() == 0 )
569 retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh,
570 myPathShape, aNodeStart,
571 AnglesGrp->isChecked(), anAngles,
572 BasePointGrp->isChecked(), aBasePoint);
574 retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh,
575 myPathShape, aNodeStart,
576 AnglesGrp->isChecked(), anAngles,
577 BasePointGrp->isChecked(), aBasePoint);
580 retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
581 myPathShape, aNodeStart,
582 AnglesGrp->isChecked(), anAngles,
583 BasePointGrp->isChecked(), aBasePoint);
587 bool NeedGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
588 SMESH::ElementType ElemType = SMESH::FACE;
589 if( GetConstructorId() == 0 )
590 ElemType = SMESH::EDGE;
591 if( !MeshCheck->isChecked() ) {
592 SMESH::ListOfGroups_var groups =
593 aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(),
594 anAngles, LinearAnglesCheck->isChecked(),
595 BasePointGrp->isChecked(), aBasePoint,
596 NeedGroups, ElemType, retVal);
599 SMESH::ListOfGroups_var groups =
600 aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(),
601 anAngles, LinearAnglesCheck->isChecked(),
602 BasePointGrp->isChecked(), aBasePoint,
603 NeedGroups, ElemType, retVal);
607 if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
608 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
613 case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
614 SUIT_MessageBox::warning(this,
616 tr("NO_ELEMENTS_SELECTED"));
618 case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
619 SUIT_MessageBox::warning(this,
621 tr("SELECTED_PATH_IS_NOT_EDGE"));
623 case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
624 SUIT_MessageBox::warning(this,
626 tr("BAD_SHAPE_TYPE"));
628 case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
629 SUIT_MessageBox::warning(this,
631 tr("EXTR_BAD_STARTING_NODE"));
633 case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
634 SUIT_MessageBox::warning(this,
636 tr("WRONG_ANGLES_NUMBER"));
638 case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
639 SUIT_MessageBox::warning(this,
641 tr("CANT_GET_TANGENT"));
643 case SMESH::SMESH_MeshEditor::EXTR_OK:
650 //mySelectionMgr->clearSelected();
652 SMESH::Update( myMeshActor->getIO(), myMeshActor->GetVisibility() );
654 SMESHGUI::Modified();
656 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
657 mySMESHGUI->updateObjBrowser(true); // new groups may appear
658 //SMESH::UpdateView();
660 ConstructorsClicked(GetConstructorId());
664 //=================================================================================
665 // function : ClickOnOk()
666 // purpose : Called when user presses <OK> button
667 //=================================================================================
668 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
674 //=================================================================================
675 // function : ClickOnHelp()
677 //=================================================================================
678 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp()
680 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
682 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
686 platform = "winapplication";
688 platform = "application";
690 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
691 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
692 arg(app->resourceMgr()->stringValue("ExternalBrowser",
694 arg(myHelpFileName));
698 //=================================================================================
699 // function : reject()
700 // purpose : Called when dialog box is closed
701 //=================================================================================
702 void SMESHGUI_ExtrusionAlongPathDlg::reject()
704 disconnect(mySelectionMgr, 0, this, 0);
705 mySelectionMgr->clearFilters();
706 //mySelectionMgr->clearSelected();
707 if (SMESH::GetCurrentVtkView()) {
708 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
709 SMESH::SetPointRepresentation(false);
710 SMESH::SetPickable();
712 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
713 aViewWindow->SetSelectionMode(ActorSelection);
714 mySMESHGUI->ResetState();
718 //=======================================================================
719 // function : onTextChange()
721 //=======================================================================
722 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
724 QLineEdit* send = (QLineEdit*)sender();
732 if (send != StartPointLineEdit && send != ElementsLineEdit)
733 send = ElementsLineEdit;
735 if (send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit) {
736 // hilight entered elements
737 SMDS_Mesh* aMesh = 0;
739 aMesh = myMeshActor->GetObject()->GetMesh();
742 //mySelectionMgr->clearSelected();
743 //mySelectionMgr->AddIObject(myMeshActor->getIO());
745 aList.Append(myMeshActor->getIO());
746 mySelectionMgr->setSelectedObjects(aList, false);
748 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
750 const Handle(SALOME_InteractiveObject)& anIO = myMeshActor->getIO();
751 TColStd_MapOfInteger newIndices;
752 for (int i = 0; i < aListId.count(); i++) {
753 long ind = aListId[ i ].toLong(&bOk);
755 const SMDS_MeshElement* e = aMesh->FindElement(ind);
757 // check also type of element
758 bool typeMatch = (Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge) ||
759 (Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face);
761 newIndices.Add(e->GetID());
765 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
766 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
767 aViewWindow->highlight( anIO, true, true );
770 else if (send == StartPointLineEdit &&
771 myEditCurrentArgument == StartPointLineEdit) {
772 if (!myPath->_is_nil()) {
773 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
774 SMDS_Mesh* aMesh = 0;
776 aMesh = aPathActor->GetObject()->GetMesh();
778 //mySelectionMgr->clearSelected();
779 //mySelectionMgr->AddIObject(aPathActor->getIO());
781 aList.Append(aPathActor->getIO());
782 mySelectionMgr->setSelectedObjects(aList, false);
785 long ind = theNewText.toLong(&bOk);
787 const SMDS_MeshNode* n = aMesh->FindNode(ind);
789 //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) {
790 TColStd_MapOfInteger newIndices;
791 newIndices.Add(n->GetID());
792 mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false );
793 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
794 aViewWindow->highlight( aPathActor->getIO(), true, true );
802 //=================================================================================
803 // function : SelectionIntoArgument()
804 // purpose : Called when selection as changed or other case
805 //=================================================================================
806 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
810 // return if dialog box is inactive
811 if (!GroupButtons->isEnabled())
814 // selected objects count
815 const SALOME_ListIO& aList = mySelector->StoredIObjects();
816 int nbSel = aList.Extent();
823 if (myEditCurrentArgument == ElementsLineEdit) {
824 // we are now selecting mesh elements (or whole mesh/submesh/group)
826 ElementsLineEdit->clear();
827 myMesh = SMESH::SMESH_Mesh::_nil();
828 myIDSource = SMESH::SMESH_IDSource::_nil();
831 // try to get mesh from selection
832 Handle(SALOME_InteractiveObject) IO = aList.First();
833 myMesh = SMESH::GetMeshByIO(IO);
834 if (myMesh->_is_nil())
837 // MakeGroups is available if there are groups
838 if ( myMesh->NbGroups() == 0 ) {
839 MakeGroupsCheck->setChecked(false);
840 MakeGroupsCheck->setEnabled(false);
842 MakeGroupsCheck->setEnabled(true);
845 myMeshActor = SMESH::FindActorByObject(myMesh);
846 if (!myMeshActor && !MeshCheck->isChecked())
849 if (MeshCheck->isChecked()) {
850 // If "Select whole mesh, submesh or group" check box is on ->
851 // get ID source and put it's name to the edit box
853 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
855 myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
856 ElementsLineEdit->setText(aString);
858 // If "Select whole mesh, submesh or group" check box is off ->
859 // try to get selected elements IDs
861 //int aNbUnits = SMESH::GetNameOfSelectedElements(mySelectionMgr, aString);
862 SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
863 ElementsLineEdit->setText(aString);
866 else if (myEditCurrentArgument == PathMeshLineEdit) {
867 // we are now selecting path mesh
869 PathMeshLineEdit->clear();
870 myPath = SMESH::SMESH_IDSource::_nil();
871 StartPointLineEdit->clear();
873 // try to get mesh from selection
874 Handle(SALOME_InteractiveObject) IO = aList.First();
875 myPath = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
876 if( myPath->_is_nil() )
880 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
881 PathMeshLineEdit->setText(aString);
883 else if (myEditCurrentArgument == StartPointLineEdit) {
884 // we are now selecting start point of path
886 StartPointLineEdit->clear();
888 // return if path mesh or path shape is not yet selected
889 if( myPath->_is_nil() )
892 // try to get shape from selection
893 Handle(SALOME_InteractiveObject) IO = aList.First();
895 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
900 int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aPathActor->getIO(), aString);
902 StartPointLineEdit->setText(aString.trimmed());
904 } else if (myEditCurrentArgument == XSpin) {
905 // we are now selecting base point
906 // reset is not performed here!
908 // return if is not enabled
909 if (!BasePointGrp->isChecked())
912 // try to get shape from selection
913 Handle(SALOME_InteractiveObject) IO = aList.First();
915 // check if geom vertex is selected
916 GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
917 TopoDS_Vertex aVertex;
918 if (!aGeomObj->_is_nil()) {
919 if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) {
920 gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
921 XSpin->SetValue(aPnt.X());
922 YSpin->SetValue(aPnt.Y());
923 ZSpin->SetValue(aPnt.Z());
928 // check if smesh node is selected
929 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO);
930 if (aMesh->_is_nil())
934 int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myMeshActor->getIO(), aString);
935 // return if more than one node is selected
939 SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh);
943 SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
947 const SMDS_MeshNode* n = mesh->FindNode(aString.toLong());
951 XSpin->SetValue(n->X());
952 YSpin->SetValue(n->Y());
953 ZSpin->SetValue(n->Z());
955 onDisplaySimulation(true);
958 //=================================================================================
959 // function : SetEditCurrentArgument()
961 //=================================================================================
962 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
964 QToolButton* send = (QToolButton*)sender();
965 if (send != SelectElementsButton &&
966 send != SelectPathMeshButton &&
967 send != SelectStartPointButton &&
968 send != SelectBasePointButton)
970 SetEditCurrentArgument(send);
973 //=================================================================================
974 // function : SetEditCurrentArgument()
976 //=================================================================================
977 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button)
979 disconnect(mySelectionMgr, 0, this, 0);
980 // mySelectionMgr->clearSelected();
981 mySelectionMgr->clearFilters();
982 SMESH::SetPickable();
984 if (button == SelectElementsButton) {
985 myEditCurrentArgument = ElementsLineEdit;
986 SMESH::SetPointRepresentation(false);
987 if (MeshCheck->isChecked()) {
988 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
989 aViewWindow->SetSelectionMode(ActorSelection);
990 mySelectionMgr->installFilter(myElementsFilter);
992 if (Elements1dRB->isChecked())
994 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
995 aViewWindow->SetSelectionMode(EdgeSelection);
997 else if (Elements2dRB->isChecked())
999 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1000 aViewWindow->SetSelectionMode(FaceSelection);
1003 } else if (button == SelectPathMeshButton) {
1004 myEditCurrentArgument = PathMeshLineEdit;
1005 SMESH::SetPointRepresentation(false);
1006 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1007 aViewWindow->SetSelectionMode(ActorSelection);
1008 mySelectionMgr->installFilter(myPathMeshFilter);
1010 else if (button == SelectStartPointButton) {
1011 myEditCurrentArgument = StartPointLineEdit;
1012 //if (!myPathMesh->_is_nil()) {
1013 if (!myPath->_is_nil()) {
1014 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
1016 SMESH::SetPointRepresentation(true);
1017 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1018 aViewWindow->SetSelectionMode(NodeSelection);
1019 SMESH::SetPickable(aPathActor);
1023 else if (button == SelectBasePointButton) {
1024 myEditCurrentArgument = XSpin;
1025 SMESH::SetPointRepresentation(true);
1026 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1027 aViewWindow->SetSelectionMode(NodeSelection);
1029 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
1030 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter(GROUP);
1031 SMESH_NumberFilter* aVertexFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE,
1033 QList<SUIT_SelectionFilter*> aListOfFilters;
1034 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
1035 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
1036 if (aVertexFilter) aListOfFilters.append(aVertexFilter);
1038 mySelectionMgr->installFilter(new SMESH_LogicalFilter
1039 (aListOfFilters, SMESH_LogicalFilter::LO_OR));
1042 if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus())
1043 myEditCurrentArgument->setFocus();
1045 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1046 SelectionIntoArgument();
1049 //=================================================================================
1050 // function : DeactivateActiveDialog()
1051 // purpose : Deactivates this dialog
1052 //=================================================================================
1053 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1055 if (ConstructorsBox->isEnabled()) {
1056 ConstructorsBox->setEnabled(false);
1057 GroupArguments->setEnabled(false);
1058 GroupButtons->setEnabled(false);
1059 mySMESHGUI->ResetState();
1060 mySMESHGUI->SetActiveDialogBox(0);
1064 //=================================================================================
1065 // function : ActivateThisDialog()
1066 // purpose : Activates this dialog
1067 //=================================================================================
1068 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1070 // Emit a signal to deactivate the active dialog
1071 mySMESHGUI->EmitSignalDeactivateDialog();
1072 ConstructorsBox->setEnabled(true);
1073 GroupArguments->setEnabled(true);
1074 GroupButtons->setEnabled(true);
1076 mySMESHGUI->SetActiveDialogBox(this);
1078 ConstructorsClicked(GetConstructorId());
1079 SelectionIntoArgument();
1082 //=================================================================================
1083 // function : enterEvent()
1084 // purpose : Mouse enter event
1085 //=================================================================================
1086 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*)
1088 if (!ConstructorsBox->isEnabled())
1089 ActivateThisDialog();
1092 //=======================================================================
1093 // function : onSelectMesh()
1095 //=======================================================================
1096 void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
1098 bool toSelectMesh = MeshCheck->isChecked();
1100 ElementsLineEdit->setReadOnly(toSelectMesh);
1101 ElementsLineEdit->setValidator(toSelectMesh ? 0 : myIdValidator);
1102 ElementsLab->setText(toSelectMesh ? tr("SMESH_NAME") : tr("SMESH_ID_ELEMENTS"));
1103 ElementsLineEdit->clear();
1104 myFilterBtn->setEnabled(!toSelectMesh);
1106 SetEditCurrentArgument(SelectElementsButton);
1109 //=================================================================================
1110 // function : GetConstructorId()
1112 //=================================================================================
1113 int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1115 return GroupConstructors->checkedId();
1118 //=======================================================================
1119 // function : OnAngleAdded()
1120 // purpose : Called when user adds angle to the list
1121 //=======================================================================
1122 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
1125 if( !AngleSpin->isValid( msg, true ) ) {
1126 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1127 if ( !msg.isEmpty() )
1129 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1132 AnglesList->addItem(AngleSpin->text());
1133 myAnglesList.append(AngleSpin->GetValue());
1135 updateLinearAngles();
1138 //=======================================================================
1139 // function : OnAngleRemoved()
1140 // purpose : Called when user removes angle(s) from the list
1141 //=======================================================================
1142 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
1144 QList<QListWidgetItem*> aList = AnglesList->selectedItems();
1145 QListWidgetItem* anItem;
1146 foreach(anItem, aList) {
1147 myAnglesList.removeAt(AnglesList->row(anItem));
1151 updateLinearAngles();
1154 //=================================================================================
1155 // function : eventFilter()
1156 // purpose : event filter ???
1157 //=================================================================================
1158 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event)
1160 if (event->type() == QEvent::KeyPress) {
1161 QKeyEvent* ke = (QKeyEvent*)event;
1162 if (object == AnglesList) {
1163 if (ke->key() == Qt::Key_Delete)
1167 else if (event->type() == QEvent::FocusIn) {
1168 if (object == ElementsLineEdit) {
1169 if (myEditCurrentArgument != ElementsLineEdit)
1170 SetEditCurrentArgument(SelectElementsButton);
1172 else if (object == StartPointLineEdit) {
1173 if (myEditCurrentArgument != StartPointLineEdit)
1174 SetEditCurrentArgument(SelectStartPointButton);
1176 else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) {
1177 if (myEditCurrentArgument != XSpin)
1178 SetEditCurrentArgument(SelectBasePointButton);
1181 return QDialog::eventFilter(object, event);
1184 //=================================================================================
1185 // function : keyPressEvent()
1187 //=================================================================================
1188 void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e )
1190 QDialog::keyPressEvent( e );
1191 if ( e->isAccepted() )
1194 if ( e->key() == Qt::Key_F1 ) {
1200 //=================================================================================
1201 // function : setFilters()
1202 // purpose : SLOT. Called when "Filter" button pressed.
1203 //=================================================================================
1204 void SMESHGUI_ExtrusionAlongPathDlg::setFilters()
1206 if(myMesh->_is_nil()) {
1207 SUIT_MessageBox::critical(this,
1209 tr("NO_MESH_SELECTED"));
1215 types.append( SMESH::EDGE );
1216 types.append( SMESH::FACE );
1217 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1219 myFilterDlg->Init( Elements1dRB->isChecked() ? SMESH::EDGE : SMESH::FACE );
1221 myFilterDlg->SetSelection();
1222 myFilterDlg->SetMesh( myMesh );
1223 myFilterDlg->SetSourceWg( ElementsLineEdit );
1225 myFilterDlg->show();
1228 //=================================================================================
1229 // function : isValid
1231 //=================================================================================
1232 bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
1236 ok = XSpin->isValid( msg, true ) && ok;
1237 ok = YSpin->isValid( msg, true ) && ok;
1238 ok = ZSpin->isValid( msg, true ) && ok;
1241 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1242 if ( !msg.isEmpty() )
1244 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1250 //=================================================================================
1251 // function : updateLinearAngles
1253 //=================================================================================
1254 void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
1256 bool enableLinear = true;
1257 for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
1258 if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
1259 enableLinear = false;
1260 anItem->text().toDouble(&enableLinear);
1266 LinearAnglesCheck->setChecked( false );
1267 LinearAnglesCheck->setEnabled( enableLinear );
1270 //=================================================================================
1271 // function : isValuesValid()
1272 // purpose : Return true in case if values entered into dialog are valid
1273 //=================================================================================
1274 bool SMESHGUI_ExtrusionAlongPathDlg::isValuesValid() {
1276 if ( (MeshCheck->isChecked() && myIDSource->_is_nil()) ||
1277 myMesh->_is_nil() ||
1281 if(!MeshCheck->isChecked()) {
1282 QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts);
1283 if(aListElementsId.count() <= 0)
1288 StartPointLineEdit->text().toLong(&bOk);
1297 //=================================================================================
1298 // function : onDisplaySimulation
1299 // purpose : Show/Hide preview
1300 //=================================================================================
1301 void SMESHGUI_ExtrusionAlongPathDlg::onDisplaySimulation( bool toDisplayPreview ) {
1302 if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1303 if(isValid() && isValuesValid()) {
1305 //Get selected elements:
1306 SMESH::long_array_var anElementsId = getSelectedElements();
1309 SMESH::double_array_var anAngles = getAngles();
1312 SMESH::PointStruct aBasePoint;
1313 if (BasePointGrp->isChecked()) {
1314 aBasePoint.x = XSpin->GetValue();
1315 aBasePoint.y = YSpin->GetValue();
1316 aBasePoint.z = ZSpin->GetValue();
1319 long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
1323 SUIT_OverrideCursor wc;
1325 SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
1326 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1327 bool NeedGroups = false;
1328 SMESH::ElementType ElemType = SMESH::FACE;
1329 if( GetConstructorId() == 0 )
1330 ElemType = SMESH::EDGE;
1331 if( !MeshCheck->isChecked() ) {
1332 aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(),
1333 anAngles, LinearAnglesCheck->isChecked(),
1334 BasePointGrp->isChecked(), aBasePoint,
1335 NeedGroups, ElemType, retVal);
1338 SMESH::ListOfGroups_var groups =
1339 aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(),
1340 anAngles, LinearAnglesCheck->isChecked(),
1341 BasePointGrp->isChecked(), aBasePoint,
1342 NeedGroups, ElemType, retVal);
1346 if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) {
1347 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1348 mySimulation->SetData(aMeshPreviewStruct._retn());
1369 //=================================================================================
1370 // function : getSelectedElements
1371 // purpose : return list of the selected elements
1372 //=================================================================================
1373 SMESH::long_array_var SMESHGUI_ExtrusionAlongPathDlg::getSelectedElements() {
1375 // If "Select whole mesh, submesh or group" check box is off ->
1376 // use only elements of given type selected by user
1377 SMESH::long_array_var anElementsId = new SMESH::long_array;
1378 if (!MeshCheck->isChecked()) {
1382 aMesh = myMeshActor->GetObject()->GetMesh();
1385 QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts);
1386 anElementsId = new SMESH::long_array;
1387 anElementsId->length(aListElementsId.count());
1390 for (int i = 0; i < aListElementsId.count(); i++) {
1391 long ind = aListElementsId[ i ].toLong(&bOk);
1393 const SMDS_MeshElement* e = aMesh->FindElement(ind);
1395 bool typeMatch = (Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge) ||
1396 (Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face);
1398 anElementsId[ j++ ] = ind;
1402 anElementsId->length(j);
1405 return anElementsId;
1408 SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getAngles() {
1409 SMESH::double_array_var anAngles = new SMESH::double_array;
1410 if (AnglesGrp->isChecked()) {
1411 anAngles->length(myAnglesList.count());
1413 for (int i = 0; i < myAnglesList.count(); i++) {
1414 double angle = myAnglesList[i];
1415 anAngles[ j++ ] = angle*PI/180;
1417 anAngles->length(j);