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