]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI.cxx
Salome HOME
eb4aa6d772f0bf039af3e7b294126c7707d9b4f5
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
1 // Copyright (C) 2007-2011  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     libName = "GEOMToolsGUI";
430     break;
431   case GEOMOp::OpDisplayMode:        // MENU VIEW - WIREFRAME/SHADING
432   case GEOMOp::OpShowAll:            // MENU VIEW - SHOW ALL
433   case GEOMOp::OpShowOnly:           // MENU VIEW - DISPLAY ONLY
434   case GEOMOp::OpHideAll:            // MENU VIEW - ERASE ALL
435   case GEOMOp::OpHide:               // MENU VIEW - ERASE
436   case GEOMOp::OpShow:               // MENU VIEW - DISPLAY
437   case GEOMOp::OpSwitchVectors:      // MENU VIEW - VECTOR MODE
438   case GEOMOp::OpWireframe:          // POPUP MENU - WIREFRAME
439   case GEOMOp::OpShading:            // POPUP MENU - SHADING
440   case GEOMOp::OpShadingWithEdges:   // POPUP MENU - SHADING WITH EDGES
441   case GEOMOp::OpTexture:            // POPUP MENU - TEXTURE
442   case GEOMOp::OpVectors:            // POPUP MENU - VECTORS
443     libName = "DisplayGUI";
444     break;
445   case GEOMOp::OpPoint:              // MENU BASIC - POINT
446   case GEOMOp::OpLine:               // MENU BASIC - LINE
447   case GEOMOp::OpCircle:             // MENU BASIC - CIRCLE
448   case GEOMOp::OpEllipse:            // MENU BASIC - ELLIPSE
449   case GEOMOp::OpArc:                // MENU BASIC - ARC
450   case GEOMOp::OpVector:             // MENU BASIC - VECTOR
451   case GEOMOp::OpPlane:              // MENU BASIC - PLANE
452   case GEOMOp::OpCurve:              // MENU BASIC - CURVE
453   case GEOMOp::OpLCS:                // MENU BASIC - LOCAL COORDINATE SYSTEM
454     libName = "BasicGUI";
455     break;
456   case GEOMOp::OpBox:                // MENU PRIMITIVE - BOX
457   case GEOMOp::OpCylinder:           // MENU PRIMITIVE - CYLINDER
458   case GEOMOp::OpSphere:             // MENU PRIMITIVE - SPHERE
459   case GEOMOp::OpTorus:              // MENU PRIMITIVE - TORUS
460   case GEOMOp::OpCone:               // MENU PRIMITIVE - CONE
461   case GEOMOp::OpRectangle:          // MENU PRIMITIVE - FACE
462   case GEOMOp::OpDisk:               // MENU PRIMITIVE - DISK
463     libName = "PrimitiveGUI";
464     break;
465   case GEOMOp::OpPrism:              // MENU GENERATION - PRISM
466   case GEOMOp::OpRevolution:         // MENU GENERATION - REVOLUTION
467   case GEOMOp::OpFilling:            // MENU GENERATION - FILLING
468   case GEOMOp::OpPipe:               // MENU GENERATION - PIPE
469     libName = "GenerationGUI";
470     break;
471   case GEOMOp::Op2dSketcher:         // MENU ENTITY - SKETCHER
472   case GEOMOp::Op3dSketcher:         // MENU ENTITY - 3D SKETCHER
473   case GEOMOp::OpExplode:            // MENU ENTITY - EXPLODE
474 #ifdef WITH_OPENCV
475   case GEOMOp::OpFeatureDetect:      // MENU ENTITY - FEATURE DETECTION
476 #endif
477   case GEOMOp::OpPictureImport:      // MENU ENTITY - IMPORT PICTURE IN VIEWER
478     libName = "EntityGUI";
479     break;
480   case GEOMOp::OpEdge:               // MENU BUILD - EDGE
481   case GEOMOp::OpWire:               // MENU BUILD - WIRE
482   case GEOMOp::OpFace:               // MENU BUILD - FACE
483   case GEOMOp::OpShell:              // MENU BUILD - SHELL
484   case GEOMOp::OpSolid:              // MENU BUILD - SOLID
485   case GEOMOp::OpCompound:           // MENU BUILD - COMPUND
486     libName = "BuildGUI";
487     break;
488   case GEOMOp::OpFuse:               // MENU BOOLEAN - FUSE
489   case GEOMOp::OpCommon:             // MENU BOOLEAN - COMMON
490   case GEOMOp::OpCut:                // MENU BOOLEAN - CUT
491   case GEOMOp::OpSection:            // MENU BOOLEAN - SECTION
492     libName = "BooleanGUI";
493     break;
494   case GEOMOp::OpTranslate:          // MENU TRANSFORMATION - TRANSLATION
495   case GEOMOp::OpRotate:             // MENU TRANSFORMATION - ROTATION
496   case GEOMOp::OpChangeLoc:          // MENU TRANSFORMATION - LOCATION
497   case GEOMOp::OpMirror:             // MENU TRANSFORMATION - MIRROR
498   case GEOMOp::OpScale:              // MENU TRANSFORMATION - SCALE
499   case GEOMOp::OpOffset:             // MENU TRANSFORMATION - OFFSET
500   case GEOMOp::OpProjection:         // MENU TRANSFORMATION - PROJECTION
501   case GEOMOp::OpMultiTranslate:     // MENU TRANSFORMATION - MULTI-TRANSLATION
502   case GEOMOp::OpMultiRotate:        // MENU TRANSFORMATION - MULTI-ROTATION
503   case GEOMOp::OpReimport:           // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
504     libName = "TransformationGUI";
505     break;
506   case GEOMOp::OpPartition:          // MENU OPERATION - PARTITION
507   case GEOMOp::OpArchimede:          // MENU OPERATION - ARCHIMEDE
508   case GEOMOp::OpFillet3d:           // MENU OPERATION - FILLET
509   case GEOMOp::OpChamfer:            // MENU OPERATION - CHAMFER
510   case GEOMOp::OpClipping:           // MENU OPERATION - CLIPPING RANGE
511   case GEOMOp::OpShapesOnShape:      // MENU OPERATION - GET SHAPES ON SHAPE
512   case GEOMOp::OpFillet2d:           // MENU OPERATION - FILLET 2D
513   case GEOMOp::OpFillet1d:           // MENU OPERATION - FILLET 1D
514   case GEOMOp::OpSharedShapes:       // MENU OPERATION - GET SHARED SHAPES
515   case GEOMOp::OpExtrudedBoss:       // MENU OPERATION - EXTRUDED BOSS
516   case GEOMOp::OpExtrudedCut:        // MENU OPERATION - EXTRUDED CUT
517     libName = "OperationGUI";
518     break;
519   case GEOMOp::OpSewing:             // MENU REPAIR - SEWING
520   case GEOMOp::OpSuppressFaces:      // MENU REPAIR - SUPPRESS FACES
521   case GEOMOp::OpSuppressHoles:      // MENU REPAIR - SUPPRESS HOLE
522   case GEOMOp::OpShapeProcess:       // MENU REPAIR - SHAPE PROCESSING
523   case GEOMOp::OpCloseContour:       // MENU REPAIR - CLOSE CONTOUR
524   case GEOMOp::OpRemoveIntWires:     // MENU REPAIR - REMOVE INTERNAL WIRES
525   case GEOMOp::OpAddPointOnEdge:     // MENU REPAIR - ADD POINT ON EDGE
526   case GEOMOp::OpFreeBoundaries:     // MENU MEASURE - FREE BOUNDARIES
527   case GEOMOp::OpFreeFaces:          // MENU MEASURE - FREE FACES
528   case GEOMOp::OpOrientation:        // MENU REPAIR - CHANGE ORIENTATION
529   case GEOMOp::OpGlueFaces:          // MENU REPAIR - GLUE FACES
530   case GEOMOp::OpGlueEdges:          // MENU REPAIR - GLUE EDGES
531   case GEOMOp::OpLimitTolerance:     // MENU REPAIR - LIMIT TOLERANCE
532   case GEOMOp::OpRemoveExtraEdges:   // MENU REPAIR - REMOVE EXTRA EDGES
533     libName = "RepairGUI";
534     break;
535   case GEOMOp::OpProperties:         // MENU MEASURE - PROPERTIES
536   case GEOMOp::OpCenterMass:         // MENU MEASURE - CDG
537   case GEOMOp::OpInertia:            // MENU MEASURE - INERTIA
538   case GEOMOp::OpNormale:            // MENU MEASURE - NORMALE
539   case GEOMOp::OpBoundingBox:        // MENU MEASURE - BOUNDING BOX
540   case GEOMOp::OpMinDistance:        // MENU MEASURE - MIN DISTANCE
541   case GEOMOp::OpAngle:              // MENU MEASURE - ANGLE
542   case GEOMOp::OpTolerance:          // MENU MEASURE - TOLERANCE
543   case GEOMOp::OpWhatIs:             // MENU MEASURE - WHATIS
544   case GEOMOp::OpCheckShape:         // MENU MEASURE - CHECK
545   case GEOMOp::OpCheckCompound:      // MENU MEASURE - CHECK COMPOUND OF BLOCKS
546   case GEOMOp::OpPointCoordinates:   // MENU MEASURE - POINT COORDINATES
547   case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
548     libName = "MeasureGUI";
549     break;
550   case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
551   case GEOMOp::OpGroupCreatePopup:   // POPUP MENU - CREATE GROUP
552   case GEOMOp::OpGroupEdit:          // MENU GROUP - EDIT
553     libName = "GroupGUI";
554     break;
555   case GEOMOp::OpHexaSolid:          // MENU BLOCKS - HEXAHEDRAL SOLID
556   case GEOMOp::OpMultiTransform:     // MENU BLOCKS - MULTI-TRANSFORMATION
557   case GEOMOp::OpQuadFace:           // MENU BLOCKS - QUADRANGLE FACE
558   case GEOMOp::OpPropagate:          // MENU BLOCKS - PROPAGATE
559   case GEOMOp::OpExplodeBlock:       // MENU BLOCKS - EXPLODE ON BLOCKS
560     libName = "BlocksGUI";
561     break;
562   case GEOMOp::OpAdvancedNoOp:       // NO OPERATION (advanced operations base)
563   case GEOMOp::OpPipeTShape:         // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
564 //   case GEOMOp::OpPipeTShapeGroups:     // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
565     //@@ 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 @@//
566     libName = "AdvancedGUI";
567     break;
568   default:
569     break;
570   }
571
572   GEOMGUI* library = 0;
573   if ( !libName.isEmpty() ) {
574 #ifndef WNT
575     libName = QString( "lib" ) + libName + ".so";
576 #else
577     libName = libName + ".dll";
578 #endif
579     library = getLibrary( libName );
580   }
581
582   // call method of corresponding GUI library
583   if ( library ) {
584     library->OnGUIEvent( id, desk );
585     
586     // Update a list of materials for "Preferences" dialog
587     if ( id == GEOMOp::OpMaterialProperties ) {
588       LightApp_Preferences* pref = preferences();
589       if ( pref ) {
590         Material_ResourceMgr aMatResMgr;
591         QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames();
592         setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_FRONT_MATERIAL" ), true )->id(),
593                                "strings",
594                                aPerfMatNames );
595         setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_BACK_MATERIAL" ), true )->id(),
596                                "strings",
597                                aPerfMatNames );
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::OpDisplayMode,      "SHADING" );
834   createGeomAction( GEOMOp::OpShowAll,          "DISPLAY_ALL" );
835   createGeomAction( GEOMOp::OpHideAll,          "ERASE_ALL" );
836   createGeomAction( GEOMOp::OpShow,             "DISPLAY" );
837   createGeomAction( GEOMOp::OpSwitchVectors,    "VECTOR_MODE");
838   createGeomAction( GEOMOp::OpSelectVertex,     "VERTEX_SEL_ONLY" ,"", 0, true );
839   createGeomAction( GEOMOp::OpSelectEdge,       "EDGE_SEL_ONLY", "", 0, true );
840   createGeomAction( GEOMOp::OpSelectWire,       "WIRE_SEL_ONLY", "",  0, true );
841   createGeomAction( GEOMOp::OpSelectFace,       "FACE_SEL_ONLY", "", 0, true );
842   createGeomAction( GEOMOp::OpSelectShell,      "SHELL_SEL_ONLY", "",  0, true );
843   createGeomAction( GEOMOp::OpSelectSolid,      "SOLID_SEL_ONLY", "", 0, true );
844   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
845   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
846   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
847   createGeomAction( GEOMOp::OpHide,             "ERASE" );
848
849   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
850   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
851   createGeomAction( GEOMOp::OpShadingWithEdges, "POP_SHADING_WITH_EDGES", "", 0, true );
852   createGeomAction( GEOMOp::OpTexture,          "POP_TEXTURE", "", 0, true );
853   createGeomAction( GEOMOp::OpEdgeWidth,        "EDGE_WIDTH");
854   createGeomAction( GEOMOp::OpIsosWidth,        "ISOS_WIDTH");
855   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
856   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
857   createGeomAction( GEOMOp::OpColor,            "POP_COLOR" );
858   createGeomAction( GEOMOp::OpSetTexture,       "POP_SETTEXTURE" );
859   createGeomAction( GEOMOp::OpTransparency,     "POP_TRANSPARENCY" );
860   createGeomAction( GEOMOp::OpIsos,             "POP_ISOS" );
861   createGeomAction( GEOMOp::OpAutoColor,        "POP_AUTO_COLOR" );
862   createGeomAction( GEOMOp::OpNoAutoColor,      "POP_DISABLE_AUTO_COLOR" );
863   createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
864   createGeomAction( GEOMOp::OpShowChildren,     "POP_SHOW_CHILDREN" );
865   createGeomAction( GEOMOp::OpHideChildren,     "POP_HIDE_CHILDREN" );
866   createGeomAction( GEOMOp::OpUnpublishObject,  "POP_UNPUBLISH_OBJ" );
867   createGeomAction( GEOMOp::OpPublishObject,    "POP_PUBLISH_OBJ" );
868   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
869   createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" );
870
871   createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
872
873   // Create actions for increase/decrease transparency shortcuts
874   createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
875                     "Geometry:Increase transparency");
876   createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
877                     "Geometry:Decrease transparency");
878
879   // Create actions for increase/decrease number of isolines
880   createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
881                     "Geometry:Increase number of isolines");
882   createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
883                     "Geometry:Decrease number of isolines");
884
885 //   createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
886   //@@ 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 @@//
887
888   // ---- create menus --------------------------
889
890   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
891   createMenu( separator(),      fileId, 10 );
892   createMenu( GEOMOp::OpImport, fileId, 10 );
893   createMenu( GEOMOp::OpExport, fileId, 10 );
894   createMenu( separator(),      fileId, -1 );
895
896   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
897   createMenu( GEOMOp::OpDelete, editId, -1 );
898
899   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
900
901   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
902   createMenu( GEOMOp::OpPoint,   basicId, -1 );
903   createMenu( GEOMOp::OpLine,    basicId, -1 );
904   createMenu( GEOMOp::OpCircle,  basicId, -1 );
905   createMenu( GEOMOp::OpEllipse, basicId, -1 );
906   createMenu( GEOMOp::OpArc,     basicId, -1 );
907   createMenu( GEOMOp::OpCurve,   basicId, -1 );
908   createMenu( separator(),       basicId, -1 );
909   createMenu( GEOMOp::OpVector,  basicId, -1 );
910   createMenu( GEOMOp::OpPlane,   basicId, -1 );
911   createMenu( GEOMOp::OpLCS,     basicId, -1 );
912   createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
913
914   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
915   createMenu( GEOMOp::OpBox,       primId, -1 );
916   createMenu( GEOMOp::OpCylinder,  primId, -1 );
917   createMenu( GEOMOp::OpSphere,    primId, -1 );
918   createMenu( GEOMOp::OpTorus,     primId, -1 );
919   createMenu( GEOMOp::OpCone,      primId, -1 );
920   createMenu( GEOMOp::OpRectangle, primId, -1 );
921   createMenu( GEOMOp::OpDisk,      primId, -1 );
922
923   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
924   createMenu( GEOMOp::OpPrism,      genId, -1 );
925   createMenu( GEOMOp::OpRevolution, genId, -1 );
926   createMenu( GEOMOp::OpFilling,    genId, -1 );
927   createMenu( GEOMOp::OpPipe,       genId, -1 );
928
929   int advId = createMenu( tr( "MEN_ADVANCED" ), newEntId, -1 );
930   createMenu( GEOMOp::OpPipeTShape, advId, -1 );
931 //   createMenu( GEOMOp::OpPipeTShapeGroups, advId, -1 );
932   //@@ 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 @@//
933
934   createMenu( separator(), newEntId, -1 );
935
936   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
937   createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
938   createMenu( GEOMOp::OpGroupEdit,   groupId, -1 );
939
940   createMenu( separator(), newEntId, -1 );
941
942   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
943   createMenu( GEOMOp::OpQuadFace,  blocksId, -1 );
944   createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
945
946   createMenu( separator(),          newEntId, -1 );
947
948   createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
949   createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
950
951   createMenu( separator(),          newEntId, -1 );
952
953   createMenu( GEOMOp::OpExplode,    newEntId, -1 );
954
955   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
956   createMenu( GEOMOp::OpEdge,     buildId, -1 );
957   createMenu( GEOMOp::OpWire,     buildId, -1 );
958   createMenu( GEOMOp::OpFace,     buildId, -1 );
959   createMenu( GEOMOp::OpShell,    buildId, -1 );
960   createMenu( GEOMOp::OpSolid,    buildId, -1 );
961   createMenu( GEOMOp::OpCompound, buildId, -1 );
962   
963   createMenu( separator(),          newEntId, -1 );
964   
965   createMenu( GEOMOp::OpPictureImport, newEntId, -1 );
966 #ifdef WITH_OPENCV
967   createMenu( GEOMOp::OpFeatureDetect, newEntId, -1 );
968 #endif
969
970   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
971
972   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
973   createMenu( GEOMOp::OpFuse,    boolId, -1 );
974   createMenu( GEOMOp::OpCommon,  boolId, -1 );
975   createMenu( GEOMOp::OpCut,     boolId, -1 );
976   createMenu( GEOMOp::OpSection, boolId, -1 );
977
978   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
979   createMenu( GEOMOp::OpTranslate,      transId, -1 );
980   createMenu( GEOMOp::OpRotate,         transId, -1 );
981   createMenu( GEOMOp::OpChangeLoc,      transId, -1 );
982   createMenu( GEOMOp::OpMirror,         transId, -1 );
983   createMenu( GEOMOp::OpScale,          transId, -1 );
984   createMenu( GEOMOp::OpOffset,         transId, -1 );
985   createMenu( GEOMOp::OpProjection,     transId, -1 );
986   createMenu( separator(),              transId, -1 );
987   createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
988   createMenu( GEOMOp::OpMultiRotate,    transId, -1 );
989
990   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
991   createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
992   createMenu( GEOMOp::OpExplodeBlock,   blockId, -1 );
993   createMenu( GEOMOp::OpPropagate,      blockId, -1 );
994
995   createMenu( separator(), operId, -1 );
996
997   createMenu( GEOMOp::OpPartition,     operId, -1 );
998   createMenu( GEOMOp::OpArchimede,     operId, -1 );
999   createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
1000   createMenu( GEOMOp::OpSharedShapes,  operId, -1 );
1001
1002   createMenu( separator(), operId, -1 );
1003
1004   createMenu( GEOMOp::OpFillet1d,      operId, -1 );
1005   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
1006   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
1007   createMenu( GEOMOp::OpChamfer,       operId, -1 );
1008   createMenu( GEOMOp::OpExtrudedBoss,  operId, -1 );
1009   createMenu( GEOMOp::OpExtrudedCut,   operId, -1 );
1010   //createMenu( GEOMOp::OpClipping,      operId, -1 );
1011
1012   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
1013   createMenu( GEOMOp::OpShapeProcess,    repairId, -1 );
1014   createMenu( GEOMOp::OpSuppressFaces,   repairId, -1 );
1015   createMenu( GEOMOp::OpCloseContour,    repairId, -1 );
1016   createMenu( GEOMOp::OpRemoveIntWires,  repairId, -1 );
1017   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
1018   createMenu( GEOMOp::OpSewing,          repairId, -1 );
1019   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
1020   createMenu( GEOMOp::OpGlueEdges,       repairId, -1 );
1021   createMenu( GEOMOp::OpLimitTolerance,  repairId, -1 );
1022   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
1023   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
1024   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
1025   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
1026   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
1027
1028   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1029   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
1030   createMenu( GEOMOp::OpProperties,       measurId, -1 );
1031   createMenu( separator(),                measurId, -1 );
1032   createMenu( GEOMOp::OpCenterMass,       measurId, -1 );
1033   createMenu( GEOMOp::OpInertia,          measurId, -1 );
1034   createMenu( GEOMOp::OpNormale,          measurId, -1 );
1035   createMenu( separator(),                measurId, -1 );
1036   createMenu( GEOMOp::OpFreeBoundaries,   measurId, -1 );
1037   createMenu( GEOMOp::OpFreeFaces,        measurId, -1 );
1038   createMenu( separator(),                measurId, -1 );
1039
1040   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1041   createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
1042   createMenu( GEOMOp::OpMinDistance, dimId, -1 );
1043   createMenu( GEOMOp::OpAngle,       dimId, -1 );
1044
1045   createMenu( separator(),               measurId, -1 );
1046   createMenu( GEOMOp::OpTolerance,       measurId, -1 );
1047   createMenu( separator(),               measurId, -1 );
1048   createMenu( GEOMOp::OpWhatIs,          measurId, -1 );
1049   createMenu( GEOMOp::OpCheckShape,      measurId, -1 );
1050   createMenu( GEOMOp::OpCheckCompound,   measurId, -1 );
1051   createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
1052
1053 #ifdef _DEBUG_ // PAL16821
1054   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1055   createMenu( separator(),         toolsId, -1 );
1056   createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
1057 #endif
1058
1059   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1060   createMenu( separator(),       viewId, -1 );
1061
1062   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1063   createMenu( GEOMOp::OpDisplayMode,   dispmodeId, -1 );
1064   createMenu( separator(),             dispmodeId, -1 );
1065   createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
1066
1067   createMenu( separator(),       viewId, -1 );
1068   createMenu( GEOMOp::OpShowAll, viewId, -1 );
1069   createMenu( GEOMOp::OpHideAll, viewId, -1 );
1070   createMenu( separator(),       viewId, -1 );
1071   createMenu( GEOMOp::OpPublishObject, viewId, -1 );
1072   createMenu( separator(),       viewId, -1 );
1073
1074 /*
1075   PAL9111:
1076   because of these items are accessible through object browser and viewers
1077   we have removed they from main menu
1078
1079   createMenu( GEOMOp::OpShow, viewId, -1 );
1080   createMenu( GEOMOp::OpShowOnly, viewId, -1 );
1081   createMenu( GEOMOp::OpHide, viewId, -1 );
1082 */
1083
1084   // ---- create toolbars --------------------------
1085   
1086   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1087   createTool( GEOMOp::OpPoint,      basicTbId );
1088   createTool( GEOMOp::OpLine,       basicTbId );
1089   createTool( GEOMOp::OpCircle,     basicTbId );
1090   createTool( GEOMOp::OpEllipse,    basicTbId );
1091   createTool( GEOMOp::OpArc,        basicTbId );
1092   createTool( GEOMOp::OpCurve,      basicTbId );
1093   createTool( GEOMOp::OpVector,     basicTbId );
1094   createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
1095   createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
1096   createTool( GEOMOp::OpPlane,      basicTbId );
1097   createTool( GEOMOp::OpLCS,        basicTbId );
1098   createTool( GEOMOp::OpOriginAndVectors, basicTbId );
1099   
1100 //   int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
1101 //   createTool( GEOMOp::Op2dSketcher,  sketchTbId );
1102 //   createTool( GEOMOp::Op3dSketcher,  sketchTbId );
1103   
1104   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1105   createTool( GEOMOp::OpBox,        primTbId );
1106   createTool( GEOMOp::OpCylinder,   primTbId );
1107   createTool( GEOMOp::OpSphere,     primTbId );
1108   createTool( GEOMOp::OpTorus,      primTbId );
1109   createTool( GEOMOp::OpCone,       primTbId );
1110   createTool( GEOMOp::OpRectangle,  primTbId );
1111   createTool( GEOMOp::OpDisk,       primTbId );
1112   createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
1113   
1114 //   int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
1115 //   createTool( GEOMOp::OpPipeTShape, advancedTbId );
1116   
1117   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1118   createTool( GEOMOp::OpFuse,       boolTbId );
1119   createTool( GEOMOp::OpCommon,     boolTbId );
1120   createTool( GEOMOp::OpCut,        boolTbId );
1121   createTool( GEOMOp::OpSection,    boolTbId );
1122   
1123    int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1124   createTool( GEOMOp::OpPrism,      genTbId );
1125   createTool( GEOMOp::OpRevolution, genTbId );
1126   createTool( GEOMOp::OpFilling,    genTbId );
1127   createTool( GEOMOp::OpPipe,       genTbId );
1128   
1129   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1130   createTool( GEOMOp::OpTranslate,      transTbId );
1131   createTool( GEOMOp::OpRotate,         transTbId );
1132   createTool( GEOMOp::OpChangeLoc,      transTbId );
1133   createTool( GEOMOp::OpMirror,         transTbId );
1134   createTool( GEOMOp::OpScale,          transTbId );
1135   createTool( GEOMOp::OpOffset,         transTbId );
1136   createTool( GEOMOp::OpProjection,     transTbId );
1137   createTool( separator(),              transTbId );
1138   createTool( GEOMOp::OpMultiTranslate, transTbId );
1139   createTool( GEOMOp::OpMultiRotate,    transTbId );
1140   
1141   int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
1142   createTool( GEOMOp::OpExplode,         operTbId );
1143   createTool( GEOMOp::OpPartition,       operTbId );
1144   createTool( GEOMOp::OpArchimede,       operTbId );
1145   createTool( GEOMOp::OpShapesOnShape,   operTbId );
1146   createTool( GEOMOp::OpSharedShapes,    operTbId );
1147   
1148   int featTbId = createTool( tr( "TOOL_FEATURES" ) );
1149   createTool( GEOMOp::OpFillet1d,        featTbId );
1150   createTool( GEOMOp::OpFillet2d,        featTbId );
1151   createTool( GEOMOp::OpFillet3d,        featTbId );
1152   createTool( GEOMOp::OpChamfer,         featTbId );
1153   createTool( GEOMOp::OpExtrudedBoss,    featTbId );
1154   createTool( GEOMOp::OpExtrudedCut,     featTbId );
1155   
1156   int buildTbId = createTool( tr( "TOOL_BUILD" ) );
1157   createTool( GEOMOp::OpEdge,     buildTbId );
1158   createTool( GEOMOp::OpWire,     buildTbId );
1159   createTool( GEOMOp::OpFace,     buildTbId );
1160   createTool( GEOMOp::OpShell,    buildTbId );
1161   createTool( GEOMOp::OpSolid,    buildTbId );
1162   createTool( GEOMOp::OpCompound, buildTbId );
1163
1164   int measureTbId = createTool( tr( "TOOL_MEASURES" ) );
1165   createTool( GEOMOp::OpPointCoordinates, measureTbId );
1166   createTool( GEOMOp::OpProperties,       measureTbId );
1167   createTool( GEOMOp::OpCenterMass,       measureTbId );
1168   createTool( GEOMOp::OpInertia,          measureTbId );
1169   createTool( GEOMOp::OpNormale,          measureTbId );
1170   createTool( separator(),                measureTbId );
1171   createTool( GEOMOp::OpBoundingBox,      measureTbId );
1172   createTool( GEOMOp::OpMinDistance,      measureTbId );
1173   createTool( GEOMOp::OpAngle,            measureTbId );
1174   createTool( GEOMOp::OpTolerance  ,      measureTbId );
1175   createTool( separator(),                measureTbId );
1176   createTool( GEOMOp::OpFreeBoundaries,   measureTbId );
1177   createTool( GEOMOp::OpFreeFaces,        measureTbId );
1178   createTool( separator(),                measureTbId );
1179   createTool( GEOMOp::OpWhatIs,           measureTbId );
1180   createTool( GEOMOp::OpCheckShape,       measureTbId );
1181   createTool( GEOMOp::OpCheckCompound,    measureTbId );
1182   createTool( GEOMOp::OpCheckSelfInters,  measureTbId );
1183   
1184   int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
1185   createTool( GEOMOp::OpPictureImport,    picturesTbId );
1186   #ifdef WITH_OPENCV
1187     createTool( GEOMOp::OpFeatureDetect,  picturesTbId );
1188   #endif
1189
1190   //@@ 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 @@//
1191
1192   // ---- create popup menus --------------------------
1193
1194   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1195   QString clientOCC = "(client='OCCViewer')";
1196   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1197   QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
1198
1199   QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
1200   QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
1201   QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
1202   QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
1203
1204   QString autoColorPrefix =
1205     "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
1206
1207   QtxPopupMgr* mgr = popupMgr();
1208
1209   mgr->insert( action(  GEOMOp::OpDelete ), -1, -1 );  // delete
1210   mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1211   mgr->insert( action(  GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
1212   mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1213   mgr->insert( action(  GEOMOp::OpShowChildren ), -1, -1 ); // show children
1214   mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
1215
1216   mgr->insert( action(  GEOMOp::OpHideChildren ), -1, -1 ); // hide children
1217   mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
1218   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
1219   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
1220   mgr->insert( separator(), -1, -1 );     // -----------
1221   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1222   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
1223   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1224   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
1225   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
1226   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1227   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1228   mgr->insert( action(  GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges
1229   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1230   mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule );
1231   mgr->insert( action(  GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
1232   mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
1233   mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
1234   mgr->insert( separator(), dispmodeId, -1 );
1235   mgr->insert( action(  GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1236   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1237   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1238   mgr->insert( separator(), -1, -1 );     // -----------
1239   mgr->insert( action(  GEOMOp::OpColor ), -1, -1 ); // color
1240   mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1241   mgr->insert( action(  GEOMOp::OpTransparency ), -1, -1 ); // transparency
1242   mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1243   mgr->insert( action(  GEOMOp::OpIsos ), -1, -1 ); // isos
1244   mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1245   mgr->insert( action(  GEOMOp::OpDeflection ), -1, -1 ); // deflection
1246   mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1247   mgr->insert( action(  GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1248   //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
1249   mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
1250   mgr->insert( action(  GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties  
1251   mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1252   mgr->insert( action(  GEOMOp::OpSetTexture ), -1, -1 ); // texture
1253   mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1254
1255   int lineW = mgr->insert(  tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu
1256   mgr->insert( action(  GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width
1257   mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1258
1259   mgr->insert( action(  GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width
1260   mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1261   
1262   mgr->insert( separator(), -1, -1 );     // -----------
1263   mgr->insert( action(  GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1264   mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1265   mgr->insert( action(  GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1266   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1267   mgr->insert( separator(), -1, -1 );     // -----------
1268
1269   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1270           onlyComponent = "((type='Component') and selcount=1)",
1271           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1272           types = "'Shape' 'Group'";
1273
1274   mgr->insert( action(  GEOMOp::OpShow ), -1, -1 ); // display
1275   mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1276
1277   mgr->insert( action(  GEOMOp::OpHide ), -1, -1 ); // erase
1278   mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1279
1280   mgr->insert( action(  GEOMOp::OpHideAll ), -1, -1 ); // erase All
1281   mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1282
1283   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1284
1285   int selectonlyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
1286   mgr->insert( action(GEOMOp::OpSelectVertex),   selectonlyId, -1);                                  //Vertex
1287   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly, QtxPopupMgr::VisibleRule);
1288   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1289   mgr->insert( action(GEOMOp::OpSelectEdge),     selectonlyId, -1);                                  //Edge
1290   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly, QtxPopupMgr::VisibleRule);
1291   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1292   mgr->insert( action(GEOMOp::OpSelectWire),     selectonlyId, -1);                                  //Wire
1293   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly, QtxPopupMgr::VisibleRule);
1294   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1295   mgr->insert( action(GEOMOp::OpSelectFace),     selectonlyId, -1);                                  //Face
1296   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly, QtxPopupMgr::VisibleRule);
1297   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1298   mgr->insert( action(GEOMOp::OpSelectShell),    selectonlyId, -1);                                  //Shell
1299   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly, QtxPopupMgr::VisibleRule);
1300   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1301   mgr->insert( action(GEOMOp::OpSelectSolid),    selectonlyId, -1);                                  //Solid
1302   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly, QtxPopupMgr::VisibleRule);
1303   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1304   mgr->insert( action(GEOMOp::OpSelectCompound), selectonlyId, -1);                                  //Compound
1305   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1306   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1307   mgr->insert( separator(), selectonlyId, -1);
1308   mgr->insert( action(GEOMOp::OpSelectAll),      selectonlyId, -1);                                  //Clear selection filter
1309   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly, QtxPopupMgr::VisibleRule);
1310   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1311   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1312   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1313   mgr->insert( separator(), -1, -1 );
1314
1315   mgr->insert( separator(), -1, -1 );     // -----------
1316   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
1317   mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
1318
1319
1320   mgr->insert( action(  GEOMOp::OpPublishObject ), -1, -1 ); // Publish object
1321   mgr->setRule( action( GEOMOp::OpPublishObject ), QString("client='ObjectBrowser' and isComponent=true"), QtxPopupMgr::VisibleRule );
1322
1323   mgr->insert( action(  GEOMOp::OpReimport ), -1, -1 );  // delete
1324   mgr->setRule( action( GEOMOp::OpReimport ), QString("$imported in {'true'} and selcount>0"), QtxPopupMgr::VisibleRule );
1325
1326   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1327 }
1328
1329 //=======================================================================
1330 // function : GeometryGUI::activateModule()
1331 // purpose  : Called when GEOM module is activated
1332 //=======================================================================
1333 bool GeometryGUI::activateModule( SUIT_Study* study )
1334 {
1335   if ( CORBA::is_nil( myComponentGeom ) )
1336     return false;
1337
1338   bool res = SalomeApp_Module::activateModule( study );
1339
1340   if ( !res )
1341     return false;
1342   setMenuShown( true );
1343   setToolShown( true );
1344
1345   // import Python module that manages GEOM plugins (need to be here because SalomePyQt API uses active module)
1346   PyGILState_STATE gstate = PyGILState_Ensure();
1347   PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
1348   if(pluginsmanager==NULL)
1349     PyErr_Print();
1350   else
1351     {
1352       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());
1353       if(result==NULL)
1354         PyErr_Print();
1355       Py_XDECREF(result);
1356     }
1357   PyGILState_Release(gstate);
1358   // end of GEOM plugins loading
1359
1360   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1361           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1362
1363   // Reset actions accelerator keys
1364   action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1365   action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1366   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1367
1368   GUIMap::Iterator it;
1369   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1370     it.value()->activate( application()->desktop() );
1371
1372   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1373
1374   SUIT_ViewManager* vm;
1375   ViewManagerList OCCViewManagers, VTKViewManagers;
1376
1377   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1378   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1379   while ( itOCC.hasNext() && (vm = itOCC.next()) )
1380     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1381
1382   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1383   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1384   while ( itVTK.hasNext() && (vm = itVTK.next()) )
1385     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1386
1387   //NPAL 19674
1388   SALOME_ListIO selected;
1389   sm->selectedObjects( selected );
1390   sm->clearSelected();
1391
1392   // disable OCC selectors
1393   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1394   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1395   while ( itOCCSel.hasNext() )
1396     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1397       sr->setEnabled(true);
1398
1399   // disable VTK selectors
1400   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1401   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1402   while ( itVTKSel.hasNext() )
1403     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1404       sr->setEnabled(true);
1405
1406   sm->setSelectedObjects( selected, true );   //NPAL 19674
1407
1408   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1409   if ( viewMenu )
1410     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1411
1412   // 0020836 (Basic vectors and origin)
1413   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1414   if( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) {
1415     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1416     if( appStudy ) {
1417       _PTR(Study) studyDS = appStudy->studyDS();
1418       if( studyDS ) {
1419         _PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1420         if( !aSComponent ) // create objects automatically only if there is no GEOM component
1421           createOriginAndBaseVectors();
1422       }
1423     }
1424   }
1425
1426   return true;
1427 }
1428
1429
1430 //=======================================================================
1431 // function : GeometryGUI::deactivateModule()
1432 // purpose  : Called when GEOM module is deactivated
1433 //=======================================================================
1434 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1435 {
1436   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1437   if ( viewMenu )
1438     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1439
1440   setMenuShown( false );
1441   setToolShown( false );
1442
1443   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1444              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1445
1446   EmitSignalCloseAllDialogs();
1447
1448   GUIMap::Iterator it;
1449   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1450     it.value()->deactivate();
1451
1452   // Unset actions accelerator keys
1453   action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1454   action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1455   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1456
1457   qDeleteAll(myOCCSelectors);
1458   myOCCSelectors.clear();
1459   getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1460
1461   qDeleteAll(myVTKSelectors);
1462   myVTKSelectors.clear();
1463   getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1464
1465   return SalomeApp_Module::deactivateModule( study );
1466 }
1467
1468 //=======================================================================
1469 // function : onWindowActivated()
1470 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1471 //=======================================================================
1472 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1473 {
1474   if ( !win )
1475     return;
1476
1477   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1478   //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1479
1480   // disable non-OCC viewframe menu commands
1481 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1482   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1483   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1484   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1485   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1486   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1487 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1488
1489   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1490   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1491
1492   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1493 }
1494
1495 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1496 {
1497   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1498   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1499 }
1500
1501 void GeometryGUI::viewManagers( QStringList& lst ) const
1502 {
1503   lst.append( OCCViewer_Viewer::Type() );
1504 }
1505
1506 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1507 {
1508   if ( vm && vm->getType() == OCCViewer_Viewer::Type() )
1509   {
1510     qDebug( "connect" );
1511     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
1512              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1513     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1514              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1515     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1516              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1517     connect( vm, SIGNAL( mouseRelease ( SUIT_ViewWindow*, QMouseEvent* ) ),
1518              this, SLOT( OnMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
1519     
1520     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1521     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1522
1523     // disable OCC selectors
1524     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1525     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1526     while ( itOCCSel.hasNext() )
1527       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1528         sr->setEnabled(true);
1529   }
1530   else if ( vm->getType() == SVTK_Viewer::Type() )
1531   {
1532     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1533     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1534
1535     // disable VTK selectors
1536     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1537     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1538     while ( itVTKSel.hasNext() )
1539       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1540         sr->setEnabled(true);
1541   }
1542 }
1543
1544 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1545 {
1546   SUIT_ViewModel* viewer = vm->getViewModel();
1547   if ( vm->getType() == OCCViewer_Viewer::Type() )
1548   {
1549     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1550     while ( itOCCSel.hasNext() )
1551       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1552         if ( sr->viewer() == viewer )
1553         {
1554           delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1555           break;
1556         }
1557   }
1558   if ( vm->getType() == SVTK_Viewer::Type() )
1559   {
1560     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1561     while ( itVTKSel.hasNext() )
1562       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1563         if ( sr->viewer() == viewer )
1564         {
1565           delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1566           break;
1567         }
1568   }
1569 }
1570
1571 QString GeometryGUI::engineIOR() const
1572 {
1573   if ( !CORBA::is_nil( GetGeomGen() ) )
1574     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1575   return "";
1576 }
1577
1578 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1579 Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
1580 #else
1581 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture
1582 #endif
1583       (SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight)
1584 {
1585   theWidth = theHeight = 0;
1586
1587 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1588   Handle(TColStd_HArray1OfByte) aTexture;
1589 #else
1590   Handle(Graphic3d_HArray1OfBytes) aTexture;
1591 #endif
1592
1593   if (theStudy) {
1594     TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1595     aTexture = aTextureMap[ theId ];
1596     if ( aTexture.IsNull() ) {
1597       GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1598       if ( !aInsOp->_is_nil() ) {
1599         CORBA::Long aWidth, aHeight;
1600         SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1601         if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1602           theWidth  = aWidth;
1603           theHeight = aHeight;
1604
1605 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
1606           aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
1607 #else
1608           aTexture  = new Graphic3d_HArray1OfBytes (1, aStream->length());
1609 #endif
1610
1611           for (int i = 0; i < aStream->length(); i++)
1612             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1613           aTextureMap[ theId ] = aTexture;
1614         }
1615       }
1616     }
1617   }
1618   return aTexture;
1619 }
1620
1621 LightApp_Selection* GeometryGUI::createSelection() const
1622 {
1623   return new GEOMGUI_Selection();
1624 }
1625
1626 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1627 {
1628   SalomeApp_Module::contextMenuPopup( client, menu, title );
1629
1630   /*
1631   SALOME_ListIO lst;
1632   getApp()->selectionMgr()->selectedObjects(lst);
1633   if (lst.Extent() < 1)
1634     return;
1635
1636   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1637   _PTR(Study) study = appStudy->studyDS();
1638
1639   bool isImported = true;
1640   SALOME_ListIteratorOfListIO anIt (lst);
1641   for (; anIt.More() && isImported; anIt.Next()) {
1642     Handle(SALOME_InteractiveObject) io = anIt.Value();
1643     _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1644     if (aSObj) {
1645       if (lst.Extent() == 1) {
1646         // Set context menu title
1647         if (client == "OCCViewer" || client == "VTKViewer")
1648           title = QString(aSObj->GetName().c_str());
1649       }
1650
1651       CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1652       GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1653       if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1654         isImported = false;
1655     } else {
1656       isImported = false;
1657     }
1658   }
1659
1660   if (isImported) {
1661     menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1662   }
1663   */
1664 }
1665
1666 void GeometryGUI::createPreferences()
1667 {
1668   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1669
1670   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1671   setPreferenceProperty( genGroup, "columns", 2 );
1672
1673   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1674                                 LightApp_Preferences::Selector,
1675                                 "Geometry", "display_mode" );
1676
1677   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1678                  LightApp_Preferences::Color, "Geometry", "shading_color" );
1679
1680   addPreference( tr( "PREF_EDGES_IN_SHADING" ), genGroup,
1681                  LightApp_Preferences::Color, "Geometry", "edges_in_shading_color" );
1682
1683   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1684                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1685
1686   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1687                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1688
1689   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1690                  LightApp_Preferences::Color, "Geometry", "line_color" );
1691
1692   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1693                  LightApp_Preferences::Color, "Geometry", "point_color" );
1694
1695   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1696                  LightApp_Preferences::Color, "Geometry", "isos_color" );
1697
1698   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1699                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1700
1701   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1702                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1703
1704   int front_material = addPreference( tr( "PREF_FRONT_MATERIAL" ), genGroup,
1705                                       LightApp_Preferences::Selector,
1706                                       "Geometry", "front_material" );
1707   
1708   int back_material = addPreference( tr( "PREF_BACK_MATERIAL" ), genGroup,
1709                                      LightApp_Preferences::Selector,
1710                                      "Geometry", "back_material" );
1711
1712   const int nb = 4;
1713   int wd[nb];
1714   int iter=0;
1715
1716   wd[iter++] = addPreference( tr( "PREF_EDGE_WIDTH" ), genGroup,
1717                               LightApp_Preferences::IntSpin, "Geometry", "edge_width" );
1718
1719   wd[iter++] = addPreference( tr( "PREF_ISOLINES_WIDTH" ), genGroup,
1720                               LightApp_Preferences::IntSpin, "Geometry", "isolines_width" );
1721
1722   wd[iter++] = addPreference( tr( "PREF_PREVIEW_EDGE_WIDTH" ), genGroup,
1723                                      LightApp_Preferences::IntSpin, "Geometry", "preview_edge_width" );
1724   
1725   wd[iter++] = addPreference( tr( "PREF_MEASURES_LINE_WIDTH" ), genGroup,
1726                               LightApp_Preferences::IntSpin, "Geometry", "measures_line_width" );
1727
1728   for(int i = 0; i < nb; i++) {
1729     setPreferenceProperty( wd[i], "min", 1 );    
1730     setPreferenceProperty( wd[i], "max", 5 );
1731   }
1732
1733
1734   // Quantities with individual precision settings
1735   int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId );
1736   setPreferenceProperty( precGroup, "columns", 2 );
1737
1738   const int nbQuantities = 8;
1739   int prec[nbQuantities], ii = 0;
1740   prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
1741                               LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
1742   prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
1743                               LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
1744   prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
1745                               LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
1746   prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
1747                               LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
1748   prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
1749                               LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
1750   prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
1751                               LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
1752   prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
1753                               LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
1754   prec[ii  ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
1755                               LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
1756
1757   // Set property for precision value for spinboxes
1758   for ( ii = 0; ii < nbQuantities; ii++ ){
1759     setPreferenceProperty( prec[ii], "min", -14 );
1760     setPreferenceProperty( prec[ii], "max", 14 );
1761     setPreferenceProperty( prec[ii], "precision", 2 );
1762   }
1763
1764   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1765   setPreferenceProperty( VertexGroup, "columns", 2 );
1766
1767   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1768                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1769
1770   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1771                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1772
1773   // Set property for default display mode
1774   QStringList aModesList;
1775   aModesList.append( tr("MEN_WIREFRAME") );
1776   aModesList.append( tr("MEN_SHADING") );
1777   aModesList.append( tr("MEN_SHADING_WITH_EDGES") );
1778
1779   QList<QVariant> anIndexesList;
1780   anIndexesList.append(0);
1781   anIndexesList.append(1);
1782   anIndexesList.append(2);
1783
1784   setPreferenceProperty( dispmode, "strings", aModesList );
1785   setPreferenceProperty( dispmode, "indexes", anIndexesList );
1786
1787   // Set property for step value for spinboxes
1788   setPreferenceProperty( step, "min", 1 );
1789   setPreferenceProperty( step, "max", 10000 );
1790   setPreferenceProperty( step, "precision", 3 );
1791
1792   // Set property for deflection value for spinboxes
1793   setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1794   setPreferenceProperty( defl, "max", 1.0 );
1795   setPreferenceProperty( defl, "step", 1.0e-04 );
1796   setPreferenceProperty( defl, "precision", 6 );
1797
1798   // Set property for default material
1799   Material_ResourceMgr aMatResMgr;
1800   QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames();
1801   setPreferenceProperty( front_material, "strings", aPrefMatNames );
1802   setPreferenceProperty( back_material, "strings", aPrefMatNames );
1803
1804   // Set property vertex marker type
1805   QList<QVariant> aMarkerTypeIndicesList;
1806   QList<QVariant> aMarkerTypeIconsList;
1807
1808   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1809   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1810     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1811     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1812     aMarkerTypeIndicesList << (i-1);
1813     aMarkerTypeIconsList << pixmap;
1814   }
1815
1816   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1817   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
1818
1819   // Set property for vertex marker scale
1820   QList<QVariant> aMarkerScaleIndicesList;
1821   QStringList     aMarkerScaleValuesList;
1822
1823   for ( int iii = GEOM::MS_10; iii <= GEOM::MS_70; iii++ ) {
1824     aMarkerScaleIndicesList << iii;
1825     aMarkerScaleValuesList  << QString::number( (iii-(int)GEOM::MS_10)*0.5 + 1.0 );
1826   }
1827
1828   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1829   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1830
1831   int originGroup = addPreference( tr( "PREF_GROUP_ORIGIN_AND_BASE_VECTORS" ), tabId );
1832   setPreferenceProperty( originGroup, "columns", 2 );
1833
1834   int baseVectorsLength = addPreference( tr( "PREF_BASE_VECTORS_LENGTH" ), originGroup,
1835                                          LightApp_Preferences::DblSpin, "Geometry", "base_vectors_length" );
1836   setPreferenceProperty( baseVectorsLength, "min", 0.01 );
1837   setPreferenceProperty( baseVectorsLength, "max", 1000 );
1838
1839   addPreference( tr( "PREF_AUTO_CREATE" ), originGroup,
1840                  LightApp_Preferences::Bool, "Geometry", "auto_create_base_objects" );
1841
1842
1843   int operationsGroup = addPreference( tr( "PREF_GROUP_OPERATIONS" ), tabId );
1844   setPreferenceProperty( operationsGroup, "columns", 2 );
1845
1846   addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
1847                  LightApp_Preferences::Bool, "Geometry", "geom_preview" );
1848 }
1849
1850 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1851 {
1852   if (section == "Geometry") {
1853     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1854     if (param == QString("SettingsGeomStep")) {
1855       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1856       EmitSignalDefaultStepValueChanged(spin_step);
1857     }
1858   }
1859 }
1860
1861 LightApp_Displayer* GeometryGUI::displayer()
1862 {
1863   if( !myDisplayer )
1864     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1865   return myDisplayer;
1866 }
1867
1868 void GeometryGUI::setLocalSelectionMode(const int mode)
1869 {
1870   myLocalSelectionMode = mode;
1871 }
1872 int GeometryGUI::getLocalSelectionMode() const
1873 {
1874   return myLocalSelectionMode;
1875 }
1876
1877 const char gSeparator = '_'; // character used to separate parameter names
1878 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1879
1880 /*!
1881  * \brief Store visual parameters
1882  *
1883  * This method is called just before the study document is saved.
1884  * Store visual parameters in AttributeParameter attribute(s)
1885  */
1886 void GeometryGUI::storeVisualParameters (int savePoint)
1887 {
1888   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1889   if ( !appStudy || !appStudy->studyDS() )
1890     return;
1891   _PTR(Study) studyDS = appStudy->studyDS();
1892
1893   // componentName is used for encoding of entries when storing them in IParameters
1894   std::string componentName = myComponentGeom->ComponentDataType();
1895   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1896   //if (!aSComponent) return;
1897
1898   // IParameters
1899   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1900                                                              componentName.c_str(),
1901                                                              savePoint);
1902   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1903
1904   QList<SUIT_ViewManager*> lst;
1905   QList<SUIT_ViewManager*>::Iterator it;
1906
1907   // main cycle to store parameters of displayed objects
1908   lst.clear();
1909   getApp()->viewManagers(lst);
1910   for (it = lst.begin(); it != lst.end(); it++) {
1911     SUIT_ViewManager* vman = *it;
1912     QString vType = vman->getType();
1913     int aMgrId = vman->getGlobalId();
1914     // saving VTK actors properties
1915     QVector<SUIT_ViewWindow*> views = vman->getViews();
1916     for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
1917       const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
1918       ObjMap::ConstIterator o_it = anObjects.begin();
1919       for (; o_it != anObjects.end(); o_it++) {
1920         const PropMap aProps = o_it.value();
1921
1922         //Check that object exists in the study
1923         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
1924         if ( !obj || !(aProps.count() > 0))
1925           continue;
1926         // entry is "encoded" = it does NOT contain component adress, since it is a
1927         // subject to change on next component loading
1928
1929         std::string entry = ip->encodeEntry(o_it.key().toLatin1().data(), componentName);
1930
1931         _PTR(GenericAttribute) anAttr;
1932         if( !obj->FindAttribute(anAttr, "AttributeIOR"))
1933           continue;
1934
1935         std::string param,occParam = vType.toLatin1().data();
1936         occParam += NAME_SEPARATOR;
1937         occParam += QString::number(aMgrId).toLatin1().data();
1938         occParam += NAME_SEPARATOR;
1939
1940         if(aProps.contains(VISIBILITY_PROP)) {
1941           param = occParam + VISIBILITY_PROP;
1942           ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
1943         }
1944
1945         if(aProps.contains(DISPLAY_MODE_PROP)) {
1946           param = occParam + DISPLAY_MODE_PROP;
1947           ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
1948         }
1949
1950         if(aProps.contains(COLOR_PROP)) {
1951           QColor c = aProps.value(COLOR_PROP).value<QColor>();
1952           QString colorStr = QString::number(c.red()/255.);
1953           colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
1954           colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
1955           param = occParam + COLOR_PROP;
1956           ip->setParameter(entry, param, colorStr.toLatin1().data());
1957         }
1958
1959         if(vType == SVTK_Viewer::Type()) {
1960           if(aProps.contains(OPACITY_PROP)) {
1961             param = occParam + OPACITY_PROP;
1962             ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1963           }
1964         } else if (vType == SOCC_Viewer::Type()) {
1965           if(aProps.contains(TRANSPARENCY_PROP)) {
1966             param = occParam + TRANSPARENCY_PROP;
1967             ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
1968           }
1969         }
1970
1971         if(aProps.contains(ISOS_PROP)) {
1972           param = occParam + ISOS_PROP;
1973           ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
1974         }
1975
1976         if(aProps.contains(VECTOR_MODE_PROP)) {
1977           param = occParam + VECTOR_MODE_PROP;
1978           ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
1979         }
1980
1981         if(aProps.contains(DEFLECTION_COEFF_PROP)) {
1982           param = occParam + DEFLECTION_COEFF_PROP;
1983           ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
1984         }
1985
1986         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
1987         if(aProps.contains(MARKER_TYPE_PROP)) {
1988           param = occParam + MARKER_TYPE_PROP;
1989           ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
1990         }
1991
1992         if(aProps.contains(FRONT_MATERIAL_PROP)) {
1993           param = occParam + FRONT_MATERIAL_PROP;
1994           ip->setParameter(entry, param, aProps.value(FRONT_MATERIAL_PROP).toString().toLatin1().data());
1995         }
1996
1997         if(aProps.contains(BACK_MATERIAL_PROP)) {
1998           param = occParam + BACK_MATERIAL_PROP;
1999           ip->setParameter(entry, param, aProps.value(BACK_MATERIAL_PROP).toString().toLatin1().data());
2000           
2001         }
2002
2003         if(aProps.contains( EDGE_WIDTH_PROP )) {
2004              param = occParam + EDGE_WIDTH_PROP;
2005            ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data());                               
2006         }
2007         
2008         if(aProps.contains( ISOS_WIDTH_PROP )) {
2009           param = occParam + ISOS_WIDTH_PROP;
2010           ip->setParameter(entry, param, aProps.value(ISOS_WIDTH_PROP).toString().toLatin1().data());
2011         }
2012       } // object iterator
2013     } // for (views)
2014   } // for (viewManagers)
2015 }
2016
2017 /*!
2018  * \brief Restore visual parameters
2019  *
2020  * This method is called after the study document is opened.
2021  * Restore visual parameters from AttributeParameter attribute(s)
2022  */
2023 void GeometryGUI::restoreVisualParameters (int savePoint)
2024 {
2025   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
2026   if (!appStudy || !appStudy->studyDS())
2027     return;
2028   _PTR(Study) studyDS = appStudy->studyDS();
2029
2030   // componentName is used for encoding of entries when storing them in IParameters
2031   std::string componentName = myComponentGeom->ComponentDataType();
2032   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
2033   //if (!aSComponent) return;
2034
2035   // IParameters
2036   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
2037                                                              componentName.c_str(),
2038                                                              savePoint);
2039   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
2040
2041   std::vector<std::string> entries = ip->getEntries();
2042
2043   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
2044   {
2045     // entry is a normal entry - it should be "decoded" (setting base adress of component)
2046     QString entry (ip->decodeEntry(*entIt).c_str());
2047
2048     // Check that the entry corresponds to a real object in the Study
2049     // as the object may be deleted or modified after the visual state is saved.
2050     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
2051     if (!so) continue; //Skip the not existent entry
2052
2053     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
2054     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
2055
2056     std::vector<std::string>::iterator namesIt = paramNames.begin();
2057     std::vector<std::string>::iterator valuesIt = paramValues.begin();
2058
2059     // actors are stored in a map after displaying of them for
2060     // quicker access in the future: map < viewID to actor >
2061     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
2062     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
2063
2064     QString viewerTypStr;
2065     QString viewIndexStr;
2066     int viewIndex;
2067     QVector<PropMap> aListOfMap;
2068
2069     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
2070     {
2071       // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
2072       // '_' is used as separator and should not be used in viewer type or parameter names.
2073       QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
2074       if (lst.size() != 3)
2075         continue;
2076
2077       viewerTypStr = lst[0];
2078       viewIndexStr = lst[1];
2079       QString paramNameStr = lst[2];
2080
2081       bool ok;
2082       viewIndex = viewIndexStr.toUInt(&ok);
2083       if (!ok) // bad conversion of view index to integer
2084         continue;
2085
2086       if((viewIndex + 1) > aListOfMap.count()) {
2087         aListOfMap.resize(viewIndex + 1);
2088       }
2089
2090       QString val((*valuesIt).c_str());
2091       if(paramNameStr == VISIBILITY_PROP){
2092         aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
2093
2094       } else if(paramNameStr == OPACITY_PROP) {
2095         aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
2096
2097       }        else if(paramNameStr == TRANSPARENCY_PROP) {
2098         aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
2099
2100       } else if(paramNameStr == DISPLAY_MODE_PROP) {
2101         aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
2102
2103       } else if(paramNameStr == ISOS_PROP) {
2104         aListOfMap[viewIndex].insert( ISOS_PROP, val);
2105
2106       } else if(paramNameStr == COLOR_PROP) {
2107         QStringList rgb = val.split(DIGIT_SEPARATOR);
2108         if(rgb.count() == 3) {
2109           QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
2110           aListOfMap[viewIndex].insert( COLOR_PROP, c);
2111         }
2112       } else if(paramNameStr == VECTOR_MODE_PROP) {
2113         aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
2114
2115       }  else if(paramNameStr == DEFLECTION_COEFF_PROP) {
2116         aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
2117       }  else if(paramNameStr == MARKER_TYPE_PROP) {
2118         aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
2119       } else if(paramNameStr == FRONT_MATERIAL_PROP) {
2120         aListOfMap[viewIndex].insert( FRONT_MATERIAL_PROP, val);
2121       } else if(paramNameStr == BACK_MATERIAL_PROP) {
2122         aListOfMap[viewIndex].insert( BACK_MATERIAL_PROP, val);
2123       }  else if(paramNameStr == EDGE_WIDTH_PROP) {
2124         aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP , val);
2125       }  else if(paramNameStr == ISOS_WIDTH_PROP) {
2126         aListOfMap[viewIndex].insert( ISOS_WIDTH_PROP , val);
2127       }
2128
2129                     
2130
2131     } // for names/parameters iterator
2132
2133     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
2134
2135     for (int index = 0; index < aListOfMap.count(); index++) {
2136
2137       appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
2138
2139       //Get Visibility property of the current PropMap
2140       if (aListOfMap[index].value(VISIBILITY_PROP) == 1) {
2141         SUIT_ViewManager* vman = lst.at(index);
2142         SUIT_ViewModel* vmodel = vman->getViewModel();
2143         displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
2144       }
2145     }
2146
2147   } // for entries iterator
2148
2149   // update all VTK and OCC views
2150   QList<SUIT_ViewManager*> lst;
2151   getApp()->viewManagers(lst);
2152   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
2153     SUIT_ViewModel* vmodel = (*it)->getViewModel();
2154     if (!vmodel)
2155       continue;
2156     if (vmodel->getType() == SVTK_Viewer::Type()) {
2157       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2158       vtkView->getRenderer()->ResetCameraClippingRange();
2159       vtkView->Repaint();
2160     }
2161     else if (vmodel->getType() == SOCC_Viewer::Type()) {
2162       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
2163       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
2164       if (occVMod)
2165         occVMod->Repaint();
2166     }
2167   }
2168 }
2169
2170 void GeometryGUI::onViewAboutToShow()
2171 {
2172   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
2173   QAction* a = action( GEOMOp::OpSwitchVectors );
2174   if ( window ) {
2175     a->setEnabled(true);
2176     bool vmode = window->property("VectorsMode").toBool();
2177     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
2178   } else {
2179     a->setText ( tr("MEN_VECTOR_MODE_ON") );
2180     a->setEnabled(false);
2181   }
2182 }
2183
2184 /*!
2185   Rename object by entry.
2186   \param entry entry of the object
2187   \param name new name of the object
2188   \brief Return \c true if rename operation finished successfully, \c false otherwise.
2189 */
2190 bool GeometryGUI::renameObject( const QString& entry, const QString& name) {
2191
2192   bool appRes = SalomeApp_Module::renameObject(entry,name);
2193   if( !appRes )
2194     return false;
2195
2196   bool result = false;
2197
2198   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
2199   SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
2200
2201   if(!appStudy)
2202     return result;
2203
2204   _PTR(Study) aStudy = appStudy->studyDS();
2205
2206   if(!aStudy)
2207     return result;
2208
2209   _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) );
2210   _PTR(GenericAttribute) anAttr;
2211   if ( obj ) {
2212     if ( obj->FindAttribute(anAttr, "AttributeName") ) {
2213       _PTR(AttributeName) aName (anAttr);
2214
2215       GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
2216       if (!CORBA::is_nil(anObj)) {
2217         aName->SetValue( name.toLatin1().data() ); // rename the SObject
2218         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
2219         result = true;
2220       }
2221     }
2222   }
2223   return result;
2224 }