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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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"
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 <vtkIntArray.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);
389 //=======================================================================
390 // name : SMESHGUI_MeshPatternDlg::onApply
391 // Purpose : SLOT called when "Apply" button pressed.
392 //=======================================================================
393 bool SMESHGUI_MeshPatternDlg::onApply()
401 if (isRefine()) { // Refining existing mesh elements
404 SMESH::long_array_var varIds = new SMESH::long_array();
405 varIds->length(ids.count());
407 for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
410 ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
411 : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
413 } else { // Applying a pattern to geometrical object
414 if (myType == Type_2d)
415 myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked());
417 myPattern->ApplyTo3DBlock(myGeomObj[Object], myGeomObj[Vertex1], myGeomObj[Vertex2]);
420 bool toCreatePolygons = myCreatePolygonsChk->isChecked();
421 bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked();
422 if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) {
423 //mySelectionMgr->clearSelected();
424 bool autoUpdate = SMESHGUI::automaticUpdate();
425 if (!isRefine() && autoUpdate) {
426 _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
427 SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str());
429 anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str());
431 SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
438 mySMESHGUI->updateObjBrowser(true);
440 mySelEdit[ Ids ]->setText("");
444 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
445 tr("SMESH_OPERATION_FAILED"), QMessageBox::Ok);
448 } catch (const SALOME::SALOME_Exception& S_ex) {
449 SalomeApp_Tools::QtCatchCorbaException(S_ex);
456 //=======================================================================
457 // name : SMESHGUI_MeshPatternDlg::onOk
458 // Purpose : SLOT called when "Ok" button pressed.
459 //=======================================================================
460 void SMESHGUI_MeshPatternDlg::onOk()
466 //=======================================================================
467 // name : SMESHGUI_MeshPatternDlg::onClose
468 // Purpose : SLOT called when "Close" button pressed. Close dialog
469 //=======================================================================
470 void SMESHGUI_MeshPatternDlg::onClose()
472 mySelectionMgr->clearFilters();
473 SMESH::SetPickable();
474 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
475 aViewWindow->SetSelectionMode(ActorSelection);
476 disconnect(mySelectionMgr, 0, this, 0);
477 disconnect(mySMESHGUI, 0, this, 0);
478 mySMESHGUI->ResetState();
483 //=================================================================================
484 // function : onHelp()
486 //=================================================================================
487 void SMESHGUI_MeshPatternDlg::onHelp()
489 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
491 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
493 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
494 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
495 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
496 QObject::tr("BUT_OK"));
500 //=======================================================================
501 // name : SMESHGUI_MeshPatternDlg::onSelectionDone
502 // Purpose : SLOT called when selection changed
503 //=======================================================================
504 void SMESHGUI_MeshPatternDlg::onSelectionDone()
510 if (mySelInput == Mesh) {
512 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
513 if (aList.Extent() != 1)
516 // Retrieve mesh from selection
517 Handle(SALOME_InteractiveObject) anIO = aList.First();
518 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
519 if (aMesh->_is_nil())
522 // Get geom object corresponding to the mesh
523 _PTR(SObject) aSO = SMESH::FindSObject(aMesh.in());
524 myMeshShape = SMESH::GetGeom(aSO);
526 // Clear fields of geom objects if mesh was changed
527 if (myMesh != aMesh) {
528 for (int i = Object; i <= Ids; i++) {
529 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
530 mySelEdit[ i ]->setText("");
536 // Set name of mesh in line edit
538 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
539 mySelEdit[ Mesh ]->setText(aName);
541 } else if (mySelInput == Ids) {
543 mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
544 if (aList.Extent() != 1)
548 if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds))
552 mySelEdit[ Ids ]->setText(anIds);
557 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
558 if (aList.Extent() != 1)
561 // Get geom object from selection
562 Handle(SALOME_InteractiveObject) anIO = aList.First();
563 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
564 if (anObj->_is_nil())
567 // Clear fields of vertexes if face or 3d block was changed
568 if (anObj != myGeomObj[ mySelInput ] && mySelInput == Object) {
569 for (int i = Vertex1; i <= Vertex2; i++) {
570 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
571 mySelEdit[ i ]->setText("");
575 myGeomObj[ mySelInput ] = anObj;
577 // Set name of geom object in line edit
579 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
580 mySelEdit[ mySelInput ]->setText(aName);
582 } catch (const SALOME::SALOME_Exception& S_ex) {
583 SalomeApp_Tools::QtCatchCorbaException(S_ex);
593 //=======================================================================
594 // name : SMESHGUI_MeshPatternDlg::resetSelInput
595 // Purpose : Reset fields corresponding to the current selection input
596 //=======================================================================
597 void SMESHGUI_MeshPatternDlg::resetSelInput()
599 if (mySelInput == Mesh)
601 myMesh = SMESH::SMESH_Mesh::_nil();
602 myMeshShape = GEOM::GEOM_Object::_nil();
606 myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil();
608 mySelEdit[ mySelInput ]->setText("");
611 //=======================================================================
612 // name : SMESHGUI_MeshPatternDlg::onDeactivate
613 // Purpose : SLOT called when dialog must be deativated
614 //=======================================================================
615 void SMESHGUI_MeshPatternDlg::onDeactivate()
617 mySelectionMgr->clearFilters();
618 //if (myReverseChk->isChecked())
620 disconnect(mySelectionMgr, 0, this, 0);
624 //=======================================================================
625 // name : SMESHGUI_MeshPatternDlg::enterEvent
626 // Purpose : Event filter
627 //=======================================================================
628 void SMESHGUI_MeshPatternDlg::enterEvent (QEvent*)
630 if (myIsCreateDlgOpen)
633 if (myReverseChk->isChecked())
635 mySMESHGUI->EmitSignalDeactivateDialog();
638 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
639 onTextChanged(mySelEdit[Ids]->text());
642 //=======================================================================
643 // name : SMESHGUI_MeshPatternDlg::closeEvent
645 //=======================================================================
646 void SMESHGUI_MeshPatternDlg::closeEvent (QCloseEvent*)
651 //=======================================================================
652 // name : SMESHGUI_MeshPatternDlg::onSelInputChanged
653 // Purpose : SLOT. Called when -> button clicked.
654 // Change current selection input field
655 //=======================================================================
656 void SMESHGUI_MeshPatternDlg::onSelInputChanged()
658 const QObject* aSender = sender();
659 for (int i = Mesh; i <= Ids; i++)
660 if (aSender == mySelBtn[ i ])
667 //=======================================================================
668 // name : SMESHGUI_MeshPatternDlg::prepareFilters
669 // Purpose : Prepare filters for dialog
670 //=======================================================================
671 QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const
673 static QStringList aList;
676 aList.append(tr("PATTERN_FILT"));
677 //aList.append(tr("ALL_FILES_FILTER"));
683 //=======================================================================
684 // name : SMESHGUI_MeshPatternDlg::autoExtension
685 // Purpose : Append extension to the file name
686 //=======================================================================
687 QString SMESHGUI_MeshPatternDlg::autoExtension (const QString& theFileName) const
689 QString anExt = theFileName.section('.', -1);
690 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
693 //=======================================================================
694 // name : SMESHGUI_MeshPatternDlg::onOpen
695 // Purpose : SLOT. Called when "Open" button clicked.
696 // Displays file open dialog
697 //=======================================================================
698 void SMESHGUI_MeshPatternDlg::onOpen()
700 SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, true);
701 aDlg->setCaption(tr("LOAD_PATTERN"));
702 aDlg->setMode(QFileDialog::ExistingFile);
703 aDlg->setFilters(prepareFilters());
704 if (myName->text() != "")
705 aDlg->setSelection(myName->text() + ".smp");
706 QPushButton* anOkBtn = (QPushButton*)aDlg->child("OK", "QPushButton");
708 anOkBtn->setText(tr("SMESH_BUT_OK"));
710 if (aDlg->exec() != Accepted)
713 QString fName = aDlg->selectedFile();
717 if (QFileInfo(fName).extension().isEmpty())
718 fName = autoExtension(fName);
720 fName = QDir::convertSeparators(fName);
722 QString prev = QDir::convertSeparators(myName->text());
726 // Read string from file
728 if (!aFile.open(IO_ReadOnly)) {
729 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
730 tr("ERROR_OF_OPENING"), QMessageBox::Ok);
734 QByteArray aDataArray = aFile.readAll();
735 const char* aData = aDataArray.data();
737 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
738 tr("ERROR_OF_READING"), QMessageBox::Ok);
742 if (loadFromFile(aData))
743 myName->setText(QFileInfo(fName).baseName());
749 //=======================================================================
750 // name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg
751 // Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close"
752 //=======================================================================
753 void SMESHGUI_MeshPatternDlg::onCloseCreationDlg()
756 myIsCreateDlgOpen = false;
759 //=======================================================================
760 // name : SMESHGUI_MeshPatternDlg::onOkCreationDlg
761 // Purpose : SLOT. Called when "Pattern creation" dialog closed with OK
762 // or SAVE buttons. Initialize myPattern field. Redisplay preview
763 //=======================================================================
764 void SMESHGUI_MeshPatternDlg::onOkCreationDlg()
766 myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern());
767 myName->setText(myCreationDlg->GetPatternName());
773 myIsCreateDlgOpen = false;
776 //=======================================================================
777 // name : SMESHGUI_MeshPatternDlg::onNew
778 // Purpose : SLOT. Called when "New..." button clicked. Create new pattern
779 //=======================================================================
780 void SMESHGUI_MeshPatternDlg::onNew()
783 myIsCreateDlgOpen = true;
784 if (myCreationDlg == 0)
786 myCreationDlg = new SMESHGUI_CreatePatternDlg( mySMESHGUI, myType);
787 connect(myCreationDlg, SIGNAL(NewPattern()), SLOT(onOkCreationDlg()));
788 connect(myCreationDlg, SIGNAL(Close()), SLOT(onCloseCreationDlg()));
791 myCreationDlg->Init(myType);
793 myCreationDlg->SetMesh(myMesh);
794 myCreationDlg->show();
797 //=======================================================================
798 // name : SMESHGUI_MeshPatternDlg::onReverse
799 // Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged
800 // Calculate new points of the mesh to be created. Redisplay preview
801 //=======================================================================
802 void SMESHGUI_MeshPatternDlg::onReverse (bool)
807 //=======================================================================
809 // name : SMESHGUI_MeshPatternDlg::onPreview
810 // Purpose : SLOT. Called when state of "Preview" checkbox changed
811 // Display/Erase preview
812 //=======================================================================
813 void SMESHGUI_MeshPatternDlg::onPreview (bool)
818 //=======================================================================
819 // name : SMESHGUI_MeshPatternDlg::displayPreview
820 // Purpose : Display preview
821 //=======================================================================
822 void SMESHGUI_MeshPatternDlg::displayPreview()
825 // Redisplay preview in dialog
826 SMESH::point_array_var pnts = myPattern->GetPoints();
827 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
828 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);
830 if (pnts->length() == 0 ||
831 keyPoints->length() == 0 ||
832 elemPoints->length() == 0) {
836 PointVector aPoints(pnts->length());
837 QValueVector<int> aKeyPoints(keyPoints->length());
838 ConnectivityVector anElemPoints(elemPoints->length());
840 for (int i = 0, n = pnts->length(); i < n; i++)
841 aPoints[ i ] = pnts[ i ];
843 for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++)
844 aKeyPoints[ i2 ] = keyPoints[ i2 ];
846 for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
847 QValueVector<int> aVec(elemPoints[ i3 ].length());
848 for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
849 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
851 anElemPoints[ i3 ] = aVec;
854 myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints);
857 // Redisplay preview in 3D viewer
858 if (myPreviewActor != 0) {
859 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView()) {
860 vf->RemoveActor(myPreviewActor);
863 myPreviewActor->Delete();
867 if (!myPreviewChk->isChecked() || !isValid(false))
870 vtkUnstructuredGrid* aGrid = getGrid();
874 // Create and display actor
875 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
876 aMapper->SetInput(aGrid);
878 myPreviewActor = SALOME_Actor::New();
879 myPreviewActor->PickableOff();
880 myPreviewActor->SetMapper(aMapper);
882 vtkProperty* aProp = vtkProperty::New();
883 aProp->SetRepresentationToWireframe();
884 aProp->SetColor(250, 0, 250);
885 if (SMESH::FindActorByObject(myMesh))
886 aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 1 );
888 aProp->SetLineWidth(1);
889 myPreviewActor->SetProperty(aProp);
891 myPreviewActor->SetRepresentation(3);
893 SMESH::GetCurrentVtkView()->AddActor(myPreviewActor);
894 SMESH::GetCurrentVtkView()->Repaint();
898 } catch (const SALOME::SALOME_Exception& S_ex) {
899 SalomeApp_Tools::QtCatchCorbaException(S_ex);
906 //=======================================================================
907 // name : SMESHGUI_MeshPatternDlg::erasePreview
908 // Purpose : Erase preview
909 //=======================================================================
910 void SMESHGUI_MeshPatternDlg::erasePreview()
912 // Erase preview in 2D viewer
913 myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector());
915 // Erase preview in 3D viewer
916 if (myPreviewActor == 0)
920 if (SVTK_ViewWindow* vf = SMESH::GetCurrentVtkView())
922 vf->RemoveActor(myPreviewActor);
925 myPreviewActor->Delete();
929 //=======================================================================
930 // name : SMESHGUI_MeshPatternDlg::updateWgState
931 // Purpose : Enable/disable selection widgets
932 //=======================================================================
933 void SMESHGUI_MeshPatternDlg::updateWgState()
935 if (myMesh->_is_nil()) {
936 for (int i = Object; i <= Ids; i++) {
937 mySelBtn [ i ]->setEnabled(false);
938 mySelEdit[ i ]->setEnabled(false);
939 mySelEdit[ i ]->setText("");
941 myNode1->setEnabled(false);
942 myNode2->setEnabled(false);
943 myNode1->setRange(0, 0);
944 myNode2->setRange(0, 0);
946 mySelBtn [ Object ]->setEnabled(true);
947 mySelEdit[ Object ]->setEnabled(true);
948 mySelBtn [ Ids ] ->setEnabled(true);
949 mySelEdit[ Ids ] ->setEnabled(true);
951 if (myGeomObj[ Object ]->_is_nil()) {
952 for (int i = Vertex1; i <= Vertex2; i++) {
953 mySelBtn [ i ]->setEnabled(false);
954 mySelEdit[ i ]->setEnabled(false);
955 mySelEdit[ i ]->setText("");
958 for (int i = Object; i <= Vertex2; i++) {
959 mySelBtn [ i ]->setEnabled(true);
960 mySelEdit[ i ]->setEnabled(true);
965 if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) {
966 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
967 if (keyPoints->length()) {
968 myNode1->setEnabled(true);
969 myNode2->setEnabled(true);
970 myNode1->setRange(1, keyPoints->length());
971 myNode2->setRange(1, keyPoints->length());
976 myNode1->setEnabled(false);
977 myNode2->setEnabled(false);
978 myNode1->setRange(0, 0);
979 myNode2->setRange(0, 0);
983 //=======================================================================
984 // name : SMESHGUI_MeshPatternDlg::activateSelection
985 // Purpose : Activate selection in accordance with current selection input
986 //=======================================================================
987 void SMESHGUI_MeshPatternDlg::activateSelection()
989 mySelectionMgr->clearFilters();
990 if (mySelInput == Ids) {
991 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
993 SMESH::SetPickable(anActor);
995 if (myType == Type_2d)
997 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
998 aViewWindow->SetSelectionMode(FaceSelection);
1002 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1003 aViewWindow->SetSelectionMode(CellSelection);
1007 SMESH::SetPickable();
1008 //mySelectionMgr->setSelectionModes(ActorSelection);
1009 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1010 aViewWindow->SetSelectionMode(ActorSelection);
1013 if (mySelInput == Object && !myMeshShape->_is_nil()) {
1014 if (myType == Type_2d) {
1016 mySelectionMgr->installFilter
1017 (new SMESH_NumberFilter ("GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape));
1019 mySelectionMgr->installFilter
1020 (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape));
1022 TColStd_MapOfInteger aTypes;
1023 aTypes.Add(TopAbs_SHELL);
1024 aTypes.Add(TopAbs_SOLID);
1025 mySelectionMgr->installFilter
1026 (new SMESH_NumberFilter ("GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true));
1028 } else if ((mySelInput == Vertex1 || mySelInput == Vertex2) && !myGeomObj[ Object ]->_is_nil()) {
1029 mySelectionMgr->installFilter
1030 (new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ]));
1035 //=======================================================================
1036 // name : SMESHGUI_MeshPatternDlg::loadFromFile
1037 // Purpose : Load pattern from file
1038 //=======================================================================
1039 bool SMESHGUI_MeshPatternDlg::loadFromFile (const QString& theName)
1042 SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
1044 if (!aPattern->LoadFromFile(theName.latin1()) ||
1045 myType == Type_2d && !aPattern->Is2D()) {
1046 SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();
1048 if (aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr("ERR_READ_NB_POINTS");
1049 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr("ERR_READ_POINT_COORDS");
1050 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS) aMess = tr("ERR_READ_TOO_FEW_POINTS");
1051 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr("ERR_READ_3D_COORD");
1052 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr("ERR_READ_NO_KEYPOINT");
1053 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr("ERR_READ_BAD_INDEX");
1054 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr("ERR_READ_ELEM_POINTS");
1055 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr("ERR_READ_NO_ELEMS");
1056 else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr("ERR_READ_BAD_KEY_POINT");
1057 else aMess = tr("ERROR_OF_LOADING");
1059 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), aMess, QMessageBox::Ok);
1062 myPattern = aPattern;
1065 } catch (const SALOME::SALOME_Exception& S_ex) {
1066 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1067 QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
1068 tr("ERROR_OF_LOADING"), QMessageBox::Ok);
1073 //=======================================================================
1074 // name : SMESHGUI_MeshPatternDlg::onTypeChanged
1075 // Purpose : SLOT. Called when pattern type changed.
1076 // Change dialog's look and feel
1077 //=======================================================================
1078 void SMESHGUI_MeshPatternDlg::onTypeChanged (int theType)
1080 if (myType == theType)
1086 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
1087 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
1088 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
1089 myPattern = SMESH::GetPattern();
1091 myName->setText("");
1092 mySelEdit[ Object ]->setText("");
1093 mySelEdit[ Vertex1 ]->setText("");
1094 mySelEdit[ Vertex2 ]->setText("");
1095 mySelEdit[ Ids ] ->setText("");
1096 myCreatePolygonsChk->show();
1097 myCreatePolyedrsChk->show();
1099 if (theType == Type_2d) {
1101 mySelLbl [ Vertex2 ]->hide();
1102 mySelBtn [ Vertex2 ]->hide();
1103 mySelEdit[ Vertex2 ]->hide();
1104 myReverseChk->show();
1105 myPicture2d->show();
1106 myPicture3d->hide();
1107 mySelLbl[ Object ]->setText(tr("FACE"));
1108 mySelLbl[ Vertex1 ]->setText(tr("VERTEX"));
1110 mySelLbl[ Ids ]->setText(tr("MESH_FACES"));
1115 mySelLbl [ Vertex2 ]->show();
1116 mySelBtn [ Vertex2 ]->show();
1117 mySelEdit[ Vertex2 ]->show();
1118 myReverseChk->hide();
1119 myPicture2d->hide();
1120 myPicture3d->show();
1121 mySelLbl[ Object ]->setText(tr("3D_BLOCK"));
1122 mySelLbl[ Vertex1 ]->setText(tr("VERTEX1"));
1123 mySelLbl[ Vertex2 ]->setText(tr("VERTEX2"));
1125 mySelLbl[ Ids ]->setText(tr("MESH_VOLUMES"));
1131 activateSelection();
1136 //=======================================================================
1137 // name : SMESHGUI_MeshPatternDlg::getGrid
1138 // Purpose : Get unstructured grid for pattern
1139 //=======================================================================
1140 vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid()
1143 // Get points from pattern
1144 SMESH::point_array_var pnts;
1145 QValueList<int> ids;
1146 if (isRefine() && getIds(ids)) {
1147 SMESH::long_array_var varIds = new SMESH::long_array();
1148 varIds->length(ids.count());
1150 for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
1152 pnts = myType == Type_2d
1153 ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
1154 : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
1156 pnts = myType == Type_2d
1157 ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked())
1158 : myPattern->ApplyTo3DBlock(myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ]);
1161 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(true);
1163 if (pnts->length() == 0 || elemPoints->length() == 0)
1166 // to do : to be removed /////////////////////////////////////////////
1169 for (int i1 = 0, n1 = pnts->length(); i1 < n1; i1++)
1170 printf("%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z);
1172 printf("\nELEMENTS : \n");
1173 for (int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++)
1177 for (int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++)
1178 printf("%d ", elemPoints[ i2 ][ i3 ]);
1184 //////////////////////////////////////////////////////////////////////
1186 // Calculate number of points used for cell
1187 vtkIdType aNbCells = elemPoints->length();
1188 vtkIdType aCellsSize = 0;
1189 for (int i = 0, n = elemPoints->length(); i < n; i++)
1190 aCellsSize += elemPoints[ i ].length();
1192 // Create unstructured grid and other usefull arrays
1193 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1195 vtkCellArray* aConnectivity = vtkCellArray::New();
1196 aConnectivity->Allocate(aCellsSize, 0);
1198 vtkPoints* aPoints = vtkPoints::New();
1199 aPoints->SetNumberOfPoints(pnts->length());
1201 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1202 aCellTypesArray->SetNumberOfComponents(1);
1203 aCellTypesArray->Allocate(aNbCells * aCellTypesArray->GetNumberOfComponents());
1205 vtkIdList *anIdList = vtkIdList::New();
1207 // Fill array of points
1208 for (int p = 0, nbPnt = pnts->length(); p < nbPnt; p++)
1209 aPoints->SetPoint(p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z);
1211 for (int e = 0, nbElem = elemPoints->length(); e < nbElem; e++) {
1212 int nbPoints = elemPoints[ e ].length();
1213 anIdList->SetNumberOfIds(nbPoints);
1214 for (int i = 0; i < nbPoints; i++)
1215 anIdList->SetId(i, elemPoints[ e ][ i ]);
1217 aConnectivity->InsertNextCell(anIdList);
1219 if (nbPoints == 3) aCellTypesArray->InsertNextValue(VTK_TRIANGLE);
1220 else if (nbPoints == 5) aCellTypesArray->InsertNextValue(VTK_PYRAMID);
1221 else if (nbPoints == 6) aCellTypesArray->InsertNextValue(VTK_WEDGE);
1222 else if (nbPoints == 8) aCellTypesArray->InsertNextValue(VTK_HEXAHEDRON);
1223 else if (nbPoints == 4 && myType == Type_2d) aCellTypesArray->InsertNextValue(VTK_QUAD);
1224 else if (nbPoints == 4 && myType == Type_3d) aCellTypesArray->InsertNextValue(VTK_TETRA);
1225 else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL);
1228 vtkIntArray* aCellLocationsArray = vtkIntArray::New();
1229 aCellLocationsArray->SetNumberOfComponents(1);
1230 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1232 aConnectivity->InitTraversal();
1233 for (vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell(npts, pts); idType++)
1234 aCellLocationsArray->SetValue(idType, aConnectivity->GetTraversalLocation(npts));
1236 aGrid->SetPoints(aPoints);
1237 aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aConnectivity);
1239 aConnectivity->Delete();
1241 aCellTypesArray->Delete();
1243 aCellLocationsArray->Delete();
1251 //=======================================================================
1252 // name : onModeToggled
1254 //=======================================================================
1255 void SMESHGUI_MeshPatternDlg::onModeToggled (bool on)
1257 on ? myRefineGrp->show() : myRefineGrp->hide();
1258 on ? myGeomGrp->hide() : myGeomGrp->show();
1263 //=======================================================================
1266 //=======================================================================
1267 bool SMESHGUI_MeshPatternDlg::isRefine() const
1269 return myRefine->isChecked();
1272 //=======================================================================
1273 // name : onTextChanged
1275 //=======================================================================
1276 void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText)
1278 if (myBusy || !isRefine())
1283 if (mySelInput != Ids) {
1285 activateSelection();
1288 // hilight entered elements/nodes
1289 SMDS_Mesh* aMesh = 0;
1290 SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1292 aMesh = anActor->GetObject()->GetMesh();
1295 QStringList aListId = QStringList::split(" ", theNewText, false);
1297 TColStd_MapOfInteger newIndices;
1299 for (int i = 0; i < aListId.count(); i++) {
1300 const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
1301 if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume))
1302 newIndices.Add(e->GetID());
1304 mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false);
1305 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1306 aViewWindow->highlight( anActor->getIO(), true, true );
1314 //=======================================================================
1315 // name : onNodeChanged
1317 //=======================================================================
1318 void SMESHGUI_MeshPatternDlg::onNodeChanged (int value)
1320 if (myType == Type_3d) {
1321 QSpinBox* first = (QSpinBox*)sender();
1322 QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
1323 int secondVal = second->value();
1324 if (secondVal == value) {
1325 secondVal = value == second->maxValue() ? second->minValue() : value + 1;
1326 bool blocked = second->signalsBlocked();
1327 second->blockSignals(true);
1328 second->setValue(secondVal);
1329 second->blockSignals(blocked);
1336 //=======================================================================
1339 //=======================================================================
1340 bool SMESHGUI_MeshPatternDlg::getIds (QValueList<int>& ids) const
1343 QStringList strIds = QStringList::split(" ", mySelEdit[Ids]->text());
1346 for (QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it) {
1347 val = (*it).toInt(&isOk);
1355 //=======================================================================
1358 //=======================================================================
1359 int SMESHGUI_MeshPatternDlg::getNode (bool second) const
1361 return second ? myNode2->value() - 1 : myNode1->value() - 1;