]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI.cxx
Salome HOME
3a786e03a0dcc00bb19bfcdce72b1e2bccaead11
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
1 // Copyright (C) 2007-2013  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.
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 "GEOMGUI_OCCSelector.h"
33 #include "GEOMGUI_Selection.h"
34 #include "GEOMGUI_CreationInfoWdg.h"
35 #include "GEOM_Constants.h"
36 #include "GEOM_Displayer.h"
37 #include "GEOM_AISShape.hxx"
38
39 #include "GEOM_Actor.h"
40
41 #include <Material_ResourceMgr.h>
42 #include <Material_Model.h>
43
44 #include <SUIT_Desktop.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SUIT_Session.h>
48 #include <SUIT_ViewManager.h>
49
50 #include <OCCViewer_ViewWindow.h>
51 #include <OCCViewer_ViewPort3d.h>
52 #include <OCCViewer_ViewModel.h>
53 #include <OCCViewer_ViewManager.h>
54
55 #include <SOCC_ViewModel.h>
56 #include <SOCC_ViewWindow.h>
57
58 #include <SVTK_ViewWindow.h>
59 #include <SVTK_RenderWindowInteractor.h>
60 #include <SVTK_InteractorStyle.h>
61 #include <SVTK_ViewModel.h>
62
63 #include <SalomeApp_Application.h>
64 #include <SalomeApp_DataObject.h>
65 #include <SalomeApp_Study.h>
66 #include <SalomeApp_Tools.h>
67
68 #include <LightApp_SelectionMgr.h>
69 #include <LightApp_VTKSelector.h>
70 #include <LightApp_DataObject.h>
71 #include <LightApp_Preferences.h>
72
73 #include <SALOME_LifeCycleCORBA.hxx>
74 #include <SALOME_ListIO.hxx>
75 #include <SALOME_ListIteratorOfListIO.hxx>
76
77 #include <SALOMEDSClient_ClientFactory.hxx>
78 #include <SALOMEDSClient_IParameters.hxx>
79
80 #include <Basics_OCCTVersion.hxx>
81
82 // External includes
83 #include <QMenu>
84 #include <QTime>
85 #include <QAction>
86 #include <QFileInfo>
87 #include <QString>
88 #include <QPainter>
89 #include <QSignalMapper>
90
91 #include <AIS_Drawer.hxx>
92 #include <AIS_ListOfInteractive.hxx>
93 #include <AIS_ListIteratorOfListOfInteractive.hxx>
94 #include <Prs3d_Drawer.hxx>
95 #include <Prs3d_IsoAspect.hxx>
96 #include <Aspect_TypeOfMarker.hxx>
97 #include <OSD_SharedLibrary.hxx>
98 #include <NCollection_DataMap.hxx>
99
100 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
101 #include <TColStd_HArray1OfByte.hxx>
102 #else
103 #include <Graphic3d_HArray1OfBytes.hxx>
104 #endif
105
106 #include <utilities.h>
107
108 #include <vtkCamera.h>
109 #include <vtkRenderer.h>
110
111 #include <Standard_Failure.hxx>
112 #include <Standard_ErrorHandler.hxx>
113
114 #include "GEOM_version.h"
115 #include "GEOMImpl_Types.hxx" // dangerous hxx (defines short-name macros) - include after all
116
117 extern "C" {
118   Standard_EXPORT CAM_Module* createModule() {
119     return new GeometryGUI();
120   }
121
122   Standard_EXPORT char* getModuleVersion() {
123     return (char*)GEOM_VERSION_STR;
124   }
125 }
126
127 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
128
129 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
130
131 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
132 {
133   // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
134   if (CORBA::is_nil(myComponentGeom))
135     InitGeomGen();
136   return GeometryGUI::myComponentGeom;
137 }
138
139 bool GeometryGUI::InitGeomGen()
140 {
141   GeometryGUI aGG;
142   if ( CORBA::is_nil( myComponentGeom ) ) return false;
143   return true;
144 }
145
146 //=======================================================================
147 // function : ClientSObjectToObject
148 // purpose  :
149 //=======================================================================
150 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
151 {
152   _PTR(GenericAttribute) anAttr;
153   CORBA::Object_var anObj;
154   try {
155     std::string aValue = theSObject->GetIOR();
156     if (strcmp(aValue.c_str(), "") != 0) {
157       CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
158       anObj = anORB->string_to_object(aValue.c_str());
159     }
160   } catch(...) {
161     INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
162   }
163   return anObj._retn();
164 }
165
166 //=======================================================================
167 // function : ClientStudyToStudy
168 // purpose  :
169 //=======================================================================
170 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
171 {
172   SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
173   CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
174   SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
175   int aStudyID = theStudy->StudyId();
176   SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
177   return aDSStudy._retn();
178 }
179
180 void GeometryGUI::Modified (bool theIsUpdateActions)
181 {
182   if ( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
183     if ( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
184       appStudy->Modified();
185       if ( theIsUpdateActions )
186         app->updateActions();
187     }
188   }
189 }
190
191 //=======================================================================
192 // function : GeometryGUI::GeometryGUI()
193 // purpose  : Constructor
194 //=======================================================================
195 GeometryGUI::GeometryGUI() :
196   SalomeApp_Module( "GEOM" )
197 {
198   if ( CORBA::is_nil( myComponentGeom ) )
199   {
200     Engines::EngineComponent_var comp =
201       SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
202     myComponentGeom = GEOM::GEOM_Gen::_narrow( comp );
203   }
204
205   myActiveDialogBox = 0;
206
207   gp_Pnt origin = gp_Pnt(0., 0., 0.);
208   gp_Dir direction = gp_Dir(0., 0., 1.);
209   myWorkingPlane = gp_Ax3(origin, direction);
210
211   myDisplayer = 0;
212   myLocalSelectionMode = GEOM_ALLOBJECTS;
213
214   myCreationInfoWdg = 0;
215
216   connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
217 }
218
219 //=======================================================================
220 // function : GeometryGUI::~GeometryGUI()
221 // purpose  : Destructor
222 //=======================================================================
223 GeometryGUI::~GeometryGUI()
224 {
225   while (!myOCCSelectors.isEmpty())
226     delete myOCCSelectors.takeFirst();
227
228   while (!myVTKSelectors.isEmpty())
229     delete myVTKSelectors.takeFirst();
230
231   qDeleteAll(myGUIMap);
232 }
233
234 //=======================================================================
235 // function : GeometryGUI::getLibrary()
236 // purpose  : get or load GUI library by name [ internal ]
237 //=======================================================================
238 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
239 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
240 {
241   if ( !myGUIMap.contains( libraryName ) ) {
242     // try to load library if it is not loaded yet
243 #ifndef WNT
244     QString dirs = getenv( "LD_LIBRARY_PATH" );
245     QString sep  = ":";
246 #else
247     QString dirs = getenv( "PATH" );
248     QString sep  = ";";
249 #endif
250     if ( !dirs.isEmpty() ) {
251       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
252       QListIterator<QString> it( dirList ); it.toBack();
253       while ( it.hasPrevious() ) {
254         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
255         if ( fi.exists() ) {
256           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
257           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
258           if ( !res ) {
259             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
260             continue; // continue search further
261           }
262           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
263           if ( osdF != NULL ) {
264             LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
265             GEOMGUI* libGUI = (*func)( this );
266             if ( libGUI ) {
267               myGUIMap[ libraryName ] = libGUI;
268               break; // found and loaded!
269             }
270           }
271         }
272       }
273     }
274   }
275   return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
276 }
277
278 //=======================================================================
279 // function : GeometryGUI::ActiveWorkingPlane()
280 // purpose  : Activate Working Plane View
281 //=======================================================================
282 void GeometryGUI::ActiveWorkingPlane()
283 {
284   gp_Dir DZ = myWorkingPlane.Direction();
285   gp_Dir DY = myWorkingPlane.YDirection();
286
287   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
288   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
289   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
290
291   if ( ViewOCC ) {
292     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
293     if ( vw ) {
294       Handle(V3d_View) view3d =  vw->getViewPort()->getView();
295
296       view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
297       view3d->SetUp(DY.X(), DY.Y(), DY.Z());
298       vw->onViewFitAll();
299     }
300   }
301   else if ( ViewVTK ) {
302     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
303     if ( vw ) {
304       vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
305
306       camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
307       camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
308       camera->SetFocalPoint(0,0,0);
309
310       vw->onFitAll();
311     }
312   }
313 }
314
315 //=======================================================================
316 // function : GeometryGUI::SetActiveDialogBox()
317 // purpose  : Set active dialog box
318 //=======================================================================
319 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
320 {
321   myActiveDialogBox = (QDialog*)aDlg;
322 }
323
324 //=======================================================================
325 // function : GeometryGUI::EmitSignalDeactivateDialog()
326 // purpose  : Emit a signal to deactivate the active dialog Box
327 //=======================================================================
328 void GeometryGUI::EmitSignalDeactivateDialog()
329 {
330   emit SignalDeactivateActiveDialog();
331 }
332
333 //=======================================================================
334 // function : GeometryGUI::EmitSignalCloseAllDialogs()
335 // purpose  : Emit a signal to close all non modal dialogs box
336 //=======================================================================
337 void GeometryGUI::EmitSignalCloseAllDialogs()
338 {
339   emit SignalCloseAllDialogs();
340 }
341
342 //=======================================================================
343 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
344 // purpose  : Emit a signal to inform that default real spin box step has
345 //            been changed
346 //=======================================================================
347 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
348 {
349   emit SignalDefaultStepValueChanged(newVal);
350 }
351
352 //=======================================================================
353 // function : GeometryGUI::OnGUIEvent()
354 // purpose  : common slot for all menu/toolbar actions
355 //=======================================================================
356 void GeometryGUI::OnGUIEvent()
357 {
358   const QObject* obj = sender();
359   if ( !obj || !obj->inherits( "QAction" ) )
360     return;
361   int id = actionId((QAction*)obj);
362   if ( id != -1 )
363     OnGUIEvent( id );
364 }
365
366 //=======================================================================
367 // function : GeometryGUI::OnGUIEvent()
368 // purpose  : manage all events on GUI [static]
369 //=======================================================================
370 void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
371 {
372   SUIT_Application* anApp = application();
373   if (!anApp) return;
374   SUIT_Desktop* desk = anApp->desktop();
375
376   // check type of the active viewframe
377   SUIT_ViewWindow* window = desk->activeWindow();
378   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
379   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
380   // if current viewframe is not of OCC and not of VTK type - return immediately
381   // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
382   QList<int> NotViewerDependentCommands;
383   NotViewerDependentCommands << GEOMOp::OpDelete
384                              << GEOMOp::OpShow
385                              << GEOMOp::OpShowOnly
386                              << GEOMOp::OpShowOnlyChildren
387                              << GEOMOp::OpDiscloseChildren
388                              << GEOMOp::OpConcealChildren
389                              << GEOMOp::OpUnpublishObject
390                              << GEOMOp::OpPublishObject
391                              << GEOMOp::OpPointMarker;
392   if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
393       return;
394
395   // fix for IPAL9103, point 2
396   if ( CORBA::is_nil( GetGeomGen() ) ) {
397     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
398     return;
399   }
400
401   QString libName;
402   // find corresponding GUI library
403   switch ( id ) {
404   case GEOMOp::OpOriginAndVectors:   // MENU BASIC - ORIGIN AND BASE VECTORS
405     createOriginAndBaseVectors(); // internal operation
406     return;
407   case GEOMOp::OpImport:             // MENU FILE - IMPORT
408   case GEOMOp::OpExport:             // MENU FILE - EXPORT
409   case GEOMOp::OpSelectVertex:       // POPUP MENU - SELECT ONLY - VERTEX
410   case GEOMOp::OpSelectEdge:         // POPUP MENU - SELECT ONLY - EDGE
411   case GEOMOp::OpSelectWire:         // POPUP MENU - SELECT ONLY - WIRE
412   case GEOMOp::OpSelectFace:         // POPUP MENU - SELECT ONLY - FACE
413   case GEOMOp::OpSelectShell:        // POPUP MENU - SELECT ONLY - SHELL
414   case GEOMOp::OpSelectSolid:        // POPUP MENU - SELECT ONLY - SOLID
415   case GEOMOp::OpSelectCompound:     // POPUP MENU - SELECT ONLY - COMPOUND
416   case GEOMOp::OpSelectAll:          // POPUP MENU - SELECT ONLY - SELECT ALL
417   case GEOMOp::OpDelete:             // MENU EDIT - DELETE
418   case GEOMOp::OpCheckGeom:          // MENU TOOLS - CHECK GEOMETRY
419   case GEOMOp::OpMaterialsLibrary:   // MENU TOOLS - MATERIALS LIBRARY
420   case GEOMOp::OpDeflection:         // POPUP MENU - DEFLECTION COEFFICIENT
421   case GEOMOp::OpColor:              // POPUP MENU - COLOR
422   case GEOMOp::OpSetTexture:         // POPUP MENU - SETTEXTURE
423   case GEOMOp::OpTransparency:       // POPUP MENU - TRANSPARENCY
424   case GEOMOp::OpIncrTransparency:   // SHORTCUT   - INCREASE TRANSPARENCY
425   case GEOMOp::OpDecrTransparency:   // SHORTCUT   - DECREASE TRANSPARENCY
426   case GEOMOp::OpIsos:               // POPUP MENU - ISOS
427   case GEOMOp::OpIncrNbIsos:         // SHORTCUT   - INCREASE NB ISOS
428   case GEOMOp::OpDecrNbIsos:         // SHORTCUT   - DECREASE NB ISOS
429   case GEOMOp::OpAutoColor:          // POPUP MENU - AUTO COLOR
430   case GEOMOp::OpNoAutoColor:        // POPUP MENU - DISABLE AUTO COLOR
431   case GEOMOp::OpDiscloseChildren:   // POPUP MENU - DISCLOSE CHILD ITEMS
432   case GEOMOp::OpConcealChildren:    // POPUP MENU - CONCEAL CHILD ITEMS
433   case GEOMOp::OpUnpublishObject:    // POPUP MENU - UNPUBLISH
434   case GEOMOp::OpPublishObject:      // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
435   case GEOMOp::OpPointMarker:        // POPUP MENU - POINT MARKER
436   case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
437   case GEOMOp::OpPredefMaterial:     // POPUP MENU - <SOME MATERIAL>
438   case GEOMOp::OpPredefMaterCustom:  // POPUP MENU - MATERIAL PROPERTIES - CUSTOM...
439   case GEOMOp::OpEdgeWidth:          // POPUP MENU - LINE WIDTH - EDGE WIDTH
440   case GEOMOp::OpIsosWidth:          // POPUP MENU - LINE WIDTH - ISOS WIDTH
441   case GEOMOp::OpBringToFront:       // POPUP MENU - BRING TO FRONT
442   case GEOMOp::OpClsBringToFront:    //
443     libName = "GEOMToolsGUI";
444     break;
445   case GEOMOp::OpDMWireframe:        // MENU VIEW - WIREFRAME
446   case GEOMOp::OpDMShading:          // MENU VIEW - SHADING
447   case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
448   case GEOMOp::OpShowAll:            // MENU VIEW - SHOW ALL
449   case GEOMOp::OpShowOnly:           // MENU VIEW - DISPLAY ONLY
450   case GEOMOp::OpShowOnlyChildren:   // MENU VIEW - SHOW ONLY CHILDREN
451   case GEOMOp::OpHideAll:            // MENU VIEW - ERASE ALL
452   case GEOMOp::OpHide:               // MENU VIEW - ERASE
453   case GEOMOp::OpShow:               // MENU VIEW - DISPLAY
454   case GEOMOp::OpSwitchVectors:      // MENU VIEW - VECTOR MODE
455   case GEOMOp::OpWireframe:          // POPUP MENU - WIREFRAME
456   case GEOMOp::OpShading:            // POPUP MENU - SHADING
457   case GEOMOp::OpShadingWithEdges:   // POPUP MENU - SHADING WITH EDGES
458   case GEOMOp::OpTexture:            // POPUP MENU - TEXTURE
459   case GEOMOp::OpVectors:            // POPUP MENU - VECTORS
460     libName = "DisplayGUI";
461     break;
462   case GEOMOp::OpPoint:              // MENU BASIC - POINT
463   case GEOMOp::OpLine:               // MENU BASIC - LINE
464   case GEOMOp::OpCircle:             // MENU BASIC - CIRCLE
465   case GEOMOp::OpEllipse:            // MENU BASIC - ELLIPSE
466   case GEOMOp::OpArc:                // MENU BASIC - ARC
467   case GEOMOp::OpVector:             // MENU BASIC - VECTOR
468   case GEOMOp::OpPlane:              // MENU BASIC - PLANE
469   case GEOMOp::OpCurve:              // MENU BASIC - CURVE
470   case GEOMOp::OpLCS:                // MENU BASIC - LOCAL COORDINATE SYSTEM
471     libName = "BasicGUI";
472     break;
473   case GEOMOp::OpBox:                // MENU PRIMITIVE - BOX
474   case GEOMOp::OpCylinder:           // MENU PRIMITIVE - CYLINDER
475   case GEOMOp::OpSphere:             // MENU PRIMITIVE - SPHERE
476   case GEOMOp::OpTorus:              // MENU PRIMITIVE - TORUS
477   case GEOMOp::OpCone:               // MENU PRIMITIVE - CONE
478   case GEOMOp::OpRectangle:          // MENU PRIMITIVE - FACE
479   case GEOMOp::OpDisk:               // MENU PRIMITIVE - DISK
480     libName = "PrimitiveGUI";
481     break;
482   case GEOMOp::OpPrism:              // MENU GENERATION - PRISM
483   case GEOMOp::OpRevolution:         // MENU GENERATION - REVOLUTION
484   case GEOMOp::OpFilling:            // MENU GENERATION - FILLING
485   case GEOMOp::OpPipe:               // MENU GENERATION - PIPE
486   case GEOMOp::OpPipePath:           // MENU GENERATION - RESTORE PATH
487     libName = "GenerationGUI";
488     break;
489   case GEOMOp::Op2dSketcher:         // MENU ENTITY - SKETCHER
490   case GEOMOp::Op3dSketcher:         // MENU ENTITY - 3D SKETCHER
491   case GEOMOp::OpExplode:            // MENU ENTITY - EXPLODE
492 #ifdef WITH_OPENCV
493   case GEOMOp::OpFeatureDetect:      // MENU ENTITY - FEATURE DETECTION
494 #endif
495   case GEOMOp::OpPictureImport:      // MENU ENTITY - IMPORT PICTURE IN VIEWER
496     libName = "EntityGUI";
497     break;
498   case GEOMOp::OpEdge:               // MENU BUILD - EDGE
499   case GEOMOp::OpWire:               // MENU BUILD - WIRE
500   case GEOMOp::OpFace:               // MENU BUILD - FACE
501   case GEOMOp::OpShell:              // MENU BUILD - SHELL
502   case GEOMOp::OpSolid:              // MENU BUILD - SOLID
503   case GEOMOp::OpCompound:           // MENU BUILD - COMPUND
504     libName = "BuildGUI";
505     break;
506   case GEOMOp::OpFuse:               // MENU BOOLEAN - FUSE
507   case GEOMOp::OpCommon:             // MENU BOOLEAN - COMMON
508   case GEOMOp::OpCut:                // MENU BOOLEAN - CUT
509   case GEOMOp::OpSection:            // MENU BOOLEAN - SECTION
510     libName = "BooleanGUI";
511     break;
512   case GEOMOp::OpTranslate:          // MENU TRANSFORMATION - TRANSLATION
513   case GEOMOp::OpRotate:             // MENU TRANSFORMATION - ROTATION
514   case GEOMOp::OpChangeLoc:          // MENU TRANSFORMATION - LOCATION
515   case GEOMOp::OpMirror:             // MENU TRANSFORMATION - MIRROR
516   case GEOMOp::OpScale:              // MENU TRANSFORMATION - SCALE
517   case GEOMOp::OpOffset:             // MENU TRANSFORMATION - OFFSET
518   case GEOMOp::OpProjection:         // MENU TRANSFORMATION - PROJECTION
519   case GEOMOp::OpMultiTranslate:     // MENU TRANSFORMATION - MULTI-TRANSLATION
520   case GEOMOp::OpMultiRotate:        // MENU TRANSFORMATION - MULTI-ROTATION
521   case GEOMOp::OpReimport:           // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
522     libName = "TransformationGUI";
523     break;
524   case GEOMOp::OpPartition:          // MENU OPERATION - PARTITION
525   case GEOMOp::OpArchimede:          // MENU OPERATION - ARCHIMEDE
526   case GEOMOp::OpFillet3d:           // MENU OPERATION - FILLET
527   case GEOMOp::OpChamfer:            // MENU OPERATION - CHAMFER
528   case GEOMOp::OpClipping:           // MENU OPERATION - CLIPPING RANGE
529   case GEOMOp::OpShapesOnShape:      // MENU OPERATION - GET SHAPES ON SHAPE
530   case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
531   case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
532   case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
533   case GEOMOp::OpExtrudedBoss:       // MENU OPERATION - EXTRUDED BOSS
534   case GEOMOp::OpExtrudedCut:        // MENU OPERATION - EXTRUDED CUT
535     libName = "OperationGUI";
536     break;
537   case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
538   case GEOMOp::OpSuppressFaces:      // MENU REPAIR - SUPPRESS FACES
539   case GEOMOp::OpSuppressHoles:      // MENU REPAIR - SUPPRESS HOLE
540   case GEOMOp::OpShapeProcess:       // MENU REPAIR - SHAPE PROCESSING
541   case GEOMOp::OpCloseContour:       // MENU REPAIR - CLOSE CONTOUR
542   case GEOMOp::OpRemoveIntWires:     // MENU REPAIR - REMOVE INTERNAL WIRES
543   case GEOMOp::OpAddPointOnEdge:     // MENU REPAIR - ADD POINT ON EDGE
544   case GEOMOp::OpFreeBoundaries:     // MENU MEASURE - FREE BOUNDARIES
545   case GEOMOp::OpFreeFaces:          // MENU MEASURE - FREE FACES
546   case GEOMOp::OpOrientation:        // MENU REPAIR - CHANGE ORIENTATION
547   case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
548   case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
549   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
550   case GEOMOp::OpRemoveWebs:         // MENU REPAIR - REMOVE INTERNAL FACES
551   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
552   case GEOMOp::OpFuseEdges:          // MENU REPAIR - FUSE COLLINEAR EDGES
553   case GEOMOp::OpUnionFaces:         // MENU REPAIR - UNION FACES
554     libName = "RepairGUI";
555     break;
556   case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
557   case GEOMOp::OpCenterMass:         // MENU MEASURE - CDG
558   case GEOMOp::OpInertia:            // MENU MEASURE - INERTIA
559   case GEOMOp::OpNormale:            // MENU MEASURE - NORMALE
560   case GEOMOp::OpBoundingBox:        // MENU MEASURE - BOUNDING BOX
561   case GEOMOp::OpMinDistance:        // MENU MEASURE - MIN DISTANCE
562   case GEOMOp::OpAngle:              // MENU MEASURE - ANGLE
563   case GEOMOp::OpTolerance:          // MENU MEASURE - TOLERANCE
564   case GEOMOp::OpWhatIs:             // MENU MEASURE - WHATIS
565   case GEOMOp::OpCheckShape:         // MENU MEASURE - CHECK
566   case GEOMOp::OpCheckCompound:      // MENU MEASURE - CHECK COMPOUND OF BLOCKS
567   case GEOMOp::OpGetNonBlocks:       // MENU MEASURE - Get NON BLOCKS
568   case GEOMOp::OpPointCoordinates:   // MENU MEASURE - POINT COORDINATES
569   case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
570     libName = "MeasureGUI";
571     break;
572   case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
573   case GEOMOp::OpGroupCreatePopup:   // POPUP MENU - CREATE GROUP
574   case GEOMOp::OpGroupEdit:          // MENU GROUP - EDIT
575   case GEOMOp::OpGroupUnion:         // MENU GROUP - UNION
576   case GEOMOp::OpGroupIntersect:     // MENU GROUP - INTERSECT
577   case GEOMOp::OpGroupCut:           // MENU GROUP - CUT
578     libName = "GroupGUI";
579     break;
580   case GEOMOp::OpHexaSolid:          // MENU BLOCKS - HEXAHEDRAL SOLID
581   case GEOMOp::OpMultiTransform:     // MENU BLOCKS - MULTI-TRANSFORMATION
582   case GEOMOp::OpQuadFace:           // MENU BLOCKS - QUADRANGLE FACE
583   case GEOMOp::OpPropagate:          // MENU BLOCKS - PROPAGATE
584   case GEOMOp::OpExplodeBlock:       // MENU BLOCKS - EXPLODE ON BLOCKS
585     libName = "BlocksGUI";
586     break;
587   case GEOMOp::OpAdvancedNoOp:       // NO OPERATION (advanced operations base)
588   case GEOMOp::OpPipeTShape:         // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
589 //   case GEOMOp::OpPipeTShapeGroups:     // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
590   case GEOMOp::OpDividedDisk:           // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
591   case GEOMOp::OpDividedCylinder:           // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
592   case GEOMOp::OpSmoothingSurface:           // MENU NEW ENTITY - ADVANCED - SMOOTHINGSURFACE
593     //@@ 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 @@//
594     libName = "AdvancedGUI";
595     break;
596   default:
597     break;
598   }
599
600   GEOMGUI* library = 0;
601   if ( !libName.isEmpty() ) {
602 #ifndef WNT
603     libName = QString( "lib" ) + libName + ".so";
604 #else
605     libName = libName + ".dll";
606 #endif
607     library = getLibrary( libName );
608   }
609
610   // call method of corresponding GUI library
611   if ( library ) {
612     if( !theParam.isValid() )
613       library->OnGUIEvent( id, desk );
614     else
615       library->OnGUIEvent( id, desk, theParam);
616   }
617   else
618     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
619
620   updateCreationInfo();
621 }
622
623 //=================================================================================
624 // function : GeometryGUI::OnKeyPress()
625 // purpose  : Called when any key is pressed by user [static]
626 //=================================================================================
627 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
628 {
629   if ( !application() )
630     return;
631   foreach ( GEOMGUI* lib, myGUIMap )
632     lib->OnKeyPress( e, application()->desktop(), w );
633 }
634
635 //=================================================================================
636 // function : GeometryGUI::OnMouseMove()
637 // purpose  : Manages mouse move events [static]
638 //=================================================================================
639 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
640 {
641   if ( !application() )
642     return;
643   foreach ( GEOMGUI* lib, myGUIMap )
644     lib->OnMouseMove( e, application()->desktop(), w );
645 }
646
647 //=================================================================================
648 // function : GeometryGUI::OnMouseRelease()
649 // purpose  : Manages mouse release events [static]
650 //=================================================================================
651 void GeometryGUI::OnMouseRelease( SUIT_ViewWindow* w, QMouseEvent* e )
652 {
653   if ( !application() )
654     return;
655   foreach ( GEOMGUI* lib, myGUIMap )
656     lib->OnMouseRelease( e, application()->desktop(), w );
657 }
658
659 //=================================================================================
660 // function : GeometryGUI::OnMousePress()
661 // purpose  : Manage mouse press events [static]
662 //=================================================================================
663 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
664 {
665   if ( !application() )
666     return;
667   foreach ( GEOMGUI* lib, myGUIMap )
668     lib->OnMousePress( e, application()->desktop(), w );
669 }
670
671 //=======================================================================
672 // function : createGeomAction
673 // purpose  :
674 //=======================================================================
675 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
676                                     const int accel, const bool toggle, const QString& shortcutAction )
677 {
678   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
679   QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
680                                     : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
681   createAction( id,
682                 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
683                 icon,
684                 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ),
685                 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
686                 accel,
687                 application()->desktop(),
688                 toggle,
689                 this, SLOT( OnGUIEvent() ),
690                 shortcutAction );
691 }
692
693 //=======================================================================
694 // function : createOriginAndBaseVectors
695 // purpose  :
696 //=======================================================================
697 void GeometryGUI::createOriginAndBaseVectors()
698 {
699   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
700   if ( appStudy ) {
701     _PTR(Study) studyDS = appStudy->studyDS();
702     if ( studyDS && !CORBA::is_nil( GetGeomGen() ) ) {
703       GEOM::GEOM_IBasicOperations_var aBasicOperations = GetGeomGen()->GetIBasicOperations( studyDS->StudyId() );
704       if ( !aBasicOperations->_is_nil() ) {
705         SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
706         double aLength = aResourceMgr->doubleValue( "Geometry", "base_vectors_length", 1.0 );
707         GEOM::GEOM_Object_var anOrigin = aBasicOperations->MakePointXYZ( 0.0, 0.0, 0.0 );
708         GEOM::GEOM_Object_var anOX = aBasicOperations->MakeVectorDXDYDZ( aLength, 0.0, 0.0 );
709         GEOM::GEOM_Object_var anOY = aBasicOperations->MakeVectorDXDYDZ( 0.0, aLength, 0.0 );
710         GEOM::GEOM_Object_var anOZ = aBasicOperations->MakeVectorDXDYDZ( 0.0, 0.0, aLength );
711
712         SALOMEDS::Study_var aDSStudy = ClientStudyToStudy( studyDS );
713         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOrigin, "O" );
714         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOX, "OX" );
715         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOY, "OY" );
716         GetGeomGen()->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), anOZ, "OZ" );
717
718         getApp()->updateObjectBrowser( true );
719       }
720     }
721   }
722 }
723
724 //=======================================================================
725 // function : GeometryGUI::initialize()
726 // purpose  : Called when GEOM module is created
727 //=======================================================================
728 void GeometryGUI::initialize( CAM_Application* app )
729 {
730   SalomeApp_Module::initialize( app );
731
732   // ----- create actions --------------
733
734   createGeomAction( GEOMOp::OpImport,     "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
735   createGeomAction( GEOMOp::OpExport,     "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
736
737   createGeomAction( GEOMOp::OpDelete,     "DELETE", "", Qt::Key_Delete );
738
739   createGeomAction( GEOMOp::OpPoint,      "POINT" );
740   createGeomAction( GEOMOp::OpLine,       "LINE" );
741   createGeomAction( GEOMOp::OpCircle,     "CIRCLE" );
742   createGeomAction( GEOMOp::OpEllipse,    "ELLIPSE" );
743   createGeomAction( GEOMOp::OpArc,        "ARC" );
744   createGeomAction( GEOMOp::OpCurve,      "CURVE" );
745   createGeomAction( GEOMOp::OpVector,     "VECTOR" );
746   createGeomAction( GEOMOp::OpPlane,      "PLANE" );
747   createGeomAction( GEOMOp::OpLCS,        "LOCAL_CS" );
748   createGeomAction( GEOMOp::OpOriginAndVectors, "ORIGIN_AND_VECTORS" );
749
750   createGeomAction( GEOMOp::OpBox,        "BOX" );
751   createGeomAction( GEOMOp::OpCylinder,   "CYLINDER" );
752   createGeomAction( GEOMOp::OpSphere,     "SPHERE" );
753   createGeomAction( GEOMOp::OpTorus,      "TORUS" );
754   createGeomAction( GEOMOp::OpCone,       "CONE" );
755   createGeomAction( GEOMOp::OpRectangle,  "RECTANGLE" );
756   createGeomAction( GEOMOp::OpDisk,       "DISK" );
757
758   createGeomAction( GEOMOp::OpPrism,       "EXTRUSION" );
759   createGeomAction( GEOMOp::OpRevolution,  "REVOLUTION" );
760   createGeomAction( GEOMOp::OpFilling,     "FILLING" );
761   createGeomAction( GEOMOp::OpPipe,        "PIPE" );
762   createGeomAction( GEOMOp::OpPipePath,    "PIPE_PATH" );
763
764   createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
765   createGeomAction( GEOMOp::OpGroupEdit,   "GROUP_EDIT" );
766   createGeomAction( GEOMOp::OpGroupUnion,  "GROUP_UNION" );
767   createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
768   createGeomAction( GEOMOp::OpGroupCut,    "GROUP_CUT" );
769
770   createGeomAction( GEOMOp::OpReimport,    "RELOAD_IMPORTED" );
771
772   createGeomAction( GEOMOp::OpQuadFace,    "Q_FACE" );
773   createGeomAction( GEOMOp::OpHexaSolid,   "HEX_SOLID" );
774
775   createGeomAction( GEOMOp::Op2dSketcher,  "SKETCH" );
776   createGeomAction( GEOMOp::Op3dSketcher,  "3DSKETCH" );
777   createGeomAction( GEOMOp::OpExplode,     "EXPLODE" );
778 #ifdef WITH_OPENCV
779   createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
780 #endif
781   createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
782
783   createGeomAction( GEOMOp::OpEdge,        "EDGE" );
784   createGeomAction( GEOMOp::OpWire,        "WIRE" );
785   createGeomAction( GEOMOp::OpFace,        "FACE" );
786   createGeomAction( GEOMOp::OpShell,       "SHELL" );
787   createGeomAction( GEOMOp::OpSolid,       "SOLID" );
788   createGeomAction( GEOMOp::OpCompound,    "COMPOUND" );
789
790   createGeomAction( GEOMOp::OpFuse,        "FUSE" );
791   createGeomAction( GEOMOp::OpCommon,      "COMMON" );
792   createGeomAction( GEOMOp::OpCut,         "CUT" );
793   createGeomAction( GEOMOp::OpSection,     "SECTION" );
794
795   createGeomAction( GEOMOp::OpTranslate,      "TRANSLATION" );
796   createGeomAction( GEOMOp::OpRotate,         "ROTATION" );
797   createGeomAction( GEOMOp::OpChangeLoc,      "MODIFY_LOCATION" );
798   createGeomAction( GEOMOp::OpMirror,         "MIRROR" );
799   createGeomAction( GEOMOp::OpScale,          "SCALE" );
800   createGeomAction( GEOMOp::OpOffset,         "OFFSET" );
801   createGeomAction( GEOMOp::OpProjection,     "PROJECTION" );
802   createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
803   createGeomAction( GEOMOp::OpMultiRotate,    "MUL_ROTATION" );
804
805   createGeomAction( GEOMOp::OpPartition,      "PARTITION" );
806   createGeomAction( GEOMOp::OpArchimede,      "ARCHIMEDE" );
807   createGeomAction( GEOMOp::OpFillet3d,       "FILLET" );
808   createGeomAction( GEOMOp::OpChamfer,        "CHAMFER" );
809   //createGeomAction( GEOMOp::OpClipping,        "CLIPPING" );
810   createGeomAction( GEOMOp::OpShapesOnShape,  "GET_SHAPES_ON_SHAPE" );
811   createGeomAction( GEOMOp::OpSharedShapes,   "GET_SHARED_SHAPES" );
812   createGeomAction( GEOMOp::OpExtrudedCut,    "EXTRUDED_CUT" );
813   createGeomAction( GEOMOp::OpExtrudedBoss,   "EXTRUDED_BOSS" );
814   createGeomAction( GEOMOp::OpFillet1d,       "FILLET_1D" );
815   createGeomAction( GEOMOp::OpFillet2d,       "FILLET_2D" );
816
817   createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
818   createGeomAction( GEOMOp::OpExplodeBlock,   "EXPLODE_BLOCKS" );
819   createGeomAction( GEOMOp::OpPropagate,      "PROPAGATE" );
820
821   createGeomAction( GEOMOp::OpSewing,           "SEWING" );
822   createGeomAction( GEOMOp::OpGlueFaces,        "GLUE_FACES" );
823   createGeomAction( GEOMOp::OpGlueEdges,        "GLUE_EDGES" );
824   createGeomAction( GEOMOp::OpLimitTolerance,   "LIMIT_TOLERANCE" );
825   createGeomAction( GEOMOp::OpSuppressFaces,    "SUPPRESS_FACES" );
826   createGeomAction( GEOMOp::OpSuppressHoles,    "SUPPERSS_HOLES" );
827   createGeomAction( GEOMOp::OpShapeProcess,     "SHAPE_PROCESS" );
828   createGeomAction( GEOMOp::OpCloseContour,     "CLOSE_CONTOUR" );
829   createGeomAction( GEOMOp::OpRemoveIntWires,   "SUPPRESS_INT_WIRES" );
830   createGeomAction( GEOMOp::OpAddPointOnEdge,   "POINT_ON_EDGE" );
831   createGeomAction( GEOMOp::OpFreeBoundaries,   "CHECK_FREE_BNDS" );
832   createGeomAction( GEOMOp::OpFreeFaces,        "CHECK_FREE_FACES" );
833   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
834   createGeomAction( GEOMOp::OpRemoveWebs,       "REMOVE_WEBS" );
835   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
836   createGeomAction( GEOMOp::OpFuseEdges,        "FUSE_EDGES" );
837   createGeomAction( GEOMOp::OpUnionFaces,       "UNION_FACES" );
838
839   createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
840   createGeomAction( GEOMOp::OpProperties,       "BASIC_PROPS" );
841   createGeomAction( GEOMOp::OpCenterMass,       "MASS_CENTER" );
842   createGeomAction( GEOMOp::OpInertia,          "INERTIA" );
843   createGeomAction( GEOMOp::OpNormale,          "NORMALE" );
844   createGeomAction( GEOMOp::OpBoundingBox,      "BND_BOX" );
845   createGeomAction( GEOMOp::OpMinDistance,      "MIN_DIST" );
846   createGeomAction( GEOMOp::OpAngle,            "MEASURE_ANGLE" );
847
848   createGeomAction( GEOMOp::OpTolerance,        "TOLERANCE" );
849   createGeomAction( GEOMOp::OpWhatIs,           "WHAT_IS" );
850   createGeomAction( GEOMOp::OpCheckShape,       "CHECK" );
851   createGeomAction( GEOMOp::OpCheckCompound,    "CHECK_COMPOUND" );
852   createGeomAction( GEOMOp::OpGetNonBlocks,     "GET_NON_BLOCKS" );
853   createGeomAction( GEOMOp::OpCheckSelfInters,  "CHECK_SELF_INTERSECTIONS" );
854
855 #ifdef _DEBUG_ // PAL16821
856   createGeomAction( GEOMOp::OpCheckGeom,        "CHECK_GEOMETRY" );
857 #endif
858
859   createGeomAction( GEOMOp::OpMaterialsLibrary,   "MATERIALS_LIBRARY" );
860   createGeomAction( GEOMOp::OpDMWireframe,        "WIREFRAME" );
861   createGeomAction( GEOMOp::OpDMShading,          "SHADING" );
862   createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" );
863   createGeomAction( GEOMOp::OpShowAll,          "DISPLAY_ALL" );
864   createGeomAction( GEOMOp::OpHideAll,          "ERASE_ALL" );
865   createGeomAction( GEOMOp::OpShow,             "DISPLAY" );
866   createGeomAction( GEOMOp::OpSwitchVectors,    "VECTOR_MODE");
867   createGeomAction( GEOMOp::OpSelectVertex,     "VERTEX_SEL_ONLY" ,"", 0, true );
868   createGeomAction( GEOMOp::OpSelectEdge,       "EDGE_SEL_ONLY", "", 0, true );
869   createGeomAction( GEOMOp::OpSelectWire,       "WIRE_SEL_ONLY", "",  0, true );
870   createGeomAction( GEOMOp::OpSelectFace,       "FACE_SEL_ONLY", "", 0, true );
871   createGeomAction( GEOMOp::OpSelectShell,      "SHELL_SEL_ONLY", "",  0, true );
872   createGeomAction( GEOMOp::OpSelectSolid,      "SOLID_SEL_ONLY", "", 0, true );
873   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
874   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
875   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
876   createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
877   createGeomAction( GEOMOp::OpBringToFront,     "BRING_TO_FRONT", "", 0, true );
878   createGeomAction( GEOMOp::OpClsBringToFront,  "CLS_BRING_TO_FRONT" );
879   createGeomAction( GEOMOp::OpHide,             "ERASE" );
880
881   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
882   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
883   createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
884   createGeomAction( GEOMOp::OpTexture,          "POP_TEXTURE", "", 0, true );
885   createGeomAction( GEOMOp::OpEdgeWidth,        "EDGE_WIDTH");
886   createGeomAction( GEOMOp::OpIsosWidth,        "ISOS_WIDTH");
887   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
888   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
889   createGeomAction( GEOMOp::OpColor,            "POP_COLOR" );
890   createGeomAction( GEOMOp::OpSetTexture,       "POP_SETTEXTURE" );
891   createGeomAction( GEOMOp::OpTransparency,     "POP_TRANSPARENCY" );
892   createGeomAction( GEOMOp::OpIsos,             "POP_ISOS" );
893   createGeomAction( GEOMOp::OpAutoColor,        "POP_AUTO_COLOR" );
894   createGeomAction( GEOMOp::OpNoAutoColor,      "POP_DISABLE_AUTO_COLOR" );
895   createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
896   createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
897   createGeomAction( GEOMOp::OpConcealChildren,  "POP_CONCEAL_CHILDREN" );
898   createGeomAction( GEOMOp::OpUnpublishObject,  "POP_UNPUBLISH_OBJ" );
899   createGeomAction( GEOMOp::OpPublishObject,    "POP_PUBLISH_OBJ" );
900   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
901   createGeomAction( GEOMOp::OpMaterialProperties,   "POP_MATERIAL_PROPERTIES" );
902   createGeomAction( GEOMOp::OpPredefMaterCustom,    "POP_PREDEF_MATER_CUSTOM" );
903
904   createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
905
906   // Create actions for increase/decrease transparency shortcuts
907   createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
908                     "Geometry:Increase transparency");
909   createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
910                     "Geometry:Decrease transparency");
911
912   // Create actions for increase/decrease number of isolines
913   createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
914                     "Geometry:Increase number of isolines");
915   createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
916                     "Geometry:Decrease number of isolines");
917
918 //   createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
919   createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" );
920   createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" );
921   createGeomAction( GEOMOp::OpSmoothingSurface, "SMOOTHINGSURFACE" );
922   //@@ 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 @@//
923
924   // ---- create menus --------------------------
925
926   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
927   createMenu( separator(),      fileId, 10 );
928   createMenu( GEOMOp::OpImport, fileId, 10 );
929   createMenu( GEOMOp::OpExport, fileId, 10 );
930   createMenu( separator(),      fileId, -1 );
931
932   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
933   createMenu( GEOMOp::OpDelete, editId, -1 );
934
935   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
936
937   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
938   createMenu( GEOMOp::OpPoint,   basicId, -1 );
939   createMenu( GEOMOp::OpLine,    basicId, -1 );
940   createMenu( GEOMOp::OpCircle,  basicId, -1 );
941   createMenu( GEOMOp::OpEllipse, basicId, -1 );
942   createMenu( GEOMOp::OpArc,     basicId, -1 );
943   createMenu( GEOMOp::OpCurve,   basicId, -1 );
944   createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
945   createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
946   createMenu( separator(),       basicId, -1 );
947   createMenu( GEOMOp::OpVector,  basicId, -1 );
948   createMenu( GEOMOp::OpPlane,   basicId, -1 );
949   createMenu( GEOMOp::OpLCS,     basicId, -1 );
950   createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
951
952   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
953   createMenu( GEOMOp::OpBox,       primId, -1 );
954   createMenu( GEOMOp::OpCylinder,  primId, -1 );
955   createMenu( GEOMOp::OpSphere,    primId, -1 );
956   createMenu( GEOMOp::OpTorus,     primId, -1 );
957   createMenu( GEOMOp::OpCone,      primId, -1 );
958   createMenu( GEOMOp::OpRectangle, primId, -1 );
959   createMenu( GEOMOp::OpDisk,      primId, -1 );
960   createMenu( GEOMOp::OpPipeTShape,primId, -1 );
961
962   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
963   createMenu( GEOMOp::OpPrism,      genId, -1 );
964   createMenu( GEOMOp::OpRevolution, genId, -1 );
965   createMenu( GEOMOp::OpFilling,    genId, -1 );
966   createMenu( GEOMOp::OpPipe,       genId, -1 );
967 #if OCC_VERSION_LARGE > 0x06050300
968   createMenu( GEOMOp::OpPipePath,   genId, -1 );
969 #endif
970
971    int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
972    createMenu( GEOMOp::OpSmoothingSurface, advId, -1 );
973    //@@ 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 @@//
974
975   createMenu( separator(), newEntId, -1 );
976
977   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
978   createMenu( GEOMOp::OpGroupCreate,    groupId, -1 );
979   createMenu( GEOMOp::OpGroupEdit,      groupId, -1 );
980   createMenu( GEOMOp::OpGroupUnion,     groupId, -1 );
981   createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
982   createMenu( GEOMOp::OpGroupCut,       groupId, -1 );
983
984   createMenu( separator(), newEntId, -1 );
985
986   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
987   createMenu( GEOMOp::OpQuadFace,        blocksId, -1 );
988   createMenu( GEOMOp::OpHexaSolid,       blocksId, -1 );
989   createMenu( GEOMOp::OpDividedDisk,     blocksId, -1 );
990   createMenu( GEOMOp::OpDividedCylinder, blocksId, -1 );
991
992   createMenu( separator(),          newEntId, -1 );
993
994   createMenu( GEOMOp::OpExplode,    newEntId, -1 );
995
996   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
997   createMenu( GEOMOp::OpEdge,     buildId, -1 );
998   createMenu( GEOMOp::OpWire,     buildId, -1 );
999   createMenu( GEOMOp::OpFace,     buildId, -1 );
1000   createMenu( GEOMOp::OpShell,    buildId, -1 );
1001   createMenu( GEOMOp::OpSolid,    buildId, -1 );
1002   createMenu( GEOMOp::OpCompound, buildId, -1 );
1003
1004   createMenu( separator(),          newEntId, -1 );
1005
1006   createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
1007 #ifdef WITH_OPENCV
1008   createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
1009 #endif
1010
1011   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
1012
1013   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
1014   createMenu( GEOMOp::OpFuse,    boolId, -1 );
1015   createMenu( GEOMOp::OpCommon,  boolId, -1 );
1016   createMenu( GEOMOp::OpCut,     boolId, -1 );
1017   createMenu( GEOMOp::OpSection, boolId, -1 );
1018
1019   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
1020   createMenu( GEOMOp::OpTranslate,      transId, -1 );
1021   createMenu( GEOMOp::OpRotate,         transId, -1 );
1022   createMenu( GEOMOp::OpChangeLoc,      transId, -1 );
1023   createMenu( GEOMOp::OpMirror,         transId, -1 );
1024   createMenu( GEOMOp::OpScale,          transId, -1 );
1025   createMenu( GEOMOp::OpOffset,         transId, -1 );
1026   createMenu( GEOMOp::OpProjection,     transId, -1 );
1027   createMenu( separator(),              transId, -1 );
1028   createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
1029   createMenu( GEOMOp::OpMultiRotate,    transId, -1 );
1030
1031   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
1032   createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
1033   createMenu( GEOMOp::OpExplodeBlock,   blockId, -1 );
1034   createMenu( GEOMOp::OpPropagate,      blockId, -1 );
1035
1036   createMenu( separator(), operId, -1 );
1037
1038   createMenu( GEOMOp::OpPartition,     operId, -1 );
1039   createMenu( GEOMOp::OpArchimede,     operId, -1 );
1040   createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1041   createMenu( GEOMOp::OpSharedShapes,  operId, -1 );
1042
1043   createMenu( separator(), operId, -1 );
1044
1045   createMenu( GEOMOp::OpFillet1d,      operId, -1 );
1046   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
1047   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
1048   createMenu( GEOMOp::OpChamfer,       operId, -1 );
1049   createMenu( GEOMOp::OpExtrudedBoss,  operId, -1 );
1050   createMenu( GEOMOp::OpExtrudedCut,   operId, -1 );
1051   //createMenu( GEOMOp::OpClipping,      operId, -1 );
1052
1053   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1054   createMenu( GEOMOp::OpShapeProcess,    repairId, -1 );
1055   createMenu( GEOMOp::OpSuppressFaces,   repairId, -1 );
1056   createMenu( GEOMOp::OpCloseContour,    repairId, -1 );
1057   createMenu( GEOMOp::OpRemoveIntWires,  repairId, -1 );
1058   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
1059   createMenu( GEOMOp::OpSewing,          repairId, -1 );
1060   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
1061   createMenu( GEOMOp::OpGlueEdges,       repairId, -1 );
1062   createMenu( GEOMOp::OpLimitTolerance,  repairId, -1 );
1063   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
1064   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
1065   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
1066   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
1067   createMenu( GEOMOp::OpRemoveWebs,       repairId, -1 );
1068   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1069   createMenu( GEOMOp::OpFuseEdges,        repairId, -1 );
1070   createMenu( GEOMOp::OpUnionFaces,       repairId, -1 );
1071
1072   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1073   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1074   createMenu( GEOMOp::OpProperties,       measurId, -1 );
1075   createMenu( separator(),                measurId, -1 );
1076   createMenu( GEOMOp::OpCenterMass,       measurId, -1 );
1077   createMenu( GEOMOp::OpInertia,          measurId, -1 );
1078   createMenu( GEOMOp::OpNormale,          measurId, -1 );
1079   createMenu( separator(),                measurId, -1 );
1080   createMenu( GEOMOp::OpFreeBoundaries,   measurId, -1 );
1081   createMenu( GEOMOp::OpFreeFaces,        measurId, -1 );
1082   createMenu( separator(),                measurId, -1 );
1083
1084   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1085   createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1086   createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1087   createMenu( GEOMOp::OpAngle,       dimId, -1 );
1088
1089   createMenu( separator(),               measurId, -1 );
1090   createMenu( GEOMOp::OpTolerance,       measurId, -1 );
1091   createMenu( separator(),               measurId, -1 );
1092   createMenu( GEOMOp::OpWhatIs,          measurId, -1 );
1093   createMenu( GEOMOp::OpCheckShape,      measurId, -1 );
1094   createMenu( GEOMOp::OpCheckCompound,   measurId, -1 );
1095   createMenu( GEOMOp::OpGetNonBlocks,    measurId, -1 );
1096   createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1097
1098   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1099 #if defined(_DEBUG_) || defined(_DEBUG) // PAL16821
1100   createMenu( separator(),         toolsId, -1 );
1101   createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1102 #endif
1103  
1104   createMenu( separator(),         toolsId, -1 );
1105   createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 );
1106   createMenu( separator(),         toolsId, -1 );
1107
1108   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1109   createMenu( separator(),       viewId, -1 );
1110
1111   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1112   createMenu( GEOMOp::OpDMWireframe,        dispmodeId, -1 );
1113   createMenu( GEOMOp::OpDMShading,          dispmodeId, -1 );
1114   createMenu( GEOMOp::OpDMShadingWithEdges, dispmodeId, -1 );
1115   createMenu( separator(),                  dispmodeId, -1 );
1116   createMenu( GEOMOp::OpSwitchVectors,      dispmodeId, -1 );
1117
1118   createMenu( separator(),       viewId, -1 );
1119   createMenu( GEOMOp::OpShowAll, viewId, -1 );
1120   createMenu( GEOMOp::OpHideAll, viewId, -1 );
1121   createMenu( separator(),       viewId, -1 );
1122   createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1123   createMenu( separator(),       viewId, -1 );
1124
1125 /*
1126   PAL9111:
1127   because of these items are accessible through object browser and viewers
1128   we have removed they from main menu
1129
1130   createMenu( GEOMOp::OpShow, viewId, -1 );
1131   createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1132   createMenu( GEOMOp::OpHide, viewId, -1 );
1133 */
1134
1135   // ---- create toolbars --------------------------
1136
1137   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1138   createTool( GEOMOp::OpPoint,      basicTbId );
1139   createTool( GEOMOp::OpLine,       basicTbId );
1140   createTool( GEOMOp::OpCircle,     basicTbId );
1141   createTool( GEOMOp::OpEllipse,    basicTbId );
1142   createTool( GEOMOp::OpArc,        basicTbId );
1143   createTool( GEOMOp::OpCurve,      basicTbId );
1144   createTool( GEOMOp::OpVector,     basicTbId );
1145   createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1146   createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1147   createTool( GEOMOp::OpPlane,      basicTbId );
1148   createTool( GEOMOp::OpLCS,        basicTbId );
1149   createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1150
1151 //   int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
1152 //   createTool( GEOMOp::Op2dSketcher,  sketchTbId );
1153 //   createTool( GEOMOp::Op3dSketcher,  sketchTbId );
1154
1155   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1156   createTool( GEOMOp::OpBox,        primTbId );
1157   createTool( GEOMOp::OpCylinder,   primTbId );
1158   createTool( GEOMOp::OpSphere,     primTbId );
1159   createTool( GEOMOp::OpTorus,      primTbId );
1160   createTool( GEOMOp::OpCone,       primTbId );
1161   createTool( GEOMOp::OpRectangle,  primTbId );
1162   createTool( GEOMOp::OpDisk,       primTbId );
1163   createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1164
1165   int blocksTbId = createTool( tr( "TOOL_BLOCKS" ) );
1166   createTool( GEOMOp::OpDividedDisk, blocksTbId );
1167   createTool( GEOMOp::OpDividedCylinder, blocksTbId );
1168
1169 //   int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
1170 //   createTool( GEOMOp::OpPipeTShape, advancedTbId );
1171
1172   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1173   createTool( GEOMOp::OpFuse,       boolTbId );
1174   createTool( GEOMOp::OpCommon,     boolTbId );
1175   createTool( GEOMOp::OpCut,        boolTbId );
1176   createTool( GEOMOp::OpSection,    boolTbId );
1177
1178   int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1179   createTool( GEOMOp::OpPrism,      genTbId );
1180   createTool( GEOMOp::OpRevolution, genTbId );
1181   createTool( GEOMOp::OpFilling,    genTbId );
1182   createTool( GEOMOp::OpPipe,       genTbId );
1183 #if OCC_VERSION_LARGE > 0x06050300
1184   createTool( GEOMOp::OpPipePath,   genTbId );
1185 #endif
1186
1187   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1188   createTool( GEOMOp::OpTranslate,      transTbId );
1189   createTool( GEOMOp::OpRotate,         transTbId );
1190   createTool( GEOMOp::OpChangeLoc,      transTbId );
1191   createTool( GEOMOp::OpMirror,         transTbId );
1192   createTool( GEOMOp::OpScale,          transTbId );
1193   createTool( GEOMOp::OpOffset,         transTbId );
1194   createTool( GEOMOp::OpProjection,     transTbId );
1195   createTool( separator(),              transTbId );
1196   createTool( GEOMOp::OpMultiTranslate, transTbId );
1197   createTool( GEOMOp::OpMultiRotate,    transTbId );
1198
1199   int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1200   createTool( GEOMOp::OpExplode,         operTbId );
1201   createTool( GEOMOp::OpPartition,       operTbId );
1202   createTool( GEOMOp::OpArchimede,       operTbId );
1203   createTool( GEOMOp::OpShapesOnShape,   operTbId );
1204   createTool( GEOMOp::OpSharedShapes,    operTbId );
1205
1206   int featTbId = createTool( tr( "TOOL_FEATURES" ) );
1207   createTool( GEOMOp::OpFillet1d,        featTbId );
1208   createTool( GEOMOp::OpFillet2d,        featTbId );
1209   createTool( GEOMOp::OpFillet3d,        featTbId );
1210   createTool( GEOMOp::OpChamfer,         featTbId );
1211   createTool( GEOMOp::OpExtrudedBoss,    featTbId );
1212   createTool( GEOMOp::OpExtrudedCut,     featTbId );
1213
1214   int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1215   createTool( GEOMOp::OpEdge,     buildTbId );
1216   createTool( GEOMOp::OpWire,     buildTbId );
1217   createTool( GEOMOp::OpFace,     buildTbId );
1218   createTool( GEOMOp::OpShell,    buildTbId );
1219   createTool( GEOMOp::OpSolid,    buildTbId );
1220   createTool( GEOMOp::OpCompound, buildTbId );
1221
1222   int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1223   createTool( GEOMOp::OpPointCoordinates, measureTbId );
1224   createTool( GEOMOp::OpProperties,       measureTbId );
1225   createTool( GEOMOp::OpCenterMass,       measureTbId );
1226   createTool( GEOMOp::OpInertia,          measureTbId );
1227   createTool( GEOMOp::OpNormale,          measureTbId );
1228   createTool( separator(),                measureTbId );
1229   createTool( GEOMOp::OpBoundingBox,      measureTbId );
1230   createTool( GEOMOp::OpMinDistance,      measureTbId );
1231   createTool( GEOMOp::OpAngle,            measureTbId );
1232   createTool( GEOMOp::OpTolerance  ,      measureTbId );
1233   createTool( separator(),                measureTbId );
1234   createTool( GEOMOp::OpFreeBoundaries,   measureTbId );
1235   createTool( GEOMOp::OpFreeFaces,        measureTbId );
1236   createTool( separator(),                measureTbId );
1237   createTool( GEOMOp::OpWhatIs,           measureTbId );
1238   createTool( GEOMOp::OpCheckShape,       measureTbId );
1239   createTool( GEOMOp::OpCheckCompound,    measureTbId );
1240   createTool( GEOMOp::OpGetNonBlocks,     measureTbId );
1241   createTool( GEOMOp::OpCheckSelfInters,  measureTbId );
1242
1243   int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
1244   createTool( GEOMOp::OpPictureImport,    picturesTbId );
1245   #ifdef WITH_OPENCV
1246     createTool( GEOMOp::OpFeatureDetect,  picturesTbId );
1247   #endif
1248
1249   int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) );
1250   createTool( GEOMOp::OpSmoothingSurface, advancedTbId );
1251   //@@ 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 @@//
1252
1253   // ---- create popup menus --------------------------
1254
1255   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1256   QString clientOCC = "(client='OCCViewer')";
1257   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1258   QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1259
1260   QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1261   QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1262   QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1263   QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1264
1265   QString autoColorPrefix =
1266     "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1267
1268   QtxPopupMgr* mgr = popupMgr();
1269
1270   mgr->insert( action(  GEOMOp::OpDelete ), -1, -1 );  // delete
1271   mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1272   mgr->insert( action(  GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1273   mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1274   mgr->insert( action(  GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
1275   mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
1276
1277   mgr->insert( action(  GEOMOp::OpConcealChildren ), -1, -1 ); // conceal shild items
1278   mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
1279   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
1280   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1281   mgr->insert( separator(), -1, -1 );     // -----------
1282
1283 #if OCC_VERSION_LARGE > 0x06050200
1284   //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
1285   QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true";
1286   mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
1287   mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule );
1288   mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
1289   mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
1290   mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );
1291 #endif
1292   mgr->insert( separator(), -1, -1 );     // -----------
1293   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1294   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1295   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1296   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1297   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1298   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1299   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1300   mgr->insert( action(  GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1301   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1302   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1303   mgr->insert( action(  GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1304   mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1305   mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1306   mgr->insert( separator(), dispmodeId, -1 );
1307   mgr->insert( action(  GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1308   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible  + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1309   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1310   mgr->insert( separator(), -1, -1 );     // -----------
1311   
1312   mgr->insert( action(  GEOMOp::OpColor ), -1, -1 ); // color
1313   mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
1314   mgr->insert( action(  GEOMOp::OpTransparency ), -1, -1 ); // transparency
1315   mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1316   mgr->insert( action(  GEOMOp::OpIsos ), -1, -1 ); // isos
1317   mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1318   mgr->insert( action(  GEOMOp::OpDeflection ), -1, -1 ); // deflection
1319   mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1320   mgr->insert( action(  GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1321   //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1322   mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1323   
1324   // material properties
1325   mgr->insert( action(  GEOMOp::OpMaterialProperties ), -1, -1 ); 
1326   mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1327
1328  // texture
1329   mgr->insert( action(  GEOMOp::OpSetTexture ), -1, -1 );
1330   mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1331
1332   int lineW = mgr->insert(  tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1333   mgr->insert( action(  GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1334   mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1335
1336   mgr->insert( action(  GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1337   mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1338
1339   mgr->insert( separator(), -1, -1 );     // -----------
1340   mgr->insert( action(  GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1341   mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1342   mgr->insert( action(  GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1343   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1344   mgr->insert( separator(), -1, -1 );     // -----------
1345
1346   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1347           onlyComponent = "((type='Component') and selcount=1)",
1348           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1349           types = "'Shape' 'Group'";
1350
1351   mgr->insert( action(  GEOMOp::OpShow ), -1, -1 ); // display
1352   mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1353
1354   mgr->insert( action(  GEOMOp::OpHide ), -1, -1 ); // erase
1355   mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1356
1357   mgr->insert( action(  GEOMOp::OpHideAll ), -1, -1 ); // erase All
1358   mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1359
1360   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1361
1362   int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
1363   mgr->insert( action(GEOMOp::OpSelectVertex),   selectonlyId, -1);                                  //Vertex
1364   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly, QtxPopupMgr::VisibleRule);
1365   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1366   mgr->insert( action(GEOMOp::OpSelectEdge),     selectonlyId, -1);                                  //Edge
1367   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly, QtxPopupMgr::VisibleRule);
1368   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1369   mgr->insert( action(GEOMOp::OpSelectWire),     selectonlyId, -1);                                  //Wire
1370   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly, QtxPopupMgr::VisibleRule);
1371   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1372   mgr->insert( action(GEOMOp::OpSelectFace),     selectonlyId, -1);                                  //Face
1373   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly, QtxPopupMgr::VisibleRule);
1374   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1375   mgr->insert( action(GEOMOp::OpSelectShell),    selectonlyId, -1);                                  //Shell
1376   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly, QtxPopupMgr::VisibleRule);
1377   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1378   mgr->insert( action(GEOMOp::OpSelectSolid),    selectonlyId, -1);                                  //Solid
1379   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly, QtxPopupMgr::VisibleRule);
1380   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1381   mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1);                                  //Compound
1382   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1383   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1384   mgr->insert( separator(), selectonlyId, -1);
1385   mgr->insert( action(GEOMOp::OpSelectAll),      selectonlyId, -1);                                  //Clear selection filter
1386   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly, QtxPopupMgr::VisibleRule);
1387   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1388   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1389   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1390   mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
1391   mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
1392
1393   mgr->insert( separator(), -1, -1 );     // -----------
1394   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1395   mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1396
1397   mgr->insert( action(  GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1398   mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1399
1400   mgr->insert( action(  GEOMOp::OpReimport ), -1, -1 );  // delete
1401   mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1402
1403   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1404
1405   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1406   if (resMgr) {
1407     GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)resMgr->integerValue("Geometry", "toplevel_dm", 0));
1408     QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
1409     GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
1410   }
1411 }
1412
1413 //=======================================================================
1414 // function : GeometryGUI::activateModule()
1415 // purpose  : Called when GEOM module is activated
1416 //=======================================================================
1417 bool GeometryGUI::activateModule( SUIT_Study* study )
1418 {
1419   if ( CORBA::is_nil( myComponentGeom ) )
1420     return false;
1421
1422   bool res = SalomeApp_Module::activateModule( study );
1423
1424   if ( !res )
1425     return false;
1426   setMenuShown( true );
1427   setToolShown( true );
1428
1429   // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1430   PyGILState_STATE gstate = PyGILState_Ensure();
1431   PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1432   if (pluginsmanager == NULL)
1433     PyErr_Print();
1434   else {
1435     PyObject* result =
1436       PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "geom",
1437                           tr("MEN_NEW_ENTITY").toStdString().c_str(),
1438                           tr("GEOM_PLUGINS_OTHER").toStdString().c_str());
1439     if (result == NULL)
1440       PyErr_Print();
1441     Py_XDECREF(result);
1442   }
1443   PyGILState_Release(gstate);
1444   // end of GEOM plugins loading
1445
1446   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1447           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1448
1449   // Reset actions accelerator keys
1450   action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1451   action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1452   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1453
1454   GUIMap::Iterator it;
1455   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1456     it.value()->activate( application()->desktop() );
1457
1458   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1459
1460   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1461   if ( !myCreationInfoWdg )
1462     myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
1463   getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
1464   getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1465
1466   SUIT_ViewManager* vm;
1467   ViewManagerList OCCViewManagers, VTKViewManagers;
1468
1469   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1470   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1471   while ( itOCC.hasNext() && (vm = itOCC.next()) )
1472     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1473
1474   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1475   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1476   while ( itVTK.hasNext() && (vm = itVTK.next()) )
1477     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1478
1479   //NPAL 19674
1480   SALOME_ListIO selected;
1481   sm->selectedObjects( selected );
1482   sm->clearSelected();
1483
1484   // disable OCC selectors
1485   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1486   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1487   while ( itOCCSel.hasNext() )
1488     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1489       sr->setEnabled(true);
1490
1491   // disable VTK selectors
1492   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1493   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1494   while ( itVTKSel.hasNext() )
1495     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1496       sr->setEnabled(true);
1497
1498   sm->setSelectedObjects( selected, true );   //NPAL 19674
1499
1500   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1501   if ( viewMenu )
1502     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1503
1504   // 0020836 (Basic vectors and origin)
1505   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1506   if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1507     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1508     if ( appStudy ) {
1509       _PTR(Study) studyDS = appStudy->studyDS();
1510       if ( studyDS ) {
1511         _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1512         if ( !aSComponent ) // create objects automatically only if there is no GEOM component
1513           createOriginAndBaseVectors();
1514       }
1515     }
1516   }
1517
1518   return true;
1519 }
1520
1521 //=======================================================================
1522 // function : GeometryGUI::deactivateModule()
1523 // purpose  : Called when GEOM module is deactivated
1524 //=======================================================================
1525 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1526 {
1527   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1528   if ( viewMenu )
1529     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1530
1531   setMenuShown( false );
1532   setToolShown( false );
1533
1534   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1535              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1536
1537   LightApp_SelectionMgr* selMrg = getApp()->selectionMgr();
1538
1539   disconnect( selMrg, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
1540   getApp()->removeDockWindow( myCreationInfoWdg->getWinID() );
1541   myCreationInfoWdg = 0;
1542
1543   EmitSignalCloseAllDialogs();
1544
1545   GUIMap::Iterator it;
1546   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1547     it.value()->deactivate();
1548
1549   // Unset actions accelerator keys
1550   action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1551   action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1552   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1553
1554   qDeleteAll(myOCCSelectors);
1555   myOCCSelectors.clear();
1556   selMrg->setEnabled( true, OCCViewer_Viewer::Type() );
1557
1558   qDeleteAll(myVTKSelectors);
1559   myVTKSelectors.clear();
1560   selMrg->setEnabled( true, SVTK_Viewer::Type() );
1561
1562   return SalomeApp_Module::deactivateModule( study );
1563 }
1564
1565 //=======================================================================
1566 // function : onWindowActivated()
1567 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1568 //=======================================================================
1569 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1570 {
1571   if ( !win )
1572     return;
1573
1574   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1575   //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1576
1577   // disable non-OCC viewframe menu commands
1578 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1579   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1580   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1581   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1582   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1583   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1584 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1585
1586   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1587   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1588
1589   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1590 }
1591
1592 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1593 {
1594   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1595   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1596   if ( myCreationInfoWdg )
1597     mappa.insert( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
1598 }
1599
1600 void GeometryGUI::viewManagers( QStringList& lst ) const
1601 {
1602   lst.append( OCCViewer_Viewer::Type() );
1603 }
1604
1605 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1606 {
1607   if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1608   {
1609     qDebug( "connect" );
1610     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
1611              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1612     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1613              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1614     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1615              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1616     connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1617              this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1618
1619     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1620     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1621
1622     // disable OCC selectors
1623     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1624     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1625     while ( itOCCSel.hasNext() )
1626       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1627         sr->setEnabled(true);
1628   }
1629   else if ( vm->getType() == SVTK_Viewer::Type() )
1630   {
1631     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1632     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1633
1634     // disable VTK selectors
1635     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1636     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1637     while ( itVTKSel.hasNext() )
1638       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1639         sr->setEnabled(true);
1640   }
1641 }
1642
1643 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1644 {
1645   SUIT_ViewModel* viewer = vm->getViewModel();
1646   if ( vm->getType() == OCCViewer_Viewer::Type() )
1647   {
1648     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1649     while ( itOCCSel.hasNext() )
1650       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1651         if ( sr->viewer() == viewer )
1652         {
1653           /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1654           break;
1655         }
1656   }
1657   if ( vm->getType() == SVTK_Viewer::Type() )
1658   {
1659     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1660     while ( itVTKSel.hasNext() )
1661       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1662         if ( sr->viewer() == viewer )
1663         {
1664           /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1665           break;
1666         }
1667   }
1668 }
1669
1670 //================================================================================
1671 /*!
1672  * \brief Slot called when selection changed. Shows creation info of a selected object 
1673  */
1674 //================================================================================
1675
1676 void GeometryGUI::updateCreationInfo()
1677 {
1678   myCreationInfoWdg->clear();
1679
1680   // Code below is commented to have myCreationInfoWdg filled as soon as it is shown again
1681   // if ( !myCreationInfoWdg->isVisible() )
1682   //   return;
1683
1684   // look for a sole selected GEOM_Object
1685   GEOM::GEOM_Object_var geomObj;
1686
1687   SALOME_ListIO selected;
1688   getApp()->selectionMgr()->selectedObjects( selected );
1689
1690   _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() )->studyDS();
1691   SALOME_ListIteratorOfListIO selIt( selected );
1692   for ( ; selIt.More(); selIt.Next() )
1693   {
1694     Handle(SALOME_InteractiveObject) io = selIt.Value();
1695     if ( !io->hasEntry() ) continue;
1696     _PTR(SObject) sobj = study->FindObjectID( io->getEntry() );
1697     if ( !sobj ) continue;
1698     CORBA::Object_var      obj = GeometryGUI::ClientSObjectToObject( sobj );
1699     GEOM::GEOM_Object_var gobj = GEOM::GEOM_Object::_narrow( obj );
1700     if ( !gobj->_is_nil() )
1701     {
1702       if ( !geomObj->_is_nil() )
1703         return; // several GEOM objects selected
1704       geomObj = gobj;
1705     }
1706   }
1707   if ( geomObj->_is_nil() ) return;
1708
1709   // pass creation info of geomObj to myCreationInfoWdg
1710
1711   QPixmap icon;
1712   QString operationName;
1713   myCreationInfoWdg->setOperation( icon, operationName );
1714
1715   try
1716   {
1717     OCC_CATCH_SIGNALS;
1718     GEOM::CreationInformation_var info = geomObj->GetCreationInformation();
1719     if ( &info.in() )
1720     {
1721       SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1722       QString name = info->operationName.in();
1723       if ( !name.isEmpty() )
1724       {
1725         icon = resMgr->loadPixmap( "GEOM", tr( ("ICO_"+name).toLatin1().constData() ), false );
1726         operationName = tr( ("MEN_"+name).toLatin1().constData() );
1727         if ( operationName.startsWith( "MEN_" ))
1728           operationName = name; // no translation
1729         myCreationInfoWdg->setOperation( icon, operationName );
1730
1731         for ( size_t i = 0; i < info->params.length(); ++i )
1732           myCreationInfoWdg->addParam( info->params[i].name.in(),
1733                                        info->params[i].value.in() );
1734       }
1735     }
1736   }
1737   catch (...)
1738   {
1739   }
1740 }
1741
1742 QString GeometryGUI::engineIOR() const
1743 {
1744   if ( !CORBA::is_nil( GetGeomGen() ) )
1745     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1746   return "";
1747 }
1748
1749 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1750 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
1751 #else
1752 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
1753 #endif
1754       (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
1755 {
1756   theWidth = theHeight = 0;
1757
1758 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1759   Handle(TColStd_HArray1OfByte) aTexture;
1760 #else
1761   Handle(Graphic3d_HArray1OfBytes) aTexture;
1762 #endif
1763
1764   if (theStudy) {
1765     TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1766     aTexture = aTextureMap[ theId ];
1767     if ( aTexture.IsNull() ) {
1768       GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1769       if ( !aInsOp->_is_nil() ) {
1770         CORBA::Long aWidth, aHeight;
1771         SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1772         if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1773           theWidth  = aWidth;
1774           theHeight = aHeight;
1775
1776 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1777           aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
1778 #else
1779           aTexture  = new Graphic3d_HArray1OfBytes (1, aStream->length());
1780 #endif
1781
1782           for (int i = 0; i < aStream->length(); i++)
1783             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1784           aTextureMap[ theId ] = aTexture;
1785         }
1786       }
1787     }
1788   }
1789   return aTexture;
1790 }
1791
1792 LightApp_Selection* GeometryGUI::createSelection() const
1793 {
1794   return new GEOMGUI_Selection();
1795 }
1796
1797 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1798 {
1799   SalomeApp_Module::contextMenuPopup( client, menu, title );
1800   SALOME_ListIO lst;
1801   getApp()->selectionMgr()->selectedObjects( lst );
1802
1803   //Add submenu for predefined materials
1804   bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" );
1805   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) {
1806     QtxPopupMgr* mgr = popupMgr();
1807     //get parrent for submenu
1808     QAction* act = mgr->action( mgr->actionId( action(  GEOMOp::OpMaterialProperties ) ) );
1809     //Clear old  menu
1810     QMenu* oldMenu = act->menu() ;
1811     if( oldMenu ) {
1812       delete oldMenu;
1813     }
1814     if( isPredefMat ){
1815       QMenu* matMenu = new QMenu();
1816       QSignalMapper* signalMapper = new QSignalMapper( matMenu );
1817       
1818       //Get current material model for the object
1819       QVariant v;
1820       LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( getApp() );
1821       if ( anApp && anApp->activeViewManager() ) {
1822         LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( anApp->activeStudy() );
1823         if( aStudy ) {
1824           v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() );
1825         }
1826       }
1827       QString curModel = "";
1828       if ( v.canConvert<QString>() ) curModel = v.toString();
1829       // get list of all predefined materials
1830       QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
1831       bool found = false;
1832       foreach ( QString material, materials ) 
1833       {
1834         QAction* menAct = matMenu->addAction( material );
1835         connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) );
1836         signalMapper->setMapping( menAct, material );
1837         menAct->setCheckable( true );
1838         // Set checked if this material is current 
1839         Material_Model aModel;
1840         aModel.fromResources( material );
1841         if ( !found && aModel.toProperties() == curModel ) {
1842           menAct->setChecked( true );
1843           found = true;
1844         }
1845       }
1846       matMenu->insertAction( matMenu->addSeparator(), action(  GEOMOp::OpPredefMaterCustom ) );
1847       matMenu->insertSeparator( action(  GEOMOp::OpPredefMaterCustom ) );
1848       connect( signalMapper, SIGNAL( mapped( const QString & ) ),
1849                  this, SLOT( OnSetMaterial( const QString & ) ) );
1850       act->setMenu( matMenu );
1851     }
1852   }
1853   //Set name
1854   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1855     Handle(SALOME_InteractiveObject) io = lst.First();
1856     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1857     _PTR(Study) study = appStudy->studyDS();
1858     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1859     if ( obj ) {
1860       QString aName = QString( obj->GetName().c_str() );
1861       aName.remove( QRegExp("\\s+$") );
1862       title = aName;
1863     }
1864   }
1865 }
1866
1867 void GeometryGUI::OnSetMaterial(const QString& theName)
1868 {
1869   OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) );
1870 }
1871
1872
1873 void GeometryGUI::createPreferences()
1874 {
1875   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1876
1877   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1878   setPreferenceProperty( genGroup, "columns", 2 );
1879
1880   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1881                                 LightApp_Preferences::Selector,
1882                                 "Geometry", "display_mode" );
1883
1884   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1885                  LightApp_Preferences::Color, "Geometry", "shading_color" );
1886
1887   addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
1888                  LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
1889
1890   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1891                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1892
1893   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1894                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1895
1896   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1897                  LightApp_Preferences::Color, "Geometry", "line_color" );
1898
1899   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1900                  LightApp_Preferences::Color, "Geometry", "point_color" );
1901
1902   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1903                  LightApp_Preferences::Color, "Geometry", "isos_color" );
1904
1905   addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
1906                  LightApp_Preferences::Color, "Geometry", "toplevel_color" );
1907
1908   int top_lev_dm = addPreference( tr( "PREF_TOPLEVEL_DM" ), genGroup,
1909                       LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
1910
1911   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1912                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1913
1914   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1915                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1916
1917   addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup,
1918                  LightApp_Preferences::Bool, "Geometry", "predef_materials" );
1919
1920   int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
1921                                 LightApp_Preferences::Selector,
1922                                 "Geometry", "material" );
1923
1924   addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
1925                  LightApp_Preferences::Color, "Geometry", "editgroup_color" );
1926
1927   const int nb = 4;
1928   int wd[nb];
1929   int iter=0;
1930
1931   wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
1932                               LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
1933
1934   wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
1935                               LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
1936
1937   wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
1938                                      LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
1939
1940   wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
1941                               LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
1942
1943   for (int i = 0; i < nb; i++) {
1944     setPreferenceProperty( wd[i], "min", 1 );
1945     setPreferenceProperty( wd[i], "max", 5 );
1946   }
1947  
1948   int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
1949   setPreferenceProperty( isoGroup, "columns", 2 );
1950   int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
1951                                   LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" );
1952   setPreferenceProperty( isoU, "min", 0 );
1953   setPreferenceProperty( isoU, "max", 100000 );
1954   int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup,
1955                                  LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" );
1956   setPreferenceProperty( isoV, "min", 0 );
1957   setPreferenceProperty( isoV, "max", 100000 );
1958
1959   // Quantities with individual precision settings
1960   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1961   setPreferenceProperty( precGroup, "columns", 2 );
1962
1963   const int nbQuantities = 8;
1964   int prec[nbQuantities], ii = 0;
1965   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1966                               LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1967   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1968                               LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1969   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1970                               LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1971   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1972                               LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1973   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1974                               LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1975   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1976                               LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1977   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1978                               LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1979   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1980                               LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1981
1982   // Set property for precision value for spinboxes
1983   for ( ii = 0; ii < nbQuantities; ii++ ){
1984     setPreferenceProperty( prec[ii], "min", -14 );
1985     setPreferenceProperty( prec[ii], "max", 14 );
1986     setPreferenceProperty( prec[ii], "precision", 2 );
1987   }
1988
1989   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1990   setPreferenceProperty( VertexGroup, "columns", 2 );
1991
1992   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1993                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1994
1995   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1996                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1997
1998   // Set property for default display mode
1999   QStringList aModesList;
2000   aModesList.append( tr("MEN_WIREFRAME") );
2001   aModesList.append( tr("MEN_SHADING") );
2002   aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2003
2004   QList<QVariant> anIndexesList;
2005   anIndexesList.append(0);
2006   anIndexesList.append(1);
2007   anIndexesList.append(2);
2008
2009   setPreferenceProperty( dispmode, "strings", aModesList );
2010   setPreferenceProperty( dispmode, "indexes", anIndexesList );
2011
2012   // Set property for top level display mode
2013   QStringList aTopModesList;
2014   aTopModesList.append( tr("MEN_SHOW_ADD_WACTOR") );
2015   aTopModesList.append( tr("MEN_KEEP_CURRENT_DM") );
2016   aTopModesList.append( tr("MEN_WIREFRAME") );
2017   aTopModesList.append( tr("MEN_SHADING") );
2018   aTopModesList.append( tr("MEN_SHADING_WITH_EDGES") );
2019
2020   QList<QVariant> aTopIndexesList;
2021   aTopIndexesList.append(0);
2022   aTopIndexesList.append(1);
2023   aTopIndexesList.append(2);
2024   aTopIndexesList.append(3);
2025   aTopIndexesList.append(4);
2026
2027   setPreferenceProperty( top_lev_dm, "strings", aTopModesList );
2028   setPreferenceProperty( top_lev_dm, "indexes", aTopIndexesList );
2029
2030   // Set property for step value for spinboxes
2031   setPreferenceProperty( step, "min", 1 );
2032   setPreferenceProperty( step, "max", 10000 );
2033   setPreferenceProperty( step, "precision", 3 );
2034
2035   // Set property for deflection value for spinboxes
2036   setPreferenceProperty( defl, "min", GEOM::minDeflection() );
2037   setPreferenceProperty( defl, "max", 1.0 );
2038   setPreferenceProperty( defl, "step", 1.0e-04 );
2039   setPreferenceProperty( defl, "precision", 6 );
2040
2041   // Set property for default material
2042   setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() );
2043   
2044   // Set property vertex marker type
2045   QList<QVariant> aMarkerTypeIndicesList;
2046   QList<QVariant> aMarkerTypeIconsList;
2047
2048   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2049   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
2050     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
2051     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
2052     aMarkerTypeIndicesList << (i-1);
2053     aMarkerTypeIconsList << pixmap;
2054   }
2055
2056   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
2057   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
2058
2059   // Set property for vertex marker scale
2060   QList<QVariant> aMarkerScaleIndicesList;
2061   QStringList     aMarkerScaleValuesList;
2062
2063   for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
2064     aMarkerScaleIndicesList << iii;
2065     aMarkerScaleValuesList  << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
2066   }
2067
2068   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
2069   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
2070
2071   int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
2072   setPreferenceProperty( originGroup, "columns", 2 );
2073
2074   int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
2075                                          LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
2076   setPreferenceProperty( baseVectorsLength, "min", 0.01 );
2077   setPreferenceProperty( baseVectorsLength, "max", 1000 );
2078
2079   addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
2080                  LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
2081
2082   int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
2083   setPreferenceProperty( operationsGroup, "columns", 2 );
2084
2085   addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
2086                  LightApp_Preferences::Bool, "Geometry", "geom_preview" );
2087 }
2088
2089 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
2090 {
2091   if (section == "Geometry") {
2092     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
2093     if (param == QString("SettingsGeomStep")) {
2094       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
2095       EmitSignalDefaultStepValueChanged(spin_step);
2096     }
2097     else if (param == QString("toplevel_color")) {
2098       QColor c = aResourceMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
2099       GEOM_AISShape::setTopLevelColor(SalomeApp_Tools::color(c));
2100     }
2101     else if (param == QString("toplevel_dm")) {
2102       GEOM_AISShape::setTopLevelDisplayMode((GEOM_AISShape::TopLevelDispMode)aResourceMgr->integerValue("Geometry", "toplevel_dm", 0));
2103     }
2104   }
2105 }
2106
2107 LightApp_Displayer* GeometryGUI::displayer()
2108 {
2109   if ( !myDisplayer )
2110     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
2111   return myDisplayer;
2112 }
2113
2114 void GeometryGUI::setLocalSelectionMode(const int mode)
2115 {
2116   myLocalSelectionMode = mode;
2117 }
2118
2119 int GeometryGUI::getLocalSelectionMode() const
2120 {
2121   return myLocalSelectionMode;
2122 }
2123
2124 const char gSeparator = '_'; // character used to separate parameter names
2125 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
2126
2127 /*!
2128  * \brief Store visual parameters
2129  *
2130  * This method is called just before the study document is saved.
2131  * Store visual parameters in AttributeParameter attribute(s)
2132  */
2133 void GeometryGUI::storeVisualParameters (int savePoint)
2134 {
2135   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2136   if ( !appStudy || !appStudy->studyDS() )
2137     return;
2138   _PTR(Study) studyDS = appStudy->studyDS();
2139
2140   // componentName is used for encoding of entries when storing them in IParameters
2141   std::string componentName = myComponentGeom->ComponentDataType();
2142   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2143   //if (!aSComponent) return;
2144
2145   // IParameters
2146   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2147                                                              componentName.c_str(),
2148                                                              savePoint);
2149   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2150
2151   QList<SUIT_ViewManager*> lst;
2152   QList<SUIT_ViewManager*>::Iterator it;
2153
2154   // main cycle to store parameters of displayed objects
2155   lst.clear();
2156   getApp()->viewManagers(lst);
2157   for (it = lst.begin(); it != lst.end(); it++) {
2158     SUIT_ViewManager* vman = *it;
2159     QString vType = vman->getType();
2160     int aMgrId = vman->getGlobalId();
2161     // saving VTK actors properties
2162     QVector<SUIT_ViewWindow*> views = vman->getViews();
2163     for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
2164       const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
2165       ObjMap::ConstIterator o_it = anObjects.begin();
2166       for (; o_it != anObjects.end(); o_it++) {
2167         const PropMap aProps = o_it.value();
2168
2169         //Check that object exists in the study
2170         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
2171         if ( !obj || !(aProps.count() > 0))
2172           continue;
2173         // entry is "encoded" = it does NOT contain component adress, since it is a
2174         // subject to change on next component loading
2175
2176         std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
2177
2178         _PTR(GenericAttribute) anAttr;
2179         if (!obj->FindAttribute(anAttr, "AttributeIOR"))
2180           continue;
2181
2182         QString param, occParam = vType;
2183         occParam += GEOM::sectionSeparator();
2184         occParam += QString::number(aMgrId);
2185         occParam += GEOM::sectionSeparator();
2186
2187         if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) {
2188           param = occParam + GEOM::propertyName( GEOM::Visibility );
2189           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off");
2190         }
2191
2192         if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) {
2193           param = occParam + GEOM::propertyName( GEOM::DisplayMode );
2194           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString());
2195         }
2196
2197         if (aProps.contains(GEOM::propertyName( GEOM::Color ))) {
2198           QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value<QColor>();
2199           QStringList val;
2200           val << QString::number(c.redF());
2201           val << QString::number(c.greenF());
2202           val << QString::number(c.blueF());
2203           param = occParam + GEOM::propertyName( GEOM::Color );
2204           ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString());
2205         }
2206
2207         if (vType == SVTK_Viewer::Type()) {
2208           if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) {
2209             param = occParam + GEOM::propertyName( GEOM::Opacity );
2210             ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString());
2211           }
2212         } else if (vType == SOCC_Viewer::Type()) {
2213           if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) {
2214             param = occParam + GEOM::propertyName( GEOM::Transparency );
2215             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString());
2216           }
2217
2218           if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) {
2219             param = occParam + GEOM::propertyName( GEOM::TopLevel );
2220             ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString());
2221           }
2222         }
2223
2224         if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) {
2225           param = occParam + GEOM::propertyName( GEOM::NbIsos );
2226           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString());
2227         }
2228
2229         if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) {
2230           param = occParam + GEOM::propertyName( GEOM::EdgesDirection );
2231           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString());
2232         }
2233
2234         if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) {
2235           param = occParam + GEOM::propertyName( GEOM::Deflection );
2236           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString());
2237         }
2238
2239         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
2240         if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) {
2241           param = occParam + GEOM::propertyName( GEOM::PointMarker );
2242           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString());
2243         }
2244
2245         if (aProps.contains(GEOM::propertyName( GEOM::Material ))) {
2246           param = occParam + GEOM::propertyName( GEOM::Material );
2247           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString());
2248         }
2249
2250         if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) {
2251              param = occParam + GEOM::propertyName( GEOM::LineWidth );
2252            ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString());
2253         }
2254
2255         if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) {
2256           param = occParam + GEOM::propertyName( GEOM::IsosWidth );
2257           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
2258         }
2259       } // object iterator
2260     } // for (views)
2261   } // for (viewManagers)
2262 }
2263
2264 /*!
2265  * \brief Restore visual parameters
2266  *
2267  * This method is called after the study document is opened.
2268  * Restore visual parameters from AttributeParameter attribute(s)
2269  */
2270 void GeometryGUI::restoreVisualParameters (int savePoint)
2271 {
2272   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2273   if (!appStudy || !appStudy->studyDS())
2274     return;
2275   _PTR(Study) studyDS = appStudy->studyDS();
2276
2277   // componentName is used for encoding of entries when storing them in IParameters
2278   std::string componentName = myComponentGeom->ComponentDataType();
2279   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2280   //if (!aSComponent) return;
2281
2282   // IParameters
2283   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2284                                                              componentName.c_str(),
2285                                                              savePoint);
2286   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2287
2288   std::vector<std::string> entries = ip->getEntries();
2289
2290   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
2291   {
2292     // entry is a normal entry - it should be "decoded" (setting base adress of component)
2293     QString entry (ip->decodeEntry(*entIt).c_str());
2294
2295     // Check that the entry corresponds to a real object in the Study
2296     // as the object may be deleted or modified after the visual state is saved.
2297     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
2298     if (!so) continue; //Skip the not existent entry
2299
2300     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
2301     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
2302
2303     std::vector<std::string>::iterator namesIt = paramNames.begin();
2304     std::vector<std::string>::iterator valuesIt = paramValues.begin();
2305
2306     // actors are stored in a map after displaying of them for
2307     // quicker access in the future: map < viewID to actor >
2308     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
2309     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2310
2311     QString viewerTypStr;
2312     QString viewIndexStr;
2313     int viewIndex;
2314     QVector<PropMap> aListOfMap;
2315
2316     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2317     {
2318       // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
2319       // '_' is used as separator and should not be used in viewer type or parameter names.
2320       QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
2321       if (lst.size() != 3)
2322         continue;
2323
2324       viewerTypStr = lst[0];
2325       viewIndexStr = lst[1];
2326       QString paramNameStr = lst[2];
2327
2328       bool ok;
2329       viewIndex = viewIndexStr.toUInt(&ok);
2330       if (!ok) // bad conversion of view index to integer
2331         continue;
2332
2333       if ((viewIndex + 1) > aListOfMap.count()) {
2334         aListOfMap.resize(viewIndex + 1);
2335       }
2336
2337       QString val((*valuesIt).c_str());
2338       if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) {
2339         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On");
2340       } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) {
2341         aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble());
2342       } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) {
2343         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() );
2344       } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) {
2345         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1");
2346       } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) {
2347         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt());
2348       } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) {
2349         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val);
2350       } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) {
2351         QStringList rgb = val.split(GEOM::subSectionSeparator());
2352         if (rgb.count() == 3) {
2353           QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble());
2354           aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c);
2355         }
2356       } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) {
2357         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1");
2358       } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) {
2359         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble());
2360       } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) {
2361         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val);
2362       } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) {
2363         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val);
2364       } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) {
2365         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
2366       } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
2367         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
2368       }
2369     } // for names/parameters iterator
2370
2371     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
2372
2373     for (int index = 0; index < aListOfMap.count(); index++) {
2374
2375       appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
2376
2377       //Get Visibility property of the current PropMap
2378       if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
2379         SUIT_ViewManager* vman = lst.at(index);
2380         SUIT_ViewModel* vmodel = vman->getViewModel();
2381         displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
2382       }
2383     }
2384   } // for entries iterator
2385
2386   // update all VTK and OCC views
2387   QList<SUIT_ViewManager*> lst;
2388   getApp()->viewManagers(lst);
2389   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2390     SUIT_ViewModel* vmodel = (*it)->getViewModel();
2391     if (!vmodel)
2392       continue;
2393     if (vmodel->getType() == SVTK_Viewer::Type()) {
2394       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2395       vtkView->getRenderer()->ResetCameraClippingRange();
2396       vtkView->Repaint();
2397     }
2398     else if (vmodel->getType() == SOCC_Viewer::Type()) {
2399       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2400       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2401       if (occVMod)
2402         occVMod->Repaint();
2403     }
2404   }
2405 }
2406
2407 void GeometryGUI::onViewAboutToShow()
2408 {
2409   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2410   QAction* a = action( GEOMOp::OpSwitchVectors );
2411   if ( window ) {
2412     a->setEnabled(true);
2413     bool vmode = window->property("VectorsMode").toBool();
2414     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2415   } else {
2416     a->setText ( tr("MEN_VECTOR_MODE_ON") );
2417     a->setEnabled(false);
2418   }
2419 }
2420
2421 /*!
2422   \brief Return action by id
2423   \param id identifier of the action
2424   \return action
2425 */
2426 QAction* GeometryGUI::getAction(const int id) {
2427   return action(id);
2428 }
2429
2430 /*!
2431   \brief GEOM module message handler
2432
2433   This method can be re-implemented in the subclasses.
2434   This is a GEOM module message handler.
2435
2436   \param msg the message received.
2437 */
2438 void GeometryGUI::message(const QString& msg)
2439 {
2440   // dispatch message
2441   QStringList data = msg.split("/");
2442   const int nbStrings = data.count();
2443
2444   if (nbStrings > 0) {
2445     if (data[0] == "modified") {
2446       // get mesh entry
2447       QString anIOR = nbStrings > 1 ? data[1] : QString();
2448
2449       if ( anIOR.isEmpty() ) {
2450         return;
2451       }
2452
2453       // Get the geom object.
2454       GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
2455
2456       // Clear the shape buffer
2457       GeometryGUI::ClearShapeBuffer (anObj);
2458     }
2459   }
2460 }
2461
2462 /*!
2463   \brief Clears the shape buffer.
2464
2465   This is a static method. It clears the shape buffer.
2466
2467   \param theObj the object
2468 */
2469 void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
2470 {
2471   if ( CORBA::is_nil( theObj ) )
2472     return;
2473
2474   CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
2475   TCollection_AsciiString asciiIOR( (char *)IOR.in() );
2476   GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2477
2478   SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
2479
2480   if (!aManager)
2481     return;
2482
2483   _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
2484
2485   if ( !aStudy )
2486     return;
2487
2488   _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
2489   if ( !aSObj )
2490     return;
2491
2492   _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
2493   for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
2494     _PTR(GenericAttribute) anAttr;
2495     if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
2496       _PTR(AttributeIOR) anIOR ( anAttr );
2497       TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
2498       GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
2499     }
2500   }
2501 }
2502
2503 /*!
2504   \brief Returns the object from IOR.
2505
2506   This is a static method. It returns the object from its IOR.
2507
2508   \param IOR object IOR
2509   \return GEOM object.
2510 */
2511 GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
2512 {
2513   GEOM::GEOM_Object_var geomObj;
2514   if ( !IOR.isEmpty() ) {
2515     CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
2516       ( IOR.toLatin1().constData() );
2517     if ( !CORBA::is_nil( corbaObj ) )
2518       geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
2519   }
2520   return geomObj._retn();
2521 }
2522
2523 /*!
2524   \brief Returns IOR of the object.
2525
2526   This is a static method. It returns the object's IOR.
2527
2528   \param object the GEOM object.
2529   \return object's IOR.
2530 */
2531 QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
2532 {
2533   QString IOR;
2534   if ( !CORBA::is_nil( object ) ) {
2535     CORBA::String_var anIOR =
2536       SalomeApp_Application::orb()->object_to_string( object );
2537     IOR = anIOR.in();
2538   }
2539   return IOR;
2540 }
2541
2542 /*!
2543   \brief Check if this object is can't be renamed in place
2544
2545   This method can be re-implemented in the subclasses.
2546   Return true in case if object isn't reference or component (module root).
2547
2548   \param entry column id
2549   \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
2550 */
2551 bool GeometryGUI::renameAllowed( const QString& entry) const {
2552
2553   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
2554   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2555   SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
2556
2557   return (app && appStudy && obj && !appStudy->isComponent(entry) && !obj->isReference());
2558 }
2559
2560 /*!
2561   Rename object by entry.
2562   \param entry entry of the object
2563   \param name new name of the object
2564   \brief Return \c true if rename operation finished successfully, \c false otherwise.
2565 */
2566 bool GeometryGUI::renameObject( const QString& entry, const QString& name)
2567 {
2568   bool result = false;
2569
2570   SalomeApp_Application* app =
2571     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2572   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2573
2574   if (!appStudy)
2575     return result;
2576
2577   _PTR(Study) aStudy = appStudy->studyDS();
2578
2579   if (!aStudy)
2580     return result;
2581
2582   bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
2583   if ( aLocked ) {
2584     SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
2585     return result;
2586   }
2587
2588   _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2589   _PTR(GenericAttribute) anAttr;
2590   if ( obj ) {
2591     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2592       _PTR(AttributeName) aName (anAttr);
2593
2594       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2595       if (!CORBA::is_nil(anObj)) {
2596         aName->SetValue( name.toLatin1().data() ); // rename the SObject
2597         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
2598         result = true;
2599       }
2600     }
2601   }
2602   return result;
2603 }
2604
2605 void GeometryGUI::updateMaterials()
2606 {
2607   LightApp_Preferences* pref = preferences();
2608   if ( pref ) {
2609     QStringList materials = Material_ResourceMgr::resourceMgr()->materials();
2610     QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" );
2611     if ( !materials.contains( currentMaterial ) )
2612       // user material set as default in the preferences, might be removed
2613       SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) );
2614
2615     QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true );
2616     if ( prefItem ) {
2617       setPreferenceProperty( prefItem->id(),
2618                              "strings", materials );
2619       prefItem->retrieve();
2620     }
2621   }
2622 }