]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI.cxx
Salome HOME
NPAL17241: EDF590: Keyboard shortcuts for removing and renaming an object.
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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 //
23 //
24 //  File   : GeometryGUI.cxx
25 //  Author : Lucien PIGNOLONI
26 //  Module : GEOM
27 //  $Header$
28
29 #include "GeometryGUI.h"
30 #include "GEOMGUI_OCCSelector.h"
31 #include "GEOMGUI_Selection.h"
32 #include "GEOM_Displayer.h"
33
34 #include <SUIT_MessageBox.h>
35 #include <SUIT_ResourceMgr.h>
36 #include <SUIT_Session.h>
37 #include <SUIT_ViewManager.h>
38
39 #include <OCCViewer_ViewWindow.h>
40 #include <OCCViewer_ViewPort3d.h>
41 #include <OCCViewer_ViewModel.h>
42 #include <OCCViewer_ViewManager.h>
43
44 #include <SVTK_ViewWindow.h>
45 #include <SVTK_RenderWindowInteractor.h>
46 #include <SVTK_InteractorStyle.h>
47 #include <SVTK_ViewModel.h>
48 #include <SVTK_ViewManager.h>
49
50 #include <SalomeApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <LightApp_VTKSelector.h>
53 #include <SalomeApp_Study.h>
54 #include <LightApp_Preferences.h>
55 #include <SALOME_LifeCycleCORBA.hxx>
56 #include <SALOME_ListIO.hxx>
57
58 // External includes
59 #include <qfileinfo.h>
60 #include <qpainter.h>
61
62 #include <Prs3d_Drawer.hxx>
63 #include <Prs3d_IsoAspect.hxx>
64 #include <Aspect_TypeOfMarker.hxx>
65 #include <OSD_SharedLibrary.hxx>
66
67 #include <utilities.h>
68
69 #include <vtkCamera.h>
70 #include <vtkRenderer.h>
71
72
73 extern "C" {
74   Standard_EXPORT CAM_Module* createModule() {
75     return new GeometryGUI();
76   }
77 }
78
79
80
81 GEOM::GEOM_Gen_var GeometryGUI::myComponentGeom = GEOM::GEOM_Gen::_nil();
82
83 GEOM::GEOM_Gen_var GeometryGUI::GetGeomGen()
84 {
85   // Bug 12290: exception in Mesh GUI on GEOMBase::GetShape() if Geometry GUI hasn't been loaded
86   if (CORBA::is_nil(myComponentGeom))
87     InitGeomGen();
88   return GeometryGUI::myComponentGeom;
89 }
90
91 bool GeometryGUI::InitGeomGen()
92 {
93   GeometryGUI aGG;
94   if( CORBA::is_nil( myComponentGeom ) ) return false;
95   return true;
96 }
97
98 //=======================================================================
99 // function : ClientSObjectToObject
100 // purpose  :
101 //=======================================================================
102 CORBA::Object_var GeometryGUI::ClientSObjectToObject (_PTR(SObject) theSObject)
103 {
104   _PTR(GenericAttribute) anAttr;
105   CORBA::Object_var anObj;
106   try {
107     std::string aValue = theSObject->GetIOR();
108     if (strcmp(aValue.c_str(), "") != 0) {
109       CORBA::ORB_ptr anORB = SalomeApp_Application::orb();
110       anObj = anORB->string_to_object(aValue.c_str());
111     }
112   } catch(...) {
113     INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
114   }
115   return anObj._retn();
116 }
117
118 //=======================================================================
119 // function : ClientStudyToStudy
120 // purpose  :
121 //=======================================================================
122 SALOMEDS::Study_var GeometryGUI::ClientStudyToStudy (_PTR(Study) theStudy)
123 {
124   SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
125   CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
126   SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
127   int aStudyID = theStudy->StudyId();
128   SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(aStudyID);
129   return aDSStudy._retn();
130 }
131
132 //=================================================================================
133 // class   : CustomItem
134 // purpose : Set Font to a text.
135 //=================================================================================
136 class CustomItem : public QCustomMenuItem
137 {
138 public:
139   CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
140   ~CustomItem() {}
141
142   void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
143   {
144     p->save();
145     p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
146     p->setPen( act ? cg.highlightedText() : cg.buttonText() );
147     p->setFont( myFont );
148     p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
149     p->restore();
150   }
151
152   QSize sizeHint()
153   {
154     return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
155   }
156
157   bool fullSpan() const
158   {
159     return true;
160   }
161
162 private:
163   QString myString;
164   QFont   myFont;
165 };
166
167 //=======================================================================
168 // function : GeometryGUI::GeometryGUI()
169 // purpose  : Constructor
170 //=======================================================================
171 GeometryGUI::GeometryGUI() :
172   SalomeApp_Module( "GEOM" )
173 {
174   if ( CORBA::is_nil( myComponentGeom ) )
175   {
176     SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA( getApp()->namingService() );
177     Engines::Component_var comp = ls->FindOrLoad_Component( "FactoryServer", "GEOM" );
178     myComponentGeom  = GEOM::GEOM_Gen::_narrow( comp );
179   }
180
181   myState           = -1;
182   myActiveDialogBox = 0;
183   myFatherior       = "";
184
185   gp_Pnt origin = gp_Pnt(0., 0., 0.);
186   gp_Dir direction = gp_Dir(0., 0., 1.);
187   myWorkingPlane = gp_Ax3(origin, direction);
188
189   myOCCSelectors.setAutoDelete( true );
190   myVTKSelectors.setAutoDelete( true );
191
192   myDisplayer = 0;
193   myLocalSelectionMode = GEOM_ALLOBJECTS;
194 }
195
196 //=======================================================================
197 // function : GeometryGUI::~GeometryGUI()
198 // purpose  : Destructor
199 //=======================================================================
200 GeometryGUI::~GeometryGUI()
201 {
202 }
203
204 //=======================================================================
205 // function : GeometryGUI::getLibrary()
206 // purpose  : get or load GUI library by name [ internal ]
207 //=======================================================================
208 typedef GEOMGUI* (*LibraryGUI)( GeometryGUI* );
209 GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
210 {
211   if ( !myGUIMap.contains( libraryName ) ) {
212     // try to load library if it is not loaded yet
213     QCString libs;
214 #ifndef WNT
215     if( ( libs = getenv( "LD_LIBRARY_PATH" ) ) ) {
216           QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries
217 #else
218         if( ( libs = getenv( "PATH" ) ) ) {
219           QStringList dirList = QStringList::split( ";", libs, false ); // skip empty entries
220 #endif
221       for( int i = dirList.count()-1; i >= 0; i-- ) {
222         QString dir = dirList[ i ];
223         QFileInfo fi( Qtx::addSlash( dirList[ i ] ) + libraryName );
224         if( fi.exists() ) {
225           OSD_SharedLibrary aSharedLibrary( (char*)fi.fileName().latin1() );
226           bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY );
227           if( !res ) {
228             MESSAGE( "Can't open library : " << aSharedLibrary.DlError() );
229             continue; // continue search further
230           }
231           OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" );
232           if ( osdF != NULL ) {
233             LibraryGUI func = (GEOMGUI* (*) (GeometryGUI*))osdF;
234             GEOMGUI* libGUI = (*func)(this);
235             if ( libGUI ) {
236               myGUIMap[ libraryName ] = libGUI;
237               break; // found and loaded!
238             }
239           }
240         }
241       }
242     }
243   }
244   if ( myGUIMap.contains( libraryName ) )
245     // library is successfully loaded
246     return myGUIMap[ libraryName ];
247   return 0;
248 }
249
250 //=======================================================================
251 // function : GeometryGUI::ActiveWorkingPlane()
252 // purpose  : Activate Working Plane View
253 //=======================================================================
254 void GeometryGUI::ActiveWorkingPlane()
255 {
256   gp_Dir DZ = myWorkingPlane.Direction();
257   gp_Dir DY = myWorkingPlane.YDirection();
258
259   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
260   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
261   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
262
263   if( ViewOCC ) {
264     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
265     if ( vw ) {
266       Handle(V3d_View) view3d =  vw->getViewPort()->getView();
267
268       view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z());
269       view3d->SetUp(DY.X(), DY.Y(), DY.Z());
270
271       vw->onViewFitAll();
272     }
273   }
274   else if( ViewVTK ) {
275     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
276     if ( vw ) {
277       vtkCamera* camera = vw->getRenderer()->GetActiveCamera();
278
279       camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z());
280       camera->SetViewUp(DY.X(), DY.Y(), DY.Z());
281       camera->SetFocalPoint(0,0,0);
282
283       vw->onFitAll();
284     }
285   }
286 }
287
288 //=======================================================================
289 // function : GeometryGUI::SetActiveDialogBox()
290 // purpose  : Set active dialog box
291 //=======================================================================
292 void GeometryGUI::SetActiveDialogBox( QDialog* aDlg )
293 {
294   myActiveDialogBox = (QDialog*)aDlg;
295 }
296
297 //=======================================================================
298 // function : GeometryGUI::EmitSignalDeactivateDialog()
299 // purpose  : Emit a signal to deactivate the active dialog Box
300 //=======================================================================
301 void GeometryGUI::EmitSignalDeactivateDialog()
302 {
303   emit SignalDeactivateActiveDialog();
304 }
305
306 //=======================================================================
307 // function : GeometryGUI::EmitSignalCloseAllDialogs()
308 // purpose  : Emit a signal to close all non modal dialogs box
309 //=======================================================================
310 void GeometryGUI::EmitSignalCloseAllDialogs()
311 {
312   emit SignalCloseAllDialogs();
313 }
314
315 //=======================================================================
316 // function : GeometryGUI::EmitSignalDefaultStepValueChanged()
317 // purpose  : Emit a signal to inform that default real spin box step has
318 //            been changed
319 //=======================================================================
320 void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal)
321 {
322   emit SignalDefaultStepValueChanged(newVal);
323 }
324
325 //=======================================================================
326 // function : GeometryGUI::OnGUIEvent()
327 // purpose  : common slot for all menu/toolbar actions
328 //=======================================================================
329 void GeometryGUI::OnGUIEvent()
330 {
331   const QObject* obj = sender();
332   if ( !obj || !obj->inherits( "QAction" ) )
333     return;
334   int id = actionId((QAction*)obj);
335   if ( id != -1 )
336     OnGUIEvent( id );
337 }
338
339 //=======================================================================
340 // function : GeometryGUI::OnGUIEvent()
341 // purpose  : manage all events on GUI [static]
342 //=======================================================================
343 void GeometryGUI::OnGUIEvent( int id )
344 {
345   SUIT_Application* anApp = application();
346   if (!anApp) return;
347   SUIT_Desktop* desk = anApp->desktop();
348
349   // check type of the active viewframe
350   SUIT_ViewWindow* window = desk->activeWindow();
351   bool ViewOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
352   bool ViewVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
353   // if current viewframe is not of OCC and not of VTK type - return immediately
354   // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
355   bool NotViewerDependentCommand = ( id == 901 || id == 216 || id == 213 );
356   if ( !ViewOCC && !ViewVTK && !NotViewerDependentCommand )
357       return;
358
359   // fix for IPAL9103, point 2
360   if ( CORBA::is_nil( GetGeomGen() ) ) {
361     SUIT_MessageBox::error1( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_GET_ENGINE" ), tr( "GEOM_BUT_OK" ) );
362     return;
363   }
364
365   GEOMGUI* library = 0;
366   // try to get-or-load corresponding GUI library
367   if( id == 111  ||  // MENU FILE - IMPORT BREP
368       id == 112  ||  // MENU FILE - IMPORT IGES
369       id == 113  ||  // MENU FILE - IMPORT STEP
370       id == 121  ||  // MENU FILE - EXPORT BREP
371       id == 122  ||  // MENU FILE - EXPORT IGES
372       id == 123  ||  // MENU FILE - EXPORT STEP
373       id == 2171 ||  // POPUP VIEWER - SELECT ONLY - VERTEX
374       id == 2172 ||  // POPUP VIEWER - SELECT ONLY - EDGE
375       id == 2173 ||  // POPUP VIEWER - SELECT ONLY - WIRE
376       id == 2174 ||  // POPUP VIEWER - SELECT ONLY - FACE
377       id == 2175 ||  // POPUP VIEWER - SELECT ONLY - SHELL
378       id == 2176 ||  // POPUP VIEWER - SELECT ONLY - SOLID
379       id == 2177 ||  // POPUP VIEWER - SELECT ONLY - COMPOUND
380       id == 2178 ||  // POPUP VIEWER - SELECT ONLY - SELECT ALL      
381       id == 31   ||  // MENU EDIT - COPY
382       id == 33   ||  // MENU EDIT - DELETE
383       id == 411  ||  // MENU SETTINGS - ADD IN STUDY
384       id == 412  ||  // MENU SETTINGS - SHADING COLOR
385       id == 413  ||  // MENU SETTINGS - ISOS
386       id == 414  ||  // MENU SETTINGS - STEP VALUE FOR SPIN BOXES
387       id == 5103 ||  // MENU TOOLS - CHECK GEOMETRY
388       id == 8032 ||  // POPUP VIEWER - COLOR
389       id == 8033 ||  // POPUP VIEWER - TRANSPARENCY
390       id == 8034 ||  // POPUP VIEWER - ISOS
391       id == 804  ||  // POPUP VIEWER - ADD IN STUDY
392       id == 901  ||  // OBJECT BROWSER - RENAME
393       id == 9024 ) { // OBJECT BROWSER - OPEN
394     //cout << "id " << id << " received" << endl;
395 #ifndef WNT
396         library = getLibrary( "libGEOMToolsGUI.so" );
397 #else
398         library = getLibrary( "GEOMToolsGUI.dll" );
399 #endif
400   }
401   else if( id == 211  ||  // MENU VIEW - WIREFRAME/SHADING
402            id == 212  ||  // MENU VIEW - DISPLAY ALL
403            id == 213  ||  // MENU VIEW - DISPLAY ONLY
404            id == 214  ||  // MENU VIEW - ERASE ALL
405            id == 215  ||  // MENU VIEW - ERASE
406            id == 216  ||  // MENU VIEW - DISPLAY
407            id == 80311 ||  // POPUP VIEWER - WIREFRAME
408            id == 80312 ) { // POPUP VIEWER - SHADING
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
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 #ifndef WNT
437         library = getLibrary( "libPrimitiveGUI.so" );
438 #else
439         library = getLibrary( "PrimitiveGUI.dll" );
440 #endif
441   }
442   else if( id == 4031 ||  // MENU GENERATION - PRISM
443            id == 4032 ||  // MENU GENERATION - REVOLUTION
444            id == 4033 ||  // MENU GENERATION - FILLING
445            id == 4034 ) { // MENU GENERATION - PIPE
446 #ifndef WNT
447         library = getLibrary( "libGenerationGUI.so" );
448 #else
449         library = getLibrary( "GenerationGUI.dll" );
450 #endif
451   }
452   else if( id == 404 ||   // MENU ENTITY - SKETCHER
453            id == 407 ) {  // MENU ENTITY - EXPLODE
454 #ifndef WNT
455         library = getLibrary( "libEntityGUI.so" );
456 #else
457         library = getLibrary( "EntityGUI.dll" );
458 #endif
459   }
460   else if( id == 4081 ||  // MENU BUILD - EDGE
461            id == 4082 ||  // MENU BUILD - WIRE
462            id == 4083 ||  // MENU BUILD - FACE
463            id == 4084 ||  // MENU BUILD - SHELL
464            id == 4085 ||  // MENU BUILD - SOLID
465            id == 4086 ) { // MENU BUILD - COMPUND
466 #ifndef WNT
467         library = getLibrary( "libBuildGUI.so" );
468 #else
469         library = getLibrary( "BuildGUI.dll" );
470 #endif
471   }
472   else if( id == 5011 ||  // MENU BOOLEAN - FUSE
473            id == 5012 ||  // MENU BOOLEAN - COMMON
474            id == 5013 ||  // MENU BOOLEAN - CUT
475            id == 5014 ) { // MENU BOOLEAN - SECTION
476 #ifndef WNT
477         library = getLibrary( "libBooleanGUI.so" );
478 #else
479         library = getLibrary( "BooleanGUI.dll" );
480 #endif
481   }
482   else if( id == 5021 ||  // MENU TRANSFORMATION - TRANSLATION
483            id == 5022 ||  // MENU TRANSFORMATION - ROTATION
484            id == 5023 ||  // MENU TRANSFORMATION - LOCATION
485            id == 5024 ||  // MENU TRANSFORMATION - MIRROR
486            id == 5025 ||  // MENU TRANSFORMATION - SCALE
487            id == 5026 ||  // MENU TRANSFORMATION - OFFSET
488            id == 5027 ||  // MENU TRANSFORMATION - MULTI-TRANSLATION
489            id == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION
490 #ifndef WNT
491         library = getLibrary( "libTransformationGUI.so" );
492 #else
493         library = getLibrary( "TransformationGUI.dll" );
494 #endif
495   }
496   else if( id == 503 ||   // MENU OPERATION - PARTITION
497            id == 504 ||   // MENU OPERATION - ARCHIMEDE
498            id == 505 ||   // MENU OPERATION - FILLET
499            id == 506 ||   // MENU OPERATION - CHAMFER
500            id == 507 ) {  // MENU OPERATION - CLIPPING RANGE
501 #ifndef WNT
502         library = getLibrary( "libOperationGUI.so" );
503 #else
504         library = getLibrary( "OperationGUI.dll" );
505 #endif
506   }
507   else if( id == 601 ||   // MENU REPAIR - SEWING
508            id == 603 ||   // MENU REPAIR - SUPPRESS FACES
509            id == 604 ||   // MENU REPAIR - SUPPRESS HOLE
510            id == 605 ||   // MENU REPAIR - SHAPE PROCESSING
511            id == 606 ||   // MENU REPAIR - CLOSE CONTOUR
512            id == 607 ||   // MENU REPAIR - REMOVE INTERNAL WIRES
513            id == 608 ||   // MENU REPAIR - ADD POINT ON EDGE
514            id == 609 ||   // MENU MEASURE - FREE BOUNDARIES
515            id == 610 ||   // MENU MEASURE - FREE FACES
516            id == 611 ||   // MENU REPAIR - CHANGE ORIENTATION
517            id == 602 ) {  // MENU REPAIR - GLUE FACES
518 #ifndef WNT
519         library = getLibrary( "libRepairGUI.so" );
520 #else
521         library = getLibrary( "RepairGUI.dll" );
522 #endif
523   }
524   else if( id == 701   ||  // MENU MEASURE - PROPERTIES
525            id == 702   ||  // MENU MEASURE - CDG
526            id == 703   ||  // MENU MEASURE - INERTIA
527            id == 7041  ||  // MENU MEASURE - BOUNDING BOX
528            id == 7042  ||  // MENU MEASURE - MIN DISTANCE
529            id == 7043  ||  // MENU MEASURE - ANGLE
530            id == 705   ||  // MENU MEASURE - TOLERANCE
531            id == 706   ||  // MENU MEASURE - WHATIS
532            id == 707   ||  // MENU MEASURE - CHECK
533            id == 7072  ||  // MENU MEASURE - CHECK COMPOUND OF BLOCKS
534            id == 708 ) {  // MENU MEASURE - POINT COORDINATES
535 #ifndef WNT
536         library = getLibrary( "libMeasureGUI.so" );
537 #else
538         library = getLibrary( "MeasureGUI.dll" );
539 #endif
540   }
541   else if( id == 800  ||  // MENU GROUP - CREATE
542            id == 8001 ||  // POPUP MENU - CREATE GROUP
543            id == 801 ) {  // MENU GROUP - EDIT
544 #ifndef WNT
545         library = getLibrary( "libGroupGUI.so" );
546 #else
547         library = getLibrary( "GroupGUI.dll" );
548 #endif
549   }
550   else if( id == 9999  ||  // MENU BLOCKS - HEXAHEDRAL SOLID
551            id == 9998  ||  // MENU BLOCKS - MULTI-TRANSFORMATION
552            id == 9997  ||  // MENU BLOCKS - QUADRANGLE FACE
553            id == 99991 ||  // MENU BLOCKS - PROPAGATE
554            id == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS
555 #ifndef WNT
556         library = getLibrary( "libBlocksGUI.so" );
557 #else
558         library = getLibrary( "BlocksGUI.dll" );
559 #endif
560   }
561
562   // call method of corresponding GUI library
563   if ( library )
564     library->OnGUIEvent( id, desk );
565   else
566     SUIT_MessageBox::error1( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) );
567 }
568
569
570 //=================================================================================
571 // function : GeometryGUI::OnKeyPress()
572 // purpose  : Called when any key is pressed by user [static]
573 //=================================================================================
574 void GeometryGUI::OnKeyPress( SUIT_ViewWindow* win, QKeyEvent* pe )
575 {
576   GUIMap::Iterator it;
577   bool bOk = true;
578   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
579     SUIT_Application* anApp = application();
580     if (!anApp) return;
581     bOk = bOk && it.data()->OnKeyPress( pe, anApp->desktop(), win );
582   }
583 //  return bOk;
584 }
585
586
587 //=================================================================================
588 // function : GeometryGUI::OnMouseMove()
589 // purpose  : Manages mouse move events [static]
590 //=================================================================================
591 void GeometryGUI::OnMouseMove( SUIT_ViewWindow* win, QMouseEvent* pe )
592 {
593   GUIMap::Iterator it;
594   bool bOk = true;
595   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
596     SUIT_Application* anApp = application();
597     if (!anApp) return;
598     bOk = bOk && it.data()->OnMouseMove( pe, anApp->desktop(), win );
599   }
600 //  return bOk;
601 }
602
603
604 //=================================================================================
605 // function : GeometryGUI::0nMousePress()
606 // purpose  : Manage mouse press events [static]
607 //=================================================================================
608 void GeometryGUI::OnMousePress( SUIT_ViewWindow* win, QMouseEvent* pe )
609 {
610   GUIMap::Iterator it;
611   // OnMousePress() should return false if this event should be processed further
612   // (see OCCViewer_Viewer3d::onMousePress() for explanation)
613   bool processed = false;
614   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) {
615     SUIT_Application* anApp = application();
616     if (!anApp) return;
617     processed = processed || it.data()->OnMousePress( pe, anApp->desktop(), win );
618   }
619 //  return processed;
620 }
621
622 /*
623 static void UpdateVtkSelection()
624 {
625   QPtrList<SUIT_ViewWindow> winList = application()->desktop()->windows();
626   SUIT_ViewWindow* win = 0;
627   for ( win = winList.first(); win; win = winList.next() ) {
628     if ( win->getViewManager()->getTypeView() == VIEW_VTK ) {
629       SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
630       if ( vw ) {
631         SVTK_RenderWindowInteractor* anInteractor = vw->getRWInteractor();
632         anInteractor->SetSelectionProp();
633         anInteractor->SetSelectionTolerance();
634         SVTK_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
635         if (aStyle) {
636           aStyle->setPreselectionProp();
637         }
638       }
639     }
640   }
641 }
642
643 //=================================================================================
644 // function : GeometryGUI::SetSettings()
645 // purpose  : Called when GEOM module is activated [static]
646 //=================================================================================
647 bool GeometryGUI::SetSettings()
648 {
649   QMenuBar*     Mb = parent->getMainMenuBar();
650   SUIT_Study*   ActiveStudy = application()->activeStudy();
651
652 // Wireframe or Shading
653   int DisplayMode = 0;
654   SUIT_ViewWindow* window = application()->desktop()->activeWindow();
655   bool ViewOCC = ( window && window->getViewManager()->getType() == VIEW_OCC );
656   bool ViewVTK = ( window && window->getViewManager()->getType() == VIEW_VTK );
657   if ( ViewOCC ) {
658     OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( window->getViewManager() );
659     if ( vm ) {
660       Handle(AIS_InteractiveContext) ic = vm->getOCCViewer()->getAISContext();
661       DisplayMode = ic->DisplayMode();
662     }
663   }
664   else if ( ViewVTK ) {
665     SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( window );
666     if ( vw ) {
667       SVTK_RenderWindowInteractor* myRenderInter = vw->getRWInteractor();
668       DisplayMode = myRenderInter->GetDisplayMode();
669     }
670   }
671
672   if( DisplayMode == 1 )
673     getApp()->
674     Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) );
675   else
676     Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) );
677
678
679   // Add in Study  - !!!ALWAYS TRUE!!! /////// VSR : TO BE REMOVED
680   QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
681   int Settings_AddInStudy;
682   //  if(!AddInStudy.isEmpty())
683   //    Settings_AddInStudy = AddInStudy.toInt();
684   //  else
685
686   Settings_AddInStudy = 1;
687   Mb->setItemChecked(411, Settings_AddInStudy);
688
689   // step value
690   QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
691   if(S.isEmpty())
692     QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100");
693
694   // isos
695   int count = ActiveStudy->getStudyFramesCount();
696   for(int i = 0; i < count; i++) {
697     if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
698       OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
699       Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
700
701       QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
702       QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
703       if(!IsoU.isEmpty())
704         ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
705       if(!IsoV.isEmpty())
706         ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
707     }
708   }
709
710   setActionsEnabled();
711
712   // PAL5356: update VTK selection
713   ::UpdateVtkSelection();
714   bool bOk = true;
715   GUIMap::Iterator it;
716   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
717     bOk = bOk && it.data()->SetSettings( parent );
718
719   // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable)
720   if (getenv( "GEOM_CLIPPING" ) == NULL)
721     {
722       QMenuItem* mi = Mb->findItem(50);
723       if (mi && mi->popup())
724       mi->popup()->removeItem(507);
725     }
726
727   return bOk;
728 }
729 */
730
731 //=======================================================================
732 // function : createGeomAction
733 // purpose  :
734 //=======================================================================
735 void GeometryGUI::createGeomAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle  )
736 {
737   QIconSet icon;
738   QWidget* parent = application()->desktop();
739   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
740   QPixmap pix;
741   if ( icon_id.length() )
742     pix = resMgr->loadPixmap( "GEOM", tr( icon_id ) );
743   else
744     pix = resMgr->loadPixmap( "GEOM", tr( QString( "ICO_" )+po_id ), false );
745   if ( !pix.isNull() )
746     icon = QIconSet( pix );
747
748   QString tooltip    = tr( QString( "TOP_" )+po_id ),
749           menu       = tr( QString( "MEN_" )+po_id ),
750           status_bar = tr( QString( "STB_" )+po_id );
751
752   createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() )  );
753 }
754
755
756
757 //=======================================================================
758 // function : GeometryGUI::initialize()
759 // purpose  : Called when GEOM module is created
760 //=======================================================================
761 void GeometryGUI::initialize( CAM_Application* app )
762 {
763   SalomeApp_Module::initialize( app );
764
765   // ----- create actions --------------
766
767   createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
768   createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
769
770   createGeomAction( 33, "DELETE", "", Key_Delete );
771
772   createGeomAction( 4011, "POINT" );
773   createGeomAction( 4012, "LINE" );
774   createGeomAction( 4013, "CIRCLE" );
775   createGeomAction( 4014, "ELLIPSE" );
776   createGeomAction( 4015, "ARC" );
777   createGeomAction( 4019, "CURVE" );
778   createGeomAction( 4016, "VECTOR" );
779   createGeomAction( 4017, "PLANE" );
780   createGeomAction( 4018, "WORK_PLANE" );
781   createGeomAction( 4020, "LOCAL_CS" );
782
783   createGeomAction( 4021, "BOX" );
784   createGeomAction( 4022, "CYLINDER" );
785   createGeomAction( 4023, "SPHERE" );
786   createGeomAction( 4024, "TORUS" );
787   createGeomAction( 4025, "CONE" );
788
789   createGeomAction( 4031, "EXTRUSION" );
790   createGeomAction( 4032, "REVOLUTION" );
791   createGeomAction( 4033, "FILLING" );
792   createGeomAction( 4034, "PIPE" );
793
794   createGeomAction( 800, "GROUP_CREATE" );
795   createGeomAction( 801, "GROUP_EDIT" );
796
797   createGeomAction( 9997, "Q_FACE" );
798   createGeomAction( 9999, "HEX_SOLID" );
799
800   createGeomAction( 404, "SKETCH" );
801   createGeomAction( 407, "EXPLODE" );
802
803   createGeomAction( 4081, "EDGE" );
804   createGeomAction( 4082, "WIRE" );
805   createGeomAction( 4083, "FACE" );
806   createGeomAction( 4084, "SHELL" );
807   createGeomAction( 4085, "SOLID" );
808   createGeomAction( 4086, "COMPOUND" );
809
810   createGeomAction( 5011, "FUSE" );
811   createGeomAction( 5012, "COMMON" );
812   createGeomAction( 5013, "CUT" );
813   createGeomAction( 5014, "SECTION" );
814
815   createGeomAction( 5021, "TRANSLATION" );
816   createGeomAction( 5022, "ROTATION" );
817   createGeomAction( 5023, "MODIFY_LOCATION" );
818   createGeomAction( 5024, "MIRROR" );
819   createGeomAction( 5025, "SCALE" );
820   createGeomAction( 5026, "OFFSET" );
821   createGeomAction( 5027, "MUL_TRANSLATION" );
822   createGeomAction( 5028, "MUL_ROTATION" );
823
824   createGeomAction( 503, "PARTITION" );
825   createGeomAction( 504, "ARCHIMEDE" );
826   createGeomAction( 505, "FILLET" );
827   createGeomAction( 506, "CHAMFER" );
828   //createGeomAction( 507, "CLIPPING" );
829
830   createGeomAction( 9998, "MUL_TRANSFORM" );
831   createGeomAction( 9995, "EXPLODE_BLOCKS" );
832   createGeomAction( 99991, "PROPAGATE" );
833
834   createGeomAction( 601, "SEWING" );
835   createGeomAction( 602, "GLUE_FACES" );
836   createGeomAction( 603, "SUPPRESS_FACES" );
837   createGeomAction( 604, "SUPPERSS_HOLES" );
838   createGeomAction( 605, "SHAPE_PROCESS" );
839   createGeomAction( 606, "CLOSE_CONTOUR" );
840   createGeomAction( 607, "SUPPRESS_INT_WIRES" );
841   createGeomAction( 608, "POINT_ON_EDGE" );
842   createGeomAction( 609, "CHECK_FREE_BNDS" );
843   createGeomAction( 610, "CHECK_FREE_FACES" );
844   createGeomAction( 611, "CHANGE_ORIENTATION" );
845
846   createGeomAction( 708, "POINT_COORDS" );
847   createGeomAction( 701, "BASIC_PROPS" );
848   createGeomAction( 702, "MASS_CENTER" );
849   createGeomAction( 703, "INERTIA" );
850   createGeomAction( 7041, "BND_BOX" );
851   createGeomAction( 7042, "MIN_DIST" );
852   createGeomAction( 7043, "MEASURE_ANGLE" );
853
854   createGeomAction( 705, "TOLERANCE" );
855   createGeomAction( 706, "WHAT_IS" );
856   createGeomAction( 707, "CHECK" );
857   createGeomAction( 7072, "CHECK_COMPOUND" );
858
859 #ifdef _DEBUG_ // PAL16821 
860   createGeomAction( 5103, "CHECK_GEOMETRY" );
861 #endif
862   createGeomAction( 412, "SHADING_COLOR" );
863   createGeomAction( 413, "ISOS" );
864   createGeomAction( 414, "STEP_VALUE" );
865
866   createGeomAction( 211, "SHADING" );
867   createGeomAction( 212, "DISPLAY_ALL" );
868   createGeomAction( 214, "ERASE_ALL" );
869   createGeomAction( 216, "DISPLAY" );
870   createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true );
871   createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true );
872   createGeomAction( 2173, "WIRE_SEL_ONLY", "",  0, true );
873   createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true );
874   createGeomAction( 2175, "SHELL_SEL_ONLY", "",  0, true );
875   createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true );
876   createGeomAction( 2177, "COMPOUND_SEL_ONLY", "",  0, true );
877   createGeomAction( 2178, "ALL_SEL_ONLY", "",  0, true );
878   createGeomAction( 213, "DISPLAY_ONLY" );
879   createGeomAction( 215, "ERASE" );
880
881   createGeomAction( 901, "POP_RENAME", "", Key_F2 );
882   createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
883   createGeomAction( 80312, "POP_SHADING", "", 0, true );
884   createGeomAction( 8032, "POP_COLOR" );
885   createGeomAction( 8033, "POP_TRANSPARENCY" );
886   createGeomAction( 8034, "POP_ISOS" );
887   createGeomAction( 8001, "POP_CREATE_GROUP" );
888
889   // make wireframe-shading items to be exclusive (only one at a time is selected)
890   //QActionGroup* dispModeGr = new QActionGroup( this, "", true );
891   //dispModeGr->add( action( 80311 ) );
892   //dispModeGr->add( action( 80312 ) );
893   // ---- create menu --------------------------
894
895   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
896   createMenu( separator(), fileId, 10 );
897   createMenu( 111, fileId, 10 );
898   createMenu( 121, fileId, 10 );
899   createMenu( separator(), fileId, -1 );
900
901   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
902   createMenu( 33, editId, -1 );
903
904   int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
905
906   int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
907   createMenu( 4011, basicId, -1 );
908   createMenu( 4012, basicId, -1 );
909   createMenu( 4013, basicId, -1 );
910   createMenu( 4014, basicId, -1 );
911   createMenu( 4015, basicId, -1 );
912   createMenu( 4019, basicId, -1 );
913   createMenu( separator(), basicId, -1 );
914   createMenu( 4016, basicId, -1 );
915   createMenu( 4017, basicId, -1 );
916   createMenu( 4018, basicId, -1 );
917   createMenu( 4020, basicId, -1 );
918
919   int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
920   createMenu( 4021, primId, -1 );
921   createMenu( 4022, primId, -1 );
922   createMenu( 4023, primId, -1 );
923   createMenu( 4024, primId, -1 );
924   createMenu( 4025, primId, -1 );
925
926   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
927   createMenu( 4031, genId, -1 );
928   createMenu( 4032, genId, -1 );
929   createMenu( 4033, genId, -1 );
930   createMenu( 4034, genId, -1 );
931   createMenu( separator(), newEntId, -1 );
932
933   int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
934   createMenu( 800, groupId, -1 );
935   createMenu( 801, groupId, -1 );
936   createMenu( separator(), newEntId, -1 );
937
938   int blocksId = createMenu( tr( "MEN_BLOCKS" ), newEntId, -1 );
939   createMenu( 9997, blocksId, -1 );
940   createMenu( 9999, blocksId, -1 );
941
942   createMenu( separator(), newEntId, -1 );
943   createMenu( 404, newEntId, -1 );
944   createMenu( separator(), newEntId, -1 );
945   createMenu( 407, newEntId, -1 );
946
947   int buildId = createMenu( tr( "MEN_BUILD" ), newEntId, -1 );
948   createMenu( 4081, buildId, -1 );
949   createMenu( 4082, buildId, -1 );
950   createMenu( 4083, buildId, -1 );
951   createMenu( 4084, buildId, -1 );
952   createMenu( 4085, buildId, -1 );
953   createMenu( 4086, buildId, -1 );
954
955   int operId = createMenu( tr( "MEN_OPERATIONS" ), -1, -1, 10 );
956
957   int boolId = createMenu( tr( "MEN_BOOLEAN" ), operId, -1 );
958   createMenu( 5011, boolId, -1 );
959   createMenu( 5012, boolId, -1 );
960   createMenu( 5013, boolId, -1 );
961   createMenu( 5014, boolId, -1 );
962
963   int transId = createMenu( tr( "MEN_TRANSFORMATION" ), operId, -1 );
964   createMenu( 5021, transId, -1 );
965   createMenu( 5022, transId, -1 );
966   createMenu( 5023, transId, -1 );
967   createMenu( 5024, transId, -1 );
968   createMenu( 5025, transId, -1 );
969   createMenu( 5026, transId, -1 );
970   createMenu( separator(), transId, -1 );
971   createMenu( 5027, transId, -1 );
972   createMenu( 5028, transId, -1 );
973
974   createMenu( 503, operId, -1 );
975   createMenu( 504, operId, -1 );
976   createMenu( separator(), operId, -1 );
977   createMenu( 505, transId, -1 );
978   createMenu( 506, transId, -1 );
979   //createMenu( 507, transId, -1 );
980
981   int blockId = createMenu( tr( "MEN_BLOCKS" ), operId, -1 );
982   createMenu( 9998, blockId, -1 );
983   createMenu( 9995, blockId, -1 );
984   createMenu( 99991, blockId, -1 );
985
986   int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
987   createMenu( 605, repairId, -1 );
988   createMenu( 603, repairId, -1 );
989   createMenu( 606, repairId, -1 );
990   createMenu( 607, repairId, -1 );
991   createMenu( 604, repairId, -1 );
992   createMenu( 601, repairId, -1 );
993   createMenu( 602, repairId, -1 );
994   createMenu( 608, repairId, -1 );
995   //createMenu( 609, repairId, -1 );
996   //createMenu( 610, repairId, -1 );
997   createMenu( 611, repairId, -1 );
998
999   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
1000   createMenu( 708, measurId, -1 );
1001   createMenu( 701, measurId, -1 );
1002   createMenu( separator(), measurId, -1 );
1003   createMenu( 702, measurId, -1 );
1004   createMenu( 703, measurId, -1 );
1005   // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
1006   createMenu( separator(), measurId, -1 );
1007   createMenu( 609, measurId, -1 );
1008   createMenu( 610, measurId, -1 );
1009   // NPAL16572 END
1010   createMenu( separator(), measurId, -1 );
1011
1012   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
1013   createMenu( 7041, dimId, -1 );
1014   createMenu( 7042, dimId, -1 );
1015   createMenu( 7043, dimId, -1 );
1016   createMenu( separator(), measurId, -1 );
1017
1018   createMenu( 705, measurId, -1 );
1019   createMenu( separator(), measurId, -1 );
1020   createMenu( 706, measurId, -1 );
1021   createMenu( 707, measurId, -1 );
1022   createMenu( 7072, measurId, -1 );
1023
1024 #ifdef _DEBUG_ // PAL16821 
1025   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
1026   createMenu( separator(), toolsId, -1 );
1027   createMenu( 5103, toolsId, -1 );
1028 #endif
1029   //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
1030   //createMenu( separator(), prefId, -1 );
1031   //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
1032   //createMenu( 412, geomId, -1 );
1033   //createMenu( 413, geomId, -1 );
1034   //createMenu( 414, geomId, -1 );
1035   //createMenu( separator(), prefId, -1 );
1036
1037   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
1038   createMenu( separator(), viewId, -1 );
1039
1040   int dispmodeId = createMenu( tr( "MEN_DISPLAY_MODE" ), viewId, -1 );
1041   createMenu( 211, dispmodeId, -1 );
1042
1043   createMenu( separator(), viewId, -1 );
1044   createMenu( 212, viewId, -1 );
1045   createMenu( 214, viewId, -1 );
1046   createMenu( separator(), viewId, -1 );
1047
1048 /*
1049   PAL9111:
1050   because of these items are accessible through object browser and viewers
1051   we have removed they from main menu
1052
1053   createMenu( 216, viewId, -1 );
1054   createMenu( 213, viewId, -1 );
1055   createMenu( 215, viewId, -1 );
1056 */
1057
1058   // ---- create toolbars --------------------------
1059
1060   int basicTbId = createTool( tr( "TOOL_BASIC" ) );
1061   createTool( 4011, basicTbId );
1062   createTool( 4012, basicTbId );
1063   createTool( 4013, basicTbId );
1064   createTool( 4014, basicTbId );
1065   createTool( 4015, basicTbId );
1066   createTool( 4019, basicTbId );
1067   createTool( 4016, basicTbId );
1068   createTool( 4017, basicTbId );
1069   createTool( 4018, basicTbId );
1070   createTool( 4020, basicTbId );
1071
1072   int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
1073   createTool( 4021, primTbId );
1074   createTool( 4022, primTbId );
1075   createTool( 4023, primTbId );
1076   createTool( 4024, primTbId );
1077   createTool( 4025, primTbId );
1078
1079   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
1080   createTool( 5011, boolTbId );
1081   createTool( 5012, boolTbId );
1082   createTool( 5013, boolTbId );
1083   createTool( 5014, boolTbId );
1084
1085   int genTbId = createTool( tr( "TOOL_GENERATION" ) );
1086   createTool( 4031, genTbId );
1087   createTool( 4032, genTbId );
1088   createTool( 4033, genTbId );
1089   createTool( 4034, genTbId );
1090
1091   int transTbId = createTool( tr( "TOOL_TRANSFORMATION" ) );
1092   createTool( 5021, transTbId );
1093   createTool( 5022, transTbId );
1094   createTool( 5023, transTbId );
1095   createTool( 5024, transTbId );
1096   createTool( 5025, transTbId );
1097   createTool( 5026, transTbId );
1098   createTool( separator(), transTbId );
1099   createTool( 5027, transTbId );
1100   createTool( 5028, transTbId );
1101
1102   // ---- create popup menus --------------------------
1103
1104   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
1105   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
1106
1107   QtxPopupMgr* mgr = popupMgr();
1108   mgr->insert( action(  901 ), -1, -1 );  // rename
1109   mgr->setRule( action( 901 ), "$type in {'Shape' 'Group'} and selcount=1", true );
1110   mgr->insert( action(   33 ), -1, -1 );  // delete
1111   mgr->setRule( action(  33 ), "$type in {'Shape' 'Group'} and selcount>0", true );
1112   mgr->insert( action(  8001 ), -1, -1 ); // create group
1113   mgr->setRule( action( 8001 ), "client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true", true );
1114   mgr->insert( action(  801 ), -1, -1 );  // edit group
1115   mgr->setRule( action( 801 ),  "client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true", true );
1116   mgr->insert( separator(), -1, -1 );     // -----------
1117   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
1118   mgr->insert( action(  80311 ), dispmodeId, -1 ); // wireframe
1119   mgr->setRule( action( 80311 ), clientOCCorVTK_AndSomeVisible, true );
1120   mgr->setRule( action( 80311 ), clientOCCorVTK + " and displaymode='Wireframe'", false );
1121   mgr->insert( action(  80312 ), dispmodeId, -1 ); // shading
1122   mgr->setRule( action( 80312 ), clientOCCorVTK_AndSomeVisible, true );
1123   mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", false );
1124   mgr->insert( separator(), -1, -1 );     // -----------
1125   mgr->insert( action(  8032 ), -1, -1 ); // color
1126   mgr->setRule( action( 8032 ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", true );
1127   mgr->insert( action(  8033 ), -1, -1 ); // transparency
1128   mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, true );
1129   mgr->insert( action(  8034 ), -1, -1 ); // isos
1130   mgr->setRule( action( 8034 ), "client='OCCViewer' and selcount>0 and isVisible", true );
1131   mgr->insert( separator(), -1, -1 );     // -----------
1132
1133
1134   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
1135           onlyComponent = "((type='Component') and selcount=1)",
1136           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
1137           types = "'Shape' 'Group'";
1138
1139   mgr->insert( action(  216 ), -1, -1 ); // display
1140   mgr->setRule( action( 216 ), rule.arg( types ).arg( "not isVisible" ), true );
1141
1142   mgr->insert( action(  215 ), -1, -1 ); // erase
1143   mgr->setRule( action( 215 ), rule.arg( types ).arg( "isVisible" ), true );
1144
1145   mgr->insert( action(  214 ), -1, -1 ); // erase All
1146   mgr->setRule( action( 214 ), clientOCCorVTK, true );
1147
1148   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
1149   
1150   int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
1151   mgr->insert( action(2171), selectolnyId, -1);                                  //Vertex
1152   mgr->setRule(action(2171), selectOnly, true);
1153   mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", false);
1154   mgr->insert( action(2172), selectolnyId, -1);                                  //Edge
1155   mgr->setRule(action(2172), selectOnly, true);
1156   mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", false);
1157   mgr->insert( action(2173), selectolnyId, -1);                                  //Wire
1158   mgr->setRule(action(2173), selectOnly, true);
1159   mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", false);
1160   mgr->insert( action(2174), selectolnyId, -1);                                  //Face
1161   mgr->setRule(action(2174), selectOnly, true);
1162   mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", false);
1163   mgr->insert( action(2175), selectolnyId, -1);                                  //Shell
1164   mgr->setRule(action(2175), selectOnly, true);
1165   mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", false);
1166   mgr->insert( action(2176), selectolnyId, -1);                                  //Solid
1167   mgr->setRule(action(2176), selectOnly, true);
1168   mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", false);
1169   mgr->insert( action(2177), selectolnyId, -1);                                  //Compound
1170   mgr->setRule(action(2177), selectOnly, true);
1171   mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", false);
1172   mgr->insert( separator(), selectolnyId, -1);
1173   mgr->insert( action(2178), selectolnyId, -1);                                  //Clear selection filter
1174   mgr->setRule(action(2178), selectOnly, true);
1175   mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", false);
1176   
1177   mgr->insert( action(  213 ), -1, -1 ); // display only
1178   mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), true );
1179   mgr->insert( separator(), -1, -1 );
1180
1181   mgr->hide( mgr->actionId( action( myEraseAll ) ) );
1182 }
1183
1184 //=======================================================================
1185 // function : GeometryGUI::activateModule()
1186 // purpose  : Called when GEOM module is activated
1187 //=======================================================================
1188 bool GeometryGUI::activateModule( SUIT_Study* study )
1189 {
1190   if ( CORBA::is_nil( myComponentGeom ) )
1191     return false;
1192
1193   bool res = SalomeApp_Module::activateModule( study );
1194
1195   if ( !res )
1196     return false;
1197
1198   setMenuShown( true );
1199   setToolShown( true );
1200
1201   connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1202           this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1203
1204   // Reset actions accelerator keys
1205   //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
1206   //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
1207   action(111)->setEnabled(true); // Import
1208   action(121)->setEnabled(true); // Export
1209
1210   GUIMap::Iterator it;
1211   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1212     it.data()->activate( application()->desktop() );
1213
1214   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1215   SUIT_ViewManager* vm;
1216   ViewManagerList OCCViewManagers, VTKViewManagers;
1217   application()->viewManagers( OCCViewer_Viewer::Type(), OCCViewManagers );
1218   for ( vm = OCCViewManagers.first(); vm; vm = OCCViewManagers.next() )
1219     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1220   application()->viewManagers( SVTK_Viewer::Type(), VTKViewManagers );
1221   for ( vm = VTKViewManagers.first(); vm; vm = VTKViewManagers.next() )
1222     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1223
1224   // disable OCC selectors
1225   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1226   for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1227     sr->setEnabled(true);
1228
1229   // disable VTK selectors
1230   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1231   for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1232     sr->setEnabled(true);
1233
1234   return true;
1235 }
1236
1237
1238 //=======================================================================
1239 // function : GeometryGUI::deactivateModule()
1240 // purpose  : Called when GEOM module is deactivated
1241 //=======================================================================
1242 bool GeometryGUI::deactivateModule( SUIT_Study* study )
1243 {
1244   setMenuShown( false );
1245   setToolShown( false );
1246
1247   disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
1248              this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
1249
1250   EmitSignalCloseAllDialogs();
1251
1252   GUIMap::Iterator it;
1253   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
1254     it.data()->deactivate();
1255
1256   // Unset actions accelerator keys
1257   //action(111)->setAccel(QKeySequence()); // Import
1258   //action(121)->setAccel(QKeySequence()); // Export
1259   action(111)->setEnabled(false); // Import
1260   action(121)->setEnabled(false); // Export
1261
1262   myOCCSelectors.clear();
1263   getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
1264
1265   myVTKSelectors.clear();
1266   getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
1267
1268   return SalomeApp_Module::deactivateModule( study );
1269 }
1270
1271 //=================================================================================
1272 // function : GeometryGUI::DefinePopup()
1273 // purpose  : Called from desktop to define popup menu [static]
1274 //=================================================================================
1275 /*
1276 void GeometryGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject)
1277 {
1278   QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
1279   SALOME_Selection* Sel  = SALOME_Selection::Selection(ActiveStudy->getSelection());
1280
1281   theObject  = "";
1282   theContext = "";
1283
1284   if ( theParent == "Viewer" ) {
1285     if ( Sel->IObjectCount() == 0 )
1286       theContext = "NothingSelected";
1287   }
1288
1289   if ( Sel->IObjectCount() == 1 ) {
1290     Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
1291     if( IO->hasEntry() ) {
1292       SALOMEDS::SObject_var sobj = ActiveStudy->getStudyDocument()->FindObjectID( IO->getEntry() );
1293       if ( !sobj->_is_nil() ) {
1294         SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
1295         if ( !strcmp(scomp->GetID(), IO->getEntry() ) ) {
1296           // component is selected
1297           theObject = "Component";
1298         }
1299         else {
1300           GEOM::GEOM_Object_var aGObj = GEOM::GEOM_Object::_narrow( sobj->GetObject() );
1301           if ( !CORBA::is_nil( aGObj ) ) {
1302             switch( aGObj->GetType() ) {
1303             case GEOM_GROUP:
1304               theObject = "Group";
1305               break;
1306             default:
1307               theObject = "Shape";
1308               break;
1309             }
1310           }
1311         }
1312       }
1313     }
1314   }
1315 }
1316
1317 //=================================================================================
1318 // function : GeometryGUI::CustomPopup()
1319 // purpose  : Called from desktop to create popup menu [static]
1320 //=================================================================================
1321 bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
1322                               const QString& theParent, const QString& theObject)
1323 {
1324   GeometryGUI* geomGUI = GetGeomGUI();
1325
1326   // Deactivate any non modal dialog box to get the neutral point
1327   geomGUI->EmitSignalDeactivateDialog();
1328   QAD_Study* anActiveStudy    = parent->getActiveStudy();
1329   QAD_StudyFrame* aStudyFrame = anActiveStudy->getActiveStudyFrame();
1330   QAD_ViewFrame* aViewFrame   = aStudyFrame->getRightFrame()->getViewFrame();
1331   SALOME_Selection* Sel       = SALOME_Selection::Selection(anActiveStudy->getSelection());
1332   QString parentComponent     = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
1333   bool isOCCViewer            = aViewFrame->getTypeView() == VIEW_OCC;
1334   bool isVTKViewer            = aViewFrame->getTypeView() == VIEW_VTK;
1335   int aDisplayMode            = 0;
1336   QString objectName;
1337
1338   if ( aViewFrame->getTypeView() == VIEW_OCC )
1339     aDisplayMode = ((OCCViewer_ViewFrame*)aViewFrame)->getViewer()->getAISContext()->DisplayMode();
1340   else if ( aViewFrame->getTypeView() == VIEW_VTK )
1341     aDisplayMode = (dynamic_cast<SVTK_ViewFrame*>( aViewFrame )->getRWInteractor()->GetDisplayMode();
1342
1343   int nbSel = Sel->IObjectCount();
1344
1345   if( nbSel == 0 ) {
1346     ////// NOTHING SELECTED
1347     popup->clear();
1348   }
1349   else if ( nbSel == 1 ) {
1350     ////// SINGLE OBJECT SELECTION
1351     if ( parentComponent != parent->getActiveComponent() )  {
1352       ////// selected object does not belong to GEOM module:
1353       // remove all commands except Display/Erase...
1354       while ( 1 ) {
1355         int id = popup->idAt( 0 );
1356         if ( id <= QAD_TopLabel_Popup_ID )
1357           popup->removeItemAt( 0 );
1358         else
1359           break;
1360       }
1361     }
1362     else {
1363       ////// selected object belong to the GEOM module
1364       // get interactive object
1365       Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
1366       objectName = IObject->getName();
1367       // if object has entry get SObject
1368       SALOMEDS::SObject_var SO;
1369       if ( IObject->hasEntry() )
1370         SO = anActiveStudy->getStudyDocument()->FindObjectID( IObject->getEntry() );
1371
1372       if ( theObject == "Component" ) {
1373         ////// menu for component
1374         if ( !isOCCViewer && !isVTKViewer ) {
1375           popup->removeItem( QAD_DisplayOnly_Popup_ID );
1376           popup->removeItem( QAD_Display_Popup_ID );
1377           popup->removeItem( QAD_Erase_Popup_ID );
1378         }
1379       }
1380       else {
1381         ////// not component (should be shape)
1382         if ( IObject->hasEntry() )  /////// VSR : TO BE REMOVED
1383           popup->removeItem( 804 ); // "Add in Study"
1384
1385         // Here could be analysis of the geom shape's type
1386         // ... //
1387
1388         SALOMEDS::GenericAttribute_var aTmpAttr;
1389         if( SO->_is_nil() || SO->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR") )
1390           popup->removeItem( 9024 ); // "Open" /////// VSR : TO BE REMOVED
1391
1392         if ( !isOCCViewer && theParent == "ObjectBrowser" ) {
1393           if ( theObject == "Shape" )
1394             popup->removeItem( 800 ); // Create Group
1395           else if ( theObject == "Group" )
1396             popup->removeItem( 801 ); // Edit Group
1397         }
1398
1399         if ( isOCCViewer || isVTKViewer ) {
1400           ////// current viewer is OCC or VTK
1401           SALOME_Prs* prs = aViewFrame->CreatePrs( IObject->getEntry() );
1402           if ( aViewFrame->isVisible( IObject ) ) {
1403             ////// object is already displayed in the viewer
1404             popup->removeItem( QAD_Display_Popup_ID );
1405             if ( isOCCViewer ) {
1406               ////// OCC viewer only
1407               OCCViewer_Prs* occPrs = dynamic_cast<OCCViewer_Prs*>( prs );
1408               if ( occPrs && !occPrs->IsNull() ) {
1409                 AIS_ListOfInteractive ioList;
1410                 occPrs->GetObjects( ioList );
1411                 QMenuItem* mi = popup->findItem( 803 );
1412                 if ( mi && mi->popup() ) {
1413                   if ( ioList.First()->DisplayMode() == 0 )
1414                     mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
1415                   else if ( ioList.First()->DisplayMode() == 1 )
1416                     mi->popup()->setItemChecked( 80312, true ); // "Shading"
1417                   else if ( ioList.First()->DisplayMode() < 0 )
1418                     mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
1419                 }
1420               }
1421             }
1422             else {
1423               ////// VTK viewer only
1424               popup->removeItem( 8034 ); // "Isos"
1425               SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
1426               if ( vtkPrs && !vtkPrs->IsNull() ) {
1427                 vtkActorCollection* actorList = vtkPrs->GetObjects();
1428                 actorList->InitTraversal();
1429                 SALOME_Actor* ac = SALOME_Actor::SafeDownCast( actorList->GetNextActor() );
1430                 QMenuItem* mi = popup->findItem( 803 );
1431                 if ( ac && mi && mi->popup() ) {
1432                   if ( ac->getDisplayMode() == 0 )
1433                     mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
1434                   else if ( ac->getDisplayMode() == 1 )
1435                     mi->popup()->setItemChecked( 80312, true ); // "Shading"
1436                   else
1437                     mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
1438                 }
1439               }
1440             }
1441           }
1442           else {
1443             ////// object is not yet displayed in the viewer
1444             popup->removeItem( 803 );  // "Display Mode"
1445             popup->removeItem( 8032 ); // "Color"
1446             popup->removeItem( 8033 ); // "Transparency"
1447             popup->removeItem( 8034 ); // "Isos"
1448             popup->removeItem( QAD_Erase_Popup_ID );
1449           }
1450           delete prs;
1451         }
1452         else {
1453           ////// other viewer type (neither OCC nor VTK)
1454           popup->removeItem( 803 );  // "Display Mode"
1455           popup->removeItem( 8032 ); // "Color"
1456           popup->removeItem( 8033 ); // "Transparency"
1457           popup->removeItem( 8034 ); // "Isos"
1458           popup->removeItem( QAD_Display_Popup_ID );
1459           popup->removeItem( QAD_DisplayOnly_Popup_ID );
1460           popup->removeItem( QAD_Erase_Popup_ID );
1461         }
1462       }
1463     }
1464   }
1465   else {
1466     ////// MULTIPLE SELECTION
1467     if ( parentComponent != parent->getActiveComponent() )  {
1468       ////// not GEOM module objects or objects belong to different modules
1469       // remove all commands except Display/Erase...
1470       while ( 1 ) {
1471         int id = popup->idAt( 0 );
1472         if ( id <= QAD_TopLabel_Popup_ID )
1473           popup->removeItemAt( 0 );
1474         else
1475           break;
1476       }
1477       if ( parentComponent.isNull() )  {
1478         ////// objects belong to different modules
1479         popup->removeItem(QAD_Display_Popup_ID);
1480         popup->removeItem(QAD_DisplayOnly_Popup_ID);
1481         popup->removeItem(QAD_Erase_Popup_ID);
1482       }
1483       else {
1484         objectName = tr( "GEOM_MEN_POPUP_NAME" ).arg( nbSel );
1485       }
1486     }
1487     else {
1488       ////// all selected objects belong to GEOM module
1489       popup->removeItem( 901 ); // "Rename"
1490
1491       SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1492       bool isComponent  = false;
1493       bool needOpen     = false;
1494       bool needDisplay  = false;
1495       bool needErase    = false;
1496       int needToPublish = 0;
1497
1498       for( ;It.More();It.Next() ) {
1499         Handle(SALOME_InteractiveObject) anIObject = It.Value();
1500
1501         if ( aViewFrame->isVisible( anIObject ) )
1502           needErase   = true;
1503         else
1504           needDisplay = true;
1505
1506         if( anIObject->hasEntry() ) {
1507           needToPublish = -1; /////// VSR : TO BE REMOVED
1508           SALOMEDS::SObject_var obj = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
1509           SALOMEDS::GenericAttribute_var aTmpAttr;
1510           if ( !obj->_is_nil() && !obj->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR" ) )
1511             needOpen = true;  /////// VSR : TO BE REMOVED
1512           if ( !obj->_is_nil() && QString( obj->GetID() ) == QString( obj->GetFatherComponent()->GetID() ) )
1513             isComponent = true;
1514         }
1515         else {
1516           if ( needToPublish != -1 ) needToPublish = 1;
1517         }
1518       }
1519       if( needOpen || ( !isOCCViewer && !isVTKViewer ) ) {
1520         ////// Data is not loaded yet or current viewer is neither OCC nor VTK
1521         popup->removeItem( 803 );  // "Display Mode"
1522         popup->removeItem( 8032 ); // "Color"
1523         popup->removeItem( 8033 ); // "Transparency"
1524         popup->removeItem( 8034 ); // "Isos"
1525         popup->removeItem( 804 );  // "Add in Study"
1526         popup->removeItem( QAD_DisplayOnly_Popup_ID );
1527         popup->removeItem( QAD_Display_Popup_ID );
1528         popup->removeItem( QAD_Erase_Popup_ID );
1529       }
1530       else {
1531         popup->removeItem( 9024 );   // "Open"
1532         if ( needToPublish <= 0 )
1533           popup->removeItem( 804 );  // "Add in Study"
1534
1535         if( isComponent ) {
1536           popup->removeItem( 803 );  // "Display Mode"
1537           popup->removeItem( 8032 ); // "Color"
1538           popup->removeItem( 8033 ); // "Transparency"
1539           popup->removeItem( 8034 ); // "Isos"
1540           popup->removeItem( QAD_DisplayOnly_Popup_ID );
1541         }
1542
1543         if ( !needDisplay )
1544           popup->removeItem( QAD_Display_Popup_ID );
1545         if ( !needErase )
1546           popup->removeItem( QAD_Erase_Popup_ID );
1547         if ( !isOCCViewer )
1548           popup->removeItem( 8034 ); // "Isos"
1549       }
1550     }
1551   }
1552
1553   // check popup for unnecessary separators
1554   QAD_Tools::checkPopup( popup );
1555   // find popup menu's TopLabel item (with title)
1556   int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
1557   if ( topItem >= 0 ) {
1558     // remove popup menu's title item
1559     popup->removeItem( QAD_TopLabel_Popup_ID );
1560     if ( theParent == "Viewer" && !objectName.isEmpty() && popup->count() > 0 ) {
1561       // set bold font for popup menu's title
1562       QFont f = popup->font(); f.setBold( TRUE );
1563       popup->removeItem( QAD_TopLabel_Popup_ID );
1564       popup->insertItem( new CustomItem( objectName, f ), QAD_TopLabel_Popup_ID, topItem );
1565     }
1566   }
1567
1568   return false;
1569 }
1570
1571 */
1572
1573 //=======================================================================
1574 // function : GeometryGUI::BuildPresentation()
1575 // purpose  :
1576 //=======================================================================
1577 void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& io, SUIT_ViewWindow* win )
1578 {
1579   //GEOM_Displayer().Display( io, false, win );
1580 }
1581
1582 //=======================================================================
1583 // function : onWindowActivated()
1584 // purpose  : update menu items' status - disable non-OCC-viewer-compatible actions
1585 //=======================================================================
1586 void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
1587 {
1588   if ( !win )
1589     return;
1590
1591   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
1592 //  const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
1593
1594   // disable non-OCC viewframe menu commands
1595 //  action( 404 )->setEnabled( ViewOCC ); // SKETCHER
1596   action( 603 )->setEnabled( ViewOCC ); // SuppressFace
1597   action( 604 )->setEnabled( ViewOCC ); // SuppressHole
1598   action( 606 )->setEnabled( ViewOCC ); // CloseContour
1599   action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
1600   action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
1601 //  action( 609 )->setEnabled( ViewOCC ); // Free boundaries
1602   action( 413 )->setEnabled( ViewOCC ); // Isos Settings
1603
1604   action( 800 )->setEnabled( ViewOCC ); // Create Group
1605   action( 801 )->setEnabled( ViewOCC ); // Edit Group
1606
1607   action( 9998 )->setEnabled( ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION
1608 }
1609
1610 void GeometryGUI::windows( QMap<int, int>& mappa ) const
1611 {
1612   mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
1613   mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
1614 }
1615
1616 void GeometryGUI::viewManagers( QStringList& lst ) const
1617 {
1618   lst.append( OCCViewer_Viewer::Type() );
1619 }
1620
1621 void GeometryGUI::onViewManagerAdded( SUIT_ViewManager* vm )
1622 {
1623   if ( vm->getType() == OCCViewer_Viewer::Type() )
1624   {
1625     qDebug( "connect" );
1626     connect( vm, SIGNAL( keyPress  ( SUIT_ViewWindow*, QKeyEvent* ) ),
1627              this, SLOT( OnKeyPress( SUIT_ViewWindow*, QKeyEvent* ) ) );
1628     connect( vm, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
1629              this, SLOT( OnMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
1630     connect( vm, SIGNAL( mouseMove ( SUIT_ViewWindow*, QMouseEvent* ) ),
1631              this, SLOT( OnMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1632
1633
1634     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1635     myOCCSelectors.append( new GEOMGUI_OCCSelector( ((OCCViewer_ViewManager*)vm)->getOCCViewer(), sm ) );
1636
1637     // disable OCC selectors
1638     getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
1639     for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1640       sr->setEnabled(true);
1641   }
1642   else if ( vm->getType() == SVTK_Viewer::Type() )
1643   {
1644     LightApp_SelectionMgr* sm = getApp()->selectionMgr();
1645     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
1646
1647     // disable VTK selectors
1648     getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
1649     for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1650       sr->setEnabled(true);
1651   }
1652 }
1653
1654 void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
1655 {
1656   SUIT_ViewModel* viewer = vm->getViewModel();
1657   if ( vm->getType() == OCCViewer_Viewer::Type() )
1658   {
1659     for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() )
1660       if ( sr->viewer() == viewer )
1661       {
1662         myOCCSelectors.remove( sr );
1663         break;
1664       }
1665   }
1666   if ( vm->getType() == SVTK_Viewer::Type() )
1667   {
1668     for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() )
1669       if ( sr->viewer() == viewer )
1670       {
1671         myVTKSelectors.remove( sr );
1672         break;
1673       }
1674   }
1675 }
1676
1677 QString GeometryGUI::engineIOR() const
1678 {
1679   if ( !CORBA::is_nil( GetGeomGen() ) )
1680     return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
1681   return QString( "" );
1682 }
1683
1684 LightApp_Selection* GeometryGUI::createSelection() const
1685 {
1686   return new GEOMGUI_Selection();
1687 }
1688
1689 void GeometryGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& title )
1690 {
1691   SalomeApp_Module::contextMenuPopup( client, menu, title );
1692   SALOME_ListIO lst;
1693   getApp()->selectionMgr()->selectedObjects( lst );
1694   if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
1695     Handle(SALOME_InteractiveObject) io = lst.First();
1696     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
1697     _PTR(Study) study = appStudy->studyDS();
1698     _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
1699     if ( obj )
1700       title = QString( obj->GetName().c_str() );
1701   }
1702 }
1703
1704 void GeometryGUI::createPreferences()
1705 {
1706   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
1707
1708   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
1709   setPreferenceProperty( genGroup, "columns", 1 );
1710
1711   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
1712                             LightApp_Preferences::Selector, "Geometry", "display_mode" );
1713
1714   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
1715                  LightApp_Preferences::Color, "Geometry", "shading_color" );
1716
1717   addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup,
1718                  LightApp_Preferences::Color, "Geometry", "wireframe_color" );
1719
1720   addPreference( tr( "PREF_FREE_BOUND_COLOR" ), genGroup,
1721                  LightApp_Preferences::Color, "Geometry", "free_bound_color" );
1722
1723   addPreference( tr( "PREF_LINE_COLOR"), genGroup,
1724                  LightApp_Preferences::Color, "Geometry", "line_color" );
1725
1726   addPreference( tr( "PREF_POINT_COLOR"), genGroup,
1727                  LightApp_Preferences::Color, "Geometry", "point_color" );
1728
1729   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
1730                  LightApp_Preferences::Color, "Geometry", "isos_color" );
1731
1732   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
1733                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
1734
1735   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
1736
1737   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
1738                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
1739
1740   int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), VertexGroup,
1741                                    LightApp_Preferences::DblSpin, "Geometry", "marker_scale" );
1742
1743   // Set property for default display mode
1744   QStringList aModesList;
1745   aModesList.append( tr("MEN_WIREFRAME") );
1746   aModesList.append( tr("MEN_SHADING") );
1747
1748   QValueList<QVariant> anIndexesList;
1749   anIndexesList.append(0);
1750   anIndexesList.append(1);
1751
1752   setPreferenceProperty( dispmode, "strings", aModesList );
1753   setPreferenceProperty( dispmode, "indexes", anIndexesList );
1754
1755   // Set property for step value for spinboxes
1756   setPreferenceProperty( step, "min", 0.001 );
1757   setPreferenceProperty( step, "max", 10000 );
1758   setPreferenceProperty( step, "precision", 3 );
1759
1760   // Set property for type of vertex marker
1761   QStringList aTypeOfMarkerList;
1762   QValueList<QVariant> anTypeOfMarkerIndexesList;
1763
1764   aTypeOfMarkerList.append( tr("TOM_PLUS") );
1765   anTypeOfMarkerIndexesList.append(Aspect_TOM_PLUS);
1766
1767   aTypeOfMarkerList.append( tr("TOM_POINT") );
1768   anTypeOfMarkerIndexesList.append(Aspect_TOM_POINT);
1769
1770   aTypeOfMarkerList.append( tr("TOM_STAR") );
1771   anTypeOfMarkerIndexesList.append(Aspect_TOM_STAR);
1772
1773   aTypeOfMarkerList.append( tr("TOM_O") );
1774   anTypeOfMarkerIndexesList.append(Aspect_TOM_O);
1775
1776   aTypeOfMarkerList.append( tr("TOM_X") );
1777   anTypeOfMarkerIndexesList.append(Aspect_TOM_X);
1778
1779   aTypeOfMarkerList.append( tr("TOM_O_POINT") );
1780   anTypeOfMarkerIndexesList.append(Aspect_TOM_O_POINT);
1781
1782   aTypeOfMarkerList.append( tr("TOM_O_PLUS") );
1783   anTypeOfMarkerIndexesList.append(Aspect_TOM_O_PLUS);
1784
1785   aTypeOfMarkerList.append( tr("TOM_O_STAR") );
1786   anTypeOfMarkerIndexesList.append(Aspect_TOM_O_STAR);
1787
1788   aTypeOfMarkerList.append( tr("TOM_O_X") );
1789   anTypeOfMarkerIndexesList.append(Aspect_TOM_O_X);
1790
1791
1792   setPreferenceProperty( typeOfMarker, "strings", aTypeOfMarkerList );
1793   setPreferenceProperty( typeOfMarker, "indexes", anTypeOfMarkerIndexesList );
1794
1795   // Set property for Vertex Marker scale
1796   setPreferenceProperty( markerScale, "min", 1. );
1797   setPreferenceProperty( markerScale, "max", 7. );
1798   setPreferenceProperty( markerScale, "precision", 0.01 );
1799   setPreferenceProperty( markerScale, "step", 0.5 );
1800
1801 }
1802
1803 void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
1804 {
1805   if (section == "Geometry") {
1806     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
1807     if (param == QString("SettingsGeomStep")) {
1808       double spin_step = aResourceMgr->doubleValue(section, param, 100.);
1809       EmitSignalDefaultStepValueChanged(spin_step);
1810     }
1811   }
1812 }
1813
1814 LightApp_Displayer* GeometryGUI::displayer()
1815 {
1816   if( !myDisplayer )
1817     myDisplayer = new GEOM_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );
1818   return myDisplayer;
1819 }
1820
1821 void GeometryGUI::setLocalSelectionMode(const int mode)
1822 {
1823   myLocalSelectionMode = mode;
1824 }
1825 int GeometryGUI::getLocalSelectionMode() const
1826 {
1827   return myLocalSelectionMode;
1828 }