1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SMESHGUI_CreatePatternDlg.cxx
21 // Author : Sergey LITONIN, Open CASCADE S.A.S.
25 #include "SMESHGUI_CreatePatternDlg.h"
28 #include "SMESHGUI_PatternWidget.h"
29 #include "SMESHGUI_Utils.h"
30 #include "SMESHGUI_VTKUtils.h"
31 #include "SMESHGUI_PatternUtils.h"
32 #include "SMESHGUI_GEOMGenUtils.h"
34 #include <SMESH_NumberFilter.hxx>
36 // SALOME GUI includes
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_Desktop.h>
39 #include <SUIT_FileDlg.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
43 #include <LightApp_Application.h>
44 #include <LightApp_SelectionMgr.h>
45 #include <SalomeApp_Tools.h>
47 #include <SALOME_ListIO.hxx>
48 #include <SVTK_ViewModel.h>
49 #include <SVTK_ViewWindow.h>
51 // SALOME KERNEL includes
52 #include <SALOMEDS_SObject.hxx>
55 #include <TColStd_MapOfInteger.hxx>
59 #include <QVBoxLayout>
60 #include <QHBoxLayout>
62 #include <QPushButton>
65 #include <QRadioButton>
67 #include <QButtonGroup>
68 #include <QApplication>
77 * Class : SMESHGUI_CreatePatternDlg
78 * Description : Dialog to specify filters for VTK viewer
81 //=======================================================================
82 // function : SMESHGUI_CreatePatternDlg()
83 // purpose : Constructor
84 //=======================================================================
85 SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule,
87 : QDialog( SMESH::GetDesktop( theModule ) ),
88 mySMESHGUI( theModule ),
89 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
92 setWindowTitle( tr( "CAPTION" ) );
94 QVBoxLayout* aDlgLay = new QVBoxLayout( this );
95 aDlgLay->setMargin( MARGIN );
96 aDlgLay->setSpacing( SPACING );
98 QWidget* aMainFrame = createMainFrame( this );
99 QWidget* aBtnFrame = createButtonFrame( this );
101 aDlgLay->addWidget( aMainFrame );
102 aDlgLay->addWidget( aBtnFrame );
104 aDlgLay->setStretchFactor( aMainFrame, 1 );
106 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
107 mySelector = aViewWindow->GetSelector();
109 myHelpFileName = "pattern_mapping_page.html";
114 //=======================================================================
115 // function : createMainFrame()
116 // purpose : Create frame containing dialog's input fields
117 //=======================================================================
118 QWidget* SMESHGUI_CreatePatternDlg::createMainFrame( QWidget* theParent )
120 QPixmap iconSlct ( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
121 QPixmap icon2d ( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) );
122 QPixmap icon3d ( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) );
123 QPixmap iconSample2d( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );
125 QWidget* aMainGrp = new QWidget( theParent );
126 QVBoxLayout* aMainGrpLayout = new QVBoxLayout( aMainGrp );
127 aMainGrpLayout->setMargin( 0 );
128 aMainGrpLayout->setSpacing( SPACING );
130 // Pattern type group
132 QGroupBox* aTypeGrp = new QGroupBox( tr( "PATTERN_TYPE" ), aMainGrp );
133 QHBoxLayout* aTypeGrpLayout = new QHBoxLayout( aTypeGrp );
134 aTypeGrpLayout->setMargin( MARGIN );
135 aTypeGrpLayout->setSpacing( SPACING );
137 mySwitch2d = new QRadioButton( aTypeGrp );
138 mySwitch3d = new QRadioButton( aTypeGrp );
139 mySwitch2d->setIcon( icon2d );
140 mySwitch3d->setIcon( icon3d );
142 myTypeGrp = new QButtonGroup( aMainGrp );
143 myTypeGrp->addButton( mySwitch2d, Type_2d );
144 myTypeGrp->addButton( mySwitch3d, Type_3d );
146 // ... layout widgets
148 aTypeGrpLayout->addWidget( mySwitch2d );
149 aTypeGrpLayout->addWidget( mySwitch3d );
151 // Mesh and pattern name group
153 QGroupBox* aPatternGrp = new QGroupBox( tr( "PATTERN" ), aMainGrp );
154 QGridLayout* aPatternGrpLayout = new QGridLayout( aPatternGrp );
155 aPatternGrpLayout->setMargin( MARGIN );
156 aPatternGrpLayout->setSpacing( SPACING );
158 QLabel* aMeshLab = new QLabel( tr( "MESH_OR_SUBMESH" ), aPatternGrp );
160 QPushButton* aSelBtn = new QPushButton( aPatternGrp );
161 aSelBtn->setIcon( iconSlct );
162 myMeshEdit = new QLineEdit( aPatternGrp );
163 myMeshEdit->setReadOnly( true );
165 QLabel* aNameLab = new QLabel( tr( "PATTERN_NAME" ), aPatternGrp );
166 myName = new QLineEdit( aPatternGrp );
170 myPicture2d = new SMESHGUI_PatternWidget( aPatternGrp ),
171 myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
175 myProjectChk = new QCheckBox( tr( "PROJECT" ), aPatternGrp );
177 // ... layout widgets
179 aPatternGrpLayout->addWidget( aMeshLab, 0, 0 );
180 aPatternGrpLayout->addWidget( aSelBtn, 0, 1 );
181 aPatternGrpLayout->addWidget( myMeshEdit, 0, 2 );
182 aPatternGrpLayout->addWidget( aNameLab, 1, 0 );
183 aPatternGrpLayout->addWidget( myName, 1, 2 );
184 aPatternGrpLayout->addWidget( myPicture2d, 2, 0, 1, 3 );
185 aPatternGrpLayout->addWidget( myProjectChk, 3, 0, 1, 3 );
189 aMainGrpLayout->addWidget( aTypeGrp );
190 aMainGrpLayout->addWidget( aPatternGrp );
192 // Connect signals and slots
194 connect( myTypeGrp, SIGNAL( buttonClicked( int ) ),
195 this, SLOT( onTypeChanged( int ) ) );
196 connect( myProjectChk, SIGNAL( toggled( bool ) ),
197 this, SLOT( onProject( bool ) ) );
198 connect( aSelBtn, SIGNAL( clicked() ),
199 this, SLOT( onSelBtnClicked() ) );
204 //=======================================================================
205 // function : createButtonFrame()
206 // purpose : Create frame containing buttons
207 //=======================================================================
208 QWidget* SMESHGUI_CreatePatternDlg::createButtonFrame( QWidget* theParent )
210 QFrame* aFrame = new QFrame( theParent );
211 aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
213 QPushButton* myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame );
214 QPushButton* mySaveBtn = new QPushButton( tr( "SAVE" ), aFrame );
215 QPushButton* myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL"), aFrame );
216 QPushButton* myHelpBtn = new QPushButton( tr( "SMESH_BUT_HELP"), aFrame );
218 QHBoxLayout* aLay = new QHBoxLayout( aFrame );
219 aLay->setMargin( MARGIN );
220 aLay->setSpacing( SPACING );
222 aLay->addWidget( myOkBtn );
223 aLay->addSpacing( 10 );
224 aLay->addWidget( mySaveBtn );
225 aLay->addSpacing( 10 );
227 aLay->addWidget( myCloseBtn );
228 aLay->addWidget( myHelpBtn );
230 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
231 connect( myCloseBtn, SIGNAL( clicked() ), this, SLOT( onClose() ) );
232 connect( mySaveBtn, SIGNAL( clicked() ), this, SLOT( onSave() ) );
233 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
238 //=======================================================================
239 // function : ~SMESHGUI_CreatePatternDlg()
240 // purpose : Destructor
241 //=======================================================================
242 SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg()
246 //=======================================================================
247 // function : onProject()
248 // purpose : SLOT. Called when state of "Project nodes on ther face"
249 // checkbox is changed
250 //=======================================================================
251 void SMESHGUI_CreatePatternDlg::onProject( bool )
253 loadFromObject( false );
257 //=======================================================================
259 // purpose : Init dialog fields, connect signals and slots, show dialog
260 //=======================================================================
261 void SMESHGUI_CreatePatternDlg::Init( const int theType )
265 mySubMesh = SMESH::SMESH_subMesh::_nil();
266 myMesh = SMESH::SMESH_Mesh::_nil();
267 myGeomObj = GEOM::GEOM_Object::_nil();
268 myPattern = SMESH::SMESH_Pattern::_nil();
272 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
274 // selection and SMESHGUI
275 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ),
276 this, SLOT( onSelectionDone() ) );
277 connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ),
278 this, SLOT( onDeactivate() ) );
279 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ),
280 this, SLOT( onClose() ) );
282 mySwitch2d->setEnabled( theType == Type_2d );
283 mySwitch3d->setEnabled( theType == Type_3d );
285 myTypeGrp->button( theType )->setChecked( true );
286 onTypeChanged( theType );
288 myName->setText( getDefaultName() );
289 myMeshEdit->setText( "" );
291 QApplication::instance()->processEvents();
293 resize( minimumSize() );
301 //=======================================================================
302 // function : SetMesh()
303 // purpose : Set mesh to dialog
304 //=======================================================================
305 void SMESHGUI_CreatePatternDlg::SetMesh( SMESH::SMESH_Mesh_ptr thePtr )
307 myMesh = SMESH::SMESH_Mesh::_duplicate( thePtr );
308 mySubMesh = SMESH::SMESH_subMesh::_nil();
310 bool isValidMesh = false;
311 if ( !myMesh->_is_nil() ) {
312 _PTR(SObject) aSobj = SMESH::FindSObject( myMesh.in() );
313 //Handle(SALOME_InteractiveObject) anIObj =
314 // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH");
315 SUIT_DataOwnerPtr anIObj( new LightApp_DataOwner( aSobj->GetID().c_str() ) );
317 isValidMesh = mySelectionMgr->isOk( anIObj );
321 _PTR(SObject) aSO = SMESH::FindSObject( myMesh.in() );
322 myMeshEdit->setText( aSO->GetName().c_str() );
323 myGeomObj = SMESH::GetGeom( aSO );
326 myMeshEdit->setText( "" );
327 myGeomObj = GEOM::GEOM_Object::_nil();
330 if ( myType == Type_2d ) {
331 loadFromObject( false );
336 //=======================================================================
337 // function : isValid()
338 // purpose : Verify validity of entry data
339 //=======================================================================
340 bool SMESHGUI_CreatePatternDlg::isValid()
342 if ( myGeomObj->_is_nil() ) {
343 SUIT_MessageBox::information( this,
344 tr( "SMESH_INSUFFICIENT_DATA" ),
345 tr( "SMESHGUI_INVALID_PARAMETERS" ) );
351 //=======================================================================
352 // function : getDefaultName()
353 // purpose : Get default pattern name
354 //=======================================================================
355 QString SMESHGUI_CreatePatternDlg::getDefaultName() const
357 return myType == Type_2d ? tr( "DEFAULT_2D" ) : tr( "DEFAULT_3D" );
360 //=======================================================================
361 // function : onSave()
362 // purpose : SLOT called when "Save" button pressed. Build pattern and
364 //=======================================================================
365 void SMESHGUI_CreatePatternDlg::onSave()
372 loadFromObject( true );
374 // Load pattern from object
378 ///////////////////////////////////////////////////////
379 SUIT_FileDlg* aDlg = new SUIT_FileDlg( this, false );
380 aDlg->setWindowTitle( tr( "SAVE_PATTERN" ) );
381 aDlg->setFileMode( QFileDialog::AnyFile );
382 aDlg->setFilter( tr( "PATTERN_FILT" ) );
383 if ( myName->text() != "" )
384 aDlg->selectFile( myName->text() );
386 if ( aDlg->exec() != Accepted )
389 QString fName = aDlg->selectedFile();
390 if ( fName.isEmpty() )
393 if ( QFileInfo( fName ).suffix().isEmpty() )
394 fName = autoExtension( fName );
396 fName = QDir::convertSeparators( fName );
398 QString aData( myPattern->GetString() );
399 long aLen = aData.length();
401 QFile aFile( fName );
402 aFile.open( QIODevice::WriteOnly );
403 long aWritten = aFile.write( aData.toLatin1(), aLen );
406 if ( aWritten != aLen ) {
407 SUIT_MessageBox::information( this,
409 tr( "ERROR_OF_SAVING" ) );
412 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
413 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
414 aViewWindow->SetSelectionMode( ActorSelection );
415 disconnect( mySelectionMgr, 0, this, 0 );
416 disconnect( mySMESHGUI, 0, this, 0 );
417 mySMESHGUI->ResetState();
422 catch ( const SALOME::SALOME_Exception& S_ex ) {
423 SalomeApp_Tools::QtCatchCorbaException( S_ex );
429 //=======================================================================
430 // function : GetPatternName()
431 // purpose : Get name of pattern
432 //=======================================================================
433 QString SMESHGUI_CreatePatternDlg::GetPatternName() const
435 return myName->text();
438 //=======================================================================
439 // function : GetPattern()
440 // purpose : Get result pattern
441 //=======================================================================
442 SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern()
444 return myPattern.in();
447 //=======================================================================
449 // purpose : SLOT called when "Ok" button pressed.
450 //=======================================================================
451 void SMESHGUI_CreatePatternDlg::onOk()
458 loadFromObject( true );
460 // Load pattern from object
465 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
466 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
467 aViewWindow->SetSelectionMode( ActorSelection );
468 disconnect( mySelectionMgr, 0, this, 0 );
469 disconnect( mySMESHGUI, 0, this, 0 );
470 mySMESHGUI->ResetState();
475 catch ( const SALOME::SALOME_Exception& S_ex ) {
476 SalomeApp_Tools::QtCatchCorbaException( S_ex );
482 //=======================================================================
483 // function : onClose()
484 // purpose : SLOT called when "Close" button pressed. Close dialog
485 //=======================================================================
486 void SMESHGUI_CreatePatternDlg::onClose()
488 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
489 aViewWindow->SetSelectionMode( ActorSelection );
490 disconnect( mySelectionMgr, 0, this, 0 );
491 disconnect( mySMESHGUI, 0, this, 0 );
492 mySMESHGUI->ResetState();
497 //=================================================================================
498 // function : onHelp()
500 //=================================================================================
501 void SMESHGUI_CreatePatternDlg::onHelp()
503 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
505 app->onHelpContextModule( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) : QString( "" ), myHelpFileName );
509 platform = "winapplication";
511 platform = "application";
513 SUIT_MessageBox::warning( this,
515 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
516 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
518 arg( myHelpFileName ) );
522 //=======================================================================
523 // function : loadFromObject()
524 // purpose : Load pattern from geom object corresponding to the mesh/submesh
525 //=======================================================================
526 bool SMESHGUI_CreatePatternDlg::loadFromObject( const bool theMess )
531 if ( myPattern->_is_nil() )
532 myPattern = SMESH::GetPattern();
534 if ( myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil() )
537 SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather();
539 myIsLoaded = myType == Type_2d
540 ? myPattern->LoadFromFace( aMesh, myGeomObj, myProjectChk->isChecked() )
541 : myPattern->LoadFrom3DBlock( aMesh, myGeomObj );
543 if ( !myIsLoaded && theMess ) {
545 SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode();
547 if ( aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr( "ERR_LOAD_EMPTY_SUBMESH" );
548 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr( "ERR_LOADF_NARROW_FACE" );
549 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr( "ERR_LOADF_CLOSED_FACE" );
550 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CANT_PROJECT ) aMess = tr( "ERR_LOADF_CANT_PROJECT" );
551 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr( "ERR_LOADV_BAD_SHAPE" );
552 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS ) aMess = tr( "ERR_LOADV_COMPUTE_PARAMS" );
553 else aMess = tr( "ERROR_OF_CREATION" );
555 SUIT_MessageBox::information( this, tr( "SMESH_ERROR" ), aMess );
558 catch ( const SALOME::SALOME_Exception& S_ex ) {
559 SalomeApp_Tools::QtCatchCorbaException( S_ex );
565 //=======================================================================
566 // function : onSelectionDone()
567 // purpose : SLOT called when selection changed
568 //=======================================================================
569 void SMESHGUI_CreatePatternDlg::onSelectionDone()
573 mySelectionMgr->selectedObjects( aList, SVTK_Viewer::Type() );
574 if ( aList.Extent() != 1 )
577 // Get mesh or sub-mesh from selection
578 Handle(SALOME_InteractiveObject) anIO = aList.First();
579 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIO );
580 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>( anIO );
581 if ( aMesh->_is_nil() && aSubMesh->_is_nil() )
584 // Get geom object corresponding to the mesh
586 if ( !aMesh->_is_nil() )
587 aSO = SMESH::FindSObject( aMesh.in() );
589 aSO = SMESH::FindSObject( aSubMesh.in() );
591 GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom( aSO );
592 if ( aGeomObj->_is_nil() )
595 myGeomObj = aGeomObj;
598 if ( !aMesh->_is_nil() ) {
600 mySubMesh = SMESH::SMESH_subMesh::_nil();
603 mySubMesh = aSubMesh;
604 myMesh = SMESH::SMESH_Mesh::_nil();
608 SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aName );
609 myMeshEdit->setText( aName );
611 if ( myType == Type_2d ) {
612 loadFromObject( true );
617 myMesh = SMESH::SMESH_Mesh::_nil();
618 mySubMesh = SMESH::SMESH_subMesh::_nil();
619 myGeomObj = GEOM::GEOM_Object::_nil();
624 //=======================================================================
625 // function : onDeactivate()
626 // purpose : SLOT called when dialog must be deativated
627 //=======================================================================
628 void SMESHGUI_CreatePatternDlg::onDeactivate()
630 disconnect( mySelectionMgr, 0, this, 0 );
634 //=======================================================================
635 // function : enterEvent()
636 // purpose : Event filter
637 //=======================================================================
638 void SMESHGUI_CreatePatternDlg::enterEvent( QEvent* )
640 // there is a stange problem that enterEvent() comes after onSave()
641 if ( isVisible () ) {
642 mySMESHGUI->EmitSignalDeactivateDialog();
645 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
649 //=================================================================================
650 // function : closeEvent()
651 // purpose : Close dialog box
652 //=================================================================================
653 void SMESHGUI_CreatePatternDlg::closeEvent( QCloseEvent* )
658 //=======================================================================
659 // function : onSelBtnClicked()
660 // purpose : SLOT. Called when -> button clicked.
661 //=======================================================================
662 void SMESHGUI_CreatePatternDlg::onSelBtnClicked()
667 //================================================================
668 // function : autoExtension()
669 // purpose : Append extension to the file name
670 //================================================================
671 QString SMESHGUI_CreatePatternDlg::autoExtension( const QString& theFileName ) const
673 QString anExt = theFileName.section('.', -1);
674 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
677 //=======================================================================
678 // function : displayPreview()
679 // purpose : Display preview
680 //=======================================================================
681 void SMESHGUI_CreatePatternDlg::displayPreview()
683 // Redisplay preview in dialog
689 SMESH::point_array_var pnts = myPattern->GetPoints();
690 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
691 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints( false );
693 if ( pnts->length() == 0 ||
694 keyPoints->length() == 0 ||
695 elemPoints->length() == 0 ) {
701 PointVector aPoints( pnts->length() );
702 QVector<int> aKeyPoints( keyPoints->length() );
703 ConnectivityVector anElemPoints( elemPoints->length() );
705 for ( int i = 0, n = pnts->length(); i < n; i++ )
706 aPoints[ i ] = pnts[ i ];
708 for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ )
709 aKeyPoints[ i2 ] = keyPoints[ i2 ];
711 for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
712 QVector<int> aVec (elemPoints[ i3 ].length());
713 for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
714 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
716 anElemPoints[ i3 ] = aVec;
719 myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints );
725 catch ( const SALOME::SALOME_Exception& S_ex ) {
726 SalomeApp_Tools::QtCatchCorbaException( S_ex );
733 //=======================================================================
734 // function : erasePreview()
735 // purpose : Erase preview
736 //=======================================================================
737 void SMESHGUI_CreatePatternDlg::erasePreview()
739 // Erase preview in 2D viewer
740 myPicture2d->SetPoints( PointVector(), QVector<int>(), ConnectivityVector() );
743 //=======================================================================
744 // function : activateSelection()
745 // purpose : Activate selection in accordance with current pattern type
746 //=======================================================================
747 void SMESHGUI_CreatePatternDlg::activateSelection()
749 mySelectionMgr->clearFilters();
750 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
751 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
752 aViewWindow->SetSelectionMode( ActorSelection );
754 if ( myType == Type_2d ) {
755 mySelectionMgr->installFilter( new SMESH_NumberFilter( "SMESH",
761 TColStd_MapOfInteger aTypes;
762 aTypes.Add( TopAbs_SHELL );
763 aTypes.Add( TopAbs_SOLID );
764 mySelectionMgr->installFilter( new SMESH_NumberFilter( "SMESH",
768 GEOM::GEOM_Object::_nil(),
773 //=======================================================================
774 // function : onTypeChanged()
775 // purpose : SLOT. Called when pattern type changed.
776 // Change dialog's look and feel
777 //=======================================================================
778 void SMESHGUI_CreatePatternDlg::onTypeChanged( int theType )
780 if ( myType == theType )
785 myPicture2d->setVisible( theType == Type_2d );
786 myProjectChk->setVisible( theType == Type_2d );
789 //=================================================================================
790 // function : keyPressEvent()
792 //=================================================================================
793 void SMESHGUI_CreatePatternDlg::keyPressEvent( QKeyEvent* e )
795 QDialog::keyPressEvent( e );
796 if ( e->isAccepted() )
799 if ( e->key() == Qt::Key_F1 ){