1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESHGUI_SewingDlg.cxx
25 // Author : Michael ZORIN
29 #include "SMESHGUI_SewingDlg.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_IdValidator.h"
36 #include "SMESH_Actor.h"
37 #include "SMDS_Mesh.hxx"
39 #include "SUIT_Session.h"
40 #include "SUIT_ResourceMgr.h"
41 #include "SUIT_Desktop.h"
42 #include "SUIT_MessageBox.h"
44 #include "LightApp_Application.h"
46 #include "SVTK_ViewModel.h"
47 #include "SVTK_ViewWindow.h"
48 #include "SVTK_Selector.h"
49 #include "SVTK_Selection.h"
50 #include "SALOME_ListIO.hxx"
52 #include "utilities.h"
55 #include <TColStd_MapOfInteger.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
59 #include <qapplication.h>
60 #include <qbuttongroup.h>
61 #include <qgroupbox.h>
63 #include <qlineedit.h>
64 #include <qpushbutton.h>
65 #include <qradiobutton.h>
66 #include <qcheckbox.h>
72 //=================================================================================
73 // class : SMESHGUI_SewingDlg()
75 //=================================================================================
76 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule, const char* name,
77 bool modal, WFlags fl)
78 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
79 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
80 mySMESHGUI( theModule ),
81 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
83 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
84 QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS")));
85 QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS")));
86 QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE")));
87 QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS")));
88 QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
91 setName("SMESHGUI_SewingDlg");
93 setCaption(tr("SMESH_SEWING"));
94 setSizeGripEnabled(TRUE);
95 SMESHGUI_SewingDlgLayout = new QGridLayout(this);
96 SMESHGUI_SewingDlgLayout->setSpacing(6);
97 SMESHGUI_SewingDlgLayout->setMargin(11);
99 /***************************************************************/
100 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
101 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
102 (QSizePolicy::SizeType)0, 0, 0,
103 GroupConstructors->sizePolicy().hasHeightForWidth()));
104 GroupConstructors->setTitle(tr("SMESH_SEWING"));
105 GroupConstructors->setExclusive(TRUE);
106 GroupConstructors->setColumnLayout(0, Qt::Vertical);
107 GroupConstructors->layout()->setSpacing(0);
108 GroupConstructors->layout()->setMargin(0);
109 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
110 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
111 GroupConstructorsLayout->setSpacing(6);
112 GroupConstructorsLayout->setMargin(11);
113 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
114 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
115 RadioButton1->setText(tr("" ));
116 RadioButton1->setPixmap(image0);
117 RBLayout->addWidget(RadioButton1);
118 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
119 RadioButton2->setText(tr("" ));
120 RadioButton2->setPixmap(image1);
121 RBLayout->addWidget(RadioButton2);
122 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
123 RadioButton3->setText(tr("" ));
124 RadioButton3->setPixmap(image2);
125 RBLayout->addWidget(RadioButton3);
126 RadioButton4= new QRadioButton(GroupConstructors, "RadioButton4");
127 RadioButton4->setText(tr("" ));
128 RadioButton4->setPixmap(image3);
129 RBLayout->addWidget(RadioButton4);
130 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
131 SMESHGUI_SewingDlgLayout->addWidget(GroupConstructors, 0, 0);
133 /***************************************************************/
134 GroupButtons = new QGroupBox(this, "GroupButtons");
135 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
136 (QSizePolicy::SizeType)0, 0, 0,
137 GroupButtons->sizePolicy().hasHeightForWidth()));
138 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
139 GroupButtons->setTitle(tr("" ));
140 GroupButtons->setColumnLayout(0, Qt::Vertical);
141 GroupButtons->layout()->setSpacing(0);
142 GroupButtons->layout()->setMargin(0);
143 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
144 GroupButtonsLayout->setAlignment(Qt::AlignTop);
145 GroupButtonsLayout->setSpacing(6);
146 GroupButtonsLayout->setMargin(11);
147 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
148 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
149 buttonHelp->setAutoDefault(TRUE);
150 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
151 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
152 buttonCancel->setText(tr("SMESH_BUT_CLOSE"));
153 buttonCancel->setAutoDefault(TRUE);
154 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
155 buttonApply = new QPushButton(GroupButtons, "buttonApply");
156 buttonApply->setText(tr("SMESH_BUT_APPLY"));
157 buttonApply->setAutoDefault(TRUE);
158 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
159 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
160 GroupButtonsLayout->addItem(spacer_9, 0, 2);
161 buttonOk = new QPushButton(GroupButtons, "buttonOk");
162 buttonOk->setText(tr("SMESH_BUT_OK"));
163 buttonOk->setAutoDefault(TRUE);
164 buttonOk->setDefault(TRUE);
165 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
166 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons, 2, 0);
168 /***************************************************************/
169 GroupArguments = new QGroupBox(this, "GroupArguments");
170 GroupArguments->setColumnLayout(0, Qt::Vertical);
171 GroupArguments->layout()->setSpacing(0);
172 GroupArguments->layout()->setMargin(0);
173 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
174 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
175 GroupArgumentsLayout->setSpacing(6);
176 GroupArgumentsLayout->setMargin(11);
179 SubGroup1 = new QGroupBox(GroupArguments, "SubGroup1");
180 SubGroup1->setColumnLayout(0, Qt::Vertical);
181 SubGroup1->layout()->setSpacing(0);
182 SubGroup1->layout()->setMargin(0);
183 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1->layout());
184 SubGroup1Layout->setAlignment(Qt::AlignTop);
185 SubGroup1Layout->setSpacing(6);
186 SubGroup1Layout->setMargin(11);
188 // Controls of the first subgroup
189 TextLabel1 = new QLabel(SubGroup1, "TextLabel1");
190 TextLabel1->setFixedWidth(104);
191 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
193 SelectButton1 = new QPushButton(SubGroup1, "SelectButton1");
194 SelectButton1->setPixmap(image4);
195 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
197 LineEdit1 = new QLineEdit(SubGroup1, "LineEdit1");
198 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
200 TextLabel2 = new QLabel(SubGroup1, "TextLabel2");
201 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
203 SelectButton2 = new QPushButton(SubGroup1, "SelectButton2");
204 SelectButton2->setPixmap(image4);
205 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
207 LineEdit2 = new QLineEdit(SubGroup1, "LineEdit2");
208 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
210 TextLabel3 = new QLabel(SubGroup1, "TextLabel3");
211 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
213 SelectButton3 = new QPushButton(SubGroup1, "SelectButton3");
214 SelectButton3->setPixmap(image4);
215 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
217 LineEdit3 = new QLineEdit(SubGroup1, "LineEdit3");
218 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
221 SubGroup2 = new QGroupBox(GroupArguments, "SubGroup2");
222 SubGroup2->setColumnLayout(0, Qt::Vertical);
223 SubGroup2->layout()->setSpacing(0);
224 SubGroup2->layout()->setMargin(0);
225 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2->layout());
226 SubGroup2Layout->setAlignment(Qt::AlignTop);
227 SubGroup2Layout->setSpacing(6);
228 SubGroup2Layout->setMargin(11);
230 // Controls of the first subgroup
231 TextLabel4 = new QLabel(SubGroup2, "TextLabel4");
232 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
234 SelectButton4 = new QPushButton(SubGroup2, "SelectButton4");
235 SelectButton4->setPixmap(image4);
236 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
238 LineEdit4 = new QLineEdit(SubGroup2, "LineEdit4");
239 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
241 TextLabel5 = new QLabel(SubGroup2, "TextLabel5");
242 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
244 SelectButton5 = new QPushButton(SubGroup2, "SelectButton5");
245 SelectButton5->setPixmap(image4);
246 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
248 LineEdit5 = new QLineEdit(SubGroup2, "LineEdit5");
249 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
251 TextLabel6 = new QLabel(SubGroup2, "TextLabel6");
252 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
254 SelectButton6 = new QPushButton(SubGroup2, "SelectButton6");
255 SelectButton6->setPixmap(image4);
256 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
258 LineEdit6 = new QLineEdit(SubGroup2, "LineEdit6");
259 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
261 // Add subgroups to the group of arguments
262 GroupArgumentsLayout->addWidget(SubGroup1, 0, 0);
263 GroupArgumentsLayout->addWidget(SubGroup2, 1, 0);
265 // Control for the merging equal elements
266 CheckBoxMerge = new QCheckBox(GroupArguments, "CheckBoxMerge");
267 CheckBoxMerge->setText(tr("MERGE_EQUAL_ELEMENTS" ));
268 GroupArgumentsLayout->addWidget(CheckBoxMerge, 2, 0);
270 // Control for the polygons creation instead of splitting
271 CheckBoxPolygons = new QCheckBox( GroupArguments, "CheckBoxPolygons" );
272 CheckBoxPolygons->setText( tr( "CREATE_POLYGONS_INSTEAD_SPLITTING" ) );
273 GroupArgumentsLayout->addWidget( CheckBoxPolygons, 3, 0 );
275 // Control for the polyedres creation to obtain conform mesh
276 CheckBoxPolyedrs = new QCheckBox( GroupArguments, "CheckBoxPolyedrs" );
277 CheckBoxPolyedrs->setText( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ) );
278 GroupArgumentsLayout->addWidget( CheckBoxPolyedrs, 4, 0 );
281 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments, 1, 0);
283 /* Initialisations */
284 GroupArguments->show();
285 RadioButton1->setChecked(TRUE);
287 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
288 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
289 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
290 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
292 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
294 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
296 myHelpFileName = "/files/sewing_meshes.htm";
300 /* signals and slots connections */
301 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
302 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
303 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
304 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
305 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
307 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
308 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
309 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
310 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
311 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
312 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
314 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
315 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
316 /* to close dialog if study change */
317 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
319 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
320 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
321 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
322 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
323 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
324 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
326 this->show(); /* displays Dialog */
328 ConstructorsClicked(0);
332 //=================================================================================
333 // function : ~SMESHGUI_SewingDlg()
334 // purpose : Destroys the object and frees any allocated resources
335 //=================================================================================
336 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
338 // no need to delete child widgets, Qt does it all for us
341 //=================================================================================
344 //=================================================================================
345 void SMESHGUI_SewingDlg::Init()
349 myEditCurrentArgument = LineEdit1;
350 LineEdit1->setFocus();
352 myMesh = SMESH::SMESH_Mesh::_nil();
353 CheckBoxMerge->setChecked(false);
354 CheckBoxPolygons->setChecked(false);
355 CheckBoxPolyedrs->setChecked(false);
356 SelectionIntoArgument();
359 //=================================================================================
360 // function : ConstructorsClicked()
361 // purpose : Radio button management
362 //=================================================================================
363 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
365 disconnect(mySelectionMgr, 0, this, 0);
367 mySelectionMgr->selectedObjects( io );
368 mySelectionMgr->clearSelected();
369 LineEdit1->setText("");
370 LineEdit2->setText("");
371 LineEdit3->setText("");
372 LineEdit4->setText("");
373 LineEdit5->setText("");
374 LineEdit6->setText("");
375 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
376 myEditCurrentArgument = LineEdit1;
377 myEditCurrentArgument->setFocus();
379 if (!TextLabel5->isEnabled()) {
380 TextLabel5->setEnabled(true);
381 SelectButton5->setEnabled(true);
382 LineEdit5->setEnabled(true);
383 } else if (!TextLabel6->isEnabled()) {
384 TextLabel6->setEnabled(true);
385 SelectButton6->setEnabled(true);
386 LineEdit6->setEnabled(true);
389 if (constructorId == 1 || constructorId == 3) {
390 if (CheckBoxPolygons->isVisible())
391 CheckBoxPolygons->hide();
392 if (CheckBoxPolyedrs->isVisible())
393 CheckBoxPolyedrs->hide();
396 switch (constructorId) {
399 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
400 SubGroup1->setTitle(tr("BORDER_1"));
401 SubGroup2->setTitle(tr("BORDER_2"));
403 if (!CheckBoxPolygons->isVisible())
404 CheckBoxPolygons->show();
405 if (!CheckBoxPolyedrs->isVisible())
406 CheckBoxPolyedrs->show();
413 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
414 SubGroup1->setTitle(tr("BORDER_1"));
415 SubGroup2->setTitle(tr("BORDER_2"));
417 TextLabel6->setEnabled(false);
418 SelectButton6->setEnabled(false);
419 LineEdit6->setEnabled(false);
427 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
428 SubGroup1->setTitle(tr("BORDER"));
429 SubGroup2->setTitle(tr("SIDE"));
431 TextLabel5->setEnabled(false);
432 SelectButton5->setEnabled(false);
433 LineEdit5->setEnabled(false);
435 if (!CheckBoxPolygons->isVisible())
436 CheckBoxPolygons->show();
437 if (!CheckBoxPolyedrs->isVisible())
438 CheckBoxPolyedrs->show();
447 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
448 SubGroup1->setTitle(tr("SIDE_1"));
449 SubGroup2->setTitle(tr("SIDE_2"));
451 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
452 TextLabel2->setText(tr("NODE1_TO_MERGE"));
453 TextLabel3->setText(tr("NODE2_TO_MERGE"));
454 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
455 TextLabel5->setText(tr("NODE1_TO_MERGE"));
456 TextLabel6->setText(tr("NODE2_TO_MERGE"));
458 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator"));
459 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator"));
461 SMESH::SetPointRepresentation(false);
463 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
464 aViewWindow->SetSelectionMode(CellSelection);
469 if (constructorId != 3) {
470 TextLabel1->setText(tr("FIRST_NODE_ID"));
471 TextLabel2->setText(tr("SECOND_NODE_ID"));
472 TextLabel3->setText(tr("LAST_NODE_ID"));
473 TextLabel4->setText(tr("FIRST_NODE_ID"));
474 TextLabel5->setText(tr("SECOND_NODE_ID"));
475 TextLabel6->setText(tr("LAST_NODE_ID"));
477 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
478 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
480 SMESH::SetPointRepresentation(true);
482 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
483 aViewWindow->SetSelectionMode(NodeSelection);
486 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
487 mySelectionMgr->setSelectedObjects( io );
490 //=================================================================================
491 // function : ClickOnApply()
493 //=================================================================================
494 bool SMESHGUI_SewingDlg::ClickOnApply()
496 if (mySMESHGUI->isActiveStudyLocked())
499 bool aResult = false;
502 bool toMerge = CheckBoxMerge->isChecked();
503 bool toCreatePolygons = CheckBoxPolygons->isChecked();
504 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
507 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
508 QApplication::setOverrideCursor(Qt::waitCursor);
510 int aConstructorId = GetConstructorId();
511 SMESH::SMESH_MeshEditor::Sew_Error anError;
513 if (aConstructorId == 0)
514 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
515 LineEdit2->text().toLong(),
516 LineEdit3->text().toLong(),
517 LineEdit4->text().toLong(),
518 LineEdit5->text().toLong(),
519 LineEdit6->text().toLong(),
522 else if (aConstructorId == 1)
523 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
524 LineEdit2->text().toLong(),
525 LineEdit3->text().toLong(),
526 LineEdit4->text().toLong(),
527 LineEdit5->text().toLong());
528 else if (aConstructorId == 2)
529 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
530 LineEdit2->text().toLong(),
531 LineEdit3->text().toLong(),
532 LineEdit4->text().toLong(),
533 LineEdit6->text().toLong(),
536 else if (aConstructorId == 3) {
537 QStringList aListElementsId1 = QStringList::split(" ", LineEdit1->text(), false);
538 QStringList aListElementsId2 = QStringList::split(" ", LineEdit4->text(), false);
540 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
541 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
543 anElementsId1->length(aListElementsId1.count());
544 anElementsId2->length(aListElementsId2.count());
546 for (int i = 0; i < aListElementsId1.count(); i++)
547 anElementsId1[i] = aListElementsId1[i].toInt();
548 for (int i = 0; i < aListElementsId2.count(); i++)
549 anElementsId2[i] = aListElementsId2[i].toInt();
551 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
552 anElementsId2.inout(),
553 LineEdit2->text().toLong(),
554 LineEdit5->text().toLong(),
555 LineEdit3->text().toLong(),
556 LineEdit6->text().toLong());
558 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
560 if (toMerge && aResult)
561 aMeshEditor->MergeEqualElements();
563 QApplication::restoreOverrideCursor();
566 QString msg = tr(QString("ERROR_%1").arg(anError));
567 SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
568 msg, tr("SMESH_BUT_OK"));
574 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
578 mySelectionMgr->setSelectedObjects(aList, false);
582 ConstructorsClicked(GetConstructorId());
589 //=================================================================================
590 // function : ClickOnOk()
592 //=================================================================================
593 void SMESHGUI_SewingDlg::ClickOnOk()
599 //=================================================================================
600 // function : ClickOnCancel()
602 //=================================================================================
603 void SMESHGUI_SewingDlg::ClickOnCancel()
605 //mySelectionMgr->clearSelected();
606 SMESH::SetPointRepresentation(false);
607 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
608 aViewWindow->SetSelectionMode(ActorSelection);
609 disconnect(mySelectionMgr, 0, this, 0);
610 mySMESHGUI->ResetState();
614 //=================================================================================
615 // function : ClickOnHelp()
617 //=================================================================================
618 void SMESHGUI_SewingDlg::ClickOnHelp()
620 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
622 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
626 platform = "winapplication";
628 platform = "application";
630 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
631 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
632 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
633 QObject::tr("BUT_OK"));
637 //=======================================================================
638 //function : onTextChange
640 //=======================================================================
641 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
643 QLineEdit* send = (QLineEdit*)sender();
649 myEditCurrentArgument = send;
651 if (send == LineEdit1)
653 else if (send == LineEdit2)
655 else if (send == LineEdit3)
657 else if (send == LineEdit4)
659 else if (send == LineEdit5)
661 else if (send == LineEdit6)
664 buttonOk->setEnabled(false);
665 buttonApply->setEnabled(false);
667 // hilight entered elements/nodes
668 SMDS_Mesh* aMesh = 0;
671 aMesh = myActor->GetObject()->GetMesh();
676 TColStd_MapOfInteger newIndices;
678 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
679 SMESH::SetPointRepresentation(true);
681 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
682 aViewWindow->SetSelectionMode(NodeSelection);
684 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
686 newIndices.Add(n->GetID());
687 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
688 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
689 aViewWindow->highlight( myActor->getIO(), true, true );
691 if (send == LineEdit1)
693 else if (send == LineEdit2)
695 else if (send == LineEdit3)
697 else if (send == LineEdit4)
699 else if (send == LineEdit5)
701 else if (send == LineEdit6)
705 SMESH::SetPointRepresentation(false);
707 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
708 aViewWindow->SetSelectionMode(CellSelection);
710 QStringList aListId = QStringList::split(" ", theNewText, false);
712 bool isEvenOneExists = false;
714 for (int i = 0; i < aListId.count(); i++) {
715 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
717 newIndices.Add(e->GetID());
719 if (!isEvenOneExists)
720 isEvenOneExists = true;
724 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
725 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
726 aViewWindow->highlight( myActor->getIO(), true, true );
728 if (isEvenOneExists) {
729 if (send == LineEdit1)
731 else if(send == LineEdit4)
740 buttonOk->setEnabled(true);
741 buttonApply->setEnabled(true);
747 //=================================================================================
748 // function : SelectionIntoArgument()
749 // purpose : Called when selection as changed or other case
750 //=================================================================================
751 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
756 if (isSelectionChanged)
759 QString aString = "";
762 myEditCurrentArgument->setText(aString);
765 if (!GroupButtons->isEnabled()) // inactive
768 buttonOk->setEnabled(false);
769 buttonApply->setEnabled(false);
773 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
775 int nbSel = aList.Extent();
779 Handle(SALOME_InteractiveObject) IO = aList.First();
780 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
781 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
783 if (myMesh->_is_nil() || !myActor)
786 // get selected elements/nodes
789 if (GetConstructorId() != 3 ||
790 (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) {
791 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
795 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
801 myEditCurrentArgument->setText(aString);
805 if (myEditCurrentArgument == LineEdit1)
807 else if (myEditCurrentArgument == LineEdit2)
809 else if (myEditCurrentArgument == LineEdit3)
811 else if (myEditCurrentArgument == LineEdit4)
813 else if (myEditCurrentArgument == LineEdit5)
815 else if (myEditCurrentArgument == LineEdit6)
819 buttonOk->setEnabled(true);
820 buttonApply->setEnabled(true);
824 //=================================================================================
825 // function : SetEditCurrentArgument()
827 //=================================================================================
828 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
830 QPushButton* send = (QPushButton*)sender();
832 disconnect(mySelectionMgr, 0, this, 0);
833 mySelectionMgr->clearSelected();
835 if (send == SelectButton1) {
836 myEditCurrentArgument = LineEdit1;
839 else if (send == SelectButton2) {
840 myEditCurrentArgument = LineEdit2;
843 else if (send == SelectButton3) {
844 myEditCurrentArgument = LineEdit3;
847 else if (send == SelectButton4) {
848 myEditCurrentArgument = LineEdit4;
851 else if (send == SelectButton5) {
852 myEditCurrentArgument = LineEdit5;
855 else if (send == SelectButton6) {
856 myEditCurrentArgument = LineEdit6;
860 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
861 SMESH::SetPointRepresentation(true);
863 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
864 aViewWindow->SetSelectionMode(NodeSelection);
867 SMESH::SetPointRepresentation(false);
868 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
869 aViewWindow->SetSelectionMode(CellSelection);
872 myEditCurrentArgument->setFocus();
873 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
874 SelectionIntoArgument(false);
877 //=================================================================================
878 // function : DeactivateActiveDialog()
880 //=================================================================================
881 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
883 if (GroupConstructors->isEnabled()) {
884 GroupConstructors->setEnabled(false);
885 GroupArguments->setEnabled(false);
886 GroupButtons->setEnabled(false);
887 mySMESHGUI->ResetState();
888 mySMESHGUI->SetActiveDialogBox(0);
892 //=================================================================================
893 // function : ActivateThisDialog()
895 //=================================================================================
896 void SMESHGUI_SewingDlg::ActivateThisDialog()
898 /* Emit a signal to deactivate the active dialog */
899 mySMESHGUI->EmitSignalDeactivateDialog();
900 GroupConstructors->setEnabled(true);
901 GroupArguments->setEnabled(true);
902 GroupButtons->setEnabled(true);
904 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
906 ConstructorsClicked(GetConstructorId());
907 SelectionIntoArgument();
910 //=================================================================================
911 // function : enterEvent()
913 //=================================================================================
914 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
916 if (!GroupConstructors->isEnabled())
917 ActivateThisDialog();
920 //=================================================================================
921 // function : closeEvent()
923 //=================================================================================
924 void SMESHGUI_SewingDlg::closeEvent (QCloseEvent*)
926 /* same than click on cancel button */
927 this->ClickOnCancel();
930 //=======================================================================
931 //function : hideEvent
932 //purpose : caused by ESC key
933 //=======================================================================
934 void SMESHGUI_SewingDlg::hideEvent (QHideEvent*)
940 //=================================================================================
941 // function : GetConstructorId()
943 //=================================================================================
944 int SMESHGUI_SewingDlg::GetConstructorId()
946 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
947 return GroupConstructors->id(GroupConstructors->selected());
951 //=================================================================================
952 // function : GetConstructorId()
954 //=================================================================================
955 bool SMESHGUI_SewingDlg::IsValid()
957 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);