Salome HOME
Implementation of 0021855: EDF 2321 GEOM : Add folders to group objects in the object...
[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
42 // QT Includes
43 #include <QMap>
44
45 // OCCT Includes
46 #include <gp_Ax3.hxx>
47
48 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
49 #include <TColStd_HArray1OfByte.hxx>
50 #else
51 #include <Graphic3d_HArray1OfBytes.hxx>
52 #endif
53
54 // IDL headers
55 #include "SALOMEconfig.h"
56 #include CORBA_CLIENT_HEADER(SALOMEDS)
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 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
88   static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
89 #else
90   static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
91 #endif
92
93   static bool                 InitGeomGen();
94
95   static  GEOM::GEOM_Gen_var  GetGeomGen();
96
97   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
98   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
99
100   static void                 Modified( bool = true );
101
102   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
103
104   // Get active dialog box
105   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
106   // Set active dialog box
107   void                        SetActiveDialogBox( QDialog* aDlg );
108
109   // Non modal dialog boxes management
110   void                        EmitSignalDeactivateDialog();
111   void                        EmitSignalCloseAllDialogs();
112   void                        EmitSignalDefaultStepValueChanged( double newVal );
113
114   // Process action
115   void                        OnGUIEvent( int id, const QVariant& theParam =  QVariant( QVariant::Invalid ) );
116
117   // The Working Plane management
118   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
119   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
120   void                        ActiveWorkingPlane();
121
122   virtual bool                renameObject( const QString&, const QString& );
123   virtual bool                renameAllowed( const QString& ) const;
124
125   virtual void                windows( QMap<int, int>& ) const;
126   virtual void                viewManagers( QStringList& ) const;
127
128   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
129   virtual void                createPreferences();
130   virtual void                preferencesChanged( const QString&, const QString& );
131   int                         getLocalSelectionMode() const;
132   void                        setLocalSelectionMode(const int mode);
133
134   virtual void storeVisualParameters  (int savePoint);
135   virtual void restoreVisualParameters(int savePoint);
136
137   QAction*                    getAction(const int id);
138
139   virtual void                message( const QString& msg);
140   static void                 ClearShapeBuffer( GEOM::GEOM_Object_ptr );
141   static GEOM::GEOM_Object_ptr
142                               GetObjectFromIOR( const QString& IOR );
143
144   static QString              GetIORFromObject( GEOM::GEOM_Object_ptr object );
145
146   virtual bool                isDraggable( const SUIT_DataObject* what ) const;
147   virtual bool                isDropAccepted( const SUIT_DataObject* where ) const;
148   virtual void                dropObjects( const DataObjectList& what, 
149                                            SUIT_DataObject* where,
150                                            const int row, Qt::DropAction action );
151
152 public slots:
153   virtual bool                deactivateModule( SUIT_Study* );
154   virtual bool                activateModule( SUIT_Study* );
155   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
156   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
157   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
158   virtual void                OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
159
160 protected slots:
161   virtual void                onViewManagerAdded( SUIT_ViewManager* );
162   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
163
164 private slots:
165   void                        OnGUIEvent();
166   void                        onWindowActivated( SUIT_ViewWindow* );
167   void                        onViewAboutToShow();
168   void                        OnSetMaterial( const QString& );
169   void                        updateMaterials();
170   void                        updateCreationInfo();
171
172 signals :
173   void                        SignalDeactivateActiveDialog();
174   void                        SignalCloseAllDialogs();
175   void                        SignalDefaultStepValueChanged( double newVal );
176
177 protected:
178   virtual LightApp_Selection* createSelection() const;
179
180 private:
181   GEOMGUI*                    getLibrary( const QString& libraryName );
182   void                        createGeomAction( const int id, const QString& po_id,
183                                                 const QString& icon_id = QString(""),
184                                                 const int key = 0, const bool toggle = false,
185                                                 const QString& shortcutAction = QString() );
186   void                        createPopupItem( const int, const QString& clients, const QString& types,
187                                                const bool isSingle = false, const int isVisible = -1,
188                                                const bool isExpandAll = false, const bool isOCC = false,
189                                                const int parentId = -1 );
190
191   void                        createOriginAndBaseVectors();
192
193 public:
194   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
195
196 private:  
197
198 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
199   typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
200 #else
201   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
202 #endif
203
204   typedef QMap<long, TextureMap> StudyTextureMap;
205   typedef QMap<QString, GEOMGUI*> GUIMap;
206
207   GUIMap                      myGUIMap;          // GUI libraries map
208   QDialog*                    myActiveDialogBox; // active dialog box
209   gp_Ax3                      myWorkingPlane;
210   QMap<int,QString>           myRules;           // popup rules
211   static StudyTextureMap      myTextureMap;      // texture map
212
213   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
214   QList<LightApp_VTKSelector*> myVTKSelectors;
215
216   LightApp_Displayer*         myDisplayer;
217   int                         myLocalSelectionMode; //Select Only
218
219   GEOMGUI_CreationInfoWdg*    myCreationInfoWdg;
220
221   friend class DisplayGUI;
222 };
223
224 #endif