]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI.h
Salome HOME
Windows porting
[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 void                initialize( CAM_Application* );
92   virtual QString             engineIOR() const;
93
94   static bool                 InitGeomGen();   //BugID IPAL9186: SRN: To be called by Python scripts
95
96   static  GEOM::GEOM_Gen_var  GetGeomGen();//        { return GeometryGUI::myComponentGeom; }
97
98   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
99   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
100
101   GEOM_Client&                GetShapeReader()    { return myShapeReader; }
102   Standard_CString&           GetFatherior()      { return myFatherior; }
103   //void                        SetState( const int state ) { myState = state; }
104   //int                         GetState() const    { return myState; }
105
106   // Get active dialog box
107   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
108   // Set active dialog box
109   void                        SetActiveDialogBox( QDialog* aDlg );
110
111   // Non modal dialog boxes management
112   void                        EmitSignalDeactivateDialog();
113   void                        EmitSignalCloseAllDialogs();
114   void                        EmitSignalDefaultStepValueChanged( double newVal );
115
116   void                        OnGUIEvent( int id );
117
118   virtual bool                OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
119   virtual bool                OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
120   virtual bool                OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
121
122 //  virtual bool                SetSettings();
123 //  virtual void                SupportedViewType ( int* buffer, int bufferSize );
124   virtual void                BuildPresentation( const Handle(SALOME_InteractiveObject)&, SUIT_ViewWindow* = 0 );
125
126 //  virtual void                DefinePopup( QString & theContext, QString & theParent, QString & theObject);
127 //  virtual bool                CustomPopup( QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
128 //                                         const QString& theParent, const QString& theObject );
129
130   // The Working Plane management
131   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
132   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
133   void                        ActiveWorkingPlane();
134
135   virtual void                windows( QMap<int, int>& ) const;
136   virtual void                viewManagers( QStringList& ) const;
137
138   virtual void                contextMenuPopup( const QString&, QPopupMenu*, QString& );
139   virtual void                createPreferences();
140   virtual void                preferencesChanged( const QString&, const QString& );
141
142
143 public slots:
144   virtual bool                deactivateModule( SUIT_Study* );
145   virtual bool                activateModule( SUIT_Study* );
146
147 private slots:
148   void                        OnGUIEvent();
149   void                        onViewManagerAdded( SUIT_ViewManager* );
150   void                        onViewManagerRemoved( SUIT_ViewManager* );
151   void                        onWindowActivated( SUIT_ViewWindow* );
152
153 signals :
154   void                        SignalDeactivateActiveDialog();
155   void                        SignalCloseAllDialogs();
156   void                        SignalDefaultStepValueChanged( double newVal );
157
158 protected:
159   virtual SalomeApp_Selection* createSelection() const;
160
161 private:
162   GEOMGUI*                    getLibrary( const QString& libraryName );
163   void                        createGeomAction( const int id, const QString& po_id,
164                                                 const QString& icon_id = QString(""),
165                                                 const int key = 0, const bool toggle = false );
166   void                        createPopupItem( const int, const QString& clients, const QString& types,
167                                                const bool isSingle = false, const int isVisible = -1,
168                                                const bool isExpandAll = false, const bool isOCC = false,
169                                                const int parentId = -1 );
170
171 public:
172   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
173 private:  
174   GUIMap                      myGUIMap;          // GUI libraries map
175   QDialog*                    myActiveDialogBox; // active dialog box
176   GEOM_Client                 myShapeReader;     // geom shape reader
177   Standard_CString            myFatherior;
178   int                         myState;           // identify a method
179   gp_Ax3                      myWorkingPlane;
180   QMap<int,QString>           myRules;           // popup rules
181
182   QPtrList<GEOMGUI_OCCSelector>   myOCCSelectors;
183   QPtrList<SalomeApp_VTKSelector> myVTKSelectors;
184 };
185
186 #endif