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