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