fixed: let the material fill the override chunk block
[opensg.git] / Source / System / Text / OSGTextVectorGlyph.h
blob16afc090481f9871e280ccd9796521792e030f65
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGTEXTVECTORGLYPH_H_
40 #define _OSGTEXTVECTORGLYPH_H_
42 #ifdef _MSC_VER
43 # pragma once
44 #endif
46 #include "OSGConfig.h"
47 #include "OSGTextDef.h"
48 #include "OSGBaseTypes.h"
49 #include "OSGVector.h"
51 #include "OSGTextGlyph.h"
53 #include <vector>
54 #include <map>
57 OSG_BEGIN_NAMESPACE
60 /**
61 * Defines a vector glyph.
62 * @author Patrick D&auml;hne
64 * \ingroup GrpTextGlyphs
65 * \ingroup GrpLibOSGText
68 class OSG_TEXT_DLLMAPPING TextVectorGlyph: public TextGlyph
71 /** Needs access to constructor */
72 friend class TextVectorFace;
74 /*========================== PUBLIC =================================*/
75 public:
77 /**
78 * Defines a point of an outline.
79 * @author Patrick D&auml;hne
81 * \nohierarchy
84 struct OSG_TEXT_DLLMAPPING Point
86 /** Defines different types of outline points */
87 enum PointType
89 PT_ON,
90 PT_QUAD,
91 PT_CUBIC
94 /** The position */
95 Vec2f pos;
97 /** The type of point (on, quad, cubic) */
98 PointType type;
101 * Creates a new %Point object.
102 * @param _pos The position
103 * @param _type The type of point
105 inline Point(const Vec2f &_pos, PointType _type);
108 /** Defines a contour */
109 typedef std::vector<Point> Contour;
111 /** Defines an outline */
112 typedef std::vector<Contour> Outline;
114 /** Defines an outline consisting of 2-d polygon lines
116 * \nohierarchy
119 struct OSG_TEXT_DLLMAPPING PolygonOutline
121 /** All vertices of the outline */
122 std::vector<Vec2f> coords;
124 /** The index of the last vertex of each contour */
125 std::vector<UInt32> contours;
127 /** The vertex indices produced by the tesselation */
128 std::vector<UInt32> indices;
130 /** Defines a pair of a GL primitive type and an index */
131 typedef std::pair<GLenum, UInt32> TypeIndex;
134 * The GL primitive types (triangles, triangle strips or
135 * triangle fans) and the index of the last vertex of each
136 * sequence of primitives.
138 std::vector<TypeIndex> types;
142 * Defines a normal for a vertex in a contour. The normal is approximated
143 * by taking the mean of its adjacent edge normals.
145 * \nohierarchy
148 struct OSG_TEXT_DLLMAPPING VertexNormal
150 /** The edge normal of the outgoing edge */
151 Vec2f nextEdgeNormal;
153 /** normalized mean of the adjacent edge normals */
154 Vec2f meanEdgeNormal;
156 /** the angle between the adjacent edges */
157 Real32 edgeAngle;
159 /** Constructor */
160 inline VertexNormal(const Vec2f &nextEdgeNormal_,
161 const Vec2f &meanEdgeNormal_,
162 Real32 edgeAngle_ );
165 /** Defines a vector containing the edge normals along a polygon contour. */
166 typedef std::vector<VertexNormal> Normals;
168 /** Destroys the %VectorGlyph object. */
169 virtual ~TextVectorGlyph(void);
172 * Returns the width of the glyph.
173 * @return The width of the glyph
175 virtual Real32 getWidth(void) const;
178 * Returns the height of the glyph.
179 * @return The height of the glyph
181 virtual Real32 getHeight(void) const;
184 * Returns the x bearing of the glyph for horizontal layout.
185 * The x bearing is the distance from the origin to the left
186 * border of the glyph.
187 * @return The x bearing of the glyph for horizontal layout
189 virtual Real32 getHoriBearingX(void) const;
192 * Returns the y bearing of the glyph for horizontal layout.
193 * The y bearing is the distance from the origin to the top
194 * border of the glyph.
195 * @return The y bearing of the glyph for horizontal layout
197 virtual Real32 getHoriBearingY(void) const;
200 * Returns the x bearing of the glyph for vertical layout.
201 * The x bearing is the distance from the origin to the left
202 * border of the glyph.
203 * @return The x bearing of the glyph for vertical layout
205 virtual Real32 getVertBearingX(void) const;
208 * Returns the y bearing of the glyph for vertical layout.
209 * The y bearing is the distance from the origin to the top
210 * border of the glyph.
211 * @return The y bearing of the glyph for vertical layout
213 virtual Real32 getVertBearingY(void) const;
216 * Returns the contours that describe the outline
217 * of the glyph.
218 * @return The contours.
220 inline const Outline &getOutline(void) const;
223 * Returns a polygon outline containing only on-curve points.
224 * The contours contained in this outline are not closed!
225 * @param level The level of detail.
226 * @return An outline containing only on-curve points.
228 const PolygonOutline &getLines(UInt32 level = 2) const;
231 * Returns an edge normal outline of the specified detail level
232 * @param level The level of detail.
233 * @return The normals at the edges of the outline.
235 const Normals &getNormals(UInt32 level = 2) const;
237 /** Defines symbolic constants for the orientation of a contour. */
238 enum Orientation
240 CW, CCW
244 * Returns the orientations of the outlines.
245 * @return The orientations of the outline.
247 const std::vector<Orientation> &getContourOrientations(void) const;
249 /*========================= PROTECTED ===============================*/
250 protected:
252 /** Creates a new %VectorGlyph object. */
253 inline TextVectorGlyph(void);
255 /** The width of the glyph */
256 Real32 _width;
258 /** The height of the glyph */
259 Real32 _height;
261 /** The x bearing of the glyph for horizontal layout */
262 Real32 _horiBearingX;
264 /** The y bearing of the glyph for horizontal layout */
265 Real32 _horiBearingY;
267 /** The x bearing of the glyph for vertical layout */
268 Real32 _vertBearingX;
270 /** The y bearing of the glyph for vertical layout */
271 Real32 _vertBearingY;
273 /** The original outline information */
274 Outline _outline;
276 /** The vector of contour orientations */
277 mutable std::vector<Orientation> _contourOrientations;
279 /** Defines the map of polygon outlines (level -> outline)*/
280 typedef std::map<UInt32, PolygonOutline> PolygonOutlineMap;
282 /** The map of polygon outlines (level -> outline)*/
283 mutable PolygonOutlineMap _polygonOutlineMap;
285 /** Defines the map of normal outlines (level -> edge normal outline) */
286 typedef std::map<UInt32, Normals> NormalMap;
288 /** The map of normal outlines (level -> edge normal outline) */
289 mutable NormalMap _normalMap;
291 /*========================== PRIVATE ================================*/
292 private:
294 /** Copy constructor (not implemented!) */
295 TextVectorGlyph(const TextVectorGlyph &);
297 /** Copy operator (not implemented!) */
298 const TextVectorGlyph &operator=(const TextVectorGlyph &);
300 /** Computes the orientation of each contour */
301 void computeContourOrientations(void) const;
305 OSG_END_NAMESPACE
308 #include "OSGTextVectorGlyph.inl"
310 #endif /* _OSGTEXTVECTORGLYPH_H_ */