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