0027818: Visualization - provide an interface to define highlight presentation properties
[occt.git] / src / Graphic3d / Graphic3d_CStructure.hxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _Graphic3d_CStructure_HeaderFile
16 #define _Graphic3d_CStructure_HeaderFile
17
18 #include <Graphic3d_BndBox4f.hxx>
19 #include <Graphic3d_Group.hxx>
20 #include <Graphic3d_HighlightStyle.hxx>
21 #include <Graphic3d_SequenceOfGroup.hxx>
22 #include <Graphic3d_SequenceOfHClipPlane.hxx>
23 #include <Graphic3d_TypeOfComposition.hxx>
24 #include <Graphic3d_ViewAffinity.hxx>
25 #include <Graphic3d_TransformPers.hxx>
26 #include <Graphic3d_Vec3.hxx>
27 #include <Graphic3d_ZLayerId.hxx>
28 #include <Geom_Transformation.hxx>
29
30 class Graphic3d_GraphicDriver;
31 class Graphic3d_StructureManager;
32
33 //! Low-level graphic structure interface
34 class Graphic3d_CStructure : public Standard_Transient
35 {
36
37 public:
38
39   //! @return graphic driver created this structure
40   const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const
41   {
42     return myGraphicDriver;
43   }
44
45   //! @return graphic groups
46   const Graphic3d_SequenceOfGroup& Groups() const
47   {
48     return myGroups;
49   }
50
51   //! Return transformation.
52   const Handle(Geom_Transformation)& Transformation() const { return myTrsf; }
53
54   //! Assign transformation.
55   virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) { myTrsf = theTrsf; }
56
57   //! Return transformation persistence.
58   const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
59
60   //! Set transformation persistence.
61   void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
62
63   //! @return associated clip planes
64   const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
65   {
66     return myClipPlanes;
67   }
68
69   //! Pass clip planes to the associated graphic driver structure
70   void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; }
71
72   //! @return bounding box of this presentation
73   const Graphic3d_BndBox4f& BoundingBox() const
74   {
75     return myBndBox;
76   }
77
78   //! @return bounding box of this presentation
79   //! without transformation matrix applied
80   Graphic3d_BndBox4f& ChangeBoundingBox()
81   {
82     return myBndBox;
83   }
84
85   //! Return structure visibility flag
86   bool IsVisible() const { return visible != 0; }
87
88   //! Return structure visibility considering both View Affinity and global visibility state.
89   bool IsVisible (const Standard_Integer theViewId) const
90   {
91     return visible != 0
92         && (ViewAffinity.IsNull()
93          || ViewAffinity->IsVisible (theViewId));
94   }
95
96   //! Set z layer ID to display the structure in specified layer
97   void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
98
99   //! Get z layer ID
100   Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
101
102   //! Returns valid handle to highlight style of the structure in case if
103   //! highlight flag is set to true
104   const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const { return myHighlightStyle; }
105
106 public:
107
108   //! Update structure visibility state
109   virtual void OnVisibilityChanged() = 0;
110
111   //! Clear graphic data
112   virtual void Clear() = 0;
113
114   //! Connect other structure to this one
115   virtual void Connect    (Graphic3d_CStructure& theStructure) = 0;
116
117   //! Disconnect other structure to this one
118   virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0;
119
120   //! Highlights structure with the given style
121   virtual void GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle,
122                                  const Handle(Graphic3d_Structure)&      theStruct) = 0;
123
124   //! Unhighlights the structure and invalidates pointer to structure's highlight
125   //! style
126   virtual void GraphicUnhighlight() = 0;
127
128   //! Create shadow link to this structure
129   virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0;
130
131   //! Create new group within this structure
132   virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0;
133
134   //! Remove group from this structure
135   virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
136
137 public:
138
139   int                      Id;
140   Graphic3d_ZLayerId       myZLayer;
141   int                      Priority;
142   int                      PreviousPriority;
143
144   int   ContainsFacet;
145
146   Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
147
148   unsigned IsInfinite     : 1;
149   unsigned stick          : 1; //!< displaying state - should be set when structure has been added to scene graph (but can be in hidden state)
150   unsigned highlight      : 1;
151   unsigned visible        : 1; //!< visibility flag - can be used to suppress structure while leaving it in the scene graph
152   unsigned HLRValidation  : 1;
153   unsigned IsForHighlight : 1;
154   unsigned IsMutable      : 1;
155   unsigned Is2dText       : 1;
156
157 protected:
158
159   //! Create empty structure.
160   Standard_EXPORT Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager);
161
162 protected:
163
164   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
165   Graphic3d_SequenceOfGroup       myGroups;
166   Graphic3d_BndBox4f              myBndBox;
167   Handle(Geom_Transformation)     myTrsf;
168   Handle(Graphic3d_TransformPers) myTrsfPers;
169   Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
170   Handle(Graphic3d_HighlightStyle)       myHighlightStyle; //! Current highlight style; is set only if highlight flag is true
171
172 public:
173
174   DEFINE_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) // Type definition
175
176 };
177
178 DEFINE_STANDARD_HANDLE (Graphic3d_CStructure, Standard_Transient)
179
180 #endif // _Graphic3d_CStructure_HeaderFile