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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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);
624 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
625 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
626 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
627 QObject::tr("BUT_OK"));
631 //=======================================================================
632 //function : onTextChange
634 //=======================================================================
635 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
637 QLineEdit* send = (QLineEdit*)sender();
643 myEditCurrentArgument = send;
645 if (send == LineEdit1)
647 else if (send == LineEdit2)
649 else if (send == LineEdit3)
651 else if (send == LineEdit4)
653 else if (send == LineEdit5)
655 else if (send == LineEdit6)
658 buttonOk->setEnabled(false);
659 buttonApply->setEnabled(false);
661 // hilight entered elements/nodes
662 SMDS_Mesh* aMesh = 0;
665 aMesh = myActor->GetObject()->GetMesh();
670 TColStd_MapOfInteger newIndices;
672 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
673 SMESH::SetPointRepresentation(true);
675 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
676 aViewWindow->SetSelectionMode(NodeSelection);
678 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
680 newIndices.Add(n->GetID());
681 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
682 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
683 aViewWindow->highlight( myActor->getIO(), true, true );
685 if (send == LineEdit1)
687 else if (send == LineEdit2)
689 else if (send == LineEdit3)
691 else if (send == LineEdit4)
693 else if (send == LineEdit5)
695 else if (send == LineEdit6)
699 SMESH::SetPointRepresentation(false);
701 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
702 aViewWindow->SetSelectionMode(CellSelection);
704 QStringList aListId = QStringList::split(" ", theNewText, false);
706 bool isEvenOneExists = false;
708 for (int i = 0; i < aListId.count(); i++) {
709 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
711 newIndices.Add(e->GetID());
713 if (!isEvenOneExists)
714 isEvenOneExists = true;
718 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
719 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
720 aViewWindow->highlight( myActor->getIO(), true, true );
722 if (isEvenOneExists) {
723 if (send == LineEdit1)
725 else if(send == LineEdit4)
734 buttonOk->setEnabled(true);
735 buttonApply->setEnabled(true);
741 //=================================================================================
742 // function : SelectionIntoArgument()
743 // purpose : Called when selection as changed or other case
744 //=================================================================================
745 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
750 if (isSelectionChanged)
753 QString aString = "";
756 myEditCurrentArgument->setText(aString);
759 if (!GroupButtons->isEnabled()) // inactive
762 buttonOk->setEnabled(false);
763 buttonApply->setEnabled(false);
767 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
769 int nbSel = aList.Extent();
773 Handle(SALOME_InteractiveObject) IO = aList.First();
774 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
775 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
777 if (myMesh->_is_nil() || !myActor)
780 // get selected elements/nodes
783 if (GetConstructorId() != 3 ||
784 (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) {
785 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
789 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
795 myEditCurrentArgument->setText(aString);
799 if (myEditCurrentArgument == LineEdit1)
801 else if (myEditCurrentArgument == LineEdit2)
803 else if (myEditCurrentArgument == LineEdit3)
805 else if (myEditCurrentArgument == LineEdit4)
807 else if (myEditCurrentArgument == LineEdit5)
809 else if (myEditCurrentArgument == LineEdit6)
813 buttonOk->setEnabled(true);
814 buttonApply->setEnabled(true);
818 //=================================================================================
819 // function : SetEditCurrentArgument()
821 //=================================================================================
822 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
824 QPushButton* send = (QPushButton*)sender();
826 disconnect(mySelectionMgr, 0, this, 0);
827 mySelectionMgr->clearSelected();
829 if (send == SelectButton1) {
830 myEditCurrentArgument = LineEdit1;
833 else if (send == SelectButton2) {
834 myEditCurrentArgument = LineEdit2;
837 else if (send == SelectButton3) {
838 myEditCurrentArgument = LineEdit3;
841 else if (send == SelectButton4) {
842 myEditCurrentArgument = LineEdit4;
845 else if (send == SelectButton5) {
846 myEditCurrentArgument = LineEdit5;
849 else if (send == SelectButton6) {
850 myEditCurrentArgument = LineEdit6;
854 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
855 SMESH::SetPointRepresentation(true);
857 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
858 aViewWindow->SetSelectionMode(NodeSelection);
861 SMESH::SetPointRepresentation(false);
862 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
863 aViewWindow->SetSelectionMode(CellSelection);
866 myEditCurrentArgument->setFocus();
867 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
868 SelectionIntoArgument(false);
871 //=================================================================================
872 // function : DeactivateActiveDialog()
874 //=================================================================================
875 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
877 if (GroupConstructors->isEnabled()) {
878 GroupConstructors->setEnabled(false);
879 GroupArguments->setEnabled(false);
880 GroupButtons->setEnabled(false);
881 mySMESHGUI->ResetState();
882 mySMESHGUI->SetActiveDialogBox(0);
886 //=================================================================================
887 // function : ActivateThisDialog()
889 //=================================================================================
890 void SMESHGUI_SewingDlg::ActivateThisDialog()
892 /* Emit a signal to deactivate the active dialog */
893 mySMESHGUI->EmitSignalDeactivateDialog();
894 GroupConstructors->setEnabled(true);
895 GroupArguments->setEnabled(true);
896 GroupButtons->setEnabled(true);
898 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
900 ConstructorsClicked(GetConstructorId());
901 SelectionIntoArgument();
904 //=================================================================================
905 // function : enterEvent()
907 //=================================================================================
908 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
910 if (!GroupConstructors->isEnabled())
911 ActivateThisDialog();
914 //=================================================================================
915 // function : closeEvent()
917 //=================================================================================
918 void SMESHGUI_SewingDlg::closeEvent (QCloseEvent*)
920 /* same than click on cancel button */
921 this->ClickOnCancel();
924 //=======================================================================
925 //function : hideEvent
926 //purpose : caused by ESC key
927 //=======================================================================
928 void SMESHGUI_SewingDlg::hideEvent (QHideEvent*)
934 //=================================================================================
935 // function : GetConstructorId()
937 //=================================================================================
938 int SMESHGUI_SewingDlg::GetConstructorId()
940 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
941 return GroupConstructors->id(GroupConstructors->selected());
945 //=================================================================================
946 // function : GetConstructorId()
948 //=================================================================================
949 bool SMESHGUI_SewingDlg::IsValid()
951 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);