Salome HOME
Typo-fix by Kunda
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.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   : GEOM_Displayer.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 //
27 #ifndef GEOM_DISPLAYER_H
28 #define GEOM_DISPLAYER_H
29
30 #include "GEOM_GEOMGUI.hxx"
31 #include <GEOM_AISShape.hxx>
32
33 #include <SALOME_InteractiveObject.hxx>
34
35 class GEOM_Actor;
36 class SALOME_ListIO;
37 class SALOME_View;
38 class SALOME_Prs;
39 class SALOME_OCCPrs;
40 class SALOME_VTKPrs;
41 class SALOME_OCCViewType;
42
43 #include <TopoDS_Shape.hxx>
44 #include <Quantity_Color.hxx>
45 #include <LightApp_Displayer.h>
46 #include <LightApp_Study.h>
47 #include <Aspect_TypeOfMarker.hxx>
48 #include <TCollection_AsciiString.hxx>
49 #include <TColStd_MapOfInteger.hxx>
50 #include <QList>
51
52 #include <list>
53
54 #include <SALOMEconfig.h>
55 #include CORBA_CLIENT_HEADER(GEOM_Gen)
56
57 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
58 #define GEOM_PREVIEW    -2 // Definition for preview selection
59 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
60 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
61
62 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
63
64 class LightApp_SelectionMgr;
65 class SalomeApp_Study;
66 class SalomeApp_Application;
67 class SUIT_SelectionFilter;
68 class gp_Ax3;
69
70 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
71 {
72
73 public:
74   /* Constructor */
75   GEOM_Displayer( SalomeApp_Study* app );
76   /* Destructor */
77   virtual ~GEOM_Displayer();
78
79   virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
80
81   /* Display/Erase object methods */
82   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
83                             const bool updateViewer = true,
84                             SALOME_View* theViewFrame = 0 );
85
86   // This overloaded Display() method can be useful for operations
87   // not using dialog boxes.
88   void          Display   ( GEOM::GEOM_BaseObject_ptr theObj,
89                             const bool updateViewer = true );
90
91   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
92                             const bool updateViewer = true,
93                             const bool checkActiveViewer = true );
94
95   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
96                             const bool theUpdateViewer,
97                             SALOME_View* theViewFrame );
98
99   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
100                             const bool forced = false,
101                             const bool updateViewer = true,
102                             SALOME_View* theViewFrame = 0 );
103
104   void          Erase     ( GEOM::GEOM_BaseObject_ptr theObj,
105                             const bool forced = false,
106                             const bool updateViewer = true,
107                             SALOME_View* theViewFrame = 0);
108
109   void          EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
110                                   const bool eraseOnlyChildren = false);
111
112   /* Display/Erase list of objects methods */
113
114   void          Display   ( const SALOME_ListIO& theIOList,
115                             const bool updateViewer = true );
116
117   void          Erase     ( const SALOME_ListIO& theIOList,
118                             const bool forced = false,
119                             const bool updateViewer = true );
120
121   void          Redisplay ( const SALOME_ListIO& theIOList,
122                             const bool updateViewer = true,
123                             const bool checkActiveViewer = true );
124
125   void          Redisplay ( const SALOME_ListIO& theIOList,
126                             const bool theUpdateViewer,
127                             SALOME_View* theViewFrame );
128
129   /* Update visibility state */
130   void          UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool );
131
132   /* build presentation according to the current viewer type*/
133   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
134   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
135
136   /* Set color for shape displaying. If it is equal -1 then default color is used.
137      Available values are from Quantity_NameOfColor enumeration */
138   void          SetColor  ( const int );
139   void          UnsetColor();
140   int           GetColor  () const;
141   bool          HasColor  () const;
142
143   double        SetTransparency  ( const double );
144   double        UnsetTransparency();
145   double        GetTransparency  () const;
146   bool          HasTransparency  () const;
147   
148   /* Set texture for shape displaying. */
149   void          SetTexture  ( const std::string& );
150   bool          HasTexture  () const;
151   std::string   GetTexture  () const;
152
153   /* Set width for shape displaying. If it is equal -1 then default width is used. */
154   void          SetWidth  ( const double );
155   void          UnsetWidth();
156   double        GetWidth  () const;
157   bool          HasWidth  () const;
158
159   /* Set width for iso-lines displaying. If it is equal -1 then default width is used. */
160   void          SetIsosWidth  ( const int );
161   int           GetIsosWidth  () const;
162   bool          HasIsosWidth  () const;
163  
164   /* Set nb iso-libes for displaying. Use -1 to set default values. */
165   int           SetNbIsos( const int );
166   int           UnsetNbIsos();
167   int           GetNbIsos() const;
168   bool          HasNbIsos() const;
169   
170   /* Set color for iso-lines displaying. If it is equal -1 then default color is used.
171      Available values are from Quantity_NameOfColor enumeration */
172   int           SetIsosColor  ( const int );
173   int           UnsetIsosColor();
174   int           GetIsosColor  () const;
175   bool          HasIsosColor  () const;
176  
177   /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
178   int           SetDisplayMode( const int );
179   int           GetDisplayMode() const;
180   int           UnsetDisplayMode();
181   bool          HasDisplayMode() const;
182
183   /* Sets name - for temporary objects only */
184   void          SetName( const char* theName );
185   void          UnsetName();
186
187   /* Reimplemented from SALOME_Displayer */
188   virtual void  Update( SALOME_OCCPrs* );
189   virtual void  Update( SALOME_VTKPrs* );
190   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
191   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
192   virtual void  BeforeErase  ( SALOME_View*, const SALOME_OCCPrs* );
193   virtual void  AfterErase   ( SALOME_View*, const SALOME_OCCPrs* );
194
195   /* This methods is used for activisation/deactivisation of objects to be displayed*/
196   void          SetToActivate( const bool );
197   bool          ToActivate() const;
198
199   /* Activate/Deactivate selection*/
200   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const std::list<int> );
201   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
202   void         LocalSelection( const SALOME_ListIO& theIOList, const std::list<int> );
203   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
204   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
205   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
206
207   SalomeApp_Study* getStudy() const;
208
209   static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
210   static SALOMEDS::Color getPredefinedUniqueColor();
211
212   /*Get color of the geom object*/
213   static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
214
215   /* Get minimum or maximum enclosed shape type */
216   static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
217
218   /* Check if the object is a vertex or a compound of vertices */
219   static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
220
221
222   /* Builds presentation of not published object */
223   virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
224                                                 const QString&,
225                                                 SALOME_View* = 0);
226
227   /* Update visibility and parameters of the currently selected field step's color scale */
228   void UpdateColorScale();
229   bool SetUpdateColorScale(bool);
230
231 protected:
232   /* internal methods */
233   /* Builds presentation according to the current viewer type */
234   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
235
236   /* Sets interactive object */
237   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
238
239   /* Sets shape */
240   void        setShape( const TopoDS_Shape& theShape );
241
242   /* Sets field step information */
243   void        setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
244                                 const int theFieldDimension,
245                                 const QList<QVariant>& theFieldStepData,
246                                 const TCollection_AsciiString& theFieldStepName,
247                                 const double theFieldStepRangeMin,
248                                 const double theFieldStepRangeMax );
249
250   /* Resets internal data */
251   void        internalReset();
252
253   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
254
255   SUIT_SelectionFilter* getFilter( const int theMode );
256   SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
257
258   Quantity_Color qColorFromResources( const QString&, const QColor& );
259   QColor         colorFromResources( const QString&, const QColor& );
260   void           updateShapeProperties( const Handle(GEOM_AISShape)&, bool );
261   void           updateActorProperties( GEOM_Actor*, bool );
262   void           updateDimensions( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
263   void           updateShapeAnnotations( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
264
265   PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 );
266   PropMap getDefaultPropertyMap();
267
268   /* Methods for reading the field step information */
269   void            readFieldStepInfo( GEOM::GEOM_FieldStep_var theGeomFieldStep );
270   QList<QVariant> groupFieldData( const QList<QVariant>& theFieldStepData,
271                                   const int theFieldNbComponents,
272                                   const bool theIsString,
273                                   double& theFieldStepRangeMin,
274                                   double& theFieldStepRangeMax );
275
276 protected:
277   Handle(SALOME_InteractiveObject) myIO;
278   TopoDS_Shape                     myShape;
279   GEOM::field_data_type            myFieldDataType;
280   int                              myFieldDimension;
281   QList<QVariant>                  myFieldStepData;
282   TCollection_AsciiString          myFieldStepName;
283   double                           myFieldStepRangeMin;
284   double                           myFieldStepRangeMax;
285   std::string                      myName;
286   std::string                      myTexture;
287   int                              myType;
288   SALOME_View*                     myViewFrame;
289   bool                             myUpdateColorScale; // IPAL54049
290
291   // Attributes
292   Quantity_Color                   myShadingColor;
293   int                              myColor;
294   double                           myWidth;
295   int                              myIsosWidth;
296   int                              myNbIsos;
297   int                              myIsosColor;
298   bool                             myToActivate;
299   int                              myDisplayMode;
300   bool                             myHasDisplayMode;
301   Aspect_TypeOfMarker              myTypeOfMarker;
302   double                           myScaleOfMarker;
303   double                           myTransparency;
304   bool                             myIsRedisplayed;
305
306 private:
307   SalomeApp_Application* myApp;
308   friend class GEOM_Swig;
309 };
310
311 #endif // GEOM_DISPLAYER_H
312