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_MeshPatternDlg.cxx
25 // Author : Sergey LITONIN
28 #include "SMESHGUI_MeshPatternDlg.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_CreatePatternDlg.h"
33 #include "SMESHGUI_PatternWidget.h"
34 #include "SMESHGUI_Utils.h"
35 #include "SMESHGUI_VTKUtils.h"
36 #include "SMESHGUI_PatternUtils.h"
37 #include "SMESHGUI_GEOMGenUtils.h"
39 #include "SMESH_Actor.h"
40 #include "SMESH_ActorUtils.h"
41 #include "SMESH_NumberFilter.hxx"
43 #include "SMDS_Mesh.hxx"
44 #include "SMDS_MeshElement.hxx"
46 #include "SUIT_ResourceMgr.h"
47 #include "SUIT_Desktop.h"
48 #include "SUIT_FileDlg.h"
49 #include "SUIT_Session.h"
50 #include "SUIT_MessageBox.h"
52 #include "LightApp_SelectionMgr.h"
53 #include "SalomeApp_Tools.h"
54 #include "SalomeApp_Study.h"
55 #include "LightApp_Application.h"
57 #include "SALOMEDS_SObject.hxx"
59 #include "SALOME_ListIO.hxx"
60 #include "SVTK_Selection.h"
62 #include "SVTK_ViewModel.h"
63 #include "SVTK_Selector.h"
64 #include "SVTK_ViewWindow.h"
65 #include "VTKViewer_CellLocationsArray.h"
68 #include <TColStd_MapOfInteger.hxx>
69 #include <TColStd_IndexedMapOfInteger.hxx>
74 #include <qlineedit.h>
75 #include <qpushbutton.h>
76 #include <qgroupbox.h>
78 #include <qradiobutton.h>
79 #include <qcheckbox.h>
80 #include <qbuttongroup.h>
81 #include <qmessagebox.h>
84 #include <qvaluelist.h>
87 #include <qfileinfo.h>
88 #include <qfiledialog.h>
92 #include <vtkIdList.h>
93 #include <vtkCellArray.h>
94 #include <vtkUnsignedCharArray.h>
95 #include <vtkUnstructuredGrid.h>
96 #include <vtkDataSetMapper.h>
97 #include <vtkProperty.h>
103 * Class : SMESHGUI_MeshPatternDlg
104 * Description : Dialog to specify filters for VTK viewer
107 //=======================================================================
108 // name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg
109 // Purpose : Constructor
110 //=======================================================================
111 SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule,
112 const char* theName )
113 : QDialog( SMESH::GetDesktop( theModule ), theName, false, WStyle_Customize |
114 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
116 mySMESHGUI( theModule ),
117 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
119 setCaption(tr("CAPTION"));
121 QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING);
123 QFrame* aMainFrame = createMainFrame (this);
124 QFrame* aBtnFrame = createButtonFrame(this);
126 aDlgLay->addWidget(aMainFrame);
127 aDlgLay->addWidget(aBtnFrame);
129 aDlgLay->setStretchFactor(aMainFrame, 1);
133 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
135 myHelpFileName = "pattern_mapping.htm";
140 //=======================================================================
141 // name : SMESHGUI_MeshPatternDlg::createMainFrame
142 // Purpose : Create frame containing dialog's input fields
143 //=======================================================================
144 QFrame* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent)
146 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
147 QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
148 QPixmap icon2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_2d")));
149 QPixmap icon3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_3d")));
150 QPixmap iconOpen ( mgr->loadPixmap("STD", tr("ICON_FILE_OPEN")));
152 QPixmap iconSample2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D")));
153 QPixmap iconSample3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_3D")));
155 QGroupBox* aMainGrp = new QGroupBox (1, Qt::Horizontal, theParent);
156 aMainGrp->setFrameStyle(QFrame::NoFrame);
157 aMainGrp->setInsideMargin(0);
159 // Pattern type group
161 myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp);
162 mySwitch2d = new QRadioButton (myTypeGrp);
163 mySwitch3d = new QRadioButton (myTypeGrp);
164 mySwitch2d->setPixmap(icon2d);
165 mySwitch3d->setPixmap(icon3d);
166 myTypeGrp->insert(mySwitch2d, Type_2d);
167 myTypeGrp->insert(mySwitch3d, Type_3d);
171 QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MESH"), aMainGrp);
172 new QLabel(tr("SMESH_MESH"), aMeshGrp);
173 mySelBtn[ Mesh ] = new QPushButton(aMeshGrp);
174 mySelBtn[ Mesh ]->setPixmap(iconSlct);
175 mySelEdit[ Mesh ] = new QLineEdit(aMeshGrp);
176 mySelEdit[ Mesh ]->setReadOnly(true);
180 QGroupBox* aPatGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp);
183 QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, aPatGrp);
184 aNameGrp->setFrameStyle(QFrame::NoFrame);
185 aNameGrp->setInsideMargin(0);
186 new QLabel(tr("PATTERN"), aNameGrp);
187 myName = new QLineEdit(aNameGrp);
188 myName->setReadOnly(true);
189 myOpenBtn = new QPushButton(aNameGrp);
190 myOpenBtn->setPixmap(iconOpen);
191 myNewBtn = new QPushButton(tr("NEW"), aNameGrp);
193 // Mode selection check box
194 myRefine = new QCheckBox(tr("REFINE"), aPatGrp);
196 // selection widgets for Apply to geom mode
197 myGeomGrp = new QGroupBox(3, Qt::Horizontal, aPatGrp);
198 myGeomGrp->setFrameStyle(QFrame::NoFrame);
199 myGeomGrp->setInsideMargin(0);
201 for (int i = Object; i <= Vertex2; i++)
203 mySelLbl[ i ] = new QLabel(myGeomGrp);
204 mySelBtn[ i ] = new QPushButton(myGeomGrp);
205 mySelBtn[ i ]->setPixmap(iconSlct);
206 mySelEdit[ i ] = new QLineEdit(myGeomGrp);
207 mySelEdit[ i ]->setReadOnly(true);
210 // Widgets for refinement of existing mesh elements
211 myRefineGrp = new QFrame(aPatGrp);
212 myRefineGrp->setFrameStyle(QFrame::NoFrame);
213 QGridLayout* aRefGrid = new QGridLayout(myRefineGrp, 3, 3, 0, 5);
215 mySelLbl[ Ids ] = new QLabel(myRefineGrp);
216 mySelBtn[ Ids ] = new QPushButton(myRefineGrp);
217 mySelBtn[ Ids ]->setPixmap(iconSlct);
218 mySelEdit[ Ids ] = new QLineEdit(myRefineGrp);
220 QLabel* aNodeLbl = new QLabel(tr("NODE_1"), myRefineGrp);
221 myNode1 = new QSpinBox(myRefineGrp);
222 myNode2Lbl = new QLabel(tr("NODE_2"), myRefineGrp);
223 myNode2 = new QSpinBox(myRefineGrp);
225 aRefGrid->addWidget(mySelLbl [ Ids ], 0, 0);
226 aRefGrid->addWidget(mySelBtn [ Ids ], 0, 1);
227 aRefGrid->addWidget(mySelEdit[ Ids ], 0, 2);
228 aRefGrid->addWidget(aNodeLbl, 1, 0);
229 aRefGrid->addMultiCellWidget(myNode1, 1, 1, 1, 2);
230 aRefGrid->addWidget(myNode2Lbl, 2, 0);
231 aRefGrid->addMultiCellWidget(myNode2, 2, 2, 1, 2);
234 myReverseChk = new QCheckBox(tr("REVERSE"), aPatGrp);
236 // CreatePoly check box
237 myCreatePolygonsChk = new QCheckBox( tr( "CREATE_POLYGONS_NEAR_BOUNDARY" ), aPatGrp );
238 myCreatePolyedrsChk = new QCheckBox( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ), aPatGrp );
240 // Pictures 2d and 3d
241 for (int i = 0; i < 2; i++) {
243 myPicture2d = new SMESHGUI_PatternWidget(aPatGrp),
244 myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
246 myPicture3d = new QFrame(aPatGrp),
247 myPreview3d = new QLabel(myPicture3d);
248 myPreview3d->setPixmap(iconSample3d);
249 QGridLayout* aLay = new QGridLayout(myPicture3d, 3, 3, 0, 0);
250 QSpacerItem* aSpacerH1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
251 QSpacerItem* aSpacerH2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
252 QSpacerItem* aSpacerV1 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
253 QSpacerItem* aSpacerV2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
254 aLay->addItem(aSpacerH1, 1, 0);
255 aLay->addItem(aSpacerH2, 1, 2);
256 aLay->addItem(aSpacerV1, 0, 1);
257 aLay->addItem(aSpacerV2, 2, 1);
258 aLay->addWidget(myPreview3d, 1, 1);
262 myPreviewChk = new QCheckBox(tr("PREVIEW"), aPatGrp);
264 // Connect signals and slots
266 connect(myTypeGrp, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
267 connect(myOpenBtn, SIGNAL(clicked()), SLOT(onOpen()));
268 connect(myNewBtn, SIGNAL(clicked()), SLOT(onNew()));
270 connect(myReverseChk, SIGNAL(toggled(bool)), SLOT(onReverse(bool)));
271 connect(myPreviewChk, SIGNAL(toggled(bool)), SLOT(onPreview(bool)));
272 connect(myRefine, SIGNAL(toggled(bool)), SLOT(onModeToggled(bool)));
274 connect(myNode1, SIGNAL(valueChanged(int)), SLOT(onNodeChanged(int)));
275 connect(myNode2, SIGNAL(valueChanged(int)), SLOT(onNodeChanged(int)));
277 connect(mySelEdit[Ids], SIGNAL(textChanged(const QString&)), SLOT(onTextChanged(const QString&)));
279 QMap< int, QPushButton* >::iterator anIter;
280 for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter)
281 connect(*anIter, SIGNAL(clicked()), SLOT(onSelInputChanged()));
286 //=======================================================================
287 // name : SMESHGUI_MeshPatternDlg::createButtonFrame
288 // Purpose : Create frame containing buttons
289 //=======================================================================
290 QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent)
292 QFrame* aFrame = new QFrame(theParent);
293 aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
295 myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
296 myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
297 myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
298 myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
300 QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
302 QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
304 aLay->addWidget(myOkBtn);
305 aLay->addWidget(myApplyBtn);
306 aLay->addItem(aSpacer);
307 aLay->addWidget(myCloseBtn);
308 aLay->addWidget(myHelpBtn);
310 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
311 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
312 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
313 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
318 //=======================================================================
319 // name : SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg
320 // Purpose : Destructor
321 //=======================================================================
322 SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg()
326 //=======================================================================
327 // name : SMESHGUI_MeshPatternDlg::Init
328 // Purpose : Init dialog fields, connect signals and slots, show dialog
329 //=======================================================================
330 void SMESHGUI_MeshPatternDlg::Init()
332 myPattern = SMESH::GetPattern();
334 myIsCreateDlgOpen = false;
338 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
339 myMesh = SMESH::SMESH_Mesh::_nil();
341 myMeshShape = GEOM::GEOM_Object::_nil();
342 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
343 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
344 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
346 // selection and SMESHGUI
347 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
348 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
349 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
351 myTypeGrp->setButton(Type_2d);
352 onTypeChanged(Type_2d);
353 onModeToggled(isRefine());
357 resize(minimumSize());
365 //=======================================================================
366 // name : SMESHGUI_MeshPatternDlg::isValid
367 // Purpose : Verify validity of entry data
368 //=======================================================================
369 bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess)
373 (myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 ||
374 myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true))))
377 (myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() ||
378 myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil())))
381 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
382 tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok);
386 if ( myName->text()=="" ) {
388 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
389 tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok);
396 //=======================================================================
397 // name : SMESHGUI_MeshPatternDlg::onApply
398 // Purpose : SLOT called when "Apply" button pressed.
399 //=======================================================================
400 bool SMESHGUI_MeshPatternDlg::onApply()
408 if (isRefine()) { // Refining existing mesh elements
411 SMESH::long_array_var varIds = new SMESH::long_array();
412 varIds->length(ids.count());
414 for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
417 ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
418 : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
420 } else { // Applying a pattern to geometrical object
421 if (myType == Type_2d)
422 myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());
424 myPattern->ApplyTo3DBlock(myGeomObj[Object], myGeomObj[Vertex1], myGeomObj[Vertex2]);
427 bool toCreatePolygons = myCreatePolygonsChk->isChecked();
428 bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked();
429 if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) {
430 //mySelectionMgr->clearSelected();
431 bool autoUpdate = SMESHGUI::automaticUpdate();
432 if (!isRefine() && autoUpdate) {
433 _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
434 SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str());
436 anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str());
438 SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
443 mySelectionMgr->clearSelected();
446 mySMESHGUI->updateObjBrowser(true);
448 mySelEdit[ Ids ]->setText("");
452 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
453 tr("SMESH_OPERATION_FAILED"), QMessageBox::Ok);
456 } catch (const SALOME::SALOME_Exception& S_ex) {
457 SalomeApp_Tools::QtCatchCorbaException(S_ex);
464 //=======================================================================
465 // name : SMESHGUI_MeshPatternDlg::onOk
466 // Purpose : SLOT called when "Ok" button pressed.
467 //=======================================================================
468 void SMESHGUI_MeshPatternDlg::onOk()
474 //=======================================================================
475 // name : SMESHGUI_MeshPatternDlg::onClose
476 // Purpose : SLOT called when "Close" button pressed. Close dialog
477 //=======================================================================
478 void SMESHGUI_MeshPatternDlg::onClose()
480 mySelectionMgr->clearFilters();
481 SMESH::SetPickable();
482 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
483 aViewWindow->SetSelectionMode(ActorSelection);
484 disconnect(mySelectionMgr, 0, this, 0);
485 disconnect(mySMESHGUI, 0, this, 0);
486 mySMESHGUI->ResetState();
491 //=================================================================================
492 // function : onHelp()
494 //=================================================================================
495 void SMESHGUI_MeshPatternDlg::onHelp()
497 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
499 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
501 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
502 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
503 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
504 QObject::tr("BUT_OK"));
508 //=======================================================================
509 // name : SMESHGUI_MeshPatternDlg::onSelectionDone
510 // Purpose : SLOT called when selection changed
511 //=======================================================================
512 void SMESHGUI_MeshPatternDlg::onSelectionDone()
518 if (mySelInput == Mesh) {
520 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
521 if (aList.Extent() != 1)
524 // Retrieve mesh from selection
525 Handle(SALOME_InteractiveObject) anIO = aList.First();
526 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
527 if (aMesh->_is_nil())
530 // Get geom object corresponding to the mesh
531 _PTR(SObject) aSO = SMESH::FindSObject(aMesh.in());
532 myMeshShape = SMESH::GetGeom(aSO);
534 // Clear fields of geom objects if mesh was changed
535 if (myMesh != aMesh) {
536 for (int i = Object; i <= Ids; i++) {
537 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
538 mySelEdit[ i ]->setText("");
544 // Set name of mesh in line edit
546 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
547 mySelEdit[ Mesh ]->setText(aName);
549 } else if (mySelInput == Ids) {
551 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
552 if (aList.Extent() != 1)
556 if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds))
560 mySelEdit[ Ids ]->setText(anIds);
565 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
566 if (aList.Extent() != 1)
569 // Get geom object from selection
570 Handle(SALOME_InteractiveObject) anIO = aList.First();
571 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
572 if (anObj->_is_nil())
575 // Clear fields of vertexes if face or 3d block was changed
576 if (anObj != myGeomObj[ mySelInput ] && mySelInput == Object) {
577 for (int i = Vertex1; i <= Vertex2; i++) {
578 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
579 mySelEdit[ i ]->setText("");
583 myGeomObj[ mySelInput ] = anObj;
585 // Set name of geom object in line edit
587 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
588 mySelEdit[ mySelInput ]->setText(aName);
590 } catch (const SALOME::SALOME_Exception& S_ex) {
591 SalomeApp_Tools::QtCatchCorbaException(S_ex);
601 //=======================================================================
602 // name : SMESHGUI_MeshPatternDlg::resetSelInput
603 // Purpose : Reset fields corresponding to the current selection input
604 //=======================================================================
605 void SMESHGUI_MeshPatternDlg::resetSelInput()
607 if (mySelInput == Mesh)
609 myMesh = SMESH::SMESH_Mesh::_nil();
610 myMeshShape = GEOM::GEOM_Object::_nil();
614 myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil();
616 mySelEdit[ mySelInput ]->setText("");
619 //=======================================================================
620 // name : SMESHGUI_MeshPatternDlg::onDeactivate
621 // Purpose : SLOT called when dialog must be deativated
622 //=======================================================================
623 void SMESHGUI_MeshPatternDlg::onDeactivate()
625 mySelectionMgr->clearFilters();
626 //if (myReverseChk->isChecked())
628 disconnect(mySelectionMgr, 0, this, 0);
632 //=======================================================================
633 // name : SMESHGUI_MeshPatternDlg::enterEvent
634 // Purpose : Event filter
635 //=======================================================================
636 void SMESHGUI_MeshPatternDlg::enterEvent (QEvent*)
638 if (myIsCreateDlgOpen)
641 if (myReverseChk->isChecked())
643 mySMESHGUI->EmitSignalDeactivateDialog();
646 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
647 onTextChanged(mySelEdit[Ids]->text());
650 //=======================================================================
651 // name : SMESHGUI_MeshPatternDlg::closeEvent
653 //=======================================================================
654 void SMESHGUI_MeshPatternDlg::closeEvent (QCloseEvent*)
659 //=======================================================================
660 // name : SMESHGUI_MeshPatternDlg::onSelInputChanged
661 // Purpose : SLOT. Called when -> button clicked.
662 // Change current selection input field
663 //=======================================================================
664 void SMESHGUI_MeshPatternDlg::onSelInputChanged()
666 const QObject* aSender = sender();
667 for (int i = Mesh; i <= Ids; i++)
668 if (aSender == mySelBtn[ i ])
675 //=======================================================================
676 // name : SMESHGUI_MeshPatternDlg::prepareFilters
677 // Purpose : Prepare filters for dialog
678 //=======================================================================
679 QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const
681 static QStringList aList;
684 aList.append(tr("PATTERN_FILT"));
685 //aList.append(tr("ALL_FILES_FILTER"));
691 //=======================================================================
692 // name : SMESHGUI_MeshPatternDlg::autoExtension
693 // Purpose : Append extension to the file name
694 //=======================================================================
695 QString SMESHGUI_MeshPatternDlg::autoExtension (const QString& theFileName) const
697 QString anExt = theFileName.section('.', -1);
698 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
701 //=======================================================================
702 // name : SMESHGUI_MeshPatternDlg::onOpen
703 // Purpose : SLOT. Called when "Open" button clicked.
704 // Displays file open dialog
705 //=======================================================================
706 void SMESHGUI_MeshPatternDlg::onOpen()
708 SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, true);
709 aDlg->setCaption(tr("LOAD_PATTERN"));
710 aDlg->setMode(QFileDialog::ExistingFile);
711 aDlg->setFilters(prepareFilters());
712 if (myName->text() != "")
713 aDlg->setSelection(myName->text() + ".smp");
714 QPushButton* anOkBtn = (QPushButton*)aDlg->child("OK", "QPushButton");
716 anOkBtn->setText(tr("SMESH_BUT_OK"));
718 if (aDlg->exec() != Accepted)
721 QString fName = aDlg->selectedFile();
725 if (QFileInfo(fName).extension().isEmpty())
726 fName = autoExtension(fName);
728 fName = QDir::convertSeparators(fName);
730 QString prev = QDir::convertSeparators(myName->text());
734 // Read string from file
736 if (!aFile.open(IO_ReadOnly)) {
737 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
738 tr("ERROR_OF_OPENING"), QMessageBox::Ok);
742 QByteArray aDataArray = aFile.readAll();
743 const char* aData = aDataArray.data();
745 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
746 tr("ERROR_OF_READING"), QMessageBox::Ok);
750 if (loadFromFile(aData))
751 myName->setText(QFileInfo(fName).baseName());
757 //=======================================================================
758 // name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg
759 // Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close"
760 //=======================================================================
761 void SMESHGUI_MeshPatternDlg::onCloseCreationDlg()
764 myIsCreateDlgOpen = false;
767 //=======================================================================
768 // name : SMESHGUI_MeshPatternDlg::onOkCreationDlg
769 // Purpose : SLOT. Called when "Pattern creation" dialog closed with OK
770 // or SAVE buttons. Initialize myPattern field. Redisplay preview
771 //=======================================================================
772 void SMESHGUI_MeshPatternDlg::onOkCreationDlg()
774 myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern());
775 myName->setText(myCreationDlg->GetPatternName());
781 myIsCreateDlgOpen = false;
784 //=======================================================================
785 // name : SMESHGUI_MeshPatternDlg::onNew
786 // Purpose : SLOT. Called when "New..." button clicked. Create new pattern
787 //=======================================================================
788 void SMESHGUI_MeshPatternDlg::onNew()
791 myIsCreateDlgOpen = true;
792 if (myCreationDlg == 0)
794 myCreationDlg = new SMESHGUI_CreatePatternDlg( mySMESHGUI, myType);
795 connect(myCreationDlg, SIGNAL(NewPattern()), SLOT(onOkCreationDlg()));
796 connect(myCreationDlg, SIGNAL(Close()), SLOT(onCloseCreationDlg()));
799 myCreationDlg->Init(myType);
801 myCreationDlg->SetMesh(myMesh);
802 myCreationDlg->show();
805 //=======================================================================
806 // name : SMESHGUI_MeshPatternDlg::onReverse
807 // Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged
808 // Calculate new points of the mesh to be created. Redisplay preview
809 //=======================================================================
810 void SMESHGUI_MeshPatternDlg::onReverse (bool)
815 //=======================================================================
817 // name : SMESHGUI_MeshPatternDlg::onPreview
818 // Purpose : SLOT. Called when state of "Preview" checkbox changed
819 // Display/Erase preview
820 //=======================================================================
821 void SMESHGUI_MeshPatternDlg::onPreview (bool)
826 //=======================================================================
827 // name : SMESHGUI_MeshPatternDlg::displayPreview
828 // Purpose : Display preview
829 //=======================================================================
830 void SMESHGUI_MeshPatternDlg::displayPreview()
833 // Redisplay preview in dialog
834 SMESH::point_array_var pnts = myPattern->GetPoints();
835 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
836 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);
838 if (pnts->length() == 0 ||
839 keyPoints->length() == 0 ||
840 elemPoints->length() == 0) {
844 PointVector aPoints(pnts->length());
845 QValueVector<int> aKeyPoints(keyPoints->length());
846 ConnectivityVector anElemPoints(elemPoints->length());
848 for (int i = 0, n = pnts->length(); i < n; i++)
849 aPoints[ i ] = pnts[ i ];
851 for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++)
852 aKeyPoints[ i2 ] = keyPoints[ i2 ];
854 for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
855 QValueVector<int> aVec(elemPoints[ i3 ].length());
856 for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
857 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
859 anElemPoints[ i3 ] = aVec;
862 myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints);
865 // Redisplay preview in 3D viewer
866 if (myPreviewActor != 0) {
867 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
868 vf->RemoveActor(myPreviewActor);
871 myPreviewActor->Delete();
875 if (!myPreviewChk->isChecked() || !isValid(false))
878 vtkUnstructuredGrid* aGrid = getGrid();
882 // Create and display actor
883 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
884 aMapper->SetInput(aGrid);
886 myPreviewActor = SALOME_Actor::New();
887 myPreviewActor->PickableOff();
888 myPreviewActor->SetMapper(aMapper);
890 vtkProperty* aProp = vtkProperty::New();
891 aProp->SetRepresentationToWireframe();
892 aProp->SetColor(250, 0, 250);
893 if (SMESH::FindActorByObject(myMesh))
894 aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 1 );
896 aProp->SetLineWidth(1);
897 myPreviewActor->SetProperty(aProp);
899 myPreviewActor->SetRepresentation(3);
901 SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
902 SMESH::GetCurrentVtkView()->Repaint();
906 } catch (const SALOME::SALOME_Exception& S_ex) {
907 SalomeApp_Tools::QtCatchCorbaException(S_ex);
914 //=======================================================================
915 // name : SMESHGUI_MeshPatternDlg::erasePreview
916 // Purpose : Erase preview
917 //=======================================================================
918 void SMESHGUI_MeshPatternDlg::erasePreview()
920 // Erase preview in 2D viewer
921 myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector());
923 // Erase preview in 3D viewer
924 if (myPreviewActor == 0)
928 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView())
930 vf->RemoveActor(myPreviewActor);
933 myPreviewActor->Delete();
937 //=======================================================================
938 // name : SMESHGUI_MeshPatternDlg::updateWgState
939 // Purpose : Enable/disable selection widgets
940 //=======================================================================
941 void SMESHGUI_MeshPatternDlg::updateWgState()
943 if (myMesh->_is_nil()) {
944 for (int i = Object; i <= Ids; i++) {
945 mySelBtn [ i ]->setEnabled(false);
946 mySelEdit[ i ]->setEnabled(false);
947 mySelEdit[ i ]->setText("");
949 myNode1->setEnabled(false);
950 myNode2->setEnabled(false);
951 myNode1->setRange(0, 0);
952 myNode2->setRange(0, 0);
954 mySelBtn [ Object ]->setEnabled(true);
955 mySelEdit[ Object ]->setEnabled(true);
956 mySelBtn [ Ids ] ->setEnabled(true);
957 mySelEdit[ Ids ] ->setEnabled(true);
959 if (myGeomObj[ Object ]->_is_nil()) {
960 for (int i = Vertex1; i <= Vertex2; i++) {
961 mySelBtn [ i ]->setEnabled(false);
962 mySelEdit[ i ]->setEnabled(false);
963 mySelEdit[ i ]->setText("");
966 for (int i = Object; i <= Vertex2; i++) {
967 mySelBtn [ i ]->setEnabled(true);
968 mySelEdit[ i ]->setEnabled(true);
973 if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) {
974 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
975 if (keyPoints->length()) {
976 myNode1->setEnabled(true);
977 myNode2->setEnabled(true);
978 myNode1->setRange(1, keyPoints->length());
979 myNode2->setRange(1, keyPoints->length());
984 myNode1->setEnabled(false);
985 myNode2->setEnabled(false);
986 myNode1->setRange(0, 0);
987 myNode2->setRange(0, 0);
991 //=======================================================================
992 // name : SMESHGUI_MeshPatternDlg::activateSelection
993 // Purpose : Activate selection in accordance with current selection input
994 //=======================================================================
995 void SMESHGUI_MeshPatternDlg::activateSelection()
997 mySelectionMgr->clearFilters();
998 if (mySelInput == Ids) {
999 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1001 SMESH::SetPickable(anActor);
1003 if (myType == Type_2d)
1005 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1006 aViewWindow->SetSelectionMode(FaceSelection);
1010 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1011 aViewWindow->SetSelectionMode(CellSelection);
1015 SMESH::SetPickable();
1016 //mySelectionMgr->setSelectionModes(ActorSelection);
1017 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1018 aViewWindow->SetSelectionMode(ActorSelection);
1021 if (mySelInput == Object && !myMeshShape->_is_nil()) {
1022 if (myType == Type_2d) {
1024 mySelectionMgr->installFilter
1025 (new SMESH_NumberFilter ("GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape));
1027 mySelectionMgr->installFilter
1028 (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape));
1030 TColStd_MapOfInteger aTypes;
1031 aTypes.Add(TopAbs_SHELL);
1032 aTypes.Add(TopAbs_SOLID);
1033 mySelectionMgr->installFilter
1034 (new SMESH_NumberFilter ("GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true));
1036 } else if ((mySelInput == Vertex1 || mySelInput == Vertex2) && !myGeomObj[ Object ]->_is_nil()) {
1037 mySelectionMgr->installFilter
1038 (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ]));
1043 //=======================================================================
1044 // name : SMESHGUI_MeshPatternDlg::loadFromFile
1045 // Purpose : Load pattern from file
1046 //=======================================================================
1047 bool SMESHGUI_MeshPatternDlg::loadFromFile (const QString& theName)
1050 SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
1052 if (!aPattern->LoadFromFile(theName.latin1()) ||
1053 myType == Type_2d && !aPattern->Is2D()) {
1054 SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();
1056 if (aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr("ERR_READ_NB_POINTS");
1057 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr("ERR_READ_POINT_COORDS");
1058 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS) aMess = tr("ERR_READ_TOO_FEW_POINTS");
1059 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr("ERR_READ_3D_COORD");
1060 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr("ERR_READ_NO_KEYPOINT");
1061 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr("ERR_READ_BAD_INDEX");
1062 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr("ERR_READ_ELEM_POINTS");
1063 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr("ERR_READ_NO_ELEMS");
1064 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr("ERR_READ_BAD_KEY_POINT");
1065 else aMess = tr("ERROR_OF_LOADING");
1067 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), aMess, QMessageBox::Ok);
1070 myPattern = aPattern;
1073 } catch (const SALOME::SALOME_Exception& S_ex) {
1074 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1075 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
1076 tr("ERROR_OF_LOADING"), QMessageBox::Ok);
1081 //=======================================================================
1082 // name : SMESHGUI_MeshPatternDlg::onTypeChanged
1083 // Purpose : SLOT. Called when pattern type changed.
1084 // Change dialog's look and feel
1085 //=======================================================================
1086 void SMESHGUI_MeshPatternDlg::onTypeChanged (int theType)
1088 if (myType == theType)
1094 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
1095 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
1096 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
1097 myPattern = SMESH::GetPattern();
1099 myName->setText("");
1100 mySelEdit[ Object ]->setText("");
1101 mySelEdit[ Vertex1 ]->setText("");
1102 mySelEdit[ Vertex2 ]->setText("");
1103 mySelEdit[ Ids ] ->setText("");
1104 myCreatePolygonsChk->show();
1105 myCreatePolyedrsChk->show();
1107 if (theType == Type_2d) {
1109 mySelLbl [ Vertex2 ]->hide();
1110 mySelBtn [ Vertex2 ]->hide();
1111 mySelEdit[ Vertex2 ]->hide();
1112 myReverseChk->show();
1113 myPicture2d->show();
1114 myPicture3d->hide();
1115 mySelLbl[ Object ]->setText(tr("FACE"));
1116 mySelLbl[ Vertex1 ]->setText(tr("VERTEX"));
1118 mySelLbl[ Ids ]->setText(tr("MESH_FACES"));
1123 mySelLbl [ Vertex2 ]->show();
1124 mySelBtn [ Vertex2 ]->show();
1125 mySelEdit[ Vertex2 ]->show();
1126 myReverseChk->hide();
1127 myPicture2d->hide();
1128 myPicture3d->show();
1129 mySelLbl[ Object ]->setText(tr("3D_BLOCK"));
1130 mySelLbl[ Vertex1 ]->setText(tr("VERTEX1"));
1131 mySelLbl[ Vertex2 ]->setText(tr("VERTEX2"));
1133 mySelLbl[ Ids ]->setText(tr("MESH_VOLUMES"));
1139 activateSelection();
1144 //=======================================================================
1145 // name : SMESHGUI_MeshPatternDlg::getGrid
1146 // Purpose : Get unstructured grid for pattern
1147 //=======================================================================
1148 vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid()
1151 // Get points from pattern
1152 SMESH::point_array_var pnts;
1153 QValueList<int> ids;
1154 if (isRefine() && getIds(ids)) {
1155 SMESH::long_array_var varIds = new SMESH::long_array();
1156 varIds->length(ids.count());
1158 for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
1160 pnts = myType == Type_2d
1161 ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
1162 : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
1164 pnts = myType == Type_2d
1165 ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked())
1166 : myPattern->ApplyTo3DBlock(myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ]);
1169 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(true);
1171 if (pnts->length() == 0 || elemPoints->length() == 0)
1174 // to do : to be removed /////////////////////////////////////////////
1177 for (int i1 = 0, n1 = pnts->length(); i1 < n1; i1++)
1178 printf("%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z);
1180 printf("\nELEMENTS : \n");
1181 for (int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++)
1185 for (int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++)
1186 printf("%d ", elemPoints[ i2 ][ i3 ]);
1192 //////////////////////////////////////////////////////////////////////
1194 // Calculate number of points used for cell
1195 vtkIdType aNbCells = elemPoints->length();
1196 vtkIdType aCellsSize = 0;
1197 for (int i = 0, n = elemPoints->length(); i < n; i++)
1198 aCellsSize += elemPoints[ i ].length();
1200 // Create unstructured grid and other usefull arrays
1201 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1203 vtkCellArray* aConnectivity = vtkCellArray::New();
1204 aConnectivity->Allocate(aCellsSize, 0);
1206 vtkPoints* aPoints = vtkPoints::New();
1207 aPoints->SetNumberOfPoints(pnts->length());
1209 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1210 aCellTypesArray->SetNumberOfComponents(1);
1211 aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
1213 vtkIdList *anIdList = vtkIdList::New();
1215 // Fill array of points
1216 for (int p = 0, nbPnt = pnts->length(); p < nbPnt; p++)
1217 aPoints->SetPoint(p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z);
1219 for (int e = 0, nbElem = elemPoints->length(); e < nbElem; e++) {
1220 int nbPoints = elemPoints[ e ].length();
1221 anIdList->SetNumberOfIds(nbPoints);
1222 for (int i = 0; i < nbPoints; i++)
1223 anIdList->SetId(i, elemPoints[ e ][ i ]);
1225 aConnectivity->InsertNextCell(anIdList);
1227 if (nbPoints == 3) aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1228 else if (nbPoints == 5) aCellTypesArray->InsertNextValue(VTK_PYRAMID);
1229 else if (nbPoints == 6) aCellTypesArray->InsertNextValue(VTK_WEDGE);
1230 else if (nbPoints == 8) aCellTypesArray->InsertNextValue(VTK_HEXAHEDRON);
1231 else if (nbPoints == 4 && myType == Type_2d) aCellTypesArray->InsertNextValue(VTK_QUAD);
1232 else if (nbPoints == 4 && myType == Type_3d) aCellTypesArray->InsertNextValue(VTK_TETRA);
1233 else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL);
1236 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1237 aCellLocationsArray->SetNumberOfComponents(1);
1238 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1240 aConnectivity->InitTraversal();
1241 for (vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
1242 aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
1244 aGrid->SetPoints(aPoints);
1245 aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
1247 aConnectivity->Delete();
1249 aCellTypesArray->Delete();
1251 aCellLocationsArray->Delete();
1259 //=======================================================================
1260 // name : onModeToggled
1262 //=======================================================================
1263 void SMESHGUI_MeshPatternDlg::onModeToggled (bool on)
1265 on ? myRefineGrp->show() : myRefineGrp->hide();
1266 on ? myGeomGrp->hide() : myGeomGrp->show();
1271 //=======================================================================
1274 //=======================================================================
1275 bool SMESHGUI_MeshPatternDlg::isRefine() const
1277 return myRefine->isChecked();
1280 //=======================================================================
1281 // name : onTextChanged
1283 //=======================================================================
1284 void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText)
1286 if (myBusy || !isRefine())
1291 if (mySelInput != Ids) {
1293 activateSelection();
1296 // hilight entered elements/nodes
1297 SMDS_Mesh* aMesh = 0;
1298 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1300 aMesh = anActor->GetObject()->GetMesh();
1303 QStringList aListId = QStringList::split(" ", theNewText, false);
1305 TColStd_MapOfInteger newIndices;
1307 for (int i = 0; i < aListId.count(); i++) {
1308 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
1309 if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume))
1310 newIndices.Add(e->GetID());
1312 mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false);
1313 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1314 aViewWindow->highlight( anActor->getIO(), true, true );
1322 //=======================================================================
1323 // name : onNodeChanged
1325 //=======================================================================
1326 void SMESHGUI_MeshPatternDlg::onNodeChanged (int value)
1328 if (myType == Type_3d) {
1329 QSpinBox* first = (QSpinBox*)sender();
1330 QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
1331 int secondVal = second->value();
1332 if (secondVal == value) {
1333 secondVal = value == second->maxValue() ? second->minValue() : value + 1;
1334 bool blocked = second->signalsBlocked();
1335 second->blockSignals(true);
1336 second->setValue(secondVal);
1337 second->blockSignals(blocked);
1344 //=======================================================================
1347 //=======================================================================
1348 bool SMESHGUI_MeshPatternDlg::getIds (QValueList<int>& ids) const
1351 QStringList strIds = QStringList::split(" ", mySelEdit[Ids]->text());
1354 for (QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it) {
1355 val = (*it).toInt(&isOk);
1363 //=======================================================================
1366 //=======================================================================
1367 int SMESHGUI_MeshPatternDlg::getNode (bool second) const
1369 return second ? myNode2->value() - 1 : myNode1->value() - 1;
1372 //=================================================================================
1373 // function : keyPressEvent()
1375 //=================================================================================
1376 void SMESHGUI_MeshPatternDlg::keyPressEvent( QKeyEvent* e )
1378 QDialog::keyPressEvent( e );
1379 if ( e->isAccepted() )
1382 if ( e->key() == Key_F1 )