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