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_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 <Geom_Transformation.hxx>
29 class Graphic3d_GraphicDriver;
30 class Graphic3d_StructureManager;
32 //! Low-level graphic structure interface
33 class Graphic3d_CStructure : public Standard_Transient
38 //! @return graphic driver created this structure
39 const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const
41 return myGraphicDriver;
44 //! @return graphic groups
45 const Graphic3d_SequenceOfGroup& Groups() const
50 //! Return transformation.
51 const Handle(Geom_Transformation)& Transformation() const { return myTrsf; }
53 //! Assign transformation.
54 virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) { myTrsf = theTrsf; }
56 //! Return transformation persistence.
57 const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
59 //! Set transformation persistence.
60 void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
62 //! @return associated clip planes
63 const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
68 //! Pass clip planes to the associated graphic driver structure
69 void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; }
71 //! @return bounding box of this presentation
72 const Graphic3d_BndBox4f& BoundingBox() const
77 //! @return bounding box of this presentation
78 //! without transformation matrix applied
79 Graphic3d_BndBox4f& ChangeBoundingBox()
84 //! Return structure visibility flag
85 bool IsVisible() const { return visible != 0; }
87 //! Return structure visibility considering both View Affinity and global visibility state.
88 bool IsVisible (const Standard_Integer theViewId) const
91 && (ViewAffinity.IsNull()
92 || ViewAffinity->IsVisible (theViewId));
95 //! Set z layer ID to display the structure in specified layer
96 void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
99 Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
103 //! Update structure visibility state
104 virtual void OnVisibilityChanged() = 0;
106 //! Clear graphic data
107 virtual void Clear() = 0;
109 //! Connect other structure to this one
110 virtual void Connect (Graphic3d_CStructure& theStructure) = 0;
112 //! Disconnect other structure to this one
113 virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0;
115 //! Highlight entire structure with color
116 virtual void HighlightWithColor (const Graphic3d_Vec3& theColor,
117 const Standard_Boolean theToCreate) = 0;
119 //! Highlight structure using boundary box
120 virtual void HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct,
121 const Standard_Boolean theToCreate) = 0;
123 //! Create shadow link to this structure
124 virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0;
126 //! Create new group within this structure
127 virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0;
129 //! Remove group from this structure
130 virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
135 Graphic3d_ZLayerId myZLayer;
137 int PreviousPriority;
139 Quantity_Color HighlightColor;
143 Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
145 unsigned IsInfinite : 1;
146 unsigned stick : 1; //!< displaying state - should be set when structure has been added to scene graph (but can be in hidden state)
147 unsigned highlight : 1;
148 unsigned visible : 1; //!< visibility flag - can be used to suppress structure while leaving it in the scene graph
149 unsigned HLRValidation : 1;
150 unsigned IsForHighlight : 1;
151 unsigned IsMutable : 1;
152 unsigned Is2dText : 1;
156 //! Create empty structure.
157 Standard_EXPORT Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager);
161 Handle(Graphic3d_GraphicDriver) myGraphicDriver;
162 Graphic3d_SequenceOfGroup myGroups;
163 Graphic3d_BndBox4f myBndBox;
164 Handle(Geom_Transformation) myTrsf;
165 Handle(Graphic3d_TransformPers) myTrsfPers;
166 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
170 DEFINE_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) // Type definition
174 DEFINE_STANDARD_HANDLE (Graphic3d_CStructure, Standard_Transient)
176 #endif // _Graphic3d_CStructure_HeaderFile