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