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"
30 #include "QAD_Desktop.h"
31 #include "QAD_FileDlg.h"
33 #include "SMESHGUI_SpinBox.h"
35 #include "SALOME_Selection.h"
36 #include "SMESH_NumberFilter.hxx"
37 #include "SMESHGUI_Utils.h"
38 #include "SMESHGUI_VTKUtils.h"
39 #include "SMESHGUI_CreatePatternDlg.h"
40 #include "SMESHGUI_PatternWidget.h"
41 #include "SMESH_Actor.h"
42 #include "SALOMEGUI_QtCatchCorbaException.hxx"
43 #include "VTKViewer_ViewFrame.h"
44 #include "SMESHGUI_PatternUtils.h"
45 #include "SMESH_ActorUtils.h"
46 #include "SMDS_MeshElement.hxx"
47 #include "SMDS_Mesh.hxx"
49 #include "QAD_Config.h"
51 #include <TColStd_MapOfInteger.hxx>
55 #include <qlineedit.h>
56 #include <qpushbutton.h>
57 #include <qgroupbox.h>
59 #include <qradiobutton.h>
60 #include <qcheckbox.h>
61 #include <qbuttongroup.h>
62 #include <qmessagebox.h>
65 #include <qvaluelist.h>
68 #include <vtkIdList.h>
69 #include <vtkIntArray.h>
70 #include <vtkCellArray.h>
71 #include <vtkUnsignedCharArray.h>
72 #include <vtkUnstructuredGrid.h>
73 #include <vtkDataSetMapper.h>
79 Class : SMESHGUI_MeshPatternDlg
80 Description : Dialog to specify filters for VTK viewer
83 //=======================================================================
84 // name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg
85 // Purpose : Constructor
86 //=======================================================================
87 SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( QWidget* theParent,
88 SALOME_Selection* theSelection,
90 : QDialog( theParent, theName, false,
91 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
94 setCaption( tr( "CAPTION" ) );
96 QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING );
98 QFrame* aMainFrame = createMainFrame ( this );
99 QFrame* aBtnFrame = createButtonFrame( this );
104 aDlgLay->addWidget( aMainFrame );
105 aDlgLay->addWidget( aBtnFrame );
107 aDlgLay->setStretchFactor( aMainFrame, 1 );
110 Init( theSelection );
113 //=======================================================================
114 // name : SMESHGUI_MeshPatternDlg::createMainFrame
115 // Purpose : Create frame containing dialog's input fields
116 //=======================================================================
117 QFrame* SMESHGUI_MeshPatternDlg::createMainFrame( QWidget* theParent )
119 QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
120 QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) );
121 QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) );
122 QPixmap iconOpen( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_FILE_OPEN" ) ) );
124 QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );
125 QPixmap iconSample3d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_3D" ) ) );
127 QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent );
128 aMainGrp->setFrameStyle( QFrame::NoFrame );
129 aMainGrp->setInsideMargin( 0 );
131 // Pattern type group
133 myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp );
134 mySwitch2d = new QRadioButton( myTypeGrp );
135 mySwitch3d = new QRadioButton( myTypeGrp );
136 mySwitch2d->setPixmap( icon2d );
137 mySwitch3d->setPixmap( icon3d );
138 myTypeGrp->insert( mySwitch2d, Type_2d );
139 myTypeGrp->insert( mySwitch3d, Type_3d );
144 QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MESH" ), aMainGrp );
145 new QLabel( tr( "SMESH_MESH" ), aMeshGrp );
146 mySelBtn[ Mesh ] = new QPushButton( aMeshGrp );
147 mySelBtn[ Mesh ]->setPixmap( iconSlct );
148 mySelEdit[ Mesh ] = new QLineEdit( aMeshGrp );
149 mySelEdit[ Mesh ]->setReadOnly( true );
153 QGroupBox* aPatGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp );
156 QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, aPatGrp );
157 aNameGrp->setFrameStyle( QFrame::NoFrame );
158 aNameGrp->setInsideMargin( 0 );
159 new QLabel( tr( "PATTERN" ), aNameGrp );
160 myName = new QLineEdit( aNameGrp );
161 myName->setReadOnly( true );
162 myOpenBtn = new QPushButton( aNameGrp );
163 myOpenBtn->setPixmap( iconOpen );
164 myNewBtn = new QPushButton( tr( "NEW" ), aNameGrp );
166 // Mode selection check box
167 myRefine = new QCheckBox( tr( "REFINE" ), aPatGrp );
169 // selection widgets for Apply to geom mode
170 myGeomGrp = new QGroupBox( 3, Qt::Horizontal, aPatGrp );
171 myGeomGrp->setFrameStyle( QFrame::NoFrame );
172 myGeomGrp->setInsideMargin( 0 );
174 for ( int i = Object; i <= Vertex2; i++ )
176 mySelLbl[ i ] = new QLabel( myGeomGrp );
177 mySelBtn[ i ] = new QPushButton( myGeomGrp );
178 mySelBtn[ i ]->setPixmap( iconSlct );
179 mySelEdit[ i ] = new QLineEdit( myGeomGrp );
180 mySelEdit[ i ]->setReadOnly( true );
183 // Widgets for refinement of existing mesh elements
184 myRefineGrp = new QFrame( aPatGrp );
185 myRefineGrp->setFrameStyle( QFrame::NoFrame );
186 QGridLayout* aRefGrid = new QGridLayout( myRefineGrp, 3, 3, 0, 5 );
188 mySelLbl[ Ids ] = new QLabel( myRefineGrp );
189 mySelBtn[ Ids ] = new QPushButton( myRefineGrp );
190 mySelBtn[ Ids ]->setPixmap( iconSlct );
191 mySelEdit[ Ids ] = new QLineEdit( myRefineGrp );
193 QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp );
194 myNode1 = new QSpinBox( myRefineGrp );
195 myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp );
196 myNode2 = new QSpinBox( myRefineGrp );
198 aRefGrid->addWidget( mySelLbl [ Ids ], 0, 0 );
199 aRefGrid->addWidget( mySelBtn [ Ids ], 0, 1 );
200 aRefGrid->addWidget( mySelEdit[ Ids ], 0, 2 );
201 aRefGrid->addWidget( aNodeLbl, 1, 0 );
202 aRefGrid->addMultiCellWidget( myNode1, 1, 1, 1, 2 );
203 aRefGrid->addWidget( myNode2Lbl, 2, 0 );
204 aRefGrid->addMultiCellWidget( myNode2, 2, 2, 1, 2 );
207 myReverseChk = new QCheckBox( tr( "REVERSE" ), aPatGrp );
209 // Pictures 2d and 3d
210 for ( int i = 0; i < 2; i++ )
214 myPicture2d = new SMESHGUI_PatternWidget( aPatGrp ),
215 myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
219 myPicture3d = new QFrame( aPatGrp ),
220 myPreview3d = new QLabel( myPicture3d );
221 myPreview3d->setPixmap( iconSample3d );
222 QGridLayout* aLay = new QGridLayout( myPicture3d, 3, 3, 0, 0 );
223 QSpacerItem* aSpacerH1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
224 QSpacerItem* aSpacerH2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
225 QSpacerItem* aSpacerV1 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
226 QSpacerItem* aSpacerV2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
227 aLay->addItem( aSpacerH1, 1, 0 );
228 aLay->addItem( aSpacerH2, 1, 2 );
229 aLay->addItem( aSpacerV1, 0, 1 );
230 aLay->addItem( aSpacerV2, 2, 1 );
231 aLay->addWidget( myPreview3d, 1, 1 );
235 myPreviewChk = new QCheckBox( tr( "PREVIEW" ), aPatGrp );
237 // Connect signals and slots
239 connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) );
240 connect( myOpenBtn, SIGNAL( clicked() ), SLOT( onOpen() ) );
241 connect( myNewBtn, SIGNAL( clicked() ), SLOT( onNew() ) );
242 connect( myReverseChk, SIGNAL( toggled( bool ) ), SLOT( onReverse( bool ) ) );
243 connect( myPreviewChk, SIGNAL( toggled( bool ) ), SLOT( onPreview( bool ) ) );
244 connect( myRefine, SIGNAL( toggled( bool ) ), SLOT( onModeToggled( bool ) ) );
245 connect( myNode1, SIGNAL( valueChanged( int ) ), SLOT( onNodeChanged( int ) ) );
246 connect( myNode2, SIGNAL( valueChanged( int ) ), SLOT( onNodeChanged( int ) ) );
247 connect( mySelEdit[Ids], SIGNAL( textChanged( const QString& ) ), SLOT( onTextChanged( const QString& ) ) );
249 QMap< int, QPushButton* >::iterator anIter;
250 for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter )
251 connect( *anIter, SIGNAL( clicked() ), SLOT( onSelInputChanged() ) );
256 //=======================================================================
258 // name : SMESHGUI_MeshPatternDlg::createButtonFrame
259 // Purpose : Create frame containing buttons
260 //=======================================================================
261 QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame( QWidget* theParent )
263 QFrame* aFrame = new QFrame( theParent );
264 aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
266 myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame );
267 myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame );
268 myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame );
270 QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
272 QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING );
274 aLay->addWidget( myOkBtn );
275 aLay->addWidget( myApplyBtn );
276 aLay->addItem( aSpacer);
277 aLay->addWidget( myCloseBtn );
279 connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) );
280 connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ;
281 connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) );
286 //=======================================================================
287 // name : SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg
288 // Purpose : Destructor
289 //=======================================================================
290 SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg()
294 //=======================================================================
295 // name : SMESHGUI_MeshPatternDlg::Init
296 // Purpose : Init dialog fields, connect signals and slots, show dialog
297 //=======================================================================
298 void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection )
300 myPattern = SMESH::GetPattern();
302 myIsCreateDlgOpen = false;
306 mySelection = theSelection;
307 SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
308 aSMESHGUI->SetActiveDialogBox( ( QDialog* )this );
309 myMesh = SMESH::SMESH_Mesh::_nil();
311 myMeshShape = GEOM::GEOM_Object::_nil();
312 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
313 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
314 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
316 // selection and SMESHGUI
317 connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
318 connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) );
319 connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) );
321 myTypeGrp->setButton( Type_2d );
322 onTypeChanged( Type_2d );
323 onModeToggled( isRefine() );
327 resize( minimumSize() );
333 aSMESHGUI->DefineDlgPosition( this, x, y );
338 //=======================================================================
339 // name : SMESHGUI_MeshPatternDlg::isValid
340 // Purpose : Verify validity of entry data
341 //=======================================================================
342 bool SMESHGUI_MeshPatternDlg::isValid( const bool theMess )
345 if ( ( isRefine() && ( myMesh->_is_nil() || !getIds( ids ) || getNode( false ) < 0 || myType == Type_3d && ( getNode( true ) < 0 || getNode( false ) == getNode( true ) ) ) )
346 || ( !isRefine() && ( myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() ||
347 myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil() ) ) )
350 QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
351 tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok );
358 //=======================================================================
359 // name : SMESHGUI_MeshPatternDlg::onApply
360 // Purpose : SLOT called when "Apply" button pressed.
361 //=======================================================================
362 bool SMESHGUI_MeshPatternDlg::onApply()
371 if ( isRefine() ) { // Refining existing mesh elements
374 SMESH::long_array_var varIds = new SMESH::long_array();
375 varIds->length( ids.count() );
377 for ( QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it )
380 ? myPattern->ApplyToMeshFaces ( myMesh, varIds, getNode( false ), myReverseChk->isChecked() )
381 : myPattern->ApplyToHexahedrons( myMesh, varIds, getNode( false ), getNode( true ) );
383 else { // Applying a pattern to geometrical object
384 if ( myType == Type_2d )
385 myPattern->ApplyToFace(
386 myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() );
388 myPattern->ApplyTo3DBlock(
389 myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] );
392 if ( myPattern->MakeMesh( myMesh ) )
394 mySelection->ClearIObjects();
395 SMESHGUI* aCompGUI = SMESHGUI::GetSMESHGUI();
396 if ( !isRefine() && !QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) ) {
397 SALOMEDS::SObject_var aSO = SMESH::FindSObject( myMesh.in() );
398 SMESH_Actor* anActor = SMESH::FindActorByEntry( aSO->GetID() );
400 anActor = SMESH::CreateActor( aSO->GetStudy(), aSO->GetID() );
402 SMESH::DisplayActor( aCompGUI->GetActiveStudy()->getActiveStudyFrame(), anActor );
409 aCompGUI->GetActiveStudy()->updateObjBrowser( true );
414 QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
415 tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), QMessageBox::Ok );
419 catch( const SALOME::SALOME_Exception& S_ex )
421 QtCatchCorbaException( S_ex );
430 //=======================================================================
431 // name : SMESHGUI_MeshPatternDlg::onOk
432 // Purpose : SLOT called when "Ok" button pressed.
433 //=======================================================================
434 void SMESHGUI_MeshPatternDlg::onOk()
440 //=======================================================================
441 // name : SMESHGUI_MeshPatternDlg::onClose
442 // Purpose : SLOT called when "Close" button pressed. Close dialog
443 //=======================================================================
444 void SMESHGUI_MeshPatternDlg::onClose()
446 mySelection->ClearFilters();
447 SMESH::SetPickable();
448 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
449 disconnect( mySelection, 0, this, 0 );
450 disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 );
451 SMESHGUI::GetSMESHGUI()->ResetState();
458 //=======================================================================
459 // name : SMESHGUI_MeshPatternDlg::onSelectionDone
460 // Purpose : SLOT called when selection changed
461 //=======================================================================
462 void SMESHGUI_MeshPatternDlg::onSelectionDone()
469 if ( mySelInput == Mesh )
471 if ( mySelection->IObjectCount() != 1 )
474 // Retrieve mesh from selection
475 Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
476 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIO );
477 if ( aMesh->_is_nil() )
480 // Get geom object corresponding to the mesh
481 SALOMEDS::Study_var aStudy =
482 SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument();
484 SALOMEDS::SObject_var aSO = SMESH::FindSObject( aMesh.in() );
485 if ( aSO->_is_nil() )
488 bool isFound = false;
489 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO );
490 for( ; anIter->More(); anIter->Next() )
492 SALOMEDS::SObject_var aSO = anIter->Value();
493 SALOMEDS::SObject_var aRefSO;
495 GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(
496 aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() );
498 if ( !aMeshShape->_is_nil() )
501 myMeshShape = aMeshShape;
508 myMeshShape = GEOM::GEOM_Object::_nil();
510 // Clear fields of geom objects if mesh was changed
511 if ( myMesh != aMesh )
513 for ( int i = Object; i <= Ids; i++ )
515 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
516 mySelEdit[ i ]->setText( "" );
522 // Set name of mesh in line edit
524 SMESH::GetNameOfSelectedIObjects( mySelection, aName );
525 mySelEdit[ Mesh ]->setText( aName );
527 else if ( mySelInput == Ids ) {
529 if ( !SMESH::GetNameOfSelectedElements( mySelection, anIds ) )
533 mySelEdit[ Ids ]->setText( anIds );
538 if ( mySelection->IObjectCount() != 1 )
541 // Get geom object from selection
542 Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
543 GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( anIO );
544 if ( anObj->_is_nil() )
547 // Clear fields of vertexes if face or 3d block was changed
548 if ( anObj != myGeomObj[ mySelInput ] && mySelInput == Object )
550 for ( int i = Vertex1; i <= Vertex2; i++ )
552 myGeomObj[ i ] = GEOM::GEOM_Object::_nil();
553 mySelEdit[ i ]->setText( "" );
557 myGeomObj[ mySelInput ] = anObj;
559 // Set name of geom object in line edit
561 SMESH::GetNameOfSelectedIObjects( mySelection, aName );
562 mySelEdit[ mySelInput ]->setText( aName );
565 catch( const SALOME::SALOME_Exception& S_ex )
567 QtCatchCorbaException( S_ex );
579 //=======================================================================
580 // name : SMESHGUI_MeshPatternDlg::resetSelInput
581 // Purpose : Reset fields corresponding to the current selection input
582 //=======================================================================
583 void SMESHGUI_MeshPatternDlg::resetSelInput()
585 if ( mySelInput == Mesh )
587 myMesh = SMESH::SMESH_Mesh::_nil();
588 myMeshShape = GEOM::GEOM_Object::_nil();
592 myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil();
594 mySelEdit[ mySelInput ]->setText( "" );
597 //=======================================================================
598 // name : SMESHGUI_MeshPatternDlg::onDeactivate
599 // Purpose : SLOT called when dialog must be deativated
600 //=======================================================================
601 void SMESHGUI_MeshPatternDlg::onDeactivate()
603 mySelection->ClearFilters();
604 //if ( myReverseChk->isChecked() )
606 disconnect( mySelection, 0, this, 0 );
610 //=======================================================================
611 // name : SMESHGUI_MeshPatternDlg::enterEvent
612 // Purpose : Event filter
613 //=======================================================================
614 void SMESHGUI_MeshPatternDlg::enterEvent( QEvent* )
616 if ( myIsCreateDlgOpen )
619 if ( myReverseChk->isChecked() )
621 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ;
624 connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
625 onTextChanged( mySelEdit[Ids]->text() );
629 //=================================================================================
630 // function : closeEvent()
632 //=================================================================================
633 void SMESHGUI_MeshPatternDlg::closeEvent( QCloseEvent* e )
638 //=======================================================================
639 // name : SMESHGUI_MeshPatternDlg::onSelInputChanged
640 // Purpose : SLOT. Called when -> button clicked.
641 // Change current selection input field
642 //=======================================================================
643 void SMESHGUI_MeshPatternDlg::onSelInputChanged()
645 const QObject* aSender = sender();
646 for ( int i = Mesh; i <= Ids; i++ )
647 if ( aSender == mySelBtn[ i ] )
654 //=======================================================================
655 // name : SMESHGUI_MeshPatternDlg::prepareFilters
656 // Purpose : Prepare filters for dialog
657 //=======================================================================
659 QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const
661 static QStringList aList;
662 if ( aList.isEmpty() )
664 aList.append( tr( "PATTERN_FILT" ) );
665 //aList.append( tr( "ALL_FILES_FILTER" ) );
671 //================================================================
673 // Function : SMESHGUI_MeshPatternDlg::autoExtension
674 // Purpose : Append extension to the file name
675 //================================================================
676 QString SMESHGUI_MeshPatternDlg::autoExtension( const QString& theFileName ) const
678 QString anExt = theFileName.section( '.', -1 );
679 return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
682 //=======================================================================
683 // name : SMESHGUI_MeshPatternDlg::onOpen
684 // Purpose : SLOT. Called when "Open" button clicked.
685 // Displays file open dialog
686 //=======================================================================
687 void SMESHGUI_MeshPatternDlg::onOpen()
689 QAD_FileDlg* aDlg = new QAD_FileDlg( this, true );
690 aDlg->setCaption( tr( "LOAD_PATTERN" ) );
691 aDlg->setMode( QFileDialogP::ExistingFile );
692 aDlg->setFilters( prepareFilters() );
693 if ( myName->text() != "" )
694 aDlg->setSelection( myName->text() + ".smp" );
695 QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" );
697 anOkBtn->setText( tr( "SMESH_BUT_OK" ) );
699 if ( aDlg->exec() != Accepted )
702 QString fName = aDlg->selectedFile();
703 if ( fName.isEmpty() )
706 if ( QFileInfo( fName ).extension().isEmpty() )
707 fName = autoExtension( fName );
709 fName = QDir::convertSeparators( fName );
711 QString prev = QDir::convertSeparators( myName->text() );
715 // Read string from file
716 QFile aFile( fName );
717 if ( !aFile.open( IO_ReadOnly ) )
719 QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
720 tr( "SMESH_ERROR" ), tr( "ERROR_OF_OPENING" ), QMessageBox::Ok );
724 QByteArray aDataArray = aFile.readAll();
725 const char* aData = aDataArray.data();
728 QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
729 tr( "SMESH_ERROR" ), tr( "ERROR_OF_READING" ), QMessageBox::Ok );
733 if ( loadFromFile( aData ) )
734 myName->setText( QFileInfo( fName ).baseName() );
740 //=======================================================================
741 // name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg
742 // Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close"
743 //=======================================================================
744 void SMESHGUI_MeshPatternDlg::onCloseCreationDlg()
747 myIsCreateDlgOpen = false;
751 //=======================================================================
752 // name : SMESHGUI_MeshPatternDlg::onOkCreationDlg
753 // Purpose : SLOT. Called when "Pattern creation" dialog closed with OK
754 // or SAVE buttons. Initialize myPattern field. Redisplay preview
755 //=======================================================================
756 void SMESHGUI_MeshPatternDlg::onOkCreationDlg()
758 myPattern = SMESH::SMESH_Pattern::_duplicate( myCreationDlg->GetPattern() );
759 myName->setText( myCreationDlg->GetPatternName() );
762 myIsCreateDlgOpen = false;
766 //=======================================================================
767 // name : SMESHGUI_MeshPatternDlg::onNew
768 // Purpose : SLOT. Called when "New..." button clicked. Create new pattern
769 //=======================================================================
770 void SMESHGUI_MeshPatternDlg::onNew()
773 myIsCreateDlgOpen = true;
774 if ( myCreationDlg == 0 )
776 myCreationDlg = new SMESHGUI_CreatePatternDlg( this, mySelection, myType );
777 connect( myCreationDlg, SIGNAL( NewPattern() ), SLOT( onOkCreationDlg() ) );
778 connect( myCreationDlg, SIGNAL( Close() ), SLOT( onCloseCreationDlg() ) );
781 myCreationDlg->Init( mySelection, myType );
783 myCreationDlg->SetMesh( myMesh );
784 myCreationDlg->show();
787 //=======================================================================
788 // name : SMESHGUI_MeshPatternDlg::onReverse
789 // Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged
790 // Calculate new points of the mesh to be created. Redisplay preview
791 //=======================================================================
792 void SMESHGUI_MeshPatternDlg::onReverse( bool )
797 //=======================================================================
799 // name : SMESHGUI_MeshPatternDlg::onPreview
800 // Purpose : SLOT. Called when state of "Preview" checkbox changed
801 // Display/Erase preview
802 //=======================================================================
803 void SMESHGUI_MeshPatternDlg::onPreview( bool )
808 //=======================================================================
809 // name : SMESHGUI_MeshPatternDlg::displayPreview
810 // Purpose : Display preview
811 //=======================================================================
812 void SMESHGUI_MeshPatternDlg::displayPreview()
816 // Redisplay preview in dialog
818 SMESH::point_array_var pnts = myPattern->GetPoints();
819 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
820 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);
822 if ( pnts->length() == 0 ||
823 keyPoints->length() == 0 ||
824 elemPoints->length() == 0 )
832 PointVector aPoints( pnts->length() );
833 QValueVector<int> aKeyPoints( keyPoints->length() );
834 ConnectivityVector anElemPoints( elemPoints->length() );
836 for ( int i = 0, n = pnts->length(); i < n; i++ )
837 aPoints[ i ] = pnts[ i ];
839 for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ )
840 aKeyPoints[ i2 ] = keyPoints[ i2 ];
842 for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ )
844 QValueVector<int> aVec( elemPoints[ i3 ].length() );
845 for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ )
846 aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
848 anElemPoints[ i3 ] = aVec;
851 myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints );
855 // Redisplay preview in 3D viewer
857 if ( myPreviewActor != 0 )
859 if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() )
861 vf->RemoveActor(myPreviewActor);
864 myPreviewActor->Delete();
868 if ( !myPreviewChk->isChecked() || !isValid( false ) )
871 vtkUnstructuredGrid* aGrid = getGrid();
875 // Create and display actor
876 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
877 aMapper->SetInput( aGrid );
879 myPreviewActor = SALOME_Actor::New();
880 myPreviewActor->PickableOff();
881 myPreviewActor->SetMapper( aMapper );
883 vtkProperty* aProp = vtkProperty::New();
884 aProp->SetRepresentationToWireframe();
885 aProp->SetColor( 250, 0, 250 );
886 if ( SMESH::FindActorByObject( myMesh ) )
887 aProp->SetLineWidth( SMESH::GetFloat( "SMESH:SettingsWidth", 1 ) +1 );
889 aProp->SetLineWidth( 1 );
890 myPreviewActor->SetProperty( aProp );
892 myPreviewActor->SetRepresentation( 3 );
894 SMESH::GetCurrentVtkView()->AddActor( myPreviewActor );
895 SMESH::GetCurrentVtkView()->Repaint();
900 catch( const SALOME::SALOME_Exception& S_ex )
902 QtCatchCorbaException( S_ex );
911 //=======================================================================
912 // name : SMESHGUI_MeshPatternDlg::erasePreview
913 // Purpose : Erase preview
914 //=======================================================================
915 void SMESHGUI_MeshPatternDlg::erasePreview()
917 // Erase preview in 2D viewer
918 myPicture2d->SetPoints( PointVector(), QValueVector<int>(), ConnectivityVector() );
920 // Erase preview in 3D viewer
921 if ( myPreviewActor == 0 )
925 if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() )
927 vf->RemoveActor(myPreviewActor);
930 myPreviewActor->Delete();
934 //=======================================================================
935 // name : SMESHGUI_MeshPatternDlg::updateWgState
936 // Purpose : Enable/disable selection widgets
937 //=======================================================================
938 void SMESHGUI_MeshPatternDlg::updateWgState()
940 if ( myMesh->_is_nil() )
942 for ( int i = Object; i <= Ids; i++ )
944 mySelBtn [ i ]->setEnabled( false );
945 mySelEdit[ i ]->setEnabled( false );
946 mySelEdit[ i ]->setText( "" );
948 myNode1->setEnabled( false );
949 myNode2->setEnabled( false );
950 myNode1->setRange( 0, 0 );
951 myNode2->setRange( 0, 0 );
955 mySelBtn [ Object ]->setEnabled( true );
956 mySelEdit[ Object ]->setEnabled( true );
957 mySelBtn [ Ids ] ->setEnabled( true );
958 mySelEdit[ Ids ] ->setEnabled( true );
960 if ( myGeomObj[ Object ]->_is_nil() )
962 for ( int i = Vertex1; i <= Vertex2; i++ )
964 mySelBtn [ i ]->setEnabled( false );
965 mySelEdit[ i ]->setEnabled( false );
966 mySelEdit[ i ]->setText( "" );
971 for ( int i = Object; i <= Vertex2; i++ )
973 mySelBtn [ i ]->setEnabled( true );
974 mySelEdit[ i ]->setEnabled( true );
979 if ( !CORBA::is_nil( myPattern ) && getIds( ids ) ) {
980 SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
981 if ( keyPoints->length() ) {
982 myNode1->setEnabled( true );
983 myNode2->setEnabled( true );
984 myNode1->setRange( 1, keyPoints->length() );
985 myNode2->setRange( 1, keyPoints->length() );
990 myNode1->setEnabled( false );
991 myNode2->setEnabled( false );
992 myNode1->setRange( 0, 0 );
993 myNode2->setRange( 0, 0 );
997 //=======================================================================
998 // name : SMESHGUI_MeshPatternDlg::activateSelection
999 // Purpose : Activate selection in accordance with current selection input
1000 //=======================================================================
1001 void SMESHGUI_MeshPatternDlg::activateSelection()
1003 mySelection->ClearFilters();
1004 if ( mySelInput == Ids ) {
1005 SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
1007 SMESH::SetPickable(anActor);
1009 if ( myType == Type_2d )
1010 QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
1012 QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true );
1015 SMESH::SetPickable();
1016 QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
1019 if ( mySelInput == Object && !myMeshShape->_is_nil() )
1021 if ( myType == Type_2d )
1023 if ( myNbPoints > 0 )
1024 mySelection->AddFilter( new SMESH_NumberFilter(
1026 "GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape ) );
1028 mySelection->AddFilter( new SMESH_NumberFilter(
1029 "GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape ) );
1033 TColStd_MapOfInteger aTypes;
1034 aTypes.Add( TopAbs_SHELL );
1035 aTypes.Add( TopAbs_SOLID );
1036 mySelection->AddFilter( new SMESH_NumberFilter(
1037 "GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true ) );
1040 else if ( ( mySelInput == Vertex1 || mySelInput == Vertex2 ) && !myGeomObj[ Object ]->_is_nil() )
1042 mySelection->AddFilter( new SMESH_NumberFilter(
1043 "GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ] ) );
1047 //=======================================================================
1048 // name : SMESHGUI_MeshPatternDlg::loadFromFile
1049 // Purpose : Load pattern from file
1050 //=======================================================================
1051 bool SMESHGUI_MeshPatternDlg::loadFromFile( const QString& theName )
1055 SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
1057 if ( !aPattern->LoadFromFile( theName.latin1() ) ||
1058 myType == Type_2d && !aPattern->Is2D())
1060 SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();
1062 if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr( "ERR_READ_NB_POINTS" );
1063 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr( "ERR_READ_POINT_COORDS" );
1064 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS ) aMess = tr( "ERR_READ_TOO_FEW_POINTS" );
1065 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr( "ERR_READ_3D_COORD" );
1066 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr( "ERR_READ_NO_KEYPOINT" );
1067 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr( "ERR_READ_BAD_INDEX" );
1068 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr( "ERR_READ_ELEM_POINTS" );
1069 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr( "ERR_READ_NO_ELEMS" );
1070 else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr( "ERR_READ_BAD_KEY_POINT" );
1071 else aMess = tr( "ERROR_OF_LOADING" );
1073 QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
1074 tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok );
1079 myPattern = aPattern;
1083 catch( const SALOME::SALOME_Exception& S_ex )
1085 QtCatchCorbaException( S_ex );
1086 QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
1087 tr( "SMESH_ERROR" ), tr( "ERROR_OF_LOADING" ), QMessageBox::Ok );
1092 //=======================================================================
1093 // name : SMESHGUI_MeshPatternDlg::onTypeChanged
1095 // Purpose : SLOT. Called when pattern type changed.
1096 // Change dialog's look and feel
1097 //=======================================================================
1098 void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType )
1100 if ( myType == theType )
1106 myGeomObj[ Object ] = GEOM::GEOM_Object::_nil();
1107 myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil();
1108 myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil();
1109 myPattern = SMESH::GetPattern();
1111 myName->setText( "" );
1112 mySelEdit[ Object ]->setText( "" );
1113 mySelEdit[ Vertex1 ]->setText( "" );
1114 mySelEdit[ Vertex2 ]->setText( "" );
1115 mySelEdit[ Ids ] ->setText( "" );
1117 if ( theType == Type_2d )
1120 mySelLbl [ Vertex2 ]->hide();
1121 mySelBtn [ Vertex2 ]->hide();
1122 mySelEdit[ Vertex2 ]->hide();
1123 myReverseChk->show();
1124 myPicture2d->show();
1125 myPicture3d->hide();
1126 mySelLbl[ Object ]->setText( tr( "FACE" ) );
1127 mySelLbl[ Vertex1 ]->setText( tr( "VERTEX" ) );
1129 mySelLbl[ Ids ]->setText( tr( "MESH_FACES" ) );
1136 mySelLbl [ Vertex2 ]->show();
1137 mySelBtn [ Vertex2 ]->show();
1138 mySelEdit[ Vertex2 ]->show();
1139 myReverseChk->hide();
1140 myPicture2d->hide();
1141 myPicture3d->show();
1142 mySelLbl[ Object ]->setText( tr( "3D_BLOCK" ) );
1143 mySelLbl[ Vertex1 ]->setText( tr( "VERTEX1" ) );
1144 mySelLbl[ Vertex2 ]->setText( tr( "VERTEX2" ) );
1146 mySelLbl[ Ids ]->setText( tr( "MESH_VOLUMES" ) );
1152 activateSelection();
1157 //=======================================================================
1158 // name : SMESHGUI_MeshPatternDlg::getGrid
1159 // Purpose : Get unstructured grid for pattern
1160 //=======================================================================
1161 vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid()
1165 // Get points from pattern
1166 SMESH::point_array_var pnts;
1167 QValueList<int> ids;
1168 if ( isRefine() && getIds( ids ) ) {
1169 SMESH::long_array_var varIds = new SMESH::long_array();
1170 varIds->length( ids.count() );
1172 for ( QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it )
1174 pnts = myType == Type_2d
1175 ? myPattern->ApplyToMeshFaces ( myMesh, varIds, getNode( false ), myReverseChk->isChecked() )
1176 : myPattern->ApplyToHexahedrons( myMesh, varIds, getNode( false ), getNode( true ) );
1179 pnts = myType == Type_2d
1180 ? myPattern->ApplyToFace ( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() )
1181 : myPattern->ApplyTo3DBlock( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] );
1184 SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(true);
1186 if ( pnts->length() == 0 || elemPoints->length() == 0 )
1191 // to do : to be removed /////////////////////////////////////////////
1194 for ( int i1 = 0, n1 = pnts->length(); i1 < n1; i1++ )
1195 printf( "%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z );
1197 printf( "\nELEMENTS : \n" );
1198 for ( int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++ )
1201 printf( "%d: ", i2 );
1202 for ( int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++ )
1203 printf( "%d ", elemPoints[ i2 ][ i3 ] );
1209 //////////////////////////////////////////////////////////////////////
1211 // Calculate number of points used for cell
1212 vtkIdType aNbCells = elemPoints->length();
1213 vtkIdType aCellsSize = 0;
1214 for ( int i = 0, n = elemPoints->length(); i < n; i++ )
1215 aCellsSize += elemPoints[ i ].length();
1217 // Create unstructured grid and other usefull arrays
1218 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
1220 vtkCellArray* aConnectivity = vtkCellArray::New();
1221 aConnectivity->Allocate( aCellsSize, 0 );
1223 vtkPoints* aPoints = vtkPoints::New();
1224 aPoints->SetNumberOfPoints( pnts->length() );
1226 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1227 aCellTypesArray->SetNumberOfComponents( 1 );
1228 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
1230 vtkIdList *anIdList = vtkIdList::New();
1232 // Fill array of points
1233 for ( int p = 0, nbPnt = pnts->length(); p < nbPnt; p++ )
1234 aPoints->SetPoint( p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z );
1236 for ( int e = 0, nbElem = elemPoints->length(); e < nbElem; e++ )
1238 int nbPoints = elemPoints[ e ].length();
1239 anIdList->SetNumberOfIds( nbPoints );
1240 for ( int i = 0; i < nbPoints; i++ )
1241 anIdList->SetId( i, elemPoints[ e ][ i ] );
1243 aConnectivity->InsertNextCell( anIdList );
1245 if ( nbPoints == 3 ) aCellTypesArray->InsertNextValue( VTK_TRIANGLE );
1246 else if ( nbPoints == 5 ) aCellTypesArray->InsertNextValue( VTK_PYRAMID );
1247 else if ( nbPoints == 6 ) aCellTypesArray->InsertNextValue( VTK_WEDGE );
1248 else if ( nbPoints == 8 ) aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON );
1249 else if ( nbPoints == 4 && myType == Type_2d ) aCellTypesArray->InsertNextValue( VTK_QUAD );
1250 else if ( nbPoints == 4 && myType == Type_3d ) aCellTypesArray->InsertNextValue( VTK_TETRA );
1251 else aCellTypesArray->InsertNextValue( VTK_EMPTY_CELL );
1254 vtkIntArray* aCellLocationsArray = vtkIntArray::New();
1255 aCellLocationsArray->SetNumberOfComponents( 1 );
1256 aCellLocationsArray->SetNumberOfTuples( aNbCells );
1258 aConnectivity->InitTraversal();
1259 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
1260 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
1262 aGrid->SetPoints( aPoints );
1263 aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
1265 aConnectivity->Delete();
1267 aCellTypesArray->Delete();
1269 aCellLocationsArray->Delete();
1279 //=======================================================================
1280 // name : onModeToggled
1282 //=======================================================================
1283 void SMESHGUI_MeshPatternDlg::onModeToggled( bool on )
1285 on ? myRefineGrp->show() : myRefineGrp->hide();
1286 on ? myGeomGrp->hide() : myGeomGrp->show();
1291 //=======================================================================
1294 //=======================================================================
1295 bool SMESHGUI_MeshPatternDlg::isRefine() const
1297 return myRefine->isChecked();
1300 //=======================================================================
1301 //function : onTextChanged
1303 //=======================================================================
1304 void SMESHGUI_MeshPatternDlg::onTextChanged(const QString& theNewText)
1306 if ( myBusy || !isRefine() )
1311 if ( mySelInput != Ids ) {
1313 activateSelection();
1316 // hilight entered elements/nodes
1317 SMDS_Mesh* aMesh = 0;
1318 SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
1320 aMesh = anActor->GetObject()->GetMesh();
1323 mySelection->ClearIObjects();
1324 mySelection->AddIObject( anActor->getIO() );
1326 QStringList aListId = QStringList::split( " ", theNewText, false);
1328 for ( int i = 0; i < aListId.count(); i++ ) {
1329 const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
1330 if ( e && e->GetType() == ( myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume ) ) {
1331 if ( !mySelection->IsIndexSelected( anActor->getIO(), e->GetID() ) )
1332 mySelection->AddOrRemoveIndex( anActor->getIO(), e->GetID(), true );
1340 //=======================================================================
1341 //function : onNodeChanged
1343 //=======================================================================
1344 void SMESHGUI_MeshPatternDlg::onNodeChanged( int value )
1346 if ( myType == Type_3d ) {
1347 QSpinBox* first = (QSpinBox*)sender();
1348 QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
1349 int secondVal = second->value();
1350 if ( secondVal == value ) {
1351 secondVal = value == second->maxValue() ? second->minValue() : value + 1;
1352 bool blocked = second->signalsBlocked();
1353 second->blockSignals( true );
1354 second->setValue( secondVal );
1355 second->blockSignals( blocked );
1362 //=======================================================================
1365 //=======================================================================
1366 bool SMESHGUI_MeshPatternDlg::getIds( QValueList<int>& ids ) const
1369 QStringList strIds = QStringList::split( " ", mySelEdit[Ids]->text() );
1372 for ( QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it ) {
1373 val = (*it).toInt( &isOk );
1381 //=======================================================================
1382 //function : getNode1
1384 //=======================================================================
1385 int SMESHGUI_MeshPatternDlg::getNode( bool second ) const
1387 return second ? myNode2->value() - 1 : myNode1->value() - 1;