Salome HOME
[Bug PAL7863] REGRESSION: Orientations of preview and already created object aren...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_AddMeshElementDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHGUI_AddMeshElementDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESHGUI_AddMeshElementDlg.h"
30
31 #include "SMESHGUI.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESH_ActorUtils.h"
37  
38 #include "VTKViewer_ViewFrame.h"
39 #include "SMDS_Mesh.hxx"
40 #include "SMESH_Actor.h"
41
42 #include "QAD_Application.h"
43 #include "QAD_Desktop.h"
44 #include "QAD_MessageBox.h"
45
46 #include "utilities.h"
47
48 #include <vtkCell.h>
49 #include <vtkIdList.h>
50 #include <vtkIntArray.h>
51 #include <vtkCellArray.h>
52 #include <vtkUnsignedCharArray.h>
53 #include <vtkUnstructuredGrid.h>
54 #include <vtkDataSetMapper.h>
55
56 // QT Includes
57 #include <qbuttongroup.h>
58 #include <qgroupbox.h>
59 #include <qlabel.h>
60 #include <qlineedit.h>
61 #include <qpushbutton.h>
62 #include <qradiobutton.h>
63 #include <qlayout.h>
64 #include <qvariant.h>
65 #include <qtooltip.h>
66 #include <qwhatsthis.h>
67 #include <qimage.h>
68 #include <qpixmap.h>
69 #include <qcheckbox.h>
70 #include <qregexp.h>
71
72 #include <list>
73 #include <TColStd_IndexedMapOfInteger.hxx>
74
75 using namespace std;
76
77 namespace SMESH{
78
79   class TElementSimulation{
80     QAD_Study* myStudy;
81     QAD_StudyFrame* myStudyFrame;
82     VTKViewer_ViewFrame* myViewFrame;
83
84     SALOME_Actor *myPreviewActor;
85     vtkDataSetMapper* myMapper;
86     vtkUnstructuredGrid* myGrid;
87
88   public:
89
90     TElementSimulation(QAD_Study* theStudy):
91       myStudy(theStudy),
92       myStudyFrame(theStudy->getActiveStudyFrame()),
93       myViewFrame(GetVtkViewFrame(theStudy->getActiveStudyFrame()))
94     {
95       myGrid = vtkUnstructuredGrid::New();
96   
97       // Create and display actor
98       myMapper = vtkDataSetMapper::New();
99       myMapper->SetInput( myGrid );
100
101       myPreviewActor = SALOME_Actor::New();
102       myPreviewActor->PickableOff();
103       myPreviewActor->VisibilityOff();
104       myPreviewActor->SetMapper( myMapper );
105
106       vtkProperty* aProp = vtkProperty::New();
107       float anRGB[3];
108       anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
109       anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
110       anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
111       aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
112       myPreviewActor->SetProperty( aProp );
113       aProp->Delete();
114
115       vtkProperty* aBackProp = vtkProperty::New();
116       anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
117       anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
118       anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
119       aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
120       myPreviewActor->SetBackfaceProperty( aBackProp );
121       aBackProp->Delete();
122
123       myViewFrame->AddActor( myPreviewActor );
124
125     }
126
127
128     typedef std::vector<vtkIdType> TVTKIds;
129     void SetPosition(SMESH_Actor* theActor, 
130                      vtkIdType theType, 
131                      const TVTKIds& theIds)
132     {
133       vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
134       myGrid->SetPoints(aGrid->GetPoints());
135
136       const int* aConn = NULL;
137       switch(theType){
138       case VTK_TETRA:{
139         static int anIds[] = {0,2,1,3};
140         aConn = anIds;
141         break;
142       }
143       case VTK_PYRAMID:{
144         static int anIds[] = {0,3,2,1,4};
145         aConn = anIds;
146         break;
147       }
148       case VTK_HEXAHEDRON:{
149         static int anIds[] = {0,3,2,1,4,7,6,5};
150         aConn = anIds;
151         break;
152       }}
153
154       myGrid->Reset();
155       vtkIdList *anIds = vtkIdList::New();
156
157       if(aConn)
158         for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
159           anIds->InsertId(i,theIds[aConn[i]]);
160       else
161         for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
162           anIds->InsertId(i,theIds[i]);
163
164       myGrid->InsertNextCell(theType,anIds);
165       anIds->Delete();
166
167       myGrid->Modified();
168
169       SetVisibility(true);
170     }
171
172
173     void SetVisibility(bool theVisibility){
174       myPreviewActor->SetVisibility(theVisibility);
175       RepaintCurrentView();
176     }
177
178
179     ~TElementSimulation(){
180       if(FindVtkViewFrame(myStudy,myStudyFrame)){
181         myViewFrame->RemoveActor(myPreviewActor);
182       }
183       myPreviewActor->Delete();
184
185       myMapper->RemoveAllInputs();
186       myMapper->Delete();
187
188       myGrid->Delete();
189     }
190
191   };
192
193 }
194
195 //=================================================================================
196 // class    : SMESHGUI_AddMeshElementDlg()
197 // purpose  : 
198 //=================================================================================
199 SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const char* name,
200                                                        SALOME_Selection* Sel, 
201                                                        SMDSAbs_ElementType ElementType, int nbNodes,
202                                                        bool modal, WFlags fl )
203     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu |
204                Qt::WDestructiveClose)
205 {
206   mySimulation = new SMESH::TElementSimulation(SMESH::GetActiveStudy());
207
208   // verify nb nodes and type
209   myNbNodes = nbNodes;
210   myElementType = ElementType;
211   switch ( ElementType ) {
212   case SMDSAbs_Face:
213     if ( myNbNodes != 3 && myNbNodes != 4 )
214       myNbNodes = 3;
215     break;
216   case SMDSAbs_Volume:
217     if ( myNbNodes != 4 && myNbNodes != 8 ) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
218       myNbNodes = 4;
219     break;
220   default:
221     myElementType = SMDSAbs_Edge;
222     myNbNodes = 2;
223   }
224
225   QString elemName;
226   switch ( myNbNodes ) {
227   case 2: elemName = "EDGE"; break;
228   case 3: elemName = "TRIANGLE"; break;
229   case 4: elemName =
230     myElementType == SMDSAbs_Face ? elemName = "QUADRANGLE" : elemName = "TETRAS"; break;
231 //   case 5:
232 //   case 6:
233   default: // 8
234     elemName = "HEXAS";
235   }
236   QString iconName      = tr( QString("ICON_DLG_%1").arg(elemName) );
237   QString buttonGrTitle = tr( QString("SMESH_%1").arg(elemName) );
238   QString caption       = tr( QString("SMESH_ADD_%1_TITLE").arg(elemName) );
239   QString grBoxTitle    = tr( QString("SMESH_ADD_%1").arg(elemName) );
240     
241   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", iconName ));
242   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr("ICON_SELECT")));
243
244   if ( !name )
245     setName( "SMESHGUI_AddMeshElementDlg" );
246   resize( 303, 185 ); 
247   setCaption( caption );
248
249   setSizeGripEnabled( TRUE );
250   SMESHGUI_AddMeshElementDlgLayout = new QGridLayout( this ); 
251   SMESHGUI_AddMeshElementDlgLayout->setSpacing( 6 );
252   SMESHGUI_AddMeshElementDlgLayout->setMargin( 11 );
253
254   /***************************************************************/
255   GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
256   GroupConstructors->setTitle( buttonGrTitle );
257   
258   GroupConstructors->setExclusive( TRUE );
259   GroupConstructors->setColumnLayout(0, Qt::Vertical );
260   GroupConstructors->layout()->setSpacing( 0 );
261   GroupConstructors->layout()->setMargin( 0 );
262   GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
263   GroupConstructorsLayout->setAlignment( Qt::AlignTop );
264   GroupConstructorsLayout->setSpacing( 6 );
265   GroupConstructorsLayout->setMargin( 11 );
266   Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
267   Constructor1->setText( tr( ""  ) );
268   Constructor1->setPixmap( image0 );
269   Constructor1->setChecked( TRUE );
270   Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
271   Constructor1->setMinimumSize( QSize( 50, 0 ) );
272   GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
273   QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
274   GroupConstructorsLayout->addItem( spacer, 0, 1 );
275   SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupConstructors, 0, 0 );
276     
277   /***************************************************************/
278   GroupButtons = new QGroupBox( this, "GroupButtons" );
279   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
280   GroupButtons->setTitle( tr( ""  ) );
281   GroupButtons->setColumnLayout(0, Qt::Vertical );
282   GroupButtons->layout()->setSpacing( 0 );
283   GroupButtons->layout()->setMargin( 0 );
284   GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
285   GroupButtonsLayout->setAlignment( Qt::AlignTop );
286   GroupButtonsLayout->setSpacing( 6 );
287   GroupButtonsLayout->setMargin( 11 );
288   buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
289   buttonCancel->setText( tr( "SMESH_BUT_CLOSE"  ) );
290   buttonCancel->setAutoDefault( TRUE );
291   GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
292   buttonApply = new QPushButton( GroupButtons, "buttonApply" );
293   buttonApply->setText( tr( "SMESH_BUT_APPLY"  ) );
294   buttonApply->setAutoDefault( TRUE );
295   GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
296   QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
297   GroupButtonsLayout->addItem( spacer_9, 0, 2 );
298   buttonOk = new QPushButton( GroupButtons, "buttonOk" );
299   buttonOk->setText( tr( "SMESH_BUT_OK"  ) );
300   buttonOk->setAutoDefault( TRUE );
301   buttonOk->setDefault( TRUE );
302   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
303   SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupButtons, 2, 0 );
304
305   /***************************************************************/
306   GroupC1 = new QGroupBox( this, "GroupC1" );
307   GroupC1->setTitle( grBoxTitle );
308
309   GroupC1->setMinimumSize( QSize( 0, 0 ) );
310   GroupC1->setFrameShape( QGroupBox::Box );
311   GroupC1->setFrameShadow( QGroupBox::Sunken );
312   GroupC1->setColumnLayout(0, Qt::Vertical );
313   GroupC1->layout()->setSpacing( 0 );
314   GroupC1->layout()->setMargin( 0 );
315   GroupC1Layout = new QGridLayout( GroupC1->layout() );
316   GroupC1Layout->setAlignment( Qt::AlignTop );
317   GroupC1Layout->setSpacing( 6 );
318   GroupC1Layout->setMargin( 11 );
319   TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
320   TextLabelC1A1->setText( tr( "SMESH_ID_NODES"  ) );
321   TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
322   TextLabelC1A1->setFrameShape( QLabel::NoFrame );
323   TextLabelC1A1->setFrameShadow( QLabel::Plain );
324   GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
325   SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
326   SelectButtonC1A1->setText( tr( ""  ) );
327   SelectButtonC1A1->setPixmap( image1 );
328   SelectButtonC1A1->setToggleButton( FALSE );
329   GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
330   LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
331 //  LineEditC1A1->setReadOnly( TRUE );
332   LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator", myNbNodes ));
333   GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
334
335   if ( myElementType == SMDSAbs_Face ) {
336     Reverse = new QCheckBox( GroupC1, "Reverse" );
337     Reverse->setText( tr( "SMESH_REVERSE"  ) );
338     GroupC1Layout->addWidget( Reverse, 1, 0 );
339   }
340   else
341     Reverse = 0;
342
343   SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupC1, 1, 0 );
344
345   Init(Sel) ; /* Initialisations */
346 }
347
348 //=================================================================================
349 // function : ~SMESHGUI_AddMeshElementDlg()
350 // purpose  : Destroys the object and frees any allocated resources
351 //=================================================================================
352 SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg()
353 {
354     // no need to delete child widgets, Qt does it all for us
355   delete mySimulation;
356 }
357
358
359 //=================================================================================
360 // function : Init()
361 // purpose  :
362 //=================================================================================
363 void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel )
364 {
365
366   GroupC1->show();
367   Constructor1->setChecked( TRUE );
368   myEditCurrentArgument = LineEditC1A1 ;        
369   mySelection = Sel;  
370   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
371   mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
372
373   myOkNodes = false ;
374   myActor = 0;
375
376   /* signals and slots connections */
377   connect(buttonOk, SIGNAL( clicked() ),     SLOT( ClickOnOk() ) );
378   connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ;
379   connect(buttonApply, SIGNAL( clicked() ),  SLOT(ClickOnApply() ) );
380
381   connect(SelectButtonC1A1, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ;
382   connect(LineEditC1A1, SIGNAL( textChanged(const QString&) ), SLOT(onTextChange(const QString&)));
383   connect(mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog()));
384   connect(mySelection, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() ) );
385   /* to close dialog if study frame change */
386   connect( mySMESHGUI, SIGNAL ( SignalStudyFrameChanged() ), SLOT( ClickOnCancel() ) ) ;
387
388   if ( Reverse )
389     connect( Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) );
390
391   /* Move widget on the botton right corner of main widget */
392   int x, y ;
393   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
394   this->move( x, y ) ;
395   this->show() ; /* displays Dialog */
396
397   // set selection mode
398   SMESH::SetPointRepresentation(true);
399   QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
400
401   SelectionIntoArgument();
402
403   myBusy = false;
404 }
405
406 //=================================================================================
407 // function : ClickOnApply()
408 // purpose  :
409 //=================================================================================
410 void SMESHGUI_AddMeshElementDlg::ClickOnApply()
411 {
412   if ( myOkNodes && !mySMESHGUI->ActiveStudyLocked() ) {
413
414     myBusy = true;
415     SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
416     anArrayOfIdeces->length( myNbNodes );
417     bool reverse = ( Reverse && Reverse->isChecked() );
418     QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false);
419     for ( int i = 0; i < aListId.count(); i++ )
420       if ( reverse )
421         anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt();
422       else
423         anArrayOfIdeces[i] = aListId[ i ].toInt();
424
425     SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
426     switch ( myElementType ) {
427     case SMDSAbs_Edge:
428       aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
429     case SMDSAbs_Face:
430       aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
431     case SMDSAbs_Volume:
432       aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
433     default:;
434     }
435     
436     mySelection->ClearIObjects();
437     mySelection->AddIObject( myActor->getIO(), false );
438
439     SMESH::UpdateView();
440     mySimulation->SetVisibility(false);
441
442     buttonOk->setEnabled( false );
443     buttonApply->setEnabled( false );
444
445     myEditCurrentArgument->setText("");
446
447     myBusy = false;
448   }
449 }
450
451 //=================================================================================
452 // function : ClickOnOk()
453 // purpose  :
454 //=================================================================================
455 void SMESHGUI_AddMeshElementDlg::ClickOnOk()
456 {
457   this->ClickOnApply() ;
458   this->ClickOnCancel() ;
459   return ;
460 }
461
462 //=================================================================================
463 // function : ClickOnCancel()
464 // purpose  :
465 //=================================================================================
466 void SMESHGUI_AddMeshElementDlg::ClickOnCancel()
467 {
468   mySelection->ClearIObjects();
469   mySimulation->SetVisibility(false);
470   SMESH::SetPointRepresentation(false);
471   QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
472   disconnect( mySelection, 0, this, 0 );
473   mySMESHGUI->ResetState() ;
474   reject() ;
475   return ;
476 }
477
478 //=======================================================================
479 //function : onTextChange
480 //purpose  : 
481 //=======================================================================
482
483 void SMESHGUI_AddMeshElementDlg::onTextChange(const QString& theNewText)
484 {
485   if ( myBusy ) return;
486   myBusy = true;
487
488   myOkNodes = false;
489
490   buttonOk->setEnabled( false );
491   buttonApply->setEnabled( false );
492
493   mySimulation->SetVisibility(false);
494
495   // hilight entered nodes
496   SMDS_Mesh* aMesh = 0;
497   if ( myActor )
498     aMesh = myActor->GetObject()->GetMesh();
499   if ( aMesh ) {
500
501     mySelection->ClearIObjects();
502     mySelection->AddIObject( myActor->getIO() );
503
504     QStringList aListId = QStringList::split( " ", theNewText, false);
505     bool allOk = true;
506     for ( int i = 0; i < aListId.count(); i++ ) {
507       const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() );
508       if ( n ) {
509         if ( mySelection->IsIndexSelected( myActor->getIO(), n->GetID() ))
510           allOk = false;
511         else
512           mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true);
513       }
514       else
515         allOk = false;
516     }
517     myOkNodes = (allOk && myNbNodes == aListId.count() );
518
519     if ( myOkNodes ) {
520       buttonOk->setEnabled( true );
521       buttonApply->setEnabled( true );
522       displaySimulation();
523     }
524   }
525
526   myBusy = false;
527 }
528
529 //=================================================================================
530 // function : SelectionIntoArgument()
531 // purpose  : Called when selection has changed
532 //=================================================================================
533 void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
534 {
535   if ( myBusy ) return;
536
537   // clear
538
539   myOkNodes = false;
540   myActor = 0;
541
542   myBusy = true;
543   myEditCurrentArgument->setText( "" );
544   myBusy = false;
545
546   if ( !GroupButtons->isEnabled() ) // inactive
547     return;
548
549   buttonOk->setEnabled( false );
550   buttonApply->setEnabled( false );
551
552   mySimulation->SetVisibility(false);
553 //  SMESH::SetPointRepresentation(true);
554
555   // get selected mesh
556
557   int nbSel = mySelection->IObjectCount();
558   if(nbSel != 1)
559     return;
560
561   myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() );
562   if ( myMesh->_is_nil() )
563     return;
564
565   myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
566   if ( !myActor )
567     return;
568
569   // get selected nodes
570
571   QString aString = "";
572   int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ;
573   myBusy = true;
574   myEditCurrentArgument->setText( aString );
575   myBusy = false;
576   if ( myNbNodes != nbNodes )
577     return;
578
579   // OK
580
581   myOkNodes = true;
582
583   buttonOk->setEnabled( true );
584   buttonApply->setEnabled( true );
585
586   displaySimulation();
587 }
588
589 //=======================================================================
590 //function : displaySimulation
591 //purpose  : 
592 //=======================================================================
593
594 void SMESHGUI_AddMeshElementDlg::displaySimulation()
595 {
596   if ( myOkNodes && GroupButtons->isEnabled() )
597   {
598     SMESH::TElementSimulation::TVTKIds anIds;
599     QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false);
600     for ( int i = 0; i < aListId.count(); i++ )
601       anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() ));
602
603     if ( Reverse && Reverse->isChecked() )
604       reverse(anIds.begin(),anIds.end());
605
606     vtkIdType aType = 0;
607     switch ( myNbNodes ) {
608     case 2: aType = VTK_LINE; break;
609     case 3: aType = VTK_TRIANGLE; break;
610     case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
611     case 8: aType = VTK_HEXAHEDRON; break;
612     default: return;
613     }
614       
615     mySimulation->SetPosition(myActor,aType,anIds);
616   }
617 }
618
619
620 //=================================================================================
621 // function : SetEditCurrentArgument()
622 // purpose  :
623 //=================================================================================
624 void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument()
625 {
626   QPushButton* send = (QPushButton*)sender();
627   if(send == SelectButtonC1A1) {
628     LineEditC1A1->setFocus() ;
629     myEditCurrentArgument = LineEditC1A1;
630   }
631   SelectionIntoArgument() ;
632 }
633
634 //=================================================================================
635 // function : DeactivateActiveDialog()
636 // purpose  :
637 //=================================================================================
638 void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog()
639 {
640   if ( GroupConstructors->isEnabled() ) {  
641     GroupConstructors->setEnabled(false) ;
642     GroupC1->setEnabled(false) ;
643     GroupButtons->setEnabled(false) ;
644     mySimulation->SetVisibility(false);
645     mySMESHGUI->ResetState() ;    
646     mySMESHGUI->SetActiveDialogBox(0) ;
647   }
648   return ;
649 }
650
651
652 //=================================================================================
653 // function : ActivateThisDialog()
654 // purpose  :
655 //=================================================================================
656 void SMESHGUI_AddMeshElementDlg::ActivateThisDialog()
657 {
658   /* Emit a signal to deactivate the active dialog */
659   mySMESHGUI->EmitSignalDeactivateDialog() ;   
660
661   GroupConstructors->setEnabled(true) ;
662   GroupC1->setEnabled(true) ;
663   GroupButtons->setEnabled(true) ;
664
665   SMESH::SetPointRepresentation(true);
666   QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
667
668   SelectionIntoArgument();
669 }
670
671 //=================================================================================
672 // function : enterEvent()
673 // purpose  :
674 //=================================================================================
675 void SMESHGUI_AddMeshElementDlg::enterEvent(QEvent* e)
676 {
677   if ( GroupConstructors->isEnabled() )
678     return ;  
679   ActivateThisDialog() ;
680   return ;
681 }
682
683
684 //=================================================================================
685 // function : closeEvent()
686 // purpose  :
687 //=================================================================================
688 void SMESHGUI_AddMeshElementDlg::closeEvent( QCloseEvent* e )
689 {
690   /* same than click on cancel button */
691   this->ClickOnCancel() ;
692   return ;
693 }
694 //=======================================================================
695 //function : hideEvent
696 //purpose  : caused by ESC key
697 //=======================================================================
698
699 void SMESHGUI_AddMeshElementDlg::hideEvent ( QHideEvent * e )
700 {
701   if ( !isMinimized() )
702     ClickOnCancel() ;
703 }
704
705 //=======================================================================
706 //function : CheckBox
707 //purpose  : 
708 //=======================================================================
709
710 void SMESHGUI_AddMeshElementDlg::CheckBox( int state )
711 {
712   if ( !myOkNodes )
713     return;
714   
715   if ( state >= 0 ) {
716     mySimulation->SetVisibility(false);
717     displaySimulation();
718   }
719 }