Salome HOME
0021189: [CEA 451] areCoordsInside implementation in GE
[modules/geom.git] / src / GEOMGUI / GeometryGUI.h
1 //  Copyright (C) 2007-2010  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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : GeometryGUI.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 //
27 #ifndef GEOMETRYGUI_H
28 #define GEOMETRYGUI_H
29
30 #include "GEOM_GEOMGUI.hxx"
31
32 #include <SalomeApp_Module.h>
33
34 #include <GEOM_Client.hxx>
35 #include <SALOME_InteractiveObject.hxx>
36 #include <SALOMEDSClient.hxx>
37
38 #include "GEOMGUI.h"
39
40 // QT Includes
41 #include <QMap>
42
43 // OCCT Includes
44 #include <gp_Ax3.hxx>
45 #include <Graphic3d_HArray1OfBytes.hxx>
46
47 // IDL headers
48 #include "SALOMEconfig.h"
49 #include CORBA_CLIENT_HEADER(SALOMEDS)
50
51 // minimum allowed value for deflection coefficient
52 #define DEFLECTION_MIN 1e-06
53
54 //Define separators
55 #define NAME_SEPARATOR  '_' // character used to separate parameter names
56 #define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b)
57
58 #define VISIBILITY_PROP       "Visibility"      //Object visibility property
59 #define OPACITY_PROP          "Opacity"         //Object opacity property
60 #define TRANSPARENCY_PROP     "Transparency"    //Object transparency property
61 #define DISPLAY_MODE_PROP     "DisplayMode"     //Object display mode property
62 #define ISOS_PROP             "Isos"            //Number of the Isos property of the object
63 #define COLOR_PROP            "Color"           //Color of the object 
64 #define VECTOR_MODE_PROP      "VectorMode"      //Vector mode property
65 #define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
66 #define MARKER_TYPE_PROP      "MarkerType"      // Marker type property
67
68
69 class QDialog;
70 class QMenu;
71 class GEOMGUI_OCCSelector;
72 class LightApp_VTKSelector;
73 class LightApp_Selection;
74 class SUIT_ViewManager;
75 class SalomeApp_Study;
76
77 //=================================================================================
78 // class    : GeometryGUI
79 // purpose  :
80 //=================================================================================
81 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
82 {
83   Q_OBJECT;
84
85 public:
86   // Constructor
87   GeometryGUI();
88
89   // Destructor
90   ~GeometryGUI();
91
92   virtual LightApp_Displayer* displayer();
93   virtual void                initialize( CAM_Application* );
94   virtual QString             engineIOR() const;
95
96   static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
97
98   static bool                 InitGeomGen();
99
100   static  GEOM::GEOM_Gen_var  GetGeomGen();
101
102   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
103   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
104
105   static void                 Modified( bool = true );
106
107   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
108
109   // Get active dialog box
110   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
111   // Set active dialog box
112   void                        SetActiveDialogBox( QDialog* aDlg );
113
114   // Non modal dialog boxes management
115   void                        EmitSignalDeactivateDialog();
116   void                        EmitSignalCloseAllDialogs();
117   void                        EmitSignalDefaultStepValueChanged( double newVal );
118
119   // Process action
120   void                        OnGUIEvent( int id );
121
122   // The Working Plane management
123   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
124   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
125   void                        ActiveWorkingPlane();
126
127   virtual void                windows( QMap<int, int>& ) const;
128   virtual void                viewManagers( QStringList& ) const;
129
130   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
131   virtual void                createPreferences();
132   virtual void                preferencesChanged( const QString&, const QString& );
133   int                         getLocalSelectionMode() const;
134   void                        setLocalSelectionMode(const int mode);
135
136   virtual void storeVisualParameters  (int savePoint);
137   virtual void restoreVisualParameters(int savePoint);
138
139 public slots:
140   virtual bool                deactivateModule( SUIT_Study* );
141   virtual bool                activateModule( SUIT_Study* );
142   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
143   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
144   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
145
146 protected slots:
147   virtual void                onViewManagerAdded( SUIT_ViewManager* );
148   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
149
150 private slots:
151   void                        OnGUIEvent();
152   void                        onWindowActivated( SUIT_ViewWindow* );
153   void                        onViewAboutToShow();
154
155 signals :
156   void                        SignalDeactivateActiveDialog();
157   void                        SignalCloseAllDialogs();
158   void                        SignalDefaultStepValueChanged( double newVal );
159
160 protected:
161   virtual LightApp_Selection* createSelection() const;
162
163 private:
164   GEOMGUI*                    getLibrary( const QString& libraryName );
165   void                        createGeomAction( const int id, const QString& po_id,
166                                                 const QString& icon_id = QString(""),
167                                                 const int key = 0, const bool toggle = false,
168                                                 const QString& shortcutAction = QString() );
169   void                        createPopupItem( const int, const QString& clients, const QString& types,
170                                                const bool isSingle = false, const int isVisible = -1,
171                                                const bool isExpandAll = false, const bool isOCC = false,
172                                                const int parentId = -1 );
173
174   void                        createOriginAndBaseVectors();
175
176 public:
177   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
178
179 private:  
180
181   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
182   typedef QMap<long, TextureMap> StudyTextureMap;
183   typedef QMap<QString, GEOMGUI*> GUIMap;
184
185   GUIMap                      myGUIMap;          // GUI libraries map
186   QDialog*                    myActiveDialogBox; // active dialog box
187   gp_Ax3                      myWorkingPlane;
188   QMap<int,QString>           myRules;           // popup rules
189   static StudyTextureMap      myTextureMap;      // texture map
190
191   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
192   QList<LightApp_VTKSelector*> myVTKSelectors;
193
194   LightApp_Displayer*         myDisplayer;
195   int                         myLocalSelectionMode; //Select Only
196
197   friend class DisplayGUI;
198 };
199
200 #endif