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_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
37 #include "SMESH_Actor.h"
38 #include "SMDS_Mesh.hxx"
40 #include "SUIT_Session.h"
41 #include "SUIT_ResourceMgr.h"
42 #include "SUIT_Desktop.h"
43 #include "SUIT_MessageBox.h"
45 #include "LightApp_Application.h"
47 #include "SVTK_ViewModel.h"
48 #include "SVTK_ViewWindow.h"
49 #include "SVTK_Selector.h"
50 #include "SVTK_Selection.h"
51 #include "SALOME_ListIO.hxx"
53 #include "utilities.h"
56 #include <TColStd_MapOfInteger.hxx>
57 #include <TColStd_IndexedMapOfInteger.hxx>
60 #include <qapplication.h>
61 #include <qbuttongroup.h>
62 #include <qgroupbox.h>
64 #include <qlineedit.h>
65 #include <qpushbutton.h>
66 #include <qradiobutton.h>
67 #include <qcheckbox.h>
71 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
76 //=================================================================================
77 // class : SMESHGUI_SewingDlg()
79 //=================================================================================
80 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule, const char* name,
81 bool modal, WFlags fl)
82 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
83 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
84 mySMESHGUI( theModule ),
85 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
87 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
88 QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS")));
89 QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS")));
90 QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE")));
91 QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS")));
92 QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
95 setName("SMESHGUI_SewingDlg");
97 setCaption(tr("SMESH_SEWING"));
98 setSizeGripEnabled(TRUE);
99 SMESHGUI_SewingDlgLayout = new QGridLayout(this);
100 SMESHGUI_SewingDlgLayout->setSpacing(6);
101 SMESHGUI_SewingDlgLayout->setMargin(11);
103 /***************************************************************/
104 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
105 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
106 (QSizePolicy::SizeType)0, 0, 0,
107 GroupConstructors->sizePolicy().hasHeightForWidth()));
108 GroupConstructors->setTitle(tr("SMESH_SEWING"));
109 GroupConstructors->setExclusive(TRUE);
110 GroupConstructors->setColumnLayout(0, Qt::Vertical);
111 GroupConstructors->layout()->setSpacing(0);
112 GroupConstructors->layout()->setMargin(0);
113 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
114 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
115 GroupConstructorsLayout->setSpacing(6);
116 GroupConstructorsLayout->setMargin(11);
117 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
118 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
119 RadioButton1->setText(tr("" ));
120 RadioButton1->setPixmap(image0);
121 RBLayout->addWidget(RadioButton1);
122 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
123 RadioButton2->setText(tr("" ));
124 RadioButton2->setPixmap(image1);
125 RBLayout->addWidget(RadioButton2);
126 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
127 RadioButton3->setText(tr("" ));
128 RadioButton3->setPixmap(image2);
129 RBLayout->addWidget(RadioButton3);
130 RadioButton4= new QRadioButton(GroupConstructors, "RadioButton4");
131 RadioButton4->setText(tr("" ));
132 RadioButton4->setPixmap(image3);
133 RBLayout->addWidget(RadioButton4);
134 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
135 SMESHGUI_SewingDlgLayout->addWidget(GroupConstructors, 0, 0);
137 /***************************************************************/
138 GroupButtons = new QGroupBox(this, "GroupButtons");
139 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
140 (QSizePolicy::SizeType)0, 0, 0,
141 GroupButtons->sizePolicy().hasHeightForWidth()));
142 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
143 GroupButtons->setTitle(tr("" ));
144 GroupButtons->setColumnLayout(0, Qt::Vertical);
145 GroupButtons->layout()->setSpacing(0);
146 GroupButtons->layout()->setMargin(0);
147 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
148 GroupButtonsLayout->setAlignment(Qt::AlignTop);
149 GroupButtonsLayout->setSpacing(6);
150 GroupButtonsLayout->setMargin(11);
151 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
152 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
153 buttonHelp->setAutoDefault(TRUE);
154 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
155 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
156 buttonCancel->setText(tr("SMESH_BUT_CLOSE"));
157 buttonCancel->setAutoDefault(TRUE);
158 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
159 buttonApply = new QPushButton(GroupButtons, "buttonApply");
160 buttonApply->setText(tr("SMESH_BUT_APPLY"));
161 buttonApply->setAutoDefault(TRUE);
162 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
163 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
164 GroupButtonsLayout->addItem(spacer_9, 0, 2);
165 buttonOk = new QPushButton(GroupButtons, "buttonOk");
166 buttonOk->setText(tr("SMESH_BUT_OK"));
167 buttonOk->setAutoDefault(TRUE);
168 buttonOk->setDefault(TRUE);
169 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
170 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons, 2, 0);
172 /***************************************************************/
173 GroupArguments = new QGroupBox(this, "GroupArguments");
174 GroupArguments->setColumnLayout(0, Qt::Vertical);
175 GroupArguments->layout()->setSpacing(0);
176 GroupArguments->layout()->setMargin(0);
177 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
178 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
179 GroupArgumentsLayout->setSpacing(6);
180 GroupArgumentsLayout->setMargin(11);
183 SubGroup1 = new QGroupBox(GroupArguments, "SubGroup1");
184 SubGroup1->setColumnLayout(0, Qt::Vertical);
185 SubGroup1->layout()->setSpacing(0);
186 SubGroup1->layout()->setMargin(0);
187 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1->layout());
188 SubGroup1Layout->setAlignment(Qt::AlignTop);
189 SubGroup1Layout->setSpacing(6);
190 SubGroup1Layout->setMargin(11);
192 // Controls of the first subgroup
193 TextLabel1 = new QLabel(SubGroup1, "TextLabel1");
194 TextLabel1->setFixedWidth(104);
195 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
197 SelectButton1 = new QPushButton(SubGroup1, "SelectButton1");
198 SelectButton1->setPixmap(image4);
199 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
201 LineEdit1 = new QLineEdit(SubGroup1, "LineEdit1");
202 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
204 TextLabel2 = new QLabel(SubGroup1, "TextLabel2");
205 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
207 SelectButton2 = new QPushButton(SubGroup1, "SelectButton2");
208 SelectButton2->setPixmap(image4);
209 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
211 LineEdit2 = new QLineEdit(SubGroup1, "LineEdit2");
212 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
214 TextLabel3 = new QLabel(SubGroup1, "TextLabel3");
215 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
217 SelectButton3 = new QPushButton(SubGroup1, "SelectButton3");
218 SelectButton3->setPixmap(image4);
219 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
221 LineEdit3 = new QLineEdit(SubGroup1, "LineEdit3");
222 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
225 SubGroup2 = new QGroupBox(GroupArguments, "SubGroup2");
226 SubGroup2->setColumnLayout(0, Qt::Vertical);
227 SubGroup2->layout()->setSpacing(0);
228 SubGroup2->layout()->setMargin(0);
229 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2->layout());
230 SubGroup2Layout->setAlignment(Qt::AlignTop);
231 SubGroup2Layout->setSpacing(6);
232 SubGroup2Layout->setMargin(11);
234 // Controls of the first subgroup
235 TextLabel4 = new QLabel(SubGroup2, "TextLabel4");
236 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
238 SelectButton4 = new QPushButton(SubGroup2, "SelectButton4");
239 SelectButton4->setPixmap(image4);
240 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
242 LineEdit4 = new QLineEdit(SubGroup2, "LineEdit4");
243 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
245 TextLabel5 = new QLabel(SubGroup2, "TextLabel5");
246 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
248 SelectButton5 = new QPushButton(SubGroup2, "SelectButton5");
249 SelectButton5->setPixmap(image4);
250 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
252 LineEdit5 = new QLineEdit(SubGroup2, "LineEdit5");
253 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
255 TextLabel6 = new QLabel(SubGroup2, "TextLabel6");
256 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
258 SelectButton6 = new QPushButton(SubGroup2, "SelectButton6");
259 SelectButton6->setPixmap(image4);
260 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
262 LineEdit6 = new QLineEdit(SubGroup2, "LineEdit6");
263 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
265 // Add subgroups to the group of arguments
266 GroupArgumentsLayout->addWidget(SubGroup1, 0, 0);
267 GroupArgumentsLayout->addWidget(SubGroup2, 1, 0);
269 // Control for the merging equal elements
270 CheckBoxMerge = new QCheckBox(GroupArguments, "CheckBoxMerge");
271 CheckBoxMerge->setText(tr("MERGE_EQUAL_ELEMENTS" ));
272 GroupArgumentsLayout->addWidget(CheckBoxMerge, 2, 0);
274 // Control for the polygons creation instead of splitting
275 CheckBoxPolygons = new QCheckBox( GroupArguments, "CheckBoxPolygons" );
276 CheckBoxPolygons->setText( tr( "CREATE_POLYGONS_INSTEAD_SPLITTING" ) );
277 GroupArgumentsLayout->addWidget( CheckBoxPolygons, 3, 0 );
279 // Control for the polyedres creation to obtain conform mesh
280 CheckBoxPolyedrs = new QCheckBox( GroupArguments, "CheckBoxPolyedrs" );
281 CheckBoxPolyedrs->setText( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ) );
282 GroupArgumentsLayout->addWidget( CheckBoxPolyedrs, 4, 0 );
285 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments, 1, 0);
287 /* Initialisations */
288 GroupArguments->show();
289 RadioButton1->setChecked(TRUE);
291 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
292 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
293 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
294 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
296 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
298 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
300 myHelpFileName = "sewing_meshes_page.html";
304 /* signals and slots connections */
305 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
306 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
307 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
308 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
309 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
311 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
312 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
313 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
314 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
315 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
316 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
318 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
319 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
320 /* to close dialog if study change */
321 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
323 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
324 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
325 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
326 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
327 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
328 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
330 this->show(); /* displays Dialog */
332 ConstructorsClicked(0);
336 //=================================================================================
337 // function : ~SMESHGUI_SewingDlg()
338 // purpose : Destroys the object and frees any allocated resources
339 //=================================================================================
340 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
342 // no need to delete child widgets, Qt does it all for us
345 //=================================================================================
348 //=================================================================================
349 void SMESHGUI_SewingDlg::Init()
353 myEditCurrentArgument = LineEdit1;
354 LineEdit1->setFocus();
356 myMesh = SMESH::SMESH_Mesh::_nil();
357 CheckBoxMerge->setChecked(false);
358 CheckBoxPolygons->setChecked(false);
359 CheckBoxPolyedrs->setChecked(false);
360 SelectionIntoArgument();
363 //=================================================================================
364 // function : ConstructorsClicked()
365 // purpose : Radio button management
366 //=================================================================================
367 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
369 disconnect(mySelectionMgr, 0, this, 0);
371 mySelectionMgr->selectedObjects( io );
372 mySelectionMgr->clearSelected();
373 LineEdit1->setText("");
374 LineEdit2->setText("");
375 LineEdit3->setText("");
376 LineEdit4->setText("");
377 LineEdit5->setText("");
378 LineEdit6->setText("");
379 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
380 myEditCurrentArgument = LineEdit1;
381 myEditCurrentArgument->setFocus();
383 if (!TextLabel5->isEnabled()) {
384 TextLabel5->setEnabled(true);
385 SelectButton5->setEnabled(true);
386 LineEdit5->setEnabled(true);
387 } else if (!TextLabel6->isEnabled()) {
388 TextLabel6->setEnabled(true);
389 SelectButton6->setEnabled(true);
390 LineEdit6->setEnabled(true);
393 if (constructorId == 1 || constructorId == 3) {
394 if (CheckBoxPolygons->isVisible())
395 CheckBoxPolygons->hide();
396 if (CheckBoxPolyedrs->isVisible())
397 CheckBoxPolyedrs->hide();
400 switch (constructorId) {
403 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
404 SubGroup1->setTitle(tr("BORDER_1"));
405 SubGroup2->setTitle(tr("BORDER_2"));
407 if (!CheckBoxPolygons->isVisible())
408 CheckBoxPolygons->show();
409 if (!CheckBoxPolyedrs->isVisible())
410 CheckBoxPolyedrs->show();
417 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
418 SubGroup1->setTitle(tr("BORDER_1"));
419 SubGroup2->setTitle(tr("BORDER_2"));
421 TextLabel6->setEnabled(false);
422 SelectButton6->setEnabled(false);
423 LineEdit6->setEnabled(false);
431 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
432 SubGroup1->setTitle(tr("BORDER"));
433 SubGroup2->setTitle(tr("SIDE"));
435 TextLabel5->setEnabled(false);
436 SelectButton5->setEnabled(false);
437 LineEdit5->setEnabled(false);
439 if (!CheckBoxPolygons->isVisible())
440 CheckBoxPolygons->show();
441 if (!CheckBoxPolyedrs->isVisible())
442 CheckBoxPolyedrs->show();
451 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
452 SubGroup1->setTitle(tr("SIDE_1"));
453 SubGroup2->setTitle(tr("SIDE_2"));
455 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
456 TextLabel2->setText(tr("NODE1_TO_MERGE"));
457 TextLabel3->setText(tr("NODE2_TO_MERGE"));
458 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
459 TextLabel5->setText(tr("NODE1_TO_MERGE"));
460 TextLabel6->setText(tr("NODE2_TO_MERGE"));
462 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator"));
463 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator"));
465 SMESH::SetPointRepresentation(false);
467 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
468 aViewWindow->SetSelectionMode(CellSelection);
473 if (constructorId != 3) {
474 TextLabel1->setText(tr("FIRST_NODE_ID"));
475 TextLabel2->setText(tr("SECOND_NODE_ID"));
476 TextLabel3->setText(tr("LAST_NODE_ID"));
477 TextLabel4->setText(tr("FIRST_NODE_ID"));
478 TextLabel5->setText(tr("SECOND_NODE_ID"));
479 TextLabel6->setText(tr("LAST_NODE_ID"));
481 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
482 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
484 SMESH::SetPointRepresentation(true);
486 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
487 aViewWindow->SetSelectionMode(NodeSelection);
490 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
491 mySelectionMgr->setSelectedObjects( io );
494 //=================================================================================
495 // function : ClickOnApply()
497 //=================================================================================
498 bool SMESHGUI_SewingDlg::ClickOnApply()
500 if (mySMESHGUI->isActiveStudyLocked())
503 bool aResult = false;
506 bool toMerge = CheckBoxMerge->isChecked();
507 bool toCreatePolygons = CheckBoxPolygons->isChecked();
508 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
511 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
512 QApplication::setOverrideCursor(Qt::waitCursor);
514 int aConstructorId = GetConstructorId();
515 SMESH::SMESH_MeshEditor::Sew_Error anError;
517 if (aConstructorId == 0)
518 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
519 LineEdit2->text().toLong(),
520 LineEdit3->text().toLong(),
521 LineEdit4->text().toLong(),
522 LineEdit5->text().toLong(),
523 LineEdit6->text().toLong(),
526 else if (aConstructorId == 1)
527 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
528 LineEdit2->text().toLong(),
529 LineEdit3->text().toLong(),
530 LineEdit4->text().toLong(),
531 LineEdit5->text().toLong());
532 else if (aConstructorId == 2)
533 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
534 LineEdit2->text().toLong(),
535 LineEdit3->text().toLong(),
536 LineEdit4->text().toLong(),
537 LineEdit6->text().toLong(),
540 else if (aConstructorId == 3) {
541 QStringList aListElementsId1 = QStringList::split(" ", LineEdit1->text(), false);
542 QStringList aListElementsId2 = QStringList::split(" ", LineEdit4->text(), false);
544 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
545 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
547 anElementsId1->length(aListElementsId1.count());
548 anElementsId2->length(aListElementsId2.count());
550 for (int i = 0; i < aListElementsId1.count(); i++)
551 anElementsId1[i] = aListElementsId1[i].toInt();
552 for (int i = 0; i < aListElementsId2.count(); i++)
553 anElementsId2[i] = aListElementsId2[i].toInt();
555 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
556 anElementsId2.inout(),
557 LineEdit2->text().toLong(),
558 LineEdit5->text().toLong(),
559 LineEdit3->text().toLong(),
560 LineEdit6->text().toLong());
562 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
564 if (toMerge && aResult)
565 aMeshEditor->MergeEqualElements();
567 QApplication::restoreOverrideCursor();
570 QString msg = tr(QString("ERROR_%1").arg(anError));
571 SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
572 msg, tr("SMESH_BUT_OK"));
578 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
582 mySelectionMgr->setSelectedObjects(aList, false);
586 ConstructorsClicked(GetConstructorId());
593 //=================================================================================
594 // function : ClickOnOk()
596 //=================================================================================
597 void SMESHGUI_SewingDlg::ClickOnOk()
603 //=================================================================================
604 // function : ClickOnCancel()
606 //=================================================================================
607 void SMESHGUI_SewingDlg::ClickOnCancel()
609 //mySelectionMgr->clearSelected();
610 SMESH::SetPointRepresentation(false);
611 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
612 aViewWindow->SetSelectionMode(ActorSelection);
613 disconnect(mySelectionMgr, 0, this, 0);
614 mySMESHGUI->ResetState();
618 //=================================================================================
619 // function : ClickOnHelp()
621 //=================================================================================
622 void SMESHGUI_SewingDlg::ClickOnHelp()
624 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
626 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
630 platform = "winapplication";
632 platform = "application";
634 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
635 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
636 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
637 QObject::tr("BUT_OK"));
641 //=======================================================================
642 //function : onTextChange
644 //=======================================================================
645 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
647 QLineEdit* send = (QLineEdit*)sender();
653 myEditCurrentArgument = send;
655 if (send == LineEdit1)
657 else if (send == LineEdit2)
659 else if (send == LineEdit3)
661 else if (send == LineEdit4)
663 else if (send == LineEdit5)
665 else if (send == LineEdit6)
668 buttonOk->setEnabled(false);
669 buttonApply->setEnabled(false);
671 // hilight entered elements/nodes
672 SMDS_Mesh* aMesh = 0;
675 aMesh = myActor->GetObject()->GetMesh();
680 TColStd_MapOfInteger newIndices;
682 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
683 SMESH::SetPointRepresentation(true);
685 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
686 aViewWindow->SetSelectionMode(NodeSelection);
688 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
690 newIndices.Add(n->GetID());
691 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
692 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
693 aViewWindow->highlight( myActor->getIO(), true, true );
695 if (send == LineEdit1)
697 else if (send == LineEdit2)
699 else if (send == LineEdit3)
701 else if (send == LineEdit4)
703 else if (send == LineEdit5)
705 else if (send == LineEdit6)
709 SMESH::SetPointRepresentation(false);
711 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
712 aViewWindow->SetSelectionMode(CellSelection);
714 QStringList aListId = QStringList::split(" ", theNewText, false);
716 bool isEvenOneExists = false;
718 for (int i = 0; i < aListId.count(); i++) {
719 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
721 newIndices.Add(e->GetID());
723 if (!isEvenOneExists)
724 isEvenOneExists = true;
728 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
729 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
730 aViewWindow->highlight( myActor->getIO(), true, true );
732 if (isEvenOneExists) {
733 if (send == LineEdit1)
735 else if(send == LineEdit4)
744 buttonOk->setEnabled(true);
745 buttonApply->setEnabled(true);
751 //=================================================================================
752 // function : SelectionIntoArgument()
753 // purpose : Called when selection as changed or other case
754 //=================================================================================
755 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
760 if (isSelectionChanged)
763 QString aString = "";
766 myEditCurrentArgument->setText(aString);
769 if (!GroupButtons->isEnabled()) // inactive
772 buttonOk->setEnabled(false);
773 buttonApply->setEnabled(false);
777 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
779 int nbSel = aList.Extent();
783 Handle(SALOME_InteractiveObject) IO = aList.First();
784 myMesh = SMESH::GetMeshByIO(IO); //@ SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
785 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
787 if (myMesh->_is_nil() || !myActor)
790 // get selected elements/nodes
793 if (GetConstructorId() != 3 ||
794 (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) {
795 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
799 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
805 myEditCurrentArgument->setText(aString);
809 if (myEditCurrentArgument == LineEdit1)
811 else if (myEditCurrentArgument == LineEdit2)
813 else if (myEditCurrentArgument == LineEdit3)
815 else if (myEditCurrentArgument == LineEdit4)
817 else if (myEditCurrentArgument == LineEdit5)
819 else if (myEditCurrentArgument == LineEdit6)
823 buttonOk->setEnabled(true);
824 buttonApply->setEnabled(true);
828 //=================================================================================
829 // function : SetEditCurrentArgument()
831 //=================================================================================
832 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
834 QPushButton* send = (QPushButton*)sender();
836 disconnect(mySelectionMgr, 0, this, 0);
837 mySelectionMgr->clearSelected();
839 if (send == SelectButton1) {
840 myEditCurrentArgument = LineEdit1;
843 else if (send == SelectButton2) {
844 myEditCurrentArgument = LineEdit2;
847 else if (send == SelectButton3) {
848 myEditCurrentArgument = LineEdit3;
851 else if (send == SelectButton4) {
852 myEditCurrentArgument = LineEdit4;
855 else if (send == SelectButton5) {
856 myEditCurrentArgument = LineEdit5;
859 else if (send == SelectButton6) {
860 myEditCurrentArgument = LineEdit6;
864 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
865 SMESH::SetPointRepresentation(true);
867 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
868 aViewWindow->SetSelectionMode(NodeSelection);
871 SMESH::SetPointRepresentation(false);
872 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
873 aViewWindow->SetSelectionMode(CellSelection);
876 myEditCurrentArgument->setFocus();
877 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
878 SelectionIntoArgument(false);
881 //=================================================================================
882 // function : DeactivateActiveDialog()
884 //=================================================================================
885 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
887 if (GroupConstructors->isEnabled()) {
888 GroupConstructors->setEnabled(false);
889 GroupArguments->setEnabled(false);
890 GroupButtons->setEnabled(false);
891 mySMESHGUI->ResetState();
892 mySMESHGUI->SetActiveDialogBox(0);
896 //=================================================================================
897 // function : ActivateThisDialog()
899 //=================================================================================
900 void SMESHGUI_SewingDlg::ActivateThisDialog()
902 /* Emit a signal to deactivate the active dialog */
903 mySMESHGUI->EmitSignalDeactivateDialog();
904 GroupConstructors->setEnabled(true);
905 GroupArguments->setEnabled(true);
906 GroupButtons->setEnabled(true);
908 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
910 ConstructorsClicked(GetConstructorId());
911 SelectionIntoArgument();
914 //=================================================================================
915 // function : enterEvent()
917 //=================================================================================
918 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
920 if (!GroupConstructors->isEnabled())
921 ActivateThisDialog();
924 //=================================================================================
925 // function : closeEvent()
927 //=================================================================================
928 void SMESHGUI_SewingDlg::closeEvent (QCloseEvent*)
930 /* same than click on cancel button */
931 this->ClickOnCancel();
934 //=======================================================================
935 //function : hideEvent
936 //purpose : caused by ESC key
937 //=======================================================================
938 void SMESHGUI_SewingDlg::hideEvent (QHideEvent*)
944 //=================================================================================
945 // function : GetConstructorId()
947 //=================================================================================
948 int SMESHGUI_SewingDlg::GetConstructorId()
950 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
951 return GroupConstructors->id(GroupConstructors->selected());
955 //=================================================================================
956 // function : GetConstructorId()
958 //=================================================================================
959 bool SMESHGUI_SewingDlg::IsValid()
961 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);
964 //=================================================================================
965 // function : keyPressEvent()
967 //=================================================================================
968 void SMESHGUI_SewingDlg::keyPressEvent( QKeyEvent* e )
970 QDialog::keyPressEvent( e );
971 if ( e->isAccepted() )
974 if ( e->key() == Key_F1 )