1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_SewingDlg.cxx
25 // Author : Michael ZORIN, Open CASCADE S.A.S.
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 // SALOME GUI includes
40 #include <SUIT_Session.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Desktop.h>
43 #include <SUIT_MessageBox.h>
44 #include <SUIT_OverrideCursor.h>
46 #include <LightApp_Application.h>
47 #include <LightApp_SelectionMgr.h>
49 #include <SVTK_ViewModel.h>
50 #include <SVTK_ViewWindow.h>
51 #include <SALOME_ListIO.hxx>
54 #include <TColStd_MapOfInteger.hxx>
57 #include <QApplication>
58 #include <QButtonGroup>
62 #include <QPushButton>
63 #include <QRadioButton>
65 #include <QHBoxLayout>
66 #include <QVBoxLayout>
67 #include <QGridLayout>
71 #include <SALOMEconfig.h>
72 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
77 //=================================================================================
78 // class : SMESHGUI_SewingDlg()
80 //=================================================================================
81 SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule )
82 : QDialog( SMESH::GetDesktop( theModule ) ),
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 setAttribute(Qt::WA_DeleteOnClose, true);
95 setWindowTitle(tr("SMESH_SEWING"));
96 setSizeGripEnabled(true);
98 QVBoxLayout* SMESHGUI_SewingDlgLayout = new QVBoxLayout(this);
99 SMESHGUI_SewingDlgLayout->setSpacing(SPACING);
100 SMESHGUI_SewingDlgLayout->setMargin(MARGIN);
102 /***************************************************************/
103 ConstructorsBox = new QGroupBox(tr("SMESH_SEWING"), this);
104 GroupConstructors = new QButtonGroup(this);
105 QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
106 ConstructorsBoxLayout->setSpacing(SPACING);
107 ConstructorsBoxLayout->setMargin(MARGIN);
109 RadioButton1 = new QRadioButton(ConstructorsBox);
110 RadioButton1->setIcon(image0);
111 RadioButton2 = new QRadioButton(ConstructorsBox);
112 RadioButton2->setIcon(image1);
113 RadioButton3 = new QRadioButton(ConstructorsBox);
114 RadioButton3->setIcon(image2);
115 RadioButton4 = new QRadioButton(ConstructorsBox);
116 RadioButton4->setIcon(image3);
118 ConstructorsBoxLayout->addWidget(RadioButton1);
119 ConstructorsBoxLayout->addWidget(RadioButton2);
120 ConstructorsBoxLayout->addWidget(RadioButton3);
121 ConstructorsBoxLayout->addWidget(RadioButton4);
122 GroupConstructors->addButton(RadioButton1, 0);
123 GroupConstructors->addButton(RadioButton2, 1);
124 GroupConstructors->addButton(RadioButton3, 2);
125 GroupConstructors->addButton(RadioButton4, 3);
127 /***************************************************************/
128 GroupArguments = new QGroupBox(this);
129 QVBoxLayout* GroupArgumentsLayout = new QVBoxLayout(GroupArguments);
130 GroupArgumentsLayout->setSpacing(SPACING);
131 GroupArgumentsLayout->setMargin(MARGIN);
134 SubGroup1 = new QGroupBox(GroupArguments);
135 QGridLayout* SubGroup1Layout = new QGridLayout(SubGroup1);
136 SubGroup1Layout->setSpacing(SPACING);
137 SubGroup1Layout->setMargin(MARGIN);
139 // Controls of the first subgroup
140 TextLabel1 = new QLabel(SubGroup1);
141 SelectButton1 = new QPushButton(SubGroup1);
142 SelectButton1->setIcon(image4);
143 LineEdit1 = new QLineEdit(SubGroup1);
145 TextLabel2 = new QLabel(SubGroup1);
146 SelectButton2 = new QPushButton(SubGroup1);
147 SelectButton2->setIcon(image4);
148 LineEdit2 = new QLineEdit(SubGroup1);
150 TextLabel3 = new QLabel(SubGroup1);
151 SelectButton3 = new QPushButton(SubGroup1);
152 SelectButton3->setIcon(image4);
153 LineEdit3 = new QLineEdit(SubGroup1);
155 SubGroup1Layout->addWidget(TextLabel1, 0, 0);
156 SubGroup1Layout->addWidget(SelectButton1, 0, 1);
157 SubGroup1Layout->addWidget(LineEdit1, 0, 2);
158 SubGroup1Layout->addWidget(TextLabel2, 1, 0);
159 SubGroup1Layout->addWidget(SelectButton2, 1, 1);
160 SubGroup1Layout->addWidget(LineEdit2, 1, 2);
161 SubGroup1Layout->addWidget(TextLabel3, 2, 0);
162 SubGroup1Layout->addWidget(SelectButton3, 2, 1);
163 SubGroup1Layout->addWidget(LineEdit3, 2, 2);
166 SubGroup2 = new QGroupBox(GroupArguments);
167 QGridLayout* SubGroup2Layout = new QGridLayout(SubGroup2);
168 SubGroup2Layout->setSpacing(SPACING);
169 SubGroup2Layout->setMargin(MARGIN);
171 // Controls of the first subgroup
172 TextLabel4 = new QLabel(SubGroup2);
173 SelectButton4 = new QPushButton(SubGroup2);
174 SelectButton4->setIcon(image4);
175 LineEdit4 = new QLineEdit(SubGroup2);
177 TextLabel5 = new QLabel(SubGroup2);
178 SelectButton5 = new QPushButton(SubGroup2);
179 SelectButton5->setIcon(image4);
180 LineEdit5 = new QLineEdit(SubGroup2);
182 TextLabel6 = new QLabel(SubGroup2);
183 SelectButton6 = new QPushButton(SubGroup2);
184 SelectButton6->setIcon(image4);
185 LineEdit6 = new QLineEdit(SubGroup2);
187 SubGroup2Layout->addWidget(TextLabel4, 0, 0);
188 SubGroup2Layout->addWidget(SelectButton4, 0, 1);
189 SubGroup2Layout->addWidget(LineEdit4, 0, 2);
190 SubGroup2Layout->addWidget(TextLabel5, 1, 0);
191 SubGroup2Layout->addWidget(SelectButton5, 1, 1);
192 SubGroup2Layout->addWidget(LineEdit5, 1, 2);
193 SubGroup2Layout->addWidget(TextLabel6, 2, 0);
194 SubGroup2Layout->addWidget(SelectButton6, 2, 1);
195 SubGroup2Layout->addWidget(LineEdit6, 2, 2);
197 // Control for the merging equal elements
198 CheckBoxMerge = new QCheckBox(tr("MERGE_EQUAL_ELEMENTS"), GroupArguments);
200 // Control for the polygons creation instead of splitting
201 CheckBoxPolygons = new QCheckBox(tr("CREATE_POLYGONS_INSTEAD_SPLITTING"), GroupArguments);
203 // Control for the polyedres creation to obtain conform mesh
204 CheckBoxPolyedrs = new QCheckBox(tr("CREATE_POLYEDRS_NEAR_BOUNDARY"), GroupArguments);
207 GroupArgumentsLayout->addWidget(SubGroup1);
208 GroupArgumentsLayout->addWidget(SubGroup2);
209 GroupArgumentsLayout->addWidget(CheckBoxMerge);
210 GroupArgumentsLayout->addWidget(CheckBoxPolygons);
211 GroupArgumentsLayout->addWidget(CheckBoxPolyedrs);
213 /***************************************************************/
214 GroupButtons = new QGroupBox(this);
215 QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
216 GroupButtonsLayout->setSpacing(SPACING);
217 GroupButtonsLayout->setMargin(MARGIN);
219 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
220 buttonOk->setAutoDefault(true);
221 buttonOk->setDefault(true);
222 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
223 buttonApply->setAutoDefault(true);
224 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
225 buttonCancel->setAutoDefault(true);
226 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
227 buttonHelp->setAutoDefault(true);
229 GroupButtonsLayout->addWidget(buttonOk);
230 GroupButtonsLayout->addSpacing(10);
231 GroupButtonsLayout->addWidget(buttonApply);
232 GroupButtonsLayout->addSpacing(10);
233 GroupButtonsLayout->addStretch();
234 GroupButtonsLayout->addWidget(buttonCancel);
235 GroupButtonsLayout->addWidget(buttonHelp);
237 /***************************************************************/
238 SMESHGUI_SewingDlgLayout->addWidget(ConstructorsBox);
239 SMESHGUI_SewingDlgLayout->addWidget(GroupArguments);
240 SMESHGUI_SewingDlgLayout->addWidget(GroupButtons);
242 /* Initialisations */
243 RadioButton1->setChecked(true);
245 LineEdit2->setValidator(new SMESHGUI_IdValidator(this, 1));
246 LineEdit3->setValidator(new SMESHGUI_IdValidator(this, 1));
247 LineEdit5->setValidator(new SMESHGUI_IdValidator(this, 1));
248 LineEdit6->setValidator(new SMESHGUI_IdValidator(this, 1));
250 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
252 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
254 myHelpFileName = "sewing_meshes_page.html";
258 /* signals and slots connections */
259 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
260 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
261 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
262 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
263 connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
265 connect(SelectButton1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
266 connect(SelectButton2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
267 connect(SelectButton3, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
268 connect(SelectButton4, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
269 connect(SelectButton5, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
270 connect(SelectButton6, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
272 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
273 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
274 /* to close dialog if study change */
275 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
276 connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView()));
277 connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView()));
279 connect(LineEdit1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
280 connect(LineEdit2, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
281 connect(LineEdit3, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
282 connect(LineEdit4, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
283 connect(LineEdit5, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
284 connect(LineEdit6, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
286 ConstructorsClicked(0);
289 //=================================================================================
290 // function : ~SMESHGUI_SewingDlg()
291 // purpose : Destroys the object and frees any allocated resources
292 //=================================================================================
293 SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg()
297 //=================================================================================
300 //=================================================================================
301 void SMESHGUI_SewingDlg::Init()
305 myEditCurrentArgument = LineEdit1;
306 LineEdit1->setFocus();
308 myMesh = SMESH::SMESH_Mesh::_nil();
309 CheckBoxMerge->setChecked(false);
310 CheckBoxPolygons->setChecked(false);
311 CheckBoxPolyedrs->setChecked(false);
312 SelectionIntoArgument();
315 //=================================================================================
316 // function : ConstructorsClicked()
317 // purpose : Radio button management
318 //=================================================================================
319 void SMESHGUI_SewingDlg::ConstructorsClicked (int constructorId)
321 disconnect(mySelectionMgr, 0, this, 0);
323 mySelectionMgr->selectedObjects( io );
324 mySelectionMgr->clearSelected();
325 LineEdit1->setText("");
326 LineEdit2->setText("");
327 LineEdit3->setText("");
328 LineEdit4->setText("");
329 LineEdit5->setText("");
330 LineEdit6->setText("");
331 myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false;
332 myEditCurrentArgument = LineEdit1;
333 myEditCurrentArgument->setFocus();
335 if (!TextLabel5->isEnabled()) {
336 TextLabel5->setEnabled(true);
337 SelectButton5->setEnabled(true);
338 LineEdit5->setEnabled(true);
339 } else if (!TextLabel6->isEnabled()) {
340 TextLabel6->setEnabled(true);
341 SelectButton6->setEnabled(true);
342 LineEdit6->setEnabled(true);
345 if (constructorId == 1 || constructorId == 3) {
346 if (CheckBoxPolygons->isVisible())
347 CheckBoxPolygons->hide();
348 if (CheckBoxPolyedrs->isVisible())
349 CheckBoxPolyedrs->hide();
352 switch (constructorId) {
355 GroupArguments->setTitle(tr("SEW_FREE_BORDERS"));
356 SubGroup1->setTitle(tr("BORDER_1"));
357 SubGroup2->setTitle(tr("BORDER_2"));
359 if (!CheckBoxPolygons->isVisible())
360 CheckBoxPolygons->show();
361 if (!CheckBoxPolyedrs->isVisible())
362 CheckBoxPolyedrs->show();
368 GroupArguments->setTitle(tr("SEW_CONFORM_FREE_BORDERS"));
369 SubGroup1->setTitle(tr("BORDER_1"));
370 SubGroup2->setTitle(tr("BORDER_2"));
372 TextLabel6->setEnabled(false);
373 SelectButton6->setEnabled(false);
374 LineEdit6->setEnabled(false);
382 GroupArguments->setTitle(tr("SEW_BORDER_TO_SIDE"));
383 SubGroup1->setTitle(tr("BORDER"));
384 SubGroup2->setTitle(tr("SIDE"));
386 TextLabel5->setEnabled(false);
387 SelectButton5->setEnabled(false);
388 LineEdit5->setEnabled(false);
390 if (!CheckBoxPolygons->isVisible())
391 CheckBoxPolygons->show();
392 if (!CheckBoxPolyedrs->isVisible())
393 CheckBoxPolyedrs->show();
401 GroupArguments->setTitle(tr("SEW_SIDE_ELEMENTS"));
402 SubGroup1->setTitle(tr("SIDE_1"));
403 SubGroup2->setTitle(tr("SIDE_2"));
405 TextLabel1->setText(tr("SMESH_ID_ELEMENTS"));
406 TextLabel2->setText(tr("NODE1_TO_MERGE"));
407 TextLabel3->setText(tr("NODE2_TO_MERGE"));
408 TextLabel4->setText(tr("SMESH_ID_ELEMENTS"));
409 TextLabel5->setText(tr("NODE1_TO_MERGE"));
410 TextLabel6->setText(tr("NODE2_TO_MERGE"));
412 LineEdit1->setValidator(new SMESHGUI_IdValidator(this));
413 LineEdit4->setValidator(new SMESHGUI_IdValidator(this));
415 SMESH::SetPointRepresentation(false);
417 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
418 aViewWindow->SetSelectionMode(CellSelection);
423 if (constructorId != 3) {
424 TextLabel1->setText(tr("FIRST_NODE_ID"));
425 TextLabel2->setText(tr("SECOND_NODE_ID"));
426 TextLabel3->setText(tr("LAST_NODE_ID"));
427 TextLabel4->setText(tr("FIRST_NODE_ID"));
428 TextLabel5->setText(tr("SECOND_NODE_ID"));
429 TextLabel6->setText(tr("LAST_NODE_ID"));
431 LineEdit1->setValidator(new SMESHGUI_IdValidator(this, 1));
432 LineEdit4->setValidator(new SMESHGUI_IdValidator(this, 1));
434 SMESH::SetPointRepresentation(true);
436 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
437 aViewWindow->SetSelectionMode(NodeSelection);
440 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
441 mySelectionMgr->setSelectedObjects( io );
443 QApplication::instance()->processEvents();
448 //=================================================================================
449 // function : ClickOnApply()
451 //=================================================================================
452 bool SMESHGUI_SewingDlg::ClickOnApply()
454 if (mySMESHGUI->isActiveStudyLocked())
457 bool aResult = false;
460 bool toMerge = CheckBoxMerge->isChecked();
461 bool toCreatePolygons = CheckBoxPolygons->isChecked();
462 bool toCreatePolyedrs = CheckBoxPolyedrs->isChecked();
465 SUIT_OverrideCursor aWaitCursor;
466 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
468 int aConstructorId = GetConstructorId();
469 SMESH::SMESH_MeshEditor::Sew_Error anError;
471 if (aConstructorId == 0)
472 anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(),
473 LineEdit2->text().toLong(),
474 LineEdit3->text().toLong(),
475 LineEdit4->text().toLong(),
476 LineEdit5->text().toLong(),
477 LineEdit6->text().toLong(),
480 else if (aConstructorId == 1)
481 anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(),
482 LineEdit2->text().toLong(),
483 LineEdit3->text().toLong(),
484 LineEdit4->text().toLong(),
485 LineEdit5->text().toLong());
486 else if (aConstructorId == 2)
487 anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(),
488 LineEdit2->text().toLong(),
489 LineEdit3->text().toLong(),
490 LineEdit4->text().toLong(),
491 LineEdit6->text().toLong(),
494 else if (aConstructorId == 3) {
495 QStringList aListElementsId1 = LineEdit1->text().split(" ", QString::SkipEmptyParts);
496 QStringList aListElementsId2 = LineEdit4->text().split(" ", QString::SkipEmptyParts);
498 SMESH::long_array_var anElementsId1 = new SMESH::long_array;
499 SMESH::long_array_var anElementsId2 = new SMESH::long_array;
501 anElementsId1->length(aListElementsId1.count());
502 anElementsId2->length(aListElementsId2.count());
504 for (int i = 0; i < aListElementsId1.count(); i++)
505 anElementsId1[i] = aListElementsId1[i].toInt();
506 for (int i = 0; i < aListElementsId2.count(); i++)
507 anElementsId2[i] = aListElementsId2[i].toInt();
509 anError = aMeshEditor->SewSideElements(anElementsId1.inout(),
510 anElementsId2.inout(),
511 LineEdit2->text().toLong(),
512 LineEdit5->text().toLong(),
513 LineEdit3->text().toLong(),
514 LineEdit6->text().toLong());
516 aResult = (anError == SMESH::SMESH_MeshEditor::SEW_OK);
518 if (toMerge && aResult)
519 aMeshEditor->MergeEqualElements();
522 QString msg = tr(QString("ERROR_%1").arg(anError).toLatin1().data());
523 SUIT_MessageBox::warning(this, tr("SMESH_WRN_WARNING"), msg);
529 Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
533 mySelectionMgr->setSelectedObjects(aList, false);
537 ConstructorsClicked(GetConstructorId());
539 SMESHGUI::Modified();
546 //=================================================================================
547 // function : ClickOnOk()
549 //=================================================================================
550 void SMESHGUI_SewingDlg::ClickOnOk()
556 //=================================================================================
557 // function : onOpenView()
559 //=================================================================================
560 void SMESHGUI_SewingDlg::onOpenView()
563 SMESH::SetPointRepresentation(false);
566 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
567 ActivateThisDialog();
571 //=================================================================================
572 // function : onCloseView()
574 //=================================================================================
575 void SMESHGUI_SewingDlg::onCloseView()
577 DeactivateActiveDialog();
581 //=================================================================================
582 // function : reject()
584 //=================================================================================
585 void SMESHGUI_SewingDlg::reject()
587 //mySelectionMgr->clearSelected();
588 SMESH::SetPointRepresentation(false);
589 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
590 aViewWindow->SetSelectionMode(ActorSelection);
591 disconnect(mySelectionMgr, 0, this, 0);
592 mySMESHGUI->ResetState();
596 //=================================================================================
597 // function : ClickOnHelp()
599 //=================================================================================
600 void SMESHGUI_SewingDlg::ClickOnHelp()
602 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
604 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
608 platform = "winapplication";
610 platform = "application";
612 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
613 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
614 arg(app->resourceMgr()->stringValue("ExternalBrowser",
616 arg(myHelpFileName));
620 //=======================================================================
621 //function : onTextChange
623 //=======================================================================
624 void SMESHGUI_SewingDlg::onTextChange (const QString& theNewText)
626 QLineEdit* send = (QLineEdit*)sender();
632 myEditCurrentArgument = send;
634 if (send == LineEdit1)
636 else if (send == LineEdit2)
638 else if (send == LineEdit3)
640 else if (send == LineEdit4)
642 else if (send == LineEdit5)
644 else if (send == LineEdit6)
647 buttonOk->setEnabled(false);
648 buttonApply->setEnabled(false);
650 // hilight entered elements/nodes
651 SMDS_Mesh* aMesh = 0;
654 aMesh = myActor->GetObject()->GetMesh();
659 TColStd_MapOfInteger newIndices;
661 if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) {
662 SMESH::SetPointRepresentation(true);
664 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
665 aViewWindow->SetSelectionMode(NodeSelection);
667 const SMDS_MeshNode * n = aMesh->FindNode(theNewText.toInt());
669 newIndices.Add(n->GetID());
670 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
671 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
672 aViewWindow->highlight( myActor->getIO(), true, true );
674 if (send == LineEdit1)
676 else if (send == LineEdit2)
678 else if (send == LineEdit3)
680 else if (send == LineEdit4)
682 else if (send == LineEdit5)
684 else if (send == LineEdit6)
688 SMESH::SetPointRepresentation(false);
690 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
691 aViewWindow->SetSelectionMode(CellSelection);
693 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
695 bool isEvenOneExists = false;
697 for (int i = 0; i < aListId.count(); i++) {
698 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
700 newIndices.Add(e->GetID());
702 if (!isEvenOneExists)
703 isEvenOneExists = true;
706 mySelector->AddOrRemoveIndex(myActor->getIO(), newIndices, false);
707 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
708 aViewWindow->highlight( myActor->getIO(), true, true );
710 if (isEvenOneExists) {
711 if (send == LineEdit1)
713 else if(send == LineEdit4)
722 buttonOk->setEnabled(true);
723 buttonApply->setEnabled(true);
729 //=================================================================================
730 // function : SelectionIntoArgument()
731 // purpose : Called when selection as changed or other case
732 //=================================================================================
733 void SMESHGUI_SewingDlg::SelectionIntoArgument (bool isSelectionChanged)
738 if (isSelectionChanged)
741 QString aString = "";
744 myEditCurrentArgument->setText(aString);
747 if (!GroupButtons->isEnabled()) // inactive
750 buttonOk->setEnabled(false);
751 buttonApply->setEnabled(false);
755 mySelectionMgr->selectedObjects(aList);
757 int nbSel = aList.Extent();
761 Handle(SALOME_InteractiveObject) IO = aList.First();
762 myMesh = SMESH::GetMeshByIO(IO); //@ SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
763 myActor = SMESH::FindActorByEntry(aList.First()->getEntry());
765 if (myMesh->_is_nil() || !myActor)
768 // get selected elements/nodes
770 if (GetConstructorId() != 3 ||
771 (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) {
772 aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
776 aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
782 myEditCurrentArgument->setText(aString);
786 if (myEditCurrentArgument == LineEdit1)
788 else if (myEditCurrentArgument == LineEdit2)
790 else if (myEditCurrentArgument == LineEdit3)
792 else if (myEditCurrentArgument == LineEdit4)
794 else if (myEditCurrentArgument == LineEdit5)
796 else if (myEditCurrentArgument == LineEdit6)
800 buttonOk->setEnabled(true);
801 buttonApply->setEnabled(true);
805 //=================================================================================
806 // function : SetEditCurrentArgument()
808 //=================================================================================
809 void SMESHGUI_SewingDlg::SetEditCurrentArgument()
811 QPushButton* send = (QPushButton*)sender();
813 disconnect(mySelectionMgr, 0, this, 0);
814 mySelectionMgr->clearSelected();
816 if (send == SelectButton1) {
817 myEditCurrentArgument = LineEdit1;
820 else if (send == SelectButton2) {
821 myEditCurrentArgument = LineEdit2;
824 else if (send == SelectButton3) {
825 myEditCurrentArgument = LineEdit3;
828 else if (send == SelectButton4) {
829 myEditCurrentArgument = LineEdit4;
832 else if (send == SelectButton5) {
833 myEditCurrentArgument = LineEdit5;
836 else if (send == SelectButton6) {
837 myEditCurrentArgument = LineEdit6;
841 if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) {
842 SMESH::SetPointRepresentation(true);
844 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
845 aViewWindow->SetSelectionMode(NodeSelection);
848 SMESH::SetPointRepresentation(false);
849 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
850 aViewWindow->SetSelectionMode(CellSelection);
853 myEditCurrentArgument->setFocus();
854 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
855 SelectionIntoArgument(false);
858 //=================================================================================
859 // function : DeactivateActiveDialog()
861 //=================================================================================
862 void SMESHGUI_SewingDlg::DeactivateActiveDialog()
864 if (ConstructorsBox->isEnabled()) {
865 ConstructorsBox->setEnabled(false);
866 GroupArguments->setEnabled(false);
867 GroupButtons->setEnabled(false);
868 mySMESHGUI->ResetState();
869 mySMESHGUI->SetActiveDialogBox(0);
873 //=================================================================================
874 // function : ActivateThisDialog()
876 //=================================================================================
877 void SMESHGUI_SewingDlg::ActivateThisDialog()
879 /* Emit a signal to deactivate the active dialog */
880 mySMESHGUI->EmitSignalDeactivateDialog();
881 ConstructorsBox->setEnabled(true);
882 GroupArguments->setEnabled(true);
883 GroupButtons->setEnabled(true);
885 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
887 ConstructorsClicked(GetConstructorId());
888 SelectionIntoArgument();
891 //=================================================================================
892 // function : enterEvent()
894 //=================================================================================
895 void SMESHGUI_SewingDlg::enterEvent (QEvent* e)
897 if (!ConstructorsBox->isEnabled()) {
898 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
899 if ( aViewWindow && !mySelector) {
900 mySelector = aViewWindow->GetSelector();
902 ActivateThisDialog();
906 //=================================================================================
907 // function : GetConstructorId()
909 //=================================================================================
910 int SMESHGUI_SewingDlg::GetConstructorId()
912 return GroupConstructors->checkedId();
915 //=================================================================================
916 // function : GetConstructorId()
918 //=================================================================================
919 bool SMESHGUI_SewingDlg::IsValid()
921 return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6);
924 //=================================================================================
925 // function : keyPressEvent()
927 //=================================================================================
928 void SMESHGUI_SewingDlg::keyPressEvent( QKeyEvent* e )
930 QDialog::keyPressEvent( e );
931 if ( e->isAccepted() )
934 if ( e->key() == Qt::Key_F1 ) {