1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_MeshPatternDlg.cxx
24 // Author : Sergey LITONIN
27 #include "SMESHGUI_MeshPatternDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_CreatePatternDlg.h"
32 #include "SMESHGUI_PatternWidget.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_PatternUtils.h"
36 #include "SMESHGUI_GEOMGenUtils.h"
38 #include "SMESH_Actor.h"
39 #include "SMESH_ActorUtils.h"
40 #include "SMESH_NumberFilter.hxx"
42 #include "SMDS_Mesh.hxx"
43 #include "SMDS_MeshElement.hxx"
45 #include "SUIT_ResourceMgr.h"
46 #include "SUIT_Desktop.h"
47 #include "SUIT_FileDlg.h"
48 #include "SUIT_Session.h"
49 #include "SUIT_MessageBox.h"
51 #include "LightApp_SelectionMgr.h"
52 #include "SalomeApp_Tools.h"
53 #include "SalomeApp_Study.h"
54 #include "LightApp_Application.h"
56 #include "SALOMEDS_SObject.hxx"
58 #include "SALOME_ListIO.hxx"
59 #include "SVTK_Selection.h"
61 #include "SVTK_ViewModel.h"
62 #include "SVTK_Selector.h"
63 #include "SVTK_ViewWindow.h"
64 #include "VTKViewer_CellLocationsArray.h"
67 #include <TColStd_MapOfInteger.hxx>
68 #include <TColStd_IndexedMapOfInteger.hxx>
73 #include <qlineedit.h>
74 #include <qpushbutton.h>
75 #include <qgroupbox.h>
77 #include <qradiobutton.h>
78 #include <qcheckbox.h>
79 #include <qbuttongroup.h>
80 #include <qmessagebox.h>
83 #include <qvaluelist.h>
86 #include <qfileinfo.h>
87 #include <qfiledialog.h>
91 #include <vtkIdList.h>
92 #include <vtkCellArray.h>
93 #include <vtkUnsignedCharArray.h>
94 #include <vtkUnstructuredGrid.h>
95 #include <vtkDataSetMapper.h>
96 #include <vtkProperty.h>
102 * Class : SMESHGUI_MeshPatternDlg
103 * Description : Dialog to specify filters for VTK viewer
106 //=======================================================================
107 // name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg
108 // Purpose : Constructor
109 //=======================================================================
110 SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule,
111 const char* theName )
112 : QDialog( SMESH::GetDesktop( theModule ), theName, false, WStyle_Customize |
113 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
115 mySMESHGUI( theModule ),
116 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
118 setCaption(tr("CAPTION"));
120 QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING);
122 QFrame* aMainFrame = createMainFrame (this);
123 QFrame* aBtnFrame = createButtonFrame(this);
125 aDlgLay->addWidget(aMainFrame);
126 aDlgLay->addWidget(aBtnFrame);
128 aDlgLay->setStretchFactor(aMainFrame, 1);
132 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
134 myHelpFileName = "pattern_mapping_page.html";
139 //=======================================================================
140 // name : SMESHGUI_MeshPatternDlg::createMainFrame
141 // Purpose : Create frame containing dialog's input fields
142 //=======================================================================
143 QFrame* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent)
145 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
146 QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
147 QPixmap icon2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_2d")));
148 QPixmap icon3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_3d")));
149 QPixmap iconOpen ( mgr->loadPixmap("STD", tr("ICON_FILE_OPEN")));
151 QPixmap iconSample2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D")));
152 QPixmap iconSample3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_3D")));
154 QGroupBox* aMainGrp = new QGroupBox (1, Qt::Horizontal, theParent);
155 aMainGrp->setFrameStyle(QFrame::NoFrame);
156 aMainGrp->setInsideMargin(0);
158 // Pattern type group
160 myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp);
161 mySwitch2d = new QRadioButton (myTypeGrp);
162 mySwitch3d = new QRadioButton (myTypeGrp);
163 mySwitch2d->setPixmap(icon2d);
164 mySwitch3d->setPixmap(icon3d);
165 myTypeGrp->insert(mySwitch2d, Type_2d);
166 myTypeGrp->insert(mySwitch3d, Type_3d);
170 QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MESH"), aMainGrp);
171 new QLabel(tr("SMESH_MESH"), aMeshGrp);
172 mySelBtn[ Mesh ] = new QPushButton(aMeshGrp);
173 mySelBtn[ Mesh ]->setPixmap(iconSlct);
174 mySelEdit[ Mesh ] = new QLineEdit(aMeshGrp);
175 mySelEdit[ Mesh ]->setReadOnly(true);
179 QGroupBox* aPatGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp);
182 QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, aPatGrp);
183 aNameGrp->setFrameStyle(QFrame::NoFrame);
184 aNameGrp->setInsideMargin(0);
185 new QLabel(tr("PATTERN"), aNameGrp);
186 myName = new QLineEdit(aNameGrp);
187 myName->setReadOnly(true);
188 myOpenBtn = new QPushButton(aNameGrp);
189 myOpenBtn->setPixmap(iconOpen);
190 myNewBtn = new QPushButton(tr("NEW"), aNameGrp);
192 // Mode selection check box
193 myRefine = new QCheckBox(tr("REFINE"), aPatGrp);
195 // selection widgets for Apply to geom mode
196 myGeomGrp = new QGroupBox(3, Qt::Horizontal, aPatGrp);
197 myGeomGrp->setFrameStyle(QFrame::NoFrame);
198 myGeomGrp->setInsideMargin(0);
200 for (int i = Object; i <= Vertex2; i++)
202 mySelLbl[ i ] = new QLabel(myGeomGrp);
203 mySelBtn[ i ] = new QPushButton(myGeomGrp);
204 mySelBtn[ i ]->setPixmap(iconSlct);
205 mySelEdit[ i ] = new QLineEdit(myGeomGrp);
206 mySelEdit[ i ]->setReadOnly(true);
209 // Widgets for refinement of existing mesh elements
210 myRefineGrp = new QFrame(aPatGrp);
211 myRefineGrp->setFrameStyle(QFrame::NoFrame);
212 QGridLayout* aRefGrid = new QGridLayout(myRefineGrp, 3, 3, 0, 5);
214 mySelLbl[ Ids ] = new QLabel(myRefineGrp);
215 mySelBtn[ Ids ] = new QPushButton(myRefineGrp);
216 mySelBtn[ Ids ]->setPixmap(iconSlct);
217 mySelEdit[ Ids ] = new QLineEdit(myRefineGrp);
219 QLabel* aNodeLbl = new QLabel(tr("NODE_1"), myRefineGrp);
220 myNode1 = new QSpinBox(myRefineGrp);
221 myNode2Lbl = new QLabel(tr("NODE_2"), myRefineGrp);
222 myNode2 = new QSpinBox(myRefineGrp);
224 aRefGrid->addWidget(mySelLbl [ Ids ], 0, 0);
225 aRefGrid->addWidget(mySelBtn [ Ids ], 0, 1);
226 aRefGrid->addWidget(mySelEdit[ Ids ], 0, 2);
227 aRefGrid->addWidget(aNodeLbl, 1, 0);
228 aRefGrid->addMultiCellWidget(myNode1, 1, 1, 1, 2);
229 aRefGrid->addWidget(myNode2Lbl, 2, 0);
230 aRefGrid->addMultiCellWidget(myNode2, 2, 2, 1, 2);
233 myReverseChk = new QCheckBox(tr("REVERSE"), aPatGrp);
235 // CreatePoly check box
236 myCreatePolygonsChk = new QCheckBox( tr( "CREATE_POLYGONS_NEAR_BOUNDARY" ), aPatGrp );
237 myCreatePolyedrsChk = new QCheckBox( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ), aPatGrp );
239 // Pictures 2d and 3d
240 for (int i = 0; i < 2; i++) {
242 myPicture2d = new SMESHGUI_PatternWidget(aPatGrp),
243 myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
245 myPicture3d = new QFrame(aPatGrp),
246 myPreview3d = new QLabel(myPicture3d);
247 myPreview3d->setPixmap(iconSample3d);
248 QGridLayout* aLay = new QGridLayout(myPicture3d, 3, 3, 0, 0);
249 QSpacerItem* aSpacerH1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
250 QSpacerItem* aSpacerH2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
251 QSpacerItem* aSpacerV1 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
252 QSpacerItem* aSpacerV2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
253 aLay->addItem(aSpacerH1, 1, 0);
254 aLay->addItem(aSpacerH2, 1, 2);
255 aLay->addItem(aSpacerV1, 0, 1);
256 aLay->addItem(aSpacerV2, 2, 1);
257 aLay->addWidget(myPreview3d, 1, 1);
261 myPreviewChk = new QCheckBox(tr("PREVIEW"), aPatGrp);
263 // Connect signals and slots
265 connect(myTypeGrp, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
266 connect(myOpenBtn, SIGNAL(clicked()), SLOT(onOpen()));
267 connect(myNewBtn, SIGNAL(clicked()), SLOT(onNew()));
269 connect(myReverseChk, SIGNAL(toggled(bool)), SLOT(onReverse(bool)));
270 connect(myPreviewChk, SIGNAL(toggled(bool)), SLOT(onPreview(bool)));
271 connect(myRefine, SIGNAL(toggled(bool)), SLOT(onModeToggled(bool)));
273 connect(myNode1, SIGNAL(valueChanged(int)), SLOT(onNodeChanged(int)));
274 connect(myNode2, SIGNAL(valueChanged(int)), SLOT(onNodeChanged(int)));
276 connect(mySelEdit[Ids], SIGNAL(textChanged(const QString&)), SLOT(onTextChanged(const QString&)));
278 QMap< int, QPushButton* >::iterator anIter;
279 for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter)
280 connect(*anIter, SIGNAL(clicked()), SLOT(onSelInputChanged()));
285 //=======================================================================
286 // name : SMESHGUI_MeshPatternDlg::createButtonFrame
287 // Purpose : Create frame containing buttons
288 //=======================================================================
289 QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent)
291 QFrame* aFrame = new QFrame(theParent);
292 aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
294 myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
295 myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
296 myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
297 myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
299 QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
301 QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
303 aLay->addWidget(myOkBtn);
304 aLay->addWidget(myApplyBtn);
305 aLay->addItem(aSpacer);
306 aLay->addWidget(myCloseBtn);
307 aLay->addWidget(myHelpBtn);
309 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
310 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
311 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
312 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
317 //=======================================================================
318 // name : SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg
319 // Purpose : Destructor
320 //=======================================================================
321 SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg()
325 //=======================================================================
326 // name : SMESHGUI_MeshPatternDlg::Init
327 // Purpose : Init dialog fields, connect signals and slots, show dialog
328 //=======================================================================
329 void SMESHGUI_MeshPatternDlg::Init()
331 myPattern = SMESH::GetPattern();
333 myIsCreateDlgOpen = false;
337 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
338 myMesh = SMESH::SMESH_Mesh::_nil();
340 myMeshShape = GEOM::GEOM_Object::_nil();
341 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
342 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
343 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
345 // selection and SMESHGUI
346 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
347 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
348 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
350 myTypeGrp->setButton(Type_2d);
351 onTypeChanged(Type_2d);
352 onModeToggled(isRefine());
356 resize(minimumSize());
364 //=======================================================================
365 // name : SMESHGUI_MeshPatternDlg::isValid
366 // Purpose : Verify validity of entry data
367 //=======================================================================
368 bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess)
372 (myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 ||
373 myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true))))
376 (myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() ||
377 myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil())))
380 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
381 tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok);
385 if ( myName->text()=="" ) {
387 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
388 tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok);
395 //=======================================================================
396 // name : SMESHGUI_MeshPatternDlg::onApply
397 // Purpose : SLOT called when "Apply" button pressed.
398 //=======================================================================
399 bool SMESHGUI_MeshPatternDlg::onApply()
407 if (isRefine()) { // Refining existing mesh elements
410 SMESH::long_array_var varIds = new SMESH::long_array();
411 varIds->length(ids.count());
413 for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
416 ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
417 : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
419 } else { // Applying a pattern to geometrical object
420 if (myType == Type_2d)
421 myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());
423 myPattern->ApplyTo3DBlock(myGeomObj[Object], myGeomObj[Vertex1], myGeomObj[Vertex2]);
426 bool toCreatePolygons = myCreatePolygonsChk->isChecked();
427 bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked();
428 if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) {
429 //mySelectionMgr->clearSelected();
430 bool autoUpdate = SMESHGUI::automaticUpdate();
431 if (!isRefine() && autoUpdate) {
432 _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
433 SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str());
435 anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str());
437 SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
442 mySelectionMgr->clearSelected();
445 mySMESHGUI->updateObjBrowser(true);
447 mySelEdit[ Ids ]->setText("");
451 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
452 tr("SMESH_OPERATION_FAILED"), QMessageBox::Ok);
455 } catch (const SALOME::SALOME_Exception& S_ex) {
456 SalomeApp_Tools::QtCatchCorbaException(S_ex);
463 //=======================================================================
464 // name : SMESHGUI_MeshPatternDlg::onOk
465 // Purpose : SLOT called when "Ok" button pressed.
466 //=======================================================================
467 void SMESHGUI_MeshPatternDlg::onOk()
473 //=======================================================================
474 // name : SMESHGUI_MeshPatternDlg::onClose
475 // Purpose : SLOT called when "Close" button pressed. Close dialog
476 //=======================================================================
477 void SMESHGUI_MeshPatternDlg::onClose()
479 mySelectionMgr->clearFilters();
480 SMESH::SetPickable();
481 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
482 aViewWindow->SetSelectionMode(ActorSelection);
483 disconnect(mySelectionMgr, 0, this, 0);
484 disconnect(mySMESHGUI, 0, this, 0);
485 mySMESHGUI->ResetState();
490 //=================================================================================
491 // function : onHelp()
493 //=================================================================================
494 void SMESHGUI_MeshPatternDlg::onHelp()
496 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
498 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
502 platform = "winapplication";
504 platform = "application";
506 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
507 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
508 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
509 QObject::tr("BUT_OK"));
513 //=======================================================================
514 // name : SMESHGUI_MeshPatternDlg::onSelectionDone
515 // Purpose : SLOT called when selection changed
516 //=======================================================================
517 void SMESHGUI_MeshPatternDlg::onSelectionDone()
523 if (mySelInput == Mesh) {
525 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
526 if (aList.Extent() != 1)
529 // Retrieve mesh from selection
530 Handle(SALOME_InteractiveObject) anIO = aList.First();
531 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
532 if (aMesh->_is_nil())
535 // Get geom object corresponding to the mesh
536 _PTR(SObject) aSO = SMESH::FindSObject(aMesh.in());
537 myMeshShape = SMESH::GetGeom(aSO);
539 // Clear fields of geom objects if mesh was changed
540 if (myMesh != aMesh) {
541 for (int i = Object; i <= Ids; i++) {
542 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
543 mySelEdit[ i ]->setText("");
549 // Set name of mesh in line edit
551 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
552 mySelEdit[ Mesh ]->setText(aName);
554 } else if (mySelInput == Ids) {
556 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
557 if (aList.Extent() != 1)
561 if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds))
565 mySelEdit[ Ids ]->setText(anIds);
570 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
571 if (aList.Extent() != 1)
574 // Get geom object from selection
575 Handle(SALOME_InteractiveObject) anIO = aList.First();
576 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
577 if (anObj->_is_nil())
580 // Clear fields of vertexes if face or 3d block was changed
581 if (anObj != myGeomObj[ mySelInput ] && mySelInput == Object) {
582 for (int i = Vertex1; i <= Vertex2; i++) {
583 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
584 mySelEdit[ i ]->setText("");
588 myGeomObj[ mySelInput ] = anObj;
590 // Set name of geom object in line edit
592 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
593 mySelEdit[ mySelInput ]->setText(aName);
595 } catch (const SALOME::SALOME_Exception& S_ex) {
596 SalomeApp_Tools::QtCatchCorbaException(S_ex);
606 //=======================================================================
607 // name : SMESHGUI_MeshPatternDlg::resetSelInput
608 // Purpose : Reset fields corresponding to the current selection input
609 //=======================================================================
610 void SMESHGUI_MeshPatternDlg::resetSelInput()
612 if (mySelInput == Mesh)
614 myMesh = SMESH::SMESH_Mesh::_nil();
615 myMeshShape = GEOM::GEOM_Object::_nil();
619 myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil();
621 mySelEdit[ mySelInput ]->setText("");
624 //=======================================================================
625 // name : SMESHGUI_MeshPatternDlg::onDeactivate
626 // Purpose : SLOT called when dialog must be deativated
627 //=======================================================================
628 void SMESHGUI_MeshPatternDlg::onDeactivate()
630 mySelectionMgr->clearFilters();
631 //if (myReverseChk->isChecked())
633 disconnect(mySelectionMgr, 0, this, 0);
637 //=======================================================================
638 // name : SMESHGUI_MeshPatternDlg::enterEvent
639 // Purpose : Event filter
640 //=======================================================================
641 void SMESHGUI_MeshPatternDlg::enterEvent (QEvent*)
643 if (myIsCreateDlgOpen)
646 if (myReverseChk->isChecked())
648 mySMESHGUI->EmitSignalDeactivateDialog();
651 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
652 onTextChanged(mySelEdit[Ids]->text());
655 //=======================================================================
656 // name : SMESHGUI_MeshPatternDlg::closeEvent
658 //=======================================================================
659 void SMESHGUI_MeshPatternDlg::closeEvent (QCloseEvent*)
664 //=======================================================================
665 // name : SMESHGUI_MeshPatternDlg::onSelInputChanged
666 // Purpose : SLOT. Called when -> button clicked.
667 // Change current selection input field
668 //=======================================================================
669 void SMESHGUI_MeshPatternDlg::onSelInputChanged()
671 const QObject* aSender = sender();
672 for (int i = Mesh; i <= Ids; i++)
673 if (aSender == mySelBtn[ i ])
680 //=======================================================================
681 // name : SMESHGUI_MeshPatternDlg::prepareFilters
682 // Purpose : Prepare filters for dialog
683 //=======================================================================
684 QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const
686 static QStringList aList;
689 aList.append(tr("PATTERN_FILT"));
690 //aList.append(tr("ALL_FILES_FILTER"));
696 //=======================================================================
697 // name : SMESHGUI_MeshPatternDlg::autoExtension
698 // Purpose : Append extension to the file name
699 //=======================================================================
700 QString SMESHGUI_MeshPatternDlg::autoExtension (const QString& theFileName) const
702 QString anExt = theFileName.section('.', -1);
703 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
706 //=======================================================================
707 // name : SMESHGUI_MeshPatternDlg::onOpen
708 // Purpose : SLOT. Called when "Open" button clicked.
709 // Displays file open dialog
710 //=======================================================================
711 void SMESHGUI_MeshPatternDlg::onOpen()
713 SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, true);
714 aDlg->setCaption(tr("LOAD_PATTERN"));
715 aDlg->setMode(QFileDialog::ExistingFile);
716 aDlg->setFilters(prepareFilters());
717 if (myName->text() != "")
718 aDlg->setSelection(myName->text() + ".smp");
719 QPushButton* anOkBtn = (QPushButton*)aDlg->child("OK", "QPushButton");
721 anOkBtn->setText(tr("SMESH_BUT_OK"));
723 if (aDlg->exec() != Accepted)
726 QString fName = aDlg->selectedFile();
730 if (QFileInfo(fName).extension().isEmpty())
731 fName = autoExtension(fName);
733 fName = QDir::convertSeparators(fName);
735 QString prev = QDir::convertSeparators(myName->text());
739 // Read string from file
741 if (!aFile.open(IO_ReadOnly)) {
742 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
743 tr("ERROR_OF_OPENING"), QMessageBox::Ok);
747 QByteArray aDataArray = aFile.readAll();
748 const char* aData = aDataArray.data();
750 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
751 tr("ERROR_OF_READING"), QMessageBox::Ok);
755 if (loadFromFile(aData))
756 myName->setText(QFileInfo(fName).baseName());
762 //=======================================================================
763 // name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg
764 // Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close"
765 //=======================================================================
766 void SMESHGUI_MeshPatternDlg::onCloseCreationDlg()
769 myIsCreateDlgOpen = false;
772 //=======================================================================
773 // name : SMESHGUI_MeshPatternDlg::onOkCreationDlg
774 // Purpose : SLOT. Called when "Pattern creation" dialog closed with OK
775 // or SAVE buttons. Initialize myPattern field. Redisplay preview
776 //=======================================================================
777 void SMESHGUI_MeshPatternDlg::onOkCreationDlg()
779 myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern());
780 myName->setText(myCreationDlg->GetPatternName());
786 myIsCreateDlgOpen = false;
789 //=======================================================================
790 // name : SMESHGUI_MeshPatternDlg::onNew
791 // Purpose : SLOT. Called when "New..." button clicked. Create new pattern
792 //=======================================================================
793 void SMESHGUI_MeshPatternDlg::onNew()
796 myIsCreateDlgOpen = true;
797 if (myCreationDlg == 0)
799 myCreationDlg = new SMESHGUI_CreatePatternDlg( mySMESHGUI, myType);
800 connect(myCreationDlg, SIGNAL(NewPattern()), SLOT(onOkCreationDlg()));
801 connect(myCreationDlg, SIGNAL(Close()), SLOT(onCloseCreationDlg()));
804 myCreationDlg->Init(myType);
806 myCreationDlg->SetMesh(myMesh);
807 myCreationDlg->show();
810 //=======================================================================
811 // name : SMESHGUI_MeshPatternDlg::onReverse
812 // Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged
813 // Calculate new points of the mesh to be created. Redisplay preview
814 //=======================================================================
815 void SMESHGUI_MeshPatternDlg::onReverse (bool)
820 //=======================================================================
822 // name : SMESHGUI_MeshPatternDlg::onPreview
823 // Purpose : SLOT. Called when state of "Preview" checkbox changed
824 // Display/Erase preview
825 //=======================================================================
826 void SMESHGUI_MeshPatternDlg::onPreview (bool)
831 //=======================================================================
832 // name : SMESHGUI_MeshPatternDlg::displayPreview
833 // Purpose : Display preview
834 //=======================================================================
835 void SMESHGUI_MeshPatternDlg::displayPreview()
838 // Redisplay preview in dialog
839 SMESH::point_array_var pnts = myPattern->GetPoints();
840 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
841 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);
843 if (pnts->length() == 0 ||
844 keyPoints->length() == 0 ||
845 elemPoints->length() == 0) {
849 PointVector aPoints(pnts->length());
850 QValueVector<int> aKeyPoints(keyPoints->length());
851 ConnectivityVector anElemPoints(elemPoints->length());
853 for (int i = 0, n = pnts->length(); i < n; i++)
854 aPoints[ i ] = pnts[ i ];
856 for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++)
857 aKeyPoints[ i2 ] = keyPoints[ i2 ];
859 for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
860 QValueVector<int> aVec(elemPoints[ i3 ].length());
861 for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
862 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
864 anElemPoints[ i3 ] = aVec;
867 myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints);
870 // Redisplay preview in 3D viewer
871 if (myPreviewActor != 0) {
872 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
873 vf->RemoveActor(myPreviewActor);
876 myPreviewActor->Delete();
880 if (!myPreviewChk->isChecked() || !isValid(false))
883 vtkUnstructuredGrid* aGrid = getGrid();
887 // Create and display actor
888 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
889 aMapper->SetInput(aGrid);
891 myPreviewActor = SALOME_Actor::New();
892 myPreviewActor->PickableOff();
893 myPreviewActor->SetMapper(aMapper);
895 vtkProperty* aProp = vtkProperty::New();
896 aProp->SetRepresentationToWireframe();
897 aProp->SetColor(250, 0, 250);
898 if (SMESH::FindActorByObject(myMesh))
899 aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 1 );
901 aProp->SetLineWidth(1);
902 myPreviewActor->SetProperty(aProp);
904 myPreviewActor->SetRepresentation(3);
906 SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
907 SMESH::GetCurrentVtkView()->Repaint();
911 } catch (const SALOME::SALOME_Exception& S_ex) {
912 SalomeApp_Tools::QtCatchCorbaException(S_ex);
919 //=======================================================================
920 // name : SMESHGUI_MeshPatternDlg::erasePreview
921 // Purpose : Erase preview
922 //=======================================================================
923 void SMESHGUI_MeshPatternDlg::erasePreview()
925 // Erase preview in 2D viewer
926 myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector());
928 // Erase preview in 3D viewer
929 if (myPreviewActor == 0)
933 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView())
935 vf->RemoveActor(myPreviewActor);
938 myPreviewActor->Delete();
942 //=======================================================================
943 // name : SMESHGUI_MeshPatternDlg::updateWgState
944 // Purpose : Enable/disable selection widgets
945 //=======================================================================
946 void SMESHGUI_MeshPatternDlg::updateWgState()
948 if (myMesh->_is_nil()) {
949 for (int i = Object; i <= Ids; i++) {
950 mySelBtn [ i ]->setEnabled(false);
951 mySelEdit[ i ]->setEnabled(false);
952 mySelEdit[ i ]->setText("");
954 myNode1->setEnabled(false);
955 myNode2->setEnabled(false);
956 myNode1->setRange(0, 0);
957 myNode2->setRange(0, 0);
959 mySelBtn [ Object ]->setEnabled(true);
960 mySelEdit[ Object ]->setEnabled(true);
961 mySelBtn [ Ids ] ->setEnabled(true);
962 mySelEdit[ Ids ] ->setEnabled(true);
964 if (myGeomObj[ Object ]->_is_nil()) {
965 for (int i = Vertex1; i <= Vertex2; i++) {
966 mySelBtn [ i ]->setEnabled(false);
967 mySelEdit[ i ]->setEnabled(false);
968 mySelEdit[ i ]->setText("");
971 for (int i = Object; i <= Vertex2; i++) {
972 mySelBtn [ i ]->setEnabled(true);
973 mySelEdit[ i ]->setEnabled(true);
978 if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) {
979 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
980 if (keyPoints->length()) {
981 myNode1->setEnabled(true);
982 myNode2->setEnabled(true);
983 myNode1->setRange(1, keyPoints->length());
984 myNode2->setRange(1, keyPoints->length());
989 myNode1->setEnabled(false);
990 myNode2->setEnabled(false);
991 myNode1->setRange(0, 0);
992 myNode2->setRange(0, 0);
996 //=======================================================================
997 // name : SMESHGUI_MeshPatternDlg::activateSelection
998 // Purpose : Activate selection in accordance with current selection input
999 //=======================================================================
1000 void SMESHGUI_MeshPatternDlg::activateSelection()
1002 mySelectionMgr->clearFilters();
1003 if (mySelInput == Ids) {
1004 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1006 SMESH::SetPickable(anActor);
1008 if (myType == Type_2d)
1010 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1011 aViewWindow->SetSelectionMode(FaceSelection);
1015 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1016 aViewWindow->SetSelectionMode(CellSelection);
1020 SMESH::SetPickable();
1021 //mySelectionMgr->setSelectionModes(ActorSelection);
1022 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1023 aViewWindow->SetSelectionMode(ActorSelection);
1026 if (mySelInput == Object && !myMeshShape->_is_nil()) {
1027 if (myType == Type_2d) {
1029 mySelectionMgr->installFilter
1030 (new SMESH_NumberFilter ("GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape));
1032 mySelectionMgr->installFilter
1033 (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape));
1035 TColStd_MapOfInteger aTypes;
1036 aTypes.Add(TopAbs_SHELL);
1037 aTypes.Add(TopAbs_SOLID);
1038 mySelectionMgr->installFilter
1039 (new SMESH_NumberFilter ("GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true));
1041 } else if ((mySelInput == Vertex1 || mySelInput == Vertex2) && !myGeomObj[ Object ]->_is_nil()) {
1042 mySelectionMgr->installFilter
1043 (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ]));
1048 //=======================================================================
1049 // name : SMESHGUI_MeshPatternDlg::loadFromFile
1050 // Purpose : Load pattern from file
1051 //=======================================================================
1052 bool SMESHGUI_MeshPatternDlg::loadFromFile (const QString& theName)
1055 SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
1057 if (!aPattern->LoadFromFile(theName.latin1()) ||
1058 myType == Type_2d && !aPattern->Is2D()) {
1059 SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();
1061 if (aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr("ERR_READ_NB_POINTS");
1062 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr("ERR_READ_POINT_COORDS");
1063 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS) aMess = tr("ERR_READ_TOO_FEW_POINTS");
1064 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr("ERR_READ_3D_COORD");
1065 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr("ERR_READ_NO_KEYPOINT");
1066 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr("ERR_READ_BAD_INDEX");
1067 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr("ERR_READ_ELEM_POINTS");
1068 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr("ERR_READ_NO_ELEMS");
1069 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr("ERR_READ_BAD_KEY_POINT");
1070 else aMess = tr("ERROR_OF_LOADING");
1072 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), aMess, QMessageBox::Ok);
1075 myPattern = aPattern;
1078 } catch (const SALOME::SALOME_Exception& S_ex) {
1079 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1080 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
1081 tr("ERROR_OF_LOADING"), QMessageBox::Ok);
1086 //=======================================================================
1087 // name : SMESHGUI_MeshPatternDlg::onTypeChanged
1088 // Purpose : SLOT. Called when pattern type changed.
1089 // Change dialog's look and feel
1090 //=======================================================================
1091 void SMESHGUI_MeshPatternDlg::onTypeChanged (int theType)
1093 if (myType == theType)
1099 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
1100 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
1101 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
1102 myPattern = SMESH::GetPattern();
1104 myName->setText("");
1105 mySelEdit[ Object ]->setText("");
1106 mySelEdit[ Vertex1 ]->setText("");
1107 mySelEdit[ Vertex2 ]->setText("");
1108 mySelEdit[ Ids ] ->setText("");
1109 myCreatePolygonsChk->show();
1110 myCreatePolyedrsChk->show();
1112 if (theType == Type_2d) {
1114 mySelLbl [ Vertex2 ]->hide();
1115 mySelBtn [ Vertex2 ]->hide();
1116 mySelEdit[ Vertex2 ]->hide();
1117 myReverseChk->show();
1118 myPicture2d->show();
1119 myPicture3d->hide();
1120 mySelLbl[ Object ]->setText(tr("FACE"));
1121 mySelLbl[ Vertex1 ]->setText(tr("VERTEX"));
1123 mySelLbl[ Ids ]->setText(tr("MESH_FACES"));
1128 mySelLbl [ Vertex2 ]->show();
1129 mySelBtn [ Vertex2 ]->show();
1130 mySelEdit[ Vertex2 ]->show();
1131 myReverseChk->hide();
1132 myPicture2d->hide();
1133 myPicture3d->show();
1134 mySelLbl[ Object ]->setText(tr("3D_BLOCK"));
1135 mySelLbl[ Vertex1 ]->setText(tr("VERTEX1"));
1136 mySelLbl[ Vertex2 ]->setText(tr("VERTEX2"));
1138 mySelLbl[ Ids ]->setText(tr("MESH_VOLUMES"));
1144 activateSelection();
1149 //=======================================================================
1150 // name : SMESHGUI_MeshPatternDlg::getGrid
1151 // Purpose : Get unstructured grid for pattern
1152 //=======================================================================
1153 vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid()
1156 // Get points from pattern
1157 SMESH::point_array_var pnts;
1158 QValueList<int> ids;
1159 if (isRefine() && getIds(ids)) {
1160 SMESH::long_array_var varIds = new SMESH::long_array();
1161 varIds->length(ids.count());
1163 for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
1165 pnts = myType == Type_2d
1166 ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
1167 : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
1169 pnts = myType == Type_2d
1170 ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked())
1171 : myPattern->ApplyTo3DBlock(myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ]);
1174 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(true);
1176 if (pnts->length() == 0 || elemPoints->length() == 0)
1179 // to do : to be removed /////////////////////////////////////////////
1182 for (int i1 = 0, n1 = pnts->length(); i1 < n1; i1++)
1183 printf("%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z);
1185 printf("\nELEMENTS : \n");
1186 for (int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++)
1190 for (int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++)
1191 printf("%d ", elemPoints[ i2 ][ i3 ]);
1197 //////////////////////////////////////////////////////////////////////
1199 // Calculate number of points used for cell
1200 vtkIdType aNbCells = elemPoints->length();
1201 vtkIdType aCellsSize = 0;
1202 for (int i = 0, n = elemPoints->length(); i < n; i++)
1203 aCellsSize += elemPoints[ i ].length();
1205 // Create unstructured grid and other usefull arrays
1206 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1208 vtkCellArray* aConnectivity = vtkCellArray::New();
1209 aConnectivity->Allocate(aCellsSize, 0);
1211 vtkPoints* aPoints = vtkPoints::New();
1212 aPoints->SetNumberOfPoints(pnts->length());
1214 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1215 aCellTypesArray->SetNumberOfComponents(1);
1216 aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
1218 vtkIdList *anIdList = vtkIdList::New();
1220 // Fill array of points
1221 for (int p = 0, nbPnt = pnts->length(); p < nbPnt; p++)
1222 aPoints->SetPoint(p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z);
1224 for (int e = 0, nbElem = elemPoints->length(); e < nbElem; e++) {
1225 int nbPoints = elemPoints[ e ].length();
1226 anIdList->SetNumberOfIds(nbPoints);
1227 for (int i = 0; i < nbPoints; i++)
1228 anIdList->SetId(i, elemPoints[ e ][ i ]);
1230 aConnectivity->InsertNextCell(anIdList);
1232 if (nbPoints == 3) aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1233 else if (nbPoints == 5) aCellTypesArray->InsertNextValue(VTK_PYRAMID);
1234 else if (nbPoints == 6) aCellTypesArray->InsertNextValue(VTK_WEDGE);
1235 else if (nbPoints == 8) aCellTypesArray->InsertNextValue(VTK_HEXAHEDRON);
1236 else if (nbPoints == 4 && myType == Type_2d) aCellTypesArray->InsertNextValue(VTK_QUAD);
1237 else if (nbPoints == 4 && myType == Type_3d) aCellTypesArray->InsertNextValue(VTK_TETRA);
1238 else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL);
1241 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1242 aCellLocationsArray->SetNumberOfComponents(1);
1243 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1245 aConnectivity->InitTraversal();
1246 for (vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
1247 aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
1249 aGrid->SetPoints(aPoints);
1250 aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
1252 aConnectivity->Delete();
1254 aCellTypesArray->Delete();
1256 aCellLocationsArray->Delete();
1264 //=======================================================================
1265 // name : onModeToggled
1267 //=======================================================================
1268 void SMESHGUI_MeshPatternDlg::onModeToggled (bool on)
1270 on ? myRefineGrp->show() : myRefineGrp->hide();
1271 on ? myGeomGrp->hide() : myGeomGrp->show();
1276 //=======================================================================
1279 //=======================================================================
1280 bool SMESHGUI_MeshPatternDlg::isRefine() const
1282 return myRefine->isChecked();
1285 //=======================================================================
1286 // name : onTextChanged
1288 //=======================================================================
1289 void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText)
1291 if (myBusy || !isRefine())
1296 if (mySelInput != Ids) {
1298 activateSelection();
1301 // hilight entered elements/nodes
1302 SMDS_Mesh* aMesh = 0;
1303 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1305 aMesh = anActor->GetObject()->GetMesh();
1308 QStringList aListId = QStringList::split(" ", theNewText, false);
1310 TColStd_MapOfInteger newIndices;
1312 for (int i = 0; i < aListId.count(); i++) {
1313 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
1314 if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume))
1315 newIndices.Add(e->GetID());
1317 mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false);
1318 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1319 aViewWindow->highlight( anActor->getIO(), true, true );
1327 //=======================================================================
1328 // name : onNodeChanged
1330 //=======================================================================
1331 void SMESHGUI_MeshPatternDlg::onNodeChanged (int value)
1333 if (myType == Type_3d) {
1334 QSpinBox* first = (QSpinBox*)sender();
1335 QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
1336 int secondVal = second->value();
1337 if (secondVal == value) {
1338 secondVal = value == second->maxValue() ? second->minValue() : value + 1;
1339 bool blocked = second->signalsBlocked();
1340 second->blockSignals(true);
1341 second->setValue(secondVal);
1342 second->blockSignals(blocked);
1349 //=======================================================================
1352 //=======================================================================
1353 bool SMESHGUI_MeshPatternDlg::getIds (QValueList<int>& ids) const
1356 QStringList strIds = QStringList::split(" ", mySelEdit[Ids]->text());
1359 for (QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it) {
1360 val = (*it).toInt(&isOk);
1368 //=======================================================================
1371 //=======================================================================
1372 int SMESHGUI_MeshPatternDlg::getNode (bool second) const
1374 return second ? myNode2->value() - 1 : myNode1->value() - 1;
1377 //=================================================================================
1378 // function : keyPressEvent()
1380 //=================================================================================
1381 void SMESHGUI_MeshPatternDlg::keyPressEvent( QKeyEvent* e )
1383 QDialog::keyPressEvent( e );
1384 if ( e->isAccepted() )
1387 if ( e->key() == Key_F1 )