2 // Copyright (c) 1998-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Visual3d_Layer_HeaderFile
17 #define _Visual3d_Layer_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
22 #include <Aspect_CLayer2d.hxx>
23 #include <Standard_Address.hxx>
24 #include <Visual3d_NListOfLayerItem.hxx>
25 #include <MMgt_TShared.hxx>
26 #include <Aspect_TypeOfLayer.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_Real.hxx>
29 #include <Standard_CString.hxx>
30 #include <Standard_ShortReal.hxx>
31 #include <Aspect_TypeOfLine.hxx>
32 #include <Aspect_TypeOfDisplayText.hxx>
33 #include <Aspect_TypeOfConstraint.hxx>
34 #include <Standard_Integer.hxx>
35 class Graphic3d_GraphicDriver;
36 class Visual3d_LayerDefinitionError;
37 class Visual3d_ViewManager;
39 class Visual3d_LayerItem;
43 DEFINE_STANDARD_HANDLE(Visual3d_Layer, MMgt_TShared)
45 //! This class allows to manage 2d graphics.
46 class Visual3d_Layer : public MMgt_TShared
52 //! Creates a layer with the type <Atype>.
53 //! if <AFlag> == Standard_True then the layer is
55 //! The mapping of the layer is dependent of each
57 //! if <AFlag> == Standard_False then the mapping of the
58 //! layer is dependent of the highest window and the largest
59 //! window of all the views of the viewer <AViewer>.
60 //! When the viewer <AViewer> have only one view, the
61 //! result will be the same with <AFlag> == Standard_False
62 //! or <AFlag> == Standard_True.
63 Standard_EXPORT Visual3d_Layer(const Handle(Visual3d_ViewManager)& AViewer, const Aspect_TypeOfLayer AType = Aspect_TOL_OVERLAY, const Standard_Boolean AFlag = Standard_False);
65 //! Suppress the layer <me>.
66 Standard_EXPORT void Destroy();
72 //! Begins the definition of the layer <me>
73 //! Warning: No default attributes
74 Standard_EXPORT void Begin();
76 //! Finishs the definition of the layer <me>.
77 Standard_EXPORT void End();
79 //! Clear all graphics managed by the layer <me>.
80 Standard_EXPORT void Clear();
82 //! After this call, <me> is ready to receive
83 //! a definition of a polyline with AddVertex().
84 Standard_EXPORT void BeginPolyline();
86 //! After this call, <me> is ready to receive
87 //! a definition of a polygon with AddEdge().
88 Standard_EXPORT void BeginPolygon();
90 //! Puts <X, Y> as a new point in the current primitive.
91 //! If <AFlag> then it is a draw between last point and
92 //! this point else it is a move between last point and
94 Standard_EXPORT void AddVertex (const Standard_Real X, const Standard_Real Y, const Standard_Boolean AFlag = Standard_True);
96 //! After this call, <me> stops the reception of
97 //! a definition of a Begin... primitive.
98 Standard_EXPORT void ClosePrimitive();
100 //! Draws the rectangle at position <X,Y>.
101 Standard_EXPORT void DrawRectangle (const Standard_Real X, const Standard_Real Y, const Standard_Real Width, const Standard_Real Height);
103 //! Draws the string <AText> at position <X,Y>.
104 //! The attributes are given with respect to the plane of
106 //! <AHeight> : Height of text.
107 //! (Relative to the Normalized Projection
108 //! Coordinates (NPC) Space).
109 Standard_EXPORT void DrawText (const Standard_CString AText, const Standard_Real X, const Standard_Real Y, const Standard_Real AHeight);
111 //! Get the size of text.
112 //! The attributes are given with respect to the plane of
114 //! <AHeight> : Height of text.
115 //! (Relative to the Normalized Projection
116 //! Coordinates (NPC) Space).
117 Standard_EXPORT void TextSize (const Standard_CString AText, const Standard_Real AHeight, Standard_Real& AWidth, Standard_Real& AnAscent, Standard_Real& ADescent) const;
119 //! Modifies the current color.
120 //! Warning: No default color
121 Standard_EXPORT void SetColor (const Quantity_Color& AColor);
123 //! Modifies the current transparency.
124 //! Warning: No default transparency
125 Standard_EXPORT void SetTransparency (const Standard_ShortReal ATransparency);
127 //! Unsets the transparency.
128 Standard_EXPORT void UnsetTransparency();
130 //! Modifies the current lines attributes.
131 //! Warning: No default attributes
132 Standard_EXPORT void SetLineAttributes (const Aspect_TypeOfLine AType, const Standard_Real AWidth);
134 //! Modifies the current texts attributes.
135 //! <AFont> defines the name of the font to be used.
136 //! <AType> defines the display type of the text.
137 //! <AColor> defines the color of decal or subtitle background.
138 //! To set the color of the text you can use the SetColor method.
139 //! Warning: No default attributes
140 Standard_EXPORT void SetTextAttributes (const Standard_CString AFont, const Aspect_TypeOfDisplayText AType, const Quantity_Color& AColor);
142 //! Modifies the current coordinates system of the layer <me>.
143 Standard_EXPORT void SetOrtho (const Standard_Real Left, const Standard_Real Right, const Standard_Real Bottom, const Standard_Real Top, const Aspect_TypeOfConstraint Attach = Aspect_TOC_BOTTOM_LEFT);
145 //! Modifies the current viewport of the layer <me>.
146 Standard_EXPORT void SetViewport (const Standard_Integer Width, const Standard_Integer Height);
148 //! Returns the associated C structure.
149 Standard_EXPORT Aspect_CLayer2d CLayer() const;
151 //! Returns the type.
152 Standard_EXPORT Aspect_TypeOfLayer Type() const;
154 Standard_EXPORT void AddLayerItem (const Handle(Visual3d_LayerItem)& Item);
156 Standard_EXPORT void RemoveLayerItem (const Handle(Visual3d_LayerItem)& Item);
158 Standard_EXPORT void RemoveAllLayerItems();
160 Standard_EXPORT const Visual3d_NListOfLayerItem& GetLayerItemList() const;
162 Standard_EXPORT void RenderLayerItems() const;
166 DEFINE_STANDARD_RTTI(Visual3d_Layer,MMgt_TShared)
176 Handle(Graphic3d_GraphicDriver) MyGraphicDriver;
177 Aspect_CLayer2d MyCLayer;
178 Standard_Address MyPtrViewManager;
179 Visual3d_NListOfLayerItem MyListOfLayerItems;
190 #endif // _Visual3d_Layer_HeaderFile