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