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