Salome HOME
2f56a0029bc5a9c4fb175162163007a01ae1e85f
[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 #include <qmap.h>
38
39 #include "gp_Ax3.hxx"
40
41 #ifdef WNT
42 #include <SALOME_WNT.hxx>
43 #else
44 #define SALOME_WNT_EXPORT
45 #endif
46
47 typedef QMap<QString, GEOMGUI*> GUIMap;
48
49 class QDialog;
50 class QPopupMenu;
51 class GEOMGUI_OCCSelector;
52 class SalomeApp_VTKSelector;
53 class SUIT_ViewManager;
54
55
56 //=================================================================================
57 // class    : GeometryGUI
58 // purpose  :
59 //=================================================================================
60 class SALOME_WNT_EXPORT GeometryGUI : public SalomeApp_Module
61 {
62   Q_OBJECT;
63
64 public:
65   // Constructor
66   GeometryGUI(); 
67
68   // Destructor
69   ~GeometryGUI();
70
71   virtual void                initialize( CAM_Application* );
72   virtual QString             engineIOR() const;
73
74   static bool                 InitGeomGen();   //BugID IPAL9186: SRN: To be called by Python scripts 
75
76   static GEOM::GEOM_Gen_var   GetGeomGen()        { return myComponentGeom; }
77   
78   GEOM_Client&                GetShapeReader()    { return myShapeReader; }
79   Standard_CString&           GetFatherior()      { return myFatherior; }
80   //void                        SetState( const int state ) { myState = state; }
81   //int                         GetState() const    { return myState; }
82   
83   // Get active dialog box
84   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
85   // Set active dialog box
86   void                        SetActiveDialogBox( QDialog* aDlg );
87
88   // Non modal dialog boxes management
89   void                        EmitSignalDeactivateDialog();
90   void                        EmitSignalCloseAllDialogs();
91   void                        EmitSignalDefaultStepValueChanged( double newVal );
92
93   void                        OnGUIEvent( int id );
94   
95   virtual bool                OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
96   virtual bool                OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
97   virtual bool                OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
98
99 //  virtual bool                SetSettings();
100 //  virtual void                SupportedViewType ( int* buffer, int bufferSize );
101   virtual void                BuildPresentation( const Handle(SALOME_InteractiveObject)&, SUIT_ViewWindow* = 0 );
102
103 //  virtual void                DefinePopup( QString & theContext, QString & theParent, QString & theObject);
104 //  virtual bool                CustomPopup( QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
105 //                                         const QString& theParent, const QString& theObject );
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&, QPopupMenu*, QString& );
116   virtual void                createPreferences();
117   virtual void                preferencesChanged( const QString&, const QString& );
118
119
120 public slots:
121   virtual bool                deactivateModule( SUIT_Study* );
122   virtual bool                activateModule( SUIT_Study* );
123
124 private slots:
125   void                        OnGUIEvent();
126   void                        onViewManagerAdded( SUIT_ViewManager* );
127   void                        onViewManagerRemoved( SUIT_ViewManager* );
128   void                        onWindowActivated( SUIT_ViewWindow* );
129
130 signals :
131   void                        SignalDeactivateActiveDialog();
132   void                        SignalCloseAllDialogs();
133   void                        SignalDefaultStepValueChanged( double newVal );
134
135 protected:
136   virtual SalomeApp_Selection* createSelection() const;
137
138 private:
139   GEOMGUI*                    getLibrary( const QString& libraryName );
140   void                        createGeomAction( const int id, const QString& po_id, const QString& icon_id = QString(""), const int key = 0, const bool toggle = false );
141   void                        createPopupItem( const int, const QString& clients, const QString& types, 
142                                                const bool isSingle = false, const int isVisible = -1, 
143                                                const bool isExpandAll = false, const bool isOCC = false, const int parentId = -1 );
144
145 private:
146   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine
147
148   GUIMap                      myGUIMap;          // GUI libraries map
149   QDialog*                    myActiveDialogBox; // active dialog box
150   GEOM_Client                 myShapeReader;     // geom shape reader
151   Standard_CString            myFatherior;
152   int                         myState;           // identify a method
153   gp_Ax3                      myWorkingPlane;
154   QMap<int,QString>           myRules;           // popup rules
155
156   QPtrList<GEOMGUI_OCCSelector>   myOCCSelectors;
157   QPtrList<SalomeApp_VTKSelector> myVTKSelectors;
158 };
159
160 #endif
161