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
22 // File : SMESHGUI_SewingDlg.cxx
23 // Author : Michael ZORIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_SewingDlg.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_MeshUtils.h"
33 #include "SMESHGUI_IdValidator.h"
35 #include <SMESH_Actor.h>
36 #include <SMDS_Mesh.hxx>
38 // SALOME GUI includes
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>
45 #include <LightApp_SelectionMgr.h>
47 #include <SVTK_ViewModel.h>
48 #include <SVTK_ViewWindow.h>
49 #include <SALOME_ListIO.hxx>
52 #include <TColStd_MapOfInteger.hxx>
55 #include <QApplication>
56 #include <QButtonGroup>
60 #include <QPushButton>
61 #include <QRadioButton>
63 #include <QHBoxLayout>
64 #include <QVBoxLayout>
65 #include <QGridLayout>
69 #include <SALOMEconfig.h>
70 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
75 //=================================================================================
76 // class : SMESHGUI_SewingDlg()
78 //=================================================================================
79 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule )
80 : QDialog( SMESH::GetDesktop( theModule ) ),
81 mySMESHGUI( theModule ),
82 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
84 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
85 QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS")));
86 QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS")));
87 QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE")));
88 QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS")));
89 QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
92 setAttribute(Qt::WA_DeleteOnClose, true);
93 setWindowTitle(tr("SMESH_SEWING"));
94 setSizeGripEnabled(true);
96 QVBoxLayout* SMESHGUI_SewingDlgLayout = new QVBoxLayout(this);
97 SMESHGUI_SewingDlgLayout->setSpacing(SPACING);
98 SMESHGUI_SewingDlgLayout->setMargin(MARGIN);
100 /***************************************************************/
101 ConstructorsBox = new QGroupBox(tr("SMESH_SEWING"), this);
102 GroupConstructors = new QButtonGroup(this);
103 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
104 ConstructorsBoxLayout->setSpacing(SPACING);
105 ConstructorsBoxLayout->setMargin(MARGIN);
107 RadioButton1 = new QRadioButton(ConstructorsBox);
108 RadioButton1->setIcon(image0);
109 RadioButton2 = new QRadioButton(ConstructorsBox);
110 RadioButton2->setIcon(image1);
111 RadioButton3 = new QRadioButton(ConstructorsBox);
112 RadioButton3->setIcon(image2);
113 RadioButton4 = new QRadioButton(ConstructorsBox);
114 RadioButton4->setIcon(image3);
116 ConstructorsBoxLayout->addWidget(RadioButton1);
117 ConstructorsBoxLayout->addWidget(RadioButton2);
118 ConstructorsBoxLayout->addWidget(RadioButton3);
119 ConstructorsBoxLayout->addWidget(RadioButton4);
120 GroupConstructors->addButton(RadioButton1, 0);
121 GroupConstructors->addButton(RadioButton2, 1);
122 GroupConstructors->addButton(RadioButton3, 2);
123 GroupConstructors->addButton(RadioButton4, 3);
125 /***************************************************************/
126 GroupArguments = new QGroupBox(this);
127 QVBoxLayout* GroupArgumentsLayout = new QVBoxLayout(GroupArguments);
128 GroupArgumentsLayout->setSpacing(SPACING);
129 GroupArgumentsLayout->setMargin(MARGIN);
132 SubGroup1 = new QGroupBox(GroupArguments);
133 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1);
134 SubGroup1Layout->setSpacing(SPACING);
135 SubGroup1Layout->setMargin(MARGIN);
137 // Controls of the first subgroup
138 TextLabel1 = new QLabel(SubGroup1);
139 SelectButton1 = new QPushButton(SubGroup1);
140 SelectButton1->setIcon(image4);
141 LineEdit1 = new QLineEdit(SubGroup1);
143 TextLabel2 = new QLabel(SubGroup1);
144 SelectButton2 = new QPushButton(SubGroup1);
145 SelectButton2->setIcon(image4);
146 LineEdit2 = new QLineEdit(SubGroup1);
148 TextLabel3 = new QLabel(SubGroup1);
149 SelectButton3 = new QPushButton(SubGroup1);
150 SelectButton3->setIcon(image4);
151 LineEdit3 = new QLineEdit(SubGroup1);
153 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
154 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
155 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
156 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
157 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
158 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
159 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
160 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
161 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
164 SubGroup2 = new QGroupBox(GroupArguments);
165 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2);
166 SubGroup2Layout->setSpacing(SPACING);
167 SubGroup2Layout->setMargin(MARGIN);
169 // Controls of the first subgroup
170 TextLabel4 = new QLabel(SubGroup2);
171 SelectButton4 = new QPushButton(SubGroup2);
172 SelectButton4->setIcon(image4);
173 LineEdit4 = new QLineEdit(SubGroup2);
175 TextLabel5 = new QLabel(SubGroup2);
176 SelectButton5 = new QPushButton(SubGroup2);
177 SelectButton5->setIcon(image4);
178 LineEdit5 = new QLineEdit(SubGroup2);
180 TextLabel6 = new QLabel(SubGroup2);
181 SelectButton6 = new QPushButton(SubGroup2);
182 SelectButton6->setIcon(image4);
183 LineEdit6 = new QLineEdit(SubGroup2);
185 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
186 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
187 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
188 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
189 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
190 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
191 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
192 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
193 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
195 // Control for the merging equal elements
196 CheckBoxMerge = new QCheckBox(tr("MERGE_EQUAL_ELEMENTS"), GroupArguments);
198 // Control for the polygons creation instead of splitting
199 CheckBoxPolygons = new QCheckBox(tr("CREATE_POLYGONS_INSTEAD_SPLITTING"), GroupArguments);
201 // Control for the polyedres creation to obtain conform mesh
202 CheckBoxPolyedrs = new QCheckBox(tr("CREATE_POLYEDRS_NEAR_BOUNDARY"), GroupArguments);
205 GroupArgumentsLayout->addWidget(SubGroup1);
206 GroupArgumentsLayout->addWidget(SubGroup2);
207 GroupArgumentsLayout->addWidget(CheckBoxMerge);
208 GroupArgumentsLayout->addWidget(CheckBoxPolygons);
209 GroupArgumentsLayout->addWidget(CheckBoxPolyedrs);
211 /***************************************************************/
212 GroupButtons = new QGroupBox(this);
213 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
214 GroupButtonsLayout->setSpacing(SPACING);
215 GroupButtonsLayout->setMargin(MARGIN);
217 buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons);
218 buttonOk->setAutoDefault(true);
219 buttonOk->setDefault(true);
220 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
221 buttonApply->setAutoDefault(true);
222 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
223 buttonCancel->setAutoDefault(true);
224 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
225 buttonHelp->setAutoDefault(true);
227 GroupButtonsLayout->addWidget(buttonOk);
228 GroupButtonsLayout->addSpacing(10);
229 GroupButtonsLayout->addWidget(buttonApply);
230 GroupButtonsLayout->addSpacing(10);
231 GroupButtonsLayout->addStretch();
232 GroupButtonsLayout->addWidget(buttonCancel);
233 GroupButtonsLayout->addWidget(buttonHelp);
235 /***************************************************************/
236 SMESHGUI_SewingDlgLayout->addWidget(ConstructorsBox);
237 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments);
238 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons);
240 /* Initialisations */
241 RadioButton1->setChecked(true);
243 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, 1));
244 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, 1));
245 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, 1));
246 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, 1));
248 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
250 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
252 myHelpFileName = "sewing_meshes_page.html";
256 /* signals and slots connections */
257 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
258 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
259 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
260 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
261 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
263 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
264 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
265 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
266 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
267 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
268 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
270 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
271 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
272 /* to close dialog if study change */
273 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
275 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
276 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
277 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
278 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
279 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
280 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
282 ConstructorsClicked(0);
285 //=================================================================================
286 // function : ~SMESHGUI_SewingDlg()
287 // purpose : Destroys the object and frees any allocated resources
288 //=================================================================================
289 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
293 //=================================================================================
296 //=================================================================================
297 void SMESHGUI_SewingDlg::Init()
301 myEditCurrentArgument = LineEdit1;
302 LineEdit1->setFocus();
304 myMesh = SMESH::SMESH_Mesh::_nil();
305 CheckBoxMerge->setChecked(false);
306 CheckBoxPolygons->setChecked(false);
307 CheckBoxPolyedrs->setChecked(false);
308 SelectionIntoArgument();
311 //=================================================================================
312 // function : ConstructorsClicked()
313 // purpose : Radio button management
314 //=================================================================================
315 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
317 disconnect(mySelectionMgr, 0, this, 0);
319 mySelectionMgr->selectedObjects( io );
320 mySelectionMgr->clearSelected();
321 LineEdit1->setText("");
322 LineEdit2->setText("");
323 LineEdit3->setText("");
324 LineEdit4->setText("");
325 LineEdit5->setText("");
326 LineEdit6->setText("");
327 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
328 myEditCurrentArgument = LineEdit1;
329 myEditCurrentArgument->setFocus();
331 if (!TextLabel5->isEnabled()) {
332 TextLabel5->setEnabled(true);
333 SelectButton5->setEnabled(true);
334 LineEdit5->setEnabled(true);
335 } else if (!TextLabel6->isEnabled()) {
336 TextLabel6->setEnabled(true);
337 SelectButton6->setEnabled(true);
338 LineEdit6->setEnabled(true);
341 if (constructorId == 1 || constructorId == 3) {
342 if (CheckBoxPolygons->isVisible())
343 CheckBoxPolygons->hide();
344 if (CheckBoxPolyedrs->isVisible())
345 CheckBoxPolyedrs->hide();
348 switch (constructorId) {
351 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
352 SubGroup1->setTitle(tr("BORDER_1"));
353 SubGroup2->setTitle(tr("BORDER_2"));
355 if (!CheckBoxPolygons->isVisible())
356 CheckBoxPolygons->show();
357 if (!CheckBoxPolyedrs->isVisible())
358 CheckBoxPolyedrs->show();
364 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
365 SubGroup1->setTitle(tr("BORDER_1"));
366 SubGroup2->setTitle(tr("BORDER_2"));
368 TextLabel6->setEnabled(false);
369 SelectButton6->setEnabled(false);
370 LineEdit6->setEnabled(false);
378 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
379 SubGroup1->setTitle(tr("BORDER"));
380 SubGroup2->setTitle(tr("SIDE"));
382 TextLabel5->setEnabled(false);
383 SelectButton5->setEnabled(false);
384 LineEdit5->setEnabled(false);
386 if (!CheckBoxPolygons->isVisible())
387 CheckBoxPolygons->show();
388 if (!CheckBoxPolyedrs->isVisible())
389 CheckBoxPolyedrs->show();
397 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
398 SubGroup1->setTitle(tr("SIDE_1"));
399 SubGroup2->setTitle(tr("SIDE_2"));
401 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
402 TextLabel2->setText(tr("NODE1_TO_MERGE"));
403 TextLabel3->setText(tr("NODE2_TO_MERGE"));
404 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
405 TextLabel5->setText(tr("NODE1_TO_MERGE"));
406 TextLabel6->setText(tr("NODE2_TO_MERGE"));
408 LineEdit1->setValidator(new SMESHGUI_IdValidator(this));
409 LineEdit4->setValidator(new SMESHGUI_IdValidator(this));
411 SMESH::SetPointRepresentation(false);
413 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
414 aViewWindow->SetSelectionMode(CellSelection);
419 if (constructorId != 3) {
420 TextLabel1->setText(tr("FIRST_NODE_ID"));
421 TextLabel2->setText(tr("SECOND_NODE_ID"));
422 TextLabel3->setText(tr("LAST_NODE_ID"));
423 TextLabel4->setText(tr("FIRST_NODE_ID"));
424 TextLabel5->setText(tr("SECOND_NODE_ID"));
425 TextLabel6->setText(tr("LAST_NODE_ID"));
427 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, 1));
428 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, 1));
430 SMESH::SetPointRepresentation(true);
432 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
433 aViewWindow->SetSelectionMode(NodeSelection);
436 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
437 mySelectionMgr->setSelectedObjects( io );
439 QApplication::instance()->processEvents();
441 resize( minimumSize() );
444 //=================================================================================
445 // function : ClickOnApply()
447 //=================================================================================
448 bool SMESHGUI_SewingDlg::ClickOnApply()
450 if (mySMESHGUI->isActiveStudyLocked())
453 bool aResult = false;
456 bool toMerge = CheckBoxMerge->isChecked();
457 bool toCreatePolygons = CheckBoxPolygons->isChecked();
458 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
461 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
462 QApplication::setOverrideCursor(Qt::WaitCursor);
464 int aConstructorId = GetConstructorId();
465 SMESH::SMESH_MeshEditor::Sew_Error anError;
467 if (aConstructorId == 0)
468 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
469 LineEdit2->text().toLong(),
470 LineEdit3->text().toLong(),
471 LineEdit4->text().toLong(),
472 LineEdit5->text().toLong(),
473 LineEdit6->text().toLong(),
476 else if (aConstructorId == 1)
477 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
478 LineEdit2->text().toLong(),
479 LineEdit3->text().toLong(),
480 LineEdit4->text().toLong(),
481 LineEdit5->text().toLong());
482 else if (aConstructorId == 2)
483 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
484 LineEdit2->text().toLong(),
485 LineEdit3->text().toLong(),
486 LineEdit4->text().toLong(),
487 LineEdit6->text().toLong(),
490 else if (aConstructorId == 3) {
491 QStringList aListElementsId1 = LineEdit1->text().split(" ", QString::SkipEmptyParts);
492 QStringList aListElementsId2 = LineEdit4->text().split(" ", QString::SkipEmptyParts);
494 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
495 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
497 anElementsId1->length(aListElementsId1.count());
498 anElementsId2->length(aListElementsId2.count());
500 for (int i = 0; i < aListElementsId1.count(); i++)
501 anElementsId1[i] = aListElementsId1[i].toInt();
502 for (int i = 0; i < aListElementsId2.count(); i++)
503 anElementsId2[i] = aListElementsId2[i].toInt();
505 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
506 anElementsId2.inout(),
507 LineEdit2->text().toLong(),
508 LineEdit5->text().toLong(),
509 LineEdit3->text().toLong(),
510 LineEdit6->text().toLong());
512 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
514 if (toMerge && aResult)
515 aMeshEditor->MergeEqualElements();
517 QApplication::restoreOverrideCursor();
520 QString msg = tr(QString("ERROR_%1").arg(anError).toLatin1().data());
521 SUIT_MessageBox::warning(this, tr("SMESH_WRN_WARNING"), msg);
527 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
531 mySelectionMgr->setSelectedObjects(aList, false);
535 ConstructorsClicked(GetConstructorId());
542 //=================================================================================
543 // function : ClickOnOk()
545 //=================================================================================
546 void SMESHGUI_SewingDlg::ClickOnOk()
552 //=================================================================================
553 // function : ClickOnCancel()
555 //=================================================================================
556 void SMESHGUI_SewingDlg::ClickOnCancel()
558 //mySelectionMgr->clearSelected();
559 SMESH::SetPointRepresentation(false);
560 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
561 aViewWindow->SetSelectionMode(ActorSelection);
562 disconnect(mySelectionMgr, 0, this, 0);
563 mySMESHGUI->ResetState();
567 //=================================================================================
568 // function : ClickOnHelp()
570 //=================================================================================
571 void SMESHGUI_SewingDlg::ClickOnHelp()
573 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
575 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
579 platform = "winapplication";
581 platform = "application";
583 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
584 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
585 arg(app->resourceMgr()->stringValue("ExternalBrowser",
587 arg(myHelpFileName));
591 //=======================================================================
592 //function : onTextChange
594 //=======================================================================
595 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
597 QLineEdit* send = (QLineEdit*)sender();
603 myEditCurrentArgument = send;
605 if (send == LineEdit1)
607 else if (send == LineEdit2)
609 else if (send == LineEdit3)
611 else if (send == LineEdit4)
613 else if (send == LineEdit5)
615 else if (send == LineEdit6)
618 buttonOk->setEnabled(false);
619 buttonApply->setEnabled(false);
621 // hilight entered elements/nodes
622 SMDS_Mesh* aMesh = 0;
625 aMesh = myActor->GetObject()->GetMesh();
630 TColStd_MapOfInteger newIndices;
632 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
633 SMESH::SetPointRepresentation(true);
635 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
636 aViewWindow->SetSelectionMode(NodeSelection);
638 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
640 newIndices.Add(n->GetID());
641 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
642 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
643 aViewWindow->highlight( myActor->getIO(), true, true );
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)
659 SMESH::SetPointRepresentation(false);
661 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
662 aViewWindow->SetSelectionMode(CellSelection);
664 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
666 bool isEvenOneExists = false;
668 for (int i = 0; i < aListId.count(); i++) {
669 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
671 newIndices.Add(e->GetID());
673 if (!isEvenOneExists)
674 isEvenOneExists = true;
678 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
679 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
680 aViewWindow->highlight( myActor->getIO(), true, true );
682 if (isEvenOneExists) {
683 if (send == LineEdit1)
685 else if(send == LineEdit4)
694 buttonOk->setEnabled(true);
695 buttonApply->setEnabled(true);
701 //=================================================================================
702 // function : SelectionIntoArgument()
703 // purpose : Called when selection as changed or other case
704 //=================================================================================
705 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
710 if (isSelectionChanged)
713 QString aString = "";
716 myEditCurrentArgument->setText(aString);
719 if (!GroupButtons->isEnabled()) // inactive
722 buttonOk->setEnabled(false);
723 buttonApply->setEnabled(false);
727 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
729 int nbSel = aList.Extent();
733 Handle(SALOME_InteractiveObject) IO = aList.First();
734 myMesh = SMESH::GetMeshByIO(IO); //@ SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
735 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
737 if (myMesh->_is_nil() || !myActor)
740 // get selected elements/nodes
743 if (GetConstructorId() != 3 ||
744 (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) {
745 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
749 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
755 myEditCurrentArgument->setText(aString);
759 if (myEditCurrentArgument == LineEdit1)
761 else if (myEditCurrentArgument == LineEdit2)
763 else if (myEditCurrentArgument == LineEdit3)
765 else if (myEditCurrentArgument == LineEdit4)
767 else if (myEditCurrentArgument == LineEdit5)
769 else if (myEditCurrentArgument == LineEdit6)
773 buttonOk->setEnabled(true);
774 buttonApply->setEnabled(true);
778 //=================================================================================
779 // function : SetEditCurrentArgument()
781 //=================================================================================
782 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
784 QPushButton* send = (QPushButton*)sender();
786 disconnect(mySelectionMgr, 0, this, 0);
787 mySelectionMgr->clearSelected();
789 if (send == SelectButton1) {
790 myEditCurrentArgument = LineEdit1;
793 else if (send == SelectButton2) {
794 myEditCurrentArgument = LineEdit2;
797 else if (send == SelectButton3) {
798 myEditCurrentArgument = LineEdit3;
801 else if (send == SelectButton4) {
802 myEditCurrentArgument = LineEdit4;
805 else if (send == SelectButton5) {
806 myEditCurrentArgument = LineEdit5;
809 else if (send == SelectButton6) {
810 myEditCurrentArgument = LineEdit6;
814 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
815 SMESH::SetPointRepresentation(true);
817 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
818 aViewWindow->SetSelectionMode(NodeSelection);
821 SMESH::SetPointRepresentation(false);
822 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
823 aViewWindow->SetSelectionMode(CellSelection);
826 myEditCurrentArgument->setFocus();
827 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
828 SelectionIntoArgument(false);
831 //=================================================================================
832 // function : DeactivateActiveDialog()
834 //=================================================================================
835 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
837 if (ConstructorsBox->isEnabled()) {
838 ConstructorsBox->setEnabled(false);
839 GroupArguments->setEnabled(false);
840 GroupButtons->setEnabled(false);
841 mySMESHGUI->ResetState();
842 mySMESHGUI->SetActiveDialogBox(0);
846 //=================================================================================
847 // function : ActivateThisDialog()
849 //=================================================================================
850 void SMESHGUI_SewingDlg::ActivateThisDialog()
852 /* Emit a signal to deactivate the active dialog */
853 mySMESHGUI->EmitSignalDeactivateDialog();
854 ConstructorsBox->setEnabled(true);
855 GroupArguments->setEnabled(true);
856 GroupButtons->setEnabled(true);
858 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
860 ConstructorsClicked(GetConstructorId());
861 SelectionIntoArgument();
864 //=================================================================================
865 // function : enterEvent()
867 //=================================================================================
868 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
870 if (!ConstructorsBox->isEnabled())
871 ActivateThisDialog();
874 //=================================================================================
875 // function : closeEvent()
877 //=================================================================================
878 void SMESHGUI_SewingDlg::closeEvent (QCloseEvent*)
880 /* same than click on cancel button */
884 //=======================================================================
885 //function : hideEvent
886 //purpose : caused by ESC key
887 //=======================================================================
888 void SMESHGUI_SewingDlg::hideEvent (QHideEvent*)
894 //=================================================================================
895 // function : GetConstructorId()
897 //=================================================================================
898 int SMESHGUI_SewingDlg::GetConstructorId()
900 return GroupConstructors->checkedId();
903 //=================================================================================
904 // function : GetConstructorId()
906 //=================================================================================
907 bool SMESHGUI_SewingDlg::IsValid()
909 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);
912 //=================================================================================
913 // function : keyPressEvent()
915 //=================================================================================
916 void SMESHGUI_SewingDlg::keyPressEvent( QKeyEvent* e )
918 QDialog::keyPressEvent( e );
919 if ( e->isAccepted() )
922 if ( e->key() == Qt::Key_F1 ) {