Salome HOME
Fix regression: storeViewParameters() does not work for OCC view
[modules/geom.git] / src / GEOMGUI / GeometryGUI.h
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : GeometryGUI.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 //
27 #ifndef GEOMETRYGUI_H
28 #define GEOMETRYGUI_H
29
30 #include "GEOM_GEOMGUI.hxx"
31
32 #include <SalomeApp_Module.h>
33
34 #include <GEOM_Client.hxx>
35 #include <SALOME_InteractiveObject.hxx>
36 #include <SALOMEDSClient.hxx>
37
38 #include "GEOMGUI.h"
39
40 // QT Includes
41 #include <QMap>
42
43 // OCCT Includes
44 #include <gp_Ax3.hxx>
45 #include <Graphic3d_HArray1OfBytes.hxx>
46
47 // IDL headers
48 #include "SALOMEconfig.h"
49 #include CORBA_CLIENT_HEADER(SALOMEDS)
50
51 // minimum allowed value for deflection coefficient
52 #define DEFLECTION_MIN 1e-06
53
54 class QDialog;
55 class QMenu;
56 class GEOMGUI_OCCSelector;
57 class LightApp_VTKSelector;
58 class LightApp_Selection;
59 class SUIT_ViewManager;
60 class SalomeApp_Study;
61
62 //=================================================================================
63 // class    : GeometryGUI
64 // purpose  :
65 //=================================================================================
66 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
67 {
68   Q_OBJECT;
69
70 public:
71   // Constructor
72   GeometryGUI();
73
74   // Destructor
75   ~GeometryGUI();
76
77   virtual LightApp_Displayer* displayer();
78   virtual void                initialize( CAM_Application* );
79   virtual QString             engineIOR() const;
80
81   static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
82
83   static bool                 InitGeomGen();
84
85   static  GEOM::GEOM_Gen_var  GetGeomGen();
86
87   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
88   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
89
90   static void                 Modified( bool = true );
91
92   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
93
94   // Get active dialog box
95   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
96   // Set active dialog box
97   void                        SetActiveDialogBox( QDialog* aDlg );
98
99   // Non modal dialog boxes management
100   void                        EmitSignalDeactivateDialog();
101   void                        EmitSignalCloseAllDialogs();
102   void                        EmitSignalDefaultStepValueChanged( double newVal );
103
104   // Process action
105   void                        OnGUIEvent( int id );
106
107   // The Working Plane management
108   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
109   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
110   void                        ActiveWorkingPlane();
111
112   virtual void                windows( QMap<int, int>& ) const;
113   virtual void                viewManagers( QStringList& ) const;
114
115   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
116   virtual void                createPreferences();
117   virtual void                preferencesChanged( const QString&, const QString& );
118   int                         getLocalSelectionMode() const;
119   void                        setLocalSelectionMode(const int mode);
120
121   virtual void storeVisualParameters  (int savePoint);
122   virtual void restoreVisualParameters(int savePoint);
123
124 public slots:
125   virtual bool                deactivateModule( SUIT_Study* );
126   virtual bool                activateModule( SUIT_Study* );
127   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
128   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
129   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
130
131 protected slots:
132   virtual void                onViewManagerAdded( SUIT_ViewManager* );
133   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
134
135 private slots:
136   void                        OnGUIEvent();
137   void                        onWindowActivated( SUIT_ViewWindow* );
138   void                        onViewAboutToShow();
139
140 signals :
141   void                        SignalDeactivateActiveDialog();
142   void                        SignalCloseAllDialogs();
143   void                        SignalDefaultStepValueChanged( double newVal );
144
145 protected:
146   virtual LightApp_Selection* createSelection() const;
147
148 private:
149   GEOMGUI*                    getLibrary( const QString& libraryName );
150   void                        createGeomAction( const int id, const QString& po_id,
151                                                 const QString& icon_id = QString(""),
152                                                 const int key = 0, const bool toggle = false,
153                                                 const QString& shortcutAction = QString() );
154   void                        createPopupItem( const int, const QString& clients, const QString& types,
155                                                const bool isSingle = false, const int isVisible = -1,
156                                                const bool isExpandAll = false, const bool isOCC = false,
157                                                const int parentId = -1 );
158
159   void                        createOriginAndBaseVectors();
160
161 public:
162   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
163
164 private:  
165
166   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
167   typedef QMap<long, TextureMap> StudyTextureMap;
168   typedef QMap<QString, GEOMGUI*> GUIMap;
169
170   GUIMap                      myGUIMap;          // GUI libraries map
171   QDialog*                    myActiveDialogBox; // active dialog box
172   gp_Ax3                      myWorkingPlane;
173   QMap<int,QString>           myRules;           // popup rules
174   static StudyTextureMap      myTextureMap;      // texture map
175
176   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
177   QList<LightApp_VTKSelector*> myVTKSelectors;
178
179   LightApp_Displayer*         myDisplayer;
180   int                         myLocalSelectionMode; //Select Only
181
182   friend class DisplayGUI;
183 };
184
185 #endif