Salome HOME
IPAL54434: TC9.2.0: GEOM: Textured point marker is not set
[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 <SalomeApp_Module.h>
33
34 #include <GEOM_Client.hxx>
35 #include <SALOME_InteractiveObject.hxx>
36 #include <SALOMEDSClient.hxx>
37 #include <Qtx.h>
38
39 #include "GEOMGUI.h"
40 #include "GEOMPluginGUI.h"
41
42 // QT Includes
43 #include <QMap>
44 #include <QPair>
45
46 // OCCT Includes
47 #include <gp_Ax3.hxx>
48
49 #include <TColStd_HArray1OfByte.hxx>
50
51 // IDL headers
52 #include "SALOMEconfig.h"
53 #include CORBA_CLIENT_HEADER(SALOMEDS)
54
55 #include <SALOME_ListIO.hxx>
56
57 class QDialog;
58 class QMenu;
59 class QAction;
60 class GEOMGUI_OCCSelector;
61 class LightApp_VTKSelector;
62 class LightApp_Selection;
63 class SUIT_ViewManager;
64 class SalomeApp_Study;
65 class GEOMGUI_CreationInfoWdg;
66 class GEOMGUI_TextTreeWdg;
67 class GEOMGUI_AnnotationMgr;
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 (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  getStudyServant();
96
97   static void                 Modified( bool = true );
98
99   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
100
101   GEOMGUI_AnnotationMgr*      GetAnnotationMgr();
102
103   GEOMGUI_TextTreeWdg*        GetTextTreeWdg() const;
104
105   // Get active dialog box
106   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
107   // Set active dialog box
108   void                        SetActiveDialogBox( QDialog* aDlg );
109
110   // Non modal dialog boxes management
111   void                        EmitSignalDeactivateDialog();
112   void                        EmitSignalCloseAllDialogs();
113   void                        EmitSignalDefaultStepValueChanged( double newVal );
114
115   // Process action
116   void                        OnGUIEvent( int id, const QVariant& theParam =  QVariant( QVariant::Invalid ) );
117   virtual bool                activateOperation( int actionId );
118   virtual bool                activateOperation( const QString& actionId );
119   virtual bool                activateOperation( const QString& actionId, const QString& plugin );
120
121   // The Working Plane management
122   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
123   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
124   void                        ActiveWorkingPlane();
125
126   virtual bool                renameObject( const QString&, const QString& );
127   virtual bool                renameAllowed( const QString& ) const;
128
129   virtual void                windows( QMap<int, int>& ) const;
130   virtual void                viewManagers( QStringList& ) const;
131
132   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
133   virtual void                createPreferences();
134   virtual void                preferencesChanged( const QString&, const QString& );
135   int                         getLocalSelectionMode() const;
136   void                        setLocalSelectionMode(const int mode);
137
138   virtual void storeVisualParameters  (int savePoint);
139   virtual void restoreVisualParameters(int savePoint);
140
141   QAction*                    getAction(const int id);
142
143   virtual void                message( const QString& msg);
144   static void                 ClearShapeBuffer( GEOM::GEOM_Object_ptr );
145   static GEOM::GEOM_Object_ptr
146                               GetObjectFromIOR( const QString& IOR );
147
148   static QString              GetIORFromObject( GEOM::GEOM_Object_ptr object );
149
150   virtual bool                isDraggable( const SUIT_DataObject* what ) const;
151   virtual bool                isDropAccepted( const SUIT_DataObject* where ) const;
152   virtual void                dropObjects( const DataObjectList& what, 
153                                            SUIT_DataObject* where,
154                                            const int row, Qt::DropAction action );
155
156   void                        emitDimensionsUpdated( QString entry );
157   void                        emitAnnotationsUpdated( QString entry );
158
159 public slots:
160   virtual bool                deactivateModule( SUIT_Study* );
161   virtual bool                activateModule( SUIT_Study* );
162   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
163   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
164   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
165   virtual void                OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
166
167 protected slots:
168   virtual void                onViewManagerAdded( SUIT_ViewManager* );
169   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
170
171 private slots:
172   void                        OnGUIEvent();
173   void                        onWindowActivated( SUIT_ViewWindow* );
174   void                        onViewAboutToShow();
175   void                        OnSetMaterial( const QString& );
176   void                        updateMaterials();
177   void                        updateCreationInfo();
178   void                        onAutoBringToFront();
179   void                        updateFieldColorScale();
180
181 signals :
182   void                        SignalDeactivateActiveDialog();
183   void                        SignalCloseAllDialogs();
184   void                        SignalDefaultStepValueChanged( double newVal );
185   void                        SignalDependencyTreeParamChanged( const QString&, const QString& );
186   void                        SignalDependencyTreeRenameObject( const QString& );
187   void                        SignalTextTreeRenameObject( const QString& );
188   void                        SignalAnnotationsUpdated( const QString& );
189   void                        DimensionsUpdated( const QString& );
190
191 protected:
192   virtual LightApp_Selection* createSelection() const;
193
194 private:
195   GEOMGUI*                    getLibrary( const QString& libraryName );
196   GEOMPluginGUI*              getPluginLibrary( const QString& libraryName );
197   void                        createGeomAction( const int id, const QString& po_id,
198                                                 const QString& icon_id = QString(""),
199                                                 const int key = 0, const bool toggle = false,
200                                                 const QString& shortcutAction = QString() );
201   void                        createPopupItem( const int, const QString& clients, const QString& types,
202                                                const bool isSingle = false, const int isVisible = -1,
203                                                const bool isExpandAll = false, const bool isOCC = false,
204                                                const int parentId = -1 );
205   void                        addPluginActions();
206
207   void                        createOriginAndBaseVectors();
208
209 public:
210   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
211
212 private:  
213
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
223   QMap<int, PluginAction>      myPluginActions;   // plugin actions
224   QMap<QString, QString>       myPluginLibs;      // plugin name to plugin client library
225
226   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
227   QList<LightApp_VTKSelector*> myVTKSelectors;
228
229   LightApp_Displayer*          myDisplayer;
230   int                          myLocalSelectionMode; //Select Only
231
232   GEOMGUI_CreationInfoWdg*     myCreationInfoWdg;
233   
234   GEOMGUI_TextTreeWdg*        myTextTreeWdg;
235   GEOMGUI_AnnotationMgr*      myAnnotationMgr;
236   
237   SALOME_ListIO                myTopLevelIOList;
238
239   friend class DisplayGUI;
240 };
241
242 #endif