1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
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
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_SewingDlg.cxx
24 // Author : Michael ZORIN
28 #include "SMESHGUI_SewingDlg.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.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>
70 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
75 //=================================================================================
76 // class : SMESHGUI_SewingDlg()
78 //=================================================================================
79 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule, const char* name,
80 bool modal, WFlags fl)
81 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
82 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
83 mySMESHGUI( theModule ),
84 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
86 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
87 QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS")));
88 QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS")));
89 QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE")));
90 QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS")));
91 QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
94 setName("SMESHGUI_SewingDlg");
96 setCaption(tr("SMESH_SEWING"));
97 setSizeGripEnabled(TRUE);
98 SMESHGUI_SewingDlgLayout = new QGridLayout(this);
99 SMESHGUI_SewingDlgLayout->setSpacing(6);
100 SMESHGUI_SewingDlgLayout->setMargin(11);
102 /***************************************************************/
103 GroupConstructors = new QButtonGroup(this, "GroupConstructors");
104 GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,
105 (QSizePolicy::SizeType)0, 0, 0,
106 GroupConstructors->sizePolicy().hasHeightForWidth()));
107 GroupConstructors->setTitle(tr("SMESH_SEWING"));
108 GroupConstructors->setExclusive(TRUE);
109 GroupConstructors->setColumnLayout(0, Qt::Vertical);
110 GroupConstructors->layout()->setSpacing(0);
111 GroupConstructors->layout()->setMargin(0);
112 GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
113 GroupConstructorsLayout->setAlignment(Qt::AlignTop);
114 GroupConstructorsLayout->setSpacing(6);
115 GroupConstructorsLayout->setMargin(11);
116 QHBoxLayout* RBLayout = new QHBoxLayout(0, 0, 6, "Layout2");
117 RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
118 RadioButton1->setText(tr("" ));
119 RadioButton1->setPixmap(image0);
120 RBLayout->addWidget(RadioButton1);
121 RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
122 RadioButton2->setText(tr("" ));
123 RadioButton2->setPixmap(image1);
124 RBLayout->addWidget(RadioButton2);
125 RadioButton3= new QRadioButton(GroupConstructors, "RadioButton3");
126 RadioButton3->setText(tr("" ));
127 RadioButton3->setPixmap(image2);
128 RBLayout->addWidget(RadioButton3);
129 RadioButton4= new QRadioButton(GroupConstructors, "RadioButton4");
130 RadioButton4->setText(tr("" ));
131 RadioButton4->setPixmap(image3);
132 RBLayout->addWidget(RadioButton4);
133 GroupConstructorsLayout->addLayout(RBLayout, 0, 0);
134 SMESHGUI_SewingDlgLayout->addWidget(GroupConstructors, 0, 0);
136 /***************************************************************/
137 GroupButtons = new QGroupBox(this, "GroupButtons");
138 GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7,
139 (QSizePolicy::SizeType)0, 0, 0,
140 GroupButtons->sizePolicy().hasHeightForWidth()));
141 GroupButtons->setGeometry(QRect(10, 10, 281, 48));
142 GroupButtons->setTitle(tr("" ));
143 GroupButtons->setColumnLayout(0, Qt::Vertical);
144 GroupButtons->layout()->setSpacing(0);
145 GroupButtons->layout()->setMargin(0);
146 GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
147 GroupButtonsLayout->setAlignment(Qt::AlignTop);
148 GroupButtonsLayout->setSpacing(6);
149 GroupButtonsLayout->setMargin(11);
150 buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
151 buttonHelp->setText(tr("SMESH_BUT_HELP" ));
152 buttonHelp->setAutoDefault(TRUE);
153 GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
154 buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
155 buttonCancel->setText(tr("SMESH_BUT_CLOSE"));
156 buttonCancel->setAutoDefault(TRUE);
157 GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
158 buttonApply = new QPushButton(GroupButtons, "buttonApply");
159 buttonApply->setText(tr("SMESH_BUT_APPLY"));
160 buttonApply->setAutoDefault(TRUE);
161 GroupButtonsLayout->addWidget(buttonApply, 0, 1);
162 QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
163 GroupButtonsLayout->addItem(spacer_9, 0, 2);
164 buttonOk = new QPushButton(GroupButtons, "buttonOk");
165 buttonOk->setText(tr("SMESH_BUT_APPLY_AND_CLOSE"));
166 buttonOk->setAutoDefault(TRUE);
167 buttonOk->setDefault(TRUE);
168 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
169 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons, 2, 0);
171 /***************************************************************/
172 GroupArguments = new QGroupBox(this, "GroupArguments");
173 GroupArguments->setColumnLayout(0, Qt::Vertical);
174 GroupArguments->layout()->setSpacing(0);
175 GroupArguments->layout()->setMargin(0);
176 GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
177 GroupArgumentsLayout->setAlignment(Qt::AlignTop);
178 GroupArgumentsLayout->setSpacing(6);
179 GroupArgumentsLayout->setMargin(11);
182 SubGroup1 = new QGroupBox(GroupArguments, "SubGroup1");
183 SubGroup1->setColumnLayout(0, Qt::Vertical);
184 SubGroup1->layout()->setSpacing(0);
185 SubGroup1->layout()->setMargin(0);
186 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1->layout());
187 SubGroup1Layout->setAlignment(Qt::AlignTop);
188 SubGroup1Layout->setSpacing(6);
189 SubGroup1Layout->setMargin(11);
191 // Controls of the first subgroup
192 TextLabel1 = new QLabel(SubGroup1, "TextLabel1");
193 TextLabel1->setFixedWidth(104);
194 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
196 SelectButton1 = new QPushButton(SubGroup1, "SelectButton1");
197 SelectButton1->setPixmap(image4);
198 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
200 LineEdit1 = new QLineEdit(SubGroup1, "LineEdit1");
201 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
203 TextLabel2 = new QLabel(SubGroup1, "TextLabel2");
204 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
206 SelectButton2 = new QPushButton(SubGroup1, "SelectButton2");
207 SelectButton2->setPixmap(image4);
208 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
210 LineEdit2 = new QLineEdit(SubGroup1, "LineEdit2");
211 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
213 TextLabel3 = new QLabel(SubGroup1, "TextLabel3");
214 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
216 SelectButton3 = new QPushButton(SubGroup1, "SelectButton3");
217 SelectButton3->setPixmap(image4);
218 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
220 LineEdit3 = new QLineEdit(SubGroup1, "LineEdit3");
221 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
224 SubGroup2 = new QGroupBox(GroupArguments, "SubGroup2");
225 SubGroup2->setColumnLayout(0, Qt::Vertical);
226 SubGroup2->layout()->setSpacing(0);
227 SubGroup2->layout()->setMargin(0);
228 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2->layout());
229 SubGroup2Layout->setAlignment(Qt::AlignTop);
230 SubGroup2Layout->setSpacing(6);
231 SubGroup2Layout->setMargin(11);
233 // Controls of the first subgroup
234 TextLabel4 = new QLabel(SubGroup2, "TextLabel4");
235 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
237 SelectButton4 = new QPushButton(SubGroup2, "SelectButton4");
238 SelectButton4->setPixmap(image4);
239 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
241 LineEdit4 = new QLineEdit(SubGroup2, "LineEdit4");
242 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
244 TextLabel5 = new QLabel(SubGroup2, "TextLabel5");
245 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
247 SelectButton5 = new QPushButton(SubGroup2, "SelectButton5");
248 SelectButton5->setPixmap(image4);
249 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
251 LineEdit5 = new QLineEdit(SubGroup2, "LineEdit5");
252 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
254 TextLabel6 = new QLabel(SubGroup2, "TextLabel6");
255 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
257 SelectButton6 = new QPushButton(SubGroup2, "SelectButton6");
258 SelectButton6->setPixmap(image4);
259 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
261 LineEdit6 = new QLineEdit(SubGroup2, "LineEdit6");
262 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
264 // Add subgroups to the group of arguments
265 GroupArgumentsLayout->addWidget(SubGroup1, 0, 0);
266 GroupArgumentsLayout->addWidget(SubGroup2, 1, 0);
268 // Control for the merging equal elements
269 CheckBoxMerge = new QCheckBox(GroupArguments, "CheckBoxMerge");
270 CheckBoxMerge->setText(tr("MERGE_EQUAL_ELEMENTS" ));
271 GroupArgumentsLayout->addWidget(CheckBoxMerge, 2, 0);
273 // Control for the polygons creation instead of splitting
274 CheckBoxPolygons = new QCheckBox( GroupArguments, "CheckBoxPolygons" );
275 CheckBoxPolygons->setText( tr( "CREATE_POLYGONS_INSTEAD_SPLITTING" ) );
276 GroupArgumentsLayout->addWidget( CheckBoxPolygons, 3, 0 );
278 // Control for the polyedres creation to obtain conform mesh
279 CheckBoxPolyedrs = new QCheckBox( GroupArguments, "CheckBoxPolyedrs" );
280 CheckBoxPolyedrs->setText( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ) );
281 GroupArgumentsLayout->addWidget( CheckBoxPolyedrs, 4, 0 );
284 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments, 1, 0);
286 /* Initialisations */
287 GroupArguments->show();
288 RadioButton1->setChecked(TRUE);
290 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
291 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
292 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
293 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
295 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
297 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
299 myHelpFileName = "sewing_meshes_page.html";
303 /* signals and slots connections */
304 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
305 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
306 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
307 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
308 connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
310 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
311 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
312 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
313 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
314 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
315 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
317 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
318 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
319 /* to close dialog if study change */
320 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
322 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
323 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
324 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
325 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
326 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
327 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
329 this->show(); /* displays Dialog */
331 ConstructorsClicked(0);
335 //=================================================================================
336 // function : ~SMESHGUI_SewingDlg()
337 // purpose : Destroys the object and frees any allocated resources
338 //=================================================================================
339 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
341 // no need to delete child widgets, Qt does it all for us
344 //=================================================================================
347 //=================================================================================
348 void SMESHGUI_SewingDlg::Init()
352 myEditCurrentArgument = LineEdit1;
353 LineEdit1->setFocus();
355 myMesh = SMESH::SMESH_Mesh::_nil();
356 CheckBoxMerge->setChecked(false);
357 CheckBoxPolygons->setChecked(false);
358 CheckBoxPolyedrs->setChecked(false);
359 SelectionIntoArgument();
362 //=================================================================================
363 // function : ConstructorsClicked()
364 // purpose : Radio button management
365 //=================================================================================
366 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
368 disconnect(mySelectionMgr, 0, this, 0);
370 mySelectionMgr->selectedObjects( io );
371 mySelectionMgr->clearSelected();
372 LineEdit1->setText("");
373 LineEdit2->setText("");
374 LineEdit3->setText("");
375 LineEdit4->setText("");
376 LineEdit5->setText("");
377 LineEdit6->setText("");
378 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
379 myEditCurrentArgument = LineEdit1;
380 myEditCurrentArgument->setFocus();
382 if (!TextLabel5->isEnabled()) {
383 TextLabel5->setEnabled(true);
384 SelectButton5->setEnabled(true);
385 LineEdit5->setEnabled(true);
386 } else if (!TextLabel6->isEnabled()) {
387 TextLabel6->setEnabled(true);
388 SelectButton6->setEnabled(true);
389 LineEdit6->setEnabled(true);
392 if (constructorId == 1 || constructorId == 3) {
393 if (CheckBoxPolygons->isVisible())
394 CheckBoxPolygons->hide();
395 if (CheckBoxPolyedrs->isVisible())
396 CheckBoxPolyedrs->hide();
399 switch (constructorId) {
402 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
403 SubGroup1->setTitle(tr("BORDER_1"));
404 SubGroup2->setTitle(tr("BORDER_2"));
406 if (!CheckBoxPolygons->isVisible())
407 CheckBoxPolygons->show();
408 if (!CheckBoxPolyedrs->isVisible())
409 CheckBoxPolyedrs->show();
416 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
417 SubGroup1->setTitle(tr("BORDER_1"));
418 SubGroup2->setTitle(tr("BORDER_2"));
420 TextLabel6->setEnabled(false);
421 SelectButton6->setEnabled(false);
422 LineEdit6->setEnabled(false);
430 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
431 SubGroup1->setTitle(tr("BORDER"));
432 SubGroup2->setTitle(tr("SIDE"));
434 TextLabel5->setEnabled(false);
435 SelectButton5->setEnabled(false);
436 LineEdit5->setEnabled(false);
438 if (!CheckBoxPolygons->isVisible())
439 CheckBoxPolygons->show();
440 if (!CheckBoxPolyedrs->isVisible())
441 CheckBoxPolyedrs->show();
450 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
451 SubGroup1->setTitle(tr("SIDE_1"));
452 SubGroup2->setTitle(tr("SIDE_2"));
454 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
455 TextLabel2->setText(tr("NODE1_TO_MERGE"));
456 TextLabel3->setText(tr("NODE2_TO_MERGE"));
457 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
458 TextLabel5->setText(tr("NODE1_TO_MERGE"));
459 TextLabel6->setText(tr("NODE2_TO_MERGE"));
461 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator"));
462 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator"));
464 SMESH::SetPointRepresentation(false);
466 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
467 aViewWindow->SetSelectionMode(CellSelection);
472 if (constructorId != 3) {
473 TextLabel1->setText(tr("FIRST_NODE_ID"));
474 TextLabel2->setText(tr("SECOND_NODE_ID"));
475 TextLabel3->setText(tr("LAST_NODE_ID"));
476 TextLabel4->setText(tr("FIRST_NODE_ID"));
477 TextLabel5->setText(tr("SECOND_NODE_ID"));
478 TextLabel6->setText(tr("LAST_NODE_ID"));
480 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
481 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
483 SMESH::SetPointRepresentation(true);
485 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
486 aViewWindow->SetSelectionMode(NodeSelection);
489 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
490 mySelectionMgr->setSelectedObjects( io );
493 //=================================================================================
494 // function : ClickOnApply()
496 //=================================================================================
497 bool SMESHGUI_SewingDlg::ClickOnApply()
499 if (mySMESHGUI->isActiveStudyLocked())
502 bool aResult = false;
505 bool toMerge = CheckBoxMerge->isChecked();
506 bool toCreatePolygons = CheckBoxPolygons->isChecked();
507 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
510 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
511 QApplication::setOverrideCursor(Qt::waitCursor);
513 int aConstructorId = GetConstructorId();
514 SMESH::SMESH_MeshEditor::Sew_Error anError;
516 if (aConstructorId == 0)
517 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
518 LineEdit2->text().toLong(),
519 LineEdit3->text().toLong(),
520 LineEdit4->text().toLong(),
521 LineEdit5->text().toLong(),
522 LineEdit6->text().toLong(),
525 else if (aConstructorId == 1)
526 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
527 LineEdit2->text().toLong(),
528 LineEdit3->text().toLong(),
529 LineEdit4->text().toLong(),
530 LineEdit5->text().toLong());
531 else if (aConstructorId == 2)
532 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
533 LineEdit2->text().toLong(),
534 LineEdit3->text().toLong(),
535 LineEdit4->text().toLong(),
536 LineEdit6->text().toLong(),
539 else if (aConstructorId == 3) {
540 QStringList aListElementsId1 = QStringList::split(" ", LineEdit1->text(), false);
541 QStringList aListElementsId2 = QStringList::split(" ", LineEdit4->text(), false);
543 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
544 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
546 anElementsId1->length(aListElementsId1.count());
547 anElementsId2->length(aListElementsId2.count());
549 for (int i = 0; i < aListElementsId1.count(); i++)
550 anElementsId1[i] = aListElementsId1[i].toInt();
551 for (int i = 0; i < aListElementsId2.count(); i++)
552 anElementsId2[i] = aListElementsId2[i].toInt();
554 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
555 anElementsId2.inout(),
556 LineEdit2->text().toLong(),
557 LineEdit5->text().toLong(),
558 LineEdit3->text().toLong(),
559 LineEdit6->text().toLong());
561 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
563 if (toMerge && aResult)
564 aMeshEditor->MergeEqualElements();
566 QApplication::restoreOverrideCursor();
569 QString msg = tr(QString("ERROR_%1").arg(anError));
570 SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
571 msg, tr("SMESH_BUT_OK"));
577 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
581 mySelectionMgr->setSelectedObjects(aList, false);
585 ConstructorsClicked(GetConstructorId());
592 //=================================================================================
593 // function : ClickOnOk()
595 //=================================================================================
596 void SMESHGUI_SewingDlg::ClickOnOk()
602 //=================================================================================
603 // function : ClickOnCancel()
605 //=================================================================================
606 void SMESHGUI_SewingDlg::ClickOnCancel()
608 //mySelectionMgr->clearSelected();
609 SMESH::SetPointRepresentation(false);
610 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
611 aViewWindow->SetSelectionMode(ActorSelection);
612 disconnect(mySelectionMgr, 0, this, 0);
613 mySMESHGUI->ResetState();
617 //=================================================================================
618 // function : ClickOnHelp()
620 //=================================================================================
621 void SMESHGUI_SewingDlg::ClickOnHelp()
623 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
625 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
629 platform = "winapplication";
631 platform = "application";
633 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
634 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
635 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
636 QObject::tr("BUT_OK"));
640 //=======================================================================
641 //function : onTextChange
643 //=======================================================================
644 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
646 QLineEdit* send = (QLineEdit*)sender();
652 myEditCurrentArgument = send;
654 if (send == LineEdit1)
656 else if (send == LineEdit2)
658 else if (send == LineEdit3)
660 else if (send == LineEdit4)
662 else if (send == LineEdit5)
664 else if (send == LineEdit6)
667 buttonOk->setEnabled(false);
668 buttonApply->setEnabled(false);
670 // hilight entered elements/nodes
671 SMDS_Mesh* aMesh = 0;
674 aMesh = myActor->GetObject()->GetMesh();
679 TColStd_MapOfInteger newIndices;
681 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
682 SMESH::SetPointRepresentation(true);
684 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
685 aViewWindow->SetSelectionMode(NodeSelection);
687 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
689 newIndices.Add(n->GetID());
690 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
691 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
692 aViewWindow->highlight( myActor->getIO(), true, true );
694 if (send == LineEdit1)
696 else if (send == LineEdit2)
698 else if (send == LineEdit3)
700 else if (send == LineEdit4)
702 else if (send == LineEdit5)
704 else if (send == LineEdit6)
708 SMESH::SetPointRepresentation(false);
710 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
711 aViewWindow->SetSelectionMode(CellSelection);
713 QStringList aListId = QStringList::split(" ", theNewText, false);
715 bool isEvenOneExists = false;
717 for (int i = 0; i < aListId.count(); i++) {
718 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
720 newIndices.Add(e->GetID());
722 if (!isEvenOneExists)
723 isEvenOneExists = true;
727 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
728 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
729 aViewWindow->highlight( myActor->getIO(), true, true );
731 if (isEvenOneExists) {
732 if (send == LineEdit1)
734 else if(send == LineEdit4)
743 buttonOk->setEnabled(true);
744 buttonApply->setEnabled(true);
750 //=================================================================================
751 // function : SelectionIntoArgument()
752 // purpose : Called when selection as changed or other case
753 //=================================================================================
754 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
759 if (isSelectionChanged)
762 QString aString = "";
765 myEditCurrentArgument->setText(aString);
768 if (!GroupButtons->isEnabled()) // inactive
771 buttonOk->setEnabled(false);
772 buttonApply->setEnabled(false);
776 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
778 int nbSel = aList.Extent();
782 Handle(SALOME_InteractiveObject) IO = aList.First();
783 myMesh = SMESH::GetMeshByIO(IO); //@ SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
784 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
786 if (myMesh->_is_nil() || !myActor)
789 // get selected elements/nodes
792 if (GetConstructorId() != 3 ||
793 (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) {
794 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
798 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
804 myEditCurrentArgument->setText(aString);
808 if (myEditCurrentArgument == LineEdit1)
810 else if (myEditCurrentArgument == LineEdit2)
812 else if (myEditCurrentArgument == LineEdit3)
814 else if (myEditCurrentArgument == LineEdit4)
816 else if (myEditCurrentArgument == LineEdit5)
818 else if (myEditCurrentArgument == LineEdit6)
822 buttonOk->setEnabled(true);
823 buttonApply->setEnabled(true);
827 //=================================================================================
828 // function : SetEditCurrentArgument()
830 //=================================================================================
831 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
833 QPushButton* send = (QPushButton*)sender();
835 disconnect(mySelectionMgr, 0, this, 0);
836 mySelectionMgr->clearSelected();
838 if (send == SelectButton1) {
839 myEditCurrentArgument = LineEdit1;
842 else if (send == SelectButton2) {
843 myEditCurrentArgument = LineEdit2;
846 else if (send == SelectButton3) {
847 myEditCurrentArgument = LineEdit3;
850 else if (send == SelectButton4) {
851 myEditCurrentArgument = LineEdit4;
854 else if (send == SelectButton5) {
855 myEditCurrentArgument = LineEdit5;
858 else if (send == SelectButton6) {
859 myEditCurrentArgument = LineEdit6;
863 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
864 SMESH::SetPointRepresentation(true);
866 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
867 aViewWindow->SetSelectionMode(NodeSelection);
870 SMESH::SetPointRepresentation(false);
871 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
872 aViewWindow->SetSelectionMode(CellSelection);
875 myEditCurrentArgument->setFocus();
876 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
877 SelectionIntoArgument(false);
880 //=================================================================================
881 // function : DeactivateActiveDialog()
883 //=================================================================================
884 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
886 if (GroupConstructors->isEnabled()) {
887 GroupConstructors->setEnabled(false);
888 GroupArguments->setEnabled(false);
889 GroupButtons->setEnabled(false);
890 mySMESHGUI->ResetState();
891 mySMESHGUI->SetActiveDialogBox(0);
895 //=================================================================================
896 // function : ActivateThisDialog()
898 //=================================================================================
899 void SMESHGUI_SewingDlg::ActivateThisDialog()
901 /* Emit a signal to deactivate the active dialog */
902 mySMESHGUI->EmitSignalDeactivateDialog();
903 GroupConstructors->setEnabled(true);
904 GroupArguments->setEnabled(true);
905 GroupButtons->setEnabled(true);
907 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
909 ConstructorsClicked(GetConstructorId());
910 SelectionIntoArgument();
913 //=================================================================================
914 // function : enterEvent()
916 //=================================================================================
917 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
919 if (!GroupConstructors->isEnabled())
920 ActivateThisDialog();
923 //=================================================================================
924 // function : closeEvent()
926 //=================================================================================
927 void SMESHGUI_SewingDlg::closeEvent (QCloseEvent*)
929 /* same than click on cancel button */
930 this->ClickOnCancel();
933 //=======================================================================
934 //function : hideEvent
935 //purpose : caused by ESC key
936 //=======================================================================
937 void SMESHGUI_SewingDlg::hideEvent (QHideEvent*)
943 //=================================================================================
944 // function : GetConstructorId()
946 //=================================================================================
947 int SMESHGUI_SewingDlg::GetConstructorId()
949 if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
950 return GroupConstructors->id(GroupConstructors->selected());
954 //=================================================================================
955 // function : GetConstructorId()
957 //=================================================================================
958 bool SMESHGUI_SewingDlg::IsValid()
960 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);
963 //=================================================================================
964 // function : keyPressEvent()
966 //=================================================================================
967 void SMESHGUI_SewingDlg::keyPressEvent( QKeyEvent* e )
969 QDialog::keyPressEvent( e );
970 if ( e->isAccepted() )
973 if ( e->key() == Key_F1 )