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