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 <SALOMEDSClient_Study.hxx>
48 #include <SALOME_ListIO.hxx>
49 #include <SUIT_Desktop.h>
50 #include <SUIT_MessageBox.h>
51 #include <SUIT_OverrideCursor.h>
52 #include <SUIT_ResourceMgr.h>
53 #include <SUIT_Session.h>
54 #include <SVTK_ViewModel.h>
55 #include <SVTK_ViewWindow.h>
56 #include <SalomeApp_IntSpinBox.h>
57 #include <SalomeApp_Tools.h>
60 #include <TColStd_MapOfInteger.hxx>
63 #include <QApplication>
64 #include <QButtonGroup>
66 #include <QGridLayout>
68 #include <QHBoxLayout>
72 #include <QListWidget>
73 #include <QPushButton>
74 #include <QRadioButton>
75 #include <QToolButton>
76 #include <QVBoxLayout>
83 enum ActionType { MODE_AUTO=0, MODE_MANUAL,
84 MOVE_LEFT_1=0, MOVE_RIGHT_1, MOVE_LEFT_2, MOVE_RIGHT_2,
85 GROUP_COLOR=Qt::UserRole, GROUP_INDEX };
88 //=================================================================================
90 * \brief Dispalayer of free borders
92 //=================================================================================
94 struct SMESHGUI_SewingDlg::BorderGroupDisplayer
96 const SMESH::ListOfFreeBorders& myBorders;
97 const SMESH::FreeBordersGroup& myGroup;
99 SMESH::SMESH_Mesh_ptr myMesh;
101 std::vector< SMESH_Actor* > myPartActors;
102 SVTK_ViewWindow* myViewWindow;
103 SMESHGUI_IdPreview myIdPreview;
105 BorderGroupDisplayer( const SMESH::CoincidentFreeBorders& borders,
108 SMESH::SMESH_Mesh_ptr mesh);
109 ~BorderGroupDisplayer();
111 void ShowGroup( bool wholeBorders );
112 void ShowPart( int partIndex, bool toEdit );
116 void getPartEnds( int partIndex, std::vector<int> & ids, std::list<gp_XYZ>& coords);
119 //=================================================================================
120 // class : SMESHGUI_SewingDlg()
122 //=================================================================================
123 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule )
124 : QDialog( SMESH::GetDesktop( theModule ) ),
125 mySMESHGUI( theModule ),
126 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
128 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
129 QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS")));
130 QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS")));
131 QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE")));
132 QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS")));
133 QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
134 QPixmap IconRemove(mgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
137 setAttribute(Qt::WA_DeleteOnClose, true);
138 setWindowTitle(tr("SMESH_SEWING"));
139 setSizeGripEnabled(true);
141 QVBoxLayout* SMESHGUI_SewingDlgLayout = new QVBoxLayout(this);
142 SMESHGUI_SewingDlgLayout->setSpacing(SPACING);
143 SMESHGUI_SewingDlgLayout->setMargin(MARGIN);
145 /***************************************************************/
146 ConstructorsBox = new QGroupBox(tr("SMESH_SEWING"), this);
147 GroupConstructors = new QButtonGroup(this);
148 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
149 ConstructorsBoxLayout->setSpacing(SPACING);
150 ConstructorsBoxLayout->setMargin(MARGIN);
152 RadioButton1 = new QRadioButton(ConstructorsBox);
153 RadioButton1->setIcon(image0);
154 RadioButton2 = new QRadioButton(ConstructorsBox);
155 RadioButton2->setIcon(image1);
156 RadioButton3 = new QRadioButton(ConstructorsBox);
157 RadioButton3->setIcon(image2);
158 RadioButton4 = new QRadioButton(ConstructorsBox);
159 RadioButton4->setIcon(image3);
161 ConstructorsBoxLayout->addWidget(RadioButton1);
162 ConstructorsBoxLayout->addWidget(RadioButton2);
163 ConstructorsBoxLayout->addWidget(RadioButton3);
164 ConstructorsBoxLayout->addWidget(RadioButton4);
165 GroupConstructors->addButton(RadioButton1, 0);
166 GroupConstructors->addButton(RadioButton2, 1);
167 GroupConstructors->addButton(RadioButton3, 2);
168 GroupConstructors->addButton(RadioButton4, 3);
170 /***************************************************************/
171 GroupArguments = new QGroupBox(this);
172 QVBoxLayout* GroupArgumentsLayout = new QVBoxLayout(GroupArguments);
173 GroupArgumentsLayout->setSpacing(SPACING);
174 GroupArgumentsLayout->setMargin(MARGIN);
177 SubGroup1 = new QGroupBox(GroupArguments);
178 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1);
179 SubGroup1Layout->setSpacing(SPACING);
180 SubGroup1Layout->setMargin(MARGIN);
182 // Controls of the first subgroup
183 TextLabel1 = new QLabel(SubGroup1);
184 SelectButton1 = new QPushButton(SubGroup1);
185 SelectButton1->setIcon(image4);
186 LineEdit1 = new QLineEdit(SubGroup1);
188 TextLabel2 = new QLabel(SubGroup1);
189 SelectButton2 = new QPushButton(SubGroup1);
190 SelectButton2->setIcon(image4);
191 LineEdit2 = new QLineEdit(SubGroup1);
193 TextLabel3 = new QLabel(SubGroup1);
194 SelectButton3 = new QPushButton(SubGroup1);
195 SelectButton3->setIcon(image4);
196 LineEdit3 = new QLineEdit(SubGroup1);
198 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
199 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
200 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
201 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
202 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
203 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
204 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
205 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
206 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
209 SubGroup2 = new QGroupBox(GroupArguments);
210 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2);
211 SubGroup2Layout->setSpacing(SPACING);
212 SubGroup2Layout->setMargin(MARGIN);
214 // Controls of the first subgroup
215 TextLabel4 = new QLabel(SubGroup2);
216 SelectButton4 = new QPushButton(SubGroup2);
217 SelectButton4->setIcon(image4);
218 LineEdit4 = new QLineEdit(SubGroup2);
220 TextLabel5 = new QLabel(SubGroup2);
221 SelectButton5 = new QPushButton(SubGroup2);
222 SelectButton5->setIcon(image4);
223 LineEdit5 = new QLineEdit(SubGroup2);
225 TextLabel6 = new QLabel(SubGroup2);
226 SelectButton6 = new QPushButton(SubGroup2);
227 SelectButton6->setIcon(image4);
228 LineEdit6 = new QLineEdit(SubGroup2);
230 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
231 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
232 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
233 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
234 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
235 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
236 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
237 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
238 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
240 // Control for the merging equal elements
241 CheckBoxMerge = new QCheckBox(tr("MERGE_EQUAL_ELEMENTS"), GroupArguments);
243 // Control for the polygons creation instead of splitting
244 CheckBoxPolygons = new QCheckBox(tr("CREATE_POLYGONS_INSTEAD_SPLITTING"), GroupArguments);
246 // Control for the polyedres creation to obtain conform mesh
247 CheckBoxPolyedrs = new QCheckBox(tr("CREATE_POLYEDRS_NEAR_BOUNDARY"), GroupArguments);
249 /***************************************************************/
250 // Controls to switch free borders mode ( auto || manual )
252 ModeGroup = new QGroupBox( tr( "SMESH_MODE" ), GroupArguments );
253 ModeButGrp = new QButtonGroup( ModeGroup );
254 QHBoxLayout* aModeGroupLayout = new QHBoxLayout( ModeGroup );
255 aModeGroupLayout->setMargin( MARGIN );
256 aModeGroupLayout->setSpacing( SPACING );
258 QRadioButton* rb1 = new QRadioButton( tr( "SMESH_AUTOMATIC" ), ModeGroup );
259 QRadioButton* rb2 = new QRadioButton( tr( "SMESH_MANUAL" ), ModeGroup );
260 ModeButGrp->addButton( rb1, MODE_AUTO );
261 ModeButGrp->addButton( rb2, MODE_MANUAL );
262 aModeGroupLayout->addWidget( rb1 );
263 aModeGroupLayout->addWidget( rb2 );
264 rb1->setChecked(true);
266 /***************************************************************/
267 // Controls for detecting coincident free borders
269 SewFreeBordersWidget = new QWidget( GroupArguments );
270 QVBoxLayout* aSewFreeBordersLayout = new QVBoxLayout( SewFreeBordersWidget );
271 aSewFreeBordersLayout->setMargin( 0 );
272 aSewFreeBordersLayout->setSpacing( SPACING );
275 QWidget* TolAndAuto = new QWidget(SewFreeBordersWidget);
276 QLabel* TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), TolAndAuto);
277 SpinBoxTolerance = new SMESHGUI_SpinBox(TolAndAuto);
278 SpinBoxTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
279 SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
280 SpinBoxTolerance->SetValue(0.); // auto-tolerance
283 AutoSewCheck = new QCheckBox(tr("AUTO_SEWING"), TolAndAuto);
284 AutoSewCheck->setChecked( true );
287 QGroupBox* GroupMesh = new QGroupBox(tr("SMESH_MESH"), SewFreeBordersWidget);
288 QHBoxLayout* GroupMeshLayout = new QHBoxLayout(GroupMesh);
289 GroupMeshLayout->setSpacing(SPACING);
290 GroupMeshLayout->setMargin(MARGIN);
292 QLabel* TextLabelName = new QLabel(tr("SMESH_NAME"), GroupMesh);
293 //SelectMeshButton = new QPushButton(GroupMesh);
294 //SelectMeshButton->setIcon(IconSelect);
295 LineEditMesh = new QLineEdit(GroupMesh);
296 LineEditMesh->setReadOnly(true);
298 GroupMeshLayout->addWidget(TextLabelName);
299 //GroupMeshLayout->addWidget(SelectMeshButton);
300 GroupMeshLayout->addWidget(LineEditMesh);
302 QGridLayout* TolAndAutoLayout = new QGridLayout( TolAndAuto );
303 TolAndAutoLayout->setSpacing(SPACING);
304 TolAndAutoLayout->setMargin(0);
305 TolAndAutoLayout->addWidget(GroupMesh, 0, 0, 1, 2 );
306 TolAndAutoLayout->addWidget(TextLabelTolerance, 1, 0 );
307 TolAndAutoLayout->addWidget(SpinBoxTolerance, 1, 1 );
308 TolAndAutoLayout->addWidget(AutoSewCheck, 2, 0 );
310 aSewFreeBordersLayout->addWidget( TolAndAuto );
314 GroupCoincidentWidget = new QWidget(SewFreeBordersWidget);
315 QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincidentWidget);
316 GroupCoincidentLayout->setSpacing(SPACING);
317 GroupCoincidentLayout->setMargin(0);
319 QGroupBox* GroupCoincident = new QGroupBox(tr("COINCIDENT_FREE_BORDERS"), GroupCoincidentWidget);
320 QGridLayout* aCoincidentLayout = new QGridLayout(GroupCoincident);
321 aCoincidentLayout->setSpacing(SPACING);
322 aCoincidentLayout->setMargin(MARGIN);
326 ListCoincident = new QListWidget(GroupCoincident);
327 ListCoincident->setSelectionMode(QListWidget::ExtendedSelection);
329 DetectButton = new QPushButton(tr("DETECT"), GroupCoincident);
330 RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincident);
332 SelectAllCheck = new QCheckBox(tr("SELECT_ALL"), GroupCoincident);
334 aCoincidentLayout->addWidget(ListCoincident, 0, 0, 5, 2);
335 aCoincidentLayout->addWidget(DetectButton, 1, 2);
336 aCoincidentLayout->addWidget(RemoveGroupButton, 3, 2);
337 aCoincidentLayout->addWidget(SelectAllCheck, 5, 0);
338 aCoincidentLayout->setRowMinimumHeight(1, 10);
339 aCoincidentLayout->setRowStretch (4, 5);
340 aCoincidentLayout->setRowStretch (5, 0);
342 /*****************************************/
343 // Controls for editing the selected group
345 QGroupBox* GroupEdit = new QGroupBox(tr("EDIT_SELECTED_GROUP"), GroupCoincidentWidget);
346 QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit);
347 GroupEditLayout->setSpacing(SPACING);
348 GroupEditLayout->setMargin(MARGIN);
350 ListEdit = new QListWidget(GroupEdit);
351 ListEdit->setFlow( QListView::LeftToRight );
352 ListEdit->setSelectionMode(QListWidget::ExtendedSelection);
353 SetFirstButton = new QPushButton(GroupEdit);
354 SetFirstButton->setIcon(QPixmap(SMESHGUI_MergeDlg::IconFirst()));
355 RemoveElemButton = new QPushButton(GroupEdit);
356 RemoveElemButton->setIcon(IconRemove);
358 MoveBorderEndsButGrp = new QButtonGroup( GroupEdit );
359 QToolButton* moveBut1 = new QToolButton( GroupEdit );
360 QToolButton* moveBut2 = new QToolButton( GroupEdit );
361 QToolButton* moveBut3 = new QToolButton( GroupEdit );
362 QToolButton* moveBut4 = new QToolButton( GroupEdit );
363 moveBut1->setArrowType( Qt::LeftArrow );
364 moveBut2->setArrowType( Qt::RightArrow );
365 moveBut3->setArrowType( Qt::LeftArrow );
366 moveBut4->setArrowType( Qt::RightArrow );
367 MoveBorderEndsButGrp->addButton( moveBut1, MOVE_LEFT_1 );
368 MoveBorderEndsButGrp->addButton( moveBut2, MOVE_RIGHT_1 );
369 MoveBorderEndsButGrp->addButton( moveBut3, MOVE_LEFT_2 );
370 MoveBorderEndsButGrp->addButton( moveBut4, MOVE_RIGHT_2 );
372 SwapBut = new QPushButton( "<->", GroupEdit );
373 BorderEndLine[0] = new QLineEdit( GroupEdit );
374 BorderEndLine[1] = new QLineEdit( GroupEdit );
375 BorderEndLine[0]->setReadOnly(true);
376 BorderEndLine[1]->setReadOnly(true);
377 QLabel* StepLabel = new QLabel(tr("STEP"), GroupEdit );
378 StepSpin = new SalomeApp_IntSpinBox( 1, 100000, 1, GroupEdit,
379 /*acceptNames=*/false, /*showTip=*/false );
380 StepSpin->setValue( 1 );
382 GroupEditLayout->addWidget(ListEdit, 0, 0, 1, 8);
383 GroupEditLayout->addWidget(SetFirstButton, 0, 8);
384 GroupEditLayout->addWidget(RemoveElemButton, 0, 9);
385 GroupEditLayout->addWidget(moveBut1, 1, 0);
386 GroupEditLayout->addWidget(BorderEndLine[0], 1, 1);
387 GroupEditLayout->addWidget(moveBut2, 1, 2);
388 GroupEditLayout->addWidget(moveBut3, 1, 3);
389 GroupEditLayout->addWidget(BorderEndLine[1], 1, 4);
390 GroupEditLayout->addWidget(moveBut4, 1, 5);
391 GroupEditLayout->setColumnStretch( 6, 5 );
392 GroupEditLayout->addWidget(SwapBut, 1, 7);
393 GroupEditLayout->addWidget(StepLabel, 1, 8);
394 GroupEditLayout->addWidget(StepSpin, 1, 9);
395 GroupEditLayout->setRowStretch( 0, 1 );
397 GroupCoincidentLayout->addWidget( GroupCoincident );
398 GroupCoincidentLayout->addWidget( GroupEdit );
399 GroupCoincidentLayout->setRowStretch( 0, 10 );
400 GroupCoincidentLayout->setRowStretch( 1, 1 );
402 aSewFreeBordersLayout->addWidget( GroupCoincidentWidget );
405 GroupArgumentsLayout->addWidget(ModeGroup);
406 GroupArgumentsLayout->addWidget(SubGroup1);
407 GroupArgumentsLayout->addWidget(SubGroup2);
408 GroupArgumentsLayout->addWidget(SewFreeBordersWidget);
409 GroupArgumentsLayout->addWidget(CheckBoxMerge);
410 GroupArgumentsLayout->addWidget(CheckBoxPolygons);
411 GroupArgumentsLayout->addWidget(CheckBoxPolyedrs);
413 /***************************************************************/
414 GroupButtons = new QGroupBox(this);
415 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
416 GroupButtonsLayout->setSpacing(SPACING);
417 GroupButtonsLayout->setMargin(MARGIN);
419 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
420 buttonOk->setAutoDefault(true);
421 buttonOk->setDefault(true);
422 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
423 buttonApply->setAutoDefault(true);
424 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
425 buttonCancel->setAutoDefault(true);
426 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
427 buttonHelp->setAutoDefault(true);
429 GroupButtonsLayout->addWidget(buttonOk);
430 GroupButtonsLayout->addSpacing(10);
431 GroupButtonsLayout->addWidget(buttonApply);
432 GroupButtonsLayout->addSpacing(10);
433 GroupButtonsLayout->addStretch();
434 GroupButtonsLayout->addWidget(buttonCancel);
435 GroupButtonsLayout->addWidget(buttonHelp);
437 /***************************************************************/
438 SMESHGUI_SewingDlgLayout->addWidget(ConstructorsBox);
439 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments);
440 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons);
441 //SMESHGUI_SewingDlgLayout->setStretch( 2, 10 );
443 /* Initialisations */
444 RadioButton1->setChecked(true);
446 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, 1));
447 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, 1));
448 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, 1));
449 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, 1));
451 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
453 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
455 myHelpFileName = "sewing_meshes_page.html";
458 myStoredEntityMode = 0;
463 /* signals and slots connections */
464 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
465 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
466 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
467 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
468 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
470 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
471 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
472 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
473 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
474 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
475 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
477 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
478 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
479 /* to close dialog if study change */
480 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
481 connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView()));
482 connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView()));
484 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
485 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
486 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
487 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
488 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
489 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
491 connect(ModeButGrp, SIGNAL(buttonClicked(int)), SLOT(onModeChange(int)));
492 connect(AutoSewCheck, SIGNAL(stateChanged(int)), SLOT(onAutoSew(int)));
493 connect(DetectButton, SIGNAL(clicked()), SLOT(onDetectClicked()));
494 connect(RemoveGroupButton, SIGNAL(clicked()), SLOT(onRemoveGroupClicked()));
495 connect(ListCoincident, SIGNAL(itemSelectionChanged()), SLOT(onSelectGroup()));
496 connect(SelectAllCheck, SIGNAL(stateChanged(int)), SLOT(onSelectAll(int)));
497 connect(ListEdit, SIGNAL(itemSelectionChanged()), SLOT(onSelectBorderPartFromGroup()));
498 connect(SetFirstButton, SIGNAL(clicked()), SLOT(onSetFirstClicked()));
499 connect(RemoveElemButton, SIGNAL(clicked()), SLOT(onRemoveElemClicked()));
500 connect(MoveBorderEndsButGrp, SIGNAL(buttonClicked(int)), SLOT(onMoveBorderEnd(int)));
501 connect(SwapBut, SIGNAL(clicked()), SLOT(onSwapClicked()));
503 ConstructorsClicked(0);
506 //=================================================================================
507 // function : ~SMESHGUI_SewingDlg()
508 // purpose : Destroys the object and frees any allocated resources
509 //=================================================================================
510 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
512 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
514 delete myBorderDisplayers[ i ];
515 myBorderDisplayers[ i ] = 0;
517 myBorderDisplayers.clear();
520 //=================================================================================
523 //=================================================================================
524 void SMESHGUI_SewingDlg::Init()
528 if ( LineEdit1->isVisible() )
529 myEditCurrentArgument = LineEdit1;
531 myEditCurrentArgument = LineEditMesh;
532 myEditCurrentArgument->setFocus();
534 myMesh = SMESH::SMESH_Mesh::_nil();
535 // CheckBoxMerge->setChecked(false);
536 // CheckBoxPolygons->setChecked(false);
537 // CheckBoxPolyedrs->setChecked(false);
538 SelectionIntoArgument();
541 //=================================================================================
542 // function : ConstructorsClicked()
543 // purpose : Radio button management
544 //=================================================================================
545 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
547 disconnect(mySelectionMgr, 0, this, 0);
549 mySelectionMgr->selectedObjects( io );
550 mySelectionMgr->clearSelected();
551 LineEdit1->setText("");
552 LineEdit2->setText("");
553 LineEdit3->setText("");
554 LineEdit4->setText("");
555 LineEdit5->setText("");
556 LineEdit6->setText("");
557 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
558 myEditCurrentArgument = LineEdit1;
559 myEditCurrentArgument->setFocus();
561 if (!TextLabel5->isEnabled()) {
562 TextLabel5->setEnabled(true);
563 SelectButton5->setEnabled(true);
564 LineEdit5->setEnabled(true);
565 } else if (!TextLabel6->isEnabled()) {
566 TextLabel6->setEnabled(true);
567 SelectButton6->setEnabled(true);
568 LineEdit6->setEnabled(true);
571 if (constructorId == 1 || constructorId == 3) {
572 if (CheckBoxPolygons->isVisible())
573 CheckBoxPolygons->hide();
574 if (CheckBoxPolyedrs->isVisible())
575 CheckBoxPolyedrs->hide();
578 CheckBoxMerge->setVisible ( constructorId == 3 );
580 if (( !SubGroup1->isVisible() ) &&
581 ( constructorId != 0 || ModeButGrp->checkedId() == MODE_MANUAL ))
587 if ( constructorId != 0 )
590 SewFreeBordersWidget->hide();
591 restoreDisplayMode();
594 bool isNodeSelection = true;
596 switch (constructorId) {
599 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
600 SubGroup1->setTitle(tr("BORDER_1"));
601 SubGroup2->setTitle(tr("BORDER_2"));
603 if (!CheckBoxPolygons->isVisible())
604 CheckBoxPolygons->show();
605 if (!CheckBoxPolyedrs->isVisible())
606 CheckBoxPolyedrs->show();
608 if ( !ModeGroup->isVisible() )
612 onModeChange( ModeButGrp->checkedId() );
614 isNodeSelection = ( ModeButGrp->checkedId() == MODE_MANUAL );
620 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
621 SubGroup1->setTitle(tr("BORDER_1"));
622 SubGroup2->setTitle(tr("BORDER_2"));
624 TextLabel6->setEnabled(false);
625 SelectButton6->setEnabled(false);
626 LineEdit6->setEnabled(false);
634 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
635 SubGroup1->setTitle(tr("BORDER"));
636 SubGroup2->setTitle(tr("SIDE"));
638 TextLabel5->setEnabled(false);
639 SelectButton5->setEnabled(false);
640 LineEdit5->setEnabled(false);
642 if (!CheckBoxPolygons->isVisible())
643 CheckBoxPolygons->show();
644 if (!CheckBoxPolyedrs->isVisible())
645 CheckBoxPolyedrs->show();
653 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
654 SubGroup1->setTitle(tr("SIDE_1"));
655 SubGroup2->setTitle(tr("SIDE_2"));
657 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
658 TextLabel2->setText(tr("NODE1_TO_MERGE"));
659 TextLabel3->setText(tr("NODE2_TO_MERGE"));
660 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
661 TextLabel5->setText(tr("NODE1_TO_MERGE"));
662 TextLabel6->setText(tr("NODE2_TO_MERGE"));
664 LineEdit1->setValidator(new SMESHGUI_IdValidator(this));
665 LineEdit4->setValidator(new SMESHGUI_IdValidator(this));
667 isNodeSelection = false;
668 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
669 aViewWindow->SetSelectionMode(CellSelection);
674 if (constructorId != 3) {
675 TextLabel1->setText(tr("FIRST_NODE_ID"));
676 TextLabel2->setText(tr("SECOND_NODE_ID"));
677 TextLabel3->setText(tr("LAST_NODE_ID"));
678 TextLabel4->setText(tr("FIRST_NODE_ID"));
679 TextLabel5->setText(tr("SECOND_NODE_ID"));
680 TextLabel6->setText(tr("LAST_NODE_ID"));
682 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, 1));
683 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, 1));
687 myActor->SetPointRepresentation( isNodeSelection );
689 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
690 aViewWindow->SetSelectionMode( isNodeSelection ? NodeSelection : ActorSelection );
694 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
695 mySelectionMgr->setSelectedObjects( io );
697 QApplication::instance()->processEvents();
703 //=======================================================================
704 //function : storeDisplayMode
705 //purpose : save representation of a mesh and switch it to wireframe mode
706 //=======================================================================
708 void SMESHGUI_SewingDlg::setDisplayMode()
710 if ( myStoredEntityMode )
712 myStoredEntityMode = 0;
713 myStoredRepresentation = -1;
715 if ( myActor && AutoSewCheck->isVisible() && !AutoSewCheck->isChecked() )
717 myStoredEntityMode = myActor->GetEntityMode();
718 myStoredRepresentation = myActor->GetRepresentation();
720 myActor->SetEntityMode( myStoredEntityMode & ~SMESH_Actor::eVolumes );
721 myActor->SetRepresentation( SMESH_Actor::eEdge );
725 //=======================================================================
726 //function : restoreDisplayMode
727 //purpose : restore representation of a mesh
728 //=======================================================================
730 void SMESHGUI_SewingDlg::restoreDisplayMode()
732 if ( myActor && myStoredEntityMode )
734 if ( myActor->GetEntityMode() == ( myStoredEntityMode & ~SMESH_Actor::eVolumes ))
735 myActor->SetEntityMode( myStoredEntityMode );
737 if ( myActor->GetRepresentation() == SMESH_Actor::eEdge )
738 myActor->SetRepresentation( myStoredRepresentation );
740 myStoredEntityMode = 0;
741 myStoredRepresentation = -1;
743 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
744 if ( myBorderDisplayers[ i ])
745 myBorderDisplayers[ i ]->Hide();
748 //=======================================================================
749 //function : onModeChange
750 //purpose : SLOT called when mode (auto or manual) of Sew free borders change
751 //=======================================================================
753 void SMESHGUI_SewingDlg::onModeChange( int mode )
755 if ( mode == MODE_MANUAL )
757 myEditCurrentArgument = LineEdit1;
758 if ( !SubGroup1->isVisible() )
759 SubGroup1->show(), SubGroup2->show();
760 SewFreeBordersWidget->hide();
764 myEditCurrentArgument = LineEditMesh;
765 SubGroup1->hide(), SubGroup2->hide();
766 if ( !SewFreeBordersWidget->isVisible() )
767 SewFreeBordersWidget->show();
770 myActor->SetPointRepresentation( mode == MODE_MANUAL );
772 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
773 aViewWindow->SetSelectionMode( mode == MODE_MANUAL ? NodeSelection : ActorSelection );
775 onAutoSew( AutoSewCheck->isChecked() );
777 QApplication::instance()->processEvents();
783 //=======================================================================
784 //function : onAutoSew
785 //purpose : SLOT called when Auto Sewing check box is checked
786 //=======================================================================
788 void SMESHGUI_SewingDlg::onAutoSew( int isAuto )
790 GroupCoincidentWidget->setVisible( !isAuto );
792 QApplication::instance()->processEvents();
794 SewFreeBordersWidget->hide();
795 if ( ModeButGrp->checkedId() == MODE_AUTO )
796 SewFreeBordersWidget->show();
799 restoreDisplayMode();
802 SMESH::RepaintCurrentView();
807 resize(minimumSizeHint());
810 //=======================================================================
811 //function : haveBorders
812 //purpose : Returns true if myBorders have been initialized
813 //=======================================================================
815 bool SMESHGUI_SewingDlg::haveBorders()
817 return ( & myBorders.in() &&
818 myBorders->borders.length() &&
819 myBorders->coincidentGroups.length() );
822 //=======================================================================
823 //function : getGroupText
824 //purpose : Returns a text of a given group of coincident free borders
825 //=======================================================================
827 QString SMESHGUI_SewingDlg::getPartText(const SMESH::FreeBorderPart& aPART)
830 if ( 0 <= aPART.border && aPART.border < myBorders->borders.length() )
832 const SMESH::FreeBorder& aBRD = myBorders->borders[ aPART.border ];
833 if ( 0 <= aPART.node1 && aPART.node1 < aBRD.nodeIDs.length() &&
834 0 <= aPART.nodeLast && aPART.nodeLast < aBRD.nodeIDs.length() )
836 text += QString("( %1 %2 %3 ) ")
837 .arg( aBRD.nodeIDs[ aPART.node1 ] )
838 .arg( aBRD.nodeIDs[ aPART.node2 ] )
839 .arg( aBRD.nodeIDs[ aPART.nodeLast ] );
845 //=======================================================================
846 //function : getGroupText
847 //purpose : Returns a text of a given group of coincident free borders
848 //=======================================================================
850 QString SMESHGUI_SewingDlg::getGroupText(int groupIndex)
854 if ( haveBorders() &&
856 groupIndex < myBorders->coincidentGroups.length() )
858 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ groupIndex ];
860 for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
862 QString partText = getPartText( aGRP[ iP ]);
863 if ( partText.isEmpty() )
871 //=======================================================================
872 //function : onDetectClicked
873 //purpose : SLOT called when [Detect] is clicked
874 //=======================================================================
876 void SMESHGUI_SewingDlg::onDetectClicked()
879 ListCoincident->clear();
881 if ( myMesh->_is_nil() )
884 SUIT_OverrideCursor wc;
886 SMESH::SMESH_MeshEditor_var editor = myMesh->GetMeshEditor();
887 myBorders = editor->FindCoincidentFreeBorders( SpinBoxTolerance->GetValue() );
890 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
892 delete myBorderDisplayers[ i ];
893 myBorderDisplayers[ i ] = 0;
895 myBorderDisplayers.resize( myBorders->coincidentGroups.length(), 0 );
897 for ( uint i = 0; i < myBorders->coincidentGroups.length(); ++i )
899 QString groupText = getGroupText( i );
900 if ( groupText.isEmpty() )
904 groupColor.setHsvF( float(i) / myBorders->coincidentGroups.length(), 1., 1. );
905 QPixmap icon( QSize( 20, 20 ));
906 icon.fill( groupColor );
908 QListWidgetItem * item = new QListWidgetItem( icon, groupText, ListCoincident );
909 item->setData( GROUP_COLOR, groupColor );
910 item->setData( GROUP_INDEX, i );
920 //=======================================================================
921 //function : onRemoveGroupClicked
923 //=======================================================================
925 void SMESHGUI_SewingDlg::onRemoveGroupClicked()
928 QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
929 for ( int i = 0; i < selItems.count(); ++i )
931 QListWidgetItem* item = selItems[ i ];
932 item->setSelected( false );
933 int groupIndex = item->data( GROUP_INDEX ).toInt();
935 if ( myBorderDisplayers[ groupIndex ])
936 myBorderDisplayers[ groupIndex ]->Hide();
937 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
946 //=======================================================================
947 //function : showGroup
948 //purpose : display a group of coincident free borders in the Viewer
949 //=======================================================================
951 void SMESHGUI_SewingDlg::showGroup( QListWidgetItem* item )
954 item->listWidget() != ListCoincident ||
958 int groupIndex = item->data( GROUP_INDEX ).toInt();
959 QColor groupColor = item->data( GROUP_COLOR ).value<QColor>();
960 if ( groupIndex >= 0 &&
961 groupIndex < myBorders->coincidentGroups.length() )
963 if ( !myBorderDisplayers[ groupIndex ] && SMESH::GetCurrentVtkView())
964 myBorderDisplayers[ groupIndex ] = new BorderGroupDisplayer( myBorders, groupIndex, groupColor, myMesh );
965 bool wholeBorders = setCurrentGroup();
966 if ( myBorderDisplayers[ groupIndex ])
967 myBorderDisplayers[ groupIndex ]->ShowGroup( wholeBorders );
971 //=======================================================================
972 //function : setCurrentGroup
973 //purpose : set index of a current free border group to myCurGroupIndex
974 //=======================================================================
976 bool SMESHGUI_SewingDlg::setCurrentGroup()
978 if ( !haveBorders() )
981 QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
982 if ( selItems.count() != 1 )
985 myCurGroupIndex = selItems[0]->data( GROUP_INDEX ).toInt();
987 return ( myCurGroupIndex >= 0 && myCurGroupIndex < myBorders->coincidentGroups.length() );
990 //=======================================================================
991 //function : setCurrentPart
992 //purpose : set index of a current free border of a current group to myCurPartIndex
993 //=======================================================================
995 bool SMESHGUI_SewingDlg::setCurrentPart()
997 if ( !setCurrentGroup() )
1000 if ( ListEdit->selectedItems().count() != 1 )
1003 myCurPartIndex = ListEdit->currentRow();
1004 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1006 return ( myCurPartIndex >= 0 && myCurPartIndex < aGRP.length() );
1009 //=======================================================================
1010 //function : onSelectGroup
1011 //purpose : SLOT called when selection of coincident free borders change
1012 //=======================================================================
1014 void SMESHGUI_SewingDlg::onSelectGroup()
1019 BorderEndLine[0]->clear();
1020 BorderEndLine[1]->clear();
1021 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
1022 if ( myBorderDisplayers[ i ])
1023 myBorderDisplayers[ i ]->Hide();
1025 QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
1027 RemoveGroupButton->setEnabled( selItems.count() > 0 );
1029 onSelectBorderPartFromGroup(); // enable buttons
1031 if ( !haveBorders() )
1034 SelectAllCheck->blockSignals( true );
1035 if ( ListCoincident->count() != selItems.count() )
1036 SelectAllCheck->setChecked( false );
1037 SelectAllCheck->blockSignals( false );
1039 if ( selItems.empty() ) // nothing selected - show all
1040 for ( int i = 0; i < ListCoincident->count(); ++i )
1041 showGroup( ListCoincident->item( i ));
1043 for ( int i = 0; i < selItems.count(); ++i )
1044 showGroup( selItems[ i ]);
1046 if ( setCurrentGroup() ) // edit a selected group
1048 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1049 for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
1050 new QListWidgetItem( getPartText( aGRP[ iP ]), ListEdit );
1052 SMESH::RepaintCurrentView();
1055 //=======================================================================
1056 //function : onSelectAll
1057 //purpose : SLOT called when Select All is checked
1058 //=======================================================================
1060 void SMESHGUI_SewingDlg::onSelectAll(int isOn)
1063 ListCoincident->selectAll();
1065 ListCoincident->clearSelection();
1068 //=======================================================================
1069 //function : onSelectBorderPartFromGroup
1070 //purpose : SLOT called when selection of borders in an edited group changes
1071 //=======================================================================
1073 void SMESHGUI_SewingDlg::onSelectBorderPartFromGroup()
1075 if ( myBusy ) return;
1076 BorderEndLine[0]->setText("");
1077 BorderEndLine[1]->setText("");
1078 MoveBorderEndsButGrp->button( MOVE_LEFT_1 )->setEnabled( false );
1079 MoveBorderEndsButGrp->button( MOVE_RIGHT_1 )->setEnabled( false );
1080 MoveBorderEndsButGrp->button( MOVE_LEFT_2 )->setEnabled( false );
1081 MoveBorderEndsButGrp->button( MOVE_RIGHT_2 )->setEnabled( false );
1082 SwapBut->setEnabled( false );
1083 SetFirstButton->setEnabled( false );
1084 RemoveElemButton->setEnabled ( ListEdit->count() > 2 );
1086 if ( !setCurrentGroup() )
1089 if ( !myBorderDisplayers[ myCurGroupIndex ]) return;
1090 myBorderDisplayers[ myCurGroupIndex ]->Hide();
1092 QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
1093 bool editPart = ( setCurrentPart() );
1094 for ( int i = 0; i < selItems.count(); ++i )
1095 myBorderDisplayers[ myCurGroupIndex ]->ShowPart( ListEdit->row( selItems[i] ), editPart );
1097 if ( selItems.isEmpty() )
1098 myBorderDisplayers[ myCurGroupIndex ]->ShowGroup( /*wholeBorders=*/ true );
1102 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1103 SMESH::FreeBorderPart& aPRT = aGRP[ myCurPartIndex ];
1104 SMESH::FreeBorder& aBRD = myBorders->borders[ aPRT.border ];
1106 BorderEndLine[0]->setText( QString::number( aBRD.nodeIDs[ aPRT.node1 ]));
1107 BorderEndLine[1]->setText( QString::number( aBRD.nodeIDs[ aPRT.nodeLast ]));
1108 SwapBut->setEnabled( true );
1109 SetFirstButton->setEnabled( myCurPartIndex > 0 );
1111 int size = (int) aBRD.nodeIDs.length();
1112 bool isClosed = ( aBRD.nodeIDs[0] == aBRD.nodeIDs[ size-1 ]);
1115 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1116 int dn = ( isFwd ? +1 : -1 ) * StepSpin->value();
1117 MoveBorderEndsButGrp->button( MOVE_LEFT_1 )->
1118 setEnabled( 0 <= aPRT.node1-dn && aPRT.node1-dn < size );
1119 MoveBorderEndsButGrp->button( MOVE_RIGHT_1 )->
1120 setEnabled( 0 <= aPRT.node1+dn && aPRT.node1+dn < size );
1121 MoveBorderEndsButGrp->button( MOVE_LEFT_2 )->
1122 setEnabled( 0 <= aPRT.nodeLast-dn && aPRT.nodeLast-dn < size );
1123 MoveBorderEndsButGrp->button( MOVE_RIGHT_2 )->
1124 setEnabled( 0 <= aPRT.nodeLast+dn && aPRT.nodeLast+dn < size );
1128 MoveBorderEndsButGrp->button( MOVE_LEFT_1 )->setEnabled( true );
1129 MoveBorderEndsButGrp->button( MOVE_RIGHT_1 )->setEnabled( true );
1130 MoveBorderEndsButGrp->button( MOVE_LEFT_2 )->setEnabled( true );
1131 MoveBorderEndsButGrp->button( MOVE_RIGHT_2 )->setEnabled( true );
1134 SMESH::RepaintCurrentView();
1137 //=======================================================================
1138 //function : onGroupChange
1139 //purpose : Update after modification of a current group by the user
1140 //=======================================================================
1142 void SMESHGUI_SewingDlg::onGroupChange( bool partChange )
1144 ListCoincident->currentItem()->setText( getGroupText( myCurGroupIndex ));
1146 const SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1147 for ( int i = 0; i < ListEdit->count(); ++i )
1148 ListEdit->item( i )->setText( getPartText( aGRP[ i ]));
1150 if ( myBorderDisplayers[ myCurGroupIndex ])
1151 myBorderDisplayers[ myCurGroupIndex ]->Update();
1154 onSelectBorderPartFromGroup();
1157 //=======================================================================
1158 //function : onSetFirstClicked
1159 //purpose : STOL called when |<< is clicked
1160 //=======================================================================
1162 void SMESHGUI_SewingDlg::onSetFirstClicked()
1164 if ( !setCurrentPart() || myCurPartIndex == 0 || ListEdit->count() == 0 )
1167 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1169 SMESH::FreeBorderPart new1st = aGRP[ myCurPartIndex ];
1170 for ( ; myCurPartIndex > 0; --myCurPartIndex )
1171 aGRP[ myCurPartIndex ] = aGRP[ myCurPartIndex - 1 ];
1178 ListEdit->clearSelection();
1180 ListEdit->setCurrentItem( ListEdit->item(0) );//ListEdit->item(0)->setSelected(true);
1183 //=======================================================================
1184 //function : onRemoveElemClicked
1186 //=======================================================================
1188 void SMESHGUI_SewingDlg::onRemoveElemClicked()
1190 if ( !setCurrentGroup() )
1193 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1195 QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
1196 for ( int i = 0; i < selItems.count(); ++i )
1198 int part = ListEdit->row( selItems[i] );
1199 for ( ; part + 1 < aGRP.length(); ++part )
1200 aGRP[ part ] = aGRP[ part + 1 ];
1201 aGRP.length( aGRP.length() - 1 );
1205 if ( aGRP.length() == 0 )
1206 onRemoveGroupClicked();
1208 onGroupChange( /*partChange=*/true );
1211 //=======================================================================
1212 //function : onMoveBorderEnd
1214 //=======================================================================
1216 void SMESHGUI_SewingDlg::onMoveBorderEnd(int button)
1218 if ( !setCurrentPart() )
1221 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1222 SMESH::FreeBorderPart& aPRT = aGRP[ myCurPartIndex ];
1223 SMESH::FreeBorder& aBRD = myBorders->borders[ aPRT.border ];
1224 int size = (int) aBRD.nodeIDs.length();
1226 bool isClosed = ( aBRD.nodeIDs[0] == aBRD.nodeIDs[ size-1 ]);
1227 if ( isClosed ) --size;
1229 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1230 int dn = ( isFwd ? +1 : -1 ) * StepSpin->value();
1231 if ( button == MOVE_LEFT_1 || button == MOVE_LEFT_2 )
1238 ( 0 <= aPRT.node1+dn && aPRT.node1+dn < size ))
1240 aPRT.node1 = ( aPRT.node1 + size + dn ) % size;
1241 aPRT.node2 = ( aPRT.node2 + size + dn ) % size;
1247 ( 0 <= aPRT.nodeLast+dn && aPRT.nodeLast+dn < size ))
1249 aPRT.nodeLast = ( aPRT.nodeLast + size + dn ) % size;
1253 return; // impossible to move
1256 onGroupChange( /*partChange=*/true );
1259 //=======================================================================
1260 //function : onSwapClicked
1261 //purpose : SLOT called when <-> is clicked
1262 //=======================================================================
1264 void SMESHGUI_SewingDlg::onSwapClicked()
1266 if ( !setCurrentPart() )
1269 SMESH::FreeBordersGroup& aGRP = myBorders->coincidentGroups[ myCurGroupIndex ];
1270 SMESH::FreeBorderPart& aPRT = aGRP[ myCurPartIndex ];
1271 SMESH::FreeBorder& aBRD = myBorders->borders[ aPRT.border ];
1272 int size = (int) aBRD.nodeIDs.length();
1274 bool isClosed = ( aBRD.nodeIDs[0] == aBRD.nodeIDs[ size-1 ]);
1275 if ( isClosed ) --size;
1277 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1279 std::swap( aPRT.nodeLast, aPRT.node1 );
1281 aPRT.node2 = ( aPRT.node1 + ( isFwd ? -1 : +1 ) + size ) % size;
1283 onGroupChange( /*partChange=*/true );
1286 //=================================================================================
1287 // function : ClickOnApply()
1289 //=================================================================================
1290 bool SMESHGUI_SewingDlg::ClickOnApply()
1292 if (mySMESHGUI->isActiveStudyLocked())
1295 bool aResult = false;
1299 bool toMerge = CheckBoxMerge->isChecked();
1300 bool toCreatePolygons = CheckBoxPolygons->isChecked();
1301 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
1303 SUIT_OverrideCursor aWaitCursor;
1304 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
1306 int aConstructorId = GetConstructorId();
1307 SMESH::SMESH_MeshEditor::Sew_Error anError;
1309 if (aConstructorId == 0)
1311 if ( ModeButGrp->checkedId() == MODE_MANUAL )
1313 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
1314 LineEdit2->text().toLong(),
1315 LineEdit3->text().toLong(),
1316 LineEdit4->text().toLong(),
1317 LineEdit5->text().toLong(),
1318 LineEdit6->text().toLong(),
1324 int nbCoincGroups = ListCoincident->count();
1325 if ( AutoSewCheck->isChecked() )
1327 myBorders = aMeshEditor->FindCoincidentFreeBorders( SpinBoxTolerance->GetValue() );
1328 nbCoincGroups = myBorders->coincidentGroups.length();
1330 CORBA::Short nbSewed = aMeshEditor->SewCoincidentFreeBorders( myBorders.inout(),
1334 if ( nbCoincGroups == 0 )
1335 msg = tr("NO_BORDERS_TO_SEW");
1336 else if ( nbSewed < nbCoincGroups )
1337 msg = tr("NOT_ALL_BORDERS_SEWED").arg( nbSewed ).arg( nbCoincGroups );
1339 msg = tr("ALL_BORDERS_SEWED").arg( nbSewed );
1340 SUIT_MessageBox::information( this, tr("SMESH_INFORMATION"), msg );
1342 anError = SMESH::SMESH_MeshEditor::SEW_OK;
1345 else if (aConstructorId == 1)
1347 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
1348 LineEdit2->text().toLong(),
1349 LineEdit3->text().toLong(),
1350 LineEdit4->text().toLong(),
1351 LineEdit5->text().toLong());
1353 else if (aConstructorId == 2)
1355 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
1356 LineEdit2->text().toLong(),
1357 LineEdit3->text().toLong(),
1358 LineEdit4->text().toLong(),
1359 LineEdit6->text().toLong(),
1363 else if (aConstructorId == 3) {
1364 QStringList aListElementsId1 = LineEdit1->text().split(" ", QString::SkipEmptyParts);
1365 QStringList aListElementsId2 = LineEdit4->text().split(" ", QString::SkipEmptyParts);
1367 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
1368 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
1370 anElementsId1->length(aListElementsId1.count());
1371 anElementsId2->length(aListElementsId2.count());
1373 for (int i = 0; i < aListElementsId1.count(); i++)
1374 anElementsId1[i] = aListElementsId1[i].toInt();
1375 for (int i = 0; i < aListElementsId2.count(); i++)
1376 anElementsId2[i] = aListElementsId2[i].toInt();
1378 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
1379 anElementsId2.inout(),
1380 LineEdit2->text().toLong(),
1381 LineEdit5->text().toLong(),
1382 LineEdit3->text().toLong(),
1383 LineEdit6->text().toLong());
1385 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
1387 if (toMerge && aResult)
1388 aMeshEditor->MergeEqualElements();
1391 QString msg = tr(QString("ERROR_%1").arg(anError).toLatin1().data());
1392 SUIT_MessageBox::warning(this, tr("SMESH_WRN_WARNING"), msg);
1395 catch ( const SALOME::SALOME_Exception& S_ex )
1397 SalomeApp_Tools::QtCatchCorbaException( S_ex );
1405 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
1406 SALOME_ListIO aList;
1408 mySelectionMgr->setSelectedObjects(aList, false);
1409 SMESH::UpdateView();
1412 ConstructorsClicked(GetConstructorId());
1414 SMESHGUI::Modified();
1421 //=================================================================================
1422 // function : ClickOnOk()
1424 //=================================================================================
1425 void SMESHGUI_SewingDlg::ClickOnOk()
1431 //=================================================================================
1432 // function : onOpenView()
1434 //=================================================================================
1435 void SMESHGUI_SewingDlg::onOpenView()
1438 SMESH::SetPointRepresentation(false);
1441 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
1442 ActivateThisDialog();
1446 //=================================================================================
1447 // function : onCloseView()
1449 //=================================================================================
1450 void SMESHGUI_SewingDlg::onCloseView()
1452 DeactivateActiveDialog();
1456 for ( size_t i = 0; i < myBorderDisplayers.size(); ++i )
1458 delete myBorderDisplayers[ i ];
1459 myBorderDisplayers[ i ] = 0;
1461 myBorderDisplayers.clear();
1464 //=================================================================================
1465 // function : reject()
1467 //=================================================================================
1468 void SMESHGUI_SewingDlg::reject()
1470 restoreDisplayMode();
1471 //mySelectionMgr->clearSelected();
1472 SMESH::SetPointRepresentation(false);
1473 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1474 aViewWindow->SetSelectionMode(ActorSelection);
1475 disconnect(mySelectionMgr, 0, this, 0);
1476 mySMESHGUI->ResetState();
1480 //=================================================================================
1481 // function : ClickOnHelp()
1483 //=================================================================================
1484 void SMESHGUI_SewingDlg::ClickOnHelp()
1486 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1488 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1492 platform = "winapplication";
1494 platform = "application";
1496 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
1497 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1498 arg(app->resourceMgr()->stringValue("ExternalBrowser",
1500 arg(myHelpFileName));
1504 //=======================================================================
1505 //function : onTextChange
1507 //=======================================================================
1508 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
1510 QLineEdit* send = (QLineEdit*)sender();
1516 myEditCurrentArgument = send;
1518 if (send == LineEdit1)
1520 else if (send == LineEdit2)
1522 else if (send == LineEdit3)
1524 else if (send == LineEdit4)
1526 else if (send == LineEdit5)
1528 else if (send == LineEdit6)
1531 // hilight entered elements/nodes
1532 SMDS_Mesh* aMesh = 0;
1535 aMesh = myActor->GetObject()->GetMesh();
1540 TColStd_MapOfInteger newIndices;
1542 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
1543 SMESH::SetPointRepresentation(true);
1545 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1546 aViewWindow->SetSelectionMode(NodeSelection);
1548 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
1550 newIndices.Add(n->GetID());
1551 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
1552 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1553 aViewWindow->highlight( myActor->getIO(), true, true );
1555 if (send == LineEdit1)
1557 else if (send == LineEdit2)
1559 else if (send == LineEdit3)
1561 else if (send == LineEdit4)
1563 else if (send == LineEdit5)
1565 else if (send == LineEdit6)
1569 SMESH::SetPointRepresentation(false);
1571 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1572 aViewWindow->SetSelectionMode(CellSelection);
1574 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
1576 bool isEvenOneExists = false;
1578 for (int i = 0; i < aListId.count(); i++) {
1579 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
1581 newIndices.Add(e->GetID());
1583 if (!isEvenOneExists)
1584 isEvenOneExists = true;
1587 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
1588 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1589 aViewWindow->highlight( myActor->getIO(), true, true );
1591 if (isEvenOneExists) {
1592 if (send == LineEdit1)
1594 else if(send == LineEdit4)
1607 //=================================================================================
1608 // function : SelectionIntoArgument()
1609 // purpose : Called when selection as changed or other case
1610 //=================================================================================
1611 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
1616 restoreDisplayMode();
1617 if (isSelectionChanged)
1620 QString aString = "";
1623 myEditCurrentArgument->setText(aString);
1624 ListCoincident->clear();
1628 onSelectGroup(); // erase preview
1630 if (!GroupButtons->isEnabled()) // inactive
1633 buttonOk->setEnabled(false);
1634 buttonApply->setEnabled(false);
1635 DetectButton->setEnabled(false);
1637 // get selected mesh
1638 SALOME_ListIO aList;
1639 mySelectionMgr->selectedObjects(aList);
1641 int nbSel = aList.Extent();
1645 Handle(SALOME_InteractiveObject) IO = aList.First();
1646 myMesh = SMESH::GetMeshByIO(IO);
1647 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
1648 if (myMesh->_is_nil())
1651 CheckBoxPolyedrs->setEnabled( myMesh->NbVolumes() > 0 );
1653 if ( myEditCurrentArgument == LineEditMesh )
1655 if ( _PTR(SObject) meshSO = SMESH::FindSObject( myMesh ))
1656 LineEditMesh->setText( meshSO->GetName().c_str() );
1657 ListCoincident->clear();
1658 if ( AutoSewCheck->isChecked() )
1660 buttonOk->setEnabled(true);
1661 buttonApply->setEnabled(true);
1663 DetectButton->setEnabled( myMesh->NbFaces() > 0 );
1671 // get selected elements/nodes
1673 if (( GetConstructorId() != 3 ) ||
1674 ( myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4))
1676 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
1681 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
1687 myEditCurrentArgument->setText(aString);
1691 if (myEditCurrentArgument == LineEdit1)
1693 else if (myEditCurrentArgument == LineEdit2)
1695 else if (myEditCurrentArgument == LineEdit3)
1697 else if (myEditCurrentArgument == LineEdit4)
1699 else if (myEditCurrentArgument == LineEdit5)
1701 else if (myEditCurrentArgument == LineEdit6)
1707 //=================================================================================
1708 // function : SetEditCurrentArgument()
1710 //=================================================================================
1711 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
1713 QPushButton* send = (QPushButton*)sender();
1715 disconnect(mySelectionMgr, 0, this, 0);
1716 mySelectionMgr->clearSelected();
1718 if (send == SelectButton1) {
1719 myEditCurrentArgument = LineEdit1;
1722 else if (send == SelectButton2) {
1723 myEditCurrentArgument = LineEdit2;
1726 else if (send == SelectButton3) {
1727 myEditCurrentArgument = LineEdit3;
1730 else if (send == SelectButton4) {
1731 myEditCurrentArgument = LineEdit4;
1734 else if (send == SelectButton5) {
1735 myEditCurrentArgument = LineEdit5;
1738 else if (send == SelectButton6) {
1739 myEditCurrentArgument = LineEdit6;
1743 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
1744 SMESH::SetPointRepresentation(true);
1746 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1747 aViewWindow->SetSelectionMode(NodeSelection);
1750 SMESH::SetPointRepresentation(false);
1751 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1752 aViewWindow->SetSelectionMode(CellSelection);
1755 myEditCurrentArgument->setFocus();
1756 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
1757 SelectionIntoArgument(false);
1760 //=================================================================================
1761 // function : DeactivateActiveDialog()
1763 //=================================================================================
1764 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
1766 if (ConstructorsBox->isEnabled()) {
1767 ConstructorsBox->setEnabled(false);
1768 GroupArguments->setEnabled(false);
1769 GroupButtons->setEnabled(false);
1770 mySMESHGUI->ResetState();
1771 mySMESHGUI->SetActiveDialogBox(0);
1775 //=================================================================================
1776 // function : ActivateThisDialog()
1778 //=================================================================================
1779 void SMESHGUI_SewingDlg::ActivateThisDialog()
1781 /* Emit a signal to deactivate the active dialog */
1782 mySMESHGUI->EmitSignalDeactivateDialog();
1783 ConstructorsBox->setEnabled(true);
1784 GroupArguments->setEnabled(true);
1785 GroupButtons->setEnabled(true);
1787 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1789 ConstructorsClicked(GetConstructorId());
1790 SelectionIntoArgument();
1793 //=================================================================================
1794 // function : enterEvent()
1796 //=================================================================================
1797 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
1799 if (!ConstructorsBox->isEnabled()) {
1800 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
1801 if ( aViewWindow && !mySelector) {
1802 mySelector = aViewWindow->GetSelector();
1804 ActivateThisDialog();
1808 //=================================================================================
1809 // function : GetConstructorId()
1811 //=================================================================================
1812 int SMESHGUI_SewingDlg::GetConstructorId()
1814 return GroupConstructors->checkedId();
1817 //=================================================================================
1818 // function : GetConstructorId()
1820 //=================================================================================
1821 bool SMESHGUI_SewingDlg::IsValid()
1823 if ( myMesh->_is_nil() )
1826 if ( GetConstructorId() == 0 && ModeButGrp->checkedId() == MODE_AUTO )
1828 if ( AutoSewCheck->isChecked() )
1832 if ( haveBorders() )
1833 for ( int i = 0; i < ListCoincident->count(); ++i )
1835 int groupIndex = ListCoincident->item(i)->data( GROUP_INDEX ).toInt();
1836 nbGroups += ( !getGroupText( groupIndex ).isEmpty() );
1838 return nbGroups > 0;
1840 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);
1843 //=======================================================================
1844 //function : UpdateButtons
1845 //purpose : activate [Apply] buttons
1846 //=======================================================================
1848 void SMESHGUI_SewingDlg::UpdateButtons()
1850 bool ok = IsValid();
1851 buttonOk->setEnabled( ok );
1852 buttonApply->setEnabled( ok );
1855 //=================================================================================
1856 // function : keyPressEvent()
1858 //=================================================================================
1859 void SMESHGUI_SewingDlg::keyPressEvent( QKeyEvent* e )
1861 QDialog::keyPressEvent( e );
1862 if ( e->isAccepted() )
1865 if ( e->key() == Qt::Key_F1 ) {
1871 SMESHGUI_SewingDlg::
1872 BorderGroupDisplayer::BorderGroupDisplayer( const SMESH::CoincidentFreeBorders& borders,
1875 SMESH::SMESH_Mesh_ptr mesh):
1876 myBorders ( borders.borders ),
1877 myGroup ( borders.coincidentGroups[ groupIndex ]),
1880 myViewWindow( SMESH::GetCurrentVtkView() ),
1881 myIdPreview ( myViewWindow )
1886 SMESHGUI_SewingDlg::BorderGroupDisplayer::~BorderGroupDisplayer()
1888 for ( size_t i = 0; i < myPartActors.size(); ++i )
1890 if ( myPartActors[ i ]) {
1891 myViewWindow->RemoveActor( myPartActors[i] );
1892 myPartActors[i]->Delete();
1895 myIdPreview.SetPointsLabeled(false);
1898 void SMESHGUI_SewingDlg::BorderGroupDisplayer::Hide()
1900 for ( size_t i = 0; i < myPartActors.size(); ++i )
1901 if ( myPartActors[ i ])
1902 myPartActors[ i ]->SetVisibility(false);
1904 myIdPreview.SetPointsLabeled(false);
1907 void SMESHGUI_SewingDlg::BorderGroupDisplayer::ShowGroup( bool wholeBorders )
1909 std::vector<int> ids;
1910 std::list<gp_XYZ> coords;
1911 for ( size_t i = 0; i < myPartActors.size(); ++i )
1912 if ( myPartActors[ i ])
1914 myPartActors[ i ]->SetPointRepresentation( wholeBorders );
1915 myPartActors[ i ]->SetVisibility( true );
1917 getPartEnds( i, ids, coords );
1920 myIdPreview.SetElemsData( ids, coords );
1921 myIdPreview.SetPointsLabeled( wholeBorders, true );
1924 void SMESHGUI_SewingDlg::BorderGroupDisplayer::ShowPart( int partIndex, bool toEdit )
1926 if ( partIndex < (int) myPartActors.size() )
1928 myPartActors[partIndex]->SetVisibility(true);
1929 myPartActors[partIndex]->SetPointRepresentation(toEdit);
1933 std::vector<int> ids;
1934 std::list<gp_XYZ> coords;
1935 getPartEnds( partIndex, ids, coords );
1937 myIdPreview.SetElemsData( ids, coords );
1938 myIdPreview.SetPointsLabeled( true, /*show=*/true );
1943 void SMESHGUI_SewingDlg::BorderGroupDisplayer::getPartEnds( int partIndex,
1944 std::vector<int> & ids,
1945 std::list<gp_XYZ>& coords)
1947 const SMESH::FreeBorderPart& aPART = myGroup [ partIndex ];
1948 const SMESH::FreeBorder& aBRD = myBorders[ aPART.border ];
1950 ids.push_back( aBRD.nodeIDs[ aPART.node1 ]);
1951 ids.push_back( aBRD.nodeIDs[ aPART.nodeLast ]);
1953 SMDS_Mesh* mesh = myPartActors[ partIndex ]->GetObject()->GetMesh();
1955 coords.push_back( SMESH_TNodeXYZ( mesh->FindNode( aPART.node1+1 )));
1956 coords.push_back( SMESH_TNodeXYZ( mesh->FindNode( aPART.nodeLast+1 )));
1959 void SMESHGUI_SewingDlg::BorderGroupDisplayer::Update()
1962 myPartActors.resize( myGroup.length(), 0 );
1964 for ( size_t i = 0; i < myPartActors.size(); ++i )
1967 if ( myPartActors[ i ])
1968 obj = myPartActors[ i ]->GetObject();
1970 obj = TVisualObjPtr( new SMESHGUI_PreVisualObj() );
1971 SMDS_Mesh* mesh = obj->GetMesh();
1975 const SMESH::FreeBorderPart& aPRT = myGroup[ i ];
1976 const SMESH::FreeBorder& aBRD = myBorders[ aPRT.border ];
1977 for ( CORBA::ULong iN = 0; iN < aBRD.nodeIDs.length(); ++iN )
1979 SMESH::double_array_var xyz = myMesh->GetNodeXYZ( aBRD.nodeIDs[ iN ]);
1980 if ( xyz->length() == 3 )
1981 mesh->AddNode( xyz[0], xyz[1], xyz[2] );
1985 bool isFwd = ( Abs( aPRT.node2 - aPRT.node1 ) == 1 ) ? aPRT.node2 > aPRT.node1 : aPRT.node2 < aPRT.node1;
1986 int dn = isFwd ? +1 : -1;
1987 int size = (int) aBRD.nodeIDs.length();
1988 int n2, n1 = aPRT.node1;
1989 for ( n2 = n1 + dn; ( n2 >= 0 && n2 < size ); n2 += dn )
1991 mesh->AddEdgeWithID( n1+1, n2+1, mesh->NbEdges() + 1 );
1993 if ( n2 == aPRT.nodeLast )
1996 if ( n2 % size != aPRT.nodeLast )
1998 if ( n2 < 0 ) n1 = size;
2000 for ( n2 = n1 + dn; ( n2 >= 0 && n2 < size ); n2 += dn )
2002 mesh->AddEdgeWithID( n1+1, n2+1, mesh->NbEdges() + 1 );
2004 if ( n2 == aPRT.nodeLast )
2009 if ( !myPartActors[ i ]) // TVisualObj must be filled before actor creation
2011 myPartActors[ i ] = SMESH_Actor::New( obj, "", "", 1 );
2012 myPartActors[ i ]->SetEdgeColor( myColor.redF(), myColor.greenF(), myColor.blueF() );
2013 myPartActors[ i ]->SetLineWidth( 3 * SMESH::GetFloat("SMESH:element_width",1));
2014 myPartActors[ i ]->SetNodeColor( myColor.redF(), myColor.greenF(), myColor.blueF() );
2015 myPartActors[ i ]->SetMarkerStd( VTK::MT_POINT, 13 );
2016 myPartActors[ i ]->SetPickable ( false );
2017 myViewWindow->AddActor( myPartActors[ i ]);