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