Salome HOME
Remove obsolete OCC_VERSION_LARGE defines.
[modules/geom.git] / src / GEOMGUI / GeometryGUI.h
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 #include <TColStd_HArray1OfByte.hxx>
51
52 // IDL headers
53 #include "SALOMEconfig.h"
54 #include CORBA_CLIENT_HEADER(SALOMEDS)
55
56 #include <SALOME_ListIO.hxx>
57
58 class QDialog;
59 class QMenu;
60 class QAction;
61 class GEOMGUI_OCCSelector;
62 class LightApp_VTKSelector;
63 class LightApp_Selection;
64 class SUIT_ViewManager;
65 class SalomeApp_Study;
66 class GEOMGUI_CreationInfoWdg;
67
68 //=================================================================================
69 // class    : GeometryGUI
70 // purpose  :
71 //=================================================================================
72 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
73 {
74   Q_OBJECT;
75
76 public:
77   // Constructor
78   GeometryGUI();
79
80   // Destructor
81   ~GeometryGUI();
82
83   virtual LightApp_Displayer* displayer();
84   virtual void                initialize( CAM_Application* );
85   virtual QString             engineIOR() const;
86
87   static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
88
89   static bool                 InitGeomGen();
90
91   static  GEOM::GEOM_Gen_var  GetGeomGen();
92
93   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
94   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
95
96   static void                 Modified( bool = true );
97
98   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
99
100   // Get active dialog box
101   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
102   // Set active dialog box
103   void                        SetActiveDialogBox( QDialog* aDlg );
104
105   // Non modal dialog boxes management
106   void                        EmitSignalDeactivateDialog();
107   void                        EmitSignalCloseAllDialogs();
108   void                        EmitSignalDefaultStepValueChanged( double newVal );
109
110   // Process action
111   void                        OnGUIEvent( int id, const QVariant& theParam =  QVariant( QVariant::Invalid ) );
112   virtual bool                activateOperation( int actionId );
113   virtual bool                activateOperation( const QString& actionId );
114   virtual bool                activateOperation( const QString& actionId, const QString& plugin );
115
116   // The Working Plane management
117   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
118   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
119   void                        ActiveWorkingPlane();
120
121   virtual bool                renameObject( const QString&, const QString& );
122   virtual bool                renameAllowed( const QString& ) const;
123
124   virtual void                windows( QMap<int, int>& ) const;
125   virtual void                viewManagers( QStringList& ) const;
126
127   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
128   virtual void                createPreferences();
129   virtual void                preferencesChanged( const QString&, const QString& );
130   int                         getLocalSelectionMode() const;
131   void                        setLocalSelectionMode(const int mode);
132
133   virtual void storeVisualParameters  (int savePoint);
134   virtual void restoreVisualParameters(int savePoint);
135
136   QAction*                    getAction(const int id);
137
138   virtual void                message( const QString& msg);
139   static void                 ClearShapeBuffer( GEOM::GEOM_Object_ptr );
140   static GEOM::GEOM_Object_ptr
141                               GetObjectFromIOR( const QString& IOR );
142
143   static QString              GetIORFromObject( GEOM::GEOM_Object_ptr object );
144
145   virtual bool                isDraggable( const SUIT_DataObject* what ) const;
146   virtual bool                isDropAccepted( const SUIT_DataObject* where ) const;
147   virtual void                dropObjects( const DataObjectList& what, 
148                                            SUIT_DataObject* where,
149                                            const int row, Qt::DropAction action );
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   void                        OnSetMaterial( const QString& );
168   void                        updateMaterials();
169   void                        updateCreationInfo();
170   void                        onAutoBringToFront();
171   void                        updateFieldColorScale();
172
173 signals :
174   void                        SignalDeactivateActiveDialog();
175   void                        SignalCloseAllDialogs();
176   void                        SignalDefaultStepValueChanged( double newVal );
177   void                        SignalDependencyTreeParamChanged( const QString&, const QString& );
178   void                        SignalDependencyTreeRenameObject( const QString& );
179
180 protected:
181   virtual LightApp_Selection* createSelection() const;
182
183 private:
184   GEOMGUI*                    getLibrary( const QString& libraryName );
185   GEOMPluginGUI*              getPluginLibrary( const QString& libraryName );
186   void                        createGeomAction( const int id, const QString& po_id,
187                                                 const QString& icon_id = QString(""),
188                                                 const int key = 0, const bool toggle = false,
189                                                 const QString& shortcutAction = QString() );
190   void                        createPopupItem( const int, const QString& clients, const QString& types,
191                                                const bool isSingle = false, const int isVisible = -1,
192                                                const bool isExpandAll = false, const bool isOCC = false,
193                                                const int parentId = -1 );
194   void                        addPluginActions();
195
196   void                        createOriginAndBaseVectors();
197
198 public:
199   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
200
201 private:  
202
203   typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
204
205   typedef QMap<long, TextureMap> StudyTextureMap;
206   typedef QMap<QString, GEOMGUI*> GUIMap;
207
208   typedef QPair<QString, QString> PluginAction;
209
210   GUIMap                      myGUIMap;          // GUI libraries map
211   QDialog*                    myActiveDialogBox; // active dialog box
212   gp_Ax3                      myWorkingPlane;
213   //QMap<int,QString>           myRules;           // popup rules
214   static StudyTextureMap      myTextureMap;      // texture map
215
216   QMap<int, PluginAction>      myPluginActions; // plugin actions
217   QMap<QString, QString>       myPluginLibs;    // plugin name to plugin client library
218
219   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
220   QList<LightApp_VTKSelector*> myVTKSelectors;
221
222   LightApp_Displayer*         myDisplayer;
223   int                         myLocalSelectionMode; //Select Only
224
225   GEOMGUI_CreationInfoWdg*    myCreationInfoWdg;
226   
227   SALOME_ListIO               myTopLevelIOList;               
228
229   friend class DisplayGUI;
230 };
231
232 #endif