0c3a4b6f1fc2a5407c993d2d8038ff7a467c0be8
[occt.git] / src / Visual3d / Visual3d_Layer.hxx
1 // Created by: CAL
2 // Copyright (c) 1998-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _Visual3d_Layer_HeaderFile
17 #define _Visual3d_Layer_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
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;
38 class Quantity_Color;
39 class Visual3d_LayerItem;
40
41
42 class Visual3d_Layer;
43 DEFINE_STANDARD_HANDLE(Visual3d_Layer, MMgt_TShared)
44
45 //! This class allows to manage 2d graphics.
46 class Visual3d_Layer : public MMgt_TShared
47 {
48
49 public:
50
51   
52   //! Creates a layer with the type <Atype>.
53   //! if <AFlag> == Standard_True then the layer is
54   //! "size dependent".
55   //! The mapping of the layer is dependent of each
56   //! window's size.
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);
64   
65   //! Suppress the layer <me>.
66   Standard_EXPORT void Destroy();
67 ~Visual3d_Layer()
68 {
69   Destroy();
70 }
71   
72   //! Begins the definition of the layer <me>
73   //! Warning: No default attributes
74   Standard_EXPORT void Begin();
75   
76   //! Finishs the definition of the layer <me>.
77   Standard_EXPORT void End();
78   
79   //! Clear all graphics managed by the layer <me>.
80   Standard_EXPORT void Clear();
81   
82   //! After this call, <me> is ready to receive
83   //! a definition of a polyline with AddVertex().
84   Standard_EXPORT void BeginPolyline();
85   
86   //! After this call, <me> is ready to receive
87   //! a definition of a polygon with AddEdge().
88   Standard_EXPORT void BeginPolygon();
89   
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
93   //! this point.
94   Standard_EXPORT void AddVertex (const Standard_Real X, const Standard_Real Y, const Standard_Boolean AFlag = Standard_True);
95   
96   //! After this call, <me> stops the reception of
97   //! a definition of a Begin... primitive.
98   Standard_EXPORT void ClosePrimitive();
99   
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);
102   
103   //! Draws the string <AText> at position <X,Y>.
104   //! The attributes are given with respect to the plane of
105   //! projection.
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);
110   
111   //! Get the size of text.
112   //! The attributes are given with respect to the plane of
113   //! projection.
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;
118   
119   //! Modifies the current color.
120   //! Warning: No default color
121   Standard_EXPORT void SetColor (const Quantity_Color& AColor);
122   
123   //! Modifies the current transparency.
124   //! Warning: No default transparency
125   Standard_EXPORT void SetTransparency (const Standard_ShortReal ATransparency);
126   
127   //! Unsets the transparency.
128   Standard_EXPORT void UnsetTransparency();
129   
130   //! Modifies the current lines attributes.
131   //! Warning: No default attributes
132   Standard_EXPORT void SetLineAttributes (const Aspect_TypeOfLine AType, const Standard_Real AWidth);
133   
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);
141   
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);
144   
145   //! Modifies the current viewport of the layer <me>.
146   Standard_EXPORT void SetViewport (const Standard_Integer Width, const Standard_Integer Height);
147   
148   //! Returns the associated C structure.
149   Standard_EXPORT Aspect_CLayer2d CLayer() const;
150   
151   //! Returns the type.
152   Standard_EXPORT Aspect_TypeOfLayer Type() const;
153   
154   Standard_EXPORT void AddLayerItem (const Handle(Visual3d_LayerItem)& Item);
155   
156   Standard_EXPORT void RemoveLayerItem (const Handle(Visual3d_LayerItem)& Item);
157   
158   Standard_EXPORT void RemoveAllLayerItems();
159   
160   Standard_EXPORT const Visual3d_NListOfLayerItem& GetLayerItemList() const;
161   
162   Standard_EXPORT void RenderLayerItems() const;
163
164
165
166   DEFINE_STANDARD_RTTI(Visual3d_Layer,MMgt_TShared)
167
168 protected:
169
170
171
172
173 private:
174
175
176   Handle(Graphic3d_GraphicDriver) MyGraphicDriver;
177   Aspect_CLayer2d MyCLayer;
178   Standard_Address MyPtrViewManager;
179   Visual3d_NListOfLayerItem MyListOfLayerItems;
180
181
182 };
183
184
185
186
187
188
189
190 #endif // _Visual3d_Layer_HeaderFile