1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _Graphic3d_CStructure_HeaderFile
16 #define _Graphic3d_CStructure_HeaderFile
18 #include <Graphic3d_BndBox3d.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>
30 class Graphic3d_GraphicDriver;
31 class Graphic3d_StructureManager;
33 //! Low-level graphic structure interface
34 class Graphic3d_CStructure : public Standard_Transient
39 //! @return graphic driver created this structure
40 const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const
42 return myGraphicDriver;
45 //! @return graphic groups
46 const Graphic3d_SequenceOfGroup& Groups() const
51 //! Return transformation.
52 const Handle(Geom_Transformation)& Transformation() const { return myTrsf; }
54 //! Assign transformation.
55 virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) { myTrsf = theTrsf; }
57 //! Return transformation persistence.
58 const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
60 //! Set transformation persistence.
61 virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
63 //! @return associated clip planes
64 const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
69 //! Pass clip planes to the associated graphic driver structure
70 void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; }
72 //! @return bounding box of this presentation
73 const Graphic3d_BndBox3d& BoundingBox() const
78 //! @return bounding box of this presentation
79 //! without transformation matrix applied
80 Graphic3d_BndBox3d& ChangeBoundingBox()
85 //! Return structure visibility flag
86 bool IsVisible() const { return visible != 0; }
88 //! Return structure visibility considering both View Affinity and global visibility state.
89 bool IsVisible (const Standard_Integer theViewId) const
92 && (ViewAffinity.IsNull()
93 || ViewAffinity->IsVisible (theViewId));
96 //! Set z layer ID to display the structure in specified layer
97 virtual void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
100 Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
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; }
108 //! Update structure visibility state
109 virtual void OnVisibilityChanged() = 0;
111 //! Clear graphic data
112 virtual void Clear() = 0;
114 //! Connect other structure to this one
115 virtual void Connect (Graphic3d_CStructure& theStructure) = 0;
117 //! Disconnect other structure to this one
118 virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0;
120 //! Highlights structure with the given style
121 virtual void GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle,
122 const Handle(Graphic3d_Structure)& theStruct) = 0;
124 //! Unhighlights the structure and invalidates pointer to structure's highlight
126 virtual void GraphicUnhighlight() = 0;
128 //! Create shadow link to this structure
129 virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0;
131 //! Create new group within this structure
132 virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0;
134 //! Remove group from this structure
135 virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
140 Graphic3d_ZLayerId myZLayer;
142 int PreviousPriority;
146 Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
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;
159 //! Create empty structure.
160 Standard_EXPORT Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager);
164 Handle(Graphic3d_GraphicDriver) myGraphicDriver;
165 Graphic3d_SequenceOfGroup myGroups;
166 Graphic3d_BndBox3d 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
174 DEFINE_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) // Type definition
178 DEFINE_STANDARD_HANDLE (Graphic3d_CStructure, Standard_Transient)
180 #endif // _Graphic3d_CStructure_HeaderFile