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