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