Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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           break;
1283         }
1284
1285         SMESH::SMESH_Mesh_var aMesh;
1286         SMESH::SMESH_subMesh_var aSubMesh;
1287         Handle(SALOME_InteractiveObject) IObject = selected.First();
1288         if (IObject->hasEntry()) {
1289           _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
1290           GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
1291           if ( aShapeObject->_is_nil() ) {
1292             // imported mesh
1293             break;
1294           }
1295           if( aMeshSObj ) {
1296             aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
1297             aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
1298             if ( !aSubMesh->_is_nil() )
1299               aMesh = aSubMesh->GetFather();
1300
1301             if (!aMesh->_is_nil()) {
1302 //               if(!GetSMESHGen()->IsReadyToCompute(aMesh,aShapeObject)) {
1303 //                 SUIT_MessageBox::warn1(desktop(),
1304 //                                        tr("SMESH_WRN_WARNING"),
1305 //                                        tr("SMESH_WRN_MISSING_PARAMETERS"),
1306 //                                        tr("SMESH_BUT_OK"));
1307 //                 break;
1308 //               }
1309               SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
1310               if ( errors->length() > 0 ) {
1311                 SUIT_MessageBox::warn1(desktop(),
1312                                        tr("SMESH_WRN_WARNING"),
1313                                        SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
1314                                        tr("SMESH_BUT_OK"));
1315                 break;
1316               }
1317               try{
1318                 if (GetSMESHGen()->Compute(aMesh,aShapeObject))
1319                   SMESH::ModifiedMesh(aMeshSObj,true);
1320                 else
1321                   SUIT_MessageBox::warn1(desktop(),
1322                                          tr("SMESH_WRN_WARNING"),
1323                                          tr("SMESH_WRN_COMPUTE_FAILED"),
1324                                          tr("SMESH_BUT_OK"));
1325               }
1326               catch(const SALOME::SALOME_Exception & S_ex){
1327                 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1328               }
1329             }
1330           }
1331         }
1332         CORBA::Long anId = aStudy->StudyId();
1333         TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
1334         if ( automaticUpdate() && aVisualObj){
1335           aVisualObj->Update();
1336           SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
1337           if(!anActor){
1338             anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
1339             if(anActor){
1340               SMESH::DisplayActor(view,anActor); //apo
1341               SMESH::FitAll();
1342             }
1343           }
1344           SMESH::RepaintCurrentView();
1345         }
1346       }else{
1347         SUIT_MessageBox::warn1(desktop(),
1348                               tr("SMESH_WRN_WARNING"),
1349                               tr("SMESH_WRN_VIEWER_VTK"),
1350                               tr("SMESH_BUT_OK"));
1351       }
1352       updateObjBrowser();
1353       Sel->setSelectedObjects( selected );
1354       break;
1355     }
1356
1357   case 702:  // Create mesh
1358     startOperation( 702 );
1359     break;
1360   case 703:  // Create sub-mesh
1361     startOperation( 703 );
1362     break;
1363   case 704: // Edit mesh/sub-mesh
1364     startOperation( 704 );
1365     break;
1366   case 407: // DIAGONAL INVERSION
1367   case 408: // Delete diagonal
1368     {
1369       if ( !vtkwnd )
1370       {
1371         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1372           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1373         break;
1374       }
1375
1376       if ( checkLock( aStudy ) )
1377         break;
1378
1379       /*Standard_Boolean aRes;
1380       SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
1381       if ( aMesh->_is_nil() )
1382       {
1383         SUIT_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
1384           tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
1385         break;
1386       }
1387       */
1388       EmitSignalDeactivateDialog();
1389       if ( theCommandID == 407 )
1390         new SMESHGUI_TrianglesInversionDlg(this);
1391       else
1392         new SMESHGUI_UnionOfTwoTrianglesDlg(this);
1393       break;
1394     }
1395     case 409: // Change orientation
1396     case 410: // Union of triangles
1397     case 411: // Cutting of quadrangles
1398     {
1399       if ( !vtkwnd )
1400       {
1401         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1402           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1403         break;
1404       }
1405
1406       if ( checkLock( aStudy ) )
1407         break;
1408
1409       EmitSignalDeactivateDialog();
1410       SMESHGUI_MultiEditDlg* aDlg = NULL;
1411       if ( theCommandID == 409 )
1412         aDlg = new SMESHGUI_ChangeOrientationDlg(this);
1413       else if ( theCommandID == 410 )
1414         aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
1415       else
1416         aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
1417
1418       aDlg->show();
1419       break;
1420     }
1421   case 412: // Smoothing
1422     {
1423       if(checkLock(aStudy)) break;
1424       if( vtkwnd ) {
1425         EmitSignalDeactivateDialog();
1426         new SMESHGUI_SmoothingDlg( this );
1427       }
1428       else {
1429         SUIT_MessageBox::warn1(desktop(),
1430                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1431                               tr("SMESH_BUT_OK"));
1432       }
1433       break;
1434     }
1435   case 413: // Extrusion
1436     {
1437       if (checkLock(aStudy)) break;
1438       if (vtkwnd) {
1439         EmitSignalDeactivateDialog();
1440         new SMESHGUI_ExtrusionDlg ( this );
1441       } else {
1442         SUIT_MessageBox::warn1(desktop(),
1443                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1444                                tr("SMESH_BUT_OK"));
1445       }
1446       break;
1447     }
1448   case 414: // Revolution
1449     {
1450       if(checkLock(aStudy)) break;
1451       if( vtkwnd ) {
1452         EmitSignalDeactivateDialog();
1453         new SMESHGUI_RevolutionDlg( this );
1454       }
1455       else {
1456         SUIT_MessageBox::warn1(desktop(),
1457                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1458                               tr("SMESH_BUT_OK"));
1459       }
1460       break;
1461     }
1462   case 415: // Pattern mapping
1463     {
1464       if ( checkLock( aStudy ) )
1465         break;
1466       if ( vtkwnd )
1467       {
1468         EmitSignalDeactivateDialog();
1469         new SMESHGUI_MeshPatternDlg( this );
1470       }
1471       else {
1472         SUIT_MessageBox::warn1(desktop(),
1473                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1474                               tr("SMESH_BUT_OK"));
1475       }
1476       break;
1477     }
1478   case 416: // Extrusion along a path
1479     {
1480       if (checkLock(aStudy)) break;
1481       if (vtkwnd) {
1482         EmitSignalDeactivateDialog();
1483         new SMESHGUI_ExtrusionAlongPathDlg( this );
1484       } else {
1485         SUIT_MessageBox::warn1(desktop(),
1486                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1487                                tr("SMESH_BUT_OK"));
1488       }
1489       break;
1490     }
1491   case 417: // Convert mesh to quadratic
1492     {
1493     startOperation( 417 );
1494       /*      if (checkLock(aStudy)) break;
1495       if (vtkwnd) {
1496         EmitSignalDeactivateDialog();
1497         new SMESHGUI_ConvToQuadDlg();
1498       } else {
1499         SUIT_MessageBox::warn1(desktop(),
1500                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1501                                tr("SMESH_BUT_OK"));
1502                                }*/
1503       break;
1504     }
1505   case 801:                                     // CREATE GROUP
1506     {
1507       if ( !vtkwnd )
1508       {
1509         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1510           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1511         break;
1512       }
1513
1514       if(checkLock(aStudy)) break;
1515       EmitSignalDeactivateDialog();
1516       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
1517
1518       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1519       SALOME_ListIO selected;
1520       if( aSel )
1521         aSel->selectedObjects( selected );
1522
1523       int nbSel = selected.Extent();
1524       if (nbSel == 1) {
1525         // check if mesh is selected
1526         aMesh = SMESH::GetMeshByIO( selected.First() );
1527       }
1528       SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aMesh);
1529       aDlg->show();
1530       break;
1531     }
1532
1533   case 802:                                     // CONSTRUCT GROUP
1534     {
1535       if ( !vtkwnd )
1536       {
1537         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1538           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1539         break;
1540       }
1541
1542       if(checkLock(aStudy)) break;
1543       EmitSignalDeactivateDialog();
1544
1545       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1546       SALOME_ListIO selected;
1547       if( aSel )
1548         aSel->selectedObjects( selected );
1549
1550       int nbSel = selected.Extent();
1551       if (nbSel == 1) {
1552         // check if submesh is selected
1553         Handle(SALOME_InteractiveObject) IObject = selected.First();
1554         if (IObject->hasEntry()) {
1555           _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
1556           if( aSObj ) {
1557             SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
1558             if (!aSubMesh->_is_nil()) {
1559               try {
1560                 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1561                 // get submesh elements list by types
1562                 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
1563                 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
1564                 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
1565                 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
1566                 // create group for each type o elements
1567                 QString aName = IObject->getName();
1568                 if (aNodes->length() > 0) {
1569                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
1570                   aGroup->Add(aNodes.inout());
1571                 }
1572                 if (aEdges->length() > 0) {
1573                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
1574                   aGroup->Add(aEdges.inout());
1575                 }
1576                 if (aFaces->length() > 0) {
1577                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
1578                   aGroup->Add(aFaces.inout());
1579                 }
1580                 if (aVolumes->length() > 0) {
1581                   SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
1582                   aGroup->Add(aVolumes.inout());
1583                 }
1584                 updateObjBrowser();
1585
1586               }catch(const SALOME::SALOME_Exception & S_ex){
1587                 SalomeApp_Tools::QtCatchCorbaException(S_ex);
1588               }
1589             }
1590           }
1591         }
1592       }
1593       break;
1594     }
1595
1596   case 803:                                     // EDIT GROUP
1597     {
1598       if ( !vtkwnd )
1599       {
1600         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1601           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1602         break;
1603       }
1604
1605       if(checkLock(aStudy)) break;
1606       EmitSignalDeactivateDialog();
1607
1608       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1609       SALOME_ListIO selected;
1610       if( aSel )
1611         aSel->selectedObjects( selected );
1612
1613       SALOME_ListIteratorOfListIO It (selected);
1614       int nbSelectedGroups = 0;
1615       for ( ; It.More(); It.Next() )
1616       {
1617         SMESH::SMESH_GroupBase_var aGroup =
1618           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
1619         if (!aGroup->_is_nil()) {
1620           nbSelectedGroups++;
1621           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", aGroup);
1622           aDlg->show();
1623         }
1624       }
1625       if (nbSelectedGroups == 0)
1626         {
1627           SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, "", SMESH::SMESH_GroupBase::_nil());
1628           aDlg->show();
1629         }
1630       break;
1631     }
1632
1633   case 804:                                     // Add elements to group
1634     {
1635       if(checkLock(aStudy)) break;
1636       if (myState == 800) {
1637         SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1638         if (aDlg) aDlg->onAdd();
1639       }
1640       break;
1641     }
1642
1643   case 805:                                     // Remove elements from group
1644     {
1645       if(checkLock(aStudy)) break;
1646       if (myState == 800) {
1647         SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
1648         if (aDlg) aDlg->onRemove();
1649       }
1650       break;
1651     }
1652
1653     case 810: // Union Groups
1654     case 811: // Intersect groups
1655     case 812: // Cut groups
1656     {
1657       if ( !vtkwnd )
1658       {
1659         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1660           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1661         break;
1662       }
1663
1664       if ( checkLock( aStudy ) )
1665         break;
1666
1667       EmitSignalDeactivateDialog();
1668
1669       int aMode;
1670       if      ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
1671       else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
1672       else                            aMode = SMESHGUI_GroupOpDlg::CUT;
1673
1674       ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
1675       break;
1676     }
1677
1678     case 813: // Delete groups with their contents
1679     {
1680       if ( !vtkwnd )
1681       {
1682         SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
1683           tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
1684         break;
1685       }
1686
1687       if ( checkLock( aStudy ) )
1688         break;
1689
1690       EmitSignalDeactivateDialog();
1691
1692       new SMESHGUI_DeleteGroupDlg( this );
1693       break;
1694     }
1695
1696   case 900:                                     // MESH INFOS
1697     {
1698       EmitSignalDeactivateDialog();
1699       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1700       SALOME_ListIO selected;
1701       if( aSel )
1702         aSel->selectedObjects( selected );
1703
1704       if ( selected.Extent() > 1 ) { // a dlg for each IO
1705         SALOME_ListIO IOs;
1706         SALOME_ListIteratorOfListIO It (selected);
1707         for ( ; It.More(); It.Next() ) {
1708           IOs.Clear(); IOs.Append( It.Value() );
1709           aSel->setSelectedObjects( IOs );
1710           new SMESHGUI_MeshInfosDlg(this, "", false);
1711         }
1712         // restore selection
1713         aSel->setSelectedObjects( selected );
1714       }
1715       else
1716         new SMESHGUI_MeshInfosDlg(this, "", false);
1717       break;
1718     }
1719
1720   case 902:                                     // STANDARD MESH INFOS
1721     {
1722       EmitSignalDeactivateDialog();
1723       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1724       SALOME_ListIO selected;
1725       if( aSel )
1726         aSel->selectedObjects( selected );
1727
1728       if ( selected.Extent() > 1 ) { // a dlg for each IO
1729         SALOME_ListIO IOs;
1730         SALOME_ListIteratorOfListIO It (selected);
1731         for ( ; It.More(); It.Next() ) {
1732           IOs.Clear();
1733           IOs.Append( It.Value() );
1734           aSel->setSelectedObjects( IOs );
1735           new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1736         }
1737         // restore selection
1738         aSel->setSelectedObjects( selected );
1739       }
1740       else
1741         new SMESHGUI_StandardMeshInfosDlg( this, "", false);
1742       break;
1743     }
1744
1745   case 1100:                                    // EDIT HYPOTHESIS
1746     {
1747       if(checkLock(aStudy)) break;
1748
1749       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1750       SALOME_ListIO selected;
1751       if( aSel )
1752         aSel->selectedObjects( selected );
1753
1754       int nbSel = selected.Extent();
1755
1756       if (nbSel == 1) {
1757         SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
1758
1759         /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
1760         /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
1761         /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
1762         if ( !Hyp->_is_nil() )
1763         {
1764           char* sName = Hyp->GetName();
1765           SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
1766           if (aCreator)
1767             aCreator->edit( Hyp.in(), desktop() );
1768           else
1769           {
1770             // report error
1771           }
1772         }
1773       }
1774       updateObjBrowser( true );
1775       break;
1776     }
1777
1778   case 1101:                                    // RENAME
1779     {
1780       if ( checkLock( aStudy ) )
1781         break;
1782
1783       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1784       SALOME_ListIO selected;
1785       if( aSel )
1786         aSel->selectedObjects( selected );
1787
1788       SALOME_ListIteratorOfListIO It( selected );
1789       for ( ; It.More(); It.Next() )
1790       {
1791         Handle(SALOME_InteractiveObject) IObject = It.Value();
1792         _PTR(SObject) obj = aStudy->FindObjectID( IObject->getEntry() );
1793         _PTR(GenericAttribute) anAttr;
1794         _PTR(AttributeName) aName;
1795         if ( obj )
1796         {
1797           if ( obj->FindAttribute(anAttr, "AttributeName") )
1798           {
1799             aName = anAttr;
1800             QString newName = QString(aName->Value().c_str());
1801             newName = LightApp_NameDlg::getName(desktop(), newName);
1802             if ( !newName.isEmpty() )
1803             {
1804               //old source: aStudy->renameIObject( IObject, newName );
1805               aName->SetValue( newName.latin1() );
1806
1807               // if current object is group update group's name
1808               SMESH::SMESH_GroupBase_var aGroup =
1809                 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1810               if (!aGroup->_is_nil() )
1811                 aGroup->SetName( newName.latin1() );
1812
1813               updateObjBrowser();
1814             }
1815           }
1816         }
1817       }
1818       break;
1819     }
1820
1821   case 1102:                                    // REMOVE HYPOTHESIS / ALGORITHMS
1822     {
1823       if(checkLock(aStudy)) break;
1824       SUIT_OverrideCursor wc;
1825
1826       LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1827       SALOME_ListIO selected;
1828       if( aSel )
1829         aSel->selectedObjects( selected, QString::null, false );
1830
1831       SALOME_ListIteratorOfListIO It(selected);
1832       for (int i = 0; It.More(); It.Next(), i++) {
1833         Handle(SALOME_InteractiveObject) IObject = It.Value();
1834         SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1835       }
1836       SALOME_ListIO l1;
1837       aSel->setSelectedObjects( l1 );
1838       updateObjBrowser();
1839       break;
1840     }
1841
1842   case 401:                                     // GEOM::EDGE
1843   case 4021:                                    // TRIANGLE
1844   case 4022:                                    // QUAD
1845   case 4023:                                    // POLYGON
1846   case 4031:                                    // TETRA
1847   case 4032:                                    // HEXA
1848     {
1849       if(checkLock(aStudy)) break;
1850       if ( vtkwnd ) {
1851         EmitSignalDeactivateDialog();
1852         SMDSAbs_ElementType type    = SMDSAbs_Edge;
1853         int                 nbNodes = 2;
1854         switch (theCommandID) {
1855         case 4021:                                      // TRIANGLE
1856           type = SMDSAbs_Face; nbNodes = 3; break;
1857         case 4022:                                      // QUAD
1858           type = SMDSAbs_Face; nbNodes = 4; break;
1859         case 4031:                                      // TETRA
1860           type = SMDSAbs_Volume; nbNodes = 4; break;
1861         case 4023:                                      // POLYGON
1862           type = SMDSAbs_Face; nbNodes = 5; break;     // 5 - identificator for POLYGON
1863         case 4032:                                      // HEXA
1864           type = SMDSAbs_Volume; nbNodes = 8; break;
1865         case 4033:                                      // POLYHEDRE
1866           type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
1867         default:;
1868         }
1869         new SMESHGUI_AddMeshElementDlg( this, "", type, nbNodes);
1870       }
1871       else {
1872         SUIT_MessageBox::warn1(desktop(),
1873                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1874                               tr("SMESH_BUT_OK"));
1875       }
1876       break;
1877     }
1878   case 4033:                                    // POLYHEDRON
1879     {
1880       if(checkLock(aStudy)) break;
1881       if ( vtkwnd ) {
1882         EmitSignalDeactivateDialog();
1883         new SMESHGUI_CreatePolyhedralVolumeDlg(this, "", FALSE );
1884       }
1885       else {
1886         SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1887                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1888                               tr("SMESH_BUT_OK"));
1889       }
1890       break;
1891     }
1892   case 4034:     // QUADRATIC EDGE
1893   case 4035:     // QUADRATIC TRIANGLE
1894   case 4036:     // QUADRATIC QUADRANGLE
1895   case 4037:     // QUADRATIC TETRAHEDRON
1896   case 4038:     // QUADRATIC PYRAMID
1897   case 4039:     // QUADRATIC PENTAHEDRON
1898   case 4040:     // QUADRATIC HEXAHEDRON
1899     {
1900       if(checkLock(aStudy)) break;
1901       if ( vtkwnd ) {
1902         EmitSignalDeactivateDialog();
1903         int type;
1904
1905         switch (theCommandID) {
1906         case 4034:                                      
1907           type = QUAD_EDGE; break;
1908         case 4035:                                      
1909           type = QUAD_TRIANGLE; break;
1910         case 4036:                                     
1911           type = QUAD_QUADRANGLE; break;
1912         case 4037:                                     
1913           type = QUAD_TETRAHEDRON; break;
1914         case 4038:                                     
1915           type = QUAD_PYRAMID; break; 
1916         case 4039:                                     
1917           type = QUAD_PENTAHEDRON; break; 
1918         case 4040:
1919           type = QUAD_HEXAHEDRON;
1920           break;
1921         default:;
1922         }
1923          new SMESHGUI_AddQuadraticElementDlg( this, type );
1924       }
1925       else {
1926         SUIT_MessageBox::warn1(SMESHGUI::desktop(),
1927                                tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1928                                tr("SMESH_BUT_OK"));
1929       }
1930       break;
1931     }
1932   case 4041:                                    // REMOVES NODES
1933     {
1934       if(checkLock(aStudy)) break;
1935       if ( vtkwnd ) {
1936         EmitSignalDeactivateDialog();
1937         new SMESHGUI_RemoveNodesDlg(this);
1938       }
1939       else {
1940         SUIT_MessageBox::warn1(desktop(),
1941                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1942                               tr("SMESH_BUT_OK"));
1943       }
1944       break;
1945     }
1946   case 4042:                                    // REMOVES ELEMENTS
1947     {
1948       if(checkLock(aStudy)) break;
1949       if( vtkwnd ) {
1950         EmitSignalDeactivateDialog();
1951         new SMESHGUI_RemoveElementsDlg(this);
1952       }
1953       else
1954         {
1955           SUIT_MessageBox::warn1(desktop(),
1956                                 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1957                                 tr("SMESH_BUT_OK"));
1958         }
1959       break;
1960     }
1961   case 4051:                                    // RENUMBERING NODES
1962     {
1963       if(checkLock(aStudy)) break;
1964       if( vtkwnd ) {
1965         EmitSignalDeactivateDialog();
1966         new SMESHGUI_RenumberingDlg( this, "", 0);
1967       }
1968       else
1969         {
1970           SUIT_MessageBox::warn1(desktop(),
1971                                 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1972                                 tr("SMESH_BUT_OK"));
1973         }
1974       break;
1975     }
1976   case 4052:                                    // RENUMBERING ELEMENTS
1977     {
1978       if(checkLock(aStudy)) break;
1979       if ( vtkwnd ) {
1980         EmitSignalDeactivateDialog();
1981         new SMESHGUI_RenumberingDlg( this, "", 1);
1982       }
1983       else
1984         {
1985           SUIT_MessageBox::warn1(desktop(),
1986                                 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
1987                                 tr("SMESH_BUT_OK"));
1988         }
1989       break;
1990     }
1991   case 4061:                                   // TRANSLATION
1992     {
1993       if(checkLock(aStudy)) break;
1994       if ( vtkwnd ) {
1995         EmitSignalDeactivateDialog();
1996         new SMESHGUI_TranslationDlg( this );
1997       }
1998       else {
1999         SUIT_MessageBox::warn1(desktop(),
2000                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2001                               tr("SMESH_BUT_OK"));
2002       }
2003       break;
2004     }
2005   case 4062:                                   // ROTATION
2006     {
2007       if(checkLock(aStudy)) break;
2008       if( vtkwnd ) {
2009         EmitSignalDeactivateDialog();
2010         new SMESHGUI_RotationDlg( this );
2011       }
2012       else {
2013         SUIT_MessageBox::warn1(desktop(),
2014                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2015                               tr("SMESH_BUT_OK"));
2016       }
2017       break;
2018     }
2019   case 4063:                                   // SYMMETRY
2020     {
2021       if(checkLock(aStudy)) break;
2022       if(vtkwnd) {
2023         EmitSignalDeactivateDialog();
2024         new SMESHGUI_SymmetryDlg( this );
2025       }
2026       else {
2027         SUIT_MessageBox::warn1(desktop(),
2028                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2029                               tr("SMESH_BUT_OK"));
2030       }
2031       break;
2032     }
2033   case 4064:                                   // SEWING
2034     {
2035       if(checkLock(aStudy)) break;
2036       if(vtkwnd) {
2037         EmitSignalDeactivateDialog();
2038         new SMESHGUI_SewingDlg( this );
2039       }
2040       else {
2041         SUIT_MessageBox::warn1(desktop(),
2042                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2043                               tr("SMESH_BUT_OK"));
2044       }
2045       break;
2046     }
2047   case 4065:                                   // MERGE NODES
2048     {
2049       if(checkLock(aStudy)) break;
2050       if(vtkwnd) {
2051         EmitSignalDeactivateDialog();
2052         new SMESHGUI_MergeNodesDlg( this );
2053       }
2054       else {
2055         SUIT_MessageBox::warn1(desktop(),
2056                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2057                               tr("SMESH_BUT_OK"));
2058       }
2059       break;
2060     }
2061   case 4066: // MERGE EQUAL ELEMENTS
2062     {
2063       if (checkLock(aStudy)) break;
2064       if (vtkwnd) {
2065         EmitSignalDeactivateDialog();
2066         new SMESHGUI_EditMeshDlg(this,
2067                                  "SMESH_MERGE_ELEMENTS_TITLE",
2068                                  "ICON_DLG_MERGE_ELEMENTS",
2069                                  1); // MergeEqualElemets
2070       } else {
2071         SUIT_MessageBox::warn1(desktop(),
2072                               tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2073                               tr("SMESH_BUT_OK"));
2074       }
2075       break;
2076     }
2077
2078   case 5105: // Library of selection filters
2079   {
2080     static QValueList<int> aTypes;
2081     if ( aTypes.isEmpty() )
2082     {
2083       aTypes.append( SMESH::NODE );
2084       aTypes.append( SMESH::EDGE );
2085       aTypes.append( SMESH::FACE );
2086       aTypes.append( SMESH::VOLUME );
2087     }
2088     if (!myFilterLibraryDlg)
2089       myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2090     else if (myFilterLibraryDlg->isHidden())
2091       myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
2092     myFilterLibraryDlg->raise();
2093   }
2094   break;
2095
2096   case 6017:                                    // CONTROLS
2097   case 6016:
2098   case 6015:
2099   case 6014:
2100   case 6013:
2101   case 6012:
2102   case 6011:
2103   case 6001:
2104   case 6018:
2105   case 6019:
2106   case 6002:
2107   case 6003:
2108   case 6004:
2109   case 6009:
2110     if ( vtkwnd ) {
2111
2112       LightApp_SelectionMgr* mgr = selectionMgr();
2113       SALOME_ListIO selected; mgr->selectedObjects( selected );
2114
2115       if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
2116         _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
2117         if ( SO ) {
2118           CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
2119           SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( aObject );
2120           SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
2121           SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( aObject );
2122           if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
2123             ::Control( theCommandID );
2124             break;
2125           }
2126         }
2127       }
2128       SUIT_MessageBox::warn1(desktop(),
2129                             tr( "SMESH_WRN_WARNING" ),
2130                             tr( "SMESH_BAD_SELECTION" ),
2131                             tr( "SMESH_BUT_OK" ) );
2132       break;
2133     }
2134     else {
2135       SUIT_MessageBox::warn1(desktop(),
2136                             tr( "SMESH_WRN_WARNING" ),
2137                             tr( "NOT_A_VTK_VIEWER" ),
2138                             tr( "SMESH_BUT_OK" ) );
2139     }
2140     break;
2141   case 9010:
2142     {
2143       LightApp_SelectionMgr* mgr = selectionMgr();
2144       SALOME_ListIO selected; mgr->selectedObjects( selected );
2145
2146       if (selected.Extent() == 1)       {
2147         Handle(SALOME_InteractiveObject) anIObject = selected.First();
2148         if(anIObject->hasEntry())
2149           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2150             anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2151           }
2152       }
2153       break;
2154     }
2155   case 9011:
2156     {
2157       LightApp_SelectionMgr* mgr = selectionMgr();
2158       SALOME_ListIO selected; mgr->selectedObjects( selected );
2159
2160       if (selected.Extent() == 1)       {
2161         Handle(SALOME_InteractiveObject) anIObject = selected.First();
2162         if(anIObject->hasEntry())
2163           if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2164             anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
2165           }
2166       }
2167       break;
2168     }
2169   }
2170
2171   anApp->updateActions(); //SRN: To update a Save button in the toolbar
2172   //updateObjBrowser();
2173   return true;
2174 }
2175
2176 //=============================================================================
2177 /*!
2178  *
2179  */
2180 //=============================================================================
2181 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2182 {
2183   return false;
2184 }
2185
2186 //=============================================================================
2187 /*!
2188  *
2189  */
2190 //=============================================================================
2191 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
2192 {
2193   return true;
2194 }
2195
2196 //=============================================================================
2197 /*!
2198  *
2199  */
2200 //=============================================================================
2201 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
2202 {
2203   return true;
2204 }
2205
2206 //=============================================================================
2207 /*! Method:  BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2208  *  Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2209  */
2210 //=============================================================================
2211 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
2212                                   SUIT_ViewWindow* wnd )
2213 {
2214   if(theIO->hasEntry()){
2215     //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
2216     SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
2217   }
2218 }
2219
2220 //=======================================================================
2221 // function : createSMESHAction
2222 // purpose  :
2223 //=======================================================================
2224 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle  )
2225 {
2226   QIconSet icon;
2227   QWidget* parent = application()->desktop();
2228   SUIT_ResourceMgr* resMgr = resourceMgr();
2229   QPixmap pix;
2230   if ( icon_id.length() )
2231     pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) );
2232   else
2233     pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false );
2234   if ( !pix.isNull() )
2235     icon = QIconSet( pix );
2236
2237   QString tooltip    = tr( QString( "TOP_" )+po_id ),
2238           menu       = tr( QString( "MEN_" )+po_id ),
2239           status_bar = tr( QString( "STB_" )+po_id );
2240
2241   createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() )  );
2242 }
2243
2244 //=======================================================================
2245 // function : createPopupItem
2246 // purpose  :
2247 //=======================================================================
2248 void SMESHGUI::createPopupItem( const int id,
2249                                 const QString& clients,
2250                                 const QString& types,
2251                                 const QString& theRule,
2252                                 const int pId )
2253 {
2254   int parentId = pId;
2255   if( pId!=-1 )
2256     parentId = popupMgr()->actionId( action( pId ) );
2257
2258   if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
2259     popupMgr()->insert( action( id ), parentId, 0 );
2260
2261   QChar lc = QtxPopupMgr::Selection::defEquality();
2262   QString rule = "(%1) and (%2) and (%3)";
2263   rule = rule.arg( QString( "%1>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() ) );
2264   if( clients.isEmpty() )
2265     rule = rule.arg( QString( "true" ) );
2266   else
2267     rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
2268   rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
2269   rule += theRule;
2270
2271   bool cont = myRules.contains( id );
2272   if( cont )
2273     rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
2274
2275   popupMgr()->setRule( action( id ), rule, true );
2276   myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
2277 }
2278
2279 //=======================================================================
2280 // function : initialize
2281 // purpose  :
2282 //=======================================================================
2283 void SMESHGUI::initialize( CAM_Application* app )
2284 {
2285   SalomeApp_Module::initialize( app );
2286
2287 //   SUIT_ResourceMgr* mgr = app->resourceMgr();
2288 //   if ( mgr )
2289   /* Automatic Update flag */
2290 //     myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
2291
2292   // ----- create actions --------------
2293
2294   createSMESHAction(  111, "DAT", "", (CTRL+Key_B) );
2295   createSMESHAction(  112, "UNV", "", (CTRL+Key_U) );
2296   createSMESHAction(  113, "MED", "", (CTRL+Key_M) );
2297   createSMESHAction(  114, "NUM" );
2298   createSMESHAction(  121, "DAT" );
2299   createSMESHAction(  122, "MED" );
2300   createSMESHAction(  123, "UNV" );
2301   createSMESHAction(  124, "EXPORT_DAT" );
2302   createSMESHAction(  125, "EXPORT_MED" );
2303   createSMESHAction(  126, "EXPORT_UNV" );
2304   createSMESHAction(   33, "DELETE",          "ICON_DELETE" );
2305   createSMESHAction( 5105, "SEL_FILTER_LIB" );
2306   createSMESHAction(  701, "COMPUTE",         "ICON_COMPUTE" );
2307   createSMESHAction(  702, "CREATE_MESH",     "ICON_DLG_INIT_MESH" );
2308   createSMESHAction(  703, "CREATE_SUBMESH",  "ICON_DLG_ADD_SUBMESH" );
2309   createSMESHAction(  704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
2310   createSMESHAction(  801, "CREATE_GROUP",    "ICON_SMESH_TREE_GROUP" );
2311   createSMESHAction(  802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
2312   createSMESHAction(  803, "EDIT_GROUP",      "ICON_EDIT_GROUP" );
2313   createSMESHAction(  804, "ADD" );
2314   createSMESHAction(  805, "REMOVE" );
2315   createSMESHAction(  810, "UN_GROUP",        "ICON_UNION" );
2316   createSMESHAction(  811, "INT_GROUP",       "ICON_INTERSECT" );
2317   createSMESHAction(  812, "CUT_GROUP",       "ICON_CUT" );
2318   createSMESHAction(  813, "DEL_GROUP",       "ICON_DEL_GROUP" );
2319   createSMESHAction(  900, "ADV_INFO",        "ICON_ADV_INFO" );
2320   createSMESHAction(  902, "STD_INFO",        "ICON_STD_INFO" );
2321   createSMESHAction( 6001, "LENGTH",          "ICON_LENGTH" ,       0, true );
2322   createSMESHAction( 6002, "FREE_EDGE",       "ICON_FREE_EDGE" ,    0, true );
2323   createSMESHAction( 6003, "FREE_BORDER",     "ICON_FREE_EDGE_2D" , 0, true );
2324   createSMESHAction( 6004, "CONNECTION",      "ICON_CONNECTION" ,   0, true );
2325   createSMESHAction( 6011, "AREA",            "ICON_AREA" ,         0, true );
2326   createSMESHAction( 6012, "TAPER",           "ICON_TAPER" ,        0, true );
2327   createSMESHAction( 6013, "ASPECT",          "ICON_ASPECT" ,       0, true );
2328   createSMESHAction( 6014, "MIN_ANG",         "ICON_ANGLE" ,        0, true );
2329   createSMESHAction( 6015, "WARP",            "ICON_WARP" ,         0, true );
2330   createSMESHAction( 6016, "SKEW",            "ICON_SKEW",          0, true );
2331   createSMESHAction( 6017, "ASPECT_3D",       "ICON_ASPECT_3D",     0, true );
2332   createSMESHAction( 6018, "LENGTH_2D",       "ICON_LENGTH_2D",     0, true );
2333   createSMESHAction( 6019, "CONNECTION_2D",   "ICON_CONNECTION_2D", 0, true );
2334   createSMESHAction( 6009, "VOLUME_3D",       "ICON_VOLUME_3D",     0, true );
2335   createSMESHAction(  400, "NODE",            "ICON_DLG_NODE" );
2336   createSMESHAction(  401, "EDGE",            "ICON_DLG_EDGE" );
2337   createSMESHAction( 4021, "TRIANGLE",        "ICON_DLG_TRIANGLE" );
2338   createSMESHAction( 4022, "QUAD",            "ICON_DLG_QUADRANGLE" );
2339   createSMESHAction( 4023, "POLYGON",         "ICON_DLG_POLYGON" );
2340   createSMESHAction( 4031, "TETRA",           "ICON_DLG_TETRAS" );
2341   createSMESHAction( 4032, "HEXA",            "ICON_DLG_HEXAS" );
2342   createSMESHAction( 4041, "REMOVE_NODES",    "ICON_DLG_REM_NODE" );
2343   createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
2344   createSMESHAction( 4051, "RENUM_NODES",     "ICON_DLG_RENUMBERING_NODES" );
2345   createSMESHAction( 4052, "RENUM_ELEMENTS",  "ICON_DLG_RENUMBERING_ELEMENTS" );
2346   createSMESHAction( 4061, "TRANS",           "ICON_SMESH_TRANSLATION_VECTOR" );
2347   createSMESHAction( 4062, "ROT",             "ICON_DLG_ROTATION" );
2348   createSMESHAction( 4063, "SYM",             "ICON_SMESH_SYMMETRY_PLANE" );
2349   createSMESHAction( 4064, "SEW",             "ICON_SMESH_SEWING_FREEBORDERS" );
2350   createSMESHAction( 4065, "MERGE",           "ICON_SMESH_MERGE_NODES" );
2351   createSMESHAction( 4066, "MERGE_ELEMENTS",  "ICON_DLG_MERGE_ELEMENTS" );
2352   createSMESHAction(  406, "MOVE",            "ICON_DLG_MOVE_NODE" );
2353   createSMESHAction(  407, "INV",             "ICON_DLG_MESH_DIAGONAL" );
2354   createSMESHAction(  408, "UNION2",          "ICON_UNION2TRI" );
2355   createSMESHAction(  409, "ORIENT",          "ICON_DLG_MESH_ORIENTATION" );
2356   createSMESHAction(  410, "UNION",           "ICON_UNIONTRI" );
2357   createSMESHAction(  411, "CUT",             "ICON_CUTQUAD" );
2358   createSMESHAction(  412, "SMOOTH",          "ICON_DLG_SMOOTHING" );
2359   createSMESHAction(  413, "EXTRUSION",       "ICON_EXTRUSION" );
2360   createSMESHAction(  414, "REVOLUTION",      "ICON_REVOLUTION" );
2361   createSMESHAction(  415, "MAP",             "ICON_MAP" );
2362   createSMESHAction(  416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
2363   createSMESHAction(  417, "CONV_TO_QUAD",    "ICON_CONV_TO_QUAD" );
2364   createSMESHAction(  200, "RESET" );
2365   createSMESHAction(  201, "SCALAR_BAR_PROP" );
2366   createSMESHAction(  211, "WIRE",           "ICON_WIRE", 0, true );
2367   createSMESHAction(  212, "SHADE",          "ICON_SHADE", 0, true );
2368   createSMESHAction(  213, "SHRINK",         "ICON_SHRINK", 0, true );
2369   createSMESHAction(  214, "UPDATE",         "ICON_UPDATE" );
2370   createSMESHAction(  215, "NODES",          "ICON_POINTS", 0, true );
2371   createSMESHAction(  217, "EDGES",          "ICON_DLG_EDGE", 0, true );
2372   createSMESHAction(  218, "FACES",          "ICON_DLG_TRIANGLE", 0, true );
2373   createSMESHAction(  219, "VOLUMES",        "ICON_DLG_TETRAS", 0, true );
2374   createSMESHAction(  220, "ALL" );
2375   createSMESHAction( 1100, "EDIT_HYPO" );
2376   createSMESHAction( 1101, "RENAME" );
2377   createSMESHAction( 1102, "UNASSIGN" );
2378   createSMESHAction( 9010, "NUM_NODES", "", 0, true );
2379   createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
2380   createSMESHAction( 1131, "DISPMODE" );
2381   createSMESHAction( 1132, "COLORS" );
2382   createSMESHAction( 1133, "TRANSP" );
2383   createSMESHAction( 1134, "CLIP" );
2384   createSMESHAction( 1135, "DISP_ENT" );
2385   createSMESHAction( 2000, "CTRL" );
2386
2387   createSMESHAction( 300, "ERASE" );
2388   createSMESHAction( 301, "DISPLAY" );
2389   createSMESHAction( 302, "DISPLAY_ONLY" );
2390   createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
2391   createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
2392   createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
2393   createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
2394   createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
2395   createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
2396   createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
2397   createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
2398
2399   // ----- create menu --------------
2400   int fileId   = createMenu( tr( "MEN_FILE" ),   -1,  1 ),
2401       editId   = createMenu( tr( "MEN_EDIT" ),   -1,  3 ),
2402       toolsId  = createMenu( tr( "MEN_TOOLS" ),  -1,  5, 50 ),
2403       meshId   = createMenu( tr( "MEN_MESH" ),   -1, 70, 10 ),
2404       ctrlId   = createMenu( tr( "MEN_CTRL" ),   -1, 60, 10 ),
2405       modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
2406       viewId   = createMenu( tr( "MEN_VIEW" ),   -1,  2 );
2407
2408   createMenu( separator(), fileId );
2409
2410   int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
2411       exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
2412       addId    = createMenu( tr( "MEN_ADD" ),    modifyId, 402 ),
2413       removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
2414       renumId  = createMenu( tr( "MEN_RENUM" ),  modifyId, 404 ),
2415       transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
2416
2417   createMenu( 111, importId, -1 );
2418   createMenu( 112, importId, -1 );
2419   createMenu( 113, importId, -1 );
2420
2421   createMenu( 121, exportId, -1 );
2422   createMenu( 122, exportId, -1 );
2423   createMenu( 123, exportId, -1 );
2424
2425   createMenu( separator(), fileId, 10 );
2426
2427   createMenu( 33, editId, -1 );
2428
2429   createMenu( 5105, toolsId, -1 );
2430
2431   createMenu( 702, meshId, -1 );
2432   createMenu( 703, meshId, -1 );
2433   createMenu( 704, meshId, -1 );
2434   createMenu( separator(), meshId, -1 );
2435   createMenu( 701, meshId, -1 );
2436   createMenu( separator(), meshId, -1 );
2437   createMenu( 801, meshId, -1 );
2438   createMenu( 802, meshId, -1 );
2439   createMenu( 803, meshId, -1 );
2440   createMenu( separator(), meshId, -1 );
2441   createMenu( 810, meshId, -1 );
2442   createMenu( 811, meshId, -1 );
2443   createMenu( 812, meshId, -1 );
2444   createMenu( separator(), meshId, -1 );
2445   createMenu( 813, meshId, -1 );
2446   createMenu( separator(), meshId, -1 );
2447   createMenu( 900, meshId, -1 );
2448   createMenu( 902, meshId, -1 );
2449   createMenu( separator(), meshId, -1 );
2450
2451   createMenu( 6003, ctrlId, -1 );
2452   createMenu( 6001, ctrlId, -1 );
2453   createMenu( 6004, ctrlId, -1 );
2454   createMenu( separator(), ctrlId, -1 );
2455   createMenu( 6002, ctrlId, -1 );
2456   createMenu( 6018, ctrlId, -1 );
2457   createMenu( 6019, ctrlId, -1 );
2458   createMenu( 6011, ctrlId, -1 );
2459   createMenu( 6012, ctrlId, -1 );
2460   createMenu( 6013, ctrlId, -1 );
2461   createMenu( 6014, ctrlId, -1 );
2462   createMenu( 6015, ctrlId, -1 );
2463   createMenu( 6016, ctrlId, -1 );
2464   createMenu( separator(), ctrlId, -1 );
2465   createMenu( 6017, ctrlId, -1 );
2466   createMenu( 6009, ctrlId, -1 );
2467   createMenu( separator(), ctrlId, -1 );
2468
2469   createMenu( 400, addId, -1 );
2470   createMenu( 401, addId, -1 );
2471   createMenu( 4021, addId, -1 );
2472   createMenu( 4022, addId, -1 );
2473   createMenu( 4023, addId, -1 );
2474   createMenu( 4031, addId, -1 );
2475   createMenu( 4032, addId, -1 );
2476   createMenu( 4033, addId, -1 );
2477   createMenu( separator(), addId, -1 );
2478   createMenu( 4034, addId, -1 );
2479   createMenu( 4035, addId, -1 );
2480   createMenu( 4036, addId, -1 );
2481   createMenu( 4037, addId, -1 );
2482   createMenu( 4038, addId, -1 );
2483   createMenu( 4039, addId, -1 );
2484   createMenu( 4040, addId, -1 );
2485
2486   createMenu( 4041, removeId, -1 );
2487   createMenu( 4042, removeId, -1 );
2488
2489   createMenu( 4051, renumId, -1 );
2490   createMenu( 4052, renumId, -1 );
2491
2492   createMenu( 4061, transfId, -1 );
2493   createMenu( 4062, transfId, -1 );
2494   createMenu( 4063, transfId, -1 );
2495   createMenu( 4064, transfId, -1 );
2496   createMenu( 4065, transfId, -1 );
2497   createMenu( 4066, transfId, -1 );
2498
2499   createMenu( 406, modifyId, -1 );
2500   createMenu( 407, modifyId, -1 );
2501   createMenu( 408, modifyId, -1 );
2502   createMenu( 409, modifyId, -1 );
2503   createMenu( 410, modifyId, -1 );
2504   createMenu( 411, modifyId, -1 );
2505   createMenu( 412, modifyId, -1 );
2506   createMenu( 413, modifyId, -1 );
2507   createMenu( 416, modifyId, -1 );
2508   createMenu( 414, modifyId, -1 );
2509   createMenu( 415, modifyId, -1 );
2510   createMenu( 417, modifyId, -1 );
2511
2512   createMenu( 214, viewId, -1 );
2513
2514   // ----- create toolbars --------------
2515   int meshTb     = createTool( tr( "TB_MESH" ) ),
2516       ctrlTb     = createTool( tr( "TB_CTRL" ) ),
2517       addRemTb   = createTool( tr( "TB_ADD_REMOVE" ) ),
2518       modifyTb   = createTool( tr( "TB_MODIFY" ) ),
2519       dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
2520
2521   createTool( 702, meshTb );
2522   createTool( 703, meshTb );
2523   createTool( 704, meshTb );
2524   createTool( separator(), meshTb );
2525   createTool( 701, meshTb );
2526   createTool( separator(), meshTb );
2527   createTool( 801, meshTb );
2528   createTool( 802, meshTb );
2529   createTool( 803, meshTb );
2530   createTool( separator(), meshTb );
2531   createTool( 900, meshTb );
2532   createTool( 902, meshTb );
2533   createTool( separator(), meshTb );
2534
2535   createTool( 6001, ctrlTb );
2536   createTool( 6003, ctrlTb );
2537   createTool( 6004, ctrlTb );
2538   createTool( separator(), ctrlTb );
2539   createTool( 6002, ctrlTb );
2540   createTool( 6018, ctrlTb );
2541   createTool( 6019, ctrlTb );
2542   createTool( 6011, ctrlTb );
2543   createTool( 6012, ctrlTb );
2544   createTool( 6013, ctrlTb );
2545   createTool( 6014, ctrlTb );
2546   createTool( 6015, ctrlTb );
2547   createTool( 6016, ctrlTb );
2548   createTool( separator(), ctrlTb );
2549   createTool( 6017, ctrlTb );
2550   createTool( 6009, ctrlTb );
2551   createTool( separator(), ctrlTb );
2552
2553   createTool( 400, addRemTb );
2554   createTool( 401, addRemTb );
2555   createTool( 4021, addRemTb );
2556   createTool( 4022, addRemTb );
2557   createTool( 4023, addRemTb );
2558   createTool( 4031, addRemTb );
2559   createTool( 4032, addRemTb );
2560   createTool( 4033, addRemTb );
2561   createTool( separator(), addRemTb );
2562   createTool( 4034, addRemTb );
2563   createTool( 4035, addRemTb );
2564   createTool( 4036, addRemTb );
2565   createTool( 4037, addRemTb );
2566   createTool( 4038, addRemTb );
2567   createTool( 4039, addRemTb );
2568   createTool( 4040, addRemTb );
2569   createTool( separator(), addRemTb );
2570   createTool( 4041, addRemTb );
2571   createTool( 4042, addRemTb );
2572   createTool( separator(), addRemTb );
2573   createTool( 4051, addRemTb );
2574   createTool( 4052, addRemTb );
2575   createTool( separator(), addRemTb );
2576   createTool( 4061, addRemTb );
2577   createTool( 4062, addRemTb );
2578   createTool( 4063, addRemTb );
2579   createTool( 4064, addRemTb );
2580   createTool( 4065, addRemTb );
2581   createTool( 4066, addRemTb );
2582   createTool( separator(), addRemTb );
2583
2584   createTool( 406, modifyTb );
2585   createTool( 407, modifyTb );
2586   createTool( 408, modifyTb );
2587   createTool( 409, modifyTb );
2588   createTool( 410, modifyTb );
2589   createTool( 411, modifyTb );
2590   createTool( 412, modifyTb );
2591   createTool( 413, modifyTb );
2592   createTool( 416, modifyTb );
2593   createTool( 414, modifyTb );
2594   createTool( 415, modifyTb );
2595   createTool( 417, modifyTb );
2596
2597   createTool( 214, dispModeTb );
2598
2599
2600   myRules.clear();
2601   QString OB = "'ObjectBrowser'",
2602           View = "'" + SVTK_Viewer::Type() + "'",
2603           pat = "'%1'",
2604           mesh    = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
2605           group   = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
2606           hypo    = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
2607           algo    = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
2608           elems   = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
2609                        arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
2610                        arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
2611                        arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
2612                        arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
2613                        arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
2614                        arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
2615           subMesh = elems,
2616           mesh_group = mesh + " " + subMesh + " " + group,
2617           hyp_alg = hypo + " " + algo;
2618
2619   // popup for object browser
2620
2621   createPopupItem( 704, OB, mesh, "&& isComputable");      // EDIT_MESHSUBMESH
2622   createPopupItem( 704, OB, subMesh, "&& isComputable" );  // EDIT_MESHSUBMESH
2623   createPopupItem( 803, OB, group );                       // EDIT_GROUP
2624   popupMgr()->insert( separator(), -1, 0 );
2625   createPopupItem( 701, OB, mesh, "&& isComputable" );     // COMPUTE
2626   createPopupItem( 214, OB, mesh_group );                  // UPDATE
2627   createPopupItem( 900, OB, mesh_group );                  // ADV_INFO
2628   createPopupItem( 902, OB, mesh );                        // STD_INFO
2629   popupMgr()->insert( separator(), -1, 0 );
2630   createPopupItem( 801, OB, mesh );                        // CREATE_GROUP
2631   createPopupItem( 802, OB, subMesh );                     // CONSTRUCT_GROUP
2632   popupMgr()->insert( separator(), -1, 0 );
2633   createPopupItem( 1100, OB, hypo, "" /*"&& $hasReference={false}"*/ );   // EDIT HYPOTHESIS
2634   createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
2635   createPopupItem( 1101, OB, mesh_group + " " + hyp_alg, "" /*"&& $hasReference={false}"*/ ); // RENAME
2636   popupMgr()->insert( separator(), -1, 0 );
2637
2638   QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2639   createPopupItem( 125, OB, mesh, only_one_non_empty );    // EXPORT_MED
2640   createPopupItem( 126, OB, mesh, only_one_non_empty );    // EXPORT_UNV
2641   createPopupItem( 33, OB, subMesh + " " + group );        // DELETE
2642   popupMgr()->insert( separator(), -1, 0 );
2643
2644   // popup for viewer
2645   createPopupItem( 803, View, group ); // EDIT_GROUP
2646   createPopupItem( 804, View, elems ); // ADD
2647   createPopupItem( 805, View, elems ); // REMOVE
2648   popupMgr()->insert( separator(), -1, 0 );
2649   createPopupItem( 214, View, mesh_group ); // UPDATE
2650   createPopupItem( 900, View, mesh_group ); // ADV_INFO
2651   createPopupItem( 902, View, mesh );       // STD_INFO
2652   popupMgr()->insert( separator(), -1, 0 );
2653
2654   int anId;
2655   QString
2656     isInvisible("not( isVisible )"),
2657     isEmpty("numberOfNodes = 0"),
2658     isNotEmpty("numberOfNodes <> 0"),
2659
2660     // has nodes, edges, etc in VISIBLE! actor
2661     hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
2662     hasElems("(count( elemTypes ) > 0)"),
2663     hasDifferentElems("(count( elemTypes ) > 1)"),
2664     hasEdges("({'Edge'} in elemTypes)"),
2665     hasFaces("({'Face'} in elemTypes)"),
2666     hasVolumes("({'Volume'} in elemTypes)");
2667
2668   QString lc = QtxPopupMgr::Selection::defEquality();
2669   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
2670   QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
2671   aType = aType.arg( mesh_group );
2672   QString aMeshInVTK = aClient + "&&" + aType;
2673
2674   //-------------------------------------------------
2675   // Numbering
2676   //-------------------------------------------------
2677   anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
2678
2679   popupMgr()->insert( action( 9010 ), anId, -1 );
2680   popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, true );
2681   popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", false );
2682
2683   popupMgr()->insert( action( 9011 ), anId, -1 );
2684   popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, true );
2685   popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", false );
2686
2687   popupMgr()->insert( separator(), -1, -1 );
2688
2689   //-------------------------------------------------
2690   // Display Mode
2691   //-------------------------------------------------
2692   anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
2693
2694   popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
2695   popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, true );
2696   popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", false );
2697
2698   popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
2699   popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")",true);
2700   popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", false );
2701
2702   popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
2703   popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, true );
2704   popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", false );
2705
2706   popupMgr()->insert( separator(), anId, -1 );
2707
2708   popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
2709   popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'",true);
2710   popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", false );
2711
2712   //-------------------------------------------------
2713   // Display Entity
2714   //-------------------------------------------------
2715   QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
2716
2717   anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
2718
2719   popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
2720   popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, true );
2721   popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", false );
2722
2723   popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
2724   popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, true );
2725   popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", false );
2726
2727   popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
2728   popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, true );
2729   popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", false );
2730
2731   popupMgr()->insert( separator(), anId, -1 );
2732
2733   popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
2734   popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", true );
2735
2736   //-------------------------------------------------
2737   // Color / Size
2738   //-------------------------------------------------
2739   popupMgr()->insert( action( 1132 ), -1, -1 );
2740   popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", true );
2741
2742   //-------------------------------------------------
2743   // Transparency
2744   //-------------------------------------------------
2745   popupMgr()->insert( action( 1133 ), -1, -1 );
2746   popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", true );
2747
2748   //-------------------------------------------------
2749   // Clipping
2750   //-------------------------------------------------
2751   popupMgr()->insert( action( 1134 ), -1, -1 );
2752   popupMgr()->setRule( action( 1134 ), aMeshInVTK + "&& isVisible", true );
2753
2754   popupMgr()->insert( separator(), -1, -1 );
2755
2756   //-------------------------------------------------
2757   // Controls
2758   //-------------------------------------------------
2759   QString
2760     aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
2761     aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
2762     aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
2763
2764   anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
2765
2766   popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
2767   popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2768
2769   popupMgr()->insert( separator(), anId, -1 );
2770
2771   popupMgr()->insert( action( 6003 ), anId, -1 ); // FREE_BORDER
2772   popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, true );
2773   popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", false );
2774
2775   popupMgr()->insert( action( 6001 ), anId, -1 ); // LENGTH
2776   popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, true );
2777   popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", false );
2778
2779   popupMgr()->insert( action( 6004 ), anId, -1 ); // CONNECTION
2780   popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, true );
2781   popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", false );
2782
2783   popupMgr()->insert( separator(), anId, -1 );
2784
2785   popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
2786   popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, true );
2787   popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", false );
2788
2789   popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
2790   popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, true );
2791   popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", false );
2792
2793   popupMgr()->insert( action( 6019 ), anId, -1 ); // CONNECTION_2D
2794   popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, true );
2795   popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", false );
2796
2797   popupMgr()->insert( action( 6011 ), anId, -1 ); // AREA
2798   popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, true );
2799   popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", false );
2800
2801   popupMgr()->insert( action( 6012 ), anId, -1 ); // TAPER
2802   popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, true );
2803   popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", false );
2804
2805   popupMgr()->insert( action( 6013 ), anId, -1 ); // ASPECT
2806   popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, true );
2807   popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", false );
2808
2809   popupMgr()->insert( action( 6014 ), anId, -1 ); // MIN_ANG
2810   popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, true );
2811   popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", false );
2812
2813   popupMgr()->insert( action( 6015 ), anId, -1 ); // WARP
2814   popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, true );
2815   popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", false );
2816
2817   popupMgr()->insert( action( 6016 ), anId, -1 ); // SKEW
2818   popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, true );
2819   popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", false );
2820
2821   popupMgr()->insert( separator(), anId, -1 );
2822
2823   popupMgr()->insert( action( 6017 ), anId, -1 ); // ASPECT_3D
2824   popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
2825   popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
2826
2827   popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
2828   popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
2829   popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
2830
2831   popupMgr()->insert( separator(), anId, -1 );
2832
2833   popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
2834   popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", true );
2835
2836   popupMgr()->insert( separator(), -1, -1 );
2837
2838   //-------------------------------------------------
2839   // Display / Erase
2840   //-------------------------------------------------
2841   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
2842   QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
2843   QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
2844
2845   QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
2846     aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
2847   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
2848   popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
2849
2850   popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
2851   popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
2852
2853   popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
2854   popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
2855
2856   popupMgr()->insert( separator(), -1, -1 );
2857
2858   connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
2859            this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
2860 }
2861
2862 bool SMESHGUI::activateModule( SUIT_Study* study )
2863 {
2864   bool res = SalomeApp_Module::activateModule( study );
2865
2866   setMenuShown( true );
2867   setToolShown( true );
2868
2869   return res;
2870 }
2871
2872 bool SMESHGUI::deactivateModule( SUIT_Study* study )
2873 {
2874   setMenuShown( false );
2875   setToolShown( false );
2876
2877   EmitSignalCloseAllDialogs();
2878
2879   return SalomeApp_Module::deactivateModule( study );
2880 }
2881
2882 void SMESHGUI::OnGUIEvent()
2883 {
2884   const QObject* obj = sender();
2885   if ( !obj || !obj->inherits( "QAction" ) )
2886     return;
2887   int id = actionId((QAction*)obj);
2888   if ( id != -1 )
2889     OnGUIEvent( id );
2890 }
2891
2892 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
2893 {
2894   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2895   if ( CORBA::is_nil( myComponentSMESH ) )
2896     {
2897       SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
2898       if ( aStudy )
2899         aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2900       return aGUI.myComponentSMESH;
2901     }
2902   if ( aStudy )
2903     myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2904   return myComponentSMESH;
2905 }
2906
2907 QString SMESHGUI::engineIOR() const
2908 {
2909   CORBA::ORB_var anORB = getApp()->orb();
2910   CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
2911   return anIOR.in();
2912 }
2913
2914 void SMESHGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
2915 {
2916   SMESHGUI_Selection sel;
2917   sel.init( client, selectionMgr() );
2918   popupMgr()->updatePopup( menu, &sel );
2919 }
2920
2921 void SMESHGUI::windows( QMap<int, int>& aMap ) const
2922 {
2923   aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2924   aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2925 }
2926
2927 void SMESHGUI::viewManagers( QStringList& list ) const
2928 {
2929   list.append( SVTK_Viewer::Type() );
2930 }
2931
2932 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
2933 {
2934   if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
2935     SMESH::UpdateSelectionProp( this );
2936 }
2937
2938 void SMESHGUI::createPreferences()
2939 {
2940   int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
2941
2942   int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
2943   addPreference( tr( "PREF_AUTO_UPDATE" ), updateGroup, LightApp_Preferences::Bool, "SMESH", "auto_update" );
2944
2945   int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
2946   addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
2947   addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
2948
2949   int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab );
2950   setPreferenceProperty( precGroup, "columns", 1 );
2951
2952   int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
2953
2954   setPreferenceProperty( prec, "min", 0 );
2955   setPreferenceProperty( prec, "max", 16 );
2956
2957   int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
2958   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
2959   QStringList modes;
2960   modes.append( "Wireframe" );
2961   modes.append( "Shading" );
2962   modes.append( "Nodes" );
2963   modes.append( "Shrink" );
2964   QValueList<QVariant> indices;
2965   indices.append( 0 );
2966   indices.append( 1 );
2967   indices.append( 2 );
2968   indices.append( 3 );
2969   setPreferenceProperty( dispmode, "strings", modes );
2970   setPreferenceProperty( dispmode, "indexes", indices );
2971
2972   int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
2973   addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
2974   
2975   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
2976   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
2977
2978   addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
2979   int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, LightApp_Preferences::IntSpin, "SMESH", "node_size" );
2980
2981   setPreferenceProperty( nodeSz, "min", 1 );
2982   setPreferenceProperty( nodeSz, "max", 5 );
2983
2984   int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
2985
2986   addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
2987   addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
2988   addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
2989   addPreference( "", elemGroup, LightApp_Preferences::Space );
2990
2991   int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width" );
2992   int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff" );
2993
2994   setPreferenceProperty( elemW, "min", 1 );
2995   setPreferenceProperty( elemW, "max", 5 );
2996
2997   setPreferenceProperty( shrink, "min", 0 );
2998   setPreferenceProperty( shrink, "max", 100 );
2999
3000   int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
3001
3002   int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
3003
3004   addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
3005   addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
3006   int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
3007
3008   setPreferenceProperty( selW, "min", 1 );
3009   setPreferenceProperty( selW, "max", 5 );
3010
3011   int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
3012
3013   addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
3014   int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
3015
3016   setPreferenceProperty( preW, "min", 1 );
3017   setPreferenceProperty( preW, "max", 5 );
3018
3019   int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
3020
3021   addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
3022   addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
3023
3024   int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
3025   int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
3026
3027   int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
3028   addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
3029   int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
3030   addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
3031
3032   QStringList fam;
3033   fam.append( tr( "SMESH_FONT_ARIAL" ) );
3034   fam.append( tr( "SMESH_FONT_COURIER" ) );
3035   fam.append( tr( "SMESH_FONT_TIMES" ) );
3036   int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
3037
3038   setPreferenceProperty( tfont, "families", fam );
3039   setPreferenceProperty( tfont, "system", false );
3040   setPreferenceProperty( tfont, "widget_flags", wflag );
3041   setPreferenceProperty( lfont, "families", fam );
3042   setPreferenceProperty( lfont, "system", false );
3043   setPreferenceProperty( lfont, "widget_flags", wflag );
3044
3045   int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
3046
3047   int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
3048   setPreferenceProperty( numcol, "min", 2 );
3049   setPreferenceProperty( numcol, "max", 256 );
3050
3051   int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
3052   setPreferenceProperty( numlab, "min", 2 );
3053   setPreferenceProperty( numlab, "max", 65 );
3054
3055   int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
3056   int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
3057   QStringList orients;
3058   orients.append( tr( "SMESH_VERTICAL" ) );
3059   orients.append( tr( "SMESH_HORIZONTAL" ) );
3060   indices.clear(); indices.append( 0 ); indices.append( 1 );
3061   setPreferenceProperty( orient, "strings", orients );
3062   setPreferenceProperty( orient, "indexes", indices );
3063
3064   int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
3065   int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
3066   int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
3067   int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
3068   int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
3069   setPreferenceProperty( xv, "step", 0.1 );
3070   setPreferenceProperty( xv, "min", 0.0 );
3071   setPreferenceProperty( xv, "max", 1.0 );
3072   setPreferenceProperty( yv, "step", 0.1 );
3073   setPreferenceProperty( yv, "min", 0.0 );
3074   setPreferenceProperty( yv, "max", 1.0 );
3075   setPreferenceProperty( wv, "step", 0.1 );
3076   setPreferenceProperty( wv, "min", 0.0 );
3077   setPreferenceProperty( wv, "max", 1.0 );
3078   setPreferenceProperty( hv, "min", 0.0 );
3079   setPreferenceProperty( hv, "max", 1.0 );
3080   setPreferenceProperty( hv, "step", 0.1 );
3081
3082   int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
3083   int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
3084   int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
3085   int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
3086   int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
3087   setPreferenceProperty( xv, "min", 0.0 );
3088   setPreferenceProperty( xv, "max", 1.0 );
3089   setPreferenceProperty( xv, "step", 0.1 );
3090   setPreferenceProperty( xh, "min", 0.0 );
3091   setPreferenceProperty( xh, "max", 1.0 );
3092   setPreferenceProperty( xh, "step", 0.1 );
3093   setPreferenceProperty( yh, "min", 0.0 );
3094   setPreferenceProperty( yh, "max", 1.0 );
3095   setPreferenceProperty( yh, "step", 0.1 );
3096   setPreferenceProperty( wh, "min", 0.0 );
3097   setPreferenceProperty( wh, "max", 1.0 );
3098   setPreferenceProperty( wh, "step", 0.1 );
3099   setPreferenceProperty( hh, "min", 0.0 );
3100   setPreferenceProperty( hh, "max", 1.0 );
3101   setPreferenceProperty( hh, "step", 0.1 );
3102 }
3103
3104 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
3105 {
3106   if( sect=="SMESH" ){
3107     float sbX1,sbY1,sbW,sbH;
3108     float aTol = 1.00000009999999;
3109     std::string aWarning;
3110     SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
3111     if( name=="selection_object_color" || name=="selection_element_color" || 
3112         name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
3113         name=="selection_precision_node" || name=="selection_precision_element" )
3114       SMESH::UpdateSelectionProp( this );
3115     else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
3116       sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
3117       sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
3118       if(sbX1+sbW > aTol){
3119         aWarning = "Origin and Size Vertical: X+Width > 1\n";   
3120         sbX1=0.01;
3121         sbW=0.05;
3122         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
3123         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
3124       }
3125     }
3126     else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
3127       sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
3128       sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
3129       if(sbY1+sbH > aTol){
3130         aWarning = "Origin and Size Vertical: Y+Height > 1\n";
3131         sbY1=0.01;
3132         sbH=0.5;
3133         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
3134         aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
3135       }
3136     }
3137     else if(name ==  QString("scalar_bar_horizontal_x") || name ==  QString("scalar_bar_horizontal_width")){
3138       sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3139       sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
3140       if(sbX1+sbW > aTol){
3141         aWarning = "Origin and Size Horizontal: X+Width > 1\n";
3142         sbX1=0.2;
3143         sbW=0.6;
3144         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
3145         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
3146       }
3147     }
3148     else if(name ==  QString("scalar_bar_horizontal_y") || name ==  QString("scalar_bar_horizontal_height")){
3149       sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3150       sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
3151       if(sbY1+sbH > aTol){
3152         aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
3153         sbY1=0.01;
3154         sbH=0.12;
3155         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
3156         aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
3157       }
3158     }
3159     
3160     if(aWarning.size() != 0){
3161       aWarning += "The default values are applied instead.";
3162       SUIT_MessageBox::warn1(SMESHGUI::desktop(),
3163                              QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
3164                              QObject::tr(aWarning.c_str()),
3165                              QObject::tr("SMESH_BUT_OK"));
3166     }
3167   }
3168 }
3169
3170 //================================================================================
3171 /*!
3172  * \brief Update something in accordance with update flags
3173   * \param theFlags - update flags
3174 *
3175 * Update viewer or/and object browser etc. in accordance with update flags ( see
3176 * LightApp_UpdateFlags enumeration ).
3177 */
3178 //================================================================================
3179 void SMESHGUI::update( const int flags )
3180 {
3181   if ( flags & UF_Viewer | flags & UF_Forced )
3182     SMESH::UpdateView();
3183   else
3184     SalomeApp_Module::update( flags );
3185 }
3186
3187 //================================================================================
3188 /*!
3189  * \brief Set default selection mode
3190 *
3191 * SLOT called when operation commited. Sets default selection mode
3192 */
3193 //================================================================================
3194 void SMESHGUI::onOperationCommited( SUIT_Operation* )
3195 {
3196   SVTK_ViewWindow* vtkWnd =
3197     dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3198   if ( vtkWnd )
3199     vtkWnd->SetSelectionMode( ActorSelection );
3200 }
3201
3202 //================================================================================
3203 /*!
3204  * \brief Set default selection mode
3205 *
3206 * SLOT called when operation aborted. Sets default selection mode
3207 */
3208 //================================================================================
3209 void SMESHGUI::onOperationAborted( SUIT_Operation* )
3210 {
3211   SVTK_ViewWindow* vtkWnd =
3212     dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
3213   if ( vtkWnd )
3214     vtkWnd->SetSelectionMode( ActorSelection );
3215 }
3216
3217 //================================================================================
3218 /*!
3219  * \brief Creates operation with given identifier
3220   * \param id - identifier of operation to be started
3221   * \return Pointer on created operation or NULL if operation is not created
3222 *
3223 * Virtual method redefined from the base class creates operation with given id.
3224 * It is called called automatically from startOperation method of base class.
3225 */
3226 //================================================================================
3227 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
3228 {
3229   LightApp_Operation* op = 0;
3230   // to do : create operation here
3231   switch( id )
3232   {
3233     case 702: // Create mesh
3234       op = new SMESHGUI_MeshOp( true, true );
3235     break;
3236     case 703: // Create sub-mesh
3237       op = new SMESHGUI_MeshOp( true, false );
3238     break;
3239     case 704: // Edit mesh/sub-mesh
3240       op = new SMESHGUI_MeshOp( false );
3241     break;
3242     case 417: //convert to quadratic
3243       op = new SMESHGUI_ConvToQuadOp();
3244     break;
3245     default:
3246     break;
3247   }
3248
3249   if( !op )
3250     op = SalomeApp_Module::createOperation( id );
3251   return op;
3252 }
3253
3254 //================================================================================
3255 /*!
3256  * \brief Stops current operations and starts a given one
3257   * \param id - The id of the operation to start
3258  */
3259 //================================================================================
3260
3261 void SMESHGUI::switchToOperation(int id)
3262 {
3263   if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
3264     activeStudy()->abortAllOperations();
3265   startOperation( id );
3266 }
3267
3268 LightApp_Displayer* SMESHGUI::displayer()
3269 {
3270   if( !myDisplayer )
3271     myDisplayer = new SMESHGUI_Displayer( getApp() );
3272   return myDisplayer;
3273 }