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