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