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
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"
36 #include "SMESHGUI_MeshEditPreview.h"
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_NumberFilter.hxx>
41 #include <SMESH_LogicalFilter.hxx>
43 #include <SMDS_Mesh.hxx>
45 // SALOME GEOM includes
48 // SALOME GUI includes
49 #include <SUIT_ResourceMgr.h>
50 #include <SUIT_OverrideCursor.h>
51 #include <SUIT_Desktop.h>
52 #include <SUIT_MessageBox.h>
53 #include <SUIT_Session.h>
55 #include <LightApp_Application.h>
56 #include <LightApp_SelectionMgr.h>
58 #include <SVTK_ViewWindow.h>
61 #include <BRep_Tool.hxx>
62 #include <TopoDS_Vertex.hxx>
64 #include <TColStd_MapOfInteger.hxx>
67 #include <QButtonGroup>
71 #include <QPushButton>
72 #include <QToolButton>
73 #include <QRadioButton>
75 #include <QListWidget>
76 #include <QVBoxLayout>
77 #include <QHBoxLayout>
78 #include <QGridLayout>
82 #include <SALOMEconfig.h>
83 #include CORBA_SERVER_HEADER(SMESH_Group)
84 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
89 class SMESHGUI_ExtrusionAlongPathDlg::SetBusy
92 SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg )
100 myDlg->myBusy = false;
104 SMESHGUI_ExtrusionAlongPathDlg* myDlg;
107 //=================================================================================
108 // function : SMESHGUI_ExtrusionAlongPathDlg()
109 // purpose : constructor
110 //=================================================================================
111 SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule )
112 : SMESHGUI_PreviewDlg( theModule ),
113 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
116 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
117 QPixmap edgeImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
118 QPixmap faceImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
119 QPixmap selectImage ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
120 QPixmap addImage ( mgr->loadPixmap("SMESH", tr("ICON_APPEND")));
121 QPixmap removeImage ( mgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
126 setAttribute( Qt::WA_DeleteOnClose, true );
127 setWindowTitle(tr("EXTRUSION_ALONG_PATH"));
128 setSizeGripEnabled(true);
130 QVBoxLayout* topLayout = new QVBoxLayout(this);
131 topLayout->setSpacing(SPACING);
132 topLayout->setMargin(MARGIN);
134 /***************************************************************/
135 // Elements type group box (1d / 2d elements)
136 ConstructorsBox = new QGroupBox(tr("SMESH_EXTRUSION"), this);
137 GroupConstructors = new QButtonGroup(this);
138 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
139 ConstructorsBoxLayout->setSpacing(SPACING); ConstructorsBoxLayout->setMargin(MARGIN);
141 Elements1dRB = new QRadioButton(ConstructorsBox);
142 Elements1dRB->setIcon(edgeImage);
143 Elements2dRB = new QRadioButton(ConstructorsBox);
144 Elements2dRB->setIcon(faceImage);
145 Elements1dRB->setChecked(true);
148 ConstructorsBoxLayout->addWidget(Elements1dRB);
149 ConstructorsBoxLayout->addWidget(Elements2dRB);
150 GroupConstructors->addButton(Elements1dRB, 0);
151 GroupConstructors->addButton(Elements2dRB, 1);
153 /***************************************************************/
154 // Arguments group box
155 GroupArguments = new QGroupBox(tr("EXTRUSION_1D"), this);
156 QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
157 GroupArgumentsLayout->setSpacing(SPACING); GroupArgumentsLayout->setMargin(MARGIN);
159 myIdValidator = new SMESHGUI_IdValidator(this);
161 // Controls for elements selection
162 ElementsLab = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
164 SelectElementsButton = new QToolButton(GroupArguments);
165 SelectElementsButton->setIcon(selectImage);
167 ElementsLineEdit = new QLineEdit(GroupArguments);
168 ElementsLineEdit->setValidator(myIdValidator);
169 ElementsLineEdit->setMaxLength(-1);
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 myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
268 GroupArgumentsLayout->addWidget(ElementsLab, 0, 0);
269 GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
270 GroupArgumentsLayout->addWidget(ElementsLineEdit, 0, 2);
271 GroupArgumentsLayout->addWidget(myFilterBtn, 0, 3);
272 GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 4);
273 GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 4);
274 GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 4);
275 GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 4);
276 GroupArgumentsLayout->addWidget(myPreviewCheckBox, 5, 0, 1, 4);
277 GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
279 /***************************************************************/
280 // common buttons group box
281 GroupButtons = new QGroupBox(this);
282 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
283 GroupButtonsLayout->setSpacing(SPACING); GroupButtonsLayout->setMargin(MARGIN);
285 OkButton = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
286 OkButton->setAutoDefault(true);
287 OkButton->setDefault(true);
289 ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
290 ApplyButton->setAutoDefault(true);
292 CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
293 CloseButton->setAutoDefault(true);
295 HelpButton = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
296 HelpButton->setAutoDefault(true);
299 GroupButtonsLayout->addWidget(OkButton);
300 GroupButtonsLayout->addSpacing(10);
301 GroupButtonsLayout->addWidget(ApplyButton);
302 GroupButtonsLayout->addSpacing(10);
303 GroupButtonsLayout->addStretch();
304 GroupButtonsLayout->addWidget(CloseButton);
305 GroupButtonsLayout->addWidget(HelpButton);
307 /***************************************************************/
309 topLayout->addWidget(ConstructorsBox);
310 topLayout->addWidget(GroupArguments);
311 topLayout->addWidget(GroupButtons);
313 /***************************************************************/
315 XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
316 YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
317 ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
318 AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, "angle_precision");
320 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
322 mySMESHGUI->SetActiveDialogBox(this);
324 // Costruction of the logical filter for the elements: mesh/sub-mesh/group
325 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
326 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
328 QList<SUIT_SelectionFilter*> aListOfFilters;
329 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
330 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
332 myElementsFilter = new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
333 //myPathMeshFilter = new SMESH_TypeFilter (MESH);
334 myPathMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
336 myHelpFileName = "extrusion_along_path_page.html";
340 /***************************************************************/
341 // signals-slots connections
342 connect(OkButton, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
343 connect(CloseButton, SIGNAL(clicked()), this, SLOT(reject()));
344 connect(ApplyButton, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
345 connect(HelpButton, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
347 connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
348 connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
350 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
352 connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
353 connect(SelectPathMeshButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
354 connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
355 connect(SelectBasePointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
357 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
358 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
359 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
361 connect(ElementsLineEdit, SIGNAL(textChanged(const QString&)),
362 SLOT(onTextChange(const QString&)));
363 connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)),
364 SLOT(onTextChange(const QString&)));
366 connect(MeshCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh()));
368 connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
369 connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
370 connect(ZSpin, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
371 connect(AddAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
372 connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
373 connect(LinearAnglesCheck, SIGNAL(toggled(bool)), SLOT(onSelectMesh()));
376 //To Connect preview check box
377 connectPreviewControl();
379 AnglesList->installEventFilter(this);
380 ElementsLineEdit->installEventFilter(this);
381 StartPointLineEdit->installEventFilter(this);
382 XSpin->editor()->installEventFilter(this);
383 YSpin->editor()->installEventFilter(this);
384 ZSpin->editor()->installEventFilter(this);
387 //=================================================================================
388 // function : ~SMESHGUI_ExtrusionAlongPathDlg()
389 // purpose : destructor
390 //=================================================================================
391 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
393 // no need to delete child widgets, Qt does it all for us
394 if ( myFilterDlg != 0 ) {
395 myFilterDlg->setParent( 0 );
400 //=================================================================================
402 // purpose : initialization
403 //=================================================================================
404 void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls)
407 myEditCurrentArgument = 0;
409 myMesh = SMESH::SMESH_Mesh::_nil();
410 myIDSource = SMESH::SMESH_IDSource::_nil();
412 myPath = SMESH::SMESH_IDSource::_nil();
414 ElementsLineEdit->clear();
415 PathMeshLineEdit->clear();
416 StartPointLineEdit->clear();
419 XSpin->SetValue(0.0);
420 YSpin->SetValue(0.0);
421 ZSpin->SetValue(0.0);
423 AngleSpin->SetValue(45);
424 MeshCheck->setChecked(false);
425 ConstructorsClicked(0);
427 myPreviewCheckBox->setChecked(false);
428 onDisplaySimulation(false);
430 SetEditCurrentArgument(0);
433 //=================================================================================
434 // function : ConstructorsClicked()
435 // purpose : Called when user changes type of elements (1d / 2d)
436 //=================================================================================
437 void SMESHGUI_ExtrusionAlongPathDlg::ConstructorsClicked (int type)
439 if (myType == type) return;
441 disconnect(mySelectionMgr, 0, this, 0);
446 GroupArguments->setTitle(tr("EXTRUSION_1D"));
448 GroupArguments->setTitle(tr("EXTRUSION_2D"));
450 // clear elements ID list
451 if (!MeshCheck->isChecked()) {
452 ElementsLineEdit->clear();
454 // set selection mode if necessary
455 if (myEditCurrentArgument == ElementsLineEdit) {
456 mySelectionMgr->clearSelected();
457 mySelectionMgr->clearFilters();
458 SMESH::SetPickable();
460 SMESH::SetPointRepresentation(false);
461 if (MeshCheck->isChecked()) {
462 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
463 aViewWindow->SetSelectionMode(ActorSelection);
464 mySelectionMgr->installFilter(myElementsFilter);
468 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
469 aViewWindow->SetSelectionMode(EdgeSelection);
473 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
474 aViewWindow->SetSelectionMode(FaceSelection);
478 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
483 //=================================================================================
484 // function : ClickOnApply()
485 // purpose : Called when user presses <Apply> button
486 //=================================================================================
487 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
489 if (mySMESHGUI->isActiveStudyLocked())
492 //if (myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() ||
493 // !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil())
494 if ( myMesh->_is_nil() || (MeshCheck->isChecked() && myIDSource->_is_nil()) ||
495 /*!myMeshActor ||*/ myPath->_is_nil() )
501 SMESH::long_array_var anElementsId = getSelectedElements();
503 if (StartPointLineEdit->text().trimmed().isEmpty()) {
508 long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
513 QStringList aParameters;
516 SMESH::double_array_var anAngles = getAngles();
518 for (int i = 0; i < myAnglesList.count(); i++)
519 aParameters << AnglesList->item(i)->text();
523 SMESH::PointStruct aBasePoint;
524 if (BasePointGrp->isChecked()) {
525 aBasePoint.x = XSpin->GetValue();
526 aBasePoint.y = YSpin->GetValue();
527 aBasePoint.z = ZSpin->GetValue();
530 aParameters << XSpin->text();
531 aParameters << YSpin->text();
532 aParameters << ZSpin->text();
535 SUIT_OverrideCursor wc;
536 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
537 //if ( LinearAnglesCheck->isChecked() ) {
538 // anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles );
541 SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
543 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) {
544 if( MeshCheck->isChecked() ) {
545 if( GetConstructorId() == 0 )
546 SMESH::ListOfGroups_var groups =
547 aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh,
548 myPathShape, aNodeStart,
549 AnglesGrp->isChecked(), anAngles,
550 BasePointGrp->isChecked(), aBasePoint, retVal);
552 SMESH::ListOfGroups_var groups =
553 aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh,
554 myPathShape, aNodeStart,
555 AnglesGrp->isChecked(), anAngles,
556 BasePointGrp->isChecked(), aBasePoint, retVal);
559 SMESH::ListOfGroups_var groups =
560 aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh,
561 myPathShape, aNodeStart,
562 AnglesGrp->isChecked(), anAngles,
563 BasePointGrp->isChecked(), aBasePoint, retVal);
566 if( MeshCheck->isChecked() ) {
567 if( GetConstructorId() == 0 )
568 retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh,
569 myPathShape, aNodeStart,
570 AnglesGrp->isChecked(), anAngles,
571 BasePointGrp->isChecked(), aBasePoint);
573 retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh,
574 myPathShape, aNodeStart,
575 AnglesGrp->isChecked(), anAngles,
576 BasePointGrp->isChecked(), aBasePoint);
579 retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh,
580 myPathShape, aNodeStart,
581 AnglesGrp->isChecked(), anAngles,
582 BasePointGrp->isChecked(), aBasePoint);
586 bool NeedGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
587 SMESH::ElementType ElemType = SMESH::FACE;
588 if( GetConstructorId() == 0 )
589 ElemType = SMESH::EDGE;
590 if( !MeshCheck->isChecked() ) {
591 SMESH::ListOfGroups_var groups =
592 aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(),
593 anAngles, LinearAnglesCheck->isChecked(),
594 BasePointGrp->isChecked(), aBasePoint,
595 NeedGroups, ElemType, retVal);
598 SMESH::ListOfGroups_var groups =
599 aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(),
600 anAngles, LinearAnglesCheck->isChecked(),
601 BasePointGrp->isChecked(), aBasePoint,
602 NeedGroups, ElemType, retVal);
606 if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
607 myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
612 case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
613 SUIT_MessageBox::warning(this,
615 tr("NO_ELEMENTS_SELECTED"));
617 case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
618 SUIT_MessageBox::warning(this,
620 tr("SELECTED_PATH_IS_NOT_EDGE"));
622 case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
623 SUIT_MessageBox::warning(this,
625 tr("BAD_SHAPE_TYPE"));
627 case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
628 SUIT_MessageBox::warning(this,
630 tr("EXTR_BAD_STARTING_NODE"));
632 case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
633 SUIT_MessageBox::warning(this,
635 tr("WRONG_ANGLES_NUMBER"));
637 case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
638 SUIT_MessageBox::warning(this,
640 tr("CANT_GET_TANGENT"));
642 case SMESH::SMESH_MeshEditor::EXTR_OK:
649 //mySelectionMgr->clearSelected();
651 SMESH::Update( myMeshActor->getIO(), myMeshActor->GetVisibility() );
653 SMESHGUI::Modified();
655 if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
656 mySMESHGUI->updateObjBrowser(true); // new groups may appear
657 //SMESH::UpdateView();
659 ConstructorsClicked(GetConstructorId());
663 //=================================================================================
664 // function : ClickOnOk()
665 // purpose : Called when user presses <OK> button
666 //=================================================================================
667 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
673 //=================================================================================
674 // function : ClickOnHelp()
676 //=================================================================================
677 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp()
679 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
681 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
685 platform = "winapplication";
687 platform = "application";
689 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
690 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
691 arg(app->resourceMgr()->stringValue("ExternalBrowser",
693 arg(myHelpFileName));
697 //=================================================================================
698 // function : reject()
699 // purpose : Called when dialog box is closed
700 //=================================================================================
701 void SMESHGUI_ExtrusionAlongPathDlg::reject()
703 disconnect(mySelectionMgr, 0, this, 0);
704 mySelectionMgr->clearFilters();
705 //mySelectionMgr->clearSelected();
706 if (SMESH::GetCurrentVtkView()) {
707 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
708 SMESH::SetPointRepresentation(false);
709 SMESH::SetPickable();
711 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
712 aViewWindow->SetSelectionMode(ActorSelection);
713 mySMESHGUI->ResetState();
717 //=======================================================================
718 // function : onTextChange()
720 //=======================================================================
721 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
723 QLineEdit* send = (QLineEdit*)sender();
731 if (send != StartPointLineEdit && send != ElementsLineEdit)
732 send = ElementsLineEdit;
734 if (send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit) {
735 // hilight entered elements
736 SMDS_Mesh* aMesh = 0;
738 aMesh = myMeshActor->GetObject()->GetMesh();
741 //mySelectionMgr->clearSelected();
742 //mySelectionMgr->AddIObject(myMeshActor->getIO());
744 aList.Append(myMeshActor->getIO());
745 mySelectionMgr->setSelectedObjects(aList, false);
747 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
749 const Handle(SALOME_InteractiveObject)& anIO = myMeshActor->getIO();
750 TColStd_MapOfInteger newIndices;
751 for (int i = 0; i < aListId.count(); i++) {
752 long ind = aListId[ i ].toLong(&bOk);
754 const SMDS_MeshElement* e = aMesh->FindElement(ind);
756 // check also type of element
757 bool typeMatch = (Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge) ||
758 (Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face);
760 newIndices.Add(e->GetID());
764 mySelector->AddOrRemoveIndex(anIO, newIndices, false);
765 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
766 aViewWindow->highlight( anIO, true, true );
769 else if (send == StartPointLineEdit &&
770 myEditCurrentArgument == StartPointLineEdit) {
771 if (!myPath->_is_nil()) {
772 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
773 SMDS_Mesh* aMesh = 0;
775 aMesh = aPathActor->GetObject()->GetMesh();
777 //mySelectionMgr->clearSelected();
778 //mySelectionMgr->AddIObject(aPathActor->getIO());
780 aList.Append(aPathActor->getIO());
781 mySelectionMgr->setSelectedObjects(aList, false);
784 long ind = theNewText.toLong(&bOk);
786 const SMDS_MeshNode* n = aMesh->FindNode(ind);
788 //if (!mySelectionMgr->IsIndexSelected(aPathActor->getIO(), n->GetID())) {
789 TColStd_MapOfInteger newIndices;
790 newIndices.Add(n->GetID());
791 mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false );
792 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
793 aViewWindow->highlight( aPathActor->getIO(), true, true );
801 //=================================================================================
802 // function : SelectionIntoArgument()
803 // purpose : Called when selection as changed or other case
804 //=================================================================================
805 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
809 // return if dialog box is inactive
810 if (!GroupButtons->isEnabled())
813 // selected objects count
814 const SALOME_ListIO& aList = mySelector->StoredIObjects();
815 int nbSel = aList.Extent();
822 if (myEditCurrentArgument == ElementsLineEdit) {
823 // we are now selecting mesh elements (or whole mesh/submesh/group)
825 ElementsLineEdit->clear();
826 myMesh = SMESH::SMESH_Mesh::_nil();
827 myIDSource = SMESH::SMESH_IDSource::_nil();
830 // try to get mesh from selection
831 Handle(SALOME_InteractiveObject) IO = aList.First();
832 myMesh = SMESH::GetMeshByIO(IO);
833 if (myMesh->_is_nil())
836 // MakeGroups is available if there are groups
837 if ( myMesh->NbGroups() == 0 ) {
838 MakeGroupsCheck->setChecked(false);
839 MakeGroupsCheck->setEnabled(false);
841 MakeGroupsCheck->setEnabled(true);
844 myMeshActor = SMESH::FindActorByObject(myMesh);
845 if (!myMeshActor && !MeshCheck->isChecked())
848 if (MeshCheck->isChecked()) {
849 // If "Select whole mesh, submesh or group" check box is on ->
850 // get ID source and put it's name to the edit box
852 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
854 myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
855 ElementsLineEdit->setText(aString);
857 // If "Select whole mesh, submesh or group" check box is off ->
858 // try to get selected elements IDs
860 //int aNbUnits = SMESH::GetNameOfSelectedElements(mySelectionMgr, aString);
861 SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
862 ElementsLineEdit->setText(aString);
865 else if (myEditCurrentArgument == PathMeshLineEdit) {
866 // we are now selecting path mesh
868 PathMeshLineEdit->clear();
869 myPath = SMESH::SMESH_IDSource::_nil();
870 StartPointLineEdit->clear();
872 // try to get mesh from selection
873 Handle(SALOME_InteractiveObject) IO = aList.First();
874 myPath = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
875 if( myPath->_is_nil() )
879 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
880 PathMeshLineEdit->setText(aString);
882 else if (myEditCurrentArgument == StartPointLineEdit) {
883 // we are now selecting start point of path
885 StartPointLineEdit->clear();
887 // return if path mesh or path shape is not yet selected
888 if( myPath->_is_nil() )
891 // try to get shape from selection
892 Handle(SALOME_InteractiveObject) IO = aList.First();
894 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
899 int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aPathActor->getIO(), aString);
901 StartPointLineEdit->setText(aString.trimmed());
903 } else if (myEditCurrentArgument == XSpin) {
904 // we are now selecting base point
905 // reset is not performed here!
907 // return if is not enabled
908 if (!BasePointGrp->isChecked())
911 // try to get shape from selection
912 Handle(SALOME_InteractiveObject) IO = aList.First();
914 // check if geom vertex is selected
915 GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
916 TopoDS_Vertex aVertex;
917 if (!aGeomObj->_is_nil()) {
918 if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) {
919 gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
920 XSpin->SetValue(aPnt.X());
921 YSpin->SetValue(aPnt.Y());
922 ZSpin->SetValue(aPnt.Z());
927 // check if smesh node is selected
928 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO);
929 if (aMesh->_is_nil())
933 int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myMeshActor->getIO(), aString);
934 // return if more than one node is selected
938 SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh);
942 SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
946 const SMDS_MeshNode* n = mesh->FindNode(aString.toLong());
950 XSpin->SetValue(n->X());
951 YSpin->SetValue(n->Y());
952 ZSpin->SetValue(n->Z());
954 onDisplaySimulation(true);
957 //=================================================================================
958 // function : SetEditCurrentArgument()
960 //=================================================================================
961 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
963 QToolButton* send = (QToolButton*)sender();
964 if (send != SelectElementsButton &&
965 send != SelectPathMeshButton &&
966 send != SelectStartPointButton &&
967 send != SelectBasePointButton)
969 SetEditCurrentArgument(send);
972 //=================================================================================
973 // function : SetEditCurrentArgument()
975 //=================================================================================
976 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QToolButton* button)
978 disconnect(mySelectionMgr, 0, this, 0);
979 // mySelectionMgr->clearSelected();
980 mySelectionMgr->clearFilters();
981 SMESH::SetPickable();
983 if (button == SelectElementsButton) {
984 myEditCurrentArgument = ElementsLineEdit;
985 SMESH::SetPointRepresentation(false);
986 if (MeshCheck->isChecked()) {
987 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
988 aViewWindow->SetSelectionMode(ActorSelection);
989 mySelectionMgr->installFilter(myElementsFilter);
991 if (Elements1dRB->isChecked())
993 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
994 aViewWindow->SetSelectionMode(EdgeSelection);
996 else if (Elements2dRB->isChecked())
998 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
999 aViewWindow->SetSelectionMode(FaceSelection);
1002 } else if (button == SelectPathMeshButton) {
1003 myEditCurrentArgument = PathMeshLineEdit;
1004 SMESH::SetPointRepresentation(false);
1005 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1006 aViewWindow->SetSelectionMode(ActorSelection);
1007 mySelectionMgr->installFilter(myPathMeshFilter);
1009 else if (button == SelectStartPointButton) {
1010 myEditCurrentArgument = StartPointLineEdit;
1011 //if (!myPathMesh->_is_nil()) {
1012 if (!myPath->_is_nil()) {
1013 SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
1015 SMESH::SetPointRepresentation(true);
1016 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1017 aViewWindow->SetSelectionMode(NodeSelection);
1018 SMESH::SetPickable(aPathActor);
1022 else if (button == SelectBasePointButton) {
1023 myEditCurrentArgument = XSpin;
1024 SMESH::SetPointRepresentation(true);
1025 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1026 aViewWindow->SetSelectionMode(NodeSelection);
1028 SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH);
1029 SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter(GROUP);
1030 SMESH_NumberFilter* aVertexFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE,
1032 QList<SUIT_SelectionFilter*> aListOfFilters;
1033 if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
1034 if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
1035 if (aVertexFilter) aListOfFilters.append(aVertexFilter);
1037 mySelectionMgr->installFilter(new SMESH_LogicalFilter
1038 (aListOfFilters, SMESH_LogicalFilter::LO_OR));
1041 if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus())
1042 myEditCurrentArgument->setFocus();
1044 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1045 SelectionIntoArgument();
1048 //=================================================================================
1049 // function : DeactivateActiveDialog()
1050 // purpose : Deactivates this dialog
1051 //=================================================================================
1052 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1054 if (ConstructorsBox->isEnabled()) {
1055 ConstructorsBox->setEnabled(false);
1056 GroupArguments->setEnabled(false);
1057 GroupButtons->setEnabled(false);
1058 mySMESHGUI->ResetState();
1059 mySMESHGUI->SetActiveDialogBox(0);
1063 //=================================================================================
1064 // function : ActivateThisDialog()
1065 // purpose : Activates this dialog
1066 //=================================================================================
1067 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1069 // Emit a signal to deactivate the active dialog
1070 mySMESHGUI->EmitSignalDeactivateDialog();
1071 ConstructorsBox->setEnabled(true);
1072 GroupArguments->setEnabled(true);
1073 GroupButtons->setEnabled(true);
1075 mySMESHGUI->SetActiveDialogBox(this);
1077 ConstructorsClicked(GetConstructorId());
1078 SelectionIntoArgument();
1081 //=================================================================================
1082 // function : enterEvent()
1083 // purpose : Mouse enter event
1084 //=================================================================================
1085 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*)
1087 if (!ConstructorsBox->isEnabled())
1088 ActivateThisDialog();
1091 //=======================================================================
1092 // function : onSelectMesh()
1094 //=======================================================================
1095 void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
1097 bool toSelectMesh = MeshCheck->isChecked();
1099 ElementsLineEdit->setReadOnly(toSelectMesh);
1100 ElementsLineEdit->setValidator(toSelectMesh ? 0 : myIdValidator);
1101 ElementsLab->setText(toSelectMesh ? tr("SMESH_NAME") : tr("SMESH_ID_ELEMENTS"));
1102 ElementsLineEdit->clear();
1103 myFilterBtn->setEnabled(!toSelectMesh);
1105 SetEditCurrentArgument(SelectElementsButton);
1108 //=================================================================================
1109 // function : GetConstructorId()
1111 //=================================================================================
1112 int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1114 return GroupConstructors->checkedId();
1117 //=======================================================================
1118 // function : OnAngleAdded()
1119 // purpose : Called when user adds angle to the list
1120 //=======================================================================
1121 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
1124 if( !AngleSpin->isValid( msg, true ) ) {
1125 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1126 if ( !msg.isEmpty() )
1128 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1131 AnglesList->addItem(AngleSpin->text());
1132 myAnglesList.append(AngleSpin->GetValue());
1134 updateLinearAngles();
1137 //=======================================================================
1138 // function : OnAngleRemoved()
1139 // purpose : Called when user removes angle(s) from the list
1140 //=======================================================================
1141 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
1143 QList<QListWidgetItem*> aList = AnglesList->selectedItems();
1144 QListWidgetItem* anItem;
1145 foreach(anItem, aList) {
1146 myAnglesList.removeAt(AnglesList->row(anItem));
1150 updateLinearAngles();
1153 //=================================================================================
1154 // function : eventFilter()
1155 // purpose : event filter ???
1156 //=================================================================================
1157 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event)
1159 if (event->type() == QEvent::KeyPress) {
1160 QKeyEvent* ke = (QKeyEvent*)event;
1161 if (object == AnglesList) {
1162 if (ke->key() == Qt::Key_Delete)
1166 else if (event->type() == QEvent::FocusIn) {
1167 if (object == ElementsLineEdit) {
1168 if (myEditCurrentArgument != ElementsLineEdit)
1169 SetEditCurrentArgument(SelectElementsButton);
1171 else if (object == StartPointLineEdit) {
1172 if (myEditCurrentArgument != StartPointLineEdit)
1173 SetEditCurrentArgument(SelectStartPointButton);
1175 else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) {
1176 if (myEditCurrentArgument != XSpin)
1177 SetEditCurrentArgument(SelectBasePointButton);
1180 return QDialog::eventFilter(object, event);
1183 //=================================================================================
1184 // function : keyPressEvent()
1186 //=================================================================================
1187 void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e )
1189 QDialog::keyPressEvent( e );
1190 if ( e->isAccepted() )
1193 if ( e->key() == Qt::Key_F1 ) {
1199 //=================================================================================
1200 // function : setFilters()
1201 // purpose : SLOT. Called when "Filter" button pressed.
1202 //=================================================================================
1203 void SMESHGUI_ExtrusionAlongPathDlg::setFilters()
1205 if(myMesh->_is_nil()) {
1206 SUIT_MessageBox::critical(this,
1208 tr("NO_MESH_SELECTED"));
1214 types.append( SMESH::EDGE );
1215 types.append( SMESH::FACE );
1216 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
1218 myFilterDlg->Init( Elements1dRB->isChecked() ? SMESH::EDGE : SMESH::FACE );
1220 myFilterDlg->SetSelection();
1221 myFilterDlg->SetMesh( myMesh );
1222 myFilterDlg->SetSourceWg( ElementsLineEdit );
1224 myFilterDlg->show();
1227 //=================================================================================
1228 // function : isValid
1230 //=================================================================================
1231 bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
1235 ok = XSpin->isValid( msg, true ) && ok;
1236 ok = YSpin->isValid( msg, true ) && ok;
1237 ok = ZSpin->isValid( msg, true ) && ok;
1240 QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1241 if ( !msg.isEmpty() )
1243 SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1249 //=================================================================================
1250 // function : updateLinearAngles
1252 //=================================================================================
1253 void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
1255 bool enableLinear = true;
1256 for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
1257 if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
1258 enableLinear = false;
1259 anItem->text().toDouble(&enableLinear);
1265 LinearAnglesCheck->setChecked( false );
1266 LinearAnglesCheck->setEnabled( enableLinear );
1269 //=================================================================================
1270 // function : isValuesValid()
1271 // purpose : Return true in case if values entered into dialog are valid
1272 //=================================================================================
1273 bool SMESHGUI_ExtrusionAlongPathDlg::isValuesValid() {
1275 if ( (MeshCheck->isChecked() && myIDSource->_is_nil()) ||
1276 myMesh->_is_nil() ||
1280 if(!MeshCheck->isChecked()) {
1281 QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts);
1282 if(aListElementsId.count() <= 0)
1287 StartPointLineEdit->text().toLong(&bOk);
1296 //=================================================================================
1297 // function : onDisplaySimulation
1298 // purpose : Show/Hide preview
1299 //=================================================================================
1300 void SMESHGUI_ExtrusionAlongPathDlg::onDisplaySimulation( bool toDisplayPreview ) {
1301 if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1302 if(isValid() && isValuesValid()) {
1304 //Get selected elements:
1305 SMESH::long_array_var anElementsId = getSelectedElements();
1308 SMESH::double_array_var anAngles = getAngles();
1311 SMESH::PointStruct aBasePoint;
1312 if (BasePointGrp->isChecked()) {
1313 aBasePoint.x = XSpin->GetValue();
1314 aBasePoint.y = YSpin->GetValue();
1315 aBasePoint.z = ZSpin->GetValue();
1318 long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
1322 SUIT_OverrideCursor wc;
1324 SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
1325 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1326 bool NeedGroups = false;
1327 SMESH::ElementType ElemType = SMESH::FACE;
1328 if( GetConstructorId() == 0 )
1329 ElemType = SMESH::EDGE;
1330 if( !MeshCheck->isChecked() ) {
1331 aMeshEditor->ExtrusionAlongPathX(anElementsId, myPath, aNodeStart, AnglesGrp->isChecked(),
1332 anAngles, LinearAnglesCheck->isChecked(),
1333 BasePointGrp->isChecked(), aBasePoint,
1334 NeedGroups, ElemType, retVal);
1337 SMESH::ListOfGroups_var groups =
1338 aMeshEditor->ExtrusionAlongPathObjX(myIDSource, myPath, aNodeStart, AnglesGrp->isChecked(),
1339 anAngles, LinearAnglesCheck->isChecked(),
1340 BasePointGrp->isChecked(), aBasePoint,
1341 NeedGroups, ElemType, retVal);
1345 if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) {
1346 SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1347 mySimulation->SetData(aMeshPreviewStruct._retn());
1368 //=================================================================================
1369 // function : getSelectedElements
1370 // purpose : return list of the selected elements
1371 //=================================================================================
1372 SMESH::long_array_var SMESHGUI_ExtrusionAlongPathDlg::getSelectedElements() {
1374 // If "Select whole mesh, submesh or group" check box is off ->
1375 // use only elements of given type selected by user
1376 SMESH::long_array_var anElementsId = new SMESH::long_array;
1377 if (!MeshCheck->isChecked()) {
1381 aMesh = myMeshActor->GetObject()->GetMesh();
1384 QStringList aListElementsId = ElementsLineEdit->text().split(" ", QString::SkipEmptyParts);
1385 anElementsId = new SMESH::long_array;
1386 anElementsId->length(aListElementsId.count());
1389 for (int i = 0; i < aListElementsId.count(); i++) {
1390 long ind = aListElementsId[ i ].toLong(&bOk);
1392 const SMDS_MeshElement* e = aMesh->FindElement(ind);
1394 bool typeMatch = (Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge) ||
1395 (Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face);
1397 anElementsId[ j++ ] = ind;
1401 anElementsId->length(j);
1404 return anElementsId;
1407 SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getAngles() {
1408 SMESH::double_array_var anAngles = new SMESH::double_array;
1409 if (AnglesGrp->isChecked()) {
1410 anAngles->length(myAnglesList.count());
1412 for (int i = 0; i < myAnglesList.count(); i++) {
1413 double angle = myAnglesList[i];
1414 anAngles[ j++ ] = angle*M_PI/180.;
1416 anAngles->length(j);