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_CreatePatternDlg.cxx
24 // Author : Sergey LITONIN
27 #include "SMESHGUI_CreatePatternDlg.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_PatternWidget.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_PatternUtils.h"
35 #include "SMESHGUI_GEOMGenUtils.h"
37 #include "SMESH_NumberFilter.hxx"
39 #include "SUIT_ResourceMgr.h"
40 #include "SUIT_Desktop.h"
41 #include "SUIT_FileDlg.h"
42 #include "SUIT_Session.h"
43 #include "SUIT_MessageBox.h"
45 #include "SalomeApp_Study.h"
46 #include "LightApp_Application.h"
47 #include "LightApp_DataOwner.h"
48 #include "LightApp_SelectionMgr.h"
49 #include "SalomeApp_Tools.h"
51 #include "SALOMEDS_SObject.hxx"
53 #include "SALOME_ListIO.hxx"
54 #include "SVTK_ViewModel.h"
55 #include "SVTK_ViewWindow.h"
56 #include "SVTK_Selector.h"
57 #include "SVTK_Selection.h"
60 #include <TColStd_MapOfInteger.hxx>
65 #include <qlineedit.h>
66 #include <qpushbutton.h>
67 #include <qgroupbox.h>
69 #include <qradiobutton.h>
70 #include <qcheckbox.h>
71 #include <qbuttongroup.h>
72 #include <qmessagebox.h>
73 #include <qapplication.h>
79 * Class : SMESHGUI_CreatePatternDlg
80 * Description : Dialog to specify filters for VTK viewer
83 //=======================================================================
84 // function : SMESHGUI_CreatePatternDlg()
85 // purpose : Constructor
86 //=======================================================================
87 SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule,
90 : QDialog( SMESH::GetDesktop( theModule ), theName, false,
91 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
92 mySMESHGUI( theModule ),
93 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
95 setCaption(tr("CAPTION"));
97 QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
99 QFrame* aMainFrame = createMainFrame (this);
100 QFrame* aBtnFrame = createButtonFrame(this);
102 aDlgLay->addWidget(aMainFrame);
103 aDlgLay->addWidget(aBtnFrame);
105 aDlgLay->setStretchFactor(aMainFrame, 1);
107 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
108 mySelector = aViewWindow->GetSelector();
110 myHelpFileName = "pattern_mapping_page.html";
115 //=======================================================================
116 // function : createMainFrame()
117 // purpose : Create frame containing dialog's input fields
118 //=======================================================================
119 QFrame* SMESHGUI_CreatePatternDlg::createMainFrame (QWidget* theParent)
121 QPixmap iconSlct (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
122 QPixmap icon2d (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_PATTERN_2d")));
123 QPixmap icon3d (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_PATTERN_3d")));
124 QPixmap iconSample2d (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D")));
126 QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent);
127 aMainGrp->setFrameStyle(QFrame::NoFrame);
128 aMainGrp->setInsideMargin(0);
130 // Pattern type group
132 myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp);
133 mySwitch2d = new QRadioButton (myTypeGrp);
134 mySwitch3d = new QRadioButton (myTypeGrp);
135 mySwitch2d->setPixmap(icon2d);
136 mySwitch3d->setPixmap(icon3d);
137 myTypeGrp->insert(mySwitch2d, Type_2d);
138 myTypeGrp->insert(mySwitch3d, Type_3d);
140 QGroupBox* aPatternGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp);
142 // Mesh and pattern name group
144 QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp);
145 aMeshGrp->setFrameStyle(QFrame::NoFrame);
146 aMeshGrp->setInsideMargin(0);
148 new QLabel(tr("MESH_OR_SUBMESH"), aMeshGrp);
150 QPushButton* aSelBtn = new QPushButton(aMeshGrp);
151 aSelBtn->setPixmap(iconSlct);
152 myMeshEdit = new QLineEdit(aMeshGrp);
153 myMeshEdit->setReadOnly(true);
155 QGroupBox* aPattGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp);
156 aPattGrp->setFrameStyle(QFrame::NoFrame);
157 aPattGrp->setInsideMargin(0);
159 new QLabel(tr("PATTERN_NAME"), aPattGrp);
160 myName = new QLineEdit(aPattGrp);
164 myPicture2d = new SMESHGUI_PatternWidget(aPatternGrp),
165 myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
169 myProjectChk = new QCheckBox(tr("PROJECT"), aPatternGrp);
171 // Connect signals and slots
173 connect(myTypeGrp, SIGNAL(clicked(int) ), SLOT(onTypeChanged(int)));
174 connect(myProjectChk, SIGNAL(toggled(bool)), SLOT(onProject(bool) ));
175 connect(aSelBtn, SIGNAL(clicked() ), SLOT(onSelBtnClicked()));
180 //=======================================================================
181 // function : createButtonFrame()
182 // purpose : Create frame containing buttons
183 //=======================================================================
184 QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame (QWidget* theParent)
186 QFrame* aFrame = new QFrame(theParent);
187 aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
189 myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
190 mySaveBtn = new QPushButton(tr("SAVE" ), aFrame);
191 myCloseBtn = new QPushButton(tr("SMESH_BUT_CANCEL"), aFrame);
192 myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
194 QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
196 QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
198 aLay->addWidget(myOkBtn);
199 aLay->addWidget(mySaveBtn);
200 aLay->addItem(aSpacer);
201 aLay->addWidget(myCloseBtn);
202 aLay->addWidget(myHelpBtn);
204 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
205 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
206 connect(mySaveBtn, SIGNAL(clicked()), SLOT(onSave()));
207 connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
212 //=======================================================================
213 // function : ~SMESHGUI_CreatePatternDlg()
214 // purpose : Destructor
215 //=======================================================================
216 SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg()
218 // no need to delete child widgets, Qt does it all for us
221 //=======================================================================
222 // function : onProject()
223 // purpose : SLOT. Called when state of "Project nodes on ther face"
224 // checkbox is changed
225 //=======================================================================
226 void SMESHGUI_CreatePatternDlg::onProject (bool)
228 loadFromObject(false);
232 //=======================================================================
234 // purpose : Init dialog fields, connect signals and slots, show dialog
235 //=======================================================================
236 void SMESHGUI_CreatePatternDlg::Init( const int theType )
241 mySubMesh = SMESH::SMESH_subMesh::_nil();
242 myMesh = SMESH::SMESH_Mesh::_nil();
243 myGeomObj = GEOM::GEOM_Object::_nil();
244 myPattern = SMESH::SMESH_Pattern::_nil();
248 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
250 // selection and SMESHGUI
251 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
252 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
253 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
255 mySwitch2d->setEnabled(theType == Type_2d);
256 mySwitch3d->setEnabled(theType == Type_3d);
258 if (theType == Type_2d)
259 myProjectChk->show();
261 myProjectChk->hide();
263 myTypeGrp->setButton(theType);
264 onTypeChanged(theType);
266 myName->setText(getDefaultName());
267 myMeshEdit->setText("");
269 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
270 qApp->processEvents();
272 myPicture2d->updateGeometry();
274 resize(minimumSize());
282 //=======================================================================
283 // function : SetMesh()
284 // purpose : Set mesh to dialog
285 //=======================================================================
286 void SMESHGUI_CreatePatternDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
288 myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr);
289 mySubMesh = SMESH::SMESH_subMesh::_nil();
291 bool isValidMesh = false;
292 if (!myMesh->_is_nil())
294 _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
295 //Handle(SALOME_InteractiveObject) anIObj =
296 // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH");
297 SUIT_DataOwnerPtr anIObj (new LightApp_DataOwner(aSobj->GetID().c_str()));
299 isValidMesh = mySelectionMgr->isOk(anIObj);
303 _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
304 myMeshEdit->setText(aSO->GetName().c_str());
305 myGeomObj = SMESH::GetGeom(aSO);
307 myMeshEdit->setText("");
308 myGeomObj = GEOM::GEOM_Object::_nil();
311 if (myType == Type_2d) {
312 loadFromObject(false);
317 //=======================================================================
318 // function : isValid()
319 // purpose : Verify validity of entry data
320 //=======================================================================
321 bool SMESHGUI_CreatePatternDlg::isValid()
323 if (myGeomObj->_is_nil()) {
324 QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ),
325 tr("SMESH_INSUFFICIENT_DATA"),
326 tr("SMESHGUI_INVALID_PARAMETERS"),
334 //=======================================================================
335 // function : getDefaultName()
336 // purpose : Get default pattern name
337 //=======================================================================
338 QString SMESHGUI_CreatePatternDlg::getDefaultName() const
340 return myType == Type_2d ? tr("DEFAULT_2D") : tr("DEFAULT_3D");
343 //=======================================================================
344 // function : onSave()
345 // purpose : SLOT called when "Save" button pressed. Build pattern and
347 //=======================================================================
348 void SMESHGUI_CreatePatternDlg::onSave()
355 loadFromObject(true);
357 // Load pattern from object
361 ///////////////////////////////////////////////////////
362 SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, false);
363 aDlg->setCaption(tr("SAVE_PATTERN"));
364 aDlg->setMode(QFileDialog::AnyFile);
365 aDlg->setFilters(tr("PATTERN_FILT"));
366 if (myName->text() != "")
367 aDlg->setSelection(myName->text());
369 if (aDlg->exec() != Accepted)
372 QString fName = aDlg->selectedFile();
376 if (QFileInfo(fName).extension().isEmpty())
377 fName = autoExtension(fName);
379 fName = QDir::convertSeparators(fName);
381 QString aData (myPattern->GetString());
382 long aLen = aData.length();
385 aFile.open(IO_WriteOnly);
386 long aWritten = aFile.writeBlock(aData, aLen);
389 if (aWritten != aLen) {
390 QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), tr("SMESH_ERROR"),
391 tr("ERROR_OF_SAVING"), QMessageBox::Ok);
393 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
394 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
395 aViewWindow->SetSelectionMode(ActorSelection);
396 disconnect(mySelectionMgr, 0, this, 0);
397 disconnect(mySMESHGUI, 0, this, 0);
398 mySMESHGUI->ResetState();
402 } catch (const SALOME::SALOME_Exception& S_ex) {
403 SalomeApp_Tools::QtCatchCorbaException(S_ex);
408 //=======================================================================
409 // function : GetPatternName()
410 // purpose : Get name of pattern
411 //=======================================================================
412 QString SMESHGUI_CreatePatternDlg::GetPatternName() const
414 return myName->text();
417 //=======================================================================
418 // function : GetPattern()
419 // purpose : Get result pattern
420 //=======================================================================
421 SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern()
423 return myPattern.in();
426 //=======================================================================
428 // purpose : SLOT called when "Ok" button pressed.
429 //=======================================================================
430 void SMESHGUI_CreatePatternDlg::onOk()
437 loadFromObject(true);
439 // Load pattern from object
443 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
444 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
445 aViewWindow->SetSelectionMode(ActorSelection);
446 disconnect(mySelectionMgr, 0, this, 0);
447 disconnect(mySMESHGUI, 0, this, 0);
448 mySMESHGUI->ResetState();
452 } catch (const SALOME::SALOME_Exception& S_ex) {
453 SalomeApp_Tools::QtCatchCorbaException(S_ex);
458 //=======================================================================
459 // function : onClose()
460 // purpose : SLOT called when "Close" button pressed. Close dialog
461 //=======================================================================
462 void SMESHGUI_CreatePatternDlg::onClose()
464 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
465 aViewWindow->SetSelectionMode(ActorSelection);
466 disconnect(mySelectionMgr, 0, this, 0);
467 disconnect(mySMESHGUI, 0, this, 0);
468 mySMESHGUI->ResetState();
473 //=================================================================================
474 // function : onHelp()
476 //=================================================================================
477 void SMESHGUI_CreatePatternDlg::onHelp()
479 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
481 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
485 platform = "winapplication";
487 platform = "application";
489 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
490 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
491 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
492 QObject::tr("BUT_OK"));
496 //=======================================================================
497 // function : loadFromObject()
498 // purpose : Load pattern from geom object corresponding to the mesh/submesh
499 //=======================================================================
500 bool SMESHGUI_CreatePatternDlg::loadFromObject (const bool theMess)
505 if (myPattern->_is_nil())
506 myPattern = SMESH::GetPattern();
508 if (myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil())
511 SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather();
513 myIsLoaded = myType == Type_2d
514 ? myPattern->LoadFromFace(aMesh, myGeomObj, myProjectChk->isChecked())
515 : myPattern->LoadFrom3DBlock(aMesh, myGeomObj);
517 if (!myIsLoaded && theMess) {
519 SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode();
521 if (aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr("ERR_LOAD_EMPTY_SUBMESH");
522 else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr("ERR_LOADF_NARROW_FACE");
523 else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr("ERR_LOADF_CLOSED_FACE");
524 else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_CANT_PROJECT ) aMess = tr("ERR_LOADF_CANT_PROJECT");
525 else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr("ERR_LOADV_BAD_SHAPE");
526 else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS) aMess = tr("ERR_LOADV_COMPUTE_PARAMS");
527 else aMess = tr("ERROR_OF_CREATION");
529 QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ),
530 tr("SMESH_ERROR"), aMess, QMessageBox::Ok);
532 } catch (const SALOME::SALOME_Exception& S_ex) {
533 SalomeApp_Tools::QtCatchCorbaException(S_ex);
539 //=======================================================================
540 // function : onSelectionDone()
541 // purpose : SLOT called when selection changed
542 //=======================================================================
543 void SMESHGUI_CreatePatternDlg::onSelectionDone()
547 mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
548 if (aList.Extent() != 1)
551 // Get mesh or sub-mesh from selection
552 Handle(SALOME_InteractiveObject) anIO = aList.First();
553 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
554 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO);
555 if (aMesh->_is_nil() && aSubMesh->_is_nil())
558 // Get geom object corresponding to the mesh
560 if (!aMesh->_is_nil())
561 aSO = SMESH::FindSObject(aMesh.in());
563 aSO = SMESH::FindSObject(aSubMesh.in());
565 GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom(aSO);
566 if (aGeomObj->_is_nil())
569 myGeomObj = aGeomObj;
572 if (!aMesh->_is_nil()) {
574 mySubMesh = SMESH::SMESH_subMesh::_nil();
576 mySubMesh = aSubMesh;
577 myMesh = SMESH::SMESH_Mesh::_nil();
581 SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
582 myMeshEdit->setText(aName);
584 if (myType == Type_2d) {
585 loadFromObject(true);
589 myMesh = SMESH::SMESH_Mesh::_nil();
590 mySubMesh = SMESH::SMESH_subMesh::_nil();
591 myGeomObj = GEOM::GEOM_Object::_nil();
596 //=======================================================================
597 // function : onDeactivate()
598 // purpose : SLOT called when dialog must be deativated
599 //=======================================================================
600 void SMESHGUI_CreatePatternDlg::onDeactivate()
602 disconnect(mySelectionMgr, 0, this, 0);
606 //=======================================================================
607 // function : enterEvent()
608 // purpose : Event filter
609 //=======================================================================
610 void SMESHGUI_CreatePatternDlg::enterEvent (QEvent*)
612 // there is a stange problem that enterEvent() comes after onSave()
613 if ( isVisible () ) {
614 mySMESHGUI->EmitSignalDeactivateDialog();
617 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
621 //=================================================================================
622 // function : closeEvent()
623 // purpose : Close dialog box
624 //=================================================================================
625 void SMESHGUI_CreatePatternDlg::closeEvent (QCloseEvent*)
630 //=======================================================================
631 // function : onSelBtnClicked()
632 // purpose : SLOT. Called when -> button clicked.
633 //=======================================================================
634 void SMESHGUI_CreatePatternDlg::onSelBtnClicked()
639 //================================================================
640 // function : autoExtension()
641 // purpose : Append extension to the file name
642 //================================================================
643 QString SMESHGUI_CreatePatternDlg::autoExtension (const QString& theFileName) const
645 QString anExt = theFileName.section('.', -1);
646 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
649 //=======================================================================
650 // function : displayPreview()
651 // purpose : Display preview
652 //=======================================================================
653 void SMESHGUI_CreatePatternDlg::displayPreview()
655 // Redisplay preview in dialog
660 SMESH::point_array_var pnts = myPattern->GetPoints();
661 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
662 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);
664 if (pnts->length() == 0 ||
665 keyPoints->length() == 0 ||
666 elemPoints->length() == 0) {
672 PointVector aPoints (pnts->length());
673 QValueVector<int> aKeyPoints (keyPoints->length());
674 ConnectivityVector anElemPoints (elemPoints->length());
676 for (int i = 0, n = pnts->length(); i < n; i++)
677 aPoints[ i ] = pnts[ i ];
679 for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++)
680 aKeyPoints[ i2 ] = keyPoints[ i2 ];
682 for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
683 QValueVector<int> aVec (elemPoints[ i3 ].length());
684 for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
685 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
687 anElemPoints[ i3 ] = aVec;
690 myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints);
695 } catch (const SALOME::SALOME_Exception& S_ex) {
696 SalomeApp_Tools::QtCatchCorbaException(S_ex);
702 //=======================================================================
703 // function : erasePreview()
704 // purpose : Erase preview
705 //=======================================================================
706 void SMESHGUI_CreatePatternDlg::erasePreview()
708 // Erase preview in 2D viewer
709 myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector());
712 //=======================================================================
713 // function : activateSelection()
714 // purpose : Activate selection in accordance with current pattern type
715 //=======================================================================
716 void SMESHGUI_CreatePatternDlg::activateSelection()
718 mySelectionMgr->clearFilters();
719 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
720 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
721 aViewWindow->SetSelectionMode(ActorSelection);
723 if (myType == Type_2d) {
724 mySelectionMgr->installFilter(new SMESH_NumberFilter
725 ("SMESH", TopAbs_SHAPE, -1, TopAbs_FACE));
727 TColStd_MapOfInteger aTypes;
728 aTypes.Add(TopAbs_SHELL);
729 aTypes.Add(TopAbs_SOLID);
730 mySelectionMgr->installFilter(new SMESH_NumberFilter
731 ("SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true));
735 //=======================================================================
736 // function : onTypeChanged()
737 // purpose : SLOT. Called when pattern type changed.
738 // Change dialog's look and feel
739 //=======================================================================
740 void SMESHGUI_CreatePatternDlg::onTypeChanged (int theType)
742 if (myType == theType)
747 if (theType == Type_2d)
753 //=================================================================================
754 // function : keyPressEvent()
756 //=================================================================================
757 void SMESHGUI_CreatePatternDlg::keyPressEvent( QKeyEvent* e )
759 QDialog::keyPressEvent( e );
760 if ( e->isAccepted() )
763 if ( e->key() == Key_F1 )