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