]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI.cxx
Salome HOME
Improve actions management
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
1 //  Copyright (C) 2007-2008  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 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : GeometryGUI.cxx
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 //
26 #include "GeometryGUI.h"
27 #include "GeometryGUI_Operations.h"
28 #include "GEOMGUI_OCCSelector.h"
29 #include "GEOMGUI_Selection.h"
30 #include "GEOM_Displayer.h"
31 #include "GEOM_AISShape.hxx"
32
33 #include "GEOM_Actor.h"
34
35 #include <SUIT_Desktop.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_Session.h>
39 #include <SUIT_ViewManager.h>
40
41 #include <OCCViewer_ViewWindow.h>
42 #include <OCCViewer_ViewPort3d.h>
43 #include <OCCViewer_ViewModel.h>
44 #include <OCCViewer_ViewManager.h>
45
46 #include <SOCC_ViewModel.h>
47 #include <SOCC_ViewWindow.h>
48
49 #include <SVTK_ViewWindow.h>
50 #include <SVTK_RenderWindowInteractor.h>
51 #include <SVTK_InteractorStyle.h>
52 #include <SVTK_ViewModel.h>
53
54 #include <SalomeApp_Application.h>
55 #include <SalomeApp_Study.h>
56
57 #include <LightApp_SelectionMgr.h>
58 #include <LightApp_VTKSelector.h>
59 #include <LightApp_DataObject.h>
60 #include <LightApp_Preferences.h>
61
62 #include <SALOME_LifeCycleCORBA.hxx>
63 #include <SALOME_ListIO.hxx>
64 #include <SALOME_ListIteratorOfListIO.hxx>
65
66 #include <SALOMEDSClient_ClientFactory.hxx>
67 #include <SALOMEDSClient_IParameters.hxx>
68
69 // External includes
70 #include <QMenu>
71 #include <QAction>
72 #include <QFileInfo>
73 #include <QString>
74 #include <QPainter>
75
76 #include <AIS_Drawer.hxx>
77 #include <AIS_ListOfInteractive.hxx>
78 #include <AIS_ListIteratorOfListOfInteractive.hxx>
79 #include <Prs3d_Drawer.hxx>
80 #include <Prs3d_IsoAspect.hxx>
81 #include <Aspect_TypeOfMarker.hxx>
82 #include <OSD_SharedLibrary.hxx>
83 #include <NCollection_DataMap.hxx>
84 #include <Graphic3d_HArray1OfBytes.hxx>
85
86 #include <utilities.h>
87
88 #include <vtkCamera.h>
89 #include <vtkRenderer.h>
90
91 #include "GEOMImpl_Types.hxx"
92
93 extern "C" {
94   Standard_EXPORT CAM_Module* createModule() {
95     return new GeometryGUI();
96   }
97 }
98
99 GeometryGUI::StudyTextureMap GeometryGUI::myTextureMap;
100
101 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
102
103 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
104 {
105   // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
106   if (CORBA::is_nil(myComponentGeom))
107     InitGeomGen();
108   return GeometryGUI::myComponentGeom;
109 }
110
111 bool GeometryGUI::InitGeomGen()
112 {
113   GeometryGUI aGG;
114   if( CORBA::is_nil( myComponentGeom ) ) return false;
115   return true;
116 }
117
118 //=======================================================================
119 // function : ClientSObjectToObject
120 // purpose  :
121 //=======================================================================
122 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
123 {
124   _PTR(GenericAttribute) anAttr;
125   CORBA::Object_var anObj;
126   try {
127     std::string aValue = theSObject->GetIOR();
128     if (strcmp(aValue.c_str(), "") != 0) {
129       CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
130       anObj = anORB->string_to_object(aValue.c_str());
131     }
132   } catch(...) {
133     INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
134   }
135   return anObj._retn();
136 }
137
138 //=======================================================================
139 // function : ClientStudyToStudy
140 // purpose  :
141 //=======================================================================
142 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
143 {
144   SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
145   CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
146   SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
147   int aStudyID = theStudy->StudyId();
148   SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
149   return aDSStudy._retn();
150 }
151
152 //=======================================================================
153 // function : GeometryGUI::GeometryGUI()
154 // purpose  : Constructor
155 //=======================================================================
156 GeometryGUI::GeometryGUI() :
157   SalomeApp_Module( "GEOM" ),
158   LightApp_Module( "GEOM" )
159 {
160   if ( CORBA::is_nil( myComponentGeom ) )
161   {
162     Engines::Component_var comp = SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "GEOM" );
163     myComponentGeom  = GEOM::GEOM_Gen::_narrow( comp );
164   }
165
166   myActiveDialogBox = 0;
167
168   gp_Pnt origin = gp_Pnt(0., 0., 0.);
169   gp_Dir direction = gp_Dir(0., 0., 1.);
170   myWorkingPlane = gp_Ax3(origin, direction);
171
172   myDisplayer = 0;
173   myLocalSelectionMode = GEOM_ALLOBJECTS;
174 }
175
176 //=======================================================================
177 // function : GeometryGUI::~GeometryGUI()
178 // purpose  : Destructor
179 //=======================================================================
180 GeometryGUI::~GeometryGUI()
181 {
182   while (!myOCCSelectors.isEmpty())
183     delete myOCCSelectors.takeFirst();
184
185   while (!myVTKSelectors.isEmpty())
186     delete myVTKSelectors.takeFirst();
187
188   qDeleteAll(myGUIMap);
189 }
190
191 //=======================================================================
192 // function : GeometryGUI::getLibrary()
193 // purpose  : get or load GUI library by name [ internal ]
194 //=======================================================================
195 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
196 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
197 {
198   if ( !myGUIMap.contains( libraryName ) ) {
199     // try to load library if it is not loaded yet
200 #ifndef WNT
201     QString dirs = getenv( "LD_LIBRARY_PATH" );
202     QString sep  = ":";
203 #else
204     QString dirs = getenv( "PATH" );
205     QString sep  = ";";
206 #endif
207     if ( !dirs.isEmpty() ) {
208       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
209       QListIterator<QString> it( dirList ); it.toBack();
210       while ( it.hasPrevious() ) {
211         QFileInfo fi( Qtx::addSlash( it.previous() ) + libraryName );
212         if ( fi.exists() ) {
213           OSD_SharedLibrary aSharedLibrary( fi.fileName().toLatin1().constData() );
214           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
215           if ( !res ) {
216             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
217             continue; // continue search further
218           }
219           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
220           if ( osdF != NULL ) {
221             LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
222             GEOMGUI* libGUI = (*func)( this );
223             if ( libGUI ) {
224               myGUIMap[ libraryName ] = libGUI;
225               break; // found and loaded!
226             }
227           }
228         }
229       }
230     }
231   }
232   return myGUIMap.contains( libraryName ) ? myGUIMap[ libraryName ] : 0;
233 }
234
235 //=======================================================================
236 // function : GeometryGUI::ActiveWorkingPlane()
237 // purpose  : Activate Working Plane View
238 //=======================================================================
239 void GeometryGUI::ActiveWorkingPlane()
240 {
241   gp_Dir DZ = myWorkingPlane.Direction();
242   gp_Dir DY = myWorkingPlane.YDirection();
243
244   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
245   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
246   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
247
248   if( ViewOCC ) {
249     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
250     if ( vw ) {
251       Handle(V3d_View) view3d =  vw->getViewPort()->getView();
252
253       view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
254       view3d->SetUp(DY.X(), DY.Y(), DY.Z());
255
256       vw->onViewFitAll();
257     }
258   }
259   else if( ViewVTK ) {
260     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
261     if ( vw ) {
262       vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
263
264       camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
265       camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
266       camera->SetFocalPoint(0,0,0);
267
268       vw->onFitAll();
269     }
270   }
271 }
272
273 //=======================================================================
274 // function : GeometryGUI::SetActiveDialogBox()
275 // purpose  : Set active dialog box
276 //=======================================================================
277 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
278 {
279   myActiveDialogBox = (QDialog*)aDlg;
280 }
281
282 //=======================================================================
283 // function : GeometryGUI::EmitSignalDeactivateDialog()
284 // purpose  : Emit a signal to deactivate the active dialog Box
285 //=======================================================================
286 void GeometryGUI::EmitSignalDeactivateDialog()
287 {
288   emit SignalDeactivateActiveDialog();
289 }
290
291 //=======================================================================
292 // function : GeometryGUI::EmitSignalCloseAllDialogs()
293 // purpose  : Emit a signal to close all non modal dialogs box
294 //=======================================================================
295 void GeometryGUI::EmitSignalCloseAllDialogs()
296 {
297   emit SignalCloseAllDialogs();
298 }
299
300 //=======================================================================
301 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
302 // purpose  : Emit a signal to inform that default real spin box step has
303 //            been changed
304 //=======================================================================
305 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
306 {
307   emit SignalDefaultStepValueChanged(newVal);
308 }
309
310 //=======================================================================
311 // function : GeometryGUI::OnGUIEvent()
312 // purpose  : common slot for all menu/toolbar actions
313 //=======================================================================
314 void GeometryGUI::OnGUIEvent()
315 {
316   const QObject* obj = sender();
317   if ( !obj || !obj->inherits( "QAction" ) )
318     return;
319   int id = actionId((QAction*)obj);
320   if ( id != -1 )
321     OnGUIEvent( id );
322 }
323
324 //=======================================================================
325 // function : GeometryGUI::OnGUIEvent()
326 // purpose  : manage all events on GUI [static]
327 //=======================================================================
328 void GeometryGUI::OnGUIEvent( int id )
329 {
330   SUIT_Application* anApp = application();
331   if (!anApp) return;
332   SUIT_Desktop* desk = anApp->desktop();
333
334   // check type of the active viewframe
335   SUIT_ViewWindow* window = desk->activeWindow();
336   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
337   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
338   // if current viewframe is not of OCC and not of VTK type - return immediately
339   // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
340   QList<int> NotViewerDependentCommands;
341   NotViewerDependentCommands << GEOMOp::OpRename
342                              << GEOMOp::OpDelete
343                              << GEOMOp::OpShow
344                              << GEOMOp::OpShowOnly
345                              << GEOMOp::OpShowChildren
346                              << GEOMOp::OpHideChildren
347                              << GEOMOp::OpPointMarker;
348   if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommands.contains( id ) )
349       return;
350
351   // fix for IPAL9103, point 2
352   if ( CORBA::is_nil( GetGeomGen() ) ) {
353     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
354     return;
355   }
356
357   QString libName;
358   // find corresponding GUI library
359   switch ( id ) {
360   case GEOMOp::OpImport:           // MENU FILE - IMPORT
361   case GEOMOp::OpExport:           // MENU FILE - EXPORT
362   case GEOMOp::OpSelectVertex:     // POPUP MENU - SELECT ONLY - VERTEX
363   case GEOMOp::OpSelectEdge:       // POPUP MENU - SELECT ONLY - EDGE
364   case GEOMOp::OpSelectWire:       // POPUP MENU - SELECT ONLY - WIRE
365   case GEOMOp::OpSelectFace:       // POPUP MENU - SELECT ONLY - FACE
366   case GEOMOp::OpSelectShell:      // POPUP MENU - SELECT ONLY - SHELL
367   case GEOMOp::OpSelectSolid:      // POPUP MENU - SELECT ONLY - SOLID
368   case GEOMOp::OpSelectCompound:   // POPUP MENU - SELECT ONLY - COMPOUND
369   case GEOMOp::OpSelectAll:        // POPUP MENU - SELECT ONLY - SELECT ALL
370   case GEOMOp::OpDelete:           // MENU EDIT - DELETE
371   case GEOMOp::OpCheckGeom:        // MENU TOOLS - CHECK GEOMETRY
372   case GEOMOp::OpDeflection:       // POPUP MENU - DEFLECTION COEFFICIENT
373   case GEOMOp::OpColor:            // POPUP MENU - COLOR
374   case GEOMOp::OpTransparency:     // POPUP MENU - TRANSPARENCY
375   case GEOMOp::OpIsos:             // POPUP MENU - ISOS
376   case GEOMOp::OpAutoColor:        // POPUP MENU - AUTO COLOR
377   case GEOMOp::OpNoAutoColor:      // POPUP MENU - DISABLE AUTO COLOR
378   case GEOMOp::OpShowChildren:     // POPUP MENU - SHOW CHILDREN
379   case GEOMOp::OpHideChildren:     // POPUP MENU - HIDE CHILDREN
380   case GEOMOp::OpPointMarker:      // POPUP MENU - POINT MARKER
381   case GEOMOp::OpRename:           // POPUP MENU - RENAME
382     libName = "GEOMToolsGUI";
383     break;
384   case GEOMOp::OpDisplayMode:      // MENU VIEW - WIREFRAME/SHADING
385   case GEOMOp::OpShowAll:          // MENU VIEW - SHOW ALL
386   case GEOMOp::OpShowOnly:         // MENU VIEW - DISPLAY ONLY
387   case GEOMOp::OpHideAll:          // MENU VIEW - ERASE ALL
388   case GEOMOp::OpHide:             // MENU VIEW - ERASE
389   case GEOMOp::OpShow:             // MENU VIEW - DISPLAY
390   case GEOMOp::OpSwitchVectors:    // MENU VIEW - VECTOR MODE
391   case GEOMOp::OpWireframe:        // POPUP MENU - WIREFRAME
392   case GEOMOp::OpShading:          // POPUP MENU - SHADING
393   case GEOMOp::OpVectors:          // POPUP MENU - VECTORS
394     libName = "DisplayGUI";
395     break;
396   case GEOMOp::OpPoint:            // MENU BASIC - POINT
397   case GEOMOp::OpLine:             // MENU BASIC - LINE
398   case GEOMOp::OpCircle:           // MENU BASIC - CIRCLE
399   case GEOMOp::OpEllipse:          // MENU BASIC - ELLIPSE
400   case GEOMOp::OpArc:              // MENU BASIC - ARC
401   case GEOMOp::OpVector:           // MENU BASIC - VECTOR
402   case GEOMOp::OpPlane:            // MENU BASIC - PLANE
403   case GEOMOp::OpCurve:            // MENU BASIC - CURVE
404   case GEOMOp::OpLCS:              // MENU BASIC - REPAIR
405     libName = "BasicGUI";
406     break;
407   case GEOMOp::OpBox:              // MENU PRIMITIVE - BOX
408   case GEOMOp::OpCylinder:         // MENU PRIMITIVE - CYLINDER
409   case GEOMOp::OpSphere:           // MENU PRIMITIVE - SPHERE
410   case GEOMOp::OpTorus:            // MENU PRIMITIVE - TORUS
411   case GEOMOp::OpCone:             // MENU PRIMITIVE - CONE
412   case GEOMOp::OpRectangle:        // MENU PRIMITIVE - FACE
413   case GEOMOp::OpDisk:             // MENU PRIMITIVE - DISK
414     libName = "PrimitiveGUI";
415     break;
416   case GEOMOp::OpPrism:            // MENU GENERATION - PRISM
417   case GEOMOp::OpRevolution:       // MENU GENERATION - REVOLUTION
418   case GEOMOp::OpFilling:          // MENU GENERATION - FILLING
419   case GEOMOp::OpPipe:             // MENU GENERATION - PIPE
420     libName = "GenerationGUI";
421     break;
422   case GEOMOp::Op2dSketcher:       // MENU ENTITY - SKETCHER
423   case GEOMOp::Op3dSketcher:       // MENU ENTITY - 3D SKETCHER
424   case GEOMOp::OpExplode:          // MENU ENTITY - EXPLODE
425     libName = "EntityGUI";
426     break;
427   case GEOMOp::OpEdge:             // MENU BUILD - EDGE
428   case GEOMOp::OpWire:             // MENU BUILD - WIRE
429   case GEOMOp::OpFace:             // MENU BUILD - FACE
430   case GEOMOp::OpShell:            // MENU BUILD - SHELL
431   case GEOMOp::OpSolid:            // MENU BUILD - SOLID
432   case GEOMOp::OpCompound:         // MENU BUILD - COMPUND
433     libName = "BuildGUI";
434     break;
435   case GEOMOp::OpFuse:             // MENU BOOLEAN - FUSE
436   case GEOMOp::OpCommon:           // MENU BOOLEAN - COMMON
437   case GEOMOp::OpCut:              // MENU BOOLEAN - CUT
438   case GEOMOp::OpSection:          // MENU BOOLEAN - SECTION
439     libName = "BooleanGUI";
440     break;
441   case GEOMOp::OpTranslate:        // MENU TRANSFORMATION - TRANSLATION
442   case GEOMOp::OpRotate:           // MENU TRANSFORMATION - ROTATION
443   case GEOMOp::OpChangeLoc:        // MENU TRANSFORMATION - LOCATION
444   case GEOMOp::OpMirror:           // MENU TRANSFORMATION - MIRROR
445   case GEOMOp::OpScale:            // MENU TRANSFORMATION - SCALE
446   case GEOMOp::OpOffset:           // MENU TRANSFORMATION - OFFSET
447   case GEOMOp::OpMultiTranslate:   // MENU TRANSFORMATION - MULTI-TRANSLATION
448   case GEOMOp::OpMultiRotate:      // MENU TRANSFORMATION - MULTI-ROTATION
449   case GEOMOp::OpReimport:         // CONTEXT(POPUP) MENU - RELOAD_IMPORTED
450     libName = "TransformationGUI";
451     break;
452   case GEOMOp::OpPartition:        // MENU OPERATION - PARTITION
453   case GEOMOp::OpArchimede:        // MENU OPERATION - ARCHIMEDE
454   case GEOMOp::OpFillet3d:         // MENU OPERATION - FILLET
455   case GEOMOp::OpChamfer:          // MENU OPERATION - CHAMFER
456   case GEOMOp::OpClipping:         // MENU OPERATION - CLIPPING RANGE
457   case GEOMOp::OpShapesOnShape:    // MENU OPERATION - GET SHAPES ON SHAPE
458   case GEOMOp::OpFillet2d:         // MENU OPERATION - FILLET 2D
459   case GEOMOp::OpFillet1d:         // MENU OPERATION - FILLET 1D
460     libName = "OperationGUI";
461     break;
462   case GEOMOp::OpSewing:           // MENU REPAIR - SEWING
463   case GEOMOp::OpSuppressFaces:    // MENU REPAIR - SUPPRESS FACES
464   case GEOMOp::OpSuppressHoles:    // MENU REPAIR - SUPPRESS HOLE
465   case GEOMOp::OpShapeProcess:     // MENU REPAIR - SHAPE PROCESSING
466   case GEOMOp::OpCloseContour:     // MENU REPAIR - CLOSE CONTOUR
467   case GEOMOp::OpRemoveIntWires:   // MENU REPAIR - REMOVE INTERNAL WIRES
468   case GEOMOp::OpAddPointOnEdge:   // MENU REPAIR - ADD POINT ON EDGE
469   case GEOMOp::OpFreeBoundaries:   // MENU MEASURE - FREE BOUNDARIES
470   case GEOMOp::OpFreeFaces:        // MENU MEASURE - FREE FACES
471   case GEOMOp::OpOrientation:      // MENU REPAIR - CHANGE ORIENTATION
472   case GEOMOp::OpGlueFaces:        // MENU REPAIR - GLUE FACES
473   case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
474     libName = "RepairGUI";
475     break;
476   case GEOMOp::OpProperties:       // MENU MEASURE - PROPERTIES
477   case GEOMOp::OpCenterMass:       // MENU MEASURE - CDG
478   case GEOMOp::OpInertia:          // MENU MEASURE - INERTIA
479   case GEOMOp::OpNormale:          // MENU MEASURE - NORMALE
480   case GEOMOp::OpBoundingBox:      // MENU MEASURE - BOUNDING BOX
481   case GEOMOp::OpMinDistance:      // MENU MEASURE - MIN DISTANCE
482   case GEOMOp::OpAngle:            // MENU MEASURE - ANGLE
483   case GEOMOp::OpTolerance:        // MENU MEASURE - TOLERANCE
484   case GEOMOp::OpWhatIs:           // MENU MEASURE - WHATIS
485   case GEOMOp::OpCheckShape:       // MENU MEASURE - CHECK
486   case GEOMOp::OpCheckCompound:    // MENU MEASURE - CHECK COMPOUND OF BLOCKS
487   case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
488     libName = "MeasureGUI";
489     break;
490   case GEOMOp::OpGroupCreate:      // MENU GROUP - CREATE
491   case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
492   case GEOMOp::OpGroupEdit:        // MENU GROUP - EDIT
493     libName = "GroupGUI";
494     break;
495   case GEOMOp::OpHexaSolid:        // MENU BLOCKS - HEXAHEDRAL SOLID
496   case GEOMOp::OpMultiTransform:   // MENU BLOCKS - MULTI-TRANSFORMATION
497   case GEOMOp::OpQuadFace:         // MENU BLOCKS - QUADRANGLE FACE
498   case GEOMOp::OpPropagate:        // MENU BLOCKS - PROPAGATE
499   case GEOMOp::OpExplodeBlock:     // MENU BLOCKS - EXPLODE ON BLOCKS
500     libName = "BlocksGUI";
501     break;
502   default:
503     break;
504   }
505
506   GEOMGUI* library = 0;
507   if ( !libName.isEmpty() ) {
508 #ifndef WNT
509     libName = QString( "lib" ) + libName + ".so";
510 #else
511     libName = libName + ".dll";
512 #endif
513     library = getLibrary( libName );
514   }
515
516   // call method of corresponding GUI library
517   if ( library )
518     library->OnGUIEvent( id, desk );
519   else
520     SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
521 }
522
523 //=================================================================================
524 // function : GeometryGUI::OnKeyPress()
525 // purpose  : Called when any key is pressed by user [static]
526 //=================================================================================
527 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* w, QKeyEvent* e )
528 {
529   if ( !application() )
530     return;
531   foreach ( GEOMGUI* lib, myGUIMap )
532     lib->OnKeyPress( e, application()->desktop(), w );
533 }
534
535 //=================================================================================
536 // function : GeometryGUI::OnMouseMove()
537 // purpose  : Manages mouse move events [static]
538 //=================================================================================
539 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* w, QMouseEvent* e )
540 {
541   if ( !application() )
542     return;
543   foreach ( GEOMGUI* lib, myGUIMap )
544     lib->OnMouseMove( e, application()->desktop(), w );
545 }
546
547 //=================================================================================
548 // function : GeometryGUI::OnMousePress()
549 // purpose  : Manage mouse press events [static]
550 //=================================================================================
551 void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
552 {
553   if ( !application() )
554     return;
555   foreach ( GEOMGUI* lib, myGUIMap )
556     lib->OnMousePress( e, application()->desktop(), w );
557 }
558
559 //=======================================================================
560 // function : createGeomAction
561 // purpose  :
562 //=======================================================================
563 void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, const int accel, const bool toggle  )
564 {
565   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
566   QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
567                                     : resMgr->loadPixmap( "GEOM", tr( icolabel.toLatin1().constData() ) );
568   createAction( id,
569                 tr( QString( "TOP_%1" ).arg( label ).toLatin1().constData() ),
570                 icon,
571                 tr( QString( "MEN_%1" ).arg( label ).toLatin1().constData() ), 
572                 tr( QString( "STB_%1" ).arg( label ).toLatin1().constData() ),
573                 accel,
574                 application()->desktop(),
575                 toggle,
576                 this, SLOT( OnGUIEvent() )  );
577 }
578
579
580
581 //=======================================================================
582 // function : GeometryGUI::initialize()
583 // purpose  : Called when GEOM module is created
584 //=======================================================================
585 void GeometryGUI::initialize( CAM_Application* app )
586 {
587   SalomeApp_Module::initialize( app );
588
589   // ----- create actions --------------
590
591   createGeomAction( GEOMOp::OpImport,     "IMPORT", "", Qt::ControlModifier + Qt::Key_I );
592   createGeomAction( GEOMOp::OpExport,     "EXPORT", "", Qt::ControlModifier + Qt::Key_E );
593
594   createGeomAction( GEOMOp::OpDelete,     "DELETE", "", Qt::Key_Delete );
595
596   createGeomAction( GEOMOp::OpPoint,      "POINT" );
597   createGeomAction( GEOMOp::OpLine,       "LINE" );
598   createGeomAction( GEOMOp::OpCircle,     "CIRCLE" );
599   createGeomAction( GEOMOp::OpEllipse,    "ELLIPSE" );
600   createGeomAction( GEOMOp::OpArc,        "ARC" );
601   createGeomAction( GEOMOp::OpCurve,      "CURVE" );
602   createGeomAction( GEOMOp::OpVector,     "VECTOR" );
603   createGeomAction( GEOMOp::OpPlane,      "PLANE" );
604   createGeomAction( GEOMOp::OpLCS,        "LOCAL_CS" );
605
606   createGeomAction( GEOMOp::OpBox,        "BOX" );
607   createGeomAction( GEOMOp::OpCylinder,   "CYLINDER" );
608   createGeomAction( GEOMOp::OpSphere,     "SPHERE" );
609   createGeomAction( GEOMOp::OpTorus,      "TORUS" );
610   createGeomAction( GEOMOp::OpCone,       "CONE" );
611   createGeomAction( GEOMOp::OpRectangle,  "RECTANGLE" );
612   createGeomAction( GEOMOp::OpDisk,       "DISK" );
613
614   createGeomAction( GEOMOp::OpPrism,       "EXTRUSION" );
615   createGeomAction( GEOMOp::OpRevolution,  "REVOLUTION" );
616   createGeomAction( GEOMOp::OpFilling,     "FILLING" );
617   createGeomAction( GEOMOp::OpPipe,        "PIPE" );
618
619   createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
620   createGeomAction( GEOMOp::OpGroupEdit,   "GROUP_EDIT" );
621
622   createGeomAction( GEOMOp::OpReimport,    "RELOAD_IMPORTED" );
623
624   createGeomAction( GEOMOp::OpQuadFace,    "Q_FACE" );
625   createGeomAction( GEOMOp::OpHexaSolid,   "HEX_SOLID" );
626
627   createGeomAction( GEOMOp::Op2dSketcher,  "SKETCH" );
628   createGeomAction( GEOMOp::Op3dSketcher,  "3DSKETCH" );
629   createGeomAction( GEOMOp::OpExplode,     "EXPLODE" );
630
631   createGeomAction( GEOMOp::OpEdge,        "EDGE" );
632   createGeomAction( GEOMOp::OpWire,        "WIRE" );
633   createGeomAction( GEOMOp::OpFace,        "FACE" );
634   createGeomAction( GEOMOp::OpShell,       "SHELL" );
635   createGeomAction( GEOMOp::OpSolid,       "SOLID" );
636   createGeomAction( GEOMOp::OpCompound,    "COMPOUND" );
637
638   createGeomAction( GEOMOp::OpFuse,        "FUSE" );
639   createGeomAction( GEOMOp::OpCommon,      "COMMON" );
640   createGeomAction( GEOMOp::OpCut,         "CUT" );
641   createGeomAction( GEOMOp::OpSection,     "SECTION" );
642
643   createGeomAction( GEOMOp::OpTranslate,      "TRANSLATION" );
644   createGeomAction( GEOMOp::OpRotate,         "ROTATION" );
645   createGeomAction( GEOMOp::OpChangeLoc,      "MODIFY_LOCATION" );
646   createGeomAction( GEOMOp::OpMirror,         "MIRROR" );
647   createGeomAction( GEOMOp::OpScale,          "SCALE" );
648   createGeomAction( GEOMOp::OpOffset,         "OFFSET" );
649   createGeomAction( GEOMOp::OpMultiTranslate, "MUL_TRANSLATION" );
650   createGeomAction( GEOMOp::OpMultiRotate,    "MUL_ROTATION" );
651
652   createGeomAction( GEOMOp::OpPartition,      "PARTITION" );
653   createGeomAction( GEOMOp::OpArchimede,      "ARCHIMEDE" );
654   createGeomAction( GEOMOp::OpFillet3d,       "FILLET" );
655   createGeomAction( GEOMOp::OpChamfer,        "CHAMFER" );
656   //createGeomAction( GEOMOp::OpClipping,        "CLIPPING" );
657   createGeomAction( GEOMOp::OpShapesOnShape,  "GET_SHAPES_ON_SHAPES" );
658   createGeomAction( GEOMOp::OpFillet1d,       "FILLET_1D" );
659   createGeomAction( GEOMOp::OpFillet2d,       "FILLET_2D" );
660
661   createGeomAction( GEOMOp::OpMultiTransform, "MUL_TRANSFORM" );
662   createGeomAction( GEOMOp::OpExplodeBlock,   "EXPLODE_BLOCKS" );
663   createGeomAction( GEOMOp::OpPropagate,      "PROPAGATE" );
664
665   createGeomAction( GEOMOp::OpSewing,           "SEWING" );
666   createGeomAction( GEOMOp::OpGlueFaces,        "GLUE_FACES" );
667   createGeomAction( GEOMOp::OpSuppressFaces,    "SUPPRESS_FACES" );
668   createGeomAction( GEOMOp::OpSuppressHoles,    "SUPPERSS_HOLES" );
669   createGeomAction( GEOMOp::OpShapeProcess,     "SHAPE_PROCESS" );
670   createGeomAction( GEOMOp::OpCloseContour,     "CLOSE_CONTOUR" );
671   createGeomAction( GEOMOp::OpRemoveIntWires,   "SUPPRESS_INT_WIRES" );
672   createGeomAction( GEOMOp::OpAddPointOnEdge,   "POINT_ON_EDGE" );
673   createGeomAction( GEOMOp::OpFreeBoundaries,   "CHECK_FREE_BNDS" );
674   createGeomAction( GEOMOp::OpFreeFaces,        "CHECK_FREE_FACES" );
675   createGeomAction( GEOMOp::OpOrientation,      "CHANGE_ORIENTATION" );
676   createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
677
678   createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
679   createGeomAction( GEOMOp::OpProperties,       "BASIC_PROPS" );
680   createGeomAction( GEOMOp::OpCenterMass,       "MASS_CENTER" );
681   createGeomAction( GEOMOp::OpInertia,          "INERTIA" );
682   createGeomAction( GEOMOp::OpNormale,          "NORMALE" );
683   createGeomAction( GEOMOp::OpBoundingBox,      "BND_BOX" );
684   createGeomAction( GEOMOp::OpMinDistance,      "MIN_DIST" );
685   createGeomAction( GEOMOp::OpAngle,            "MEASURE_ANGLE" );
686
687   createGeomAction( GEOMOp::OpTolerance,        "TOLERANCE" );
688   createGeomAction( GEOMOp::OpWhatIs,           "WHAT_IS" );
689   createGeomAction( GEOMOp::OpCheckShape,       "CHECK" );
690   createGeomAction( GEOMOp::OpCheckCompound,    "CHECK_COMPOUND" );
691
692 #ifdef _DEBUG_ // PAL16821
693   createGeomAction( GEOMOp::OpCheckGeom,        "CHECK_GEOMETRY" );
694 #endif
695
696   createGeomAction( GEOMOp::OpDisplayMode,      "SHADING" );
697   createGeomAction( GEOMOp::OpShowAll,          "DISPLAY_ALL" );
698   createGeomAction( GEOMOp::OpHideAll,          "ERASE_ALL" );
699   createGeomAction( GEOMOp::OpShow,             "DISPLAY" );
700   createGeomAction( GEOMOp::OpSwitchVectors,    "VECTOR_MODE");
701   createGeomAction( GEOMOp::OpSelectVertex,     "VERTEX_SEL_ONLY" ,"", 0, true );
702   createGeomAction( GEOMOp::OpSelectEdge,       "EDGE_SEL_ONLY", "", 0, true );
703   createGeomAction( GEOMOp::OpSelectWire,       "WIRE_SEL_ONLY", "",  0, true );
704   createGeomAction( GEOMOp::OpSelectFace,       "FACE_SEL_ONLY", "", 0, true );
705   createGeomAction( GEOMOp::OpSelectShell,      "SHELL_SEL_ONLY", "",  0, true );
706   createGeomAction( GEOMOp::OpSelectSolid,      "SOLID_SEL_ONLY", "", 0, true );
707   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
708   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
709   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
710   createGeomAction( GEOMOp::OpHide,             "ERASE" );
711
712   createGeomAction( GEOMOp::OpRename,           "POP_RENAME", "", Qt::Key_F2 );
713   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
714   createGeomAction( GEOMOp::OpShading,          "POP_SHADING", "", 0, true );
715   createGeomAction( GEOMOp::OpVectors,          "POP_VECTORS", "", 0, true );
716   createGeomAction( GEOMOp::OpDeflection,       "POP_DEFLECTION" );
717   createGeomAction( GEOMOp::OpColor,            "POP_COLOR" );
718   createGeomAction( GEOMOp::OpTransparency,     "POP_TRANSPARENCY" );
719   createGeomAction( GEOMOp::OpIsos,             "POP_ISOS" );
720   createGeomAction( GEOMOp::OpAutoColor,        "POP_AUTO_COLOR" );
721   createGeomAction( GEOMOp::OpNoAutoColor,      "POP_DISABLE_AUTO_COLOR" );
722   createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
723   createGeomAction( GEOMOp::OpShowChildren,     "POP_SHOW_CHILDREN" );
724   createGeomAction( GEOMOp::OpHideChildren,     "POP_HIDE_CHILDREN" );
725   createGeomAction( GEOMOp::OpPointMarker,      "POP_POINT_MARKER" );
726
727   // ---- create menus --------------------------
728
729   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
730   createMenu( separator(),      fileId, 10 );
731   createMenu( GEOMOp::OpImport, fileId, 10 );
732   createMenu( GEOMOp::OpExport, fileId, 10 );
733   createMenu( separator(),      fileId, -1 );
734
735   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
736   createMenu( GEOMOp::OpDelete, editId, -1 );
737
738   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
739
740   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
741   createMenu( GEOMOp::OpPoint,   basicId, -1 );
742   createMenu( GEOMOp::OpLine,    basicId, -1 );
743   createMenu( GEOMOp::OpCircle,  basicId, -1 );
744   createMenu( GEOMOp::OpEllipse, basicId, -1 );
745   createMenu( GEOMOp::OpArc,     basicId, -1 );
746   createMenu( GEOMOp::OpCurve,   basicId, -1 );
747   createMenu( separator(),       basicId, -1 );
748   createMenu( GEOMOp::OpVector,  basicId, -1 );
749   createMenu( GEOMOp::OpPlane,   basicId, -1 );
750   createMenu( GEOMOp::OpLCS,     basicId, -1 );
751
752   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
753   createMenu( GEOMOp::OpBox,       primId, -1 );
754   createMenu( GEOMOp::OpCylinder,  primId, -1 );
755   createMenu( GEOMOp::OpSphere,    primId, -1 );
756   createMenu( GEOMOp::OpTorus,     primId, -1 );
757   createMenu( GEOMOp::OpCone,      primId, -1 );
758   createMenu( GEOMOp::OpRectangle, primId, -1 );
759   createMenu( GEOMOp::OpDisk,      primId, -1 );
760
761   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
762   createMenu( GEOMOp::OpPrism,      genId, -1 );
763   createMenu( GEOMOp::OpRevolution, genId, -1 );
764   createMenu( GEOMOp::OpFilling,    genId, -1 );
765   createMenu( GEOMOp::OpPipe,       genId, -1 );
766
767   createMenu( separator(), newEntId, -1 );
768
769   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
770   createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
771   createMenu( GEOMOp::OpGroupEdit,   groupId, -1 );
772
773   createMenu( separator(), newEntId, -1 );
774
775   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
776   createMenu( GEOMOp::OpQuadFace,  blocksId, -1 );
777   createMenu( GEOMOp::OpHexaSolid, blocksId, -1 );
778
779   createMenu( separator(),          newEntId, -1 );
780
781   createMenu( GEOMOp::Op2dSketcher, newEntId, -1 );
782   createMenu( GEOMOp::Op3dSketcher, newEntId, -1 );
783
784   createMenu( separator(),          newEntId, -1 );
785
786   createMenu( GEOMOp::OpExplode,    newEntId, -1 );
787
788   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
789   createMenu( GEOMOp::OpEdge,     buildId, -1 );
790   createMenu( GEOMOp::OpWire,     buildId, -1 );
791   createMenu( GEOMOp::OpFace,     buildId, -1 );
792   createMenu( GEOMOp::OpShell,    buildId, -1 );
793   createMenu( GEOMOp::OpSolid,    buildId, -1 );
794   createMenu( GEOMOp::OpCompound, buildId, -1 );
795
796   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
797
798   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
799   createMenu( GEOMOp::OpFuse,    boolId, -1 );
800   createMenu( GEOMOp::OpCommon,  boolId, -1 );
801   createMenu( GEOMOp::OpCut,     boolId, -1 );
802   createMenu( GEOMOp::OpSection, boolId, -1 );
803
804   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
805   createMenu( GEOMOp::OpTranslate,      transId, -1 );
806   createMenu( GEOMOp::OpRotate,         transId, -1 );
807   createMenu( GEOMOp::OpChangeLoc,      transId, -1 );
808   createMenu( GEOMOp::OpMirror,         transId, -1 );
809   createMenu( GEOMOp::OpScale,          transId, -1 );
810   createMenu( GEOMOp::OpOffset,         transId, -1 );
811   createMenu( separator(),              transId, -1 );
812   createMenu( GEOMOp::OpMultiTranslate, transId, -1 );
813   createMenu( GEOMOp::OpMultiRotate,    transId, -1 );
814
815   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
816   createMenu( GEOMOp::OpMultiTransform, blockId, -1 );
817   createMenu( GEOMOp::OpExplodeBlock,   blockId, -1 );
818   createMenu( GEOMOp::OpPropagate,      blockId, -1 );
819
820   createMenu( separator(), operId, -1 );
821
822   createMenu( GEOMOp::OpPartition,     operId, -1 );
823   createMenu( GEOMOp::OpArchimede,     operId, -1 );
824   createMenu( GEOMOp::OpShapesOnShape, operId, -1 );
825
826   createMenu( separator(), operId, -1 );
827
828   createMenu( GEOMOp::OpFillet1d,      operId, -1 );
829   createMenu( GEOMOp::OpFillet2d,      operId, -1 );
830   createMenu( GEOMOp::OpFillet3d,      operId, -1 );
831   createMenu( GEOMOp::OpChamfer,       operId, -1 );
832   //createMenu( GEOMOp::OpClipping,      operId, -1 );
833
834   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
835   createMenu( GEOMOp::OpShapeProcess,    repairId, -1 );
836   createMenu( GEOMOp::OpSuppressFaces,   repairId, -1 );
837   createMenu( GEOMOp::OpCloseContour,    repairId, -1 );
838   createMenu( GEOMOp::OpRemoveIntWires,  repairId, -1 );
839   createMenu( GEOMOp::OpSuppressHoles,   repairId, -1 );
840   createMenu( GEOMOp::OpSewing,          repairId, -1 );
841   createMenu( GEOMOp::OpGlueFaces,       repairId, -1 );
842   createMenu( GEOMOp::OpAddPointOnEdge,  repairId, -1 );
843   //createMenu( GEOMOp::OpFreeBoundaries,  repairId, -1 );
844   //createMenu( GEOMOp::OpFreeFaces,       repairId, -1 );
845   createMenu( GEOMOp::OpOrientation,      repairId, -1 );
846   createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
847
848   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
849   createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
850   createMenu( GEOMOp::OpProperties,       measurId, -1 );
851   createMenu( separator(),                measurId, -1 );
852   createMenu( GEOMOp::OpCenterMass,       measurId, -1 );
853   createMenu( GEOMOp::OpInertia,          measurId, -1 );
854   createMenu( GEOMOp::OpNormale,          measurId, -1 );
855   createMenu( separator(),                measurId, -1 );
856   createMenu( GEOMOp::OpFreeBoundaries,   measurId, -1 );
857   createMenu( GEOMOp::OpFreeFaces,        measurId, -1 );
858   createMenu( separator(),                measurId, -1 );
859
860   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
861   createMenu( GEOMOp::OpBoundingBox, dimId, -1 );
862   createMenu( GEOMOp::OpMinDistance, dimId, -1 );
863   createMenu( GEOMOp::OpAngle,       dimId, -1 );
864
865   createMenu( separator(),             measurId, -1 );
866   createMenu( GEOMOp::OpTolerance,     measurId, -1 );
867   createMenu( separator(),             measurId, -1 );
868   createMenu( GEOMOp::OpWhatIs,        measurId, -1 );
869   createMenu( GEOMOp::OpCheckShape,    measurId, -1 );
870   createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
871
872 #ifdef _DEBUG_ // PAL16821
873   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
874   createMenu( separator(),         toolsId, -1 );
875   createMenu( GEOMOp::OpCheckGeom, toolsId, -1 );
876 #endif
877
878   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
879   createMenu( separator(),       viewId, -1 );
880
881   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
882   createMenu( GEOMOp::OpDisplayMode,   dispmodeId, -1 );
883   createMenu( separator(),             dispmodeId, -1 );
884   createMenu( GEOMOp::OpSwitchVectors, dispmodeId, -1 );
885
886   createMenu( separator(),       viewId, -1 );
887   createMenu( GEOMOp::OpShowAll, viewId, -1 );
888   createMenu( GEOMOp::OpHideAll, viewId, -1 );
889   createMenu( separator(),       viewId, -1 );
890
891 /*
892   PAL9111:
893   because of these items are accessible through object browser and viewers
894   we have removed they from main menu
895
896   createMenu( GEOMOp::OpShow, viewId, -1 );
897   createMenu( GEOMOp::OpShowOnly, viewId, -1 );
898   createMenu( GEOMOp::OpHide, viewId, -1 );
899 */
900
901   // ---- create toolbars --------------------------
902
903   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
904   createTool( GEOMOp::OpPoint,   basicTbId );
905   createTool( GEOMOp::OpLine,    basicTbId );
906   createTool( GEOMOp::OpCircle,  basicTbId );
907   createTool( GEOMOp::OpEllipse, basicTbId );
908   createTool( GEOMOp::OpArc,     basicTbId );
909   createTool( GEOMOp::OpCurve,   basicTbId );
910   createTool( GEOMOp::OpVector,  basicTbId );
911   createTool( GEOMOp::OpPlane,   basicTbId );
912   createTool( GEOMOp::OpLCS,     basicTbId );
913
914   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
915   createTool( GEOMOp::OpBox,       primTbId );
916   createTool( GEOMOp::OpCylinder,  primTbId );
917   createTool( GEOMOp::OpSphere,    primTbId );
918   createTool( GEOMOp::OpTorus,     primTbId );
919   createTool( GEOMOp::OpCone,      primTbId );
920   createTool( GEOMOp::OpRectangle, primTbId );
921   createTool( GEOMOp::OpDisk,      primTbId );
922
923   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
924   createTool( GEOMOp::OpFuse,    boolTbId );
925   createTool( GEOMOp::OpCommon,  boolTbId );
926   createTool( GEOMOp::OpCut,     boolTbId );
927   createTool( GEOMOp::OpSection, boolTbId );
928
929   int genTbId = createTool( tr( "TOOL_GENERATION" ) );
930   createTool( GEOMOp::OpPrism,      genTbId );
931   createTool( GEOMOp::OpRevolution, genTbId );
932   createTool( GEOMOp::OpFilling,    genTbId );
933   createTool( GEOMOp::OpPipe,       genTbId );
934
935   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
936   createTool( GEOMOp::OpTranslate,      transTbId );
937   createTool( GEOMOp::OpRotate,         transTbId );
938   createTool( GEOMOp::OpChangeLoc,      transTbId );
939   createTool( GEOMOp::OpMirror,         transTbId );
940   createTool( GEOMOp::OpScale,          transTbId );
941   createTool( GEOMOp::OpOffset,         transTbId );
942   createTool( separator(),              transTbId );
943   createTool( GEOMOp::OpMultiTranslate, transTbId );
944   createTool( GEOMOp::OpMultiRotate,    transTbId );
945
946   int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
947   createTool( GEOMOp::Op2dSketcher,      operTbId );
948   createTool( GEOMOp::Op3dSketcher,      operTbId );
949   createTool( separator(),               operTbId );
950   createTool( GEOMOp::OpExplode,         operTbId );
951   createTool( separator(),               operTbId );
952   createTool( GEOMOp::OpPartition,       operTbId );
953   createTool( GEOMOp::OpArchimede,       operTbId );
954   createTool( GEOMOp::OpShapesOnShape,   operTbId );
955   createTool( separator(),               operTbId );
956   createTool( GEOMOp::OpFillet1d,        operTbId );
957   createTool( GEOMOp::OpFillet2d,        operTbId );
958   createTool( GEOMOp::OpFillet3d,        operTbId );
959   createTool( GEOMOp::OpChamfer,         operTbId );
960
961   int buildTbId = createTool( tr( "TOOL_BUILD" ) );
962   createTool( GEOMOp::OpEdge,     buildTbId );
963   createTool( GEOMOp::OpWire,     buildTbId );
964   createTool( GEOMOp::OpFace,     buildTbId );
965   createTool( GEOMOp::OpShell,    buildTbId );
966   createTool( GEOMOp::OpSolid,    buildTbId );
967   createTool( GEOMOp::OpCompound, buildTbId );
968
969   // ---- create popup menus --------------------------
970
971   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
972   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
973
974   QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
975   QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
976
977   QString autoColorPrefix =
978     "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
979
980   QtxPopupMgr* mgr = popupMgr();
981   mgr->insert( action(  GEOMOp::OpRename ), -1, -1 );  // rename
982   mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
983   mgr->insert( action(  GEOMOp::OpDelete ), -1, -1 );  // delete
984   mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
985   mgr->insert( action(  GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
986   mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
987   mgr->insert( action(  GEOMOp::OpShowChildren ), -1, -1 ); // show children
988   mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
989   mgr->insert( action(  GEOMOp::OpHideChildren ), -1, -1 ); // hide children
990   mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
991   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
992   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
993   mgr->insert( separator(), -1, -1 );     // -----------
994   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
995   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
996   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
997   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule );
998   mgr->insert( action(  GEOMOp::OpShading ), dispmodeId, -1 ); // shading
999   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1000   mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
1001   mgr->insert( separator(), dispmodeId, -1 );
1002   mgr->insert( action(  GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
1003   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1004   mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
1005   mgr->insert( separator(), -1, -1 );     // -----------
1006   mgr->insert( action(  GEOMOp::OpColor ), -1, -1 ); // color
1007   mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
1008   mgr->insert( action(  GEOMOp::OpTransparency ), -1, -1 ); // transparency
1009   mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
1010   mgr->insert( action(  GEOMOp::OpIsos ), -1, -1 ); // isos
1011   mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1012   mgr->insert( action(  GEOMOp::OpDeflection ), -1, -1 ); // deflection
1013   mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
1014   mgr->insert( action(  GEOMOp::OpPointMarker ), -1, -1 ); // point marker
1015   mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg( GEOM_POINT ), QtxPopupMgr::VisibleRule );
1016   mgr->insert( separator(), -1, -1 );     // -----------
1017   mgr->insert( action(  GEOMOp::OpAutoColor ), -1, -1 ); // auto color
1018   mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
1019   mgr->insert( action(  GEOMOp::OpNoAutoColor ), -1, -1 ); // disable auto color
1020   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
1021   mgr->insert( separator(), -1, -1 );     // -----------
1022
1023   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1024           onlyComponent = "((type='Component') and selcount=1)",
1025           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1026           types = "'Shape' 'Group'";
1027
1028   mgr->insert( action(  GEOMOp::OpShow ), -1, -1 ); // display
1029   mgr->setRule( action( GEOMOp::OpShow ), rule.arg( types ).arg( "not isVisible" ), QtxPopupMgr::VisibleRule );
1030
1031   mgr->insert( action(  GEOMOp::OpHide ), -1, -1 ); // erase
1032   mgr->setRule( action( GEOMOp::OpHide ), rule.arg( types ).arg( "isVisible" ), QtxPopupMgr::VisibleRule );
1033
1034   mgr->insert( action(  GEOMOp::OpHideAll ), -1, -1 ); // erase All
1035   mgr->setRule( action( GEOMOp::OpHideAll ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
1036
1037   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1038
1039   int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
1040   mgr->insert( action(GEOMOp::OpSelectVertex),   selectolnyId, -1);                                  //Vertex
1041   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly, QtxPopupMgr::VisibleRule);
1042   mgr->setRule(action(GEOMOp::OpSelectVertex),   selectOnly + " and selectionmode='VERTEX'", QtxPopupMgr::ToggleRule);
1043   mgr->insert( action(GEOMOp::OpSelectEdge),     selectolnyId, -1);                                  //Edge
1044   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly, QtxPopupMgr::VisibleRule);
1045   mgr->setRule(action(GEOMOp::OpSelectEdge),     selectOnly + " and selectionmode='EDGE'", QtxPopupMgr::ToggleRule);
1046   mgr->insert( action(GEOMOp::OpSelectWire),     selectolnyId, -1);                                  //Wire
1047   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly, QtxPopupMgr::VisibleRule);
1048   mgr->setRule(action(GEOMOp::OpSelectWire),     selectOnly + " and selectionmode='WIRE'", QtxPopupMgr::ToggleRule);
1049   mgr->insert( action(GEOMOp::OpSelectFace),     selectolnyId, -1);                                  //Face
1050   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly, QtxPopupMgr::VisibleRule);
1051   mgr->setRule(action(GEOMOp::OpSelectFace),     selectOnly + " and selectionmode='FACE'", QtxPopupMgr::ToggleRule);
1052   mgr->insert( action(GEOMOp::OpSelectShell),    selectolnyId, -1);                                  //Shell
1053   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly, QtxPopupMgr::VisibleRule);
1054   mgr->setRule(action(GEOMOp::OpSelectShell),    selectOnly + " and selectionmode='SHELL'", QtxPopupMgr::ToggleRule);
1055   mgr->insert( action(GEOMOp::OpSelectSolid),    selectolnyId, -1);                                  //Solid
1056   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly, QtxPopupMgr::VisibleRule);
1057   mgr->setRule(action(GEOMOp::OpSelectSolid),    selectOnly + " and selectionmode='SOLID'", QtxPopupMgr::ToggleRule);
1058   mgr->insert( action(GEOMOp::OpSelectCompound), selectolnyId, -1);                                  //Compound
1059   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly, QtxPopupMgr::VisibleRule);
1060   mgr->setRule(action(GEOMOp::OpSelectCompound), selectOnly + " and selectionmode='COMPOUND'", QtxPopupMgr::ToggleRule);
1061   mgr->insert( separator(), selectolnyId, -1);
1062   mgr->insert( action(GEOMOp::OpSelectAll),      selectolnyId, -1);                                  //Clear selection filter
1063   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly, QtxPopupMgr::VisibleRule);
1064   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
1065   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
1066   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
1067   mgr->insert( separator(), -1, -1 );
1068
1069   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1070 }
1071
1072 //=======================================================================
1073 // function : GeometryGUI::activateModule()
1074 // purpose  : Called when GEOM module is activated
1075 //=======================================================================
1076 bool GeometryGUI::activateModule( SUIT_Study* study )
1077 {
1078   if ( CORBA::is_nil( myComponentGeom ) )
1079     return false;
1080
1081   bool res = SalomeApp_Module::activateModule( study );
1082
1083   if ( !res )
1084     return false;
1085
1086   setMenuShown( true );
1087   setToolShown( true );
1088
1089   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1090           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1091
1092   // Reset actions accelerator keys
1093   action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
1094   action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
1095   action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
1096   action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2
1097
1098   GUIMap::Iterator it;
1099   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1100     it.value()->activate( application()->desktop() );
1101
1102   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1103
1104   SUIT_ViewManager* vm;
1105   ViewManagerList OCCViewManagers, VTKViewManagers;
1106
1107   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1108   QListIterator<SUIT_ViewManager*> itOCC( OCCViewManagers );
1109   while ( itOCC.hasNext() && (vm = itOCC.next()) )
1110     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1111
1112   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1113   QListIterator<SUIT_ViewManager*> itVTK( VTKViewManagers );
1114   while ( itVTK.hasNext() && (vm = itVTK.next()) )
1115     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1116
1117   //NPAL 19674
1118   SALOME_ListIO selected;
1119   sm->selectedObjects( selected );
1120   sm->clearSelected();
1121   
1122   // disable OCC selectors
1123   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1124   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1125   while ( itOCCSel.hasNext() )
1126     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1127       sr->setEnabled(true);
1128
1129   // disable VTK selectors
1130   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1131   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1132   while ( itVTKSel.hasNext() )
1133     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1134       sr->setEnabled(true);
1135
1136   sm->setSelectedObjects( selected, true );   //NPAL 19674
1137
1138   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1139   if ( viewMenu )
1140     connect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1141
1142   return true;
1143 }
1144
1145
1146 //=======================================================================
1147 // function : GeometryGUI::deactivateModule()
1148 // purpose  : Called when GEOM module is deactivated
1149 //=======================================================================
1150 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1151 {
1152   QMenu* viewMenu = menuMgr()->findMenu( STD_Application::MenuViewId );
1153   if ( viewMenu )
1154     disconnect( viewMenu, SIGNAL( aboutToShow() ), this, SLOT( onViewAboutToShow() ) );
1155
1156   setMenuShown( false );
1157   setToolShown( false );
1158
1159   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1160              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1161
1162   EmitSignalCloseAllDialogs();
1163
1164   GUIMap::Iterator it;
1165   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1166     it.value()->deactivate();
1167
1168   // Unset actions accelerator keys
1169   action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
1170   action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
1171   action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
1172   action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2
1173
1174   qDeleteAll(myOCCSelectors);
1175   myOCCSelectors.clear();
1176   getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1177
1178   qDeleteAll(myVTKSelectors);
1179   myVTKSelectors.clear();
1180   getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1181
1182   return SalomeApp_Module::deactivateModule( study );
1183 }
1184
1185 //=======================================================================
1186 // function : onWindowActivated()
1187 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1188 //=======================================================================
1189 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1190 {
1191   if ( !win )
1192     return;
1193
1194   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1195   //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1196
1197   // disable non-OCC viewframe menu commands
1198 //  action( GEOMOp::Op2dSketcher )->setEnabled( ViewOCC ); // SKETCHER
1199   action( GEOMOp::OpSuppressFaces )->setEnabled( ViewOCC ); // SuppressFace
1200   action( GEOMOp::OpSuppressHoles )->setEnabled( ViewOCC ); // SuppressHole
1201   action( GEOMOp::OpCloseContour )->setEnabled( ViewOCC ); // CloseContour
1202   action( GEOMOp::OpRemoveIntWires )->setEnabled( ViewOCC ); // RemoveInternalWires
1203   action( GEOMOp::OpAddPointOnEdge )->setEnabled( ViewOCC ); // AddPointOnEdge
1204 //  action( GEOMOp::OpFreeBoundaries )->setEnabled( ViewOCC ); // Free boundaries
1205
1206   action( GEOMOp::OpGroupCreate )->setEnabled( ViewOCC ); // Create Group
1207   action( GEOMOp::OpGroupEdit )->setEnabled( ViewOCC ); // Edit Group
1208
1209   action( GEOMOp::OpMultiTransform )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1210 }
1211
1212 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1213 {
1214   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1215   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
1216 }
1217
1218 void GeometryGUI::viewManagers( QStringList& lst ) const
1219 {
1220   lst.append( OCCViewer_Viewer::Type() );
1221 }
1222
1223 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1224 {
1225   if ( vm->getType() == OCCViewer_Viewer::Type() )
1226   {
1227     qDebug( "connect" );
1228     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
1229              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1230     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1231              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1232     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1233              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1234
1235     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1236     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1237
1238     // disable OCC selectors
1239     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1240     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1241     while ( itOCCSel.hasNext() )
1242       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1243         sr->setEnabled(true);
1244   }
1245   else if ( vm->getType() == SVTK_Viewer::Type() )
1246   {
1247     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1248     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1249
1250     // disable VTK selectors
1251     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1252     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1253     while ( itVTKSel.hasNext() )
1254       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1255         sr->setEnabled(true);
1256   }
1257 }
1258
1259 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1260 {
1261   SUIT_ViewModel* viewer = vm->getViewModel();
1262   if ( vm->getType() == OCCViewer_Viewer::Type() )
1263   {
1264     QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
1265     while ( itOCCSel.hasNext() )
1266       if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
1267         if ( sr->viewer() == viewer )
1268         {
1269           delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) );
1270           break;
1271         }
1272   }
1273   if ( vm->getType() == SVTK_Viewer::Type() )
1274   {
1275     QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
1276     while ( itVTKSel.hasNext() )
1277       if ( LightApp_VTKSelector* sr = itVTKSel.next() )
1278         if ( sr->viewer() == viewer )
1279         {
1280           delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) );
1281           break;
1282         }
1283   }
1284 }
1285
1286 QString GeometryGUI::engineIOR() const
1287 {
1288   if ( !CORBA::is_nil( GetGeomGen() ) )
1289     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1290   return "";
1291 }
1292
1293 Handle(Graphic3d_HArray1OfBytes) GeometryGUI::getTexture( SalomeApp_Study* theStudy, int theId, int& theWidth, int& theHeight )
1294 {
1295   theWidth = theHeight = 0;
1296   Handle(Graphic3d_HArray1OfBytes) aTexture;
1297   if ( theStudy ) {
1298     TextureMap aTextureMap = myTextureMap[ theStudy->studyDS()->StudyId() ];
1299     aTexture = aTextureMap[ theId ];
1300     if ( aTexture.IsNull() ) {
1301       GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGen()->GetIInsertOperations( theStudy->studyDS()->StudyId() );
1302       if ( !aInsOp->_is_nil() ) {
1303         CORBA::Long aWidth, aHeight;
1304         SALOMEDS::TMPFile_var aStream = aInsOp->GetTexture( theId, aWidth, aHeight );
1305         if ( aWidth > 0 && aHeight > 0 && aStream->length() > 0 ) {
1306           theWidth  = aWidth;
1307           theHeight = aHeight;
1308           aTexture  = new Graphic3d_HArray1OfBytes( 1, aStream->length() );
1309           for ( int i = 0; i < aStream->length(); i++ )
1310             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
1311           aTextureMap[ theId ] = aTexture;
1312         }
1313       }
1314     }
1315   }
1316   return aTexture;
1317 }
1318
1319 LightApp_Selection* GeometryGUI::createSelection() const
1320 {
1321   return new GEOMGUI_Selection();
1322 }
1323
1324 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
1325 {
1326   SalomeApp_Module::contextMenuPopup(client, menu, title);
1327
1328   SALOME_ListIO lst;
1329   getApp()->selectionMgr()->selectedObjects(lst);
1330   if (lst.Extent() < 1)
1331     return;
1332
1333   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1334   _PTR(Study) study = appStudy->studyDS();
1335
1336   bool isImported = true;
1337   SALOME_ListIteratorOfListIO anIt (lst);
1338   for (; anIt.More() && isImported; anIt.Next()) {
1339     Handle(SALOME_InteractiveObject) io = anIt.Value();
1340     _PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
1341     if (aSObj) {
1342       if (lst.Extent() == 1) {
1343         // Set context menu title
1344         if (client == "OCCViewer" || client == "VTKViewer")
1345           title = QString(aSObj->GetName().c_str());
1346       }
1347
1348       CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
1349       GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
1350       if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
1351         isImported = false;
1352     } else {
1353       isImported = false;
1354     }
1355   }
1356
1357   if (isImported) {
1358     menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
1359   }
1360 }
1361
1362 void GeometryGUI::createPreferences()
1363 {
1364   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1365
1366   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1367   setPreferenceProperty( genGroup, "columns", 2 );
1368
1369   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1370                                 LightApp_Preferences::Selector, 
1371                                 "Geometry", "display_mode" );
1372
1373   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1374                  LightApp_Preferences::Color, "Geometry", "shading_color" );
1375
1376   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1377                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1378
1379   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1380                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1381
1382   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1383                  LightApp_Preferences::Color, "Geometry", "line_color" );
1384
1385   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1386                  LightApp_Preferences::Color, "Geometry", "point_color" );
1387
1388   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1389                  LightApp_Preferences::Color, "Geometry", "isos_color" );
1390
1391   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1392                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1393
1394   int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
1395                             LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
1396
1397   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1398   setPreferenceProperty( VertexGroup, "columns", 2 );
1399
1400   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1401                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1402
1403   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1404                                    LightApp_Preferences::Selector, "Geometry", "marker_scale" );
1405
1406   // Set property for default display mode
1407   QStringList aModesList;
1408   aModesList.append( tr("MEN_WIREFRAME") );
1409   aModesList.append( tr("MEN_SHADING") );
1410
1411   QList<QVariant> anIndexesList;
1412   anIndexesList.append(0);
1413   anIndexesList.append(1);
1414
1415   setPreferenceProperty( dispmode, "strings", aModesList );
1416   setPreferenceProperty( dispmode, "indexes", anIndexesList );
1417
1418   // Set property for step value for spinboxes
1419   setPreferenceProperty( step, "min", 1 );
1420   setPreferenceProperty( step, "max", 10000 );
1421   setPreferenceProperty( step, "precision", 3 );
1422
1423   // Set property for deflection value for spinboxes
1424   setPreferenceProperty( defl, "min", DEFLECTION_MIN );
1425   setPreferenceProperty( defl, "max", 1.0 );
1426   setPreferenceProperty( defl, "step", 1.0e-04 );
1427   setPreferenceProperty( defl, "precision", 6 );
1428
1429   // Set property vertex marker type
1430   QList<QVariant> aMarkerTypeIndicesList;
1431   QList<QVariant> aMarkerTypeIconsList;
1432
1433   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1434   for ( int i = GEOM::MT_POINT; i < GEOM::MT_USER; i++ ) {
1435     QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
1436     QPixmap pixmap = resMgr->loadPixmap( "GEOM", tr( qPrintable( icoFile ) ) );
1437     aMarkerTypeIndicesList << (i-1);
1438     aMarkerTypeIconsList << pixmap;
1439   }
1440
1441   setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
1442   setPreferenceProperty( typeOfMarker, "icons",   aMarkerTypeIconsList );
1443
1444   // Set property for vertex marker scale
1445   QList<QVariant> aMarkerScaleIndicesList;
1446   QStringList     aMarkerScaleValuesList;
1447
1448   for ( int i = GEOM::MS_10; i <= GEOM::MS_70; i++ ) {
1449     aMarkerScaleIndicesList << i;
1450     aMarkerScaleValuesList  << QString::number( (i-(int)GEOM::MS_10)*0.5 + 1.0 );
1451   }
1452
1453   setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
1454   setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
1455 }
1456
1457 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1458 {
1459   if (section == "Geometry") {
1460     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1461     if (param == QString("SettingsGeomStep")) {
1462       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1463       EmitSignalDefaultStepValueChanged(spin_step);
1464     }
1465   }
1466 }
1467
1468 LightApp_Displayer* GeometryGUI::displayer()
1469 {
1470   if( !myDisplayer )
1471     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1472   return myDisplayer;
1473 }
1474
1475 void GeometryGUI::setLocalSelectionMode(const int mode)
1476 {
1477   myLocalSelectionMode = mode;
1478 }
1479 int GeometryGUI::getLocalSelectionMode() const
1480 {
1481   return myLocalSelectionMode;
1482 }
1483
1484 const char gSeparator = '_'; // character used to separate parameter names
1485 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1486
1487 /*!
1488  * \brief Store visual parameters
1489  *
1490  * This method is called just before the study document is saved.
1491  * Store visual parameters in AttributeParameter attribue(s)
1492  */
1493 void GeometryGUI::storeVisualParameters (int savePoint)
1494 {
1495   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1496   if (!appStudy || !appStudy->studyDS())
1497     return;
1498   _PTR(Study) studyDS = appStudy->studyDS();
1499
1500   // componentName is used for encoding of entries when storing them in IParameters
1501   std::string componentName = myComponentGeom->ComponentDataType();
1502   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1503   //if (!aSComponent) return;
1504
1505   // IParameters
1506   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1507                                                              componentName.c_str(),
1508                                                              savePoint);
1509   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1510
1511   // viewers counters are used for storing view_numbers in IParameters
1512   int vtkViewers(0), occViewers(0);
1513
1514   QList<SUIT_ViewManager*> lst;
1515   QList<SUIT_ViewManager*>::Iterator it;
1516
1517   // main cycle to store parameters of displayed objects
1518   lst.clear();
1519   vtkViewers = occViewers = 0;
1520   getApp()->viewManagers(lst);
1521   for (it = lst.begin(); it != lst.end(); it++)
1522   {
1523     SUIT_ViewManager* vman = *it;
1524     QString vType = vman->getType();
1525
1526     // saving VTK actors properties
1527     if (vType == SVTK_Viewer::Type())
1528     {
1529       QVector<SUIT_ViewWindow*> views = vman->getViews();
1530       for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1531       {
1532         if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
1533         {
1534           vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
1535           allActors->InitTraversal();
1536           while (vtkActor* actor = allActors->GetNextActor())
1537           {
1538             if (actor->GetVisibility()) // store only visible actors
1539             {
1540               GEOM_Actor* aGeomActor = 0;
1541               if (actor->IsA("GEOM_Actor"))
1542                 aGeomActor = GEOM_Actor::SafeDownCast(actor);
1543               if (aGeomActor && aGeomActor->hasIO())
1544               {
1545                 Handle(SALOME_InteractiveObject) io = aGeomActor->getIO();
1546                 if (io->hasEntry())
1547                 {
1548                   // entry is "encoded" = it does NOT contain component adress, since it is a
1549                   // subject to change on next component loading
1550                   std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1551
1552                   std::string param, occParam = vType.toLatin1().data();
1553                   occParam += gSeparator;
1554                   occParam += QString::number(vtkViewers).toLatin1().data();
1555                   occParam += gSeparator;
1556
1557                   param = occParam + "Visibility";
1558                   ip->setParameter(entry, param, "On");
1559
1560                   param = occParam + "DisplayMode";
1561                   ip->setParameter(entry, param, QString::number
1562                                    (aGeomActor->getDisplayMode()).toLatin1().data());
1563
1564                   vtkFloatingPointType r, g, b;
1565                   aGeomActor->GetColor(r, g, b);
1566                   QString colorStr = QString::number(r);
1567                   colorStr += gDigitsSep; colorStr += QString::number(g);
1568                   colorStr += gDigitsSep; colorStr += QString::number(b);
1569                   param = occParam + "Color";
1570                   ip->setParameter(entry, param, colorStr.toLatin1().data());
1571
1572                   param = occParam + "Opacity";
1573                   ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
1574
1575                   int nbUIso(0), nbVIso(0);
1576                   aGeomActor->GetNbIsos(nbUIso,nbVIso);
1577                   QString isosStr = QString::number(nbUIso);
1578                   isosStr += gDigitsSep;
1579                   isosStr += QString::number(nbVIso);
1580                   param = occParam + "Isos";
1581                   ip->setParameter(entry, param, isosStr.toLatin1().data());
1582                 } // if (io->hasEntry())
1583               } // GEOM_Actor && hasIO
1584             } // isVisible
1585           } // while.. actors traversal
1586         } // if (vtkView)
1587       } // for (views)
1588       vtkViewers++;
1589     } // if (SVTK view model)
1590     else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
1591     {
1592       QVector<SUIT_ViewWindow*> views = vman->getViews();
1593       for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
1594       {
1595         SOCC_ViewWindow* occView = dynamic_cast<SOCC_ViewWindow*>(views[i]);
1596         if (occView)
1597         {
1598           //Handle(AIS_InteractiveContext) ic =
1599           //  ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
1600           OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
1601           //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
1602           Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
1603
1604           AIS_ListOfInteractive aList;
1605           ic->DisplayedObjects(aList);
1606
1607           AIS_ListIteratorOfListOfInteractive ite (aList);
1608           for (; ite.More(); ite.Next())
1609           {
1610             if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
1611             {
1612               Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1613               if (aSh->hasIO())
1614               {
1615                 Handle(SALOME_InteractiveObject) io =
1616                   Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1617                 if (io->hasEntry())
1618                 {
1619                   // entry is "encoded": it does NOT contain component adress,
1620                   // since it is a subject to change on next component loading
1621                   std::string entry = ip->encodeEntry(io->getEntry(), componentName);
1622
1623                   std::string param, occParam = vType.toLatin1().data();
1624                   occParam += gSeparator;
1625                   occParam += QString::number(occViewers).toLatin1().data();
1626                   occParam += gSeparator;
1627
1628                   // Visibility
1629                   param = occParam + "Visibility";
1630                   ip->setParameter(entry, param, "On");
1631
1632                   // DisplayMode
1633                   param = occParam + "DisplayMode";
1634                   int dm = aSh->DisplayMode();
1635                   ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
1636
1637                   // Color
1638                   // is a property of GEOM_Object, it is stored by GEOM engine
1639
1640                   // Transparency
1641                   param = occParam + "Transparency";
1642                   ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
1643
1644                   // Isos
1645                   Handle(AIS_Drawer) aDrawer = aSh->Attributes();
1646                   int nbUIso = aDrawer->UIsoAspect()->Number();
1647                   int nbVIso = aDrawer->VIsoAspect()->Number();
1648                   QString isosStr = QString::number(nbUIso);
1649                   isosStr += gDigitsSep;
1650                   isosStr += QString::number(nbVIso);
1651                   param = occParam + "Isos";
1652                   ip->setParameter(entry, param, isosStr.toLatin1().data());
1653                 } // if (io->hasEntry())
1654               } // if (io)
1655             } // if (GEOM_AISShape)
1656           } // for (AIS_ListOfInteractive)
1657         } // if ( occView )
1658       } // for ( views )
1659       occViewers++;
1660     } // if (SOCC view model)
1661     else
1662     {
1663       // unknown viewer type
1664     }
1665   } // for (viewManagers)
1666 }
1667
1668 /*!
1669  * \brief Restore visual parameters
1670  *
1671  * This method is called after the study document is opened.
1672  * Restore visual parameters from AttributeParameter attribue(s)
1673  */
1674 void GeometryGUI::restoreVisualParameters (int savePoint)
1675 {
1676   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
1677   if (!appStudy || !appStudy->studyDS())
1678     return;
1679   _PTR(Study) studyDS = appStudy->studyDS();
1680
1681   // componentName is used for encoding of entries when storing them in IParameters
1682   std::string componentName = myComponentGeom->ComponentDataType();
1683   //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
1684   //if (!aSComponent) return;
1685
1686   // IParameters
1687   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
1688                                                              componentName.c_str(),
1689                                                              savePoint);
1690   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1691
1692   std::vector<std::string> entries = ip->getEntries();
1693
1694   for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
1695   {
1696     // entry is a normal entry - it should be "decoded" (setting base adress of component)
1697     QString entry (ip->decodeEntry(*entIt).c_str());
1698
1699     // Check that the entry corresponds to a real object in the Study
1700     // as the object may be deleted or modified after the visual state is saved.
1701     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1702     if (!so) continue; //Skip the not existent entry
1703
1704     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1705     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1706
1707     std::vector<std::string>::iterator namesIt = paramNames.begin();
1708     std::vector<std::string>::iterator valuesIt = paramValues.begin();
1709
1710     // actors are stored in a map after displaying of them for
1711     // quicker access in the future: map < viewID to actor >
1712     NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
1713     NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
1714
1715     for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
1716     {
1717       // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
1718       // '_' is used as separator and should not be used in viewer type or parameter names.
1719       QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
1720       if (lst.size() != 3)
1721         continue;
1722
1723       QString viewerTypStr = lst[0];
1724       QString viewIndexStr = lst[1];
1725       QString paramNameStr = lst[2];
1726
1727       bool ok;
1728       int viewIndex = viewIndexStr.toUInt(&ok);
1729       if (!ok) // bad conversion of view index to integer
1730         continue;
1731
1732       // viewers
1733       if (viewerTypStr == SVTK_Viewer::Type())
1734       {
1735         GEOM_Actor* vActor = 0;
1736         if (vtkActors.IsBound(viewIndex))
1737           vActor = vtkActors.Find(viewIndex);
1738
1739         if (paramNameStr == "Visibility")
1740         {
1741           if (!vActor && displayer())
1742           {
1743             QList<SUIT_ViewManager*> lst;
1744             getApp()->viewManagers(viewerTypStr, lst);
1745
1746             // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1747             if (viewIndex >= 0 && viewIndex < lst.count()) {
1748               SUIT_ViewManager* vman = lst.at(viewIndex);
1749               SUIT_ViewModel* vmodel = vman->getViewModel();
1750               // SVTK view model can be casted to SALOME_View
1751               displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
1752
1753               // store displayed actor in a temporary map for quicker
1754               // access later when restoring other parameters
1755               SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1756               vtkRenderer* Renderer = vtkView->getRenderer();
1757               vtkActorCollection* theActors = Renderer->GetActors();
1758               theActors->InitTraversal();
1759               bool isFound = false;
1760               vtkActor *ac = theActors->GetNextActor();
1761               for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
1762                 if (ac->IsA("GEOM_Actor")) {
1763                   GEOM_Actor* aGeomAc = GEOM_Actor::SafeDownCast(ac);
1764                   if (aGeomAc->hasIO()) {
1765                     Handle(SALOME_InteractiveObject) io =
1766                       Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
1767                     if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1768                       isFound = true;
1769                       vtkActors.Bind(viewIndex, aGeomAc);
1770                     }
1771                   }
1772                 }
1773               }
1774             }
1775           }
1776         } // if (paramNameStr == "Visibility")
1777         else
1778         {
1779           // the rest properties "work" with GEOM_Actor
1780           if (vActor)
1781           {
1782             QString val ((*valuesIt).c_str());
1783
1784             if (paramNameStr == "DisplayMode") {
1785               vActor->setDisplayMode(val.toInt());
1786             }
1787             else if (paramNameStr == "Color") {
1788               QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
1789               if (colors.count() == 3)
1790                 vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
1791             }
1792             else if (paramNameStr == "Opacity") {
1793               vActor->SetOpacity(val.toFloat());
1794             }
1795             else if (paramNameStr == "Isos") {
1796               QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1797               if (isos.count() == 2) {
1798                 int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
1799                 vActor->SetNbIsos(aIsos);
1800               }
1801             }
1802           }
1803         } // other parameters than Visibility
1804       }
1805       else if (viewerTypStr == SOCC_Viewer::Type())
1806       {
1807         //Handle(AIS_InteractiveObject) occActor;
1808         Handle(GEOM_AISShape) occActor;
1809         if (occActors.IsBound(viewIndex))
1810           occActor = occActors.Find(viewIndex);
1811
1812         // ViewModel and InteractiveContext
1813         SOCC_Viewer* occVModel = 0;
1814         Handle(AIS_InteractiveContext) ic;
1815
1816         QList<SUIT_ViewManager*> lst;
1817         getApp()->viewManagers(viewerTypStr, lst);
1818
1819         // SOCC ViewManager always has 1 ViewWindow, so view index is index of view manager
1820         if (viewIndex >= 0 && viewIndex < lst.count()) {
1821           SUIT_ViewManager* vman = lst.at(viewIndex);
1822           SUIT_ViewModel* vmodel = vman->getViewModel();
1823           occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
1824           if (occVModel)
1825             ic = occVModel->getAISContext();
1826         }
1827
1828         if (ic.IsNull())
1829           continue;
1830
1831         if (paramNameStr == "Visibility")
1832         {
1833           if (occActor.IsNull() && displayer())
1834           {
1835             displayer()->Display(entry, true, occVModel);
1836
1837             // store displayed actor in a temporary map for quicker
1838             // access later when restoring other parameters
1839             AIS_ListOfInteractive aList;
1840             ic->DisplayedObjects(aList);
1841             bool isFound = false;
1842             AIS_ListIteratorOfListOfInteractive ite (aList);
1843             for (; ite.More() && !isFound; ite.Next()) {
1844               if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
1845                 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
1846                 if (aSh->hasIO()) {
1847                   Handle(SALOME_InteractiveObject) io =
1848                     Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
1849                   if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
1850                     isFound = true;
1851                     occActors.Bind(viewIndex, aSh);
1852                   }
1853                 }
1854               }
1855             }
1856           }
1857         } // if (paramNameStr == "Visibility")
1858         else
1859         {
1860           // the rest properties "work" with GEOM_AISShape
1861           if (!occActor.IsNull())
1862           {
1863             QString val ((*valuesIt).c_str());
1864
1865             if (paramNameStr == "DisplayMode") {
1866               ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
1867               //ic->Redisplay(occActor, Standard_False, Standard_True);
1868             }
1869             // Color is restored by the GEOM engine
1870             else if (paramNameStr == "Transparency") {
1871               ic->SetTransparency(occActor, val.toFloat(), false);
1872               ic->Redisplay(occActor, Standard_False, Standard_True);
1873             }
1874             else if (paramNameStr == "Isos") {
1875               QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
1876               if (isos.count() == 2) {
1877                 Handle(AIS_Drawer) aDrawer = occActor->Attributes();
1878                 int nbUIso = isos[0].toInt();
1879                 int nbVIso = isos[1].toInt();
1880                 Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
1881                 Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
1882                 uIsoAspect->SetNumber(nbUIso);
1883                 vIsoAspect->SetNumber(nbVIso);
1884                 aDrawer->SetUIsoAspect(uIsoAspect);
1885                 aDrawer->SetVIsoAspect(vIsoAspect);
1886                 ic->SetLocalAttributes(occActor, aDrawer);
1887                 ic->Redisplay(occActor);
1888               }
1889             }
1890           }
1891         } // other parameters than Visibility
1892       }
1893       else
1894       {
1895         // unknown viewer type
1896       }
1897     } // for names/parameters iterator
1898   } // for entries iterator
1899
1900   // update all VTK and OCC views
1901   QList<SUIT_ViewManager*> lst;
1902   getApp()->viewManagers(lst);
1903   for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
1904     SUIT_ViewModel* vmodel = (*it)->getViewModel();
1905     if (!vmodel)
1906       continue;
1907     if (vmodel->getType() == SVTK_Viewer::Type()) {
1908       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
1909       vtkView->getRenderer()->ResetCameraClippingRange();
1910       vtkView->Repaint();
1911     }
1912     else if (vmodel->getType() == SOCC_Viewer::Type()) {
1913       //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
1914       SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
1915       if (occVMod)
1916         occVMod->Repaint();
1917     }
1918   }
1919 }
1920
1921 void GeometryGUI::onViewAboutToShow()
1922 {
1923   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
1924   QAction* a = action( GEOMOp::OpSwitchVectors );
1925   if ( window ) {
1926     a->setEnabled(true);
1927     bool vmode = window->getCustomData("VectorsMode").toBool();
1928     a->setText ( vmode == 1 ? tr( "MEN_VECTOR_MODE_OFF" ) : tr("MEN_VECTOR_MODE_ON") );
1929   } else {
1930     a->setText ( tr("MEN_VECTOR_MODE_ON") );
1931     a->setEnabled(false);
1932   }
1933 }