WebRadioApp  0.1
_GraphicsPath.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * E M B E D D E D W I Z A R D P R O J E C T
4  *
5  * Copyright (c) TARA Systems
6  *GmbH written by Paul Banach and Manfred Schweyer
7  *
8  ********************************************************************************
9  *
10  * This file was generated automatically by Embedded Wizard Studio.
11  *
12  * Please do not make any modifications of this file! The modifications are lost
13  * when the file is generated again by Embedded Wizard Studio!
14  *
15  * The template of this heading text can be found in the file 'head.ewt' in the
16  * directory 'Platforms' of your Embedded Wizard installation directory. If you
17  * wish to adapt this text, please copy the template file 'head.ewt' into your
18  * project directory and edit the copy only. Please avoid any modifications of
19  * the original template file!
20  *
21  * Version : 10.00
22  * Profile : STM32H747
23  * Platform : STM.STM32.RGB565
24  *
25  *******************************************************************************/
26 
27 #ifndef _GraphicsPath_H
28 #define _GraphicsPath_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include "ewrte.h"
35 #if EW_RTE_VERSION != 0x000A0000
36 #error Wrong version of Embedded Wizard Runtime Environment.
37 #endif
38 
39 #include "ewgfx.h"
40 #if EW_GFX_VERSION != 0x000A0000
41 #error Wrong version of Embedded Wizard Graphics Engine.
42 #endif
43 
44 /* Forward declaration of the class Graphics::Path */
45 #ifndef _GraphicsPath_
46 EW_DECLARE_CLASS(GraphicsPath)
47 #define _GraphicsPath_
48 #endif
49 
50 /* The class Graphics::Path provides functionality to create and store curve
51  data. Every path object can contain one or more sub-paths. In turn, every
52  sub-path can be individually composed of line segments, Bézier curves,
53  elliptical arcs or even circles. In this manner complex polygons and paths
54  can be constructed easily. With the path information the curves can be
55  displayed on the screen. The view Views::FillPath displays the path as filled
56  polygon. The view Views::StrokePath displays the path as a line with
57  specified width. The methods of the class Graphics::Paths can be divided in
58  following groups:
59  - To specify how many sub-paths the path should be able to manage use the
60  method
61  @SetMaxNoOfSubPaths(). To reserve memory for a sub-path use the method
62  @InitSubPath().
63  - With the method @Begin() the start position for a sub-path can be
64  determined or existing sub-path data can be cleared again. In turn, with the
65  method @Close() a sub-path can be closed so its end and start positions
66  appear connected together.
67  - Alternatively path data can be loaded from an SVG string by using the
68  method
69  @CreateFromSVGString().
70  - With the methods @AddLine(), @AddBezier2(), @AddBezier3() and @AddArc() new
71  line segments or even complex curves are added to the sub-path. With the
72  method
73  @AddCopy() a duplicate of another existing sub-path can be added.
74  - With the method @SetNode() the previously prepared sub-path data can be
75  modified. Similarly by using the methods @GetNodeX() and @GetNodeY() the X, Y
76  coordinates stored in the path can be evaluated. The method @ShiftNodes() is
77  convenient to delete old nodes before new nodes are appended.
78  - The methods @InitMatrix(), @Translate(), @Scale(), @Rotate(), @PushMatrix()
79  and @PopMatrix() manage a 2D transformation matrix used to convert the
80  original coordinates of the lines and curves when adding them to the path.
81  - The methods @GetSubPathBounds() and @GetPathBounds() return the area
82  enlosing all edges of a particular sub-path or of all sub-paths. */
83 EW_DEFINE_FIELDS(GraphicsPath, XObject)
84 EW_VARIABLE(path, XHandle)
85 EW_END_OF_FIELDS(GraphicsPath)
86 
87 /* Virtual Method Table (VMT) for the class : 'Graphics::Path' */
88 EW_DEFINE_METHODS(GraphicsPath, XObject)
89 EW_END_OF_METHODS(GraphicsPath)
90 
91 /* 'C' function for method : 'Graphics::Path.onUpdate()' */
92 void GraphicsPath_onUpdate(GraphicsPath _this, XObject sender);
93 
94 /* 'C' function for method : 'Graphics::Path.Done()' */
95 void GraphicsPath_Done(GraphicsPath _this);
96 
97 /* The method AddArc() adds to the sub-path a new elliptical arc composed of
98  exact aNoOfEdges straight line segments. The more edges the more smooth the
99  resulting curve. The center of the ellipse is determined in the parameters
100  aCenterX, aCenterY. The parameters aRadiusX and aRadiusY determine the
101  horizontal and vertical radius of the ellipse. The start and the end angle of
102  the arc is determined in the parameters aStartAngle and aEndAngle, both
103  expressed in degree and measured clockwise relative to the positive X-axis of
104  the path coordinate system. If the absolute difference between aStartAngle
105  and aEndAngle is equal to or greater than 360.0, the method calculates with a
106  closed ellipse instead of an opened arc. If the parameters aRadiusX and
107  aRadiusY are equal, the method calculates with a circle instead of an
108  ellipse. If the affected sub-path contains already curve information, the end
109  of the last existing segment and the start of the new arc (resulting from the
110  parameter aStartAngle) are connected with an additional straight line
111  segment. Similarly, if start position for the sub-path has been specified by
112  using the @Begin() method, an additional line segment is added to connect the
113  arc with the given sub-path start position. After the elliptical arc curve is
114  added, the sub-path actual position is adjusted to refer to the end of the
115  last line segment of the curve (resulting from the parameter aEndAngle). The
116  specified position aX, aY is relative to the origin of the path coordinate
117  system. If the path own matrix is not an identity matrix, the corresponding
118  transformations are applied on the resulting arc segments before storing them
119  in the sub-path. See methods @Translate(), @Scale() and @Rotate(). The method
120  returns the index of the node within the sub-path where the start position of
121  the first arc line segment has been stored (parameter aStartAngle). Knowing
122  this index and the number of segments the arc curve is composed of
123  (aNoOfEdges), the position of every arc line segment can be modified later by
124  using the method
125  @SetNode().
126  If the sub-path has not been initialized previously by using the method
127  @InitSubPath(), the sub-path has been closed by @Close() method or the memory
128  reserved for the sub-path (see parameter aMaxNoOfEdges in the method
129  @InitSubPath()) is occupied by other edges so no sufficient space is
130  available to accommodate aNoOfEdges new segments, the method fails and
131  returns 0. The affected sub-path is determined in the parameter aSubPathNo.
132  Within the path all existing sub-paths are numbered starting with the value 0
133  for the first sub-path, 1 for the second and so far. The maximum number of
134  sub-paths the path can manage is determined by the method
135  @SetMaxNoOfSubPaths(). */
136 XInt32 GraphicsPath_AddArc(GraphicsPath _this, XInt32 aSubPathNo,
137  XFloat aCenterX, XFloat aCenterY, XFloat aRadiusX,
138  XFloat aRadiusY, XFloat aStartAngle,
139  XFloat aEndAngle, XInt32 aNoOfEdges);
140 
141 /* The method AddBezier3() appends between the actual position of the sub-path
142  and the position aX, aY a new cubic Bézier curve composed of exact aNoOfEdges
143  straight line segments. The more edges the more smooth the resulting curve.
144  The both Bézier curve control points are determined in the parameters aCP1X,
145  aCP1Y and aCP2X, aCP2Y. After the Bézier curve is added, the sub-path actual
146  position is adjusted to refer to the end of the last line segment of the
147  curve (position aX, aY). Within a sub-path the actual position is either the
148  end position of the preceding sub-path segment or it is the value specified
149  in the invocation of the @Begin() method. If the sub-path is empty and no
150  start position has been specified in the preceding @Begin() invocation, the
151  method assumes the origin of the path coordinate system (X=0, Y=0) as the
152  start position for the new curve. The specified positions aCP1X, aCP1Y,
153  aCP2X, aCP2, aX, aY are relative to the origin of the path coordinate system.
154  If the path own matrix is not an identity matrix, the corresponding
155  transformations are applied on the positions before calculating the Bézier
156  curve and storing the resulting line segments it in the sub-path. See methods
157  @Translate(), @Scale() and @Rotate(). The method returns the index of the
158  node within the sub-path where the end position of the first Bézier line
159  segment has been stored. Knowing this index and the number of segments the
160  Bézier curve is composed of (parameter aNoOfEdges), the position of every
161  Bézier line segment can be modified later by using the method
162  @SetNode().
163  If the sub-path has not been initialized previously by using the method
164  @InitSubPath(), the sub-path has been closed by @Close() method or the memory
165  reserved for the sub-path (see parameter aMaxNoOfEdges in the method
166  @InitSubPath()) is occupied by other edges so no sufficient space is
167  available to accommodate aNoOfEdges new segments, the method fails and
168  returns 0. The affected sub-path is determined in the parameter aSubPathNo.
169  Within the path all existing sub-paths are numbered starting with the value 0
170  for the first sub-path, 1 for the second and so far. The maximum number of
171  sub-paths the path can manage is determined by the method
172  @SetMaxNoOfSubPaths(). */
173 XInt32 GraphicsPath_AddBezier3(GraphicsPath _this, XInt32 aSubPathNo,
174  XFloat aCP1X, XFloat aCP1Y, XFloat aCP2X,
175  XFloat aCP2Y, XFloat aX, XFloat aY,
176  XInt32 aNoOfEdges);
177 
178 /* The method AddLine() appends between the actual position of the sub-path and
179  the position aX, aY a new straight line segment consisting of one edge. Then
180  the sub-path actual position is adjusted to refer to the end of the just
181  added line segment (aX, aY). Within a sub-path the actual position is either
182  the end position of the preceding sub-path segment or it is the value
183  specified in the invocation of the @Begin() method. If the sub-path is empty
184  and no start position has been specified in the preceding @Begin()
185  invocation, the method assumes the origin of the path coordinate system (X=0,
186  Y=0) as the start position for the new line segment. The specified position
187  aX, aY is relative to the origin of the path coordinate system. If the path
188  own matrix is not an identity matrix, the corresponding transformations are
189  applied on the position before storing it in the sub-path. See methods
190  @Translate(),
191  @Scale() and @Rotate().
192  The method returns the index of the node within the sub-path where the end
193  position of the new line segment has been stored. Knowing this index, the
194  position can be modified later by using the method @SetNode(). If the
195  sub-path has not been initialized previously by using the method
196  @InitSubPath(), the sub-path has been closed by @Close() method or the entire
197  memory reserved for the sub-path (see parameter aMaxNoOfEdges in the method
198  @InitSubPath()) is already occupied by other edges, the method fails and
199  returns 0. The affected sub-path is determined in the parameter aSubPathNo.
200  Within the path all existing sub-paths are numbered starting with the value 0
201  for the first sub-path, 1 for the second and so far. The maximum number of
202  sub-paths the path can manage is determined by the method
203  @SetMaxNoOfSubPaths(). */
204 XInt32 GraphicsPath_AddLine(GraphicsPath _this, XInt32 aSubPathNo, XFloat aX,
205  XFloat aY);
206 
207 /* The method Close() marks the affected sub-path as closed. The method verifies
208  whether the first and the last position of the sub-path are equal and if this
209  is not the case, adds an additional straight line segment to the sub-path in
210  order to connect them together.
211  Once the method is invoked, no additional path information can be added to
212  the affected sub-path unless it is initialized or cleared again by using the
213  method
214  @InitSubPath() or @Begin(). If the affected sub-path is empty, the method
215  returns without any effect. Within the path all existing sub-paths are
216  numbered starting with the value 0 for the first sub-path, 1 for the second
217  and so far. The maximum number of sub-paths
218  the path can manage is determined by the method @SetMaxNoOfSubPaths(). */
219 void GraphicsPath_Close(GraphicsPath _this, XInt32 aSubPathNo);
220 
221 /* The method Begin() sets the parameters aX, aY as the start position for the
222  sub-path with the specified number aSubPathNo. The affected sub-path has to
223  be initialized previously by invoking the method @InitSubPath(). Beginning
224  with the specified position, the path can be filled with curve data by using
225  methods like @AddLine(),
226  @AddBezier2(), @AddArc(), etc.
227  The specified position aX, aY is relative to the origin of the path
228  coordinate system. If the path own matrix is not an identity matrix, the
229  corresponding transformations are applied on the position before storing it
230  in the sub-path. See methods @Translate(),
231  @Scale() and @Rotate().
232  Every sub-path contains exact one start position. Calling this method for a
233  sub-path being already filled with edge coordinates will clear the actual
234  sub-path as if the @InitSubPath() method has been called before. Within the
235  path all existing sub-paths are numbered starting with the value 0 for the
236  first sub-path, 1 for the second and so far. The maximum number of sub-paths
237  the path can manage is determined by the method @SetMaxNoOfSubPaths(). */
238 void GraphicsPath_Begin(GraphicsPath _this, XInt32 aSubPathNo, XFloat aX,
239  XFloat aY);
240 
241 /* The method InitSubPath() prepares the sub-path with the number aSubPathNo to
242  be able to store up to aMaxNoOfEdges path edges (straight line segments).
243  With this operation memory for the sub-path data is reserved. Initially the
244  just initialized sub-path is considered as being empty. To fill the sub-path
245  with data use the methods like @AddLine(), @AddBezier2(), @AddArc(), etc. If
246  the affected sub-path has been already initialized in the past, the old
247  information is discarded before initializing the new sub-path. Passing 0
248  (zero) in the parameter aMaxNoOfEdges results in the old sub-path data being
249  simply released without allocating the memory for the new sub-path. If
250  successful, the method returns 'true'. If there is no memory available for
251  the specified number of edges, the method fails and 'false' is returned
252  leaving the sub-path not initialized. Similarly, trying to initialize a
253  sub-path not existing in the path causes the method to return 'false'. Within
254  the path all existing sub-paths are numbered starting with the value 0 for
255  the first sub-path, 1 for the second and so far. The maximum number of
256  sub-paths the path can manage is determined by the method
257  @SetMaxNoOfSubPaths(). */
258 XBool GraphicsPath_InitSubPath(GraphicsPath _this, XInt32 aSubPathNo,
259  XInt32 aMaxNoOfEdges);
260 
261 /* The method GetMaxNoOfSubPaths() returns how many sub-paths the affected path
262  can maximally store. The returned value corresponds to the parameter passed
263  in the invocation of the @SetMaxNoOfSubPaths() method. */
264 XInt32 GraphicsPath_GetMaxNoOfSubPaths(GraphicsPath _this);
265 
266 /* The method SetMaxNoOfSubPaths() changes the number of sub-paths the affected
267  path can maximally manage to the specified value aMaxNoOfSubPaths. After
268  modifying its size the affected path is empty. This means all contents of
269  previously existing sub-paths are discarded. Before new path data can be
270  stored in a sub-path the method @InitSubPath() should be called. Please note,
271  if the size of the path does already correspond to the parameter
272  aMaxNoOfSubPaths, the path remains unaffected and retains all existing
273  contents. The method returns 'true' if the path could be initialized with the
274  new size. In case, there is no sufficient memory to store the desired number
275  of sub-paths, the method fails and returns 'false' leaving the path empty. */
276 XBool GraphicsPath_SetMaxNoOfSubPaths(GraphicsPath _this,
277  XInt32 aMaxNoOfSubPaths);
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #endif /* _GraphicsPath_H */
284 
285 /* Embedded Wizard */
GraphicsPath_Begin
void GraphicsPath_Begin(GraphicsPath _this, XInt32 aSubPathNo, XFloat aX, XFloat aY)
Definition: Graphics.c:1283
ewrte.h
GraphicsPath_InitSubPath
XBool GraphicsPath_InitSubPath(GraphicsPath _this, XInt32 aSubPathNo, XInt32 aMaxNoOfEdges)
Definition: Graphics.c:1309
XHandle
unsigned long XHandle
Definition: ewrte.h:291
GraphicsPath_SetMaxNoOfSubPaths
XBool GraphicsPath_SetMaxNoOfSubPaths(GraphicsPath _this, XInt32 aMaxNoOfSubPaths)
Definition: Graphics.c:1351
EW_END_OF_FIELDS
#define EW_END_OF_FIELDS(aClass)
Definition: ewrte.h:460
EW_DECLARE_CLASS
#define EW_DECLARE_CLASS(aClass)
Definition: ewrte.h:393
EW_VARIABLE
#define EW_VARIABLE(aName, aType)
Definition: ewrte.h:464
ewgfx.h
_obj_XObject
Definition: ewrte.h:281
GraphicsPath_Close
void GraphicsPath_Close(GraphicsPath _this, XInt32 aSubPathNo)
Definition: Graphics.c:1259
XInt32
signed long XInt32
Definition: ewrte.h:1586
XBool
char XBool
Definition: ewrte.h:1592
EW_DEFINE_METHODS
#define EW_DEFINE_METHODS(aClass, aSuperClass)
Definition: ewrte.h:524
GraphicsPath_GetMaxNoOfSubPaths
XInt32 GraphicsPath_GetMaxNoOfSubPaths(GraphicsPath _this)
Definition: Graphics.c:1327
XFloat
float XFloat
Definition: ewrte.h:1595
sender
XRect CoreOutline aOutline XObject sender
Definition: _ApplicationRadioInterface.h:186
GraphicsPath_onUpdate
void GraphicsPath_onUpdate(GraphicsPath _this, XObject sender)
Definition: Graphics.c:1089
GraphicsPath_AddBezier3
XInt32 GraphicsPath_AddBezier3(GraphicsPath _this, XInt32 aSubPathNo, XFloat aCP1X, XFloat aCP1Y, XFloat aCP2X, XFloat aCP2Y, XFloat aX, XFloat aY, XInt32 aNoOfEdges)
Definition: Graphics.c:1195
GraphicsPath_Done
void GraphicsPath_Done(GraphicsPath _this)
Definition: Graphics.c:1098
EW_END_OF_METHODS
#define EW_END_OF_METHODS(aClass)
Definition: ewrte.h:539
GraphicsPath_AddArc
XInt32 GraphicsPath_AddArc(GraphicsPath _this, XInt32 aSubPathNo, XFloat aCenterX, XFloat aCenterY, XFloat aRadiusX, XFloat aRadiusY, XFloat aStartAngle, XFloat aEndAngle, XInt32 aNoOfEdges)
Definition: Graphics.c:1147
GraphicsPath_AddLine
XInt32 GraphicsPath_AddLine(GraphicsPath _this, XInt32 aSubPathNo, XFloat aX, XFloat aY)
Definition: Graphics.c:1235
EW_DEFINE_FIELDS
#define EW_DEFINE_FIELDS(aClass, aSuperClass)
Definition: ewrte.h:451