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