Salome HOME
3d4af608b70425bf0e4d7464939e6f41cb2794d8
[modules/geom.git] / src / GEOMGUI / GeometryGUI.h
1 // Copyright (C) 2007-2013  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 <Basics_OCCTVersion.hxx>
33
34 #include <SalomeApp_Module.h>
35
36 #include <GEOM_Client.hxx>
37 #include <SALOME_InteractiveObject.hxx>
38 #include <SALOMEDSClient.hxx>
39
40 #include "GEOMGUI.h"
41 #include "GEOMPluginGUI.h"
42
43 // QT Includes
44 #include <QMap>
45 #include <QPair>
46
47 // OCCT Includes
48 #include <gp_Ax3.hxx>
49
50 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
51 #include <TColStd_HArray1OfByte.hxx>
52 #else
53 #include <Graphic3d_HArray1OfBytes.hxx>
54 #endif
55
56 // IDL headers
57 #include "SALOMEconfig.h"
58 #include CORBA_CLIENT_HEADER(SALOMEDS)
59
60 class QDialog;
61 class QMenu;
62 class QAction;
63 class GEOMGUI_OCCSelector;
64 class LightApp_VTKSelector;
65 class LightApp_Selection;
66 class SUIT_ViewManager;
67 class SalomeApp_Study;
68 class GEOMGUI_CreationInfoWdg;
69
70 //=================================================================================
71 // class    : GeometryGUI
72 // purpose  :
73 //=================================================================================
74 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
75 {
76   Q_OBJECT;
77
78 public:
79   // Constructor
80   GeometryGUI();
81
82   // Destructor
83   ~GeometryGUI();
84
85   virtual LightApp_Displayer* displayer();
86   virtual void                initialize( CAM_Application* );
87   virtual QString             engineIOR() const;
88
89 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
90   static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
91 #else
92   static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
93 #endif
94
95   static bool                 InitGeomGen();
96
97   static  GEOM::GEOM_Gen_var  GetGeomGen();
98
99   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
100   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
101
102   static void                 Modified( bool = true );
103
104   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
105
106   // Get active dialog box
107   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
108   // Set active dialog box
109   void                        SetActiveDialogBox( QDialog* aDlg );
110
111   // Non modal dialog boxes management
112   void                        EmitSignalDeactivateDialog();
113   void                        EmitSignalCloseAllDialogs();
114   void                        EmitSignalDefaultStepValueChanged( double newVal );
115
116   // Process action
117   void                        OnGUIEvent( int id, const QVariant& theParam =  QVariant( QVariant::Invalid ) );
118   virtual bool                activateOperation( int actionId );
119   virtual bool                activateOperation( const QString& actionId );
120   virtual bool                activateOperation( const QString& actionId, const QString& plugin );
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   virtual bool                renameAllowed( const QString& ) const;
129
130   virtual void                windows( QMap<int, int>& ) const;
131   virtual void                viewManagers( QStringList& ) const;
132
133   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
134   virtual void                createPreferences();
135   virtual void                preferencesChanged( const QString&, const QString& );
136   int                         getLocalSelectionMode() const;
137   void                        setLocalSelectionMode(const int mode);
138
139   virtual void storeVisualParameters  (int savePoint);
140   virtual void restoreVisualParameters(int savePoint);
141
142   QAction*                    getAction(const int id);
143
144   virtual void                message( const QString& msg);
145   static void                 ClearShapeBuffer( GEOM::GEOM_Object_ptr );
146   static GEOM::GEOM_Object_ptr
147                               GetObjectFromIOR( const QString& IOR );
148
149   static QString              GetIORFromObject( GEOM::GEOM_Object_ptr object );
150
151   virtual bool                isDraggable( const SUIT_DataObject* what ) const;
152   virtual bool                isDropAccepted( const SUIT_DataObject* where ) const;
153   virtual void                dropObjects( const DataObjectList& what, 
154                                            SUIT_DataObject* where,
155                                            const int row, Qt::DropAction action );
156
157 public slots:
158   virtual bool                deactivateModule( SUIT_Study* );
159   virtual bool                activateModule( SUIT_Study* );
160   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
161   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
162   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
163   virtual void                OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
164
165 protected slots:
166   virtual void                onViewManagerAdded( SUIT_ViewManager* );
167   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
168
169 private slots:
170   void                        OnGUIEvent();
171   void                        onWindowActivated( SUIT_ViewWindow* );
172   void                        onViewAboutToShow();
173   void                        OnSetMaterial( const QString& );
174   void                        updateMaterials();
175   void                        updateCreationInfo();
176   void                        onAutoBringToFront();
177   void                        updateFieldColorScale();
178
179 signals :
180   void                        SignalDeactivateActiveDialog();
181   void                        SignalCloseAllDialogs();
182   void                        SignalDefaultStepValueChanged( double newVal );
183
184 protected:
185   virtual LightApp_Selection* createSelection() const;
186
187 private:
188   GEOMGUI*                    getLibrary( const QString& libraryName );
189   GEOMPluginGUI*              getPluginLibrary( const QString& libraryName );
190   void                        createGeomAction( const int id, const QString& po_id,
191                                                 const QString& icon_id = QString(""),
192                                                 const int key = 0, const bool toggle = false,
193                                                 const QString& shortcutAction = QString() );
194   void                        createPopupItem( const int, const QString& clients, const QString& types,
195                                                const bool isSingle = false, const int isVisible = -1,
196                                                const bool isExpandAll = false, const bool isOCC = false,
197                                                const int parentId = -1 );
198   void                        addPluginActions();
199
200   void                        createOriginAndBaseVectors();
201
202 public:
203   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
204
205 private:  
206
207 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
208   typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
209 #else
210   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
211 #endif
212
213   typedef QMap<long, TextureMap> StudyTextureMap;
214   typedef QMap<QString, GEOMGUI*> GUIMap;
215
216   typedef QPair<QString, QString> PluginAction;
217
218   GUIMap                      myGUIMap;          // GUI libraries map
219   QDialog*                    myActiveDialogBox; // active dialog box
220   gp_Ax3                      myWorkingPlane;
221   //QMap<int,QString>           myRules;           // popup rules
222   static StudyTextureMap      myTextureMap;      // texture map
223
224   QMap<int, PluginAction>      myPluginActions; // plugin actions
225   QMap<QString, QString>       myPluginLibs;    // plugin name to plugin client library
226
227   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
228   QList<LightApp_VTKSelector*> myVTKSelectors;
229
230   LightApp_Displayer*         myDisplayer;
231   int                         myLocalSelectionMode; //Select Only
232
233   GEOMGUI_CreationInfoWdg*    myCreationInfoWdg;
234
235   friend class DisplayGUI;
236 };
237
238 #endif