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 // File : SMESHGUI_CreatePatternDlg.cxx
23 // Author : Sergey LITONIN, Open CASCADE S.A.S.
26 #include "SMESHGUI_CreatePatternDlg.h"
29 #include "SMESHGUI_PatternWidget.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_PatternUtils.h"
33 #include "SMESHGUI_GEOMGenUtils.h"
35 #include <SMESH_NumberFilter.hxx>
37 // SALOME GUI includes
38 #include <SUIT_ResourceMgr.h>
39 #include <SUIT_Desktop.h>
40 #include <SUIT_FileDlg.h>
41 #include <SUIT_Session.h>
42 #include <SUIT_MessageBox.h>
44 #include <LightApp_Application.h>
45 #include <LightApp_SelectionMgr.h>
46 #include <SalomeApp_Tools.h>
48 #include <SALOME_ListIO.hxx>
49 #include <SVTK_ViewModel.h>
50 #include <SVTK_ViewWindow.h>
52 // SALOME KERNEL includes
53 #include <SALOMEDS_SObject.hxx>
56 #include <TColStd_MapOfInteger.hxx>
60 #include <QVBoxLayout>
61 #include <QHBoxLayout>
63 #include <QPushButton>
66 #include <QRadioButton>
68 #include <QButtonGroup>
69 #include <QApplication>
78 * Class : SMESHGUI_CreatePatternDlg
79 * Description : Dialog to specify filters for VTK viewer
82 //=======================================================================
83 // function : SMESHGUI_CreatePatternDlg()
84 // purpose : Constructor
85 //=======================================================================
86 SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule,
88 : QDialog( SMESH::GetDesktop( theModule ) ),
89 mySMESHGUI( theModule ),
90 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
93 setWindowTitle( tr( "CAPTION" ) );
95 QVBoxLayout* aDlgLay = new QVBoxLayout( this );
96 aDlgLay->setMargin( MARGIN );
97 aDlgLay->setSpacing( SPACING );
99 QWidget* aMainFrame = createMainFrame( this );
100 QWidget* 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 QWidget* 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 QWidget* aMainGrp = new QWidget( theParent );
127 QVBoxLayout* aMainGrpLayout = new QVBoxLayout( aMainGrp );
128 aMainGrpLayout->setMargin( 0 );
129 aMainGrpLayout->setSpacing( SPACING );
131 // Pattern type group
133 QGroupBox* aTypeGrp = new QGroupBox( tr( "PATTERN_TYPE" ), aMainGrp );
134 QHBoxLayout* aTypeGrpLayout = new QHBoxLayout( aTypeGrp );
135 aTypeGrpLayout->setMargin( MARGIN );
136 aTypeGrpLayout->setSpacing( SPACING );
138 mySwitch2d = new QRadioButton( aTypeGrp );
139 mySwitch3d = new QRadioButton( aTypeGrp );
140 mySwitch2d->setIcon( icon2d );
141 mySwitch3d->setIcon( icon3d );
143 myTypeGrp = new QButtonGroup( aMainGrp );
144 myTypeGrp->addButton( mySwitch2d, Type_2d );
145 myTypeGrp->addButton( mySwitch3d, Type_3d );
147 // ... layout widgets
149 aTypeGrpLayout->addWidget( mySwitch2d );
150 aTypeGrpLayout->addWidget( mySwitch3d );
152 // Mesh and pattern name group
154 QGroupBox* aPatternGrp = new QGroupBox( tr( "PATTERN" ), aMainGrp );
155 QGridLayout* aPatternGrpLayout = new QGridLayout( aPatternGrp );
156 aPatternGrpLayout->setMargin( MARGIN );
157 aPatternGrpLayout->setSpacing( SPACING );
159 QLabel* aMeshLab = new QLabel( tr( "MESH_OR_SUBMESH" ), aPatternGrp );
161 QPushButton* aSelBtn = new QPushButton( aPatternGrp );
162 aSelBtn->setIcon( iconSlct );
163 myMeshEdit = new QLineEdit( aPatternGrp );
164 myMeshEdit->setReadOnly( true );
166 QLabel* aNameLab = new QLabel( tr( "PATTERN_NAME" ), aPatternGrp );
167 myName = new QLineEdit( aPatternGrp );
171 myPicture2d = new SMESHGUI_PatternWidget( aPatternGrp ),
172 myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
176 myProjectChk = new QCheckBox( tr( "PROJECT" ), aPatternGrp );
178 // ... layout widgets
180 aPatternGrpLayout->addWidget( aMeshLab, 0, 0 );
181 aPatternGrpLayout->addWidget( aSelBtn, 0, 1 );
182 aPatternGrpLayout->addWidget( myMeshEdit, 0, 2 );
183 aPatternGrpLayout->addWidget( aNameLab, 1, 0 );
184 aPatternGrpLayout->addWidget( myName, 1, 2 );
185 aPatternGrpLayout->addWidget( myPicture2d, 2, 0, 1, 3 );
186 aPatternGrpLayout->addWidget( myProjectChk, 3, 0, 1, 3 );
190 aMainGrpLayout->addWidget( aTypeGrp );
191 aMainGrpLayout->addWidget( aPatternGrp );
193 // Connect signals and slots
195 connect( myTypeGrp, SIGNAL( buttonClicked( int ) ),
196 this, SLOT( onTypeChanged( int ) ) );
197 connect( myProjectChk, SIGNAL( toggled( bool ) ),
198 this, SLOT( onProject( bool ) ) );
199 connect( aSelBtn, SIGNAL( clicked() ),
200 this, SLOT( onSelBtnClicked() ) );
205 //=======================================================================
206 // function : createButtonFrame()
207 // purpose : Create frame containing buttons
208 //=======================================================================
209 QWidget* SMESHGUI_CreatePatternDlg::createButtonFrame( QWidget* theParent )
211 QFrame* aFrame = new QFrame( theParent );
212 aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
214 QPushButton* myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame );
215 QPushButton* mySaveBtn = new QPushButton( tr( "SAVE" ), aFrame );
216 QPushButton* myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL"), aFrame );
217 QPushButton* myHelpBtn = new QPushButton( tr( "SMESH_BUT_HELP"), aFrame );
219 QHBoxLayout* aLay = new QHBoxLayout( aFrame );
220 aLay->setMargin( MARGIN );
221 aLay->setSpacing( SPACING );
223 aLay->addWidget( myOkBtn );
224 aLay->addSpacing( 10 );
225 aLay->addWidget( mySaveBtn );
226 aLay->addSpacing( 10 );
228 aLay->addWidget( myCloseBtn );
229 aLay->addWidget( myHelpBtn );
231 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
232 connect( myCloseBtn, SIGNAL( clicked() ), this, SLOT( onClose() ) );
233 connect( mySaveBtn, SIGNAL( clicked() ), this, SLOT( onSave() ) );
234 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
239 //=======================================================================
240 // function : ~SMESHGUI_CreatePatternDlg()
241 // purpose : Destructor
242 //=======================================================================
243 SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg()
247 //=======================================================================
248 // function : onProject()
249 // purpose : SLOT. Called when state of "Project nodes on ther face"
250 // checkbox is changed
251 //=======================================================================
252 void SMESHGUI_CreatePatternDlg::onProject( bool )
254 loadFromObject( false );
258 //=======================================================================
260 // purpose : Init dialog fields, connect signals and slots, show dialog
261 //=======================================================================
262 void SMESHGUI_CreatePatternDlg::Init( const int theType )
266 mySubMesh = SMESH::SMESH_subMesh::_nil();
267 myMesh = SMESH::SMESH_Mesh::_nil();
268 myGeomObj = GEOM::GEOM_Object::_nil();
269 myPattern = SMESH::SMESH_Pattern::_nil();
273 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
275 // selection and SMESHGUI
276 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ),
277 this, SLOT( onSelectionDone() ) );
278 connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ),
279 this, SLOT( onDeactivate() ) );
280 connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ),
281 this, SLOT( onClose() ) );
283 mySwitch2d->setEnabled( theType == Type_2d );
284 mySwitch3d->setEnabled( theType == Type_3d );
286 myTypeGrp->button( theType )->setChecked( true );
287 onTypeChanged( theType );
289 myName->setText( getDefaultName() );
290 myMeshEdit->setText( "" );
292 QApplication::instance()->processEvents();
302 //=======================================================================
303 // function : SetMesh()
304 // purpose : Set mesh to dialog
305 //=======================================================================
306 void SMESHGUI_CreatePatternDlg::SetMesh( SMESH::SMESH_Mesh_ptr thePtr )
308 myMesh = SMESH::SMESH_Mesh::_duplicate( thePtr );
309 mySubMesh = SMESH::SMESH_subMesh::_nil();
311 bool isValidMesh = false;
312 if ( !myMesh->_is_nil() ) {
313 _PTR(SObject) aSobj = SMESH::FindSObject( myMesh.in() );
314 //Handle(SALOME_InteractiveObject) anIObj =
315 // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH");
316 SUIT_DataOwnerPtr anIObj( new LightApp_DataOwner( aSobj->GetID().c_str() ) );
318 isValidMesh = mySelectionMgr->isOk( anIObj );
322 _PTR(SObject) aSO = SMESH::FindSObject( myMesh.in() );
323 myMeshEdit->setText( aSO->GetName().c_str() );
324 myGeomObj = SMESH::GetGeom( aSO );
327 myMeshEdit->setText( "" );
328 myGeomObj = GEOM::GEOM_Object::_nil();
331 if ( myType == Type_2d ) {
332 loadFromObject( false );
337 //=======================================================================
338 // function : isValid()
339 // purpose : Verify validity of entry data
340 //=======================================================================
341 bool SMESHGUI_CreatePatternDlg::isValid()
343 if ( myGeomObj->_is_nil() ) {
344 SUIT_MessageBox::information( this,
345 tr( "SMESH_INSUFFICIENT_DATA" ),
346 tr( "SMESHGUI_INVALID_PARAMETERS" ) );
352 //=======================================================================
353 // function : getDefaultName()
354 // purpose : Get default pattern name
355 //=======================================================================
356 QString SMESHGUI_CreatePatternDlg::getDefaultName() const
358 return myType == Type_2d ? tr( "DEFAULT_2D" ) : tr( "DEFAULT_3D" );
361 //=======================================================================
362 // function : onSave()
363 // purpose : SLOT called when "Save" button pressed. Build pattern and
365 //=======================================================================
366 void SMESHGUI_CreatePatternDlg::onSave()
373 loadFromObject( true );
375 // Load pattern from object
379 ///////////////////////////////////////////////////////
380 SUIT_FileDlg* aDlg = new SUIT_FileDlg( this, false );
381 aDlg->setWindowTitle( tr( "SAVE_PATTERN" ) );
382 aDlg->setFileMode( QFileDialog::AnyFile );
383 aDlg->setFilter( tr( "PATTERN_FILT" ) );
384 if ( myName->text() != "" )
385 aDlg->selectFile( myName->text() );
387 if ( aDlg->exec() != Accepted )
390 QString fName = aDlg->selectedFile();
391 if ( fName.isEmpty() )
394 if ( QFileInfo( fName ).suffix().isEmpty() )
395 fName = autoExtension( fName );
397 fName = QDir::convertSeparators( fName );
399 QString aData( myPattern->GetString() );
400 long aLen = aData.length();
402 QFile aFile( fName );
403 aFile.open( QIODevice::WriteOnly );
404 long aWritten = aFile.write( aData.toLatin1(), aLen );
407 if ( aWritten != aLen ) {
408 SUIT_MessageBox::information( this,
410 tr( "ERROR_OF_SAVING" ) );
413 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
414 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
415 aViewWindow->SetSelectionMode( ActorSelection );
416 disconnect( mySelectionMgr, 0, this, 0 );
417 disconnect( mySMESHGUI, 0, this, 0 );
418 mySMESHGUI->ResetState();
423 catch ( const SALOME::SALOME_Exception& S_ex ) {
424 SalomeApp_Tools::QtCatchCorbaException( S_ex );
430 //=======================================================================
431 // function : GetPatternName()
432 // purpose : Get name of pattern
433 //=======================================================================
434 QString SMESHGUI_CreatePatternDlg::GetPatternName() const
436 return myName->text();
439 //=======================================================================
440 // function : GetPattern()
441 // purpose : Get result pattern
442 //=======================================================================
443 SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern()
445 return myPattern.in();
448 //=======================================================================
450 // purpose : SLOT called when "Ok" button pressed.
451 //=======================================================================
452 void SMESHGUI_CreatePatternDlg::onOk()
459 loadFromObject( true );
461 // Load pattern from object
466 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
467 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
468 aViewWindow->SetSelectionMode( ActorSelection );
469 disconnect( mySelectionMgr, 0, this, 0 );
470 disconnect( mySMESHGUI, 0, this, 0 );
471 mySMESHGUI->ResetState();
476 catch ( const SALOME::SALOME_Exception& S_ex ) {
477 SalomeApp_Tools::QtCatchCorbaException( S_ex );
483 //=======================================================================
484 // function : onClose()
485 // purpose : SLOT called when "Close" button pressed. Close dialog
486 //=======================================================================
487 void SMESHGUI_CreatePatternDlg::onClose()
489 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
490 aViewWindow->SetSelectionMode( ActorSelection );
491 disconnect( mySelectionMgr, 0, this, 0 );
492 disconnect( mySMESHGUI, 0, this, 0 );
493 mySMESHGUI->ResetState();
498 //=================================================================================
499 // function : onHelp()
501 //=================================================================================
502 void SMESHGUI_CreatePatternDlg::onHelp()
504 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
506 app->onHelpContextModule( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) : QString( "" ), myHelpFileName );
510 platform = "winapplication";
512 platform = "application";
514 SUIT_MessageBox::warning( this,
516 tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
517 arg( app->resourceMgr()->stringValue( "ExternalBrowser",
519 arg( myHelpFileName ) );
523 //=======================================================================
524 // function : loadFromObject()
525 // purpose : Load pattern from geom object corresponding to the mesh/submesh
526 //=======================================================================
527 bool SMESHGUI_CreatePatternDlg::loadFromObject( const bool theMess )
532 if ( myPattern->_is_nil() )
533 myPattern = SMESH::GetPattern();
535 if ( myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil() )
538 SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather();
540 myIsLoaded = myType == Type_2d
541 ? myPattern->LoadFromFace( aMesh, myGeomObj, myProjectChk->isChecked() )
542 : myPattern->LoadFrom3DBlock( aMesh, myGeomObj );
544 if ( !myIsLoaded && theMess ) {
546 SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode();
548 if ( aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr( "ERR_LOAD_EMPTY_SUBMESH" );
549 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr( "ERR_LOADF_NARROW_FACE" );
550 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr( "ERR_LOADF_CLOSED_FACE" );
551 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CANT_PROJECT ) aMess = tr( "ERR_LOADF_CANT_PROJECT" );
552 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr( "ERR_LOADV_BAD_SHAPE" );
553 else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS ) aMess = tr( "ERR_LOADV_COMPUTE_PARAMS" );
554 else aMess = tr( "ERROR_OF_CREATION" );
556 SUIT_MessageBox::information( this, tr( "SMESH_ERROR" ), aMess );
559 catch ( const SALOME::SALOME_Exception& S_ex ) {
560 SalomeApp_Tools::QtCatchCorbaException( S_ex );
566 //=======================================================================
567 // function : onSelectionDone()
568 // purpose : SLOT called when selection changed
569 //=======================================================================
570 void SMESHGUI_CreatePatternDlg::onSelectionDone()
574 mySelectionMgr->selectedObjects( aList, SVTK_Viewer::Type() );
575 if ( aList.Extent() != 1 )
578 // Get mesh or sub-mesh from selection
579 Handle(SALOME_InteractiveObject) anIO = aList.First();
580 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIO );
581 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>( anIO );
582 if ( aMesh->_is_nil() && aSubMesh->_is_nil() )
585 // Get geom object corresponding to the mesh
587 if ( !aMesh->_is_nil() )
588 aSO = SMESH::FindSObject( aMesh.in() );
590 aSO = SMESH::FindSObject( aSubMesh.in() );
592 GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom( aSO );
593 if ( aGeomObj->_is_nil() )
596 myGeomObj = aGeomObj;
599 if ( !aMesh->_is_nil() ) {
601 mySubMesh = SMESH::SMESH_subMesh::_nil();
604 mySubMesh = aSubMesh;
605 myMesh = SMESH::SMESH_Mesh::_nil();
609 SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aName );
610 myMeshEdit->setText( aName );
612 if ( myType == Type_2d ) {
613 loadFromObject( true );
618 myMesh = SMESH::SMESH_Mesh::_nil();
619 mySubMesh = SMESH::SMESH_subMesh::_nil();
620 myGeomObj = GEOM::GEOM_Object::_nil();
625 //=======================================================================
626 // function : onDeactivate()
627 // purpose : SLOT called when dialog must be deativated
628 //=======================================================================
629 void SMESHGUI_CreatePatternDlg::onDeactivate()
631 disconnect( mySelectionMgr, 0, this, 0 );
635 //=======================================================================
636 // function : enterEvent()
637 // purpose : Event filter
638 //=======================================================================
639 void SMESHGUI_CreatePatternDlg::enterEvent( QEvent* )
641 // there is a stange problem that enterEvent() comes after onSave()
642 if ( isVisible () ) {
643 mySMESHGUI->EmitSignalDeactivateDialog();
646 connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
650 //=================================================================================
651 // function : closeEvent()
652 // purpose : Close dialog box
653 //=================================================================================
654 void SMESHGUI_CreatePatternDlg::closeEvent( QCloseEvent* )
659 //=======================================================================
660 // function : onSelBtnClicked()
661 // purpose : SLOT. Called when -> button clicked.
662 //=======================================================================
663 void SMESHGUI_CreatePatternDlg::onSelBtnClicked()
668 //================================================================
669 // function : autoExtension()
670 // purpose : Append extension to the file name
671 //================================================================
672 QString SMESHGUI_CreatePatternDlg::autoExtension( const QString& theFileName ) const
674 QString anExt = theFileName.section('.', -1);
675 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
678 //=======================================================================
679 // function : displayPreview()
680 // purpose : Display preview
681 //=======================================================================
682 void SMESHGUI_CreatePatternDlg::displayPreview()
684 // Redisplay preview in dialog
690 SMESH::point_array_var pnts = myPattern->GetPoints();
691 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
692 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints( false );
694 if ( pnts->length() == 0 ||
695 keyPoints->length() == 0 ||
696 elemPoints->length() == 0 ) {
702 PointVector aPoints( pnts->length() );
703 QVector<int> aKeyPoints( keyPoints->length() );
704 ConnectivityVector anElemPoints( elemPoints->length() );
706 for ( int i = 0, n = pnts->length(); i < n; i++ )
707 aPoints[ i ] = pnts[ i ];
709 for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ )
710 aKeyPoints[ i2 ] = keyPoints[ i2 ];
712 for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
713 QVector<int> aVec (elemPoints[ i3 ].length());
714 for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
715 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
717 anElemPoints[ i3 ] = aVec;
720 myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints );
726 catch ( const SALOME::SALOME_Exception& S_ex ) {
727 SalomeApp_Tools::QtCatchCorbaException( S_ex );
734 //=======================================================================
735 // function : erasePreview()
736 // purpose : Erase preview
737 //=======================================================================
738 void SMESHGUI_CreatePatternDlg::erasePreview()
740 // Erase preview in 2D viewer
741 myPicture2d->SetPoints( PointVector(), QVector<int>(), ConnectivityVector() );
744 //=======================================================================
745 // function : activateSelection()
746 // purpose : Activate selection in accordance with current pattern type
747 //=======================================================================
748 void SMESHGUI_CreatePatternDlg::activateSelection()
750 mySelectionMgr->clearFilters();
751 //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
752 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
753 aViewWindow->SetSelectionMode( ActorSelection );
755 if ( myType == Type_2d ) {
756 mySelectionMgr->installFilter( new SMESH_NumberFilter( "SMESH",
762 TColStd_MapOfInteger aTypes;
763 aTypes.Add( TopAbs_SHELL );
764 aTypes.Add( TopAbs_SOLID );
765 mySelectionMgr->installFilter( new SMESH_NumberFilter( "SMESH",
769 GEOM::GEOM_Object::_nil(),
774 //=======================================================================
775 // function : onTypeChanged()
776 // purpose : SLOT. Called when pattern type changed.
777 // Change dialog's look and feel
778 //=======================================================================
779 void SMESHGUI_CreatePatternDlg::onTypeChanged( int theType )
781 if ( myType == theType )
786 myPicture2d->setVisible( theType == Type_2d );
787 myProjectChk->setVisible( theType == Type_2d );
790 //=================================================================================
791 // function : keyPressEvent()
793 //=================================================================================
794 void SMESHGUI_CreatePatternDlg::keyPressEvent( QKeyEvent* e )
796 QDialog::keyPressEvent( e );
797 if ( e->isAccepted() )
800 if ( e->key() == Qt::Key_F1 ){