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