Salome HOME
PAL13460 (PAL EDF 301 force the mesh to go through a point)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SMESHGUI.cxx
23 //  Author : Nicolas REJNERI
24 //  Module : SMESH
25 //  $Header$
26
27 #include "SMESHGUI.h"
28
29 #include "SMESH_Client.hxx"
30 #include "SMESHGUI_NodesDlg.h"
31 #include "SMESHGUI_TransparencyDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_GroupDlg.h"
34 #include "SMESHGUI_RemoveNodesDlg.h"
35 #include "SMESHGUI_RemoveElementsDlg.h"
36 #include "SMESHGUI_MeshInfosDlg.h"
37 #include "SMESHGUI_StandardMeshInfosDlg.h"
38 #include "SMESHGUI_Preferences_ColorDlg.h"
39 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
40 #include "SMESHGUI_Preferences_SelectionDlg.h"
41 #include "SMESHGUI_Hypotheses.h"
42 #include "SMESHGUI_MoveNodesDlg.h"
43 #include "SMESHGUI_AddMeshElementDlg.h"
44 #include "SMESHGUI_AddQuadraticElementDlg.h"
45 #include "SMESHGUI_FilterDlg.h"
46 #include "SMESHGUI_FilterLibraryDlg.h"
47 #include "SMESHGUI_SingleEditDlg.h"
48 #include "SMESHGUI_MultiEditDlg.h"
49 #include "SMESHGUI_GroupOpDlg.h"
50 #include "SMESHGUI_DeleteGroupDlg.h"
51 #include "SMESHGUI_SmoothingDlg.h"
52 #include "SMESHGUI_RenumberingDlg.h"
53 #include "SMESHGUI_ExtrusionDlg.h"
54 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
55 #include "SMESHGUI_RevolutionDlg.h"
56 #include "SMESHGUI_TranslationDlg.h"
57 #include "SMESHGUI_RotationDlg.h"
58 #include "SMESHGUI_SymmetryDlg.h"
59 #include "SMESHGUI_SewingDlg.h"
60 #include "SMESHGUI_MergeNodesDlg.h"
61 #include "SMESHGUI_EditMeshDlg.h"
62 #include "SMESHGUI_MeshPatternDlg.h"
63 #include "SMESHGUI_Selection.h"
64 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
65 #include "SMESHGUI_ConvToQuadOp.h"
66 #include "SMESHGUI_MeshOp.h"
67 #include "SMESHGUI_Displayer.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69
70 #include "SMESHGUI_Utils.h"
71 #include "SMESHGUI_GEOMGenUtils.h"
72 #include "SMESHGUI_MeshUtils.h"
73 #include "SMESHGUI_GroupUtils.h"
74 #include "SMESHGUI_FilterUtils.h"
75 #include "SMESHGUI_PatternUtils.h"
76 #include "SMESHGUI_VTKUtils.h"
77 #include "SMESHGUI_HypothesesUtils.h"
78
79 #include "SMESH_Actor.h"
80 #include "SMESH_Object.h"
81 #include "SMESH_TypeFilter.hxx"
82
83 #include "SalomeApp_Tools.h"
84 #include "SalomeApp_Study.h"
85 #include "SalomeApp_Application.h"
86 #include "SalomeApp_CheckFileDlg.h"
87 #include "SalomeApp_ImportOperation.h"
88
89 #include "LightApp_DataOwner.h"
90 #include "LightApp_Preferences.h"
91 #include "LightApp_VTKSelector.h"
92 #include "LightApp_Operation.h"
93 #include "LightApp_UpdateFlags.h"
94 #include "LightApp_NameDlg.h"
95
96 #include <SVTK_ViewWindow.h>
97 #include <SVTK_ViewModel.h>
98 #include <SVTK_InteractorStyle.h>
99 #include <SVTK_RenderWindowInteractor.h>
100 #include <SVTK_ViewManager.h>
101
102 #include "OB_Browser.h"
103
104 #include "SUIT_Tools.h"
105 #include "SUIT_MessageBox.h"
106 #include "SUIT_ResourceMgr.h"
107 #include "SUIT_FileDlg.h"
108 #include "SUIT_Desktop.h"
109 #include "SUIT_OverrideCursor.h"
110 #include "SUIT_Study.h"
111 #include "SUIT_Session.h"
112
113 #include "QtxPopupMgr.h"
114
115 #include "SALOME_ListIO.hxx"
116 #include "SALOME_ListIteratorOfListIO.hxx"
117 #include "SALOME_InteractiveObject.hxx"
118 #include "SALOME_NamingService.hxx"
119 #include "SALOME_LifeCycleCORBA.hxx"
120
121 #include "SALOMEconfig.h"
122 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
123 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
124
125 // QT Includes
126 #define  INCLUDE_MENUITEM_DEF
127 #include <qpopupmenu.h>
128 #include <qstring.h>
129 #include <qwidget.h>
130 #include <qaction.h>
131
132 // BOOST Includes
133 #include <boost/shared_ptr.hpp>
134
135 // VTK Includes
136 #include <vtkRenderer.h>
137 #include <vtkRenderWindow.h>
138 #include <vtkActorCollection.h>
139 #include <vtkScalarBarActor.h>
140 #include <vtkUnstructuredGrid.h>
141
142 #include "utilities.h"
143
144 #include "SALOMEDS_Study.hxx"
145 #include "SALOMEDSClient_StudyBuilder.hxx"
146 #include "SALOMEDSClient_SComponent.hxx"
147
148 using namespace std;
149
150 //namespace{
151   // Declarations
152   //=============================================================
153   void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
154                             int theCommandID);
155
156   void ExportMeshToFile(int theCommandID);
157
158   void SetDisplayMode(int theCommandID);
159
160   void SetDisplayEntity(int theCommandID);
161
162   void Control( int theCommandID );
163
164
165   // Definitions
166   //=============================================================
167   void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
168                             int theCommandID)
169   {
170     QStringList filter;
171     string myExtension;
172
173     if(theCommandID == 113){
174       filter.append(QObject::tr("MED files (*.med)"));
175       filter.append(QObject::tr("All files (*)"));
176     }else if (theCommandID == 112){
177       filter.append(QObject::tr("IDEAS files (*.unv)"));
178     }else if (theCommandID == 111){
179       filter.append(QObject::tr("DAT files (*.dat)"));
180     }
181     QString filename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
182                                                 "",
183                                                 filter,
184                                                 QObject::tr("Import mesh"),
185                                                 true);
186     if(!filename.isEmpty()) {
187       SUIT_OverrideCursor wc;
188       _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
189
190       try {
191         SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
192         switch ( theCommandID ) {
193         case 112:
194           {
195             aMeshes->length( 1 );
196             aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
197             break;
198           }
199         case 113:
200           {
201             SMESH::DriverMED_ReadStatus res;
202             aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
203             if ( res != SMESH::DRS_OK ) {
204               wc.suspend();
205               SUIT_MessageBox::warn1(SMESHGUI::desktop(),
206                                     QObject::tr("SMESH_WRN_WARNING"),
207                                     QObject::tr(QString("SMESH_DRS_%1").arg(res)),
208                                     QObject::tr("SMESH_BUT_OK"));
209               aMeshes->length( 0 );
210               wc.resume();
211             }
212             break;
213           }
214         }
215
216         bool isEmpty = false;
217         for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
218           _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
219           if ( aMeshSO ) {
220             _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
221             _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
222             aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
223             if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
224               SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
225           } else
226             isEmpty = true;
227         }
228
229         if ( isEmpty ) {
230           wc.suspend();
231           SUIT_MessageBox::warn1(SMESHGUI::desktop(),
232                                 QObject::tr("SMESH_WRN_WARNING"),
233                                 QObject::tr("SMESH_DRS_EMPTY"),
234                                 QObject::tr("SMESH_BUT_OK"));
235           wc.resume();
236         }
237
238         SMESHGUI::GetSMESHGUI()->updateObjBrowser();
239       }
240       catch (const SALOME::SALOME_Exception& S_ex){
241         wc.suspend();
242         SalomeApp_Tools::QtCatchCorbaException(S_ex);
243         wc.resume();
244       }
245     }
246   }
247
248
249   void ExportMeshToFile( int theCommandID )
250   {
251     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
252     SALOME_ListIO selected;
253     if( aSel )
254       aSel->selectedObjects( selected );
255
256     if(selected.Extent()){
257       Handle(SALOME_InteractiveObject) anIObject = selected.First();
258       SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
259       if ( !aMesh->_is_nil() ) {
260         QString aFilter, aTitle = QObject::tr("Export mesh");
261         QMap<QString, SMESH::MED_VERSION> aFilterMap;
262         switch ( theCommandID ) {
263         case 125:
264         case 122:
265           {
266             if (aMesh->HasDuplicatedGroupNamesMED()) {
267               int aRet = SUIT_MessageBox::warn2
268                 (SMESHGUI::desktop(),
269                  QObject::tr("SMESH_WRN_WARNING"),
270                  QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg(anIObject->getName()),
271                  QObject::tr("SMESH_BUT_YES"),  QObject::tr("SMESH_BUT_NO"),
272                  0, 1, 0);
273               if (aRet)
274                 return;
275             }
276
277             aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
278             aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
279           }
280           break;
281         case 124:
282         case 121:
283           aFilter = QObject::tr("DAT files (*.dat)");
284           break;
285         case 126:
286         case 123:
287           {
288             if (aMesh->NbPyramids()) {
289               int aRet = SUIT_MessageBox::warn2
290                 (SMESHGUI::desktop(),
291                  QObject::tr("SMESH_WRN_WARNING"),
292                  QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
293                  QObject::tr("SMESH_BUT_YES"),  QObject::tr("SMESH_BUT_NO"),
294                  0, 1, 0);
295               if (aRet)
296                 return;
297             }
298             aFilter = QObject::tr("IDEAS files (*.unv)");
299           }
300           break;
301         default:
302           return;
303         }
304
305         QString aFilename;
306         SMESH::MED_VERSION aFormat;
307         // Init the parameter with the default value
308         bool toCreateGroups = false;
309         SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
310         if ( resMgr )
311           toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
312
313         if ( theCommandID != 122 && theCommandID != 125 )
314           aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
315         else {
316           QStringList filters;
317           QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
318           for ( ; it != aFilterMap.end(); ++it )
319             filters.push_back( it.key() );
320
321           //SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
322           SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
323             ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS") ,true, true );
324           fd->setCaption( aTitle );
325           fd->setFilters( filters );
326           fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
327           fd->SetChecked(toCreateGroups);
328           bool is_ok = false;
329           while (!is_ok) {
330             fd->exec();
331             aFilename = fd->selectedFile();
332             aFormat = aFilterMap[fd->selectedFilter()];
333             is_ok = true;
334             if ( !aFilename.isEmpty()
335                  && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0)
336                  && aFormat==SMESH::MED_V2_1) {
337               int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(),
338                                                 QObject::tr("SMESH_WRN_WARNING"),
339                                                 QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()),
340                                                 QObject::tr("SMESH_BUT_YES"),
341                                                 QObject::tr("SMESH_BUT_NO"),
342                                                 0,1,0);
343               if (aRet) {
344                 is_ok = false;
345               }
346             }
347           }
348           toCreateGroups = fd->IsChecked();
349           delete fd;
350         }
351         if ( !aFilename.isEmpty() ) {
352           // Check whether the file already exists and delete it if yes
353           QFile aFile( aFilename );
354           if ( aFile.exists() )
355             aFile.remove();
356           SUIT_OverrideCursor wc;
357
358           try {
359             bool Renumber = false ;
360             // PAL 14172  : Check of we have to renumber or not from the preferences before export
361             if (resMgr)
362               Renumber= resMgr->booleanValue("SMESH","renumbering");
363             if (Renumber){
364               SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
365               aMeshEditor->RenumberNodes();
366               aMeshEditor->RenumberElements();
367               if ( SMESHGUI::automaticUpdate() )
368                 SMESH::UpdateView();
369               }
370             switch ( theCommandID ) {
371             case 125:
372             case 122:
373               aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
374               break;
375             case 124:
376             case 121:
377               aMesh->ExportDAT( aFilename.latin1() );
378               break;
379             case 126:
380             case 123:
381               aMesh->ExportUNV( aFilename.latin1() );
382               break;
383             default:
384               break;
385             }
386           }
387           catch (const SALOME::SALOME_Exception& S_ex){
388             wc.suspend();
389             SUIT_MessageBox::warn1(SMESHGUI::desktop(),
390                                     QObject::tr("SMESH_WRN_WARNING"),
391                                     QObject::tr("SMESH_EXPORT_FAILED"),
392                                     QObject::tr("SMESH_BUT_OK"));
393             wc.resume();
394           }
395         }
396       }
397     }
398   }
399
400   inline void InverseEntityMode(unsigned int& theOutputMode,
401                                 unsigned int theMode)
402   {
403     bool anIsNotPresent = ~theOutputMode & theMode;
404     if(anIsNotPresent)
405       theOutputMode |= theMode;
406     else
407       theOutputMode &= ~theMode;
408   }
409
410   void SetDisplayEntity(int theCommandID){
411     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
412     SALOME_ListIO selected;
413     if( aSel )
414       aSel->selectedObjects( selected );
415
416     if(selected.Extent() >= 1){
417       SALOME_ListIteratorOfListIO It( selected );
418       for(; It.More(); It.Next()){
419         Handle(SALOME_InteractiveObject) IObject = It.Value();
420         if(IObject->hasEntry()){
421           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
422             unsigned int aMode = anActor->GetEntityMode();
423             switch(theCommandID){
424             case 217:
425               InverseEntityMode(aMode,SMESH_Actor::eEdges);
426               break;
427             case 218:
428               InverseEntityMode(aMode,SMESH_Actor::eFaces);
429               break;
430             case 219:
431               InverseEntityMode(aMode,SMESH_Actor::eVolumes);
432               break;
433             case 220:
434               aMode = SMESH_Actor::eAllEntity;
435               break;
436             }
437             if(aMode)
438               anActor->SetEntityMode(aMode);
439           }
440         }
441       }
442     }
443   }
444
445   void SetDisplayMode(int theCommandID){
446     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
447     SALOME_ListIO selected;
448     if( aSel )
449       aSel->selectedObjects( selected );
450
451     if(selected.Extent() >= 1){
452       switch(theCommandID){
453       case 1134:{
454         SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
455         new SMESHGUI_ClippingDlg( SMESHGUI::GetSMESHGUI(), "", false );
456         return;
457       }
458       case 1133:{
459         SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
460         new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false );
461         return;
462       }}
463       SALOME_ListIteratorOfListIO It( selected );
464       for(; It.More(); It.Next()){
465         Handle(SALOME_InteractiveObject) IObject = It.Value();
466         if(IObject->hasEntry()){
467           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
468             switch(theCommandID){
469             case 211:
470               anActor->SetRepresentation(SMESH_Actor::eEdge);
471               break;
472             case 212:
473               anActor->SetRepresentation(SMESH_Actor::eSurface);
474               break;
475             case 213:
476               if(anActor->IsShrunk())
477                 anActor->UnShrink();
478               else
479                 anActor->SetShrink();
480               break;
481             case 215:
482               anActor->SetRepresentation(SMESH_Actor::ePoint);
483               break;
484             case 1132:{
485               vtkFloatingPointType color[3];
486               anActor->GetSufaceColor(color[0], color[1], color[2]);
487               int c0 = int (color[0] * 255);
488               int c1 = int (color[1] * 255);
489               int c2 = int (color[2] * 255);
490               QColor c(c0, c1, c2);
491
492               vtkFloatingPointType edgecolor[3];
493               anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
494               c0 = int (edgecolor[0] * 255);
495               c1 = int (edgecolor[1] * 255);
496               c2 = int (edgecolor[2] * 255);
497               QColor e(c0, c1, c2);
498
499               vtkFloatingPointType backfacecolor[3];
500               anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
501               c0 = int (backfacecolor[0] * 255);
502               c1 = int (backfacecolor[1] * 255);
503               c2 = int (backfacecolor[2] * 255);
504               QColor b(c0, c1, c2);
505
506               vtkFloatingPointType nodecolor[3];
507               anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
508               c0 = int (nodecolor[0] * 255);
509               c1 = int (nodecolor[1] * 255);
510               c2 = int (nodecolor[2] * 255);
511               QColor n(c0, c1, c2);
512
513               int Edgewidth = (int)anActor->GetLineWidth();
514               if(Edgewidth == 0)
515                 Edgewidth = 1;
516               int intValue = int(anActor->GetNodeSize());
517               vtkFloatingPointType Shrink = anActor->GetShrinkFactor();
518
519               SMESHGUI_Preferences_ColorDlg *aDlg =
520                 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" );
521               aDlg->SetColor(1, c);
522               aDlg->SetColor(2, e);
523               aDlg->SetColor(3, n);
524               aDlg->SetColor(4, b);
525               aDlg->SetIntValue(1, Edgewidth);
526               aDlg->SetIntValue(2, intValue);
527               aDlg->SetIntValue(3, int(Shrink*100.));
528               if(aDlg->exec()){
529                 QColor color = aDlg->GetColor(1);
530                 QColor edgecolor = aDlg->GetColor(2);
531                 QColor nodecolor = aDlg->GetColor(3);
532                 QColor backfacecolor = aDlg->GetColor(4);
533                 /* actor color and backface color */
534                 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
535                                         vtkFloatingPointType (color.green()) / 255.,
536                                         vtkFloatingPointType (color.blue()) / 255.);
537                 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
538                                             vtkFloatingPointType (backfacecolor.green()) / 255.,
539                                             vtkFloatingPointType (backfacecolor.blue()) / 255.);
540
541                 /* edge color */
542                 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
543                                       vtkFloatingPointType (edgecolor.green()) / 255.,
544                                       vtkFloatingPointType (edgecolor.blue()) / 255.);
545
546                 /* Shrink factor and size edges */
547                 anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
548                 anActor->SetLineWidth(aDlg->GetIntValue(1));
549
550                 /* Nodes color and size */
551                 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
552                                       vtkFloatingPointType (nodecolor.green()) / 255.,
553                                       vtkFloatingPointType (nodecolor.blue()) / 255.);
554                 anActor->SetNodeSize(aDlg->GetIntValue(2));
555
556                 delete aDlg;
557               }
558               break;
559             }}
560           }
561         }
562       }
563       SMESH::RepaintCurrentView();
564     }
565   }
566
567   void Control( int theCommandID )
568   {
569     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
570     SALOME_ListIO selected;
571     if( aSel )
572       aSel->selectedObjects( selected );
573
574     if( !selected.IsEmpty() ){
575       Handle(SALOME_InteractiveObject) anIO = selected.First();
576       if(!anIO.IsNull()){
577         QString aTitle;
578         SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
579         if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
580           switch ( theCommandID ){
581           case 6001:
582             aTitle = QObject::tr( "LENGTH_EDGES" );
583             aControl = SMESH_Actor::eLength;
584             break;
585           case 6018:
586             aTitle = QObject::tr( "LENGTH2D_EDGES" );
587             aControl = SMESH_Actor::eLength2D;
588             break;
589           case 6002:
590             aTitle = QObject::tr( "FREE_EDGES" );
591             aControl = SMESH_Actor::eFreeEdges;
592             break;
593           case 6003:
594             aTitle = QObject::tr( "FREE_BORDERS" );
595             aControl = SMESH_Actor::eFreeBorders;
596             break;
597           case 6004:
598             aTitle = QObject::tr( "MULTI_BORDERS" );
599             aControl = SMESH_Actor::eMultiConnection;
600             break;
601           case 6019:
602             aTitle = QObject::tr( "MULTI2D_BORDERS" );
603             aControl = SMESH_Actor::eMultiConnection2D;
604             break;
605           case 6011:
606             aTitle = QObject::tr( "AREA_ELEMENTS" );
607             aControl = SMESH_Actor::eArea;
608             break;
609           case 6012:
610             aTitle = QObject::tr( "TAPER_ELEMENTS" );
611             aControl = SMESH_Actor::eTaper;
612             break;
613           case 6013:
614             aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
615             aControl = SMESH_Actor::eAspectRatio;
616             break;
617           case 6017:
618             aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
619             aControl = SMESH_Actor::eAspectRatio3D;
620             break;
621           case 6014:
622             aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
623             aControl = SMESH_Actor::eMinimumAngle;
624             break;
625           case 6015:
626             aTitle = QObject::tr( "WARP_ELEMENTS" );
627             aControl = SMESH_Actor::eWarping;
628             break;
629           case 6016:
630             aTitle = QObject::tr( "SKEW_ELEMENTS" );
631             aControl = SMESH_Actor::eSkew;
632             break;
633           case 6009:
634             aTitle = QObject::tr( "SMESH_VOLUME" );
635             aControl = SMESH_Actor::eVolume3D;
636             break;
637           }
638           anActor->SetControlMode(aControl);
639           anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
640           SMESH::RepaintCurrentView();
641         }
642       }
643     }
644   }
645
646
647   bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
648                    MeshObjectType                           theType,
649                    const QString                            theInTypeName,
650                    QString &                                theOutTypeName)
651   {
652     SMESH_TypeFilter aTypeFilter( theType );
653     QString entry;
654     if( !theIO.IsNull() )
655     {
656       entry = theIO->getEntry();
657       LightApp_DataOwner owner( entry );
658       if ( aTypeFilter.isOk( &owner )) {
659         theOutTypeName = theInTypeName;
660         return true;
661       }
662     }
663     return false;
664   }
665
666
667   QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
668   {
669     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
670     _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
671     if (aSObj) {
672       _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
673       CORBA::String_var anID = aSComp->GetID().c_str();
674       if (!strcmp(anID.in(),theIO->getEntry()))
675         return "Component";
676     }
677
678     QString aTypeName;
679     if (
680         CheckOIType ( theIO, HYPOTHESIS,    "Hypothesis", aTypeName ) ||
681         CheckOIType ( theIO, ALGORITHM,     "Algorithm",  aTypeName ) ||
682         CheckOIType ( theIO, MESH,          "Mesh",       aTypeName ) ||
683         CheckOIType ( theIO, SUBMESH,       "SubMesh",    aTypeName ) ||
684         CheckOIType ( theIO, GROUP,         "Group",      aTypeName )
685         )
686       return aTypeName;
687
688     return "NoType";
689   }
690
691
692   QString CheckHomogeneousSelection()
693   {
694     //SUIT_Study* aStudy = SMESH::GetActiveStudy();
695     LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
696     SALOME_ListIO selected;
697     if( aSel )
698       aSel->selectedObjects( selected );
699
700     QString RefType = CheckTypeObject(selected.First());
701     SALOME_ListIteratorOfListIO It(selected);
702     for (; It.More(); It.Next())
703       {
704         Handle(SALOME_InteractiveObject) IObject = It.Value();
705         QString Type = CheckTypeObject(IObject);
706         if (Type.compare(RefType) != 0)
707           return "Heterogeneous Selection";
708       }
709
710     return RefType;
711   }
712
713
714   void SMESHGUI::OnEditDelete()
715   {
716     // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
717     LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
718     SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
719
720     QString aParentComponent = QString::null;
721     for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
722     {
723       QString cur = anIt.Value()->getComponentDataType();
724       if( aParentComponent.isNull() )
725         aParentComponent = cur;
726       else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
727         aParentComponent = "";
728     }
729
730     if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() )  {
731       SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
732                               QObject::tr("ERR_ERROR"),
733                               QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
734                               QObject::tr("BUT_OK") );
735       return;
736     }
737     // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
738     if (SUIT_MessageBox::warn2
739         (SMESHGUI::desktop(),
740          QObject::tr("SMESH_WRN_WARNING"),
741          QObject::tr("SMESH_REALLY_DELETE"),
742          QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
743       return;
744
745     SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
746     SUIT_ViewManager* vm = anApp->activeViewManager();
747     int nbSf = vm->getViewsCount();
748
749     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
750     _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
751     _PTR(GenericAttribute) anAttr;
752     _PTR(AttributeIOR) anIOR;
753
754     SALOME_ListIteratorOfListIO It(selected);
755
756     aStudyBuilder->NewCommand();  // There is a transaction
757     for(; It.More(); It.Next()){ // loop on selected IO's
758       Handle(SALOME_InteractiveObject) IObject = It.Value();
759       if(IObject->hasEntry()) {
760         _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
761
762         // disable removal of "SMESH" component object
763         if(aSO->FindAttribute(anAttr, "AttributeIOR")){
764           anIOR = anAttr;
765           if ( !strcmp( (char*)anIOR->Value().c_str(), engineIOR().latin1() ) )
766             continue;
767         }
768
769         // put the whole hierarchy of sub-objects of the selected SO into a list and
770         // then treat them all starting from the deepest objects (at list back)
771
772         list< _PTR(SObject) > listSO;
773         listSO.push_back( aSO );
774         list< _PTR(SObject) >::iterator itSO = listSO.begin();
775         for ( ; itSO != listSO.end(); ++itSO ) {
776           _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
777           for (it->InitEx(false); it->More(); it->Next())
778             listSO.push_back( it->Value() );
779         }
780
781         // treat SO's in the list starting from the back
782
783         list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
784         for ( ; ritSO != listSO.rend(); ++ritSO ) {
785           _PTR(SObject) SO = *ritSO;
786           if ( !SO ) continue;
787           string anEntry = SO->GetID();
788
789           /** Erase graphical object **/
790           if(SO->FindAttribute(anAttr, "AttributeIOR")){
791             QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
792             for(int i = 0; i < nbSf; i++){
793               SUIT_ViewWindow *sf = aViews[i];
794               if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
795                 SMESH::RemoveActor(sf,anActor);
796               }
797             }
798           }
799
800           /** Remove an object from data structures **/
801           SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
802           SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
803           if ( !aGroup->_is_nil() ) {                          // DELETE GROUP
804             SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
805             aMesh->RemoveGroup( aGroup );
806           }
807           else if ( !aSubMesh->_is_nil() ) {                   // DELETE SUBMESH
808             SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
809             aMesh->RemoveSubMesh( aSubMesh );
810
811             _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
812             if (aMeshSO)
813               SMESH::ModifiedMesh(aMeshSO, false);
814           }
815           else {
816             IObject = new SALOME_InteractiveObject
817               ( anEntry.c_str(), engineIOR().latin1(), SO->GetName().c_str() );
818             QString objType = CheckTypeObject(IObject);
819             if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
820               SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
821               aStudyBuilder->RemoveObjectWithChildren( SO );
822             }
823             else {// default action: remove SObject from the study
824               // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
825               //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
826               //op->start();
827               aStudyBuilder->RemoveObjectWithChildren( SO );
828               //op->finish();
829             }
830           }
831         } /* listSO back loop */
832       } /* IObject->hasEntry() */
833     } /* more/next */
834     aStudyBuilder->CommitCommand();
835
836     /* Clear any previous selection */
837     SALOME_ListIO l1;
838     aSel->setSelectedObjects( l1 );
839
840     SMESHGUI::GetSMESHGUI()->updateObjBrowser();
841   }
842 //}
843
844 extern "C" {
845   Standard_EXPORT CAM_Module* createModule()
846   {
847     return new SMESHGUI();
848   }
849 }
850
851 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
852
853 //=============================================================================
854 /*!
855  *
856  */
857 //=============================================================================
858 SMESHGUI::SMESHGUI() :
859 SalomeApp_Module( "SMESH" )
860 {
861   if ( CORBA::is_nil( myComponentSMESH ) )
862   {
863     CORBA::Boolean anIsEmbeddedMode;
864     myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
865   }
866
867   myActiveDialogBox = 0;
868   myFilterLibraryDlg = 0;
869   myState = -1;
870   myDisplayer = 0;
871
872   SMESH::GetFilterManager();
873   SMESH::GetPattern();
874
875   /* load resources for all available meshers */
876   SMESH::InitAvailableHypotheses();
877 }
878
879 //=============================================================================
880 /*!
881  *
882  */
883 //=============================================================================
884 SMESHGUI::~SMESHGUI()
885 {
886   SMESH::GetFilterManager()->Destroy();
887   SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
888 }
889
890 //=============================================================================
891 /*!
892  *
893  */
894 //=============================================================================
895 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
896 {
897   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
898   if( anApp )
899     return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
900   else
901     return 0;
902 }
903
904 bool SMESHGUI::automaticUpdate()
905 {
906   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
907   if ( !resMgr )
908     return false;
909
910   return resMgr->booleanValue( "SMESH", "auto_update", false );
911 }
912
913 //=============================================================================
914 /*!
915  *
916  */
917 //=============================================================================
918 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
919 {
920   return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
921 }
922
923 //=============================================================================
924 /*!
925  *
926  */
927 //=============================================================================
928 SMESHGUI* SMESHGUI::GetSMESHGUI()
929 {
930   SMESHGUI* smeshMod = 0;
931   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
932   if ( app )
933   {
934     CAM_Module* module = app->module( "Mesh" );
935     smeshMod = dynamic_cast<SMESHGUI*>( module );
936   }
937
938   if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
939   {
940     SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
941     if ( study )
942     {
943       _PTR(Study) aStudy = study->studyDS();
944       if ( aStudy )
945         GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
946     }
947   }
948
949   return smeshMod;
950 }
951
952 extern "C"
953 {
954   Standard_EXPORT SMESHGUI* GetComponentGUI()
955   {
956     return SMESHGUI::GetSMESHGUI();
957   }
958 }
959
960 //=============================================================================
961 /*!
962  *
963  */
964 //=============================================================================
965 void SMESHGUI::SetState(int aState)
966 {
967   myState = aState;
968 }
969
970 //=============================================================================
971 /*!
972  *
973  */
974 //=============================================================================
975 void SMESHGUI::ResetState()
976 {
977   myState = -1;
978 }
979
980 //=============================================================================
981 /*!
982  *
983  */
984 //=============================================================================
985 void SMESHGUI::EmitSignalDeactivateDialog()
986 {
987   emit SignalDeactivateActiveDialog();
988 }
989
990 //=============================================================================
991 /*!
992  *
993  */
994 //=============================================================================
995 void SMESHGUI::EmitSignalStudyFrameChanged()
996 {
997   emit SignalStudyFrameChanged();
998 }
999
1000 //=============================================================================
1001 /*!
1002  *
1003  */
1004 //=============================================================================
1005 void SMESHGUI::EmitSignalCloseAllDialogs()
1006 {
1007   emit SignalCloseAllDialogs();
1008 }
1009
1010 //=============================================================================
1011 /*!
1012  *
1013  */
1014 //=============================================================================
1015 QDialog *SMESHGUI::GetActiveDialogBox()
1016 {
1017   return myActiveDialogBox;
1018 }
1019
1020 //=============================================================================
1021 /*!
1022  *
1023  */
1024 //=============================================================================
1025 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1026 {
1027   myActiveDialogBox = (QDialog *) aDlg;
1028   return;
1029 }
1030
1031 //=============================================================================
1032 /*!
1033  *
1034  */
1035 //=============================================================================
1036 SUIT_Desktop* SMESHGUI::desktop()
1037 {
1038   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1039   if( app )
1040     return app->desktop();
1041   else
1042     return 0;
1043 }
1044
1045 //=============================================================================
1046 /*!
1047  *
1048  */
1049 //=============================================================================
1050 SalomeApp_Study* SMESHGUI::activeStudy()
1051 {
1052   SUIT_Application* app = SUIT_Session::session()->activeApplication();
1053   if( app )
1054     return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1055   else
1056     return NULL;
1057 }
1058
1059 //=============================================================================
1060 /*!
1061  *
1062  */
1063 //=============================================================================
1064 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1065 {
1066   /* Here the position is on the bottom right corner - 10 */
1067   // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1068   aDlg->adjustSize();
1069   SUIT_Desktop *PP = desktop();
1070   x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1071   y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1072   return true;
1073 }
1074
1075 //=============================================================================
1076 /*!
1077  *
1078  */
1079 //=============================================================================
1080 static int isStudyLocked(_PTR(Study) theStudy){
1081   return theStudy->GetProperties()->IsLocked();
1082 }
1083
1084 static bool checkLock(_PTR(Study) theStudy) {
1085   if (isStudyLocked(theStudy)) {
1086     SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
1087                            QObject::tr("WRN_WARNING"),
1088                            QObject::tr("WRN_STUDY_LOCKED"),
1089                            QObject::tr("BUT_OK") );
1090     return true;
1091   }
1092   return false;
1093 }
1094
1095 //=======================================================================
1096 //function : CheckActiveStudyLocked
1097 //purpose  :
1098 //=======================================================================
1099
1100 bool SMESHGUI::isActiveStudyLocked()
1101 {
1102   _PTR(Study) aStudy = activeStudy()->studyDS();
1103   return checkLock( aStudy );
1104 }
1105
1106 //=============================================================================
1107 /*!
1108  *
1109  */
1110 //=============================================================================
1111 bool SMESHGUI::OnGUIEvent( int theCommandID )
1112 {
1113   SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1114   if( !anApp )
1115     return false;
1116
1117   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1118   SUIT_ResourceMgr* mgr = resourceMgr();
1119   if( !mgr )
1120     return false;
1121
1122   if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1123     GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1124   }
1125
1126   SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1127   SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1128
1129   //QAction* act = action( theCommandID );
1130
1131   switch (theCommandID) {
1132   case 33:                                      // DELETE
1133     if(checkLock(aStudy)) break;
1134     OnEditDelete();
1135     break;
1136
1137   case 113:                                     // IMPORT
1138   case 112:
1139   case 111:
1140     {
1141       if(checkLock(aStudy)) break;
1142       ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1143       break;
1144     }
1145
1146   case 122:                                     // EXPORT MED
1147   case 121:
1148   case 123:
1149   case 124:
1150   case 125:
1151   case 126:
1152     {
1153       ::ExportMeshToFile(theCommandID);
1154       break;
1155     }
1156
1157   case 200:                                     // SCALAR BAR
1158     {
1159       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1160       SALOME_ListIO selected;
1161       if( aSel )
1162         aSel->selectedObjects( selected );
1163
1164       if( selected.Extent() ) {
1165         Handle(SALOME_InteractiveObject) anIO = selected.First();
1166         if( anIO->hasEntry() ) {
1167           if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1168             anActor->SetControlMode( SMESH_Actor::eNone );
1169           }
1170         }
1171       }
1172       break;
1173     }
1174   case 201:
1175     {
1176       SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
1177       break;
1178     }
1179
1180   case 1134: // Clipping
1181   case 1133: // Tranparency
1182   case 1132: // Colors / Size
1183
1184     // Display Mode
1185   case 215: // Nodes
1186   case 213: // Nodes
1187   case 212: // Nodes
1188   case 211: // Nodes
1189     ::SetDisplayMode(theCommandID);
1190   break;
1191
1192     // Display Entity
1193   case 217: // Edges
1194   case 218: // Faces
1195   case 219: // Volumes
1196   case 220: // All Entity
1197     ::SetDisplayEntity(theCommandID);
1198   break;
1199
1200   case 214:                                     // UPDATE
1201     {
1202       if(checkLock(aStudy)) break;
1203       SMESH::UpdateView();
1204
1205       SALOME_ListIO l;
1206       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1207       aSel->selectedObjects( l );
1208       aSel->setSelectedObjects( l );
1209       break;
1210     }
1211
1212   case 300:                                     // ERASE
1213   case 301:                                     // DISPLAY
1214   case 302:                                     // DISPLAY ONLY
1215     {
1216       SMESH::EDisplaing anAction;
1217       switch (theCommandID) {
1218       case 300: anAction = SMESH::eErase; break;
1219       case 301: anAction = SMESH::eDisplay; break;
1220       case 302: anAction = SMESH::eDisplayOnly; break;
1221       }
1222
1223       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1224       SALOME_ListIO sel_objects, to_process;
1225       if (aSel)
1226         aSel->selectedObjects( sel_objects );
1227
1228       if( theCommandID==302 )
1229         startOperation( myEraseAll );
1230
1231       extractContainers( sel_objects, to_process );
1232
1233       if (vtkwnd) {
1234         SALOME_ListIteratorOfListIO It( to_process );
1235         for (; It.More(); It.Next()) {
1236           Handle(SALOME_InteractiveObject) IOS = It.Value();
1237           if (IOS->hasEntry()) {
1238             SMESH::UpdateView(anAction, IOS->getEntry());
1239             if (anAction == SMESH::eDisplayOnly)
1240               anAction = SMESH::eDisplay;
1241           }
1242         }
1243       }
1244
1245       // PAL13338 -->
1246       if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) && !automaticUpdate() )
1247         SMESH::UpdateView();
1248       // PAL13338 <--
1249
1250       if (anAction == SMESH::eErase) {
1251         SALOME_ListIO l1;
1252         aSel->setSelectedObjects( l1 );
1253       }
1254       else
1255         aSel->setSelectedObjects( to_process );
1256
1257       break;
1258     }
1259
1260   case 400:                                     // NODES
1261     {
1262       if(checkLock(aStudy)) break;
1263
1264       if ( vtkwnd ) {
1265         EmitSignalDeactivateDialog();
1266
1267         new SMESHGUI_NodesDlg(this);
1268       }
1269       else {
1270         SUIT_MessageBox::warn1(desktop(),
1271                               tr("SMESH_WRN_WARNING"),
1272                               tr("SMESH_WRN_VIEWER_VTK"),
1273                               tr("SMESH_BUT_OK"));
1274       }
1275       break;
1276     }
1277
1278   case 2151:  // FILTER
1279   {
1280     if ( vtkwnd )
1281     {
1282       EmitSignalDeactivateDialog();
1283       new SMESHGUI_FilterDlg( this, SMESH::EDGE );
1284     }
1285     break;
1286   }
1287
1288   case 406:                                     // MOVE NODE
1289     {
1290       if ( !vtkwnd )
1291       {
1292         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1293           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1294         break;
1295       }
1296
1297       if(checkLock(aStudy)) break;
1298       new SMESHGUI_MoveNodesDlg(this);
1299       break;
1300     }
1301
1302   case 701:                                     // COMPUTE MESH
1303     {
1304       if (checkLock(aStudy)) break;
1305
1306       LightApp_SelectionMgr *Sel = selectionMgr();
1307       SALOME_ListIO selected; Sel->selectedObjects( selected );
1308
1309       int nbSel = selected.Extent();
1310       if (nbSel != 1) {
1311         SUIT_MessageBox::warn1(desktop(),
1312                                tr("SMESH_WRN_WARNING"),
1313                                tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1314                                tr("SMESH_BUT_OK"));
1315         break;
1316       }
1317
1318       SMESH::SMESH_Mesh_var aMesh;
1319       SMESH::SMESH_subMesh_var aSubMesh;
1320       Handle(SALOME_InteractiveObject) IObject = selected.First();
1321       if (IObject->hasEntry()) {
1322         _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1323         GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1324         if ( aShapeObject->_is_nil() ) {
1325           // imported mesh
1326           break;
1327         }
1328         if ( aMeshSObj ) {
1329           aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1330           aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1331           if ( !aSubMesh->_is_nil() )
1332             aMesh = aSubMesh->GetFather();
1333
1334           if (!aMesh->_is_nil()) {
1335             SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1336             if ( errors->length() > 0 ) {
1337               SUIT_MessageBox::warn1(desktop(),
1338                                      tr("SMESH_WRN_WARNING"),
1339                                      SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1340                                      tr("SMESH_BUT_OK"));
1341               break;
1342             }
1343
1344             try {
1345               if (GetSMESHGen()->Compute(aMesh, aShapeObject))
1346                 SMESH::ModifiedMesh(aMeshSObj, true);
1347               else
1348                 SUIT_MessageBox::warn1(desktop(),
1349                                        tr("SMESH_WRN_WARNING"),
1350                                        tr("SMESH_WRN_COMPUTE_FAILED"),
1351                                        tr("SMESH_BUT_OK"));
1352             }
1353             catch(const SALOME::SALOME_Exception & S_ex){
1354               SalomeApp_Tools::QtCatchCorbaException(S_ex);
1355             }
1356
1357             updateObjBrowser();
1358
1359             if (automaticUpdate()) {
1360               SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
1361               if (aVTKView) {
1362                 CORBA::Long anId = aStudy->StudyId();
1363                 TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
1364                 if (aVisualObj) {
1365                   aVisualObj->Update();
1366                   SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1367                   if (!anActor) {
1368                     anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
1369                     if (anActor) {
1370                       SMESH::DisplayActor(aVTKView, anActor); //apo
1371                       SMESH::FitAll();
1372                     }
1373                   }
1374                   SMESH::RepaintCurrentView();
1375                   Sel->setSelectedObjects( selected );
1376                 }
1377               }
1378             }
1379           }
1380         }
1381       }
1382     }
1383     break;
1384
1385   case 702:  // Create mesh
1386     startOperation( 702 );
1387     break;
1388   case 703:  // Create sub-mesh
1389     startOperation( 703 );
1390     break;
1391   case 704: // Edit mesh/sub-mesh
1392     startOperation( 704 );
1393     break;
1394   case 407: // DIAGONAL INVERSION
1395   case 408: // Delete diagonal
1396     {
1397       if ( !vtkwnd )
1398       {
1399         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1400           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1401         break;
1402       }
1403
1404       if ( checkLock( aStudy ) )
1405         break;
1406
1407       /*Standard_Boolean aRes;
1408       SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1409       if ( aMesh->_is_nil() )
1410       {
1411         SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1412           tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1413         break;
1414       }
1415       */
1416       EmitSignalDeactivateDialog();
1417       if ( theCommandID == 407 )
1418         new SMESHGUI_TrianglesInversionDlg(this);
1419       else
1420         new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1421       break;
1422     }
1423     case 409: // Change orientation
1424     case 410: // Union of triangles
1425     case 411: // Cutting of quadrangles
1426     {
1427       if ( !vtkwnd )
1428       {
1429         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1430           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1431         break;
1432       }
1433
1434       if ( checkLock( aStudy ) )
1435         break;
1436
1437       EmitSignalDeactivateDialog();
1438       SMESHGUI_MultiEditDlg* aDlg = NULL;
1439       if ( theCommandID == 409 )
1440         aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1441       else if ( theCommandID == 410 )
1442         aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1443       else
1444         aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1445
1446       aDlg->show();
1447       break;
1448     }
1449   case 412: // Smoothing
1450     {
1451       if(checkLock(aStudy)) break;
1452       if( vtkwnd ) {
1453         EmitSignalDeactivateDialog();
1454         new SMESHGUI_SmoothingDlg( this );
1455       }
1456       else {
1457         SUIT_MessageBox::warn1(desktop(),
1458                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1459                               tr("SMESH_BUT_OK"));
1460       }
1461       break;
1462     }
1463   case 413: // Extrusion
1464     {
1465       if (checkLock(aStudy)) break;
1466       if (vtkwnd) {
1467         EmitSignalDeactivateDialog();
1468         new SMESHGUI_ExtrusionDlg ( this );
1469       } else {
1470         SUIT_MessageBox::warn1(desktop(),
1471                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1472                                tr("SMESH_BUT_OK"));
1473       }
1474       break;
1475     }
1476   case 414: // Revolution
1477     {
1478       if(checkLock(aStudy)) break;
1479       if( vtkwnd ) {
1480         EmitSignalDeactivateDialog();
1481         new SMESHGUI_RevolutionDlg( this );
1482       }
1483       else {
1484         SUIT_MessageBox::warn1(desktop(),
1485                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1486                               tr("SMESH_BUT_OK"));
1487       }
1488       break;
1489     }
1490   case 415: // Pattern mapping
1491     {
1492       if ( checkLock( aStudy ) )
1493         break;
1494       if ( vtkwnd )
1495       {
1496         EmitSignalDeactivateDialog();
1497         new SMESHGUI_MeshPatternDlg( this );
1498       }
1499       else {
1500         SUIT_MessageBox::warn1(desktop(),
1501                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1502                               tr("SMESH_BUT_OK"));
1503       }
1504       break;
1505     }
1506   case 416: // Extrusion along a path
1507     {
1508       if (checkLock(aStudy)) break;
1509       if (vtkwnd) {
1510         EmitSignalDeactivateDialog();
1511         new SMESHGUI_ExtrusionAlongPathDlg( this );
1512       } else {
1513         SUIT_MessageBox::warn1(desktop(),
1514                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1515                                tr("SMESH_BUT_OK"));
1516       }
1517       break;
1518     }
1519   case 417: // Convert mesh to quadratic
1520     {
1521     startOperation( 417 );
1522       /*      if (checkLock(aStudy)) break;
1523       if (vtkwnd) {
1524         EmitSignalDeactivateDialog();
1525         new SMESHGUI_ConvToQuadDlg();
1526       } else {
1527         SUIT_MessageBox::warn1(desktop(),
1528                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1529                                tr("SMESH_BUT_OK"));
1530                                }*/
1531       break;
1532     }
1533   case 801:                                     // CREATE GROUP
1534     {
1535       if ( !vtkwnd )
1536       {
1537         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1538           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1539         break;
1540       }
1541
1542       if(checkLock(aStudy)) break;
1543       EmitSignalDeactivateDialog();
1544       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1545
1546       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1547       SALOME_ListIO selected;
1548       if( aSel )
1549         aSel->selectedObjects( selected );
1550
1551       int nbSel = selected.Extent();
1552       if (nbSel == 1) {
1553         // check if mesh is selected
1554         aMesh = SMESH::GetMeshByIO( selected.First() );
1555       }
1556       SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1557       aDlg->show();
1558       break;
1559     }
1560
1561   case 802:                                     // CONSTRUCT GROUP
1562     {
1563       if ( !vtkwnd )
1564       {
1565         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1566           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1567         break;
1568       }
1569
1570       if(checkLock(aStudy)) break;
1571       EmitSignalDeactivateDialog();
1572
1573       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1574       SALOME_ListIO selected;
1575       if( aSel )
1576         aSel->selectedObjects( selected );
1577
1578       int nbSel = selected.Extent();
1579       if (nbSel == 1) {
1580         // check if submesh is selected
1581         Handle(SALOME_InteractiveObject) IObject = selected.First();
1582         if (IObject->hasEntry()) {
1583           _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1584           if( aSObj ) {
1585             SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1586             if (!aSubMesh->_is_nil()) {
1587               try {
1588                 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1589                 // get submesh elements list by types
1590                 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1591                 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1592                 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1593                 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1594                 // create group for each type o elements
1595                 QString aName = IObject->getName();
1596                 if (aNodes->length() > 0) {
1597                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1598                   aGroup->Add(aNodes.inout());
1599                 }
1600                 if (aEdges->length() > 0) {
1601                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1602                   aGroup->Add(aEdges.inout());
1603                 }
1604                 if (aFaces->length() > 0) {
1605                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1606                   aGroup->Add(aFaces.inout());
1607                 }
1608                 if (aVolumes->length() > 0) {
1609                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1610                   aGroup->Add(aVolumes.inout());
1611                 }
1612                 updateObjBrowser();
1613
1614               }
1615               catch(const SALOME::SALOME_Exception & S_ex){
1616                 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1617               }
1618             }
1619           }
1620         }
1621       }
1622       else if(nbSel==0) {
1623         SUIT_MessageBox::warn1(desktop(),
1624                                tr("SMESH_WRN_WARNING"),
1625                                tr("SMESH_WRN_NO_AVAILABLE_DATA"),
1626                                tr("SMESH_BUT_OK"));
1627       }
1628       break;
1629     }
1630
1631   case 803:                                     // EDIT GROUP
1632     {
1633       if ( !vtkwnd )
1634       {
1635         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1636           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1637         break;
1638       }
1639
1640       if(checkLock(aStudy)) break;
1641       EmitSignalDeactivateDialog();
1642
1643       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1644       SALOME_ListIO selected;
1645       if( aSel )
1646         aSel->selectedObjects( selected );
1647
1648       SALOME_ListIteratorOfListIO It (selected);
1649       int nbSelectedGroups = 0;
1650       for ( ; It.More(); It.Next() )
1651       {
1652         SMESH::SMESH_GroupBase_var aGroup =
1653           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1654         if (!aGroup->_is_nil()) {
1655           nbSelectedGroups++;
1656           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1657           aDlg->show();
1658         }
1659       }
1660       if (nbSelectedGroups == 0)
1661         {
1662           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1663           aDlg->show();
1664         }
1665       break;
1666     }
1667
1668   case 804:                                     // Add elements to group
1669     {
1670       if(checkLock(aStudy)) break;
1671       if (myState == 800) {
1672         SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1673         if (aDlg) aDlg->onAdd();
1674       }
1675       break;
1676     }
1677
1678   case 805:                                     // Remove elements from group
1679     {
1680       if(checkLock(aStudy)) break;
1681       if (myState == 800) {
1682         SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1683         if (aDlg) aDlg->onRemove();
1684       }
1685       break;
1686     }
1687
1688     case 810: // Union Groups
1689     case 811: // Intersect groups
1690     case 812: // Cut groups
1691     {
1692       if ( !vtkwnd )
1693       {
1694         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1695           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1696         break;
1697       }
1698
1699       if ( checkLock( aStudy ) )
1700         break;
1701
1702       EmitSignalDeactivateDialog();
1703
1704       int aMode;
1705       if      ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1706       else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1707       else                            aMode = SMESHGUI_GroupOpDlg::CUT;
1708
1709       ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1710       break;
1711     }
1712
1713     case 813: // Delete groups with their contents
1714     {
1715       if ( !vtkwnd )
1716       {
1717         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1718           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1719         break;
1720       }
1721
1722       if ( checkLock( aStudy ) )
1723         break;
1724
1725       EmitSignalDeactivateDialog();
1726
1727       new SMESHGUI_DeleteGroupDlg( this );
1728       break;
1729     }
1730
1731   case 900:                                     // MESH INFOS
1732     {
1733       EmitSignalDeactivateDialog();
1734       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1735       SALOME_ListIO selected;
1736       if( aSel )
1737         aSel->selectedObjects( selected );
1738
1739       if ( selected.Extent() > 1 ) { // a dlg for each IO
1740         SALOME_ListIO IOs;
1741         SALOME_ListIteratorOfListIO It (selected);
1742         for ( ; It.More(); It.Next() ) {
1743           IOs.Clear(); IOs.Append( It.Value() );
1744           aSel->setSelectedObjects( IOs );
1745           new SMESHGUI_MeshInfosDlg(this, "", false);
1746         }
1747         // restore selection
1748         aSel->setSelectedObjects( selected );
1749       }
1750       else
1751         new SMESHGUI_MeshInfosDlg(this, "", false);
1752       break;
1753     }
1754
1755   case 902:                                     // STANDARD MESH INFOS
1756     {
1757       EmitSignalDeactivateDialog();
1758       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1759       SALOME_ListIO selected;
1760       if( aSel )
1761         aSel->selectedObjects( selected );
1762
1763       if ( selected.Extent() > 1 ) { // a dlg for each IO
1764         SALOME_ListIO IOs;
1765         SALOME_ListIteratorOfListIO It (selected);
1766         for ( ; It.More(); It.Next() ) {
1767           IOs.Clear();
1768           IOs.Append( It.Value() );
1769           aSel->setSelectedObjects( IOs );
1770           new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1771         }
1772         // restore selection
1773         aSel->setSelectedObjects( selected );
1774       }
1775       else
1776         new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1777       break;
1778     }
1779
1780   case 1100:                                    // EDIT HYPOTHESIS
1781     {
1782       if(checkLock(aStudy)) break;
1783
1784       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1785       SALOME_ListIO selected;
1786       if( aSel )
1787         aSel->selectedObjects( selected );
1788
1789       int nbSel = selected.Extent();
1790
1791       if (nbSel == 1) {
1792         SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1793
1794         /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1795         /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
1796         /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
1797         if ( !Hyp->_is_nil() )
1798         {
1799           char* sName = Hyp->GetName();
1800           SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1801           if (aCreator)
1802             aCreator->edit( Hyp.in(), desktop() );
1803           else
1804           {
1805             // report error
1806           }
1807         }
1808       }
1809       updateObjBrowser( true );
1810       break;
1811     }
1812
1813   case 1101:                                    // RENAME
1814     {
1815       if ( checkLock( aStudy ) )
1816         break;
1817
1818       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1819       SALOME_ListIO selected;
1820       if( aSel )
1821         aSel->selectedObjects( selected );
1822
1823       SALOME_ListIteratorOfListIO It( selected );
1824       for ( ; It.More(); It.Next() )
1825       {
1826         Handle(SALOME_InteractiveObject) IObject = It.Value();
1827         _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1828         _PTR(GenericAttribute) anAttr;
1829         _PTR(AttributeName) aName;
1830         if ( obj )
1831         {
1832           if ( obj->FindAttribute(anAttr, "AttributeName") )
1833           {
1834             aName = anAttr;
1835             QString newName = QString(aName->Value().c_str());
1836             newName = LightApp_NameDlg::getName(desktop(), newName);
1837             if ( !newName.isEmpty() )
1838             {
1839               //old source: aStudy->renameIObject( IObject, newName );
1840               aName->SetValue( newName.latin1() );
1841
1842               // if current object is group update group's name
1843               SMESH::SMESH_GroupBase_var aGroup =
1844                 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1845               if (!aGroup->_is_nil() )
1846                 aGroup->SetName( newName.latin1() );
1847
1848               updateObjBrowser();
1849             }
1850           }
1851         }
1852       }
1853       break;
1854     }
1855
1856   case 1102:                                    // REMOVE HYPOTHESIS / ALGORITHMS
1857     {
1858       if(checkLock(aStudy)) break;
1859       SUIT_OverrideCursor wc;
1860
1861       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1862       SALOME_ListIO selected;
1863       if( aSel )
1864         aSel->selectedObjects( selected, QString::null, false );
1865
1866       SALOME_ListIteratorOfListIO It(selected);
1867       for (int i = 0; It.More(); It.Next(), i++) {
1868         Handle(SALOME_InteractiveObject) IObject = It.Value();
1869         SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1870       }
1871       SALOME_ListIO l1;
1872       aSel->setSelectedObjects( l1 );
1873       updateObjBrowser();
1874       break;
1875     }
1876
1877   case 401:                                     // GEOM::EDGE
1878   case 4021:                                    // TRIANGLE
1879   case 4022:                                    // QUAD
1880   case 4023:                                    // POLYGON
1881   case 4031:                                    // TETRA
1882   case 4032:                                    // HEXA
1883     {
1884       if(checkLock(aStudy)) break;
1885       if ( vtkwnd ) {
1886         EmitSignalDeactivateDialog();
1887         SMDSAbs_ElementType type    = SMDSAbs_Edge;
1888         int                 nbNodes = 2;
1889         switch (theCommandID) {
1890         case 4021:                                      // TRIANGLE
1891           type = SMDSAbs_Face; nbNodes = 3; break;
1892         case 4022:                                      // QUAD
1893           type = SMDSAbs_Face; nbNodes = 4; break;
1894         case 4031:                                      // TETRA
1895           type = SMDSAbs_Volume; nbNodes = 4; break;
1896         case 4023:                                      // POLYGON
1897           type = SMDSAbs_Face; nbNodes = 5; break;     // 5 - identificator for POLYGON
1898         case 4032:                                      // HEXA
1899           type = SMDSAbs_Volume; nbNodes = 8; break;
1900         case 4033:                                      // POLYHEDRE
1901           type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1902         default:;
1903         }
1904         new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1905       }
1906       else {
1907         SUIT_MessageBox::warn1(desktop(),
1908                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1909                               tr("SMESH_BUT_OK"));
1910       }
1911       break;
1912     }
1913   case 4033:                                    // POLYHEDRON
1914     {
1915       if(checkLock(aStudy)) break;
1916       if ( vtkwnd ) {
1917         EmitSignalDeactivateDialog();
1918         new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1919       }
1920       else {
1921         SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1922                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1923                               tr("SMESH_BUT_OK"));
1924       }
1925       break;
1926     }
1927   case 4034:     // QUADRATIC EDGE
1928   case 4035:     // QUADRATIC TRIANGLE
1929   case 4036:     // QUADRATIC QUADRANGLE
1930   case 4037:     // QUADRATIC TETRAHEDRON
1931   case 4038:     // QUADRATIC PYRAMID
1932   case 4039:     // QUADRATIC PENTAHEDRON
1933   case 4040:     // QUADRATIC HEXAHEDRON
1934     {
1935       if(checkLock(aStudy)) break;
1936       if ( vtkwnd ) {
1937         EmitSignalDeactivateDialog();
1938         int type;
1939
1940         switch (theCommandID) {
1941         case 4034:
1942           type = QUAD_EDGE; break;
1943         case 4035:
1944           type = QUAD_TRIANGLE; break;
1945         case 4036:
1946           type = QUAD_QUADRANGLE; break;
1947         case 4037:
1948           type = QUAD_TETRAHEDRON; break;
1949         case 4038:
1950           type = QUAD_PYRAMID; break;
1951         case 4039:
1952           type = QUAD_PENTAHEDRON; break;
1953         case 4040:
1954           type = QUAD_HEXAHEDRON;
1955           break;
1956         default:;
1957         }
1958          new SMESHGUI_AddQuadraticElementDlg( this, type );
1959       }
1960       else {
1961         SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1962                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1963                                tr("SMESH_BUT_OK"));
1964       }
1965       break;
1966     }
1967   case 4041:                                    // REMOVES NODES
1968     {
1969       if(checkLock(aStudy)) break;
1970       if ( vtkwnd ) {
1971         EmitSignalDeactivateDialog();
1972         new SMESHGUI_RemoveNodesDlg(this);
1973       }
1974       else {
1975         SUIT_MessageBox::warn1(desktop(),
1976                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1977                               tr("SMESH_BUT_OK"));
1978       }
1979       break;
1980     }
1981   case 4042:                                    // REMOVES ELEMENTS
1982     {
1983       if(checkLock(aStudy)) break;
1984       if( vtkwnd ) {
1985         EmitSignalDeactivateDialog();
1986         new SMESHGUI_RemoveElementsDlg(this);
1987       }
1988       else
1989         {
1990           SUIT_MessageBox::warn1(desktop(),
1991                                 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1992                                 tr("SMESH_BUT_OK"));
1993         }
1994       break;
1995     }
1996   case 4051:                                    // RENUMBERING NODES
1997     {
1998       if(checkLock(aStudy)) break;
1999       if( vtkwnd ) {
2000         EmitSignalDeactivateDialog();
2001         new SMESHGUI_RenumberingDlg( this, "", 0);
2002       }
2003       else
2004         {
2005           SUIT_MessageBox::warn1(desktop(),
2006                                 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2007                                 tr("SMESH_BUT_OK"));
2008         }
2009       break;
2010     }
2011   case 4052:                                    // RENUMBERING ELEMENTS
2012     {
2013       if(checkLock(aStudy)) break;
2014       if ( vtkwnd ) {
2015         EmitSignalDeactivateDialog();
2016         new SMESHGUI_RenumberingDlg( this, "", 1);
2017       }
2018       else
2019         {
2020           SUIT_MessageBox::warn1(desktop(),
2021                                 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2022                                 tr("SMESH_BUT_OK"));
2023         }
2024       break;
2025     }
2026   case 4061:                                   // TRANSLATION
2027     {
2028       if(checkLock(aStudy)) break;
2029       if ( vtkwnd ) {
2030         EmitSignalDeactivateDialog();
2031         new SMESHGUI_TranslationDlg( this );
2032       }
2033       else {
2034         SUIT_MessageBox::warn1(desktop(),
2035                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2036                               tr("SMESH_BUT_OK"));
2037       }
2038       break;
2039     }
2040   case 4062:                                   // ROTATION
2041     {
2042       if(checkLock(aStudy)) break;
2043       if( vtkwnd ) {
2044         EmitSignalDeactivateDialog();
2045         new SMESHGUI_RotationDlg( this );
2046       }
2047       else {
2048         SUIT_MessageBox::warn1(desktop(),
2049                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2050                               tr("SMESH_BUT_OK"));
2051       }
2052       break;
2053     }
2054   case 4063:                                   // SYMMETRY
2055     {
2056       if(checkLock(aStudy)) break;
2057       if(vtkwnd) {
2058         EmitSignalDeactivateDialog();
2059         new SMESHGUI_SymmetryDlg( this );
2060       }
2061       else {
2062         SUIT_MessageBox::warn1(desktop(),
2063                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2064                               tr("SMESH_BUT_OK"));
2065       }
2066       break;
2067     }
2068   case 4064:                                   // SEWING
2069     {
2070       if(checkLock(aStudy)) break;
2071       if(vtkwnd) {
2072         EmitSignalDeactivateDialog();
2073         new SMESHGUI_SewingDlg( this );
2074       }
2075       else {
2076         SUIT_MessageBox::warn1(desktop(),
2077                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2078                               tr("SMESH_BUT_OK"));
2079       }
2080       break;
2081     }
2082   case 4065:                                   // MERGE NODES
2083     {
2084       if(checkLock(aStudy)) break;
2085       if(vtkwnd) {
2086         EmitSignalDeactivateDialog();
2087         new SMESHGUI_MergeNodesDlg( this );
2088       }
2089       else {
2090         SUIT_MessageBox::warn1(desktop(),
2091                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2092                               tr("SMESH_BUT_OK"));
2093       }
2094       break;
2095     }
2096   case 4066: // MERGE EQUAL ELEMENTS
2097     {
2098       if (checkLock(aStudy)) break;
2099       if (vtkwnd) {
2100         EmitSignalDeactivateDialog();
2101         new SMESHGUI_EditMeshDlg(this,
2102                                  "SMESH_MERGE_ELEMENTS_TITLE",
2103                                  "ICON_DLG_MERGE_ELEMENTS",
2104                                  1); // MergeEqualElemets
2105       } else {
2106         SUIT_MessageBox::warn1(desktop(),
2107                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2108                               tr("SMESH_BUT_OK"));
2109       }
2110       break;
2111     }
2112
2113   case 4067: // MAKE MESH PASS THROUGH POINT
2114     startOperation( 4067 );
2115     break;
2116
2117   case 5105: // Library of selection filters
2118   {
2119     static QValueList<int> aTypes;
2120     if ( aTypes.isEmpty() )
2121     {
2122       aTypes.append( SMESH::NODE );
2123       aTypes.append( SMESH::EDGE );
2124       aTypes.append( SMESH::FACE );
2125       aTypes.append( SMESH::VOLUME );
2126     }
2127     if (!myFilterLibraryDlg)
2128       myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2129     else if (myFilterLibraryDlg->isHidden())
2130       myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2131     myFilterLibraryDlg->raise();
2132   }
2133   break;
2134
2135   case 6017:                                    // CONTROLS
2136   case 6016:
2137   case 6015:
2138   case 6014:
2139   case 6013:
2140   case 6012:
2141   case 6011:
2142   case 6001:
2143   case 6018:
2144   case 6019:
2145   case 6002:
2146   case 6003:
2147   case 6004:
2148   case 6009:
2149     if ( vtkwnd ) {
2150
2151       LightApp_SelectionMgr* mgr = selectionMgr();
2152       SALOME_ListIO selected; mgr->selectedObjects( selected );
2153
2154       if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2155         _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2156         if ( SO ) {
2157           CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2158           SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( aObject );
2159           SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2160           SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( aObject );
2161           if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2162             ::Control( theCommandID );
2163             break;
2164           }
2165         }
2166       }
2167       SUIT_MessageBox::warn1(desktop(),
2168                             tr( "SMESH_WRN_WARNING" ),
2169                             tr( "SMESH_BAD_SELECTION" ),
2170                             tr( "SMESH_BUT_OK" ) );
2171       break;
2172     }
2173     else {
2174       SUIT_MessageBox::warn1(desktop(),
2175                             tr( "SMESH_WRN_WARNING" ),
2176                             tr( "NOT_A_VTK_VIEWER" ),
2177                             tr( "SMESH_BUT_OK" ) );
2178     }
2179     break;
2180   case 9010:
2181     {
2182       LightApp_SelectionMgr* mgr = selectionMgr();
2183       SALOME_ListIO selected; mgr->selectedObjects( selected );
2184
2185       SALOME_ListIteratorOfListIO it(selected);
2186       for(; it.More(); it.Next()) {
2187         Handle(SALOME_InteractiveObject) anIObject = it.Value();
2188         if(anIObject->hasEntry()) {
2189           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2190             anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2191           }
2192         }
2193       }
2194       break;
2195     }
2196   case 9011:
2197     {
2198       LightApp_SelectionMgr* mgr = selectionMgr();
2199       SALOME_ListIO selected; mgr->selectedObjects( selected );
2200
2201       if (selected.Extent() == 1)       {
2202         Handle(SALOME_InteractiveObject) anIObject = selected.First();
2203         if(anIObject->hasEntry())
2204           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2205             anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2206           }
2207       }
2208       break;
2209     }
2210   }
2211
2212   anApp->updateActions(); //SRN: To update a Save button in the toolbar
2213   //updateObjBrowser();
2214   return true;
2215 }
2216
2217 //=============================================================================
2218 /*!
2219  *
2220  */
2221 //=============================================================================
2222 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2223 {
2224   return false;
2225 }
2226
2227 //=============================================================================
2228 /*!
2229  *
2230  */
2231 //=============================================================================
2232 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2233 {
2234   return true;
2235 }
2236
2237 //=============================================================================
2238 /*!
2239  *
2240  */
2241 //=============================================================================
2242 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2243 {
2244   return true;
2245 }
2246
2247 //=============================================================================
2248 /*! Method:  BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2249  *  Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2250  */
2251 //=============================================================================
2252 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2253                                   SUIT_ViewWindow* wnd )
2254 {
2255   if(theIO->hasEntry()){
2256     //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2257     SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2258   }
2259 }
2260
2261 //=======================================================================
2262 // function : createSMESHAction
2263 // purpose  :
2264 //=======================================================================
2265 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle  )
2266 {
2267   QIconSet icon;
2268   QWidget* parent = application()->desktop();
2269   SUIT_ResourceMgr* resMgr = resourceMgr();
2270   QPixmap pix;
2271   if ( icon_id.length() )
2272     pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2273   else
2274     pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2275   if ( !pix.isNull() )
2276     icon = QIconSet( pix );
2277
2278   QString tooltip    = tr( QString( "TOP_" )+po_id ),
2279           menu       = tr( QString( "MEN_" )+po_id ),
2280           status_bar = tr( QString( "STB_" )+po_id );
2281
2282   createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() )  );
2283 }
2284
2285 //=======================================================================
2286 // function : createPopupItem
2287 // purpose  :
2288 //=======================================================================
2289 void SMESHGUI::createPopupItem( const int id,
2290                                 const QString& clients,
2291                                 const QString& types,
2292                                 const QString& theRule,
2293                                 const int pId )
2294 {
2295   int parentId = pId;
2296   if( pId!=-1 )
2297     parentId = popupMgr()->actionId( action( pId ) );
2298
2299   if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2300     popupMgr()->insert( action( id ), parentId, 0 );
2301
2302   QChar lc = QtxPopupMgr::Selection::defEquality();
2303   QString rule = "(%1) and (%2) and (%3)";
2304   rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2305   if( clients.isEmpty() )
2306     rule = rule.arg( QString( "true" ) );
2307   else
2308     rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2309   rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2310   rule += theRule;
2311
2312   bool cont = myRules.contains( id );
2313   if( cont )
2314     rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2315
2316   popupMgr()->setRule( action( id ), rule, true );
2317   myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2318 }
2319
2320 //=======================================================================
2321 // function : initialize
2322 // purpose  :
2323 //=======================================================================
2324 void SMESHGUI::initialize( CAM_Application* app )
2325 {
2326   SalomeApp_Module::initialize( app );
2327
2328 //   SUIT_ResourceMgr* mgr = app->resourceMgr();
2329 //   if ( mgr )
2330   /* Automatic Update flag */
2331 //     myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2332
2333   // ----- create actions --------------
2334
2335   createSMESHAction(  111, "DAT", "", (CTRL+Key_B) );
2336   createSMESHAction(  112, "UNV", "", (CTRL+Key_U) );
2337   createSMESHAction(  113, "MED", "", (CTRL+Key_M) );
2338   createSMESHAction(  114, "NUM" );
2339   createSMESHAction(  121, "DAT" );
2340   createSMESHAction(  122, "MED" );
2341   createSMESHAction(  123, "UNV" );
2342   createSMESHAction(  124, "EXPORT_DAT" );
2343   createSMESHAction(  125, "EXPORT_MED" );
2344   createSMESHAction(  126, "EXPORT_UNV" );
2345   createSMESHAction(   33, "DELETE",          "ICON_DELETE" );
2346   createSMESHAction( 5105, "SEL_FILTER_LIB" );
2347   createSMESHAction(  701, "COMPUTE",         "ICON_COMPUTE" );
2348   createSMESHAction(  702, "CREATE_MESH",     "ICON_DLG_INIT_MESH" );
2349   createSMESHAction(  703, "CREATE_SUBMESH",  "ICON_DLG_ADD_SUBMESH" );
2350   createSMESHAction(  704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2351   createSMESHAction(  801, "CREATE_GROUP",    "ICON_SMESH_TREE_GROUP" );
2352   createSMESHAction(  802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2353   createSMESHAction(  803, "EDIT_GROUP",      "ICON_EDIT_GROUP" );
2354   createSMESHAction(  804, "ADD" );
2355   createSMESHAction(  805, "REMOVE" );
2356   createSMESHAction(  810, "UN_GROUP",        "ICON_UNION" );
2357   createSMESHAction(  811, "INT_GROUP",       "ICON_INTERSECT" );
2358   createSMESHAction(  812, "CUT_GROUP",       "ICON_CUT" );
2359   createSMESHAction(  813, "DEL_GROUP",       "ICON_DEL_GROUP" );
2360   createSMESHAction(  900, "ADV_INFO",        "ICON_ADV_INFO" );
2361   createSMESHAction(  902, "STD_INFO",        "ICON_STD_INFO" );
2362   createSMESHAction( 6001, "LENGTH",          "ICON_LENGTH" ,       0, true );
2363   createSMESHAction( 6002, "FREE_EDGE",       "ICON_FREE_EDGE" ,    0, true );
2364   createSMESHAction( 6003, "FREE_BORDER",     "ICON_FREE_EDGE_2D" , 0, true );
2365   createSMESHAction( 6004, "CONNECTION",      "ICON_CONNECTION" ,   0, true );
2366   createSMESHAction( 6011, "AREA",            "ICON_AREA" ,         0, true );
2367   createSMESHAction( 6012, "TAPER",           "ICON_TAPER" ,        0, true );
2368   createSMESHAction( 6013, "ASPECT",          "ICON_ASPECT" ,       0, true );
2369   createSMESHAction( 6014, "MIN_ANG",         "ICON_ANGLE" ,        0, true );
2370   createSMESHAction( 6015, "WARP",            "ICON_WARP" ,         0, true );
2371   createSMESHAction( 6016, "SKEW",            "ICON_SKEW",          0, true );
2372   createSMESHAction( 6017, "ASPECT_3D",       "ICON_ASPECT_3D",     0, true );
2373   createSMESHAction( 6018, "LENGTH_2D",       "ICON_LENGTH_2D",     0, true );
2374   createSMESHAction( 6019, "CONNECTION_2D",   "ICON_CONNECTION_2D", 0, true );
2375   createSMESHAction( 6009, "VOLUME_3D",       "ICON_VOLUME_3D",     0, true );
2376   createSMESHAction(  400, "NODE",            "ICON_DLG_NODE" );
2377   createSMESHAction(  401, "EDGE",            "ICON_DLG_EDGE" );
2378   createSMESHAction( 4021, "TRIANGLE",        "ICON_DLG_TRIANGLE" );
2379   createSMESHAction( 4022, "QUAD",            "ICON_DLG_QUADRANGLE" );
2380   createSMESHAction( 4023, "POLYGON",         "ICON_DLG_POLYGON" );
2381   createSMESHAction( 4031, "TETRA",           "ICON_DLG_TETRAS" );
2382   createSMESHAction( 4032, "HEXA",            "ICON_DLG_HEXAS" );
2383   createSMESHAction( 4041, "REMOVE_NODES",    "ICON_DLG_REM_NODE" );
2384   createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2385   createSMESHAction( 4051, "RENUM_NODES",     "ICON_DLG_RENUMBERING_NODES" );
2386   createSMESHAction( 4052, "RENUM_ELEMENTS",  "ICON_DLG_RENUMBERING_ELEMENTS" );
2387   createSMESHAction( 4061, "TRANS",           "ICON_SMESH_TRANSLATION_VECTOR" );
2388   createSMESHAction( 4062, "ROT",             "ICON_DLG_MESH_ROTATION" );
2389   createSMESHAction( 4063, "SYM",             "ICON_SMESH_SYMMETRY_PLANE" );
2390   createSMESHAction( 4064, "SEW",             "ICON_SMESH_SEWING_FREEBORDERS" );
2391   createSMESHAction( 4065, "MERGE",           "ICON_SMESH_MERGE_NODES" );
2392   createSMESHAction( 4066, "MERGE_ELEMENTS",  "ICON_DLG_MERGE_ELEMENTS" );
2393   createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MESH_THROU_POINT" );
2394   createSMESHAction(  406, "MOVE",            "ICON_DLG_MOVE_NODE" );
2395   createSMESHAction(  407, "INV",             "ICON_DLG_MESH_DIAGONAL" );
2396   createSMESHAction(  408, "UNION2",          "ICON_UNION2TRI" );
2397   createSMESHAction(  409, "ORIENT",          "ICON_DLG_MESH_ORIENTATION" );
2398   createSMESHAction(  410, "UNION",           "ICON_UNIONTRI" );
2399   createSMESHAction(  411, "CUT",             "ICON_CUTQUAD" );
2400   createSMESHAction(  412, "SMOOTH",          "ICON_DLG_SMOOTHING" );
2401   createSMESHAction(  413, "EXTRUSION",       "ICON_EXTRUSION" );
2402   createSMESHAction(  414, "REVOLUTION",      "ICON_REVOLUTION" );
2403   createSMESHAction(  415, "MAP",             "ICON_MAP" );
2404   createSMESHAction(  416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2405   createSMESHAction(  417, "CONV_TO_QUAD",    "ICON_CONV_TO_QUAD" );
2406   createSMESHAction(  200, "RESET" );
2407   createSMESHAction(  201, "SCALAR_BAR_PROP" );
2408   createSMESHAction(  211, "WIRE",           "ICON_WIRE", 0, true );
2409   createSMESHAction(  212, "SHADE",          "ICON_SHADE", 0, true );
2410   createSMESHAction(  213, "SHRINK",         "ICON_SHRINK", 0, true );
2411   createSMESHAction(  214, "UPDATE",         "ICON_UPDATE" );
2412   createSMESHAction(  215, "NODES",          "ICON_POINTS", 0, true );
2413   createSMESHAction(  217, "EDGES",          "ICON_DLG_EDGE", 0, true );
2414   createSMESHAction(  218, "FACES",          "ICON_DLG_TRIANGLE", 0, true );
2415   createSMESHAction(  219, "VOLUMES",        "ICON_DLG_TETRAS", 0, true );
2416   createSMESHAction(  220, "ALL" );
2417   createSMESHAction( 1100, "EDIT_HYPO" );
2418   createSMESHAction( 1101, "RENAME" );
2419   createSMESHAction( 1102, "UNASSIGN" );
2420   createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2421   createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2422   createSMESHAction( 1131, "DISPMODE" );
2423   createSMESHAction( 1132, "COLORS" );
2424   createSMESHAction( 1133, "TRANSP" );
2425   createSMESHAction( 1134, "CLIP" );
2426   createSMESHAction( 1135, "DISP_ENT" );
2427   createSMESHAction( 2000, "CTRL" );
2428
2429   createSMESHAction( 300, "ERASE" );
2430   createSMESHAction( 301, "DISPLAY" );
2431   createSMESHAction( 302, "DISPLAY_ONLY" );
2432   createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2433   createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2434   createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2435   createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2436   createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2437   createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2438   createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2439   createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2440
2441   // ----- create menu --------------
2442   int fileId   = createMenu( tr( "MEN_FILE" ),   -1,  1 ),
2443       editId   = createMenu( tr( "MEN_EDIT" ),   -1,  3 ),
2444       toolsId  = createMenu( tr( "MEN_TOOLS" ),  -1,  5, 50 ),
2445       meshId   = createMenu( tr( "MEN_MESH" ),   -1, 70, 10 ),
2446       ctrlId   = createMenu( tr( "MEN_CTRL" ),   -1, 60, 10 ),
2447       modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2448       viewId   = createMenu( tr( "MEN_VIEW" ),   -1,  2 );
2449
2450   createMenu( separator(), fileId );
2451
2452   int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2453       exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2454       addId    = createMenu( tr( "MEN_ADD" ),    modifyId, 402 ),
2455       removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2456       renumId  = createMenu( tr( "MEN_RENUM" ),  modifyId, 404 ),
2457       transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2458
2459   createMenu( 111, importId, -1 );
2460   createMenu( 112, importId, -1 );
2461   createMenu( 113, importId, -1 );
2462
2463   createMenu( 121, exportId, -1 );
2464   createMenu( 122, exportId, -1 );
2465   createMenu( 123, exportId, -1 );
2466
2467   createMenu( separator(), fileId, 10 );
2468
2469   createMenu( 33, editId, -1 );
2470
2471   createMenu( 5105, toolsId, -1 );
2472
2473   createMenu( 702, meshId, -1 );
2474   createMenu( 703, meshId, -1 );
2475   createMenu( 704, meshId, -1 );
2476   createMenu( separator(), meshId, -1 );
2477   createMenu( 701, meshId, -1 );
2478   createMenu( separator(), meshId, -1 );
2479   createMenu( 801, meshId, -1 );
2480   createMenu( 802, meshId, -1 );
2481   createMenu( 803, meshId, -1 );
2482   createMenu( separator(), meshId, -1 );
2483   createMenu( 810, meshId, -1 );
2484   createMenu( 811, meshId, -1 );
2485   createMenu( 812, meshId, -1 );
2486   createMenu( separator(), meshId, -1 );
2487   createMenu( 813, meshId, -1 );
2488   createMenu( separator(), meshId, -1 );
2489   createMenu( 900, meshId, -1 );
2490   createMenu( 902, meshId, -1 );
2491   createMenu( separator(), meshId, -1 );
2492
2493   createMenu( 6003, ctrlId, -1 );
2494   createMenu( 6001, ctrlId, -1 );
2495   createMenu( 6004, ctrlId, -1 );
2496   createMenu( separator(), ctrlId, -1 );
2497   createMenu( 6002, ctrlId, -1 );
2498   createMenu( 6018, ctrlId, -1 );
2499   createMenu( 6019, ctrlId, -1 );
2500   createMenu( 6011, ctrlId, -1 );
2501   createMenu( 6012, ctrlId, -1 );
2502   createMenu( 6013, ctrlId, -1 );
2503   createMenu( 6014, ctrlId, -1 );
2504   createMenu( 6015, ctrlId, -1 );
2505   createMenu( 6016, ctrlId, -1 );
2506   createMenu( separator(), ctrlId, -1 );
2507   createMenu( 6017, ctrlId, -1 );
2508   createMenu( 6009, ctrlId, -1 );
2509   createMenu( separator(), ctrlId, -1 );
2510
2511   createMenu( 400, addId, -1 );
2512   createMenu( 401, addId, -1 );
2513   createMenu( 4021, addId, -1 );
2514   createMenu( 4022, addId, -1 );
2515   createMenu( 4023, addId, -1 );
2516   createMenu( 4031, addId, -1 );
2517   createMenu( 4032, addId, -1 );
2518   createMenu( 4033, addId, -1 );
2519   createMenu( separator(), addId, -1 );
2520   createMenu( 4034, addId, -1 );
2521   createMenu( 4035, addId, -1 );
2522   createMenu( 4036, addId, -1 );
2523   createMenu( 4037, addId, -1 );
2524   createMenu( 4038, addId, -1 );
2525   createMenu( 4039, addId, -1 );
2526   createMenu( 4040, addId, -1 );
2527
2528   createMenu( 4041, removeId, -1 );
2529   createMenu( 4042, removeId, -1 );
2530
2531   createMenu( 4051, renumId, -1 );
2532   createMenu( 4052, renumId, -1 );
2533
2534   createMenu( 4061, transfId, -1 );
2535   createMenu( 4062, transfId, -1 );
2536   createMenu( 4063, transfId, -1 );
2537   createMenu( 4064, transfId, -1 );
2538   createMenu( 4065, transfId, -1 );
2539   createMenu( 4066, transfId, -1 );
2540
2541   createMenu( 406, modifyId, -1 );
2542   createMenu( 4067,modifyId, -1 );
2543   createMenu( 407, modifyId, -1 );
2544   createMenu( 408, modifyId, -1 );
2545   createMenu( 409, modifyId, -1 );
2546   createMenu( 410, modifyId, -1 );
2547   createMenu( 411, modifyId, -1 );
2548   createMenu( 412, modifyId, -1 );
2549   createMenu( 413, modifyId, -1 );
2550   createMenu( 416, modifyId, -1 );
2551   createMenu( 414, modifyId, -1 );
2552   createMenu( 415, modifyId, -1 );
2553   createMenu( 417, modifyId, -1 );
2554
2555   createMenu( 214, viewId, -1 );
2556
2557   // ----- create toolbars --------------
2558   int meshTb     = createTool( tr( "TB_MESH" ) ),
2559       ctrlTb     = createTool( tr( "TB_CTRL" ) ),
2560       addRemTb   = createTool( tr( "TB_ADD_REMOVE" ) ),
2561       modifyTb   = createTool( tr( "TB_MODIFY" ) ),
2562       dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2563
2564   createTool( 702, meshTb );
2565   createTool( 703, meshTb );
2566   createTool( 704, meshTb );
2567   createTool( separator(), meshTb );
2568   createTool( 701, meshTb );
2569   createTool( separator(), meshTb );
2570   createTool( 801, meshTb );
2571   createTool( 802, meshTb );
2572   createTool( 803, meshTb );
2573   createTool( separator(), meshTb );
2574   createTool( 900, meshTb );
2575   createTool( 902, meshTb );
2576   createTool( separator(), meshTb );
2577
2578   createTool( 6001, ctrlTb );
2579   createTool( 6003, ctrlTb );
2580   createTool( 6004, ctrlTb );
2581   createTool( separator(), ctrlTb );
2582   createTool( 6002, ctrlTb );
2583   createTool( 6018, ctrlTb );
2584   createTool( 6019, ctrlTb );
2585   createTool( 6011, ctrlTb );
2586   createTool( 6012, ctrlTb );
2587   createTool( 6013, ctrlTb );
2588   createTool( 6014, ctrlTb );
2589   createTool( 6015, ctrlTb );
2590   createTool( 6016, ctrlTb );
2591   createTool( separator(), ctrlTb );
2592   createTool( 6017, ctrlTb );
2593   createTool( 6009, ctrlTb );
2594   createTool( separator(), ctrlTb );
2595
2596   createTool( 400, addRemTb );
2597   createTool( 401, addRemTb );
2598   createTool( 4021, addRemTb );
2599   createTool( 4022, addRemTb );
2600   createTool( 4023, addRemTb );
2601   createTool( 4031, addRemTb );
2602   createTool( 4032, addRemTb );
2603   createTool( 4033, addRemTb );
2604   createTool( separator(), addRemTb );
2605   createTool( 4034, addRemTb );
2606   createTool( 4035, addRemTb );
2607   createTool( 4036, addRemTb );
2608   createTool( 4037, addRemTb );
2609   createTool( 4038, addRemTb );
2610   createTool( 4039, addRemTb );
2611   createTool( 4040, addRemTb );
2612   createTool( separator(), addRemTb );
2613   createTool( 4041, addRemTb );
2614   createTool( 4042, addRemTb );
2615   createTool( separator(), addRemTb );
2616   createTool( 4051, addRemTb );
2617   createTool( 4052, addRemTb );
2618   createTool( separator(), addRemTb );
2619   createTool( 4061, addRemTb );
2620   createTool( 4062, addRemTb );
2621   createTool( 4063, addRemTb );
2622   createTool( 4064, addRemTb );
2623   createTool( 4065, addRemTb );
2624   createTool( 4066, addRemTb );
2625   createTool( separator(), addRemTb );
2626
2627   createTool( 406, modifyTb );
2628   createTool( 4067,modifyTb );
2629   createTool( 407, modifyTb );
2630   createTool( 408, modifyTb );
2631   createTool( 409, modifyTb );
2632   createTool( 410, modifyTb );
2633   createTool( 411, modifyTb );
2634   createTool( 412, modifyTb );
2635   createTool( 413, modifyTb );
2636   createTool( 416, modifyTb );
2637   createTool( 414, modifyTb );
2638   createTool( 415, modifyTb );
2639   createTool( 417, modifyTb );
2640
2641   createTool( 214, dispModeTb );
2642
2643
2644   myRules.clear();
2645   QString OB = "'ObjectBrowser'",
2646           View = "'" + SVTK_Viewer::Type() + "'",
2647           pat = "'%1'",
2648           mesh    = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2649           group   = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2650           hypo    = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2651           algo    = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2652           elems   = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2653                        arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2654                        arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2655                        arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2656                        arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2657                        arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2658                        arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2659           subMesh = elems,
2660           mesh_group = mesh + " " + subMesh + " " + group,
2661           hyp_alg = hypo + " " + algo;
2662
2663   // popup for object browser
2664
2665   createPopupItem( 704, OB, mesh, "&& isComputable");      // EDIT_MESHSUBMESH
2666   createPopupItem( 704, OB, subMesh, "&& isComputable" );  // EDIT_MESHSUBMESH
2667   createPopupItem( 803, OB, group );                       // EDIT_GROUP
2668   popupMgr()->insert( separator(), -1, 0 );
2669   createPopupItem( 701, OB, mesh, "&& isComputable" );     // COMPUTE
2670   createPopupItem( 214, OB, mesh_group );                  // UPDATE
2671   createPopupItem( 900, OB, mesh_group );                  // ADV_INFO
2672   createPopupItem( 902, OB, mesh );                        // STD_INFO
2673   popupMgr()->insert( separator(), -1, 0 );
2674   createPopupItem( 801, OB, mesh );                        // CREATE_GROUP
2675   createPopupItem( 802, OB, subMesh );                     // CONSTRUCT_GROUP
2676   popupMgr()->insert( separator(), -1, 0 );
2677   createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ );   // EDIT HYPOTHESIS
2678   createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2679   createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2680   popupMgr()->insert( separator(), -1, 0 );
2681
2682   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2683   createPopupItem( 125, OB, mesh, only_one_non_empty );    // EXPORT_MED
2684   createPopupItem( 126, OB, mesh, only_one_non_empty );    // EXPORT_UNV
2685   createPopupItem( 33, OB, subMesh + " " + group );        // DELETE
2686   popupMgr()->insert( separator(), -1, 0 );
2687
2688   // popup for viewer
2689   createPopupItem( 803, View, group ); // EDIT_GROUP
2690   createPopupItem( 804, View, elems ); // ADD
2691   createPopupItem( 805, View, elems ); // REMOVE
2692   popupMgr()->insert( separator(), -1, 0 );
2693   createPopupItem( 214, View, mesh_group ); // UPDATE
2694   createPopupItem( 900, View, mesh_group ); // ADV_INFO
2695   createPopupItem( 902, View, mesh );       // STD_INFO
2696   popupMgr()->insert( separator(), -1, 0 );
2697
2698   int anId;
2699   QString
2700     isInvisible("not( isVisible )"),
2701     isEmpty("numberOfNodes = 0"),
2702     isNotEmpty("numberOfNodes <> 0"),
2703
2704     // has nodes, edges, etc in VISIBLE! actor
2705     hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2706     hasElems("(count( elemTypes ) > 0)"),
2707     hasDifferentElems("(count( elemTypes ) > 1)"),
2708     hasEdges("({'Edge'} in elemTypes)"),
2709     hasFaces("({'Face'} in elemTypes)"),
2710     hasVolumes("({'Volume'} in elemTypes)");
2711
2712   QString lc = QtxPopupMgr::Selection::defEquality();
2713   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2714   QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2715   aType = aType.arg( mesh_group );
2716   QString aMeshInVTK = aClient + "&&" + aType;
2717
2718   //-------------------------------------------------
2719   // Numbering
2720   //-------------------------------------------------
2721   anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2722
2723   popupMgr()->insert( action( 9010 ), anId, -1 );
2724   popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2725   popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2726
2727   popupMgr()->insert( action( 9011 ), anId, -1 );
2728   popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2729   popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2730
2731   popupMgr()->insert( separator(), -1, -1 );
2732
2733   //-------------------------------------------------
2734   // Display Mode
2735   //-------------------------------------------------
2736   anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2737
2738   popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2739   popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2740   popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2741
2742   popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2743   popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2744   popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2745
2746   popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2747   popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2748   popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2749
2750   popupMgr()->insert( separator(), anId, -1 );
2751
2752   popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2753   popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2754   popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2755
2756   //-------------------------------------------------
2757   // Display Entity
2758   //-------------------------------------------------
2759   QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2760
2761   anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2762
2763   popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2764   popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2765   popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2766
2767   popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2768   popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2769   popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2770
2771   popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2772   popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2773   popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2774
2775   popupMgr()->insert( separator(), anId, -1 );
2776
2777   popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2778   popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2779
2780   //-------------------------------------------------
2781   // Color / Size
2782   //-------------------------------------------------
2783   popupMgr()->insert( action( 1132 ), -1, -1 );
2784   popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2785
2786   //-------------------------------------------------
2787   // Transparency
2788   //-------------------------------------------------
2789   popupMgr()->insert( action( 1133 ), -1, -1 );
2790   popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2791
2792   //-------------------------------------------------
2793   // Clipping
2794   //-------------------------------------------------
2795   popupMgr()->insert( action( 1134 ), -1, -1 );
2796   popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2797
2798   popupMgr()->insert( separator(), -1, -1 );
2799
2800   //-------------------------------------------------
2801   // Controls
2802   //-------------------------------------------------
2803   QString
2804     aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2805     aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2806     aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2807
2808   anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2809
2810   popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2811   popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2812
2813   popupMgr()->insert( separator(), anId, -1 );
2814
2815   popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2816   popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2817   popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2818
2819   popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2820   popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2821   popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2822
2823   popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2824   popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2825   popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2826
2827   popupMgr()->insert( separator(), anId, -1 );
2828
2829   popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2830   popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2831   popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2832
2833   popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2834   popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2835   popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2836
2837   popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2838   popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2839   popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2840
2841   popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2842   popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2843   popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2844
2845   popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2846   popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2847   popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2848
2849   popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2850   popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2851   popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2852
2853   popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2854   popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2855   popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2856
2857   popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2858   popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2859   popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2860
2861   popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2862   popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2863   popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2864
2865   popupMgr()->insert( separator(), anId, -1 );
2866
2867   popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2868   popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2869   popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2870
2871   popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2872   popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2873   popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2874
2875   popupMgr()->insert( separator(), anId, -1 );
2876
2877   popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2878   popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2879
2880   popupMgr()->insert( separator(), -1, -1 );
2881
2882   //-------------------------------------------------
2883   // Display / Erase
2884   //-------------------------------------------------
2885   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2886   QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2887   QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2888
2889   QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2890     aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2891   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2892   popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2893
2894   popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2895   popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2896
2897   popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2898   popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2899
2900   popupMgr()->insert( separator(), -1, -1 );
2901
2902   connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2903            this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2904 }
2905
2906 bool SMESHGUI::activateModule( SUIT_Study* study )
2907 {
2908   bool res = SalomeApp_Module::activateModule( study );
2909
2910   setMenuShown( true );
2911   setToolShown( true );
2912
2913   // Reset actions accelerator keys
2914   action(111)->setAccel(QKeySequence(CTRL + Key_B)); // Import DAT
2915   action(112)->setAccel(QKeySequence(CTRL + Key_U)); // Import UNV
2916   action(113)->setAccel(QKeySequence(CTRL + Key_M)); // Import MED
2917
2918   return res;
2919 }
2920
2921 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2922 {
2923   setMenuShown( false );
2924   setToolShown( false );
2925
2926   EmitSignalCloseAllDialogs();
2927
2928   // Unset actions accelerator keys
2929   action(111)->setAccel(QKeySequence()); // Import DAT
2930   action(112)->setAccel(QKeySequence()); // Import UNV
2931   action(113)->setAccel(QKeySequence()); // Import MED
2932
2933   return SalomeApp_Module::deactivateModule( study );
2934 }
2935
2936 void SMESHGUI::OnGUIEvent()
2937 {
2938   const QObject* obj = sender();
2939   if ( !obj || !obj->inherits( "QAction" ) )
2940     return;
2941   int id = actionId((QAction*)obj);
2942   if ( id != -1 )
2943     OnGUIEvent( id );
2944 }
2945
2946 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2947 {
2948   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2949   if ( CORBA::is_nil( myComponentSMESH ) )
2950     {
2951       SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2952       if ( aStudy )
2953         aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2954       return aGUI.myComponentSMESH;
2955     }
2956   if ( aStudy )
2957     myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2958   return myComponentSMESH;
2959 }
2960
2961 QString SMESHGUI::engineIOR() const
2962 {
2963   CORBA::ORB_var anORB = getApp()->orb();
2964   CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2965   return anIOR.in();
2966 }
2967
2968 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2969 {
2970   SMESHGUI_Selection sel;
2971   sel.init( client, selectionMgr() );
2972   popupMgr()->updatePopup( menu, &sel );
2973 }
2974
2975 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2976 {
2977   aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2978   aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2979 }
2980
2981 void SMESHGUI::viewManagers( QStringList& list ) const
2982 {
2983   list.append( SVTK_Viewer::Type() );
2984 }
2985
2986 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2987 {
2988   if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2989     SMESH::UpdateSelectionProp( this );
2990 }
2991
2992 void SMESHGUI::createPreferences()
2993 {
2994   int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2995
2996   int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2997   addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2998
2999   int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
3000   addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
3001   addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
3002
3003   int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
3004   setPreferenceProperty( precGroup, "columns", 1 );
3005
3006   int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
3007
3008   setPreferenceProperty( prec, "min", 0 );
3009   setPreferenceProperty( prec, "max", 16 );
3010
3011   int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
3012   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
3013   QStringList modes;
3014   modes.append( "Wireframe" );
3015   modes.append( "Shading" );
3016   modes.append( "Nodes" );
3017   modes.append( "Shrink" );
3018   QValueList<QVariant> indices;
3019   indices.append( 0 );
3020   indices.append( 1 );
3021   indices.append( 2 );
3022   indices.append( 3 );
3023   setPreferenceProperty( dispmode, "strings", modes );
3024   setPreferenceProperty( dispmode, "indexes", indices );
3025
3026   int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
3027   addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
3028   int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
3029
3030   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
3031   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
3032
3033   addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
3034   int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
3035
3036   setPreferenceProperty( nodeSz, "min", 1 );
3037   setPreferenceProperty( nodeSz, "max", 5 );
3038
3039   int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
3040
3041   addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
3042   addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
3043   addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
3044   addPreference( "", elemGroup, LightApp_Preferences::Space );
3045
3046   int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
3047   int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
3048
3049   setPreferenceProperty( elemW, "min", 1 );
3050   setPreferenceProperty( elemW, "max", 5 );
3051
3052   setPreferenceProperty( shrink, "min", 0 );
3053   setPreferenceProperty( shrink, "max", 100 );
3054
3055   int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3056
3057   int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3058
3059   addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3060   addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3061   int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3062
3063   setPreferenceProperty( selW, "min", 1 );
3064   setPreferenceProperty( selW, "max", 5 );
3065
3066   int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3067
3068   addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3069   int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3070
3071   setPreferenceProperty( preW, "min", 1 );
3072   setPreferenceProperty( preW, "max", 5 );
3073
3074   int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3075
3076   addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3077   addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3078
3079   int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3080   int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3081
3082   int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3083   addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3084   int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3085   addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3086
3087   QStringList fam;
3088   fam.append( tr( "SMESH_FONT_ARIAL" ) );
3089   fam.append( tr( "SMESH_FONT_COURIER" ) );
3090   fam.append( tr( "SMESH_FONT_TIMES" ) );
3091   int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3092
3093   setPreferenceProperty( tfont, "families", fam );
3094   setPreferenceProperty( tfont, "system", false );
3095   setPreferenceProperty( tfont, "widget_flags", wflag );
3096   setPreferenceProperty( lfont, "families", fam );
3097   setPreferenceProperty( lfont, "system", false );
3098   setPreferenceProperty( lfont, "widget_flags", wflag );
3099
3100   int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3101
3102   int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3103   setPreferenceProperty( numcol, "min", 2 );
3104   setPreferenceProperty( numcol, "max", 256 );
3105
3106   int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3107   setPreferenceProperty( numlab, "min", 2 );
3108   setPreferenceProperty( numlab, "max", 65 );
3109
3110   int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3111   int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3112   QStringList orients;
3113   orients.append( tr( "SMESH_VERTICAL" ) );
3114   orients.append( tr( "SMESH_HORIZONTAL" ) );
3115   indices.clear(); indices.append( 0 ); indices.append( 1 );
3116   setPreferenceProperty( orient, "strings", orients );
3117   setPreferenceProperty( orient, "indexes", indices );
3118
3119   int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3120   int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3121   int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3122   int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3123   int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3124   setPreferenceProperty( xv, "step", 0.1 );
3125   setPreferenceProperty( xv, "min", 0.0 );
3126   setPreferenceProperty( xv, "max", 1.0 );
3127   setPreferenceProperty( yv, "step", 0.1 );
3128   setPreferenceProperty( yv, "min", 0.0 );
3129   setPreferenceProperty( yv, "max", 1.0 );
3130   setPreferenceProperty( wv, "step", 0.1 );
3131   setPreferenceProperty( wv, "min", 0.0 );
3132   setPreferenceProperty( wv, "max", 1.0 );
3133   setPreferenceProperty( hv, "min", 0.0 );
3134   setPreferenceProperty( hv, "max", 1.0 );
3135   setPreferenceProperty( hv, "step", 0.1 );
3136
3137   int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3138   int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3139   int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3140   int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3141   int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3142   setPreferenceProperty( xv, "min", 0.0 );
3143   setPreferenceProperty( xv, "max", 1.0 );
3144   setPreferenceProperty( xv, "step", 0.1 );
3145   setPreferenceProperty( xh, "min", 0.0 );
3146   setPreferenceProperty( xh, "max", 1.0 );
3147   setPreferenceProperty( xh, "step", 0.1 );
3148   setPreferenceProperty( yh, "min", 0.0 );
3149   setPreferenceProperty( yh, "max", 1.0 );
3150   setPreferenceProperty( yh, "step", 0.1 );
3151   setPreferenceProperty( wh, "min", 0.0 );
3152   setPreferenceProperty( wh, "max", 1.0 );
3153   setPreferenceProperty( wh, "step", 0.1 );
3154   setPreferenceProperty( hh, "min", 0.0 );
3155   setPreferenceProperty( hh, "max", 1.0 );
3156   setPreferenceProperty( hh, "step", 0.1 );
3157 }
3158
3159 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3160 {
3161   if( sect=="SMESH" ){
3162     float sbX1,sbY1,sbW,sbH;
3163     float aTol = 1.00000009999999;
3164     std::string aWarning;
3165     SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3166     if( name=="selection_object_color" || name=="selection_element_color" ||
3167         name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3168         name=="selection_precision_node" || name=="selection_precision_element" )
3169       SMESH::UpdateSelectionProp( this );
3170     else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3171       sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3172       sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3173       if(sbX1+sbW > aTol){
3174         aWarning = "Origin and Size Vertical: X+Width > 1\n";
3175         sbX1=0.01;
3176         sbW=0.05;
3177         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3178         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3179       }
3180     }
3181     else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3182       sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3183       sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3184       if(sbY1+sbH > aTol){
3185         aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3186         sbY1=0.01;
3187         sbH=0.5;
3188         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3189         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3190       }
3191     }
3192     else if(name ==  QString("scalar_bar_horizontal_x") || name ==  QString("scalar_bar_horizontal_width")){
3193       sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3194       sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3195       if(sbX1+sbW > aTol){
3196         aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3197         sbX1=0.2;
3198         sbW=0.6;
3199         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3200         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3201       }
3202     }
3203     else if(name ==  QString("scalar_bar_horizontal_y") || name ==  QString("scalar_bar_horizontal_height")){
3204       sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3205       sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3206       if(sbY1+sbH > aTol){
3207         aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3208         sbY1=0.01;
3209         sbH=0.12;
3210         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3211         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3212       }
3213     }
3214
3215     if(aWarning.size() != 0){
3216       aWarning += "The default values are applied instead.";
3217       SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3218                              QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3219                              QObject::tr(aWarning.c_str()),
3220                              QObject::tr("SMESH_BUT_OK"));
3221     }
3222   }
3223 }
3224
3225 //================================================================================
3226 /*!
3227  * \brief Update something in accordance with update flags
3228   * \param theFlags - update flags
3229 *
3230 * Update viewer or/and object browser etc. in accordance with update flags ( see
3231 * LightApp_UpdateFlags enumeration ).
3232 */
3233 //================================================================================
3234 void SMESHGUI::update( const int flags )
3235 {
3236   if ( flags & UF_Viewer | flags & UF_Forced )
3237     SMESH::UpdateView();
3238   else
3239     SalomeApp_Module::update( flags );
3240 }
3241
3242 //================================================================================
3243 /*!
3244  * \brief Set default selection mode
3245 *
3246 * SLOT called when operation commited. Sets default selection mode
3247 */
3248 //================================================================================
3249 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3250 {
3251   SVTK_ViewWindow* vtkWnd =
3252     dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3253   if ( vtkWnd )
3254     vtkWnd->SetSelectionMode( ActorSelection );
3255 }
3256
3257 //================================================================================
3258 /*!
3259  * \brief Set default selection mode
3260 *
3261 * SLOT called when operation aborted. Sets default selection mode
3262 */
3263 //================================================================================
3264 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3265 {
3266   SVTK_ViewWindow* vtkWnd =
3267     dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3268   if ( vtkWnd )
3269     vtkWnd->SetSelectionMode( ActorSelection );
3270 }
3271
3272 //================================================================================
3273 /*!
3274  * \brief Creates operation with given identifier
3275   * \param id - identifier of operation to be started
3276   * \return Pointer on created operation or NULL if operation is not created
3277 *
3278 * Virtual method redefined from the base class creates operation with given id.
3279 * It is called called automatically from startOperation method of base class.
3280 */
3281 //================================================================================
3282 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3283 {
3284   LightApp_Operation* op = 0;
3285   // to do : create operation here
3286   switch( id )
3287   {
3288     case 702: // Create mesh
3289       op = new SMESHGUI_MeshOp( true, true );
3290     break;
3291     case 703: // Create sub-mesh
3292       op = new SMESHGUI_MeshOp( true, false );
3293     break;
3294     case 704: // Edit mesh/sub-mesh
3295       op = new SMESHGUI_MeshOp( false );
3296     break;
3297     case 417: //convert to quadratic
3298       op = new SMESHGUI_ConvToQuadOp();
3299     break;
3300     case 4067: // make mesh pass through point
3301       op = new SMESHGUI_MakeNodeAtPointOp();
3302       break;
3303     default:
3304     break;
3305   }
3306
3307   if( !op )
3308     op = SalomeApp_Module::createOperation( id );
3309   return op;
3310 }
3311
3312 //================================================================================
3313 /*!
3314  * \brief Stops current operations and starts a given one
3315   * \param id - The id of the operation to start
3316  */
3317 //================================================================================
3318
3319 void SMESHGUI::switchToOperation(int id)
3320 {
3321   if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3322     activeStudy()->abortAllOperations();
3323   startOperation( id );
3324 }
3325
3326 LightApp_Displayer* SMESHGUI::displayer()
3327 {
3328   if( !myDisplayer )
3329     myDisplayer = new SMESHGUI_Displayer( getApp() );
3330   return myDisplayer;
3331 }