1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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_SewingDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
28 #include "SMESHGUI_SewingDlg.h"
31 #include "SMESHGUI_IdPreview.h"
32 #include "SMESHGUI_IdValidator.h"
33 #include "SMESHGUI_MergeDlg.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_PreVisualObj.h"
36 #include "SMESHGUI_SpinBox.h"
37 #include "SMESHGUI_Utils.h"
38 #include "SMESHGUI_VTKUtils.h"
40 #include <SMDS_Mesh.hxx>
41 #include <SMESH_Actor.h>
42 #include <SMESH_TypeDefs.hxx>
44 // SALOME GUI includes
45 #include <LightApp_Application.h>
46 #include <LightApp_SelectionMgr.h>
47 #include <SALOME_ListIO.hxx>
48 #include <SUIT_Desktop.h>
49 #include <SUIT_MessageBox.h>
50 #include <SUIT_OverrideCursor.h>
51 #include <SUIT_ResourceMgr.h>
52 #include <SUIT_Session.h>
53 #include <SVTK_ViewModel.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SalomeApp_IntSpinBox.h>
58 #include <TColStd_MapOfInteger.hxx>
61 #include <QApplication>
62 #include <QButtonGroup>
64 #include <QGridLayout>
66 #include <QHBoxLayout>
70 #include <QListWidget>
71 #include <QPushButton>
72 #include <QRadioButton>
73 #include <QToolButton>
74 #include <QVBoxLayout>
81 enum ActionType { MODE_AUTO=0, MODE_MANUAL,
82 MOVE_LEFT_1=0, MOVE_RIGHT_1, MOVE_LEFT_2, MOVE_RIGHT_2,
83 GROUP_COLOR=Qt::UserRole, GROUP_INDEX };
86 //=================================================================================
88 * \brief Dispalayer of free borders
90 //=================================================================================
92 struct SMESHGUI_SewingDlg::BorderGroupDisplayer
94 const SMESH::ListOfFreeBorders& myBorders;
95 const SMESH::FreeBordersGroup& myGroup;
97 SMESH::SMESH_Mesh_ptr myMesh;
99 std::vector< SMESH_Actor* > myPartActors;
100 SVTK_ViewWindow* myViewWindow;
101 SMESHGUI_IdPreview myIdPreview;
103 BorderGroupDisplayer( const SMESH::CoincidentFreeBorders& borders,
106 SMESH::SMESH_Mesh_ptr mesh);
107 ~BorderGroupDisplayer();
109 void ShowGroup( bool wholeBorders );
110 void ShowPart( int partIndex, bool toEdit );
114 void getPartEnds( int partIndex, std::vector<int> & ids, std::list<gp_XYZ>& coords);
117 //=================================================================================
118 // class : SMESHGUI_SewingDlg()
120 //=================================================================================
121 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule )
122 : QDialog( SMESH::GetDesktop( theModule ) ),
123 mySMESHGUI( theModule ),
124 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
126 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
127 QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS")));
128 QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS")));
129 QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE")));
130 QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS")));
131 QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
132 QPixmap IconRemove(mgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
135 setAttribute(Qt::WA_DeleteOnClose, true);
136 setWindowTitle(tr("SMESH_SEWING"));
137 setSizeGripEnabled(true);
139 QVBoxLayout* SMESHGUI_SewingDlgLayout = new QVBoxLayout(this);
140 SMESHGUI_SewingDlgLayout->setSpacing(SPACING);
141 SMESHGUI_SewingDlgLayout->setMargin(MARGIN);
143 /***************************************************************/
144 ConstructorsBox = new QGroupBox(tr("SMESH_SEWING"), this);
145 GroupConstructors = new QButtonGroup(this);
146 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
147 ConstructorsBoxLayout->setSpacing(SPACING);
148 ConstructorsBoxLayout->setMargin(MARGIN);
150 RadioButton1 = new QRadioButton(ConstructorsBox);
151 RadioButton1->setIcon(image0);
152 RadioButton2 = new QRadioButton(ConstructorsBox);
153 RadioButton2->setIcon(image1);
154 RadioButton3 = new QRadioButton(ConstructorsBox);
155 RadioButton3->setIcon(image2);
156 RadioButton4 = new QRadioButton(ConstructorsBox);
157 RadioButton4->setIcon(image3);
159 ConstructorsBoxLayout->addWidget(RadioButton1);
160 ConstructorsBoxLayout->addWidget(RadioButton2);
161 ConstructorsBoxLayout->addWidget(RadioButton3);
162 ConstructorsBoxLayout->addWidget(RadioButton4);
163 GroupConstructors->addButton(RadioButton1, 0);
164 GroupConstructors->addButton(RadioButton2, 1);
165 GroupConstructors->addButton(RadioButton3, 2);
166 GroupConstructors->addButton(RadioButton4, 3);
168 /***************************************************************/
169 GroupArguments = new QGroupBox(this);
170 QVBoxLayout* GroupArgumentsLayout = new QVBoxLayout(GroupArguments);
171 GroupArgumentsLayout->setSpacing(SPACING);
172 GroupArgumentsLayout->setMargin(MARGIN);
175 SubGroup1 = new QGroupBox(GroupArguments);
176 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1);
177 SubGroup1Layout->setSpacing(SPACING);
178 SubGroup1Layout->setMargin(MARGIN);
180 // Controls of the first subgroup
181 TextLabel1 = new QLabel(SubGroup1);
182 SelectButton1 = new QPushButton(SubGroup1);
183 SelectButton1->setIcon(image4);
184 LineEdit1 = new QLineEdit(SubGroup1);
186 TextLabel2 = new QLabel(SubGroup1);
187 SelectButton2 = new QPushButton(SubGroup1);
188 SelectButton2->setIcon(image4);
189 LineEdit2 = new QLineEdit(SubGroup1);
191 TextLabel3 = new QLabel(SubGroup1);
192 SelectButton3 = new QPushButton(SubGroup1);
193 SelectButton3->setIcon(image4);
194 LineEdit3 = new QLineEdit(SubGroup1);
196 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
197 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
198 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
199 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
200 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
201 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
202 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
203 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
204 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
207 SubGroup2 = new QGroupBox(GroupArguments);
208 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2);
209 SubGroup2Layout->setSpacing(SPACING);
210 SubGroup2Layout->setMargin(MARGIN);
212 // Controls of the first subgroup
213 TextLabel4 = new QLabel(SubGroup2);
214 SelectButton4 = new QPushButton(SubGroup2);
215 SelectButton4->setIcon(image4);
216 LineEdit4 = new QLineEdit(SubGroup2);
218 TextLabel5 = new QLabel(SubGroup2);
219 SelectButton5 = new QPushButton(SubGroup2);
220 SelectButton5->setIcon(image4);
221 LineEdit5 = new QLineEdit(SubGroup2);
223 TextLabel6 = new QLabel(SubGroup2);
224 SelectButton6 = new QPushButton(SubGroup2);
225 SelectButton6->setIcon(image4);
226 LineEdit6 = new QLineEdit(SubGroup2);
228 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
229 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
230 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
231 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
232 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
233 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
234 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
235 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
236 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
238 // Control for the merging equal elements
239 CheckBoxMerge = new QCheckBox(tr("MERGE_EQUAL_ELEMENTS"), GroupArguments);
241 // Control for the polygons creation instead of splitting
242 CheckBoxPolygons = new QCheckBox(tr("CREATE_POLYGONS_INSTEAD_SPLITTING"), GroupArguments);
244 // Control for the polyedres creation to obtain conform mesh
245 CheckBoxPolyedrs = new QCheckBox(tr("CREATE_POLYEDRS_NEAR_BOUNDARY"), GroupArguments);
247 /***************************************************************/
248 // Controls to switch free borders mode ( auto || manual )
250 ModeGroup = new QGroupBox( tr( "SMESH_MODE" ), GroupArguments );
251 ModeButGrp = new QButtonGroup( ModeGroup );
252 QHBoxLayout* aModeGroupLayout = new QHBoxLayout( ModeGroup );
253 aModeGroupLayout->setMargin( MARGIN );
254 aModeGroupLayout->setSpacing( SPACING );
256 QRadioButton* rb1 = new QRadioButton( tr( "SMESH_AUTOMATIC" ), ModeGroup );
257 QRadioButton* rb2 = new QRadioButton( tr( "SMESH_MANUAL" ), ModeGroup );
258 ModeButGrp->addButton( rb1, MODE_AUTO );
259 ModeButGrp->addButton( rb2, MODE_MANUAL );
260 aModeGroupLayout->addWidget( rb1 );
261 aModeGroupLayout->addWidget( rb2 );
262 rb1->setChecked(true);
264 /***************************************************************/
265 // Controls for detecting coincident free borders
267 SewFreeBordersWidget = new QWidget( GroupArguments );
268 QVBoxLayout* aSewFreeBordersLayout = new QVBoxLayout( SewFreeBordersWidget );
269 aSewFreeBordersLayout->setMargin( 0 );
270 aSewFreeBordersLayout->setSpacing( SPACING );
273 QWidget* TolAndAuto = new QWidget(SewFreeBordersWidget);
274 QLabel* TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), TolAndAuto);
275 SpinBoxTolerance = new SMESHGUI_SpinBox(TolAndAuto);
276 SpinBoxTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
277 SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
278 SpinBoxTolerance->SetValue(0.); // auto-tolerance
281 AutoSewCheck = new QCheckBox(tr("AUTO_SEWING"), TolAndAuto);
282 AutoSewCheck->setChecked( true );
285 QGroupBox* GroupMesh = new QGroupBox(tr("SMESH_SELECT_WHOLE_MESH"), SewFreeBordersWidget);
286 QHBoxLayout* GroupMeshLayout = new QHBoxLayout(GroupMesh);
287 GroupMeshLayout->setSpacing(SPACING);
288 GroupMeshLayout->setMargin(MARGIN);
290 QLabel* TextLabelName = new QLabel(tr("SMESH_NAME"), GroupMesh);
291 //SelectMeshButton = new QPushButton(GroupMesh);
292 //SelectMeshButton->setIcon(IconSelect);
293 LineEditMesh = new QLineEdit(GroupMesh);
294 LineEditMesh->setReadOnly(true);
296 GroupMeshLayout->addWidget(TextLabelName);
297 //GroupMeshLayout->addWidget(SelectMeshButton);
298 GroupMeshLayout->addWidget(LineEditMesh);
300 QGridLayout* TolAndAutoLayout = new QGridLayout( TolAndAuto );
301 TolAndAutoLayout->setSpacing(SPACING);
302 TolAndAutoLayout->setMargin(0);
303 TolAndAutoLayout->addWidget(GroupMesh, 0, 0, 1, 2 );
304 TolAndAutoLayout->addWidget(TextLabelTolerance, 1, 0 );
305 TolAndAutoLayout->addWidget(SpinBoxTolerance, 1, 1 );
306 TolAndAutoLayout->addWidget(AutoSewCheck, 2, 0 );
308 aSewFreeBordersLayout->addWidget( TolAndAuto );
312 GroupCoincidentWidget = new QWidget(SewFreeBordersWidget);
313 QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincidentWidget);
314 GroupCoincidentLayout->setSpacing(SPACING);
315 GroupCoincidentLayout->setMargin(0);
317 QGroupBox* GroupCoincident = new QGroupBox(tr("COINCIDENT_FREE_BORDERS"), GroupCoincidentWidget);
318 QGridLayout* aCoincidentLayout = new QGridLayout(GroupCoincident);
319 aCoincidentLayout->setSpacing(SPACING);
320 aCoincidentLayout->setMargin(MARGIN);
324 ListCoincident = new QListWidget(GroupCoincident);
325 ListCoincident->setSelectionMode(QListWidget::ExtendedSelection);
327 DetectButton = new QPushButton(tr("DETECT"), GroupCoincident);
328 RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincident);
330 SelectAllCheck = new QCheckBox(tr("SELECT_ALL"), GroupCoincident);
332 aCoincidentLayout->addWidget(ListCoincident, 0, 0, 5, 2);
333 aCoincidentLayout->addWidget(DetectButton, 1, 2);
334 aCoincidentLayout->addWidget(RemoveGroupButton, 3, 2);
335 aCoincidentLayout->addWidget(SelectAllCheck, 5, 0);
336 aCoincidentLayout->setRowMinimumHeight(1, 10);
337 aCoincidentLayout->setRowStretch (4, 5);
338 aCoincidentLayout->setRowStretch (5, 0);
340 /*****************************************/
341 // Controls for editing the selected group
343 QGroupBox* GroupEdit = new QGroupBox(tr("EDIT_SELECTED_GROUP"), GroupCoincidentWidget);
344 QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit);
345 GroupEditLayout->setSpacing(SPACING);
346 GroupEditLayout->setMargin(MARGIN);
348 ListEdit = new QListWidget(GroupEdit);
349 ListEdit->setFlow( QListView::LeftToRight );
350 ListEdit->setSelectionMode(QListWidget::ExtendedSelection);
351 SetFirstButton = new QPushButton(GroupEdit);
352 SetFirstButton->setIcon(QPixmap(SMESHGUI_MergeDlg::IconFirst()));
353 RemoveElemButton = new QPushButton(GroupEdit);
354 RemoveElemButton->setIcon(IconRemove);
356 MoveBorderEndsButGrp = new QButtonGroup( GroupEdit );
357 QToolButton* moveBut1 = new QToolButton( GroupEdit );
358 QToolButton* moveBut2 = new QToolButton( GroupEdit );
359 QToolButton* moveBut3 = new QToolButton( GroupEdit );
360 QToolButton* moveBut4 = new QToolButton( GroupEdit );
361 moveBut1->setArrowType( Qt::LeftArrow );
362 moveBut2->setArrowType( Qt::RightArrow );
363 moveBut3->setArrowType( Qt::LeftArrow );
364 moveBut4->setArrowType( Qt::RightArrow );
365 MoveBorderEndsButGrp->addButton( moveBut1, MOVE_LEFT_1 );
366 MoveBorderEndsButGrp->addButton( moveBut2, MOVE_RIGHT_1 );
367 MoveBorderEndsButGrp->addButton( moveBut3, MOVE_LEFT_2 );
368 MoveBorderEndsButGrp->addButton( moveBut4, MOVE_RIGHT_2 );
370 SwapBut = new QPushButton( "<->", GroupEdit );
371 BorderEndLine[0] = new QLineEdit( GroupEdit );
372 BorderEndLine[1] = new QLineEdit( GroupEdit );
373 BorderEndLine[0]->setReadOnly(true);
374 BorderEndLine[1]->setReadOnly(true);
375 QLabel* StepLabel = new QLabel(tr("STEP"), GroupEdit );
376 StepSpin = new SalomeApp_IntSpinBox( 1, 100000, 1, GroupEdit,
377 /*acceptNames=*/false, /*showTip=*/false );
378 StepSpin->setValue( 1 );
380 GroupEditLayout->addWidget(ListEdit, 0, 0, 1, 8);
381 GroupEditLayout->addWidget(SetFirstButton, 0, 8);
382 GroupEditLayout->addWidget(RemoveElemButton, 0, 9);
383 GroupEditLayout->addWidget(moveBut1, 1, 0);
384 GroupEditLayout->addWidget(BorderEndLine[0], 1, 1);
385 GroupEditLayout->addWidget(moveBut2, 1, 2);
386 GroupEditLayout->addWidget(moveBut3, 1, 3);
387 GroupEditLayout->addWidget(BorderEndLine[1], 1, 4);
388 GroupEditLayout->addWidget(moveBut4, 1, 5);
389 GroupEditLayout->setColumnStretch( 6, 5 );
390 GroupEditLayout->addWidget(SwapBut, 1, 7);
391 GroupEditLayout->addWidget(StepLabel, 1, 8);
392 GroupEditLayout->addWidget(StepSpin, 1, 9);
393 GroupEditLayout->setRowStretch( 0, 1 );
395 GroupCoincidentLayout->addWidget( GroupCoincident );
396 GroupCoincidentLayout->addWidget( GroupEdit );
397 GroupCoincidentLayout->setRowStretch( 0, 10 );
398 GroupCoincidentLayout->setRowStretch( 1, 1 );
400 aSewFreeBordersLayout->addWidget( GroupCoincidentWidget );
403 GroupArgumentsLayout->addWidget(ModeGroup);
404 GroupArgumentsLayout->addWidget(SubGroup1);
405 GroupArgumentsLayout->addWidget(SubGroup2);
406 GroupArgumentsLayout->addWidget(SewFreeBordersWidget);
407 GroupArgumentsLayout->addWidget(CheckBoxMerge);
408 GroupArgumentsLayout->addWidget(CheckBoxPolygons);
409 GroupArgumentsLayout->addWidget(CheckBoxPolyedrs);
411 /***************************************************************/
412 GroupButtons = new QGroupBox(this);
413 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
414 GroupButtonsLayout->setSpacing(SPACING);
415 GroupButtonsLayout->setMargin(MARGIN);
417 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
418 buttonOk->setAutoDefault(true);
419 buttonOk->setDefault(true);
420 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
421 buttonApply->setAutoDefault(true);
422 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
423 buttonCancel->setAutoDefault(true);
424 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
425 buttonHelp->setAutoDefault(true);
427 GroupButtonsLayout->addWidget(buttonOk);
428 GroupButtonsLayout->addSpacing(10);
429 GroupButtonsLayout->addWidget(buttonApply);
430 GroupButtonsLayout->addSpacing(10);
431 GroupButtonsLayout->addStretch();
432 GroupButtonsLayout->addWidget(buttonCancel);
433 GroupButtonsLayout->addWidget(buttonHelp);
435 /***************************************************************/
436 SMESHGUI_SewingDlgLayout->addWidget(ConstructorsBox);
437 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments);
438 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons);
439 //SMESHGUI_SewingDlgLayout->setStretch( 2, 10 );
441 /* Initialisations */
442 RadioButton1->setChecked(true);
444 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, 1));
445 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, 1));
446 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, 1));
447 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, 1));
449 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
451 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
453 myHelpFileName = "sewing_meshes_page.html";
460 /* signals and slots connections */
461 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
462 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
463 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
464 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
465 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
467 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
468 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
469 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
470 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
471 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
472 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
474 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
475 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
476 /* to close dialog if study change */
477 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
478 connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView()));
479 connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView()));
481 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
482 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
483 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
484 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
485 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
486 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
488 connect(ModeButGrp, SIGNAL(buttonClicked(int)), SLOT(onModeChange(int)));
489 connect(AutoSewCheck, SIGNAL(stateChanged(int)), SLOT(onAutoSew(int)));
490 connect(DetectButton, SIGNAL(clicked()), SLOT(onDetectClicked()));
491 connect(RemoveGroupButton, SIGNAL(clicked()), SLOT(onRemoveGroupClicked()));
492 connect(ListCoincident, SIGNAL(itemSelectionChanged()), SLOT(onSelectGroup()));
493 connect(SelectAllCheck, SIGNAL(stateChanged(int)), SLOT(onSelectAll(int)));
494 connect(ListEdit, SIGNAL(itemSelectionChanged()), SLOT(onSelectBorderPartFromGroup()));
495 connect(SetFirstButton, SIGNAL(clicked()), SLOT(onSetFirstClicked()));
496 connect(RemoveElemButton, SIGNAL(clicked()), SLOT(onRemoveElemClicked()));
497 connect(MoveBorderEndsButGrp, SIGNAL(buttonClicked(int)), SLOT(onMoveBorderEnd(int)));
498 connect(SwapBut, SIGNAL(clicked()), SLOT(onSwapClicked()));
500 ConstructorsClicked(0);
503 //=================================================================================
504 // function : ~SMESHGUI_SewingDlg()
505 // purpose : Destroys the object and frees any allocated resources
506 //=================================================================================
507 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
509 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
511 delete myBorderDisplayers[ i ];
512 myBorderDisplayers[ i ] = 0;
514 myBorderDisplayers.clear();
517 //=================================================================================
520 //=================================================================================
521 void SMESHGUI_SewingDlg::Init()
525 if ( LineEdit1->isVisible() )
526 myEditCurrentArgument = LineEdit1;
528 myEditCurrentArgument = LineEditMesh;
529 myEditCurrentArgument->setFocus();
531 myMesh = SMESH::SMESH_Mesh::_nil();
532 // CheckBoxMerge->setChecked(false);
533 // CheckBoxPolygons->setChecked(false);
534 // CheckBoxPolyedrs->setChecked(false);
535 SelectionIntoArgument();
538 //=================================================================================
539 // function : ConstructorsClicked()
540 // purpose : Radio button management
541 //=================================================================================
542 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
544 disconnect(mySelectionMgr, 0, this, 0);
546 mySelectionMgr->selectedObjects( io );
547 mySelectionMgr->clearSelected();
548 LineEdit1->setText("");
549 LineEdit2->setText("");
550 LineEdit3->setText("");
551 LineEdit4->setText("");
552 LineEdit5->setText("");
553 LineEdit6->setText("");
554 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
555 myEditCurrentArgument = LineEdit1;
556 myEditCurrentArgument->setFocus();
558 if (!TextLabel5->isEnabled()) {
559 TextLabel5->setEnabled(true);
560 SelectButton5->setEnabled(true);
561 LineEdit5->setEnabled(true);
562 } else if (!TextLabel6->isEnabled()) {
563 TextLabel6->setEnabled(true);
564 SelectButton6->setEnabled(true);
565 LineEdit6->setEnabled(true);
568 if (constructorId == 1 || constructorId == 3) {
569 if (CheckBoxPolygons->isVisible())
570 CheckBoxPolygons->hide();
571 if (CheckBoxPolyedrs->isVisible())
572 CheckBoxPolyedrs->hide();
575 if (( !SubGroup1->isVisible() ) &&
576 ( constructorId != 0 || ModeButGrp->checkedId() == MODE_MANUAL ))
582 if ( constructorId != 0 )
585 SewFreeBordersWidget->hide();
586 restoreDisplayMode();
589 bool isNodeSelection = true;
591 switch (constructorId) {
594 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
595 SubGroup1->setTitle(tr("BORDER_1"));
596 SubGroup2->setTitle(tr("BORDER_2"));
598 if (!CheckBoxPolygons->isVisible())
599 CheckBoxPolygons->show();
600 if (!CheckBoxPolyedrs->isVisible())
601 CheckBoxPolyedrs->show();
603 if ( !ModeGroup->isVisible() )
607 onModeChange( ModeButGrp->checkedId() );
609 isNodeSelection = ( ModeButGrp->checkedId() == MODE_MANUAL );
615 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
616 SubGroup1->setTitle(tr("BORDER_1"));
617 SubGroup2->setTitle(tr("BORDER_2"));
619 TextLabel6->setEnabled(false);
620 SelectButton6->setEnabled(false);
621 LineEdit6->setEnabled(false);
629 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
630 SubGroup1->setTitle(tr("BORDER"));
631 SubGroup2->setTitle(tr("SIDE"));
633 TextLabel5->setEnabled(false);
634 SelectButton5->setEnabled(false);
635 LineEdit5->setEnabled(false);
637 if (!CheckBoxPolygons->isVisible())
638 CheckBoxPolygons->show();
639 if (!CheckBoxPolyedrs->isVisible())
640 CheckBoxPolyedrs->show();
648 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
649 SubGroup1->setTitle(tr("SIDE_1"));
650 SubGroup2->setTitle(tr("SIDE_2"));
652 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
653 TextLabel2->setText(tr("NODE1_TO_MERGE"));
654 TextLabel3->setText(tr("NODE2_TO_MERGE"));
655 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
656 TextLabel5->setText(tr("NODE1_TO_MERGE"));
657 TextLabel6->setText(tr("NODE2_TO_MERGE"));
659 LineEdit1->setValidator(new SMESHGUI_IdValidator(this));
660 LineEdit4->setValidator(new SMESHGUI_IdValidator(this));
662 isNodeSelection = false;
663 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
664 aViewWindow->SetSelectionMode(CellSelection);
669 if (constructorId != 3) {
670 TextLabel1->setText(tr("FIRST_NODE_ID"));
671 TextLabel2->setText(tr("SECOND_NODE_ID"));
672 TextLabel3->setText(tr("LAST_NODE_ID"));
673 TextLabel4->setText(tr("FIRST_NODE_ID"));
674 TextLabel5->setText(tr("SECOND_NODE_ID"));
675 TextLabel6->setText(tr("LAST_NODE_ID"));
677 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, 1));
678 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, 1));
682 myActor->SetPointRepresentation( isNodeSelection );
684 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
685 aViewWindow->SetSelectionMode( isNodeSelection ? NodeSelection : ActorSelection );
689 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
690 mySelectionMgr->setSelectedObjects( io );
692 QApplication::instance()->processEvents();
698 //=======================================================================
699 //function : storeDisplayMode
700 //purpose : save representation of a mesh and switch it to wireframe mode
701 //=======================================================================
703 void SMESHGUI_SewingDlg::setDisplayMode()
705 myStoredEntityMode = 0;
706 myStoredRepresentation = -1;
708 if ( myActor && AutoSewCheck->isVisible() && !AutoSewCheck->isChecked() )
710 myStoredEntityMode = myActor->GetEntityMode();
711 myStoredRepresentation = myActor->GetRepresentation();
713 myActor->SetEntityMode( myStoredEntityMode & ~SMESH_Actor::eVolumes );
714 myActor->SetRepresentation( SMESH_Actor::eEdge );
718 //=======================================================================
719 //function : restoreDisplayMode
720 //purpose : restore representation of a mesh
721 //=======================================================================
723 void SMESHGUI_SewingDlg::restoreDisplayMode()
725 if ( myActor && myStoredEntityMode )
727 if ( myActor->GetEntityMode() == ( myStoredEntityMode & ~SMESH_Actor::eVolumes ))
728 myActor->SetEntityMode( myStoredEntityMode );
730 if ( myActor->GetRepresentation() == SMESH_Actor::eEdge )
731 myActor->SetRepresentation( myStoredRepresentation );
733 myStoredEntityMode = 0;
734 myStoredRepresentation = -1;
736 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
737 if ( myBorderDisplayers[ i ])
738 myBorderDisplayers[ i ]->Hide();
741 //=======================================================================
742 //function : onModeChange
743 //purpose : SLOT called when mode (auto or manual) of Sew free borders change
744 //=======================================================================
746 void SMESHGUI_SewingDlg::onModeChange( int mode )
748 if ( mode == MODE_MANUAL )
750 myEditCurrentArgument = LineEdit1;
751 if ( !SubGroup1->isVisible() )
752 SubGroup1->show(), SubGroup2->show();
753 SewFreeBordersWidget->hide();
757 myEditCurrentArgument = LineEditMesh;
758 SubGroup1->hide(), SubGroup2->hide();
759 if ( !SewFreeBordersWidget->isVisible() )
760 SewFreeBordersWidget->show();
763 myActor->SetPointRepresentation( mode == MODE_MANUAL );
765 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
766 aViewWindow->SetSelectionMode( mode == MODE_MANUAL ? NodeSelection : ActorSelection );
768 onAutoSew( AutoSewCheck->isChecked() );
770 QApplication::instance()->processEvents();
776 //=======================================================================
777 //function : onAutoSew
778 //purpose : SLOT called when Auto Sewing check box is checked
779 //=======================================================================
781 void SMESHGUI_SewingDlg::onAutoSew( int isAuto )
783 GroupCoincidentWidget->setVisible( !isAuto );
785 QApplication::instance()->processEvents();
787 SewFreeBordersWidget->hide();
788 if ( ModeButGrp->checkedId() == MODE_AUTO )
789 SewFreeBordersWidget->show();
792 restoreDisplayMode();
795 SMESH::RepaintCurrentView();
800 resize(minimumSizeHint());
803 //=======================================================================
804 //function : haveBorders
805 //purpose : Returns true if myBorders have been initialized
806 //=======================================================================
808 bool SMESHGUI_SewingDlg::haveBorders()
810 return ( & myBorders.in() &&
811 myBorders->borders.length() &&
812 myBorders->coincidentGroups.length() );
815 //=======================================================================
816 //function : getGroupText
817 //purpose : Returns a text of a given group of coincident free borders
818 //=======================================================================
820 QString SMESHGUI_SewingDlg::getPartText(const SMESH::FreeBorderPart& aPART)
823 if ( 0 <= aPART.border && aPART.border < myBorders->borders.length() )
825 const SMESH::FreeBorder& aBRD = myBorders->borders[ aPART.border ];
826 if ( 0 <= aPART.node1 && aPART.node1 < aBRD.nodeIDs.length() &&
827 0 <= aPART.nodeLast && aPART.nodeLast < aBRD.nodeIDs.length() )
829 text += QString("( %1 %2 ) ")
830 .arg( aBRD.nodeIDs[ aPART.node1 ] )
831 .arg( aBRD.nodeIDs[ aPART.nodeLast ] );
837 //=======================================================================
838 //function : getGroupText
839 //purpose : Returns a text of a given group of coincident free borders
840 //=======================================================================
842 QString SMESHGUI_SewingDlg::getGroupText(int groupIndex)
846 if ( haveBorders() &&
848 groupIndex < myBorders->coincidentGroups.length() )
850 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ groupIndex ];
852 for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
854 QString partText = getPartText( aGRP[ iP ]);
855 if ( partText.isEmpty() )
863 //=======================================================================
864 //function : onDetectClicked
865 //purpose : SLOT called when [Detect] is clicked
866 //=======================================================================
868 void SMESHGUI_SewingDlg::onDetectClicked()
871 ListCoincident->clear();
873 if ( myMesh->_is_nil() )
876 SUIT_OverrideCursor wc;
878 SMESH::SMESH_MeshEditor_var editor = myMesh->GetMeshEditor();
879 myBorders = editor->FindCoincidentFreeBorders( SpinBoxTolerance->GetValue() );
880 if ( !haveBorders() )
883 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
885 delete myBorderDisplayers[ i ];
886 myBorderDisplayers[ i ] = 0;
888 myBorderDisplayers.resize( myBorders->coincidentGroups.length(), 0 );
890 for ( CORBA::ULong i = 0; i < myBorders->coincidentGroups.length(); ++i )
892 QString groupText = getGroupText( i );
893 if ( groupText.isEmpty() )
897 groupColor.setHsvF( float(i) / myBorders->coincidentGroups.length(), 1., 1. );
898 QPixmap icon( QSize( 20, 20 ));
899 icon.fill( groupColor );
901 QListWidgetItem * item = new QListWidgetItem( icon, groupText, ListCoincident );
902 item->setData( GROUP_COLOR, groupColor );
903 item->setData( GROUP_INDEX, i );
912 //=======================================================================
913 //function : onRemoveGroupClicked
915 //=======================================================================
917 void SMESHGUI_SewingDlg::onRemoveGroupClicked()
920 QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
921 for ( int i = 0; i < selItems.count(); ++i )
923 QListWidgetItem* item = selItems[ i ];
924 item->setSelected( false );
925 int groupIndex = item->data( GROUP_INDEX ).toInt();
927 if ( myBorderDisplayers[ groupIndex ])
928 myBorderDisplayers[ groupIndex ]->Hide();
929 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
938 //=======================================================================
939 //function : showGroup
940 //purpose : display a group of coincident free borders in the Viewer
941 //=======================================================================
943 void SMESHGUI_SewingDlg::showGroup( QListWidgetItem* item )
946 item->listWidget() != ListCoincident ||
950 int groupIndex = item->data( GROUP_INDEX ).toInt();
951 QColor groupColor = item->data( GROUP_COLOR ).value<QColor>();
952 if ( groupIndex >= 0 &&
953 groupIndex < myBorders->coincidentGroups.length() )
955 if ( !myBorderDisplayers[ groupIndex ] && SMESH::GetCurrentVtkView())
956 myBorderDisplayers[ groupIndex ] = new BorderGroupDisplayer( myBorders, groupIndex, groupColor, myMesh );
957 bool wholeBorders = setCurrentGroup();
958 if ( myBorderDisplayers[ groupIndex ])
959 myBorderDisplayers[ groupIndex ]->ShowGroup( wholeBorders );
963 //=======================================================================
964 //function : setCurrentGroup
965 //purpose : set index of a current free border group to myCurGroupIndex
966 //=======================================================================
968 bool SMESHGUI_SewingDlg::setCurrentGroup()
970 if ( !haveBorders() )
973 QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
974 if ( selItems.count() != 1 )
977 myCurGroupIndex = selItems[0]->data( GROUP_INDEX ).toInt();
979 return ( myCurGroupIndex >= 0 && myCurGroupIndex < myBorders->coincidentGroups.length() );
982 //=======================================================================
983 //function : setCurrentPart
984 //purpose : set index of a current free border of a current group to myCurPartIndex
985 //=======================================================================
987 bool SMESHGUI_SewingDlg::setCurrentPart()
989 if ( !setCurrentGroup() )
992 if ( ListEdit->selectedItems().count() != 1 )
995 myCurPartIndex = ListEdit->currentRow();
996 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
998 return ( myCurPartIndex >= 0 && myCurPartIndex < aGRP.length() );
1001 //=======================================================================
1002 //function : onSelectGroup
1003 //purpose : SLOT called when selection of coincident free borders change
1004 //=======================================================================
1006 void SMESHGUI_SewingDlg::onSelectGroup()
1011 BorderEndLine[0]->clear();
1012 BorderEndLine[1]->clear();
1013 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
1014 if ( myBorderDisplayers[ i ])
1015 myBorderDisplayers[ i ]->Hide();
1017 QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
1019 RemoveGroupButton->setEnabled( selItems.count() > 0 );
1021 onSelectBorderPartFromGroup(); // enable buttons
1023 if ( !haveBorders() )
1026 SelectAllCheck->blockSignals( true );
1027 if ( ListCoincident->count() != selItems.count() )
1028 SelectAllCheck->setChecked( false );
1029 SelectAllCheck->blockSignals( false );
1031 if ( selItems.empty() ) // nothing selected - show all
1032 for ( int i = 0; i < ListCoincident->count(); ++i )
1033 showGroup( ListCoincident->item( i ));
1035 for ( int i = 0; i < selItems.count(); ++i )
1036 showGroup( selItems[ i ]);
1038 if ( setCurrentGroup() ) // edit a selected group
1040 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1041 for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
1042 new QListWidgetItem( getPartText( aGRP[ iP ]), ListEdit );
1044 SMESH::RepaintCurrentView();
1047 //=======================================================================
1048 //function : onSelectAll
1049 //purpose : SLOT called when Select All is checked
1050 //=======================================================================
1052 void SMESHGUI_SewingDlg::onSelectAll(int isOn)
1055 ListCoincident->selectAll();
1057 ListCoincident->clearSelection();
1060 //=======================================================================
1061 //function : onSelectBorderPartFromGroup
1062 //purpose : SLOT called when selection of borders in an edited group changes
1063 //=======================================================================
1065 void SMESHGUI_SewingDlg::onSelectBorderPartFromGroup()
1067 if ( myBusy ) return;
1068 BorderEndLine[0]->setText("");
1069 BorderEndLine[1]->setText("");
1070 MoveBorderEndsButGrp->button( MOVE_LEFT_1 )->setEnabled( false );
1071 MoveBorderEndsButGrp->button( MOVE_RIGHT_1 )->setEnabled( false );
1072 MoveBorderEndsButGrp->button( MOVE_LEFT_2 )->setEnabled( false );
1073 MoveBorderEndsButGrp->button( MOVE_RIGHT_2 )->setEnabled( false );
1074 SwapBut->setEnabled( false );
1075 SetFirstButton->setEnabled( false );
1076 RemoveElemButton->setEnabled ( ListEdit->count() > 2 );
1078 if ( !setCurrentGroup() )
1081 if ( !myBorderDisplayers[ myCurGroupIndex ]) return;
1082 myBorderDisplayers[ myCurGroupIndex ]->Hide();
1084 QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
1085 bool editPart = ( setCurrentPart() );
1086 for ( int i = 0; i < selItems.count(); ++i )
1087 myBorderDisplayers[ myCurGroupIndex ]->ShowPart( ListEdit->row( selItems[i] ), editPart );
1089 if ( selItems.isEmpty() )
1090 myBorderDisplayers[ myCurGroupIndex ]->ShowGroup( /*wholeBorders=*/ true );
1094 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1095 SMESH::FreeBorderPart& aPRT = aGRP[ myCurPartIndex ];
1096 SMESH::FreeBorder& aBRD = myBorders->borders[ aPRT.border ];
1098 BorderEndLine[0]->setText( QString::number( aBRD.nodeIDs[ aPRT.node1 ]));
1099 BorderEndLine[1]->setText( QString::number( aBRD.nodeIDs[ aPRT.nodeLast ]));
1100 SwapBut->setEnabled( true );
1101 SetFirstButton->setEnabled( myCurPartIndex > 0 );
1103 int size = (int) aBRD.nodeIDs.length();
1104 bool isClosed = ( aBRD.nodeIDs[0] == aBRD.nodeIDs[ size-1 ]);
1107 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1108 int dn = ( isFwd ? +1 : -1 ) * StepSpin->value();
1109 MoveBorderEndsButGrp->button( MOVE_LEFT_1 )->
1110 setEnabled( 0 <= aPRT.node1-dn && aPRT.node1-dn < size );
1111 MoveBorderEndsButGrp->button( MOVE_RIGHT_1 )->
1112 setEnabled( 0 <= aPRT.node1+dn && aPRT.node1+dn < size );
1113 MoveBorderEndsButGrp->button( MOVE_LEFT_2 )->
1114 setEnabled( 0 <= aPRT.nodeLast-dn && aPRT.nodeLast-dn < size );
1115 MoveBorderEndsButGrp->button( MOVE_RIGHT_2 )->
1116 setEnabled( 0 <= aPRT.nodeLast+dn && aPRT.nodeLast+dn < size );
1120 MoveBorderEndsButGrp->button( MOVE_LEFT_1 )->setEnabled( true );
1121 MoveBorderEndsButGrp->button( MOVE_RIGHT_1 )->setEnabled( true );
1122 MoveBorderEndsButGrp->button( MOVE_LEFT_2 )->setEnabled( true );
1123 MoveBorderEndsButGrp->button( MOVE_RIGHT_2 )->setEnabled( true );
1126 SMESH::RepaintCurrentView();
1129 //=======================================================================
1130 //function : onGroupChange
1131 //purpose : Update after modification of a current group by the user
1132 //=======================================================================
1134 void SMESHGUI_SewingDlg::onGroupChange( bool partChange )
1136 ListCoincident->currentItem()->setText( getGroupText( myCurGroupIndex ));
1138 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1139 for ( int i = 0; i < ListEdit->count(); ++i )
1140 ListEdit->item( i )->setText( getPartText( aGRP[ i ]));
1142 if ( myBorderDisplayers[ myCurGroupIndex ])
1143 myBorderDisplayers[ myCurGroupIndex ]->Update();
1146 onSelectBorderPartFromGroup();
1149 //=======================================================================
1150 //function : onSetFirstClicked
1151 //purpose : STOL called when |<< is clicked
1152 //=======================================================================
1154 void SMESHGUI_SewingDlg::onSetFirstClicked()
1156 if ( !setCurrentPart() || myCurPartIndex == 0 || ListEdit->count() == 0 )
1159 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1161 SMESH::FreeBorderPart new1st = aGRP[ myCurPartIndex ];
1162 for ( ; myCurPartIndex > 0; --myCurPartIndex )
1163 aGRP[ myCurPartIndex ] = aGRP[ myCurPartIndex - 1 ];
1170 ListEdit->clearSelection();
1172 ListEdit->setCurrentItem( ListEdit->item(0) );//ListEdit->item(0)->setSelected(true);
1175 //=======================================================================
1176 //function : onRemoveElemClicked
1178 //=======================================================================
1180 void SMESHGUI_SewingDlg::onRemoveElemClicked()
1182 if ( !setCurrentGroup() )
1185 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1187 QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
1188 for ( int i = 0; i < selItems.count(); ++i )
1190 int part = ListEdit->row( selItems[i] );
1191 for ( ; part + 1 < aGRP.length(); ++part )
1192 aGRP[ part ] = aGRP[ part + 1 ];
1193 aGRP.length( aGRP.length() - 1 );
1197 if ( aGRP.length() == 0 )
1198 onRemoveGroupClicked();
1200 onGroupChange( /*partChange=*/true );
1203 //=======================================================================
1204 //function : onMoveBorderEnd
1206 //=======================================================================
1208 void SMESHGUI_SewingDlg::onMoveBorderEnd(int button)
1210 if ( !setCurrentPart() )
1213 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1214 SMESH::FreeBorderPart& aPRT = aGRP[ myCurPartIndex ];
1215 SMESH::FreeBorder& aBRD = myBorders->borders[ aPRT.border ];
1216 int size = (int) aBRD.nodeIDs.length();
1218 bool isClosed = ( aBRD.nodeIDs[0] == aBRD.nodeIDs[ size-1 ]);
1219 if ( isClosed ) --size;
1221 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1222 int dn = ( isFwd ? +1 : -1 ) * StepSpin->value();
1223 if ( button == MOVE_LEFT_1 || button == MOVE_LEFT_2 )
1230 ( 0 <= aPRT.node1+dn && aPRT.node1+dn < size ))
1232 aPRT.node1 = ( aPRT.node1 + size + dn ) % size;
1233 aPRT.node2 = ( aPRT.node2 + size + dn ) % size;
1239 ( 0 <= aPRT.nodeLast+dn && aPRT.nodeLast+dn < size ))
1241 aPRT.nodeLast = ( aPRT.nodeLast + size + dn ) % size;
1245 return; // impossible to move
1248 onGroupChange( /*partChange=*/true );
1251 //=======================================================================
1252 //function : onSwapClicked
1253 //purpose : SLOT called when <-> is clicked
1254 //=======================================================================
1256 void SMESHGUI_SewingDlg::onSwapClicked()
1258 if ( !setCurrentPart() )
1261 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1262 SMESH::FreeBorderPart& aPRT = aGRP[ myCurPartIndex ];
1263 SMESH::FreeBorder& aBRD = myBorders->borders[ aPRT.border ];
1264 int size = (int) aBRD.nodeIDs.length();
1266 bool isClosed = ( aBRD.nodeIDs[0] == aBRD.nodeIDs[ size-1 ]);
1267 if ( isClosed ) --size;
1269 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1271 std::swap( aPRT.nodeLast, aPRT.node1 );
1273 aPRT.node2 = ( aPRT.node1 + ( isFwd ? -1 : +1 ) + size ) % size;
1275 onGroupChange( /*partChange=*/true );
1278 //=================================================================================
1279 // function : ClickOnApply()
1281 //=================================================================================
1282 bool SMESHGUI_SewingDlg::ClickOnApply()
1284 if (mySMESHGUI->isActiveStudyLocked())
1287 bool aResult = false;
1291 bool toMerge = CheckBoxMerge->isChecked();
1292 bool toCreatePolygons = CheckBoxPolygons->isChecked();
1293 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
1295 SUIT_OverrideCursor aWaitCursor;
1296 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
1298 int aConstructorId = GetConstructorId();
1299 SMESH::SMESH_MeshEditor::Sew_Error anError;
1301 if (aConstructorId == 0)
1303 if ( ModeButGrp->checkedId() == MODE_MANUAL )
1305 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
1306 LineEdit2->text().toLong(),
1307 LineEdit3->text().toLong(),
1308 LineEdit4->text().toLong(),
1309 LineEdit5->text().toLong(),
1310 LineEdit6->text().toLong(),
1316 int nbCoincGroups = ListCoincident->count();
1317 if ( AutoSewCheck->isChecked() )
1319 myBorders = aMeshEditor->FindCoincidentFreeBorders( SpinBoxTolerance->GetValue() );
1320 nbCoincGroups = myBorders->coincidentGroups.length();
1322 CORBA::Short nbSewed = aMeshEditor->SewCoincidentFreeBorders( myBorders.inout(),
1326 if ( nbCoincGroups == 0 )
1327 msg = tr("NO_BORDERS_TO_SEW");
1328 else if ( nbSewed < nbCoincGroups )
1329 msg = tr("NOT_ALL_BORDERS_SEWED").arg( nbSewed ).arg( nbCoincGroups );
1331 msg = tr("ALL_BORDERS_SEWED").arg( nbSewed );
1332 SUIT_MessageBox::information( this, tr("SMESH_INFORMATION"), msg );
1334 anError = SMESH::SMESH_MeshEditor::SEW_OK;
1337 else if (aConstructorId == 1)
1339 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
1340 LineEdit2->text().toLong(),
1341 LineEdit3->text().toLong(),
1342 LineEdit4->text().toLong(),
1343 LineEdit5->text().toLong());
1345 else if (aConstructorId == 2)
1347 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
1348 LineEdit2->text().toLong(),
1349 LineEdit3->text().toLong(),
1350 LineEdit4->text().toLong(),
1351 LineEdit6->text().toLong(),
1355 else if (aConstructorId == 3) {
1356 QStringList aListElementsId1 = LineEdit1->text().split(" ", QString::SkipEmptyParts);
1357 QStringList aListElementsId2 = LineEdit4->text().split(" ", QString::SkipEmptyParts);
1359 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
1360 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
1362 anElementsId1->length(aListElementsId1.count());
1363 anElementsId2->length(aListElementsId2.count());
1365 for (int i = 0; i < aListElementsId1.count(); i++)
1366 anElementsId1[i] = aListElementsId1[i].toInt();
1367 for (int i = 0; i < aListElementsId2.count(); i++)
1368 anElementsId2[i] = aListElementsId2[i].toInt();
1370 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
1371 anElementsId2.inout(),
1372 LineEdit2->text().toLong(),
1373 LineEdit5->text().toLong(),
1374 LineEdit3->text().toLong(),
1375 LineEdit6->text().toLong());
1377 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
1379 if (toMerge && aResult)
1380 aMeshEditor->MergeEqualElements();
1383 QString msg = tr(QString("ERROR_%1").arg(anError).toLatin1().data());
1384 SUIT_MessageBox::warning(this, tr("SMESH_WRN_WARNING"), msg);
1393 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
1394 SALOME_ListIO aList;
1396 mySelectionMgr->setSelectedObjects(aList, false);
1397 SMESH::UpdateView();
1400 ConstructorsClicked(GetConstructorId());
1402 SMESHGUI::Modified();
1409 //=================================================================================
1410 // function : ClickOnOk()
1412 //=================================================================================
1413 void SMESHGUI_SewingDlg::ClickOnOk()
1419 //=================================================================================
1420 // function : onOpenView()
1422 //=================================================================================
1423 void SMESHGUI_SewingDlg::onOpenView()
1426 SMESH::SetPointRepresentation(false);
1429 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
1430 ActivateThisDialog();
1434 //=================================================================================
1435 // function : onCloseView()
1437 //=================================================================================
1438 void SMESHGUI_SewingDlg::onCloseView()
1440 DeactivateActiveDialog();
1444 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
1446 delete myBorderDisplayers[ i ];
1447 myBorderDisplayers[ i ] = 0;
1449 myBorderDisplayers.clear();
1452 //=================================================================================
1453 // function : reject()
1455 //=================================================================================
1456 void SMESHGUI_SewingDlg::reject()
1458 restoreDisplayMode();
1459 //mySelectionMgr->clearSelected();
1460 SMESH::SetPointRepresentation(false);
1461 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1462 aViewWindow->SetSelectionMode(ActorSelection);
1463 disconnect(mySelectionMgr, 0, this, 0);
1464 mySMESHGUI->ResetState();
1468 //=================================================================================
1469 // function : ClickOnHelp()
1471 //=================================================================================
1472 void SMESHGUI_SewingDlg::ClickOnHelp()
1474 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1476 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1480 platform = "winapplication";
1482 platform = "application";
1484 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
1485 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1486 arg(app->resourceMgr()->stringValue("ExternalBrowser",
1488 arg(myHelpFileName));
1492 //=======================================================================
1493 //function : onTextChange
1495 //=======================================================================
1496 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
1498 QLineEdit* send = (QLineEdit*)sender();
1504 myEditCurrentArgument = send;
1506 if (send == LineEdit1)
1508 else if (send == LineEdit2)
1510 else if (send == LineEdit3)
1512 else if (send == LineEdit4)
1514 else if (send == LineEdit5)
1516 else if (send == LineEdit6)
1519 // hilight entered elements/nodes
1520 SMDS_Mesh* aMesh = 0;
1523 aMesh = myActor->GetObject()->GetMesh();
1528 TColStd_MapOfInteger newIndices;
1530 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
1531 SMESH::SetPointRepresentation(true);
1533 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1534 aViewWindow->SetSelectionMode(NodeSelection);
1536 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
1538 newIndices.Add(n->GetID());
1539 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
1540 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1541 aViewWindow->highlight( myActor->getIO(), true, true );
1543 if (send == LineEdit1)
1545 else if (send == LineEdit2)
1547 else if (send == LineEdit3)
1549 else if (send == LineEdit4)
1551 else if (send == LineEdit5)
1553 else if (send == LineEdit6)
1557 SMESH::SetPointRepresentation(false);
1559 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1560 aViewWindow->SetSelectionMode(CellSelection);
1562 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
1564 bool isEvenOneExists = false;
1566 for (int i = 0; i < aListId.count(); i++) {
1567 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
1569 newIndices.Add(e->GetID());
1571 if (!isEvenOneExists)
1572 isEvenOneExists = true;
1575 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
1576 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1577 aViewWindow->highlight( myActor->getIO(), true, true );
1579 if (isEvenOneExists) {
1580 if (send == LineEdit1)
1582 else if(send == LineEdit4)
1595 //=================================================================================
1596 // function : SelectionIntoArgument()
1597 // purpose : Called when selection as changed or other case
1598 //=================================================================================
1599 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
1604 restoreDisplayMode();
1605 if (isSelectionChanged)
1608 QString aString = "";
1611 myEditCurrentArgument->setText(aString);
1612 ListCoincident->clear();
1616 onSelectGroup(); // erase preview
1618 if (!GroupButtons->isEnabled()) // inactive
1621 buttonOk->setEnabled(false);
1622 buttonApply->setEnabled(false);
1623 DetectButton->setEnabled(false);
1625 // get selected mesh
1626 SALOME_ListIO aList;
1627 mySelectionMgr->selectedObjects(aList);
1629 int nbSel = aList.Extent();
1633 Handle(SALOME_InteractiveObject) IO = aList.First();
1634 myMesh = SMESH::GetMeshByIO(IO);
1635 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
1636 if (myMesh->_is_nil())
1639 CheckBoxPolyedrs->setEnabled( myMesh->NbVolumes() > 0 );
1641 if ( myEditCurrentArgument == LineEditMesh )
1643 LineEditMesh->setText( IO->getName() );
1644 ListCoincident->clear();
1645 if ( AutoSewCheck->isChecked() )
1647 buttonOk->setEnabled(true);
1648 buttonApply->setEnabled(true);
1650 DetectButton->setEnabled( myMesh->NbFaces() > 0 );
1658 // get selected elements/nodes
1660 if (( GetConstructorId() != 3 ) ||
1661 ( myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4))
1663 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
1668 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
1674 myEditCurrentArgument->setText(aString);
1678 if (myEditCurrentArgument == LineEdit1)
1680 else if (myEditCurrentArgument == LineEdit2)
1682 else if (myEditCurrentArgument == LineEdit3)
1684 else if (myEditCurrentArgument == LineEdit4)
1686 else if (myEditCurrentArgument == LineEdit5)
1688 else if (myEditCurrentArgument == LineEdit6)
1694 //=================================================================================
1695 // function : SetEditCurrentArgument()
1697 //=================================================================================
1698 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
1700 QPushButton* send = (QPushButton*)sender();
1702 disconnect(mySelectionMgr, 0, this, 0);
1703 mySelectionMgr->clearSelected();
1705 if (send == SelectButton1) {
1706 myEditCurrentArgument = LineEdit1;
1709 else if (send == SelectButton2) {
1710 myEditCurrentArgument = LineEdit2;
1713 else if (send == SelectButton3) {
1714 myEditCurrentArgument = LineEdit3;
1717 else if (send == SelectButton4) {
1718 myEditCurrentArgument = LineEdit4;
1721 else if (send == SelectButton5) {
1722 myEditCurrentArgument = LineEdit5;
1725 else if (send == SelectButton6) {
1726 myEditCurrentArgument = LineEdit6;
1730 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
1731 SMESH::SetPointRepresentation(true);
1733 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1734 aViewWindow->SetSelectionMode(NodeSelection);
1737 SMESH::SetPointRepresentation(false);
1738 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1739 aViewWindow->SetSelectionMode(CellSelection);
1742 myEditCurrentArgument->setFocus();
1743 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1744 SelectionIntoArgument(false);
1747 //=================================================================================
1748 // function : DeactivateActiveDialog()
1750 //=================================================================================
1751 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
1753 if (ConstructorsBox->isEnabled()) {
1754 ConstructorsBox->setEnabled(false);
1755 GroupArguments->setEnabled(false);
1756 GroupButtons->setEnabled(false);
1757 mySMESHGUI->ResetState();
1758 mySMESHGUI->SetActiveDialogBox(0);
1762 //=================================================================================
1763 // function : ActivateThisDialog()
1765 //=================================================================================
1766 void SMESHGUI_SewingDlg::ActivateThisDialog()
1768 /* Emit a signal to deactivate the active dialog */
1769 mySMESHGUI->EmitSignalDeactivateDialog();
1770 ConstructorsBox->setEnabled(true);
1771 GroupArguments->setEnabled(true);
1772 GroupButtons->setEnabled(true);
1774 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1776 ConstructorsClicked(GetConstructorId());
1777 SelectionIntoArgument();
1780 //=================================================================================
1781 // function : enterEvent()
1783 //=================================================================================
1784 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
1786 if (!ConstructorsBox->isEnabled()) {
1787 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
1788 if ( aViewWindow && !mySelector) {
1789 mySelector = aViewWindow->GetSelector();
1791 ActivateThisDialog();
1795 //=================================================================================
1796 // function : GetConstructorId()
1798 //=================================================================================
1799 int SMESHGUI_SewingDlg::GetConstructorId()
1801 return GroupConstructors->checkedId();
1804 //=================================================================================
1805 // function : GetConstructorId()
1807 //=================================================================================
1808 bool SMESHGUI_SewingDlg::IsValid()
1810 if ( myMesh->_is_nil() )
1813 if ( GetConstructorId() == 0 && ModeButGrp->checkedId() == MODE_AUTO )
1815 if ( AutoSewCheck->isChecked() )
1819 if ( haveBorders() )
1820 for ( int i = 0; i < ListCoincident->count(); ++i )
1822 int groupIndex = ListCoincident->item(i)->data( GROUP_INDEX ).toInt();
1823 nbGroups += ( !getGroupText( groupIndex ).isEmpty() );
1825 return nbGroups > 0;
1827 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);
1830 //=======================================================================
1831 //function : UpdateButtons
1832 //purpose : activate [Apply] buttons
1833 //=======================================================================
1835 void SMESHGUI_SewingDlg::UpdateButtons()
1837 bool ok = IsValid();
1838 buttonOk->setEnabled( ok );
1839 buttonApply->setEnabled( ok );
1842 //=================================================================================
1843 // function : keyPressEvent()
1845 //=================================================================================
1846 void SMESHGUI_SewingDlg::keyPressEvent( QKeyEvent* e )
1848 QDialog::keyPressEvent( e );
1849 if ( e->isAccepted() )
1852 if ( e->key() == Qt::Key_F1 ) {
1858 SMESHGUI_SewingDlg::
1859 BorderGroupDisplayer::BorderGroupDisplayer( const SMESH::CoincidentFreeBorders& borders,
1862 SMESH::SMESH_Mesh_ptr mesh):
1863 myBorders ( borders.borders ),
1864 myGroup ( borders.coincidentGroups[ groupIndex ]),
1867 myViewWindow( SMESH::GetCurrentVtkView() ),
1868 myIdPreview ( myViewWindow )
1873 SMESHGUI_SewingDlg::BorderGroupDisplayer::~BorderGroupDisplayer()
1875 for ( size_t i = 0; i < myPartActors.size(); ++i )
1877 if ( myPartActors[ i ]) {
1878 myViewWindow->RemoveActor( myPartActors[i] );
1879 myPartActors[i]->Delete();
1882 myIdPreview.SetPointsLabeled(false);
1883 //myViewWindow->Repaint();
1886 void SMESHGUI_SewingDlg::BorderGroupDisplayer::Hide()
1888 for ( size_t i = 0; i < myPartActors.size(); ++i )
1889 if ( myPartActors[ i ])
1890 myPartActors[ i ]->SetVisibility(false);
1892 myIdPreview.SetPointsLabeled(false);
1895 void SMESHGUI_SewingDlg::BorderGroupDisplayer::ShowGroup( bool wholeBorders )
1897 std::vector<int> ids;
1898 std::list<gp_XYZ> coords;
1899 for ( size_t i = 0; i < myPartActors.size(); ++i )
1900 if ( myPartActors[ i ])
1902 myPartActors[ i ]->SetPointRepresentation( wholeBorders );
1903 myPartActors[ i ]->SetVisibility( true );
1905 getPartEnds( i, ids, coords );
1908 myIdPreview.SetElemsData( ids, coords );
1909 myIdPreview.SetPointsLabeled( wholeBorders, true );
1912 void SMESHGUI_SewingDlg::BorderGroupDisplayer::ShowPart( int partIndex, bool toEdit )
1914 if ( partIndex < (int) myPartActors.size() )
1916 myPartActors[partIndex]->SetVisibility(true);
1917 myPartActors[partIndex]->SetPointRepresentation(toEdit);
1921 std::vector<int> ids;
1922 std::list<gp_XYZ> coords;
1923 getPartEnds( partIndex, ids, coords );
1925 myIdPreview.SetElemsData( ids, coords );
1926 myIdPreview.SetPointsLabeled( true, /*show=*/true );
1931 void SMESHGUI_SewingDlg::BorderGroupDisplayer::getPartEnds( int partIndex,
1932 std::vector<int> & ids,
1933 std::list<gp_XYZ>& coords)
1935 const SMESH::FreeBorderPart& aPART = myGroup [ partIndex ];
1936 const SMESH::FreeBorder& aBRD = myBorders[ aPART.border ];
1938 ids.push_back( aBRD.nodeIDs[ aPART.node1 ]);
1939 ids.push_back( aBRD.nodeIDs[ aPART.nodeLast ]);
1941 SMDS_Mesh* mesh = myPartActors[ partIndex ]->GetObject()->GetMesh();
1943 coords.push_back( SMESH_TNodeXYZ( mesh->FindNode( aPART.node1+1 )));
1944 coords.push_back( SMESH_TNodeXYZ( mesh->FindNode( aPART.nodeLast+1 )));
1947 void SMESHGUI_SewingDlg::BorderGroupDisplayer::Update()
1950 myPartActors.resize( myGroup.length(), 0 );
1952 for ( size_t i = 0; i < myPartActors.size(); ++i )
1955 if ( myPartActors[ i ])
1956 obj = myPartActors[ i ]->GetObject();
1958 obj = TVisualObjPtr( new SMESHGUI_PreVisualObj() );
1959 SMDS_Mesh* mesh = obj->GetMesh();
1963 const SMESH::FreeBorderPart& aPRT = myGroup[ i ];
1964 const SMESH::FreeBorder& aBRD = myBorders[ aPRT.border ];
1965 for ( CORBA::ULong iN = 0; iN < aBRD.nodeIDs.length(); ++iN )
1967 SMESH::double_array_var xyz = myMesh->GetNodeXYZ( aBRD.nodeIDs[ iN ]);
1968 if ( xyz->length() == 3 )
1969 mesh->AddNode( xyz[0], xyz[1], xyz[2] );
1973 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1974 int dn = isFwd ? +1 : -1;
1975 int size = (int) aBRD.nodeIDs.length();
1976 int n2, n1 = aPRT.node1;
1977 for ( n2 = n1 + dn; ( n2 >= 0 && n2 < size ); n2 += dn )
1979 mesh->AddEdgeWithID( n1+1, n2+1, mesh->NbEdges() + 1 );
1981 if ( n2 == aPRT.nodeLast )
1984 if ( n2 % size != aPRT.nodeLast )
1986 if ( n2 < 0 ) n1 = size;
1988 for ( n2 = n1 + dn; ( n2 >= 0 && n2 < size ); n2 += dn )
1990 mesh->AddEdgeWithID( n1+1, n2+1, mesh->NbEdges() + 1 );
1992 if ( n2 == aPRT.nodeLast )
1997 if ( !myPartActors[ i ]) // TVisualObj must be filled before actor creation
1999 myPartActors[ i ] = SMESH_Actor::New( obj, "", "", 1 );
2000 myPartActors[ i ]->SetEdgeColor( myColor.redF(), myColor.greenF(), myColor.blueF() );
2001 myPartActors[ i ]->SetLineWidth( 3 * SMESH::GetFloat("SMESH:element_width",1));
2002 myPartActors[ i ]->SetNodeColor( myColor.redF(), myColor.greenF(), myColor.blueF() );
2003 myPartActors[ i ]->SetMarkerStd( VTK::MT_POINT, 13 );
2004 myPartActors[ i ]->SetPickable ( false );
2005 myViewWindow->AddActor( myPartActors[ i ]);
2006 //myViewWindow->Repaint();