bbfeb655daa5ef2c3a05a02427672bc27a2569a9
[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_SequenceOfGroup.hxx>
21 #include <Graphic3d_SequenceOfHClipPlane.hxx>
22 #include <Graphic3d_TypeOfComposition.hxx>
23 #include <Graphic3d_ViewAffinity.hxx>
24 #include <Graphic3d_TransformPers.hxx>
25 #include <Graphic3d_Vec3.hxx>
26 #include <Graphic3d_ZLayerId.hxx>
27
28 class Graphic3d_GraphicDriver;
29 class Graphic3d_StructureManager;
30
31 //! Low-level graphic structure interface
32 class Graphic3d_CStructure : public Standard_Transient
33 {
34
35 public:
36
37   //! @return graphic driver created this structure
38   const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const
39   {
40     return myGraphicDriver;
41   }
42
43   //! @return graphic groups
44   const Graphic3d_SequenceOfGroup& Groups() const
45   {
46     return myGroups;
47   }
48
49   //! Return transformation persistence.
50   const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
51
52   //! Set transformation persistence.
53   void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
54
55   //! @return associated clip planes
56   const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
57   {
58     return myClipPlanes;
59   }
60
61   //! Pass clip planes to the associated graphic driver structure
62   void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; }
63
64   //! @return bounding box of this presentation
65   const Graphic3d_BndBox4f& BoundingBox() const
66   {
67     return myBndBox;
68   }
69
70   //! @return bounding box of this presentation
71   //! without transformation matrix applied
72   Graphic3d_BndBox4f& ChangeBoundingBox()
73   {
74     return myBndBox;
75   }
76
77   //! Return structure visibility flag
78   bool IsVisible() const { return visible != 0; }
79
80   //! Return structure visibility considering both View Affinity and global visibility state.
81   bool IsVisible (const Standard_Integer theViewId) const
82   {
83     return visible != 0
84         && (ViewAffinity.IsNull()
85          || ViewAffinity->IsVisible (theViewId));
86   }
87
88   //! Set z layer ID to display the structure in specified layer
89   void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
90
91   //! Get z layer ID
92   Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
93
94 public:
95
96   //! Update structure visibility state
97   virtual void OnVisibilityChanged() = 0;
98
99   //! Clear graphic data
100   virtual void Clear() = 0;
101
102   //! Connect other structure to this one
103   virtual void Connect    (Graphic3d_CStructure& theStructure) = 0;
104
105   //! Disconnect other structure to this one
106   virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0;
107
108   //! Synchronize structure transformation
109   virtual void UpdateTransformation() = 0;
110
111   //! Highlight entire structure with color
112   virtual void HighlightWithColor  (const Graphic3d_Vec3&  theColor,
113                                     const Standard_Boolean theToCreate) = 0;
114
115   //! Highlight structure using boundary box
116   virtual void HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct,
117                                     const Standard_Boolean             theToCreate) = 0;
118
119   //! Create shadow link to this structure
120   virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0;
121
122   //! Create new group within this structure
123   virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0;
124
125   //! Remove group from this structure
126   virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
127
128 public:
129
130   int                      Id;
131   Graphic3d_ZLayerId       myZLayer;
132   int                      Priority;
133   int                      PreviousPriority;
134
135   Quantity_Color           HighlightColor;
136
137   Graphic3d_Mat4           Transformation;
138
139   int   ContainsFacet;
140
141   Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
142
143   unsigned IsInfinite     : 1;
144   unsigned stick          : 1; //!< displaying state - should be set when structure has been added to scene graph (but can be in hidden state)
145   unsigned highlight      : 1;
146   unsigned visible        : 1; //!< visibility flag - can be used to suppress structure while leaving it in the scene graph
147   unsigned HLRValidation  : 1;
148   unsigned IsForHighlight : 1;
149   unsigned IsMutable      : 1;
150   unsigned Is2dText       : 1;
151
152 protected:
153
154   //! Create empty structure.
155   Standard_EXPORT Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager);
156
157 protected:
158
159   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
160   Graphic3d_SequenceOfGroup       myGroups;
161   Graphic3d_BndBox4f              myBndBox;
162   Handle(Graphic3d_TransformPers) myTrsfPers;
163   Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
164
165 public:
166
167   DEFINE_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) // Type definition
168
169 };
170
171 DEFINE_STANDARD_HANDLE (Graphic3d_CStructure, Standard_Transient)
172
173 #endif // _Graphic3d_CStructure_HeaderFile