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