Salome HOME
f92d92ab7b03b375beacf2adfafad914027a3706
[modules/geom.git] / src / GEOMGUI / GeometryGUI.h
1 // Copyright (C) 2007-2016  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 class GEOMGUI_TextTreeWdg;
68
69 //=================================================================================
70 // class    : GeometryGUI
71 // purpose  :
72 //=================================================================================
73 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
74 {
75   Q_OBJECT;
76
77 public:
78   // Constructor
79   GeometryGUI();
80
81   // Destructor
82   ~GeometryGUI();
83
84   virtual LightApp_Displayer* displayer();
85   virtual void                initialize( CAM_Application* );
86   virtual QString             engineIOR() const;
87
88   static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
89
90   static bool                 InitGeomGen();
91
92   static  GEOM::GEOM_Gen_var  GetGeomGen();
93
94   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
95   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
96
97   static void                 Modified( bool = true );
98
99   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
100
101   // Get active dialog box
102   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
103   // Set active dialog box
104   void                        SetActiveDialogBox( QDialog* aDlg );
105
106   // Non modal dialog boxes management
107   void                        EmitSignalDeactivateDialog();
108   void                        EmitSignalCloseAllDialogs();
109   void                        EmitSignalDefaultStepValueChanged( double newVal );
110
111   // Process action
112   void                        OnGUIEvent( int id, const QVariant& theParam =  QVariant( QVariant::Invalid ) );
113   virtual bool                activateOperation( int actionId );
114   virtual bool                activateOperation( const QString& actionId );
115   virtual bool                activateOperation( const QString& actionId, const QString& plugin );
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   void                        emitDimensionsUpdated( QString entry );
153
154 public slots:
155   virtual bool                deactivateModule( SUIT_Study* );
156   virtual bool                activateModule( SUIT_Study* );
157   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
158   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
159   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
160   virtual void                OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
161
162 protected slots:
163   virtual void                onViewManagerAdded( SUIT_ViewManager* );
164   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
165
166 private slots:
167   void                        OnGUIEvent();
168   void                        onWindowActivated( SUIT_ViewWindow* );
169   void                        onViewAboutToShow();
170   void                        OnSetMaterial( const QString& );
171   void                        updateMaterials();
172   void                        updateCreationInfo();
173   void                        onAutoBringToFront();
174   void                        updateFieldColorScale();
175
176 signals :
177   void                        SignalDeactivateActiveDialog();
178   void                        SignalCloseAllDialogs();
179   void                        SignalDefaultStepValueChanged( double newVal );
180   void                        SignalDependencyTreeParamChanged( const QString&, const QString& );
181   void                        SignalDependencyTreeRenameObject( const QString& );
182   void                        DimensionsUpdated( const QString& );
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   typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
208
209   typedef QMap<long, TextureMap> StudyTextureMap;
210   typedef QMap<QString, GEOMGUI*> GUIMap;
211
212   typedef QPair<QString, QString> PluginAction;
213
214   GUIMap                      myGUIMap;          // GUI libraries map
215   QDialog*                    myActiveDialogBox; // active dialog box
216   gp_Ax3                      myWorkingPlane;
217   //QMap<int,QString>           myRules;           // popup rules
218   static StudyTextureMap      myTextureMap;      // texture map
219
220   QMap<int, PluginAction>      myPluginActions; // plugin actions
221   QMap<QString, QString>       myPluginLibs;    // plugin name to plugin client library
222
223   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
224   QList<LightApp_VTKSelector*> myVTKSelectors;
225
226   LightApp_Displayer*         myDisplayer;
227   int                         myLocalSelectionMode; //Select Only
228
229   GEOMGUI_CreationInfoWdg*    myCreationInfoWdg;
230   
231   GEOMGUI_TextTreeWdg*       myTextTreeWdg;
232   
233   SALOME_ListIO               myTopLevelIOList;               
234
235   friend class DisplayGUI;
236 };
237
238 #endif