Salome HOME
untabify
[modules/geom.git] / src / GEOMGUI / GeometryGUI.h
1 //  Copyright (C) 2007-2008  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 <SalomeApp_Module.h>
32
33 #include <GEOM_Client.hxx>
34 #include <SALOME_InteractiveObject.hxx>
35 #include <SALOMEDSClient.hxx>
36
37 #include "GEOMGUI.h"
38
39 // QT Includes
40 #include <QMap>
41
42 // OCCT Includes
43 #include <gp_Ax3.hxx>
44 #include <Graphic3d_HArray1OfBytes.hxx>
45
46 // IDL headers
47 #include "SALOMEconfig.h"
48 #include CORBA_CLIENT_HEADER(SALOMEDS)
49
50 typedef QMap<QString, GEOMGUI*> GUIMap;
51
52 class QDialog;
53 class QMenu;
54 class GEOMGUI_OCCSelector;
55 class LightApp_VTKSelector;
56 class LightApp_Selection;
57 class SUIT_ViewManager;
58 class SalomeApp_Study;
59
60 //=================================================================================
61 // class    : GeometryGUI
62 // purpose  :
63 //=================================================================================
64 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
65 {
66   Q_OBJECT;
67
68 public:
69   // Constructor
70   GeometryGUI();
71
72   // Destructor
73   ~GeometryGUI();
74
75   virtual LightApp_Displayer* displayer();
76   virtual void                initialize( CAM_Application* );
77   virtual QString             engineIOR() const;
78
79   static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
80
81   static bool                 InitGeomGen();   //BugID IPAL9186: SRN: To be called by Python scripts
82
83   static  GEOM::GEOM_Gen_var  GetGeomGen();//        { return GeometryGUI::myComponentGeom; }
84
85   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
86   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
87
88   GEOM_Client&                GetShapeReader()    { return myShapeReader; }
89   Standard_CString&           GetFatherior()      { return myFatherior; }
90   //void                        SetState( const int state ) { myState = state; }
91   //int                         GetState() const    { return myState; }
92
93   // Get active dialog box
94   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
95   // Set active dialog box
96   void                        SetActiveDialogBox( QDialog* aDlg );
97
98   // Non modal dialog boxes management
99   void                        EmitSignalDeactivateDialog();
100   void                        EmitSignalCloseAllDialogs();
101   void                        EmitSignalDefaultStepValueChanged( double newVal );
102
103   void                        OnGUIEvent( int id );
104
105 //  virtual bool                SetSettings();
106 //  virtual void                SupportedViewType ( int* buffer, int bufferSize );
107   virtual void                BuildPresentation( const Handle(SALOME_InteractiveObject)&, SUIT_ViewWindow* = 0 );
108
109 //  virtual void                DefinePopup( QString & theContext, QString & theParent, QString & theObject);
110 //  virtual bool                CustomPopup( QAD_Desktop* parent, QMenu* popup, const QString& theContext,
111 //                                         const QString& theParent, const QString& theObject );
112
113   // The Working Plane management
114   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
115   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
116   void                        ActiveWorkingPlane();
117
118   virtual void                windows( QMap<int, int>& ) const;
119   virtual void                viewManagers( QStringList& ) const;
120
121   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
122   virtual void                createPreferences();
123   virtual void                preferencesChanged( const QString&, const QString& );
124   int                         getLocalSelectionMode() const;
125   void                        setLocalSelectionMode(const int mode);
126
127   virtual void storeVisualParameters  (int savePoint);
128   virtual void restoreVisualParameters(int savePoint);
129
130 public slots:
131   virtual bool                deactivateModule( SUIT_Study* );
132   virtual bool                activateModule( SUIT_Study* );
133   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
134   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
135   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
136
137 protected slots:
138   virtual void                onViewManagerAdded( SUIT_ViewManager* );
139   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
140
141 private slots:
142   void                        OnGUIEvent();
143   void                        onWindowActivated( SUIT_ViewWindow* );
144   void                        onViewAboutToShow();
145
146 signals :
147   void                        SignalDeactivateActiveDialog();
148   void                        SignalCloseAllDialogs();
149   void                        SignalDefaultStepValueChanged( double newVal );
150
151 protected:
152   virtual LightApp_Selection* createSelection() const;
153
154 private:
155   GEOMGUI*                    getLibrary( const QString& libraryName );
156   void                        createGeomAction( const int id, const QString& po_id,
157                                                 const QString& icon_id = QString(""),
158                                                 const int key = 0, const bool toggle = false );
159   void                        createPopupItem( const int, const QString& clients, const QString& types,
160                                                const bool isSingle = false, const int isVisible = -1,
161                                                const bool isExpandAll = false, const bool isOCC = false,
162                                                const int parentId = -1 );
163
164 public:
165   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
166
167 private:  
168
169   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
170   typedef QMap<long, TextureMap> StudyTextureMap;
171   
172   GUIMap                      myGUIMap;          // GUI libraries map
173   QDialog*                    myActiveDialogBox; // active dialog box
174   GEOM_Client                 myShapeReader;     // geom shape reader
175   Standard_CString            myFatherior;
176   int                         myState;           // identify a method
177   gp_Ax3                      myWorkingPlane;
178   QMap<int,QString>           myRules;           // popup rules
179   static StudyTextureMap      myTextureMap;      // texture map
180
181   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
182   QList<LightApp_VTKSelector*> myVTKSelectors;
183
184   LightApp_Displayer*         myDisplayer;
185   int                         myLocalSelectionMode; //Select Only
186
187   friend class DisplayGUI;
188 };
189
190 #endif