Salome HOME
Merge multi-study removal branch.
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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   : GeometryGUI.cxx
23 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24
25 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
26 #ifdef HAVE_FINITE
27 #undef HAVE_FINITE            // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
28 #endif
29 #include "Python.h"
30 #include "GeometryGUI.h"
31 #include "GeometryGUI_Operations.h"
32 #include "GEOMPluginGUI.h"
33 #include "GEOMGUI_OCCSelector.h"
34 #include "GEOMGUI_Selection.h"
35 #include "GEOMGUI_CreationInfoWdg.h"
36 #include "GEOMGUI_TextTreeWdg.h"
37 #include "GEOMGUI_DimensionProperty.h"
38 #include "GEOM_Constants.h"
39 #include "GEOM_Displayer.h"
40 #include "GEOM_AISShape.hxx"
41 #include "GEOMUtils_XmlHandler.hxx"
42 #include "GEOMGUI_AnnotationMgr.h"
43 #include "GEOMGUI_TextTreeSelector.h"
44
45 #include "GEOM_Actor.h"
46
47 #include <Material_ResourceMgr.h>
48 #include <Material_Model.h>
49
50 #include <SUIT_Desktop.h>
51 #include <SUIT_MessageBox.h>
52 #include <SUIT_ResourceMgr.h>
53 #include <SUIT_Session.h>
54 #include <SUIT_ViewManager.h>
55
56 #include <OCCViewer_ViewWindow.h>
57 #include <OCCViewer_ViewPort3d.h>
58 #include <OCCViewer_ViewModel.h>
59 #include <OCCViewer_ViewManager.h>
60
61 #include <SOCC_ViewModel.h>
62 #include <SOCC_ViewWindow.h>
63
64 #include <SVTK_ViewWindow.h>
65 #include <SVTK_RenderWindowInteractor.h>
66 #include <SVTK_InteractorStyle.h>
67 #include <SVTK_ViewModel.h>
68
69 #ifndef DISABLE_GRAPHICSVIEW
70 #include <GraphicsView_Viewer.h>
71 #endif
72
73 #include <SalomeApp_Application.h>
74 #include <SalomeApp_DataObject.h>
75 #include <SalomeApp_Study.h>
76 #include <SalomeApp_Tools.h>
77
78 #include <LightApp_SelectionMgr.h>
79 #include <LightApp_VTKSelector.h>
80 #include <LightApp_DataObject.h>
81 #include <LightApp_Preferences.h>
82
83 #include <SALOME_LifeCycleCORBA.hxx>
84 #include <SALOME_ListIO.hxx>
85
86 #include <SALOMEDSClient_ClientFactory.hxx>
87 #include <SALOMEDSClient_IParameters.hxx>
88
89 #include <SALOMEDS_SObject.hxx>
90
91 #include <Basics_OCCTVersion.hxx>
92 #include <QtxFontEdit.h>
93
94 // External includes
95 #include <QDir>
96 #include <QSet>
97 #include <QMenu>
98 #include <QTime>
99 #include <QAction>
100 #include <QFileInfo>
101 #include <QString>
102 #include <QPainter>
103 #include <QSignalMapper>
104 #include <QFontDatabase>
105
106 #include <AIS_ListOfInteractive.hxx>
107 #include <AIS_ListIteratorOfListOfInteractive.hxx>
108 #include <Prs3d_Drawer.hxx>
109 #include <Prs3d_IsoAspect.hxx>
110 #include <Aspect_TypeOfMarker.hxx>
111 #include <OSD_SharedLibrary.hxx>
112 #include <NCollection_DataMap.hxx>
113
114 #include <TColStd_HArray1OfByte.hxx>
115 #include <TColStd_SequenceOfHAsciiString.hxx>
116
117 #include <utilities.h>
118
119 #include <vtkCamera.h>
120 #include <vtkRenderer.h>
121
122 #include <Standard_Failure.hxx>
123 #include <Standard_ErrorHandler.hxx>
124
125 #include <Font_SystemFont.hxx>
126 #include <Font_FontMgr.hxx>
127 #include <TCollection_HAsciiString.hxx>
128
129 #include "GEOM_version.h"
130 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
131
132 extern "C" {
133   Standard_EXPORT CAM_Module* createModule() {
134     return new GeometryGUI();
135   }
136
137   Standard_EXPORT char* getModuleVersion() {
138     return (char*)GEOM_VERSION_STR;
139   }
140 }
141
142 GeometryGUI::TextureMap GeometryGUI::myTextureMap;
143
144 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
145
146 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
147 {
148   // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
149   if (CORBA::is_nil(myComponentGeom))
150     InitGeomGen();
151   return GeometryGUI::myComponentGeom;
152 }
153
154 bool GeometryGUI::InitGeomGen()
155 {
156   GeometryGUI aGG;
157   if ( CORBA::is_nil( myComponentGeom ) ) return false;
158   return true;
159 }
160
161 //=======================================================================
162 // function : ClientSObjectToObject
163 // purpose  :
164 //=======================================================================
165 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
166 {
167   _PTR(GenericAttribute) anAttr;
168   CORBA::Object_var anObj;
169   try {
170     std::string aValue = theSObject->GetIOR();
171     if (strcmp(aValue.c_str(), "") != 0) {
172       CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
173       anObj = anORB->string_to_object(aValue.c_str());
174     }
175   } catch(...) {
176     INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
177   }
178   return anObj._retn();
179 }
180
181 //=======================================================================
182 // function : GetStudy
183 // purpose  :
184 //=======================================================================
185 SALOMEDS::Study_var GeometryGUI::getStudyServant()
186 {
187   SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
188   CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
189   SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aStudyObject);
190   return aStudy._retn();
191 }
192
193 void GeometryGUI::Modified (bool theIsUpdateActions)
194 {
195   if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
196     if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
197       appStudy->Modified();
198       if ( theIsUpdateActions )
199         app->updateActions();
200     }
201   }
202 }
203
204 //=======================================================================
205 // function : GeometryGUI::GeometryGUI()
206 // purpose  : Constructor
207 //=======================================================================
208 GeometryGUI::GeometryGUI() :
209   SalomeApp_Module( "GEOM" ),
210   myTopLevelIOList()
211 {
212   if ( CORBA::is_nil( myComponentGeom ) )
213   {
214     Engines::EngineComponent_var comp =
215       SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
216     myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
217   }
218
219   myActiveDialogBox = 0;
220
221   gp_Pnt origin = gp_Pnt(0., 0., 0.);
222   gp_Dir direction = gp_Dir(0., 0., 1.);
223   myWorkingPlane = gp_Ax3(origin, direction);
224
225   myDisplayer = 0;
226   myLocalSelectionMode = GEOM_ALLOBJECTS;
227
228   myCreationInfoWdg = 0;
229   myTextTreeWdg = 0;
230   myAnnotationMgr = 0;
231
232   connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
233
234   Q_INIT_RESOURCE( GEOMGUI );
235 }
236
237 //=======================================================================
238 // function : GeometryGUI::~GeometryGUI()
239 // purpose  : Destructor
240 //=======================================================================
241 GeometryGUI::~GeometryGUI()
242 {
243   while (!myOCCSelectors.isEmpty())
244     delete myOCCSelectors.takeFirst();
245
246   while (!myVTKSelectors.isEmpty())
247     delete myVTKSelectors.takeFirst();
248
249   qDeleteAll(myGUIMap);
250 }
251
252 //=======================================================================
253 // function : GeometryGUI::getLibrary()
254 // purpose  : get or load GUI library by name [ internal ]
255 //=======================================================================
256 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
257 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
258 {
259   if ( !myGUIMap.contains( libraryName ) ) {
260     // try to load library if it is not loaded yet
261 #if defined(WIN32)
262     QString dirs = getenv( "PATH" );
263 #elif defined(__APPLE__)
264     QString dirs = getenv( "DYLD_LIBRARY_PATH" );
265 #else
266     QString dirs = getenv( "LD_LIBRARY_PATH" );
267 #endif
268 #if defined(WIN32)
269     QString sep  = ";";
270 #else
271     QString sep  = ":";
272 #endif
273
274     if ( !dirs.isEmpty() ) {
275       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
276       QListIterator<QString> it( dirList ); it.toBack();
277       while ( it.hasPrevious() ) {
278         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
279         if ( fi.exists() ) {
280           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
281           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
282           if ( !res ) {
283             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
284             continue; // continue search further
285           }
286           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
287           if ( osdF != NULL ) {
288             LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
289             GEOMGUI* libGUI = (*func)( this );
290             if ( libGUI ) {
291               myGUIMap[ libraryName ] = libGUI;
292               break; // found and loaded!
293             }
294           }
295         }
296       }
297     }
298   }
299   return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
300 }
301
302 //=======================================================================
303 // function : GeometryGUI::getPluginLibrary()
304 // purpose  : get or load GUI Plugin library by name [ internal ]
305 //=======================================================================
306 typedef GEOMPluginGUI* (*PluginLibraryGUI)( GeometryGUI* );
307 GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
308 {
309   if ( !myGUIMap.contains( libraryName ) ) {
310     // try to load library if it is not loaded yet
311
312 #if defined(WIN32)
313     QString dirs = getenv( "PATH" );
314 #elif defined(__APPLE__)
315     QString dirs = getenv( "DYLD_LIBRARY_PATH" );
316 #else
317     QString dirs = getenv( "LD_LIBRARY_PATH" );
318 #endif
319 #if defined(WIN32)
320     QString sep  = ";";
321 #else
322     QString sep  = ":";
323 #endif
324
325     if ( !dirs.isEmpty() ) {
326       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
327       QListIterator<QString> it( dirList ); it.toBack();
328       while ( it.hasPrevious() ) {
329         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
330         if ( fi.exists() ) {
331           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
332           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
333           if ( !res ) {
334             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
335             continue; // continue search further
336           }
337           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
338           if ( osdF != NULL ) {
339             PluginLibraryGUI func = (GEOMPluginGUI* (*) (GeometryGUI*))osdF;
340             GEOMPluginGUI* libGUI = (*func)( this );
341             if ( libGUI ) {
342               myGUIMap[ libraryName ] = libGUI;
343               break; // found and loaded!
344             }
345           }
346         }
347       }
348     }
349   }
350   return myGUIMap.contains( libraryName ) ? (GEOMPluginGUI*)myGUIMap[ libraryName ] : 0;
351 }
352
353 //=======================================================================
354 // function : GeometryGUI::ActiveWorkingPlane()
355 // purpose  : Activate Working Plane View
356 //=======================================================================
357 void GeometryGUI::ActiveWorkingPlane()
358 {
359   gp_Dir DZ = myWorkingPlane.Direction();
360   gp_Dir DY = myWorkingPlane.YDirection();
361
362   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
363   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
364   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
365
366   if ( ViewOCC ) {
367     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
368     if ( vw ) {
369       Handle(V3d_View) view3d =  vw->getViewPort()->getView();
370
371       view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
372       view3d->SetUp(DY.X(), DY.Y(), DY.Z());
373       vw->onViewFitAll();
374     }
375   }
376   else if ( ViewVTK ) {
377     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
378     if ( vw ) {
379       vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
380
381       camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
382       camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
383       camera->SetFocalPoint(0,0,0);
384
385       vw->onFitAll();
386     }
387   }
388 }
389
390 //=======================================================================
391 // function : GeometryGUI::SetActiveDialogBox()
392 // purpose  : Set active dialog box
393 //=======================================================================
394 GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
395 {
396   if ( !myAnnotationMgr )
397     myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
398   return myAnnotationMgr;
399 }
400
401 //=======================================================================
402 // function : GeometryGUI::SetActiveDialogBox()
403 // purpose  : Set active dialog box
404 //=======================================================================
405 GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
406 {
407   return myTextTreeWdg;
408 }
409
410 //=======================================================================
411 // function : GeometryGUI::SetActiveDialogBox()
412 // purpose  : Set active dialog box
413 //=======================================================================
414 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
415 {
416   myActiveDialogBox = (QDialog*)aDlg;
417 }
418
419 //=======================================================================
420 // function : GeometryGUI::EmitSignalDeactivateDialog()
421 // purpose  : Emit a signal to deactivate the active dialog Box
422 //=======================================================================
423 void GeometryGUI::EmitSignalDeactivateDialog()
424 {
425   emit SignalDeactivateActiveDialog();
426 }
427
428 //=======================================================================
429 // function : GeometryGUI::EmitSignalCloseAllDialogs()
430 // purpose  : Emit a signal to close all non modal dialogs box
431 //=======================================================================
432 void GeometryGUI::EmitSignalCloseAllDialogs()
433 {
434   emit SignalCloseAllDialogs();
435 }
436
437 //=======================================================================
438 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
439 // purpose  : Emit a signal to inform that default real spin box step has
440 //            been changed
441 //=======================================================================
442 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
443 {
444   emit SignalDefaultStepValueChanged(newVal);
445 }
446
447 //=======================================================================
448 // function : GeometryGUI::OnGUIEvent()
449 // purpose  : common slot for all menu/toolbar actions
450 //=======================================================================
451 void GeometryGUI::OnGUIEvent()
452 {
453   const QObject* obj = sender();
454   if ( !obj || !obj->inherits( "QAction" ) )
455     return;
456   int id = actionId((QAction*)obj);
457   if ( id != -1 )
458     OnGUIEvent( id );
459 }
460
461 //=======================================================================
462 // function : GeometryGUI::OnGUIEvent()
463 // purpose  : manage all events on GUI [static]
464 //=======================================================================
465 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
466 {
467   SUIT_Application* anApp = application();
468   if (!anApp) return;
469   SUIT_Desktop* desk = anApp->desktop();
470
471   // check type of the active viewframe
472   SUIT_ViewWindow* window = desk->activeWindow();
473   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
474   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
475 #ifndef DISABLE_GRAPHICSVIEW
476   bool ViewDep = ( window && window->getViewManager()->getType() == GraphicsView_Viewer::Type() );
477 #else
478   bool ViewDep = 0;
479 #endif
480   // if current viewframe is not of OCC and not of VTK type - return immediately
481   // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
482   QList<int> NotViewerDependentCommands;
483   NotViewerDependentCommands << GEOMOp::OpDelete
484                              << GEOMOp::OpShow
485                              << GEOMOp::OpShowOnly
486                              << GEOMOp::OpShowOnlyChildren
487                              << GEOMOp::OpDiscloseChildren
488                              << GEOMOp::OpConcealChildren
489                              << GEOMOp::OpUnpublishObject
490                              << GEOMOp::OpPublishObject
491                              << GEOMOp::OpPointMarker
492                              << GEOMOp::OpCreateFolder
493                              << GEOMOp::OpSortChildren;
494   if ( !ViewOCC && !ViewVTK && !ViewDep && !NotViewerDependentCommands.contains( id ) ) {
495     // activate OCC viewer
496     getApp()->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true);
497   }
498
499   // fix for IPAL9103, point 2
500   if ( CORBA::is_nil( GetGeomGen() ) ) {
501     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
502     return;
503   }
504
505   QString libName;
506   // find corresponding GUI library
507   switch ( id ) {
508   case GEOMOp::OpOriginAndVectors:   // MENU BASIC - ORIGIN AND BASE VECTORS
509     createOriginAndBaseVectors(); // internal operation
510     return;
511   case GEOMOp::OpSelectVertex:       // POPUP MENU - SELECT ONLY - VERTEX
512   case GEOMOp::OpSelectEdge:         // POPUP MENU - SELECT ONLY - EDGE
513   case GEOMOp::OpSelectWire:         // POPUP MENU - SELECT ONLY - WIRE
514   case GEOMOp::OpSelectFace:         // POPUP MENU - SELECT ONLY - FACE
515   case GEOMOp::OpSelectShell:        // POPUP MENU - SELECT ONLY - SHELL
516   case GEOMOp::OpSelectSolid:        // POPUP MENU - SELECT ONLY - SOLID
517   case GEOMOp::OpSelectCompound:     // POPUP MENU - SELECT ONLY - COMPOUND
518   case GEOMOp::OpSelectAll:          // POPUP MENU - SELECT ONLY - SELECT ALL
519   case GEOMOp::OpDelete:             // MENU EDIT - DELETE
520 #ifndef DISABLE_PYCONSOLE
521   case GEOMOp::OpCheckGeom:          // MENU TOOLS - CHECK GEOMETRY
522 #endif
523   case GEOMOp::OpMaterialsLibrary:   // MENU TOOLS - MATERIALS LIBRARY
524   case GEOMOp::OpDeflection:         // POPUP MENU - DEFLECTION COEFFICIENT
525   case GEOMOp::OpColor:              // POPUP MENU - COLOR
526   case GEOMOp::OpSetTexture:         // POPUP MENU - SETTEXTURE
527   case GEOMOp::OpTransparency:       // POPUP MENU - TRANSPARENCY
528   case GEOMOp::OpIncrTransparency:   // SHORTCUT   - INCREASE TRANSPARENCY
529   case GEOMOp::OpDecrTransparency:   // SHORTCUT   - DECREASE TRANSPARENCY
530   case GEOMOp::OpIsos:               // POPUP MENU - ISOS
531   case GEOMOp::OpIncrNbIsos:         // SHORTCUT   - INCREASE NB ISOS
532   case GEOMOp::OpDecrNbIsos:         // SHORTCUT   - DECREASE NB ISOS
533   case GEOMOp::OpAutoColor:          // POPUP MENU - AUTO COLOR
534   case GEOMOp::OpNoAutoColor:        // POPUP MENU - DISABLE AUTO COLOR
535   case GEOMOp::OpDiscloseChildren:   // POPUP MENU - DISCLOSE CHILD ITEMS
536   case GEOMOp::OpConcealChildren:    // POPUP MENU - CONCEAL CHILD ITEMS
537   case GEOMOp::OpUnpublishObject:    // POPUP MENU - UNPUBLISH
538   case GEOMOp::OpPublishObject:      // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
539   case GEOMOp::OpPointMarker:        // POPUP MENU - POINT MARKER
540   case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
541   case GEOMOp::OpPredefMaterial:     // POPUP MENU - <SOME MATERIAL>
542   case GEOMOp::OpPredefMaterCustom:  // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
543   case GEOMOp::OpEdgeWidth:          // POPUP MENU - LINE WIDTH - EDGE WIDTH
544   case GEOMOp::OpIsosWidth:          // POPUP MENU - LINE WIDTH - ISOS WIDTH
545   case GEOMOp::OpBringToFront:       // POPUP MENU - BRING TO FRONT
546   case GEOMOp::OpClsBringToFront:    //
547   case GEOMOp::OpCreateFolder:       // POPUP MENU - CREATE FOLDER
548   case GEOMOp::OpSortChildren:       // POPUP MENU - SORT CHILD ITEMS
549 #ifndef DISABLE_GRAPHICSVIEW
550   case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
551 #endif
552   case GEOMOp::OpReduceStudy:        // POPUP MENU - REDUCE STUDY
553     libName = "GEOMToolsGUI";
554     break;
555   case GEOMOp::OpDMWireframe:        // MENU VIEW - WIREFRAME
556   case GEOMOp::OpDMShading:          // MENU VIEW - SHADING
557   case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
558   case GEOMOp::OpDMTexture:          // MENU VIEW - TEXTURE
559   case GEOMOp::OpShowAll:            // MENU VIEW - SHOW ALL
560   case GEOMOp::OpShowOnly:           // MENU VIEW - DISPLAY ONLY
561   case GEOMOp::OpShowOnlyChildren:   // MENU VIEW - SHOW ONLY CHILDREN
562   case GEOMOp::OpHideAll:            // MENU VIEW - ERASE ALL
563   case GEOMOp::OpHide:               // MENU VIEW - ERASE
564   case GEOMOp::OpShow:               // MENU VIEW - DISPLAY
565   case GEOMOp::OpSwitchVectors:      // MENU VIEW - VECTOR MODE
566   case GEOMOp::OpSwitchVertices:     // MENU VIEW - VERTICES MODE
567   case GEOMOp::OpSwitchName:         // MENU VIEW - VERTICES MODE
568   case GEOMOp::OpWireframe:          // POPUP MENU - WIREFRAME
569   case GEOMOp::OpShading:            // POPUP MENU - SHADING
570   case GEOMOp::OpShadingWithEdges:   // POPUP MENU - SHADING WITH EDGES
571   case GEOMOp::OpTexture:            // POPUP MENU - TEXTURE
572   case GEOMOp::OpVectors:            // POPUP MENU - VECTORS
573   case GEOMOp::OpVertices:           // POPUP MENU - VERTICES
574   case GEOMOp::OpShowName:           // POPUP MENU - SHOW NAME
575     libName = "DisplayGUI";
576     break;
577   case GEOMOp::OpPoint:              // MENU BASIC - POINT
578   case GEOMOp::OpLine:               // MENU BASIC - LINE
579   case GEOMOp::OpCircle:             // MENU BASIC - CIRCLE
580   case GEOMOp::OpEllipse:            // MENU BASIC - ELLIPSE
581   case GEOMOp::OpArc:                // MENU BASIC - ARC
582   case GEOMOp::OpVector:             // MENU BASIC - VECTOR
583   case GEOMOp::OpPlane:              // MENU BASIC - PLANE
584   case GEOMOp::OpCurve:              // MENU BASIC - CURVE
585   case GEOMOp::OpLCS:                // MENU BASIC - LOCAL COORDINATE SYSTEM
586     libName = "BasicGUI";
587     break;
588   case GEOMOp::OpBox:                // MENU PRIMITIVE - BOX
589   case GEOMOp::OpCylinder:           // MENU PRIMITIVE - CYLINDER
590   case GEOMOp::OpSphere:             // MENU PRIMITIVE - SPHERE
591   case GEOMOp::OpTorus:              // MENU PRIMITIVE - TORUS
592   case GEOMOp::OpCone:               // MENU PRIMITIVE - CONE
593   case GEOMOp::OpRectangle:          // MENU PRIMITIVE - FACE
594   case GEOMOp::OpDisk:               // MENU PRIMITIVE - DISK
595     libName = "PrimitiveGUI";
596     break;
597   case GEOMOp::OpPrism:              // MENU GENERATION - PRISM
598   case GEOMOp::OpRevolution:         // MENU GENERATION - REVOLUTION
599   case GEOMOp::OpFilling:            // MENU GENERATION - FILLING
600   case GEOMOp::OpPipe:               // MENU GENERATION - PIPE
601   case GEOMOp::OpPipePath:           // MENU GENERATION - RESTORE PATH
602   case GEOMOp::OpThickness:          // MENU GENERATION - THICKNESS
603     libName = "GenerationGUI";
604     break;
605   case GEOMOp::Op2dSketcher:         // MENU ENTITY - SKETCHER
606   case GEOMOp::Op3dSketcher:         // MENU ENTITY - 3D SKETCHER
607   case GEOMOp::OpIsoline:            // MENU BASIC  - ISOLINE
608   case GEOMOp::OpExplode:            // MENU ENTITY - EXPLODE
609   case GEOMOp::OpSurfaceFromFace:    // MENU ENTITY - SURFACE FROM FACE
610 #ifdef WITH_OPENCV
611   case GEOMOp::OpFeatureDetect:      // MENU ENTITY - FEATURE DETECTION
612 #endif
613   case GEOMOp::OpPictureImport:      // MENU ENTITY - IMPORT PICTURE IN VIEWER
614   case GEOMOp::OpCreateField:        // MENU FIELD - CREATE FIELD
615   case GEOMOp::OpEditField:          // MENU FIELD - EDIT FIELD
616   case GEOMOp::OpEditFieldPopup:     // POPUP MENU - EDIT FIELD
617   case GEOMOp::Op2dPolylineEditor:   // MENU BASIC - POLYLINE EDITOR
618     libName = "EntityGUI";
619     break;
620   case GEOMOp::OpEdge:               // MENU BUILD - EDGE
621   case GEOMOp::OpWire:               // MENU BUILD - WIRE
622   case GEOMOp::OpFace:               // MENU BUILD - FACE
623   case GEOMOp::OpShell:              // MENU BUILD - SHELL
624   case GEOMOp::OpSolid:              // MENU BUILD - SOLID
625   case GEOMOp::OpCompound:           // MENU BUILD - COMPUND
626     libName = "BuildGUI";
627     break;
628   case GEOMOp::OpFuse:               // MENU BOOLEAN - FUSE
629   case GEOMOp::OpCommon:             // MENU BOOLEAN - COMMON
630   case GEOMOp::OpCut:                // MENU BOOLEAN - CUT
631   case GEOMOp::OpSection:            // MENU BOOLEAN - SECTION
632     libName = "BooleanGUI";
633     break;
634   case GEOMOp::OpTranslate:          // MENU TRANSFORMATION - TRANSLATION
635   case GEOMOp::OpRotate:             // MENU TRANSFORMATION - ROTATION
636   case GEOMOp::OpChangeLoc:          // MENU TRANSFORMATION - LOCATION
637   case GEOMOp::OpMirror:             // MENU TRANSFORMATION - MIRROR
638   case GEOMOp::OpScale:              // MENU TRANSFORMATION - SCALE
639   case GEOMOp::OpOffset:             // MENU TRANSFORMATION - OFFSET
640   case GEOMOp::OpProjection:         // MENU TRANSFORMATION - PROJECTION
641   case GEOMOp::OpProjOnCyl:          // MENU TRANSFORMATION - PROJECTION ON CYLINDER
642   case GEOMOp::OpMultiTranslate:     // MENU TRANSFORMATION - MULTI-TRANSLATION
643   case GEOMOp::OpMultiRotate:        // MENU TRANSFORMATION - MULTI-ROTATION
644   case GEOMOp::OpReimport:           // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
645   case GEOMOp::OpExtension:          // MENU TRANSFORMATION - EXTENSION
646     libName = "TransformationGUI";
647     break;
648   case GEOMOp::OpPartition:          // MENU OPERATION - PARTITION
649   case GEOMOp::OpArchimede:          // MENU OPERATION - ARCHIMEDE
650   case GEOMOp::OpFillet3d:           // MENU OPERATION - FILLET
651   case GEOMOp::OpChamfer:            // MENU OPERATION - CHAMFER
652   case GEOMOp::OpShapesOnShape:      // MENU OPERATION - GET SHAPES ON SHAPE
653   case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
654   case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
655   case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
656   case GEOMOp::OpExtrudedBoss:       // MENU OPERATION - EXTRUDED BOSS
657   case GEOMOp::OpExtrudedCut:        // MENU OPERATION - EXTRUDED CUT
658   case GEOMOp::OpTransferData:       // MENU OPERATION - TRANSFER DATA
659   case GEOMOp::OpExtraction:         // MENU OPERATION - EXTRACT AND REBUILD
660     libName = "OperationGUI";
661     break;
662   case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
663   case GEOMOp::OpSuppressFaces:      // MENU REPAIR - SUPPRESS FACES
664   case GEOMOp::OpSuppressHoles:      // MENU REPAIR - SUPPRESS HOLE
665   case GEOMOp::OpShapeProcess:       // MENU REPAIR - SHAPE PROCESSING
666   case GEOMOp::OpCloseContour:       // MENU REPAIR - CLOSE CONTOUR
667   case GEOMOp::OpRemoveIntWires:     // MENU REPAIR - REMOVE INTERNAL WIRES
668   case GEOMOp::OpAddPointOnEdge:     // MENU REPAIR - ADD POINT ON EDGE
669   case GEOMOp::OpFreeBoundaries:     // MENU MEASURE - FREE BOUNDARIES
670   case GEOMOp::OpFreeFaces:          // MENU MEASURE - FREE FACES
671   case GEOMOp::OpOrientation:        // MENU REPAIR - CHANGE ORIENTATION
672   case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
673   case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
674   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
675   case GEOMOp::OpRemoveWebs:         // MENU REPAIR - REMOVE INTERNAL FACES
676   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
677   case GEOMOp::OpFuseEdges:          // MENU REPAIR - FUSE COLLINEAR EDGES
678   case GEOMOp::OpUnionFaces:         // MENU REPAIR - UNION FACES
679   case GEOMOp::OpInspectObj:         // MENU REPAIR - INSPECT OBJECT
680     libName = "RepairGUI";
681     break;
682   case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
683   case GEOMOp::OpCenterMass:         // MENU MEASURE - CDG
684   case GEOMOp::OpInertia:            // MENU MEASURE - INERTIA
685   case GEOMOp::OpNormale:            // MENU MEASURE - NORMALE
686   case GEOMOp::OpBoundingBox:        // MENU MEASURE - BOUNDING BOX
687   case GEOMOp::OpMinDistance:        // MENU MEASURE - MIN DISTANCE
688   case GEOMOp::OpAngle:              // MENU MEASURE - ANGLE
689   case GEOMOp::OpTolerance:          // MENU MEASURE - TOLERANCE
690   case GEOMOp::OpWhatIs:             // MENU MEASURE - WHATIS
691   case GEOMOp::OpCheckShape:         // MENU MEASURE - CHECK
692   case GEOMOp::OpCheckCompound:      // MENU MEASURE - CHECK COMPOUND OF BLOCKS
693   case GEOMOp::OpGetNonBlocks:       // MENU MEASURE - Get NON BLOCKS
694   case GEOMOp::OpPointCoordinates:   // MENU MEASURE - POINT COORDINATES
695   case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
696   case GEOMOp::OpFastCheckInters:    // MENU MEASURE - FAST CHECK INTERSECTIONS
697   case GEOMOp::OpManageDimensions:   // MENU MEASURE - MANAGE DIMENSIONS
698   case GEOMOp::OpAnnotation:         // MENU MEASURE - ANNOTATION
699   case GEOMOp::OpEditAnnotation:     // POPUP MENU - EDIT ANNOTATION
700   case GEOMOp::OpDeleteAnnotation:   // POPUP MENU - DELETE ANNOTATION
701 #ifndef DISABLE_PLOT2DVIEWER
702   case GEOMOp::OpShapeStatistics:    // MENU MEASURE - SHAPE STATISTICS
703 #endif
704   case GEOMOp::OpShowAllDimensions:  // POPUP MENU - SHOW ALL DIMENSIONS
705   case GEOMOp::OpHideAllDimensions:  // POPUP MENU - HIDE ALL DIMENSIONS
706   case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
707   case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
708     libName = "MeasureGUI";
709     break;
710   case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
711   case GEOMOp::OpGroupCreatePopup:   // POPUP MENU - CREATE GROUP
712   case GEOMOp::OpGroupEdit:          // MENU GROUP - EDIT
713   case GEOMOp::OpGroupUnion:         // MENU GROUP - UNION
714   case GEOMOp::OpGroupIntersect:     // MENU GROUP - INTERSECT
715   case GEOMOp::OpGroupCut:           // MENU GROUP - CUT
716     libName = "GroupGUI";
717     break;
718   case GEOMOp::OpHexaSolid:          // MENU BLOCKS - HEXAHEDRAL SOLID
719   case GEOMOp::OpMultiTransform:     // MENU BLOCKS - MULTI-TRANSFORMATION
720   case GEOMOp::OpQuadFace:           // MENU BLOCKS - QUADRANGLE FACE
721   case GEOMOp::OpPropagate:          // MENU BLOCKS - PROPAGATE
722   case GEOMOp::OpExplodeBlock:       // MENU BLOCKS - EXPLODE ON BLOCKS
723     libName = "BlocksGUI";
724     break;
725   //case GEOMOp::OpAdvancedNoOp:       // NO OPERATION (advanced operations base)
726   //case GEOMOp::OpPipeTShape:         // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
727   //case GEOMOp::OpPipeTShapeGroups:     // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
728   //case GEOMOp::OpDividedDisk:           // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
729   //case GEOMOp::OpDividedCylinder:           // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
730   //case GEOMOp::OpSmoothingSurface:           // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
731     //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@//
732     //libName = "AdvancedGUI";
733     //break;
734   default:
735     if (myPluginActions.contains(id)) {
736       libName = myPluginActions[id].first;
737
738       GEOMPluginGUI* library = 0;
739       if ( !libName.isEmpty() ) {
740 #if defined(WIN32)
741         libName = libName + ".dll";
742 #elif defined(__APPLE__)
743         libName = QString( "lib" ) + libName + ".dylib";
744 #else
745         libName = QString( "lib" ) + libName + ".so";
746 #endif
747         library = getPluginLibrary( libName );
748       }
749
750       // call method of corresponding GUI library
751       if ( library ) {
752         //QString action ("%1");
753         //action = action.arg(id);
754
755         //if( !theParam.isValid() )
756           library->OnGUIEvent( myPluginActions[id].second, desk );
757         //else
758         //  library->OnGUIEvent( id, desk, theParam);
759       }
760       else
761         SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
762
763       updateCreationInfo();
764       return;
765     }
766     break;
767   }
768
769   GEOMGUI* library = 0;
770   if ( !libName.isEmpty() ) {
771 #if defined(WIN32)
772     libName = libName + ".dll";
773 #elif defined(__APPLE__)
774     libName = QString( "lib" ) + libName + ".dylib";
775 #else
776     libName = QString( "lib" ) + libName + ".so";
777 #endif
778     library = getLibrary( libName );
779   }
780
781   // call method of corresponding GUI library
782   if ( library ) {
783     if( !theParam.isValid() )
784       library->OnGUIEvent( id, desk );
785     else
786       library->OnGUIEvent( id, desk, theParam);
787   }
788   else
789     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
790
791   updateCreationInfo();
792 }
793
794 //=================================================================================
795 // function : GeometryGUI::activateOperation()
796 // purpose  :
797 //=================================================================================
798 bool GeometryGUI::activateOperation( int actionId )
799 {
800   OnGUIEvent(actionId);
801   return true;
802 }
803
804 //=================================================================================
805 // function : GeometryGUI::activateOperation()
806 // purpose  :
807 //=================================================================================
808 bool GeometryGUI::activateOperation( const QString& actionId )
809 {
810   bool isOk = false;
811
812   int id = actionId.toInt(&isOk);
813   if (isOk)
814     OnGUIEvent(id);
815
816   return isOk;
817 }
818
819 //=================================================================================
820 // function : GeometryGUI::activateOperation()
821 // purpose  :
822 //=================================================================================
823 bool GeometryGUI::activateOperation( const QString& actionId, const QString& plugin )
824 {
825   bool isOk = false;
826
827   QString pluginLib = plugin;
828   // TODO: if <plugin> is a plugin name, find plugin library name
829   if (myPluginLibs.contains(plugin))
830     pluginLib = myPluginLibs[plugin];
831
832   QMap<int, PluginAction>::iterator actionsIter = myPluginActions.begin();
833   for (; actionsIter != myPluginActions.end(); ++actionsIter) {
834     const PluginAction& anAction = actionsIter.value();
835     if (anAction.first == pluginLib && anAction.second == actionId) {
836       // activate operation
837       OnGUIEvent(actionsIter.key());
838       isOk = true;
839     }
840   }
841
842   return isOk;
843 }
844
845 //=================================================================================
846 // function : GeometryGUI::OnKeyPress()
847 // purpose  : Called when any key is pressed by user [static]
848 //=================================================================================
849 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
850 {
851   if ( !application() )
852     return;
853   foreach ( GEOMGUI* lib, myGUIMap )
854     lib->OnKeyPress( e, application()->desktop(), w );
855 }
856
857 //=================================================================================
858 // function : GeometryGUI::OnMouseMove()
859 // purpose  : Manages mouse move events [static]
860 //=================================================================================
861 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
862 {
863   if ( !application() )
864     return;
865   foreach ( GEOMGUI* lib, myGUIMap )
866     lib->OnMouseMove( e, application()->desktop(), w );
867 }
868
869 //=================================================================================
870 // function : GeometryGUI::OnMouseRelease()
871 // purpose  : Manages mouse release events [static]
872 //=================================================================================
873 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
874 {
875   if ( !application() )
876     return;
877   foreach ( GEOMGUI* lib, myGUIMap )
878     lib->OnMouseRelease( e, application()->desktop(), w );
879 }
880
881 //=================================================================================
882 // function : GeometryGUI::OnMousePress()
883 // purpose  : Manage mouse press events [static]
884 //=================================================================================
885 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
886 {
887   if ( !application() )
888     return;
889   foreach ( GEOMGUI* lib, myGUIMap )
890     lib->OnMousePress( e, application()->desktop(), w );
891 }
892
893 //=======================================================================
894 // function : createGeomAction
895 // purpose  :
896 //=======================================================================
897 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
898                                     const int accel, const bool toggle, const QString& shortcutAction )
899 {
900   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
901   QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
902                                     : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
903   createAction( id,
904                 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
905                 icon,
906                 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
907                 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
908                 accel,
909                 application()->desktop(),
910                 toggle,
911                 this, SLOT( OnGUIEvent() ),
912                 shortcutAction );
913 }
914
915 //=======================================================================
916 // function : createOriginAndBaseVectors
917 // purpose  :
918 //=======================================================================
919 void GeometryGUI::createOriginAndBaseVectors()
920 {
921   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
922   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
923   if ( aLocked ) {
924     SUIT_MessageBox::warning ( application()->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
925     return;
926   }
927   if ( appStudy ) {
928     if ( !CORBA::is_nil( GetGeomGen() ) ) {
929       GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations();
930       if ( !aBasicOperations->_is_nil() ) {
931         SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
932         double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
933         GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
934         GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
935         GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
936         GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
937
938         GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOrigin, "O" );
939         GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOX, "OX" );
940         GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOY, "OY" );
941         GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), anOZ, "OZ" );
942         anOrigin->UnRegister();
943         anOX->UnRegister();
944         anOY->UnRegister();
945         anOZ->UnRegister();
946         aBasicOperations->UnRegister();
947
948         getApp()->updateObjectBrowser( true );
949       }
950     }
951   }
952 }
953
954 //=======================================================================
955 // function : GeometryGUI::initialize()
956 // purpose  : Called when GEOM module is created
957 //=======================================================================
958 void GeometryGUI::initialize( CAM_Application* app )
959 {
960   SalomeApp_Module::initialize( app );
961
962   // ----- create actions --------------
963
964   createGeomAction( GEOMOp::OpDelete,     "DELETE", "", Qt::Key_Delete );
965
966   createGeomAction( GEOMOp::OpPoint,      "POINT" );
967   createGeomAction( GEOMOp::OpLine,       "LINE" );
968   createGeomAction( GEOMOp::OpCircle,     "CIRCLE" );
969   createGeomAction( GEOMOp::OpEllipse,    "ELLIPSE" );
970   createGeomAction( GEOMOp::OpArc,        "ARC" );
971   createGeomAction( GEOMOp::OpCurve,      "CURVE" );
972   createGeomAction( GEOMOp::OpIsoline,    "ISOLINE" );
973   createGeomAction( GEOMOp::OpVector,     "VECTOR" );
974   createGeomAction( GEOMOp::OpPlane,      "PLANE" );
975   createGeomAction( GEOMOp::OpLCS,        "LOCAL_CS" );
976   createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
977   createGeomAction( GEOMOp::OpSurfaceFromFace,  "SURFACE_FROM_FACE" );
978
979   createGeomAction( GEOMOp::OpBox,        "BOX" );
980   createGeomAction( GEOMOp::OpCylinder,   "CYLINDER" );
981   createGeomAction( GEOMOp::OpSphere,     "SPHERE" );
982   createGeomAction( GEOMOp::OpTorus,      "TORUS" );
983   createGeomAction( GEOMOp::OpCone,       "CONE" );
984   createGeomAction( GEOMOp::OpRectangle,  "RECTANGLE" );
985   createGeomAction( GEOMOp::OpDisk,       "DISK" );
986
987   createGeomAction( GEOMOp::OpPrism,       "EXTRUSION" );
988   createGeomAction( GEOMOp::OpRevolution,  "REVOLUTION" );
989   createGeomAction( GEOMOp::OpFilling,     "FILLING" );
990   createGeomAction( GEOMOp::OpPipe,        "PIPE" );
991   createGeomAction( GEOMOp::OpPipePath,    "PIPE_PATH" );
992   createGeomAction( GEOMOp::OpThickness,   "THICKNESS" );
993
994   createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
995   createGeomAction( GEOMOp::OpGroupEdit,   "GROUP_EDIT" );
996   createGeomAction( GEOMOp::OpGroupUnion,  "GROUP_UNION" );
997   createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
998   createGeomAction( GEOMOp::OpGroupCut,    "GROUP_CUT" );
999
1000   createGeomAction( GEOMOp::OpCreateField, "FIELD_CREATE" );
1001   createGeomAction( GEOMOp::OpEditField,   "FIELD_EDIT" );
1002
1003   createGeomAction( GEOMOp::OpReimport,    "RELOAD_IMPORTED" );
1004
1005   createGeomAction( GEOMOp::OpQuadFace,    "Q_FACE" );
1006   createGeomAction( GEOMOp::OpHexaSolid,   "HEX_SOLID" );
1007
1008   createGeomAction( GEOMOp::Op2dSketcher,  "SKETCH" );
1009   createGeomAction( GEOMOp::Op3dSketcher,  "3DSKETCH" );
1010   createGeomAction( GEOMOp::OpExplode,     "EXPLODE" );
1011 #ifdef WITH_OPENCV
1012   createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
1013 #endif
1014   createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
1015   createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
1016
1017   createGeomAction( GEOMOp::OpEdge,        "EDGE" );
1018   createGeomAction( GEOMOp::OpWire,        "WIRE" );
1019   createGeomAction( GEOMOp::OpFace,        "FACE" );
1020   createGeomAction( GEOMOp::OpShell,       "SHELL" );
1021   createGeomAction( GEOMOp::OpSolid,       "SOLID" );
1022   createGeomAction( GEOMOp::OpCompound,    "COMPOUND" );
1023
1024   createGeomAction( GEOMOp::OpFuse,        "FUSE" );
1025   createGeomAction( GEOMOp::OpCommon,      "COMMON" );
1026   createGeomAction( GEOMOp::OpCut,         "CUT" );
1027   createGeomAction( GEOMOp::OpSection,     "SECTION" );
1028
1029   createGeomAction( GEOMOp::OpTranslate,      "TRANSLATION" );
1030   createGeomAction( GEOMOp::OpRotate,         "ROTATION" );
1031   createGeomAction( GEOMOp::OpChangeLoc,      "MODIFY_LOCATION" );
1032   createGeomAction( GEOMOp::OpMirror,         "MIRROR" );
1033   createGeomAction( GEOMOp::OpScale,          "SCALE" );
1034   createGeomAction( GEOMOp::OpOffset,         "OFFSET" );
1035   createGeomAction( GEOMOp::OpProjection,     "PROJECTION" );
1036   createGeomAction( GEOMOp::OpProjOnCyl,      "PROJ_ON_CYL" );
1037   createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
1038   createGeomAction( GEOMOp::OpMultiRotate,    "MUL_ROTATION" );
1039   createGeomAction( GEOMOp::OpExtension,      "EXTENSION" );
1040
1041   createGeomAction( GEOMOp::OpPartition,      "PARTITION" );
1042   createGeomAction( GEOMOp::OpArchimede,      "ARCHIMEDE" );
1043   createGeomAction( GEOMOp::OpFillet3d,       "FILLET" );
1044   createGeomAction( GEOMOp::OpChamfer,        "CHAMFER" );
1045   createGeomAction( GEOMOp::OpShapesOnShape,  "GET_SHAPES_ON_SHAPE" );
1046   createGeomAction( GEOMOp::OpSharedShapes,   "GET_SHARED_SHAPES" );
1047   createGeomAction( GEOMOp::OpTransferData,   "TRANSFER_DATA" );
1048   createGeomAction( GEOMOp::OpExtraction,     "EXTRACTION" );
1049   createGeomAction( GEOMOp::OpExtrudedCut,    "EXTRUDED_CUT" );
1050   createGeomAction( GEOMOp::OpExtrudedBoss,   "EXTRUDED_BOSS" );
1051   createGeomAction( GEOMOp::OpFillet1d,       "FILLET_1D" );
1052   createGeomAction( GEOMOp::OpFillet2d,       "FILLET_2D" );
1053
1054   createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
1055   createGeomAction( GEOMOp::OpExplodeBlock,   "EXPLODE_BLOCKS" );
1056   createGeomAction( GEOMOp::OpPropagate,      "PROPAGATE" );
1057
1058   createGeomAction( GEOMOp::OpSewing,           "SEWING" );
1059   createGeomAction( GEOMOp::OpGlueFaces,        "GLUE_FACES" );
1060   createGeomAction( GEOMOp::OpGlueEdges,        "GLUE_EDGES" );
1061   createGeomAction( GEOMOp::OpLimitTolerance,   "LIMIT_TOLERANCE" );
1062   createGeomAction( GEOMOp::OpSuppressFaces,    "SUPPRESS_FACES" );
1063   createGeomAction( GEOMOp::OpSuppressHoles,    "SUPPERSS_HOLES" );
1064   createGeomAction( GEOMOp::OpShapeProcess,     "SHAPE_PROCESS" );
1065   createGeomAction( GEOMOp::OpCloseContour,     "CLOSE_CONTOUR" );
1066   createGeomAction( GEOMOp::OpRemoveIntWires,   "SUPPRESS_INT_WIRES" );
1067   createGeomAction( GEOMOp::OpAddPointOnEdge,   "POINT_ON_EDGE" );
1068   createGeomAction( GEOMOp::OpFreeBoundaries,   "CHECK_FREE_BNDS" );
1069   createGeomAction( GEOMOp::OpFreeFaces,        "CHECK_FREE_FACES" );
1070   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
1071   createGeomAction( GEOMOp::OpRemoveWebs,       "REMOVE_WEBS" );
1072   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
1073   createGeomAction( GEOMOp::OpFuseEdges,        "FUSE_EDGES" );
1074   createGeomAction( GEOMOp::OpUnionFaces,       "UNION_FACES" );
1075   createGeomAction( GEOMOp::OpInspectObj,       "INSPECT_OBJECT" );
1076
1077   createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
1078   createGeomAction( GEOMOp::OpProperties,       "BASIC_PROPS" );
1079   createGeomAction( GEOMOp::OpCenterMass,       "MASS_CENTER" );
1080   createGeomAction( GEOMOp::OpInertia,          "INERTIA" );
1081   createGeomAction( GEOMOp::OpNormale,          "NORMALE" );
1082   createGeomAction( GEOMOp::OpBoundingBox,      "BND_BOX" );
1083   createGeomAction( GEOMOp::OpMinDistance,      "MIN_DIST" );
1084   createGeomAction( GEOMOp::OpAngle,            "MEASURE_ANGLE" );
1085   createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
1086   createGeomAction( GEOMOp::OpAnnotation,       "ANNOTATION" );
1087   createGeomAction( GEOMOp::OpEditAnnotation,   "EDIT_ANNOTATION" );
1088   createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
1089
1090   createGeomAction( GEOMOp::OpTolerance,        "TOLERANCE" );
1091   createGeomAction( GEOMOp::OpWhatIs,           "WHAT_IS" );
1092   createGeomAction( GEOMOp::OpCheckShape,       "CHECK" );
1093   createGeomAction( GEOMOp::OpCheckCompound,    "CHECK_COMPOUND" );
1094   createGeomAction( GEOMOp::OpGetNonBlocks,     "GET_NON_BLOCKS" );
1095   createGeomAction( GEOMOp::OpCheckSelfInters,  "CHECK_SELF_INTERSECTIONS" );
1096   createGeomAction( GEOMOp::OpFastCheckInters,  "FAST_CHECK_INTERSECTIONS" );
1097 #ifndef DISABLE_PLOT2DVIEWER
1098   createGeomAction( GEOMOp::OpShapeStatistics,  "SHAPE_STATISTICS" );
1099 #endif
1100
1101 #ifndef DISABLE_PYCONSOLE
1102 #ifdef _DEBUG_ // PAL16821
1103   createGeomAction( GEOMOp::OpCheckGeom,        "CHECK_GEOMETRY" );
1104 #endif
1105 #endif
1106
1107   createGeomAction( GEOMOp::OpMaterialsLibrary,   "MATERIALS_LIBRARY" );
1108   createGeomAction( GEOMOp::OpDMWireframe,        "WIREFRAME" );
1109   createGeomAction( GEOMOp::OpDMShading,          "SHADING" );
1110   createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
1111   createGeomAction( GEOMOp::OpDMTexture,          "TEXTURE" );
1112   createGeomAction( GEOMOp::OpShowAll,          "DISPLAY_ALL" );
1113   createGeomAction( GEOMOp::OpHideAll,          "ERASE_ALL" );
1114   createGeomAction( GEOMOp::OpShow,             "DISPLAY" );
1115   createGeomAction( GEOMOp::OpSwitchVectors,    "VECTOR_MODE");
1116   createGeomAction( GEOMOp::OpSwitchVertices,   "VERTICES_MODE");
1117   createGeomAction( GEOMOp::OpSwitchName,       "NAME_MODE");
1118   createGeomAction( GEOMOp::OpSelectVertex,     "VERTEX_SEL_ONLY" ,"", 0, true );
1119   createGeomAction( GEOMOp::OpSelectEdge,       "EDGE_SEL_ONLY", "", 0, true );
1120   createGeomAction( GEOMOp::OpSelectWire,       "WIRE_SEL_ONLY", "",  0, true );
1121   createGeomAction( GEOMOp::OpSelectFace,       "FACE_SEL_ONLY", "", 0, true );
1122   createGeomAction( GEOMOp::OpSelectShell,      "SHELL_SEL_ONLY", "",  0, true );
1123   createGeomAction( GEOMOp::OpSelectSolid,      "SOLID_SEL_ONLY", "", 0, true );
1124   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
1125   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
1126   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
1127   createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
1128   createGeomAction( GEOMOp::OpBringToFront,     "BRING_TO_FRONT", "", 0, true );
1129   createGeomAction( GEOMOp::OpClsBringToFront,  "CLS_BRING_TO_FRONT" );
1130   createGeomAction( GEOMOp::OpHide,             "ERASE" );
1131
1132   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
1133   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
1134   createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
1135   createGeomAction( GEOMOp::OpTexture,          "POP_TEXTURE", "", 0, true );
1136   createGeomAction( GEOMOp::OpEdgeWidth,        "EDGE_WIDTH");
1137   createGeomAction( GEOMOp::OpIsosWidth,        "ISOS_WIDTH");
1138   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
1139   createGeomAction( GEOMOp::OpVertices,         "POP_VERTICES", "", 0, true );
1140   createGeomAction( GEOMOp::OpShowName,         "POP_SHOW_NAME", "", 0, true );
1141   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
1142   createGeomAction( GEOMOp::OpColor,            "POP_COLOR" );
1143   createGeomAction( GEOMOp::OpSetTexture,       "POP_SETTEXTURE" );
1144   createGeomAction( GEOMOp::OpTransparency,     "POP_TRANSPARENCY" );
1145   createGeomAction( GEOMOp::OpIsos,             "POP_ISOS" );
1146   createGeomAction( GEOMOp::OpAutoColor,        "POP_AUTO_COLOR" );
1147   createGeomAction( GEOMOp::OpNoAutoColor,      "POP_DISABLE_AUTO_COLOR" );
1148   createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
1149   createGeomAction( GEOMOp::OpEditFieldPopup,   "POP_EDIT_FIELD" );
1150   createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
1151   createGeomAction( GEOMOp::OpConcealChildren,  "POP_CONCEAL_CHILDREN" );
1152   createGeomAction( GEOMOp::OpUnpublishObject,  "POP_UNPUBLISH_OBJ" );
1153   createGeomAction( GEOMOp::OpPublishObject,    "POP_PUBLISH_OBJ" );
1154   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
1155   createGeomAction( GEOMOp::OpMaterialProperties,   "POP_MATERIAL_PROPERTIES" );
1156   createGeomAction( GEOMOp::OpPredefMaterCustom,    "POP_PREDEF_MATER_CUSTOM" );
1157   createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
1158   createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
1159 #ifndef DISABLE_GRAPHICSVIEW
1160   createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
1161 #endif
1162   createGeomAction( GEOMOp::OpReduceStudy,        "POP_REDUCE_STUDY" );
1163   createGeomAction( GEOMOp::OpShowAllDimensions,  "POP_SHOW_ALL_DIMENSIONS" );
1164   createGeomAction( GEOMOp::OpHideAllDimensions,  "POP_HIDE_ALL_DIMENSIONS" );
1165   createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
1166   createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
1167
1168   // Create actions for increase/decrease transparency shortcuts
1169   createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
1170                     "Geometry:Increase transparency");
1171   createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
1172                     "Geometry:Decrease transparency");
1173
1174   // Create actions for increase/decrease number of isolines
1175   createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
1176                     "Geometry:Increase number of isolines");
1177   createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
1178                     "Geometry:Decrease number of isolines");
1179
1180   //createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
1181   //createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
1182   //createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
1183   //createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
1184   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
1185
1186   // ---- create menus --------------------------
1187
1188   /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
1189
1190   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
1191   createMenu( GEOMOp::OpDelete, editId, -1 );
1192
1193   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
1194
1195   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
1196   createMenu( GEOMOp::OpPoint,            basicId, -1 );
1197   createMenu( GEOMOp::OpLine,             basicId, -1 );
1198   createMenu( GEOMOp::OpCircle,           basicId, -1 );
1199   createMenu( GEOMOp::OpEllipse,          basicId, -1 );
1200   createMenu( GEOMOp::OpArc,              basicId, -1 );
1201   createMenu( GEOMOp::OpCurve,            basicId, -1 );
1202   createMenu( GEOMOp::Op2dSketcher,       basicId, -1 );
1203   createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
1204   createMenu( GEOMOp::Op3dSketcher,       basicId, -1 );
1205   createMenu( GEOMOp::OpIsoline,          basicId, -1 );
1206   createMenu( GEOMOp::OpSurfaceFromFace, basicId, -1 );
1207   createMenu( separator(),                basicId, -1 );
1208   createMenu( GEOMOp::OpVector,           basicId, -1 );
1209   createMenu( GEOMOp::OpPlane,            basicId, -1 );
1210   createMenu( GEOMOp::OpLCS,              basicId, -1 );
1211   createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
1212
1213   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
1214   createMenu( GEOMOp::OpBox,       primId, -1 );
1215   createMenu( GEOMOp::OpCylinder,  primId, -1 );
1216   createMenu( GEOMOp::OpSphere,    primId, -1 );
1217   createMenu( GEOMOp::OpTorus,     primId, -1 );
1218   createMenu( GEOMOp::OpCone,      primId, -1 );
1219   createMenu( GEOMOp::OpRectangle, primId, -1 );
1220   createMenu( GEOMOp::OpDisk,      primId, -1 );
1221   //createMenu( GEOMOp::OpPipeTShape,primId, -1 );
1222
1223   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
1224   createMenu( GEOMOp::OpPrism,      genId, -1 );
1225   createMenu( GEOMOp::OpRevolution, genId, -1 );
1226   createMenu( GEOMOp::OpFilling,    genId, -1 );
1227   createMenu( GEOMOp::OpPipe,       genId, -1 );
1228   createMenu( GEOMOp::OpPipePath,   genId, -1 );
1229   createMenu( GEOMOp::OpThickness,  genId, -1 );
1230
1231   //int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
1232   //createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
1233   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
1234
1235   createMenu( separator(), newEntId, -1 );
1236
1237   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
1238   createMenu( GEOMOp::OpGroupCreate,    groupId, -1 );
1239   createMenu( GEOMOp::OpGroupEdit,      groupId, -1 );
1240   createMenu( GEOMOp::OpGroupUnion,     groupId, -1 );
1241   createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
1242   createMenu( GEOMOp::OpGroupCut,       groupId, -1 );
1243
1244   createMenu( separator(), newEntId, -1 );
1245
1246   int fieldId = createMenu( tr( "MEN_FIELD" ), newEntId, -1 );
1247   createMenu( GEOMOp::OpCreateField,    fieldId, -1 );
1248   createMenu( GEOMOp::OpEditField,      fieldId, -1 );
1249
1250   createMenu( separator(), newEntId, -1 );
1251
1252   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
1253   createMenu( GEOMOp::OpQuadFace,        blocksId, -1 );
1254   createMenu( GEOMOp::OpHexaSolid,       blocksId, -1 );
1255   //createMenu( GEOMOp::OpDividedDisk,     blocksId, -1 );
1256   //createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
1257
1258   createMenu( separator(),          newEntId, -1 );
1259
1260   createMenu( GEOMOp::OpExplode,    newEntId, -1 );
1261
1262   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
1263   createMenu( GEOMOp::OpEdge,     buildId, -1 );
1264   createMenu( GEOMOp::OpWire,     buildId, -1 );
1265   createMenu( GEOMOp::OpFace,     buildId, -1 );
1266   createMenu( GEOMOp::OpShell,    buildId, -1 );
1267   createMenu( GEOMOp::OpSolid,    buildId, -1 );
1268   createMenu( GEOMOp::OpCompound, buildId, -1 );
1269
1270   createMenu( separator(),          newEntId, -1 );
1271
1272   createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1273 #ifdef WITH_OPENCV
1274   createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1275 #endif
1276
1277   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1278
1279   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1280   createMenu( GEOMOp::OpFuse,    boolId, -1 );
1281   createMenu( GEOMOp::OpCommon,  boolId, -1 );
1282   createMenu( GEOMOp::OpCut,     boolId, -1 );
1283   createMenu( GEOMOp::OpSection, boolId, -1 );
1284
1285   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1286   createMenu( GEOMOp::OpTranslate,      transId, -1 );
1287   createMenu( GEOMOp::OpRotate,         transId, -1 );
1288   createMenu( GEOMOp::OpChangeLoc,      transId, -1 );
1289   createMenu( GEOMOp::OpMirror,         transId, -1 );
1290   createMenu( GEOMOp::OpScale,          transId, -1 );
1291   createMenu( GEOMOp::OpOffset,         transId, -1 );
1292   createMenu( GEOMOp::OpProjection,     transId, -1 );
1293   createMenu( GEOMOp::OpExtension,      transId, -1 );
1294   createMenu( GEOMOp::OpProjOnCyl,      transId, -1 );
1295   createMenu( separator(),              transId, -1 );
1296   createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1297   createMenu( GEOMOp::OpMultiRotate,    transId, -1 );
1298
1299   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1300   createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1301   createMenu( GEOMOp::OpExplodeBlock,   blockId, -1 );
1302   createMenu( GEOMOp::OpPropagate,      blockId, -1 );
1303
1304   createMenu( separator(), operId, -1 );
1305
1306   createMenu( GEOMOp::OpPartition,     operId, -1 );
1307   createMenu( GEOMOp::OpArchimede,     operId, -1 );
1308   createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1309   createMenu( GEOMOp::OpSharedShapes,  operId, -1 );
1310   createMenu( GEOMOp::OpTransferData,  operId, -1 );
1311   createMenu( GEOMOp::OpExtraction,    operId, -1 );
1312
1313   createMenu( separator(), operId, -1 );
1314
1315   createMenu( GEOMOp::OpFillet1d,      operId, -1 );
1316   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
1317   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
1318   createMenu( GEOMOp::OpChamfer,       operId, -1 );
1319   createMenu( GEOMOp::OpExtrudedBoss,  operId, -1 );
1320   createMenu( GEOMOp::OpExtrudedCut,   operId, -1 );
1321
1322   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1323   createMenu( GEOMOp::OpShapeProcess,    repairId, -1 );
1324   createMenu( GEOMOp::OpSuppressFaces,   repairId, -1 );
1325   createMenu( GEOMOp::OpCloseContour,    repairId, -1 );
1326   createMenu( GEOMOp::OpRemoveIntWires,  repairId, -1 );
1327   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
1328   createMenu( GEOMOp::OpSewing,          repairId, -1 );
1329   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
1330   createMenu( GEOMOp::OpGlueEdges,       repairId, -1 );
1331   createMenu( GEOMOp::OpLimitTolerance,  repairId, -1 );
1332   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
1333   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
1334   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
1335   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
1336   createMenu( GEOMOp::OpRemoveWebs,       repairId, -1 );
1337   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1338   createMenu( GEOMOp::OpFuseEdges,        repairId, -1 );
1339   createMenu( GEOMOp::OpUnionFaces,       repairId, -1 );
1340
1341   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1342   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1343   createMenu( GEOMOp::OpProperties,       measurId, -1 );
1344   createMenu( separator(),                measurId, -1 );
1345   createMenu( GEOMOp::OpCenterMass,       measurId, -1 );
1346   createMenu( GEOMOp::OpInertia,          measurId, -1 );
1347   createMenu( GEOMOp::OpNormale,          measurId, -1 );
1348   createMenu( separator(),                measurId, -1 );
1349   createMenu( GEOMOp::OpFreeBoundaries,   measurId, -1 );
1350   createMenu( GEOMOp::OpFreeFaces,        measurId, -1 );
1351   createMenu( separator(),                measurId, -1 );
1352
1353   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1354   createMenu( GEOMOp::OpBoundingBox,      dimId, -1 );
1355   createMenu( GEOMOp::OpMinDistance,      dimId, -1 );
1356   createMenu( GEOMOp::OpAngle,            dimId, -1 );
1357   createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
1358
1359   createMenu( GEOMOp::OpAnnotation,       measurId, -1 );
1360
1361   createMenu( separator(),               measurId, -1 );
1362   createMenu( GEOMOp::OpTolerance,       measurId, -1 );
1363   createMenu( separator(),               measurId, -1 );
1364   createMenu( GEOMOp::OpWhatIs,          measurId, -1 );
1365   createMenu( GEOMOp::OpCheckShape,      measurId, -1 );
1366   createMenu( GEOMOp::OpCheckCompound,   measurId, -1 );
1367   createMenu( GEOMOp::OpGetNonBlocks,    measurId, -1 );
1368   createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1369   createMenu( GEOMOp::OpFastCheckInters, measurId, -1 );
1370   createMenu( GEOMOp::OpInspectObj,      measurId, -1 );
1371 #ifndef DISABLE_PLOT2DVIEWER
1372   createMenu( GEOMOp::OpShapeStatistics, measurId, -1 );
1373 #endif
1374
1375   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1376 #ifndef DISABLE_PYCONSOLE
1377 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1378   createMenu( separator(),         toolsId, -1 );
1379   createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1380 #endif
1381 #endif
1382
1383   createMenu( separator(),         toolsId, -1 );
1384   createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1385   createMenu( separator(),         toolsId, -1 );
1386
1387   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1388   createMenu( separator(),       viewId, -1 );
1389
1390   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1391   createMenu( GEOMOp::OpDMWireframe,        dispmodeId, -1 );
1392   createMenu( GEOMOp::OpDMShading,          dispmodeId, -1 );
1393   createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1394   createMenu( GEOMOp::OpDMTexture,          dispmodeId, -1 );
1395   createMenu( separator(),                  dispmodeId, -1 );
1396   createMenu( GEOMOp::OpSwitchVectors,      dispmodeId, -1 );
1397   createMenu( GEOMOp::OpSwitchVertices,     dispmodeId, -1 );
1398   createMenu( GEOMOp::OpSwitchName,         dispmodeId, -1 );
1399
1400   createMenu( separator(),       viewId, -1 );
1401   createMenu( GEOMOp::OpShowAll, viewId, -1 );
1402   createMenu( GEOMOp::OpHideAll, viewId, -1 );
1403   createMenu( separator(),       viewId, -1 );
1404   createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1405   createMenu( separator(),       viewId, -1 );
1406
1407 /*
1408   PAL9111:
1409   because of these items are accessible through object browser and viewers
1410   we have removed they from main menu
1411
1412   createMenu( GEOMOp::OpShow, viewId, -1 );
1413   createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1414   createMenu( GEOMOp::OpHide, viewId, -1 );
1415 */
1416
1417   // ---- create toolbars --------------------------
1418
1419   int basicTbId = createTool( tr( "TOOL_BASIC" ), QString( "GEOMBasic" ) );
1420   createTool( GEOMOp::OpPoint,            basicTbId );
1421   createTool( GEOMOp::OpLine,             basicTbId );
1422   createTool( GEOMOp::OpCircle,           basicTbId );
1423   createTool( GEOMOp::OpEllipse,          basicTbId );
1424   createTool( GEOMOp::OpArc,              basicTbId );
1425   createTool( GEOMOp::OpCurve,            basicTbId );
1426   createTool( GEOMOp::OpVector,           basicTbId );
1427   createTool( GEOMOp::Op2dSketcher,       basicTbId ); //rnc
1428   createTool( GEOMOp::Op2dPolylineEditor, basicTbId ); 
1429   createTool( GEOMOp::Op3dSketcher,       basicTbId ); //rnc
1430   createTool( GEOMOp::OpIsoline,          basicTbId );
1431   createTool( GEOMOp::OpSurfaceFromFace,  basicTbId );
1432   createTool( GEOMOp::OpPlane,            basicTbId );
1433   createTool( GEOMOp::OpLCS,              basicTbId );
1434   createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1435
1436 //   int sketchTbId = createTool( tr( "TOOL_SKETCH" ), QString( "GEOMSketch" ) );
1437 //   createTool( GEOMOp::Op2dSketcher,  sketchTbId );
1438 //   createTool( GEOMOp::Op3dSketcher,  sketchTbId );
1439
1440   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ), QString( "GEOMPrimitives" ) );
1441   createTool( GEOMOp::OpBox,        primTbId );
1442   createTool( GEOMOp::OpCylinder,   primTbId );
1443   createTool( GEOMOp::OpSphere,     primTbId );
1444   createTool( GEOMOp::OpTorus,      primTbId );
1445   createTool( GEOMOp::OpCone,       primTbId );
1446   createTool( GEOMOp::OpRectangle,  primTbId );
1447   createTool( GEOMOp::OpDisk,       primTbId );
1448   //createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1449
1450   //int blocksTbId = createTool( tr( "TOOL_BLOCKS" ), QString( "GEOMBlocks" ) );
1451   //createTool( GEOMOp::OpDividedDisk, blocksTbId );
1452   //createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1453
1454   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ), QString( "GEOMBooleanOperations" ) );
1455   createTool( GEOMOp::OpFuse,       boolTbId );
1456   createTool( GEOMOp::OpCommon,     boolTbId );
1457   createTool( GEOMOp::OpCut,        boolTbId );
1458   createTool( GEOMOp::OpSection,    boolTbId );
1459
1460   int genTbId = createTool( tr( "TOOL_GENERATION" ), QString( "GEOMGeneration" ) );
1461   createTool( GEOMOp::OpPrism,      genTbId );
1462   createTool( GEOMOp::OpRevolution, genTbId );
1463   createTool( GEOMOp::OpFilling,    genTbId );
1464   createTool( GEOMOp::OpPipe,       genTbId );
1465   createTool( GEOMOp::OpPipePath,   genTbId );
1466   createTool( GEOMOp::OpThickness,  genTbId );
1467
1468   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ), QString( "GEOMTransformation" ) );
1469   createTool( GEOMOp::OpTranslate,      transTbId );
1470   createTool( GEOMOp::OpRotate,         transTbId );
1471   createTool( GEOMOp::OpChangeLoc,      transTbId );
1472   createTool( GEOMOp::OpMirror,         transTbId );
1473   createTool( GEOMOp::OpScale,          transTbId );
1474   createTool( GEOMOp::OpOffset,         transTbId );
1475   createTool( GEOMOp::OpProjection,     transTbId );
1476   createTool( GEOMOp::OpExtension,      transTbId );
1477   createTool( GEOMOp::OpProjOnCyl,      transTbId );
1478   createTool( separator(),              transTbId );
1479   createTool( GEOMOp::OpMultiTranslate, transTbId );
1480   createTool( GEOMOp::OpMultiRotate,    transTbId );
1481
1482   int operTbId = createTool( tr( "TOOL_OPERATIONS" ), QString( "GEOMOperations" ) );
1483   createTool( GEOMOp::OpExplode,         operTbId );
1484   createTool( GEOMOp::OpPartition,       operTbId );
1485   createTool( GEOMOp::OpArchimede,       operTbId );
1486   createTool( GEOMOp::OpShapesOnShape,   operTbId );
1487   createTool( GEOMOp::OpSharedShapes,    operTbId );
1488   createTool( GEOMOp::OpTransferData,    operTbId );
1489   createTool( GEOMOp::OpExtraction,      operTbId );
1490
1491   int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) );
1492   createTool( GEOMOp::OpFillet1d,        featTbId );
1493   createTool( GEOMOp::OpFillet2d,        featTbId );
1494   createTool( GEOMOp::OpFillet3d,        featTbId );
1495   createTool( GEOMOp::OpChamfer,         featTbId );
1496   createTool( GEOMOp::OpExtrudedBoss,    featTbId );
1497   createTool( GEOMOp::OpExtrudedCut,     featTbId );
1498
1499   int buildTbId = createTool( tr( "TOOL_BUILD" ), QString( "GEOMBuild" ) );
1500   createTool( GEOMOp::OpEdge,     buildTbId );
1501   createTool( GEOMOp::OpWire,     buildTbId );
1502   createTool( GEOMOp::OpFace,     buildTbId );
1503   createTool( GEOMOp::OpShell,    buildTbId );
1504   createTool( GEOMOp::OpSolid,    buildTbId );
1505   createTool( GEOMOp::OpCompound, buildTbId );
1506
1507   int measureTbId = createTool( tr( "TOOL_MEASURES" ), QString( "GEOMMeasures" ) );
1508   createTool( GEOMOp::OpPointCoordinates, measureTbId );
1509   createTool( GEOMOp::OpProperties,       measureTbId );
1510   createTool( GEOMOp::OpCenterMass,       measureTbId );
1511   createTool( GEOMOp::OpInertia,          measureTbId );
1512   createTool( GEOMOp::OpNormale,          measureTbId );
1513   createTool( separator(),                measureTbId );
1514   createTool( GEOMOp::OpBoundingBox,      measureTbId );
1515   createTool( GEOMOp::OpMinDistance,      measureTbId );
1516   createTool( GEOMOp::OpAngle,            measureTbId );
1517   createTool( GEOMOp::OpAnnotation,       measureTbId );
1518   createTool( GEOMOp::OpTolerance  ,      measureTbId );
1519   createTool( separator(),                measureTbId );
1520   createTool( GEOMOp::OpFreeBoundaries,   measureTbId );
1521   createTool( GEOMOp::OpFreeFaces,        measureTbId );
1522   createTool( separator(),                measureTbId );
1523   createTool( GEOMOp::OpWhatIs,           measureTbId );
1524   createTool( GEOMOp::OpCheckShape,       measureTbId );
1525   createTool( GEOMOp::OpCheckCompound,    measureTbId );
1526   createTool( GEOMOp::OpGetNonBlocks,     measureTbId );
1527   createTool( GEOMOp::OpCheckSelfInters,  measureTbId );
1528   createTool( GEOMOp::OpFastCheckInters,  measureTbId );
1529
1530   int picturesTbId = createTool( tr( "TOOL_PICTURES" ), QString( "GEOMPictures" ) );
1531   createTool( GEOMOp::OpPictureImport,    picturesTbId );
1532 #ifdef WITH_OPENCV
1533   createTool( GEOMOp::OpFeatureDetect,  picturesTbId );
1534 #endif
1535
1536   //int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1537   //createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1538   //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
1539
1540   // ---- create popup menus --------------------------
1541
1542   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1543   QString clientOCC = "(client='OCCViewer')";
1544   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1545   QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1546
1547   QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1548   QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1549   QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1550   QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1551
1552   QString autoColorPrefix =
1553     "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer') and type='Shape' and selcount=1";
1554
1555   QtxPopupMgr* mgr = popupMgr();
1556
1557   mgr->insert( action(  GEOMOp::OpDelete ), -1, -1 );  // delete
1558   mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group' 'Folder' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1559   mgr->insert( action(  GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1560   mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1561   mgr->insert( action(  GEOMOp::OpEditFieldPopup ), -1, -1 ); // edit field
1562   mgr->setRule( action( GEOMOp::OpEditFieldPopup ), QString("(type='Field' or type='FieldStep') and isOCC=true"), QtxPopupMgr::VisibleRule );
1563   mgr->insert( action(  GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1564   mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1565
1566   mgr->insert( action(  GEOMOp::OpConcealChildren ), -1, -1 ); // conceal child items
1567   mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1568   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
1569   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1570   mgr->insert( separator(), -1, -1 );     // -----------
1571
1572   //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1573   QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
1574   mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1575   mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1576   mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1577   mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1578   mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
1579   mgr->insert( separator(), -1, -1 );     // -----------
1580   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1581   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1582   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1583   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1584   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1585   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1586   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1587   mgr->insert( action(  GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1588   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1589   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1590   mgr->insert( action(  GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1591   mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1592   mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1593   mgr->insert( separator(), dispmodeId, -1 );
1594   mgr->insert( action(  GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1595   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible  + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1596   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1597   mgr->insert( action(  GEOMOp::OpVertices ), dispmodeId, -1 ); // vertices
1598   mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK_AndSomeVisible  + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1599   mgr->setRule( action( GEOMOp::OpVertices ), clientOCCorVTK + " and isVerticesMode", QtxPopupMgr::ToggleRule );
1600   mgr->insert( action(  GEOMOp::OpShowName ), dispmodeId, -1 ); // show name
1601   mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK_AndSomeVisible  + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1602   mgr->setRule( action( GEOMOp::OpShowName ), clientOCCorVTK + " and isNameMode", QtxPopupMgr::ToggleRule );
1603   mgr->insert( separator(), -1, -1 );     // -----------
1604
1605   mgr->insert( action(  GEOMOp::OpColor ), -1, -1 ); // color
1606   mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1607   mgr->insert( action(  GEOMOp::OpTransparency ), -1, -1 ); // transparency
1608   mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1609   mgr->insert( action(  GEOMOp::OpIsos ), -1, -1 ); // isos
1610   mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1611   mgr->insert( action(  GEOMOp::OpDeflection ), -1, -1 ); // deflection
1612   mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1613   mgr->insert( action(  GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1614   mgr->setRule( action( GEOMOp::OpPointMarker ), clientOCCorOB + " and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0 and isOCC=true", QtxPopupMgr::VisibleRule );
1615
1616   // material properties
1617   mgr->insert( action(  GEOMOp::OpMaterialProperties ), -1, -1 );
1618   mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1619
1620  // texture
1621   mgr->insert( action(  GEOMOp::OpSetTexture ), -1, -1 );
1622   mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1623
1624   int lineW = mgr->insert(  tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1625   mgr->insert( action(  GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1626   mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1627
1628   mgr->insert( action(  GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1629   mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1630
1631   mgr->insert( separator(), -1, -1 );     // -----------
1632   mgr->insert( action(  GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1633   mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1634   mgr->insert( action(  GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1635   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1636   mgr->insert( separator(), -1, -1 );     // -----------
1637
1638   mgr->insert( action(  GEOMOp::OpEditAnnotation ), -1, -1 );  // edit annotation
1639   mgr->setRule( action( GEOMOp::OpEditAnnotation ),  clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
1640   mgr->insert( action(  GEOMOp::OpDeleteAnnotation ), -1, -1 );  // delete annotation
1641   mgr->setRule( action( GEOMOp::OpDeleteAnnotation ),  clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
1642   mgr->insert( separator(), -1, -1 );     // -----------
1643
1644   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1645           onlyComponent = "((type='Component') and selcount=1)",
1646           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1647           types = "'Shape' 'Group' 'FieldStep'";
1648
1649   mgr->insert( action(  GEOMOp::OpShow ), -1, -1 ); // display
1650   mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1651
1652   mgr->insert( action(  GEOMOp::OpHide ), -1, -1 ); // erase
1653   mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1654
1655   mgr->insert( action(  GEOMOp::OpHideAll ), -1, -1 ); // erase All
1656   mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1657
1658   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1659
1660   int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
1661   mgr->insert( action(GEOMOp::OpSelectVertex),   selectonlyId, -1);                                  //Vertex
1662   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly, QtxPopupMgr::VisibleRule);
1663   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1664   mgr->insert( action(GEOMOp::OpSelectEdge),     selectonlyId, -1);                                  //Edge
1665   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly, QtxPopupMgr::VisibleRule);
1666   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1667   mgr->insert( action(GEOMOp::OpSelectWire),     selectonlyId, -1);                                  //Wire
1668   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly, QtxPopupMgr::VisibleRule);
1669   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1670   mgr->insert( action(GEOMOp::OpSelectFace),     selectonlyId, -1);                                  //Face
1671   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly, QtxPopupMgr::VisibleRule);
1672   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1673   mgr->insert( action(GEOMOp::OpSelectShell),    selectonlyId, -1);                                  //Shell
1674   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly, QtxPopupMgr::VisibleRule);
1675   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1676   mgr->insert( action(GEOMOp::OpSelectSolid),    selectonlyId, -1);                                  //Solid
1677   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly, QtxPopupMgr::VisibleRule);
1678   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1679   mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1);                                  //Compound
1680   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1681   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1682   mgr->insert( separator(), selectonlyId, -1);
1683   mgr->insert( action(GEOMOp::OpSelectAll),      selectonlyId, -1);                                  //Clear selection filter
1684   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly, QtxPopupMgr::VisibleRule);
1685   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1686   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1687   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1688   mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1689   mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1690
1691   QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
1692
1693   mgr->insert( separator(), -1, -1 ); // -----------
1694   mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
1695   mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
1696   mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
1697   mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
1698   mgr->insert( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
1699   mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
1700   mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
1701   mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
1702
1703   mgr->insert( separator(), -1, -1 );     // -----------
1704   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1705   mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
1706
1707   mgr->insert( action(  GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1708   mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1709
1710   mgr->insert( action(  GEOMOp::OpReimport ), -1, -1 );  // delete
1711   mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1712
1713   mgr->insert( separator(), -1, -1 );     // -----------
1714   mgr->insert( action(  GEOMOp::OpCreateFolder ), -1, -1 ); // Create Folder
1715   mgr->setRule( action( GEOMOp::OpCreateFolder ), QString("client='ObjectBrowser' and $component={'GEOM'} and (isComponent=true or isFolder=true)"), QtxPopupMgr::VisibleRule );
1716
1717   mgr->insert( separator(), -1, -1 );     // -----------
1718   mgr->insert( action(  GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
1719   mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
1720
1721 #ifndef DISABLE_GRAPHICSVIEW
1722   mgr->insert( separator(), -1, -1 );     // -----------
1723   mgr->insert( action(  GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
1724   mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1725 #endif
1726
1727   mgr->insert( separator(), -1, -1 );     // -----------
1728   mgr->insert( action(  GEOMOp::OpReduceStudy ), -1, -1 ); // Reduce Study
1729   mgr->setRule( action( GEOMOp::OpReduceStudy ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
1730
1731   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1732
1733   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1734   if (resMgr) {
1735     GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1736     QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1737     GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1738   }
1739
1740   // create plugin actions and menus
1741   addPluginActions();
1742 }
1743
1744 //=======================================================================
1745 // function : GeometryGUI::addPluginActions()
1746 // purpose  :
1747 //=======================================================================
1748 void GeometryGUI::addPluginActions()
1749 {
1750   // Resource manager
1751   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1752   if (!resMgr) return;
1753
1754   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1755   if (!appStudy) return;
1756
1757   // Find names of a resource XML files ("AdvancedGEOM.xml" and others);
1758
1759   GEOMUtils::PluginInfo plugins = GEOMUtils::ReadPluginInfo();
1760
1761   int id = GEOMOp::OpLastOperationID; // TODO?
1762
1763   // loop on plugins
1764   GEOMUtils::PluginInfo::const_iterator it;
1765   for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1766     // bind action lib and label to its ID for activateOperation() method proper work
1767     GEOMUtils::PluginData pdata = (*it);
1768     myPluginLibs[pdata.name.c_str()] = pdata.clientLib.c_str();
1769     std::list<GEOMUtils::ActionData> actions = (*it).actions;
1770     std::list<GEOMUtils::ActionData>::const_iterator ait;
1771     for ( ait = actions.begin(); ait != actions.end(); ++ait ) {
1772       GEOMUtils::ActionData adata = (*ait);
1773       // icon
1774       QPixmap icon;
1775       if ( !adata.icon.empty() )
1776         icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
1777       // menu text (path)
1778       QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
1779       QString actionName = smenus.last();
1780       actionName = actionName.toUpper().prepend( "MEN_" );
1781       smenus.removeLast();
1782
1783       // path to action in toolbar
1784       QStringList stools = QString( adata.toolTip.c_str() ).split( "/" );
1785       QString actionTool = stools.last();
1786       actionTool = actionTool.toUpper().prepend( "TOP_" );
1787       stools.removeLast();
1788       
1789       QString actionStat = adata.statusText.c_str();
1790       actionStat = actionStat.toUpper().prepend( "STB_" );
1791
1792       createAction( id, // ~ adata.label
1793                     tr( actionTool.toLatin1().constData() ),
1794                     icon,
1795                     tr( actionName.toLatin1().constData() ),
1796                     tr( actionStat.toLatin1().constData() ),
1797                     QKeySequence( tr( adata.accel.c_str() ) ),
1798                     application()->desktop(),
1799                     false /*toggle*/,
1800                     this, SLOT( OnGUIEvent() ),
1801                     QString() /*shortcutAction*/ );
1802       
1803       int menuId = -1;
1804       foreach ( QString subMenu, smenus ) {
1805         QStringList subMenuList = subMenu.split( ":" );
1806         QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
1807         int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
1808         menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
1809       }
1810       createMenu( id, menuId, -1 );
1811       
1812       if ( !stools.isEmpty() ) {
1813         QString subTool = stools[0];
1814         subTool = subTool.toUpper().prepend( "TOOL_" );
1815         int toolId = createTool( tr( subTool.toLatin1().constData() ) );
1816         createTool(id, toolId);
1817       }
1818
1819       // add action id to map
1820       PluginAction anAction( pdata.clientLib.c_str(), adata.label.c_str() );
1821       myPluginActions[id] = anAction;
1822       
1823       id++;
1824     }
1825   }
1826 }
1827
1828 //=======================================================================
1829 // function : GeometryGUI::activateModule()
1830 // purpose  : Called when GEOM module is activated
1831 //=======================================================================
1832 bool GeometryGUI::activateModule( SUIT_Study* study )
1833 {
1834   if ( CORBA::is_nil( myComponentGeom ) )
1835     return false;
1836
1837   bool res = SalomeApp_Module::activateModule( study );
1838
1839   if ( !res )
1840     return false;
1841   setMenuShown( true );
1842   setToolShown( true );
1843
1844   // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1845   PyGILState_STATE gstate = PyGILState_Ensure();
1846   PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1847   if ( !pluginsmanager ) {
1848     PyErr_Print();
1849   }
1850   else {
1851     PyObject* result =
1852       PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1853                           tr("MEN_NEW_ENTITY").toUtf8().data(),
1854                           tr("GEOM_PLUGINS_OTHER").toUtf8().data());
1855     if ( !result )
1856       PyErr_Print();
1857     Py_XDECREF(result);
1858   }
1859   PyGILState_Release(gstate);
1860   // end of GEOM plugins loading
1861
1862   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1863           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1864
1865   // Reset actions accelerator keys
1866   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1867
1868   GUIMap::Iterator it;
1869   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1870     it.value()->activate( application()->desktop() );
1871
1872   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1873
1874   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1875   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ));
1876   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1877
1878   if ( !myCreationInfoWdg )
1879     myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1880   getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1881   getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1882
1883   if ( !myTextTreeWdg ) {
1884     myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
1885     new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
1886   }
1887
1888   getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
1889   getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
1890
1891   //NPAL 19674
1892   SALOME_ListIO selected;
1893   sm->selectedObjects( selected );
1894   sm->clearSelected();
1895
1896   SUIT_ViewManager* vm;
1897   ViewManagerList OCCViewManagers, VTKViewManagers;
1898
1899   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1900   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1901   while ( itOCC.hasNext() && (vm = itOCC.next()) )
1902     onViewManagerAdded(vm);
1903
1904   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1905   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1906   while ( itVTK.hasNext() && (vm = itVTK.next()) )
1907     onViewManagerAdded(vm);
1908
1909   sm->setSelectedObjects( selected, true );   //NPAL 19674
1910
1911   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1912   if ( viewMenu )
1913     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1914
1915   // 0020836 (Basic vectors and origin)
1916   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1917   if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1918     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1919     if ( appStudy ) {
1920       _PTR(Study) studyDS = appStudy->studyDS();
1921       if ( studyDS ) {
1922         _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1923         if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1924           createOriginAndBaseVectors();
1925       }
1926     }
1927   }
1928
1929   Py_XDECREF(pluginsmanager);
1930   return true;
1931 }
1932
1933 //=======================================================================
1934 // function : GeometryGUI::deactivateModule()
1935 // purpose  : Called when GEOM module is deactivated
1936 //=======================================================================
1937 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1938 {
1939   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1940   if ( viewMenu )
1941     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1942
1943   setMenuShown( false );
1944   setToolShown( false );
1945
1946   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1947              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1948
1949   LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1950
1951   disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1952   disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateFieldColorScale() ));
1953   if ( myCreationInfoWdg ) {
1954     getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1955     myCreationInfoWdg = 0;
1956   }
1957   if ( myTextTreeWdg ) {
1958     getApp()->removeDockWindow( myTextTreeWdg->getWinID() );
1959     disconnect( application(), 0, myTextTreeWdg, 0 );
1960     myTextTreeWdg = 0;
1961   }
1962
1963   EmitSignalCloseAllDialogs();
1964
1965   GUIMap::Iterator it;
1966   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1967     it.value()->deactivate();
1968
1969   // Unset actions accelerator keys
1970   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1971
1972   qDeleteAll(myOCCSelectors);
1973   myOCCSelectors.clear();
1974   selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1975
1976   qDeleteAll(myVTKSelectors);
1977   myVTKSelectors.clear();
1978   selMrg->setEnabled( true, SVTK_Viewer::Type() );
1979
1980   return SalomeApp_Module::deactivateModule( study );
1981 }
1982
1983 //=======================================================================
1984 // function : onWindowActivated()
1985 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1986 //=======================================================================
1987 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1988 {
1989   if ( !win )
1990     return;
1991
1992   const bool ViewOCC = ( win->getViewManager() ? win->getViewManager()->getType() == OCCViewer_Viewer::Type() : false );
1993   //const bool ViewVTK = ( win->getViewManager() ? win->getViewManager()->getType() == SVTK_Viewer::Type() : false );
1994
1995   // disable non-OCC viewframe menu commands
1996 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1997   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1998   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1999   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
2000   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
2001   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
2002 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
2003
2004   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
2005   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
2006   action( GEOMOp::OpCreateField )->setEnabled( ViewOCC ); // Create Field
2007   action( GEOMOp::OpEditField )->setEnabled( ViewOCC ); // Edit Field
2008
2009   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
2010 }
2011
2012 void GeometryGUI::windows( QMap<int, int>& mappa ) const
2013 {
2014   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2015   mappa.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
2016 #ifndef DISABLE_PYCONSOLE
2017   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
2018 #endif
2019   if ( myCreationInfoWdg )
2020     mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
2021   if ( myTextTreeWdg )
2022     mappa.insert( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
2023 }
2024
2025 void GeometryGUI::viewManagers( QStringList& lst ) const
2026 {
2027   lst.append( OCCViewer_Viewer::Type() );
2028 }
2029
2030 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
2031 {
2032   if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
2033   {
2034     qDebug( "connect" );
2035     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
2036              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
2037     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
2038              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
2039     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
2040              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
2041     connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
2042              this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
2043
2044     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2045     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
2046
2047     // disable OCC selectors
2048     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
2049     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2050     while ( itOCCSel.hasNext() )
2051       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2052         sr->setEnabled(true);
2053   }
2054   else if ( vm->getType() == SVTK_Viewer::Type() )
2055   {
2056     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
2057     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
2058
2059     // disable VTK selectors
2060     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
2061     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2062     while ( itVTKSel.hasNext() )
2063       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2064         sr->setEnabled(true);
2065   }
2066 }
2067
2068 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
2069 {
2070   SUIT_ViewModel* viewer = vm->getViewModel();
2071   if ( vm->getType() == OCCViewer_Viewer::Type() )
2072   {
2073     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
2074     while ( itOCCSel.hasNext() )
2075       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
2076         if ( sr->viewer() == viewer )
2077         {
2078           /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
2079           break;
2080         }
2081   }
2082   if ( vm->getType() == SVTK_Viewer::Type() )
2083   {
2084     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
2085     while ( itVTKSel.hasNext() )
2086       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
2087         if ( sr->viewer() == viewer )
2088         {
2089           /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
2090           break;
2091         }
2092   }
2093   SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
2094   if ( aSOCCView ) {
2095     GetAnnotationMgr()->RemoveView( aSOCCView );
2096   }
2097 }
2098
2099 //================================================================================
2100 /*!
2101  * \brief Slot called when selection changed. Shows creation info of a selected object
2102  */
2103 //================================================================================
2104
2105 void GeometryGUI::updateCreationInfo()
2106 {
2107   if ( myCreationInfoWdg )
2108     myCreationInfoWdg->clear();
2109
2110   // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
2111   // if ( !myCreationInfoWdg->isVisible() )
2112   //   return;
2113
2114   // look for a sole selected GEOM_Object
2115   GEOM::GEOM_BaseObject_var geomObj;
2116
2117   SALOME_ListIO selected;
2118   getApp()->selectionMgr()->selectedObjects( selected );
2119
2120   _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
2121   SALOME_ListIteratorOfListIO selIt( selected );
2122   for ( ; selIt.More(); selIt.Next() )
2123   {
2124     Handle(SALOME_InteractiveObject) io = selIt.Value();
2125     if ( !io->hasEntry() ) continue;
2126     _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
2127     if ( !sobj ) continue;
2128     CORBA::Object_var          obj = GeometryGUI::ClientSObjectToObject( sobj );
2129     GEOM::GEOM_BaseObject_var gobj = GEOM::GEOM_BaseObject::_narrow( obj );
2130     if ( !gobj->_is_nil() )
2131     {
2132       if ( !geomObj->_is_nil() )
2133         return; // several GEOM objects selected
2134       geomObj = gobj;
2135     }
2136   }
2137   if ( geomObj->_is_nil() ) return;
2138
2139   // pass creation info of geomObj to myCreationInfoWdg
2140
2141   if ( myCreationInfoWdg ) {
2142
2143     GEOM::CreationInformationSeq_var info;
2144     try {
2145       OCC_CATCH_SIGNALS;
2146       info = geomObj->GetCreationInformation();
2147     }
2148     catch (...) {
2149     }
2150     myCreationInfoWdg->setInfo( info );
2151   }
2152 }
2153
2154 void GeometryGUI::onAutoBringToFront()
2155 {
2156   bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
2157   if( !isAutoBringToFront )
2158     return;
2159   
2160   SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
2161   if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
2162         return;
2163
2164   SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
2165   if (!appStudy) return;
2166
2167   GEOM_Displayer displayer;
2168   
2169   SALOME_View* window = displayer.GetActiveView();
2170   if ( !window ) return;
2171   
2172   int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
2173   
2174   SALOME_ListIO selected;
2175   getApp()->selectionMgr()->selectedObjects( selected );
2176   if (!myTopLevelIOList.IsEmpty())
2177   {
2178     for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() )
2179     {
2180       Handle( SALOME_InteractiveObject ) io = It.Value();
2181       bool isSelected = false;
2182       for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() )
2183       {
2184         Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value();
2185         if( io->isSame( sel_io ) )
2186           isSelected = true;
2187       }
2188       if (!isSelected && appStudy->findObjectByEntry(io->getEntry()))
2189       {
2190         appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
2191         if ( window->isVisible( io ) ) displayer.Redisplay( io, false );     
2192       }
2193     }
2194   }
2195   
2196   myTopLevelIOList.Assign(selected);
2197   for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
2198   {
2199     Handle( SALOME_InteractiveObject ) io = It.Value();
2200     appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
2201     if ( window->isVisible( io ) ) displayer.Redisplay( io, false );     
2202   }
2203     
2204   displayer.UpdateViewer();
2205   GeometryGUI::Modified();
2206 }
2207
2208 void GeometryGUI::updateFieldColorScale()
2209 {
2210   GEOM_Displayer aDisplayer;
2211   aDisplayer.UpdateColorScale();
2212 }
2213
2214 QString GeometryGUI::engineIOR() const
2215 {
2216   if ( !CORBA::is_nil( GetGeomGen() ) )
2217     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
2218   return "";
2219 }
2220
2221 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture (int theId, int& theWidth, int& theHeight)
2222 {
2223   theWidth = theHeight = 0;
2224
2225   Handle(TColStd_HArray1OfByte) aTexture;
2226
2227   aTexture = myTextureMap[ theId ];
2228   if ( aTexture.IsNull() ) {
2229     GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations();
2230     if ( !aInsOp->_is_nil() ) {
2231       CORBA::Long aWidth, aHeight;
2232       SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
2233       if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
2234         theWidth  = aWidth;
2235         theHeight = aHeight;
2236
2237         aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
2238
2239         for ( CORBA::ULong i = 0; i < aStream->length(); i++)
2240           aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
2241         myTextureMap[ theId ] = aTexture;
2242       }
2243     }
2244   }
2245   return aTexture;
2246 }
2247
2248 LightApp_Selection* GeometryGUI::createSelection() const
2249 {
2250   return new GEOMGUI_Selection();
2251 }
2252
2253 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
2254 {
2255   SalomeApp_Module::contextMenuPopup( client, menu, title );
2256   SALOME_ListIO lst;
2257   getApp()->selectionMgr()->selectedObjects( lst );
2258
2259   //Add submenu for predefined materials
2260   bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
2261   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
2262     QtxPopupMgr* mgr = popupMgr();
2263     //get parrent for submenu
2264     QAction* act = mgr->action( mgr->actionId( action(  GEOMOp::OpMaterialProperties ) ) );
2265     //Clear old  menu
2266     QMenu* oldMenu = act->menu() ;
2267     if( oldMenu ) {
2268       delete oldMenu;
2269     }
2270     if( isPredefMat ){
2271       QMenu* matMenu = new QMenu();
2272       QSignalMapper* signalMapper = new QSignalMapper( matMenu );
2273
2274       //Get current material model for the object
2275       QVariant v;
2276       LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
2277       if ( anApp && anApp->activeViewManager() ) {
2278         LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
2279         if( aStudy ) {
2280           v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
2281         }
2282       }
2283       QString curModel = "";
2284       if ( v.canConvert<QString>() ) curModel = v.toString();
2285       // get list of all predefined materials
2286       QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2287       bool found = false;
2288       foreach ( QString material, materials )
2289       {
2290         QAction* menAct = matMenu->addAction( material );
2291         connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
2292         signalMapper->setMapping( menAct, material );
2293         menAct->setCheckable( true );
2294         // Set checked if this material is current
2295         Material_Model aModel;
2296         aModel.fromResources( material );
2297         if ( !found && aModel.toProperties() == curModel ) {
2298           menAct->setChecked( true );
2299           found = true;
2300         }
2301       }
2302       matMenu->insertAction( matMenu->addSeparator(), action(  GEOMOp::OpPredefMaterCustom ) );
2303       matMenu->insertSeparator( action(  GEOMOp::OpPredefMaterCustom ) );
2304       connect( signalMapper, SIGNAL( mapped( const QString & ) ),
2305                  this, SLOT( OnSetMaterial( const QString & ) ) );
2306       act->setMenu( matMenu );
2307     }
2308   }
2309   //Set name
2310   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
2311     Handle(SALOME_InteractiveObject) io = lst.First();
2312     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
2313     _PTR(Study) study = appStudy->studyDS();
2314     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
2315     if ( obj ) {
2316       QString aName = QString( obj->GetName().c_str() );
2317       aName.remove( QRegExp("\\s+$") );
2318       title = aName;
2319     }
2320   }
2321 }
2322
2323 void GeometryGUI::OnSetMaterial(const QString& theName)
2324 {
2325   OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
2326 }
2327
2328
2329 void GeometryGUI::createPreferences()
2330 {
2331   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2332
2333   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
2334
2335   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
2336   setPreferenceProperty( genGroup, "columns", 2 );
2337
2338   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
2339                                 LightApp_Preferences::Selector,
2340                                 "Geometry", "display_mode" );
2341
2342   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
2343                  LightApp_Preferences::Color, "Geometry", "shading_color" );
2344
2345   addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
2346                  LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
2347
2348   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
2349                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
2350
2351   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
2352                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
2353
2354   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
2355                  LightApp_Preferences::Color, "Geometry", "line_color" );
2356
2357   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
2358                  LightApp_Preferences::Color, "Geometry", "point_color" );
2359
2360   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
2361                  LightApp_Preferences::Color, "Geometry", "isos_color" );
2362
2363   addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
2364                  LightApp_Preferences::Color, "Geometry", "label_color" );
2365
2366   addPreference( "", genGroup, LightApp_Preferences::Space );
2367
2368   addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
2369                  LightApp_Preferences::Color, "Geometry", "toplevel_color" );
2370
2371   int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
2372                       LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
2373
2374   int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
2375                                     LightApp_Preferences::IntSpin, "Geometry", "transparency" );
2376
2377   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
2378                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
2379
2380   addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
2381                  LightApp_Preferences::Bool, "Geometry", "predef_materials" );
2382
2383   int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
2384                                 LightApp_Preferences::Selector,
2385                                 "Geometry", "material" );
2386
2387   addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
2388                  LightApp_Preferences::Color, "Geometry", "editgroup_color" );
2389
2390   const int nb = 4;
2391   int wd[nb];
2392   int iter=0;
2393
2394   wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
2395                               LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
2396
2397   wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
2398                               LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
2399
2400   wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
2401                                      LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
2402
2403   wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
2404                               LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
2405
2406   for (int i = 0; i < nb; i++) {
2407     setPreferenceProperty( wd[i], "min", 1 );
2408     setPreferenceProperty( wd[i], "max", 5 );
2409   }
2410
2411   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
2412                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
2413
2414   addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
2415                  LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
2416
2417   // --------------------------------------------------------------------------
2418   // Dimensions (Measurements) preferences
2419   // --------------------------------------------------------------------------
2420
2421   int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
2422   setPreferenceProperty( aDimGroupId, "columns", 2 );
2423
2424   addPreference( tr( "PREF_DIMENSIONS_COLOR" ), aDimGroupId,
2425                  LightApp_Preferences::Color, "Geometry", "dimensions_color" );
2426
2427   int aDimLineWidthId = addPreference( tr( "PREF_DIMENSIONS_LINE_WIDTH" ), aDimGroupId, 
2428                                        LightApp_Preferences::IntSpin, "Geometry", "dimensions_line_width" );
2429
2430   setPreferenceProperty( aDimLineWidthId, "min", 1 );
2431   setPreferenceProperty( aDimLineWidthId, "max", 5 );
2432
2433   int aDimFontId = addPreference( tr( "PREF_DIMENSIONS_FONT" ), aDimGroupId, LightApp_Preferences::Font, "Geometry", "dimensions_font" );
2434
2435   int f = QtxFontEdit::Family | QtxFontEdit::Size;
2436   setPreferenceProperty( aDimFontId, "features", f );
2437   setPreferenceProperty( aDimFontId, "mode", QtxFontEdit::Custom );
2438
2439   Handle(Font_FontMgr) fmgr = Font_FontMgr::GetInstance();
2440   QString aFontFile = "";
2441   resMgr->value("resources", "GEOM", aFontFile);
2442   aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
2443   // add enginier font into combobox
2444   /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
2445   Handle(Font_SystemFont) sf = new Font_SystemFont( 
2446     new TCollection_HAsciiString("Y14.5M-2009"), 
2447     Font_FA_Regular, 
2448     new TCollection_HAsciiString(aFontFile.toLatin1().data()) );
2449   // register font in OCC font manager
2450   fmgr->RegisterFont( sf, Standard_False );
2451
2452   // get list of supported fonts by OCC
2453   QStringList anOCCFonts;
2454   TColStd_SequenceOfHAsciiString theFontsNames;
2455   fmgr->GetAvailableFontsNames( theFontsNames );
2456   for(Standard_Integer i=1; i<=theFontsNames.Length(); i++) {
2457     Handle(TCollection_HAsciiString) str = theFontsNames(i);
2458     anOCCFonts << str->ToCString();
2459   }
2460   anOCCFonts.removeDuplicates();
2461   // set the supported fonts into combobox to use its only
2462   setPreferenceProperty( aDimFontId, "fonts", anOCCFonts );
2463
2464   int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
2465                                        LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
2466
2467   setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
2468   setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
2469   setPreferenceProperty( aDimArrLengthId, "precision", 9 );
2470
2471   int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
2472                                       LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
2473
2474   int anAngUnitsId = addPreference( tr( "PREF_DIMENSIONS_ANGLE_UNITS" ), aDimGroupId,
2475                                    LightApp_Preferences::Selector, "Geometry", "dimensions_angle_units" );
2476
2477   QStringList aListOfLengthUnits;
2478   aListOfLengthUnits << "m";
2479   aListOfLengthUnits << "cm";
2480   aListOfLengthUnits << "mm";
2481   aListOfLengthUnits << "in.";
2482   aListOfLengthUnits << "ft.";
2483
2484   QStringList aListOfAngUnits;
2485   aListOfAngUnits << "rad";
2486   aListOfAngUnits << "deg";
2487
2488   setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
2489   setPreferenceProperty( anAngUnitsId,   "strings", aListOfAngUnits );
2490
2491   addPreference( tr( "PREF_DIMENSIONS_SHOW_UNITS" ), aDimGroupId,
2492                  LightApp_Preferences::Bool, "Geometry", "dimensions_show_units" );
2493
2494   int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
2495                                      LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
2496
2497   setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
2498   setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
2499   setPreferenceProperty( aDimDefFlyout, "precision", 9 );
2500
2501   addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
2502                  LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
2503
2504   // --------------------------------------------------------------------------
2505   // Shape annotation preferences
2506   // --------------------------------------------------------------------------
2507
2508   const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
2509   setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
2510
2511   addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
2512   addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
2513   const int aShapeAnnFont = 
2514     addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
2515
2516   int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
2517   setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
2518   setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
2519   setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
2520
2521   const int aShapeAnnLineWidth = 
2522     addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
2523
2524   setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
2525   setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
2526
2527   addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
2528
2529   const int aShapeAnnLineStyle =
2530     addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
2531
2532   QStringList aLineStyleList;
2533   aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
2534   aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
2535   aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
2536   aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
2537
2538   QList<QVariant> aLineStyleIds;
2539   aLineStyleIds.append(0);
2540   aLineStyleIds.append(1);
2541   aLineStyleIds.append(2);
2542   aLineStyleIds.append(3);
2543
2544   setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
2545   setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
2546
2547   // --------------------------------------------------------------------------
2548   // Isoline drawing preferences
2549   // --------------------------------------------------------------------------
2550
2551   int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
2552   setPreferenceProperty( isoGroup, "columns", 2 );
2553   int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2554                             LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
2555   setPreferenceProperty( isoU, "min", 0 );
2556   setPreferenceProperty( isoU, "max", 100000 );
2557   int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2558                             LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
2559   setPreferenceProperty( isoV, "min", 0 );
2560   setPreferenceProperty( isoV, "max", 100000 );
2561
2562   // Quantities with individual precision settings
2563   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
2564   setPreferenceProperty( precGroup, "columns", 2 );
2565
2566   const int nbQuantities = 8;
2567   int prec[nbQuantities], ii = 0;
2568   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
2569                               LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
2570   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
2571                               LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
2572   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
2573                               LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
2574   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
2575                               LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
2576   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
2577                               LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
2578   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
2579                               LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
2580   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
2581                               LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
2582   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
2583                               LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
2584
2585   // Set property for precision value for spinboxes
2586   for ( ii = 0; ii < nbQuantities; ii++ ){
2587     setPreferenceProperty( prec[ii], "min", -14 );
2588     setPreferenceProperty( prec[ii], "max", 14 );
2589     setPreferenceProperty( prec[ii], "precision", 2 );
2590   }
2591
2592   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
2593   setPreferenceProperty( VertexGroup, "columns", 2 );
2594
2595   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
2596                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
2597
2598   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
2599                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
2600
2601   // Set property for default display mode
2602   QStringList aModesList;
2603   aModesList.append( tr("MEN_WIREFRAME") );
2604   aModesList.append( tr("MEN_SHADING") );
2605   aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2606   aModesList.append( tr("MEN_TEXTURE") );
2607
2608   QList<QVariant> anIndexesList;
2609   anIndexesList.append(0);
2610   anIndexesList.append(1);
2611   anIndexesList.append(2);
2612   anIndexesList.append(3);
2613
2614   setPreferenceProperty( dispmode, "strings", aModesList );
2615   setPreferenceProperty( dispmode, "indexes", anIndexesList );
2616
2617   // Set property for top level display mode
2618   QStringList aTopModesList;
2619   aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2620   aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2621   aTopModesList.append( tr("MEN_WIREFRAME") );
2622   aTopModesList.append( tr("MEN_SHADING") );
2623   aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2624
2625   QList<QVariant> aTopIndexesList;
2626   aTopIndexesList.append(0);
2627   aTopIndexesList.append(1);
2628   aTopIndexesList.append(2);
2629   aTopIndexesList.append(3);
2630   aTopIndexesList.append(4);
2631
2632   setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2633   setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2634
2635   // Set property for step value for spinboxes
2636   setPreferenceProperty( step, "min", 1 );
2637   setPreferenceProperty( step, "max", 10000 );
2638   setPreferenceProperty( step, "precision", 3 );
2639
2640   // Set property for trandparency value for spinboxes
2641   setPreferenceProperty( transparency, "min", 0 );
2642   setPreferenceProperty( transparency, "max", 100 );
2643
2644   // Set property for deflection value for spinboxes
2645   setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2646   setPreferenceProperty( defl, "max", 1.0 );
2647   setPreferenceProperty( defl, "step", 1.0e-04 );
2648   setPreferenceProperty( defl, "precision", 6 );
2649
2650   // Set property for default material
2651   setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2652
2653   // Set property vertex marker type
2654   QList<QVariant> aMarkerTypeIndicesList;
2655   QList<QVariant> aMarkerTypeIconsList;
2656
2657   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2658     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2659     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2660     aMarkerTypeIndicesList << (i-1);
2661     aMarkerTypeIconsList << pixmap;
2662   }
2663
2664   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2665   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
2666
2667   // Set property for vertex marker scale
2668   QList<QVariant> aMarkerScaleIndicesList;
2669   QStringList     aMarkerScaleValuesList;
2670
2671   for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2672     aMarkerScaleIndicesList << iii;
2673     aMarkerScaleValuesList  << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2674   }
2675
2676   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2677   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2678
2679   // Scalar bar for field step presentation
2680   int scalarBarGroup = addPreference( tr( "PREF_GROUP_SCALAR_BAR" ), tabId );
2681   setPreferenceProperty( scalarBarGroup, "columns", 2 );
2682
2683   int sbXPosition = addPreference( tr( "PREF_SCALAR_BAR_X_POSITION" ), scalarBarGroup,
2684                                    LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_x_position" );
2685   setPreferenceProperty( sbXPosition, "min", 0 );
2686   setPreferenceProperty( sbXPosition, "max", 1 );
2687   setPreferenceProperty( sbXPosition, "step", 0.05 );
2688
2689   int sbYPosition = addPreference( tr( "PREF_SCALAR_BAR_Y_POSITION" ), scalarBarGroup,
2690                                    LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_y_position" );
2691   setPreferenceProperty( sbYPosition, "min", 0 );
2692   setPreferenceProperty( sbYPosition, "max", 1 );
2693   setPreferenceProperty( sbYPosition, "step", 0.05 );
2694
2695   int sbWidth = addPreference( tr( "PREF_SCALAR_BAR_WIDTH" ), scalarBarGroup,
2696                                LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_width" );
2697   setPreferenceProperty( sbWidth, "min", 0 );
2698   setPreferenceProperty( sbWidth, "max", 1 );
2699   setPreferenceProperty( sbWidth, "step", 0.05 );
2700
2701   int sbHeight = addPreference( tr( "PREF_SCALAR_BAR_HEIGHT" ), scalarBarGroup,
2702                                 LightApp_Preferences::DblSpin, "Geometry", "scalar_bar_height" );
2703   setPreferenceProperty( sbHeight, "min", 0 );
2704   setPreferenceProperty( sbHeight, "max", 1 );
2705   setPreferenceProperty( sbHeight, "step", 0.05 );
2706
2707   int sbTextHeight = addPreference( tr( "PREF_SCALAR_BAR_TEXT_HEIGHT" ), scalarBarGroup,
2708                                     LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_text_height" );
2709   setPreferenceProperty( sbTextHeight, "min", 6 );
2710   setPreferenceProperty( sbTextHeight, "max", 24 );
2711   setPreferenceProperty( sbTextHeight, "step", 1 );
2712
2713   int sbNbIntervals = addPreference( tr( "PREF_SCALAR_BAR_NUMBER_OF_INTERVALS" ), scalarBarGroup,
2714                                      LightApp_Preferences::IntSpin, "Geometry", "scalar_bar_nb_intervals" );
2715   setPreferenceProperty( sbNbIntervals, "min", 2 );
2716   setPreferenceProperty( sbNbIntervals, "max", 64 );
2717   setPreferenceProperty( sbNbIntervals, "step", 1 );
2718
2719   int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2720   setPreferenceProperty( originGroup, "columns", 2 );
2721
2722   int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2723                                          LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2724   setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2725   setPreferenceProperty( baseVectorsLength, "max", 1000 );
2726
2727   addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2728                  LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2729
2730   int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2731   setPreferenceProperty( operationsGroup, "columns", 2 );
2732
2733   addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2734                  LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2735
2736   addPreference( tr( "PREF_HIDE_INPUT_OBJECT" ), operationsGroup,
2737                  LightApp_Preferences::Bool, "Geometry", "hide_input_object" );
2738
2739   int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
2740
2741   int treeGeneralGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), DependencyViewId );
2742
2743   int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), treeGeneralGroup,
2744                       LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
2745
2746   QStringList aHierarchyTypeList;
2747   aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
2748   aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
2749   aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
2750
2751   QList<QVariant> aHierarchyTypeIndexesList;
2752   aHierarchyTypeIndexesList.append(0);
2753   aHierarchyTypeIndexesList.append(1);
2754   aHierarchyTypeIndexesList.append(2);
2755
2756   setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
2757   setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
2758
2759   addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), treeGeneralGroup,
2760                  LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
2761
2762   int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
2763
2764   addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
2765                  LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
2766
2767   addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
2768                  LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
2769   addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
2770                  LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
2771   addPreference( tr( "PREF_DEPENDENCY_VIEW_UNPUBLISH_NODE_COLOR"), treeColorGroup,
2772                  LightApp_Preferences::Color, "Geometry", "dependency_tree_unpublish_node_color" );
2773   addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
2774                  LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
2775
2776   addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
2777                  LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
2778   addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
2779                  LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
2780   addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
2781                  LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
2782
2783
2784
2785
2786 }
2787
2788 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2789 {
2790   if (section == "Geometry") {
2791     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2792     if (param == QString("SettingsGeomStep")) {
2793       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2794       EmitSignalDefaultStepValueChanged(spin_step);
2795     }
2796     else if (param == QString("toplevel_color")) {
2797       QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2798       GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2799     }
2800     else if (param == QString("toplevel_dm")) {
2801       GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2802     }
2803     else if (param == QString("scalar_bar_x_position") ||
2804              param == QString("scalar_bar_y_position") ||
2805              param == QString("scalar_bar_width") ||
2806              param == QString("scalar_bar_height") ||
2807              param == QString("scalar_bar_text_height") ||
2808              param == QString("scalar_bar_nb_intervals")) {
2809       GEOM_Displayer aDisplayer;
2810       bool anIsRedisplayFieldSteps = param == QString("scalar_bar_nb_intervals");
2811       aDisplayer.UpdateColorScale( anIsRedisplayFieldSteps, true );
2812     }
2813     else if ( param == QString("dimensions_color")            ||
2814               param == QString("dimensions_line_width")       ||
2815               param == QString("dimensions_font")             ||
2816               param == QString("dimensions_arrow_length")     ||
2817               param == QString("dimensions_show_units")       ||
2818               param == QString("dimensions_length_units")     ||
2819               param == QString("dimensions_angle_units")      ||
2820               param == QString("dimensions_use_text3d")       ||
2821               param == QString("shape_annotation_font_color") ||
2822               param == QString("shape_annotation_line_color") ||
2823               param == QString("shape_annotation_font")       ||
2824               param == QString("shape_annotation_line_width") ||
2825               param == QString("shape_annotation_autohide")   ||
2826               param == QString("shape_annotation_line_style") ||
2827               param == QString("shape_annotation_line_style") ||
2828               param == QString("label_color") )
2829     {
2830       SalomeApp_Application* anApp = getApp();
2831       if ( !anApp )
2832       {
2833         return;
2834       }
2835
2836       GEOM_Displayer aDisplayer;
2837
2838       ViewManagerList aVMs;
2839       anApp->viewManagers( OCCViewer_Viewer::Type(), aVMs );
2840       ViewManagerList::Iterator anIt = aVMs.begin();
2841       for ( ; anIt != aVMs.end(); ++anIt )
2842       {
2843         SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>( (*anIt)->getViewModel() );
2844         if ( !aViewer )
2845         {
2846           continue;
2847         }
2848
2849         SALOME_ListIO aVisible;
2850         aViewer->GetVisible( aVisible );
2851
2852         GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
2853         if ( anAnnotationMgr ) {
2854           SALOME_ListIteratorOfListIO anIter( aVisible );
2855           while ( anIter.More() ) {
2856             if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
2857               aVisible.Remove( anIter );
2858             }
2859             else {
2860               anIter.Next();
2861             }
2862           }
2863         }
2864
2865         aDisplayer.Redisplay( aVisible, false, aViewer );
2866       }
2867       if ( param == QString( "label_color" ) ) {
2868         ViewManagerList aVMsVTK;
2869         anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
2870         ViewManagerList::Iterator anIt = aVMsVTK.begin();
2871         for ( ; anIt != aVMsVTK.end(); ++anIt )
2872         {
2873             SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
2874             if ( !aViewer )
2875             {
2876               continue;
2877             }
2878             SALOME_ListIO aVisible;
2879             aViewer->GetVisible( aVisible );
2880             aDisplayer.Redisplay( aVisible, false, aViewer );
2881           }
2882       }
2883       aDisplayer.UpdateViewer();
2884     }
2885     else if ( param.startsWith( "dependency_tree") )
2886       emit SignalDependencyTreeParamChanged( section, param );
2887   }
2888 }
2889
2890 LightApp_Displayer* GeometryGUI::displayer()
2891 {
2892   if ( !myDisplayer )
2893     myDisplayer = new GEOM_Displayer();
2894   return myDisplayer;
2895 }
2896
2897 void GeometryGUI::setLocalSelectionMode(const int mode)
2898 {
2899   myLocalSelectionMode = mode;
2900 }
2901
2902 int GeometryGUI::getLocalSelectionMode() const
2903 {
2904   return myLocalSelectionMode;
2905 }
2906
2907 const char gSeparator = '_'; // character used to separate parameter names
2908 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2909
2910 /*!
2911  * \brief Store visual parameters
2912  *
2913  * This method is called just before the study document is saved.
2914  * Store visual parameters in AttributeParameter attribute(s)
2915  */
2916 void GeometryGUI::storeVisualParameters (int savePoint)
2917 {
2918   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2919   if ( !appStudy || !appStudy->studyDS() )
2920     return;
2921
2922   _PTR(Study) studyDS = appStudy->studyDS();
2923
2924   // componentName is used for encoding of entries when storing them in IParameters
2925   std::string componentName = myComponentGeom->ComponentDataType();
2926   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2927   //if (!aSComponent) return;
2928
2929   // IParameters
2930   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2931                                                              componentName.c_str(),
2932                                                              savePoint);
2933   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2934
2935   QSet<QString> anEntriesToStoreShared;
2936   QList<SUIT_ViewManager*> lst;
2937   QList<SUIT_ViewManager*>::Iterator it;
2938
2939   GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
2940
2941   // main cycle to store parameters of displayed objects
2942   lst.clear();
2943   getApp()->viewManagers(lst);
2944   for (it = lst.begin(); it != lst.end(); it++) {
2945     SUIT_ViewManager* vman = *it;
2946     QString vType = vman->getType();
2947     SUIT_ViewModel* vmodel = vman->getViewModel();
2948     SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
2949
2950     int aMgrId = vman->getGlobalId();
2951     // saving VTK actors properties
2952     QVector<SUIT_ViewWindow*> views = vman->getViews();
2953     for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2954       const ObjMap& anObjects = appStudy->getObjectProperties(aMgrId);
2955       ObjMap::ConstIterator o_it = anObjects.begin();
2956       for (; o_it != anObjects.end(); o_it++) {
2957         const PropMap& aProps = o_it.value();
2958
2959         //Check that object exists in the study
2960         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2961         if ( !obj || !(aProps.count() > 0))
2962           continue;
2963         // entry is "encoded" = it does NOT contain component adress, since it is a
2964         // subject to change on next component loading
2965
2966         std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2967
2968         _PTR(GenericAttribute) anAttr;
2969         if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2970           continue;
2971
2972         // remember entry of object to store shared GEOM properties
2973         // (e.g. dimension properties).
2974         if ( vType == OCCViewer_Viewer::Type() )
2975         {
2976           anEntriesToStoreShared.insert( o_it.key() );
2977         }
2978
2979         QString param, occParam = vType;
2980         occParam += GEOM::sectionSeparator();
2981         occParam += QString::number(aMgrId);
2982         occParam += GEOM::sectionSeparator();
2983
2984         if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2985           param = occParam + GEOM::propertyName( GEOM::Visibility );
2986           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2987         }
2988
2989         if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2990           param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2991           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2992         }
2993
2994         if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2995           QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2996           QStringList val;
2997           val << QString::number(c.redF());
2998           val << QString::number(c.greenF());
2999           val << QString::number(c.blueF());
3000           param = occParam + GEOM::propertyName( GEOM::Color );
3001           ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
3002         }
3003         
3004         if (aProps.contains(GEOM::propertyName( GEOM::Texture ))) {
3005           param = occParam + GEOM::propertyName( GEOM::Texture );
3006           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Texture )).toString().toStdString());
3007         }
3008
3009         if (vType == SVTK_Viewer::Type()) {
3010           if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
3011             param = occParam + GEOM::propertyName( GEOM::Opacity );
3012             ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
3013           }
3014         } else if (vType == SOCC_Viewer::Type()) {
3015           if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
3016             param = occParam + GEOM::propertyName( GEOM::Transparency );
3017             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
3018           }
3019
3020           if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
3021             param = occParam + GEOM::propertyName( GEOM::TopLevel );
3022             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
3023           }
3024         }
3025
3026         if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
3027           param = occParam + GEOM::propertyName( GEOM::NbIsos );
3028           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
3029         }
3030
3031         if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
3032           param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
3033           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
3034         }
3035
3036         if (aProps.contains(GEOM::propertyName( GEOM::Vertices ))) {
3037           param = occParam + GEOM::propertyName( GEOM::Vertices );
3038           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Vertices )).toString().toStdString());
3039         }
3040
3041         if (aProps.contains(GEOM::propertyName( GEOM::ShowName ))) {
3042           param = occParam + GEOM::propertyName( GEOM::ShowName );
3043           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::ShowName )).toString().toStdString());
3044         }
3045
3046         if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
3047           param = occParam + GEOM::propertyName( GEOM::Deflection );
3048           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
3049         }
3050
3051         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
3052         if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
3053           param = occParam + GEOM::propertyName( GEOM::PointMarker );
3054           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
3055         }
3056
3057         if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
3058           param = occParam + GEOM::propertyName( GEOM::Material );
3059           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
3060         }
3061
3062         if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
3063              param = occParam + GEOM::propertyName( GEOM::LineWidth );
3064            ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
3065         }
3066
3067         if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
3068           param = occParam + GEOM::propertyName( GEOM::IsosWidth );
3069           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
3070         }
3071
3072         if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
3073           std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
3074                                             o_it.key().toLatin1().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
3075           if (!anAnnotationInfo.empty()) {
3076             param = occParam + "ShapeAnnotationVisibleItems";
3077             ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
3078           }
3079         }
3080       } // object iterator
3081     } // for (views)
3082   } // for (viewManagers)
3083
3084   // store shape annotation and dimension attributes of objects:
3085   // since the displayed object always persists in property map, we remember the object entries
3086   // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
3087   const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
3088   const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
3089   QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
3090   for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
3091   {
3092     std::string aStudyEntry = (*aEntryIt).toLatin1().data();
3093     std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
3094
3095     // store dimension parameters
3096     GEOMGUI_DimensionProperty aDimensions( aStudyEntry );
3097     if ( aDimensions.GetNumber() != 0 ) {
3098       ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
3099     }
3100
3101     _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
3102     const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
3103     if ( !aShapeAnnAttr.IsNull() ) {
3104       ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toLatin1().data() );
3105     }
3106   }
3107 }
3108
3109 /*!
3110  * \brief Restore visual parameters
3111  *
3112  * This method is called after the study document is opened.
3113  * Restore visual parameters from AttributeParameter attribute(s)
3114  */
3115 void GeometryGUI::restoreVisualParameters (int savePoint)
3116 {
3117   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
3118   if (!appStudy || !appStudy->studyDS())
3119     return;
3120   _PTR(Study) studyDS = appStudy->studyDS();
3121
3122   // componentName is used for encoding of entries when storing them in IParameters
3123   std::string componentName = myComponentGeom->ComponentDataType();
3124   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
3125   //if (!aSComponent) return;
3126
3127   // IParameters
3128   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
3129                                                              componentName.c_str(),
3130                                                              savePoint);
3131   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
3132
3133   std::vector<std::string> entries = ip->getEntries();
3134
3135   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
3136   {
3137     // entry is a normal entry - it should be "decoded" (setting base adress of component)
3138     QString entry (ip->decodeEntry(*entIt).c_str());
3139
3140     // Check that the entry corresponds to a real object in the Study
3141     // as the object may be deleted or modified after the visual state is saved.
3142     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
3143     if (!so) continue; //Skip the not existent entry
3144
3145     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
3146     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
3147
3148     std::vector<std::string>::iterator namesIt = paramNames.begin();
3149     std::vector<std::string>::iterator valuesIt = paramValues.begin();
3150
3151     // actors are stored in a map after displaying of them for
3152     // quicker access in the future: map < viewID to actor >
3153     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
3154     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
3155
3156     QString viewerTypStr;
3157     QString viewIndexStr;
3158     int viewIndex;
3159     QVector<PropMap> aListOfMap;
3160
3161     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
3162     {
3163       // visual parameters are stored in strings as follows: 
3164       //   1) ViewerType_ViewIndex_ParamName
3165       //   2) ViewerType_ParamName (shared for GEOM module)
3166       // '_' is used as separator and should not be used in viewer type or parameter names.
3167       QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
3168
3169       bool isShared = lst.size() == 2;
3170       bool isViewer = lst.size() == 3;
3171       if ( !isShared && !isViewer )
3172       {
3173         continue;
3174       }
3175
3176       // shared visual parameters
3177       if ( isShared )
3178       {
3179         QString aParamNameStr( lst[1] );
3180         QString aValuesStr( (*valuesIt).c_str() );
3181
3182         // shared dimension properties are stored as attribute
3183         if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
3184         {
3185           GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
3186           aDimensionProp.SaveToAttribute( entry.toLatin1().data() );
3187         }
3188         else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
3189         {
3190           Handle(GEOMGUI_AnnotationAttrs) anAttr =
3191             GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
3192
3193           anAttr->ImportFromPropertyString( aValuesStr );
3194         }
3195
3196         continue;
3197       }
3198
3199       // per view visual parameters
3200       viewerTypStr = lst[0];
3201       viewIndexStr = lst[1];
3202       QString paramNameStr = lst[2];
3203
3204       bool ok;
3205       viewIndex = viewIndexStr.toUInt(&ok);
3206       if (!ok) // bad conversion of view index to integer
3207         continue;
3208
3209       if ((viewIndex + 1) > aListOfMap.count()) {
3210         aListOfMap.resize(viewIndex + 1);
3211       }
3212
3213       QString val((*valuesIt).c_str());
3214       if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
3215         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
3216       } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
3217         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
3218       } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
3219         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
3220       } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
3221         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
3222       } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
3223         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
3224       } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
3225         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
3226       } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
3227         QStringList rgb = val.split(GEOM::subSectionSeparator());
3228         if (rgb.count() == 3) {
3229           QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
3230           aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
3231         }
3232       } else if (paramNameStr == GEOM::propertyName( GEOM::Texture )) {
3233         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Texture ), val );
3234       } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
3235         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
3236       } else if (paramNameStr == GEOM::propertyName( GEOM::Vertices )) {
3237         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Vertices ), val == "true" || val == "1");
3238       } else if (paramNameStr == GEOM::propertyName( GEOM::ShowName )) {
3239         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::ShowName ), val == "true" || val == "1");
3240       } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
3241         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
3242       } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
3243         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
3244       } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
3245         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
3246       } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
3247         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
3248       } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
3249         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
3250       } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
3251         aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
3252       }
3253
3254     } // for names/parameters iterator
3255
3256     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
3257
3258     for (int index = 0; index < aListOfMap.count(); index++) {
3259       appStudy->setObjectProperties(index, entry, aListOfMap[index]);
3260
3261       //Get Visibility property of the current PropMap
3262       if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
3263         SUIT_ViewManager* vman = lst.at(index);
3264         SUIT_ViewModel* vmodel = vman->getViewModel();
3265         SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
3266         displayer()->Display(entry, true, aView);
3267
3268         if ( vmodel->getType() == SOCC_Viewer::Type() ) {
3269           PropMap& aProps = aListOfMap[index];
3270           if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
3271             SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
3272             GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
3273           }
3274         }
3275       }
3276     }
3277   } // for entries iterator
3278
3279   // update all VTK and OCC views
3280   QList<SUIT_ViewManager*> lst;
3281   getApp()->viewManagers(lst);
3282   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
3283     SUIT_ViewModel* vmodel = (*it)->getViewModel();
3284     if (!vmodel)
3285       continue;
3286     if (vmodel->getType() == SVTK_Viewer::Type()) {
3287       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
3288       vtkView->getRenderer()->ResetCameraClippingRange();
3289       vtkView->Repaint();
3290     }
3291     else if (vmodel->getType() == SOCC_Viewer::Type()) {
3292       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
3293       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
3294       if (occVMod)
3295         occVMod->Repaint();
3296     }
3297   }
3298
3299   if ( myTextTreeWdg ) {
3300     myTextTreeWdg->updateTree();
3301   }
3302 }
3303
3304 // Compute current name mode of the viewer
3305 void UpdateNameMode( SalomeApp_Application* app )
3306 {
3307   bool isMode = false;
3308   SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
3309   SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
3310   GEOM_Displayer displayer;
3311   int aMgrId = viewWindow->getViewManager()->getGlobalId();
3312
3313   SALOME_View* window = displayer.GetActiveView();
3314   if ( !window ) return;
3315
3316   SALOME_ListIO anIOlst;
3317   window->GetVisible( anIOlst );
3318
3319   for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) {
3320     Handle( SALOME_InteractiveObject ) io = It.Value();
3321     QVariant v = aStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() );
3322     bool isIONameMode =  v.isValid() ? v.toBool() : false;
3323     if( isIONameMode )
3324       isMode = true;
3325   }
3326   viewWindow->setProperty( "NameMode", isMode );
3327 }
3328
3329 void GeometryGUI::onViewAboutToShow()
3330 {
3331   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
3332   QAction* a = action( GEOMOp::OpSwitchVectors );
3333   QAction* aVerticesAction = action( GEOMOp::OpSwitchVertices );
3334   QAction* aNameAction = action( GEOMOp::OpSwitchName );
3335   if ( window ) {
3336     a->setEnabled(true);
3337     bool vmode = window->property("VectorsMode").toBool();
3338     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
3339     aVerticesAction->setEnabled(true);
3340     vmode = window->property("VerticesMode").toBool();
3341     aVerticesAction->setText ( vmode == 1 ? tr( "MEN_VERTICES_MODE_OFF" ) : tr("MEN_VERTICES_MODE_ON") );
3342     UpdateNameMode( getApp() );
3343     aNameAction->setEnabled(true);
3344     vmode = window->property("NameMode").toBool();
3345     aNameAction->setText ( vmode == 1 ? tr( "MEN_NAME_MODE_OFF" ) : tr("MEN_NAME_MODE_ON") );
3346   } else {
3347     a->setText ( tr("MEN_VECTOR_MODE_ON") );
3348     a->setEnabled(false);
3349     aVerticesAction->setText ( tr("MEN_VERTICES_MODE_ON") );
3350     aVerticesAction->setEnabled(false);
3351     aNameAction->setText ( tr("MEN_NAME_MODE_ON") );
3352     aNameAction->setEnabled(false);
3353   }
3354 }
3355
3356 /*!
3357   \brief Return action by id
3358   \param id identifier of the action
3359   \return action
3360 */
3361 QAction* GeometryGUI::getAction(const int id) {
3362   return action(id);
3363 }
3364
3365 /*!
3366   \brief GEOM module message handler
3367
3368   This method can be re-implemented in the subclasses.
3369   This is a GEOM module message handler.
3370
3371   \param msg the message received.
3372 */
3373 void GeometryGUI::message(const QString& msg)
3374 {
3375   // dispatch message
3376   QStringList data = msg.split("/");
3377   const int nbStrings = data.count();
3378
3379   if (nbStrings > 0) {
3380     if (data[0] == "modified") {
3381       // get mesh entry
3382       QString anIOR = nbStrings > 1 ? data[1] : QString();
3383
3384       if ( anIOR.isEmpty() ) {
3385         return;
3386       }
3387
3388       // Get the geom object.
3389       GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
3390
3391       // Clear the shape buffer
3392       GeometryGUI::ClearShapeBuffer (anObj);
3393     }
3394   }
3395 }
3396
3397 /*!
3398   \brief Clears the shape buffer.
3399
3400   This is a static method. It clears the shape buffer.
3401
3402   \param theObj the object
3403 */
3404 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
3405 {
3406   if ( CORBA::is_nil( theObj ) )
3407     return;
3408
3409   CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
3410   TCollection_AsciiString asciiIOR( (char *)IOR.in() );
3411   GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3412
3413   SalomeApp_Application* app =
3414     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3415   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3416
3417   if (!appStudy)
3418     return;
3419
3420   _PTR(Study) aStudy = appStudy->studyDS();
3421
3422   if ( !aStudy )
3423     return;
3424
3425   _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
3426   if ( !aSObj )
3427     return;
3428
3429   _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
3430   for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
3431     _PTR(GenericAttribute) anAttr;
3432     if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
3433       _PTR(AttributeIOR) anIOR ( anAttr );
3434       TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
3435       GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
3436     }
3437   }
3438 }
3439
3440 /*!
3441   \brief Returns the object from IOR.
3442
3443   This is a static method. It returns the object from its IOR.
3444
3445   \param IOR object IOR
3446   \return GEOM object.
3447 */
3448 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
3449 {
3450   GEOM::GEOM_Object_var geomObj;
3451   if ( !IOR.isEmpty() ) {
3452     CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
3453       ( IOR.toLatin1().constData() );
3454     if ( !CORBA::is_nil( corbaObj ) )
3455       geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
3456   }
3457   return geomObj._retn();
3458 }
3459
3460 /*!
3461   \brief Returns IOR of the object.
3462
3463   This is a static method. It returns the object's IOR.
3464
3465   \param object the GEOM object.
3466   \return object's IOR.
3467 */
3468 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
3469 {
3470   QString IOR;
3471   if ( !CORBA::is_nil( object ) ) {
3472     CORBA::String_var anIOR =
3473       SalomeApp_Application::orb()->object_to_string( object );
3474     IOR = anIOR.in();
3475   }
3476   return IOR;
3477 }
3478
3479 /*!
3480   \brief Check if this object is can't be renamed in place
3481
3482   This method can be re-implemented in the subclasses.
3483   Return true in case if object isn't reference or component (module root).
3484
3485   \param entry column id
3486   \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
3487 */
3488 bool GeometryGUI::renameAllowed( const QString& entry) const {
3489
3490   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
3491   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3492   SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
3493
3494   return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
3495 }
3496
3497 /*!
3498   Rename object by entry.
3499   \param entry entry of the object
3500   \param name new name of the object
3501   \brief Return \c true if rename operation finished successfully, \c false otherwise.
3502 */
3503 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
3504 {
3505   bool result = false;
3506
3507   SalomeApp_Application* app =
3508     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
3509   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
3510
3511   if (!appStudy)
3512     return result;
3513
3514   _PTR(Study) aStudy = appStudy->studyDS();
3515
3516   if (!aStudy)
3517     return result;
3518
3519   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
3520   if ( aLocked ) {
3521     SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
3522     return result;
3523   }
3524
3525   _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
3526   _PTR(GenericAttribute) anAttr;
3527   if ( obj ) {
3528     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
3529       _PTR(AttributeName) aName (anAttr);
3530
3531       aName->SetValue( name.toLatin1().data() ); // rename the SObject
3532       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
3533       if (!CORBA::is_nil(anObj)) {
3534         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
3535         emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
3536         emit SignalTextTreeRenameObject( entry );
3537       }
3538       result = true;
3539     }
3540   }
3541   return result;
3542 }
3543
3544 void GeometryGUI::updateMaterials()
3545 {
3546   LightApp_Preferences* pref = preferences();
3547   if ( pref ) {
3548     QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
3549     QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
3550     if ( !materials.contains( currentMaterial ) )
3551       // user material set as default in the preferences, might be removed
3552       SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
3553
3554     QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
3555     if ( prefItem ) {
3556       setPreferenceProperty( prefItem->id(),
3557                              "strings", materials );
3558       prefItem->retrieve();
3559     }
3560   }
3561 }
3562
3563 /*!
3564   \brief Check if the module allows "drag" operation of its objects.
3565
3566   Overloaded from LightApp_Module class.
3567   
3568   This function is a part of the general drag-n-drop mechanism.
3569   The goal of this function is to check data object passed as a parameter
3570   and decide if it can be dragged or no.
3571
3572   \param what data object being tested for drag operation
3573   \return \c true if module allows dragging of the specified object
3574   \sa isDropAccepted(), dropObjects()
3575 */
3576 bool GeometryGUI::isDraggable( const SUIT_DataObject* what ) const
3577 {
3578   // we allow dragging object under root and object from folder
3579   int aLevel = what->level();
3580   bool anObjectInFolder = false;
3581   if ( aLevel > 2 ) {
3582     const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( what );
3583     if ( dataObj ) {
3584       _PTR(SObject) aSO = dataObj->object();
3585       if ( aSO ) {
3586         _PTR(GenericAttribute) anAttr;
3587         _PTR(SObject) aFatherSO = SalomeApp_Application::getStudy()->GetUseCaseBuilder()->GetFather( aSO );
3588         if ( aFatherSO && aFatherSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3589           _PTR(AttributeLocalID) aLocalID( anAttr );
3590           anObjectInFolder = aLocalID->Value() == 999;
3591         }
3592       }
3593     }
3594   }
3595   return aLevel == 2 || anObjectInFolder;
3596 }
3597
3598 /*!
3599   \brief Check if the module allows "drop" operation on the given object.
3600
3601   Overloaded from LightApp_Module class.
3602
3603   This function is a part of the general drag-n-drop mechanism.
3604   The goal of this function is to check data object passed as a parameter
3605   and decide if it can be used as a target for the "drop" operation.
3606   The processing of the drop operation itself is done in the dropObjects() function.
3607
3608   \param where target data object
3609   \return \c true if module supports dropping on the \a where data object
3610   \sa isDraggable(), dropObjects()
3611 */
3612 bool GeometryGUI::isDropAccepted( const SUIT_DataObject* where ) const
3613 {
3614   // we allow dropping into folder and top-level GEOM object
3615   int aLevel = where->level();
3616   bool isFolder = false;
3617   if ( aLevel > 1 ) {
3618     const SalomeApp_DataObject* dataObj = dynamic_cast<const SalomeApp_DataObject*>( where );
3619     if ( dataObj ) {
3620       _PTR(SObject) aSO = dataObj->object();
3621       if ( aSO ) {
3622         _PTR(GenericAttribute) anAttr;
3623         if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
3624           _PTR(AttributeLocalID) aLocalID( anAttr );
3625           isFolder = aLocalID->Value() == 999;
3626         }
3627       }
3628     }
3629   }
3630   return aLevel == 1 || isFolder;
3631 }
3632
3633 /*!
3634   \brief Complete drag-n-drop operation.
3635   
3636   Overloaded from LightApp_Module class.
3637
3638   This function is a part of the general drag-n-drop mechanism.
3639   Its goal is to handle dropping of the objects being dragged according
3640   to the chosen operation (move). The dropping is performed in the
3641   context of the parent data object \a where and the \a row (position in the 
3642   children index) at which the data should be dropped. If \a row is equal to -1,
3643   this means that objects are added to the end of the children list.
3644
3645   \param what objects being dropped
3646   \param where target data object
3647   \param row child index at which the drop operation is performed
3648   \param action drag-n-drop operation (Qt::DropAction) - move
3649
3650   \sa isDraggable(), isDropAccepted()
3651 */
3652 void GeometryGUI::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
3653                                const int row, Qt::DropAction action )
3654 {
3655   if (action != Qt::CopyAction && action != Qt::MoveAction)
3656     return; // unsupported action
3657
3658   // get parent object
3659   SalomeApp_DataObject* dataObj = dynamic_cast<SalomeApp_DataObject*>( where );
3660   if ( !dataObj ) return; // wrong parent
3661   _PTR(SObject) parentObj = dataObj->object();
3662
3663   // Find the current Study and StudyBuilder
3664   _PTR(Study) aStudy = SalomeApp_Application::getStudy();
3665   _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
3666   // collect all parents of the target node
3667   QStringList parentIDs;
3668   _PTR(SObject) parent = parentObj;
3669   while( !parent->IsNull() ) {
3670     parentIDs << parent->GetID().c_str();
3671     parent = aUseCaseBuilder->GetFather(parent);
3672   }
3673
3674   // collect objects being dropped
3675   GEOM::object_list_var objects = new GEOM::object_list();
3676   objects->length( what.count() );
3677   int count = 0;
3678   for ( int i = 0; i < what.count(); i++ ) {
3679     dataObj = dynamic_cast<SalomeApp_DataObject*>( what[i] );
3680     if ( !dataObj ) continue;  // skip wrong objects
3681     _PTR(SObject) sobj = dataObj->object();
3682     // check that dropped object is not a parent of target object
3683     if ( parentIDs.contains( sobj->GetID().c_str() ) ) {
3684       return; // it's not allowed to move node into it's child 
3685     }
3686     objects[i] = _CAST(SObject, sobj)->GetSObject();
3687     count++;
3688   }
3689   objects->length( count );
3690
3691   // call engine function
3692   GetGeomGen()->Move( objects.in(),                              // what
3693                       _CAST(SObject, parentObj)->GetSObject(),   // where
3694                       row );                                     // row
3695
3696   // update Object browser
3697   getApp()->updateObjectBrowser( false );
3698 }
3699
3700 void GeometryGUI::emitDimensionsUpdated( QString entry )
3701 {
3702   emit DimensionsUpdated( entry );
3703 }
3704
3705 void GeometryGUI::emitAnnotationsUpdated( QString entry )
3706 {
3707   emit SignalAnnotationsUpdated( entry );
3708 }