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