Salome HOME
Fix for the bug "IPAL22425 TC6.3.0: Wrong Dump of Study".
[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 bool                renameObject( const QString&, const QString& );
128
129   virtual void                windows( QMap<int, int>& ) const;
130   virtual void                viewManagers( QStringList& ) const;
131
132   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
133   virtual void                createPreferences();
134   virtual void                preferencesChanged( const QString&, const QString& );
135   int                         getLocalSelectionMode() const;
136   void                        setLocalSelectionMode(const int mode);
137
138   virtual void storeVisualParameters  (int savePoint);
139   virtual void restoreVisualParameters(int savePoint);
140
141 public slots:
142   virtual bool                deactivateModule( SUIT_Study* );
143   virtual bool                activateModule( SUIT_Study* );
144   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
145   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
146   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
147
148 protected slots:
149   virtual void                onViewManagerAdded( SUIT_ViewManager* );
150   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
151
152 private slots:
153   void                        OnGUIEvent();
154   void                        onWindowActivated( SUIT_ViewWindow* );
155   void                        onViewAboutToShow();
156
157 signals :
158   void                        SignalDeactivateActiveDialog();
159   void                        SignalCloseAllDialogs();
160   void                        SignalDefaultStepValueChanged( double newVal );
161
162 protected:
163   virtual LightApp_Selection* createSelection() const;
164
165 private:
166   GEOMGUI*                    getLibrary( const QString& libraryName );
167   void                        createGeomAction( const int id, const QString& po_id,
168                                                 const QString& icon_id = QString(""),
169                                                 const int key = 0, const bool toggle = false,
170                                                 const QString& shortcutAction = QString() );
171   void                        createPopupItem( const int, const QString& clients, const QString& types,
172                                                const bool isSingle = false, const int isVisible = -1,
173                                                const bool isExpandAll = false, const bool isOCC = false,
174                                                const int parentId = -1 );
175
176   void                        createOriginAndBaseVectors();
177
178 public:
179   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
180
181 private:  
182
183   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
184   typedef QMap<long, TextureMap> StudyTextureMap;
185   typedef QMap<QString, GEOMGUI*> GUIMap;
186
187   GUIMap                      myGUIMap;          // GUI libraries map
188   QDialog*                    myActiveDialogBox; // active dialog box
189   gp_Ax3                      myWorkingPlane;
190   QMap<int,QString>           myRules;           // popup rules
191   static StudyTextureMap      myTextureMap;      // texture map
192
193   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
194   QList<LightApp_VTKSelector*> myVTKSelectors;
195
196   LightApp_Displayer*         myDisplayer;
197   int                         myLocalSelectionMode; //Select Only
198
199   friend class DisplayGUI;
200 };
201
202 #endif