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