eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_graph.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #ifndef __D4D_GRAPH_H
47 #define __D4D_GRAPH_H
48 
50 
51 /******************************************************************************
52 * D4D GRAPH setting constants
53 *
54 */
60 #ifndef D4D_GRAPH_BORDER_OFF
61  #define D4D_GRAPH_BORDER_OFF 5
62 #endif
63 
66 #ifndef D4D_GRAPH_VALUE_OFF
67  #define D4D_GRAPH_VALUE_OFF 2
68 #endif
69 
72 #ifndef D4D_COLOR_GRAPH_GRID
73  #define D4D_COLOR_GRAPH_GRID D4D_COLOR_LIGHT_GREY
74 #endif
75 
76 //********************* Graph flags for its specific flags *****************
87  //@note For axis, only one setting can be used, it is not allowed to mix two flags for one axis.
88 
89  #define D4D_GRAPH_F_MODE_MASK (0x03 << D4D_OBJECT_F_OBJECT_SHIFT)
90  #define D4D_GRAPH_F_MODE_NORMAL (0x00 << D4D_OBJECT_F_OBJECT_SHIFT)
91  #define D4D_GRAPH_F_MODE_ROLLOVER (0x01 << D4D_OBJECT_F_OBJECT_SHIFT)
92 
93  #define D4D_GRAPH_F_VALUE_X_NONE (0x00 << D4D_OBJECT_F_OBJECT_SHIFT)
94  #define D4D_GRAPH_F_VALUE_X_BOTT (0x04 << D4D_OBJECT_F_OBJECT_SHIFT)
95  #define D4D_GRAPH_F_VALUE_X_TOP (0x08 << D4D_OBJECT_F_OBJECT_SHIFT)
96 
97  #define D4D_GRAPH_F_VALUE_Y_NONE (0x00 << D4D_OBJECT_F_OBJECT_SHIFT)
98  #define D4D_GRAPH_F_VALUE_Y_LEFT (0x10 << D4D_OBJECT_F_OBJECT_SHIFT)
99  #define D4D_GRAPH_F_VALUE_Y_RIGHT (0x20 << D4D_OBJECT_F_OBJECT_SHIFT)
100 
104 #ifndef D4D_GRAPH_F_DEFAULT
105  #define D4D_GRAPH_F_DEFAULT (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_BEVEL_RAISED | D4D_GRAPH_F_MODE_ROLLOVER | D4D_GRAPH_F_VALUE_X_BOTT | D4D_GRAPH_F_VALUE_Y_RIGHT )
106 #endif
107 
110 #ifndef D4D_GRAPH_TXT_PRTY_DEFAULT
111  #define D4D_GRAPH_TXT_PRTY_DEFAULT (D4D_ALIGN_H_CENTER_MASK | D4D_ALIGN_V_CENTER_MASK)
112 #endif
113 
116 #ifndef D4D_GRAPH_FNT_PRTY_DEFAULT
117  #define D4D_GRAPH_FNT_PRTY_DEFAULT ( 0 )
118 #endif
119 
122 #ifndef D4D_GRAPH_LBL_FNT_PRTY_DEFAULT
123  #define D4D_GRAPH_LBL_FNT_PRTY_DEFAULT ( 0 )
124 #endif
125 
126 //********************* Graph traces types *****************
137  #define D4D_GRAPH_TRACE_TYPE_MASK 0x03
138  #define D4D_GRAPH_TRACE_TYPE_LINE 0x00
139  #define D4D_GRAPH_TRACE_TYPE_DOT 0x01
140  #define D4D_GRAPH_TRACE_TYPE_AREA 0x02
141  #define D4D_GRAPH_TRACE_TYPE_AREA_INV 0x03
142 
146 /******************************************************************************
147 * D4D GRAPH setting public types
148 *
149 */
154 typedef Byte D4D_GRAPH_VALUE;
155 
157 
158 /**************************************************************************/
165 typedef void (*D4D_GRAPH_ON_CHANGE)(D4D_OBJECT* pThis);
166 
167 /**************************************************************************/
176 typedef D4D_TCHAR* (*D4D_GRAPH_ON_NEED_LABEL)(D4D_OBJECT_PTR pThis, D4D_BOOL axisX, D4D_INDEX gridIx, D4D_GRAPH_SAMPLE_IX sampleIx);
177 
178 
181 /******************************************************************************
182 * Private Types
183 ******************************************************************************/
184 
185 
187 
188 
189 typedef struct
190 {
196 
197 typedef struct
198 {
199  D4D_GRAPH_SAMPLE_IX xPosCnt; // position counter on X axis
200  D4D_GRAPH_DATA_LEN lastShowPos; // position in input data buffer of shown data
201  D4D_GRAPH_DATA_LEN lastDataPos; // position in input data buffer of last added data
203  D4D_GRAPH_DATA_LEN dataShowX; // count of showed data on axis X
208 
209 typedef struct
210 {
214 
215 // GRAPH configuration (in ROM by default)
216 
217 typedef struct
218 {
219  D4D_STRING textBuff; // GRAPH main text
220  D4D_GRAPH_GRID grid; // graph grid information
227 } D4D_GRAPH;
228 
229 /******************************************************************************
230 * Macros
231 ******************************************************************************/
232 
233 // getting the GRAPH structure from general OBJECT
234 #define D4D_GET_GRAPH(pObj) ((D4D_GRAPH*)((pObj)->pParam))
235 
236 /******************************************************************************
237 * D4D GRAPH setting public macros
238 *
239 */
243 /**************************************************************************/
271 #define _D4D_DECLARE_GRAPH_BEGIN(type, name, text, x, y, cx, cy, radius, pMargin, pRelations, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg) \
272  extern type D4D_GRAPH_TRACE name##_traces[];\
273  static D4D_GRAPH_DATA name##_data = { 0, 0, 0, 0, 0, 0, 0, 0}; /* reset data of graph*/ \
274  static D4D_STR_PROPERTIES name##_strPrties = { D4D_GRAPH_FNT_PRTY_DEFAULT, D4D_GRAPH_TXT_PRTY_DEFAULT}; \
275  static type D4D_GRAPH name##_params = \
276  { \
277  { text, D4D_TEXT_LEN(text), fontId, &name##_strPrties, D4D_OBJECT_MAX_TEXT_LEN(text), 0}, /* textBuff */ \
278  { gx, gy }, /* grid info */ \
279  &(name##_traces[0]), /* pLines */ \
280  dataLen, /* Length of input data buffers */ \
281  lblFontId, /* Font ID for axis values */ \
282  pOnNeedLblTxt, /* On need the label text*/ \
283  pOnValch, /* OnValueCanged */ \
284  &(name##_data) /* RAM-based data */ \
285  }; \
286  \
287  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, pRelations, pOnUsrMsg, &d4d_graphSysFunc, &(name##_params), (flags), pUser, pScheme)\
288  \
289  type D4D_GRAPH_TRACE name##_traces[] = \
290  {
291 
292 
293 /**************************************************************************/
310 #define D4D_DECLARE_GRAPH_TRACE(pData, clr, line, type) { pData, clr , line, type},
311 
312 /**************************************************************************/
325 #define D4D_DECLARE_GRAPH_END() { NULL, D4D_COLOR_WHITE , D4D_LINE_THIN, 0}};
326 
327 
328 /**************************************************************************/
353 #define D4D_DECLARE_GRAPH_BEGIN(name, text, x, y, cx, cy, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg) \
354  _D4D_DECLARE_GRAPH_BEGIN(D4D_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg)
355 
356 /**************************************************************************/
375 #define D4D_DECLARE_STD_GRAPH_BEGIN(name, text, x, y, cx, cy, gx, gy, dataLen, fontId, lblFontId) \
376  D4D_DECLARE_GRAPH_BEGIN(name, text, x, y, cx, cy, gx, gy, dataLen, (D4D_GRAPH_F_DEFAULT), NULL, fontId, lblFontId, NULL, NULL, NULL, NULL)
377 
378 // Rounded graph definition
379 /**************************************************************************/
405 #define D4D_DECLARE_RGRAPH_BEGIN(name, text, x, y, cx, cy, radius, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg) \
406  _D4D_DECLARE_GRAPH_BEGIN(D4D_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg)
407 
408 /**************************************************************************/
428 #define D4D_DECLARE_STD_RGRAPH_BEGIN(name, text, x, y, cx, cy, radius, gx, gy, dataLen, fontId, lblFontId) \
429  D4D_DECLARE_RGRAPH_BEGIN(name, text, x, y, cx, cy, radius, gx, gy, dataLen, (D4D_GRAPH_F_DEFAULT), NULL, fontId, lblFontId, NULL, NULL, NULL, NULL)
430 
431 
432 // IN RAM instantions macros
433 /**************************************************************************/
436 #define D4D_DECLARE_GRAPH_BEGIN_INRAM(name, text, x, y, cx, cy, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg) \
437  _D4D_DECLARE_GRAPH_BEGIN(D4D_NO_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg)
438 
439 /**************************************************************************/
442 #define D4D_DECLARE_STD_GRAPH_BEGIN_INRAM(name, text, x, y, cx, cy, gx, gy, dataLen, fontId, lblFontId) \
443  D4D_DECLARE_STD_GRAPH_BEGIN_INRAM(name, text, x, y, cx, cy, gx, gy, dataLen, (D4D_GRAPH_F_DEFAULT), NULL, fontId, lblFontId, NULL, NULL, NULL, NULL)
444 
445 
446 // Rounded graph definition
447 /**************************************************************************/
450 #define D4D_DECLARE_RGRAPH_BEGIN_INRAM(name, text, x, y, cx, cy, radius, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg) \
451  _D4D_DECLARE_GRAPH_BEGIN(D4D_NO_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, gx, gy, dataLen, flags, pScheme, fontId, lblFontId, pOnNeedLblTxt, pUser, pOnValch, pOnUsrMsg)
452 
453 /**************************************************************************/
456 #define D4D_DECLARE_STD_RGRAPH_BEGIN_INRAM(name, text, x, y, cx, cy, radius, gx, gy, dataLen, fontId, lblFontId) \
457  D4D_DECLARE_RGRAPH_BEGIN_INRAM(name, text, x, y, cx, cy, radius, gx, gy, dataLen, (D4D_GRAPH_F_DEFAULT), NULL, fontId, lblFontId, NULL, NULL, NULL, NULL)
458 
460 /******************************************************************************
461 * Global variables
462 ******************************************************************************/
463 
464 /******************************************************************************
465 * Global functions
466 ******************************************************************************/
467 
468 /*********************************************************
469 *
470 * global functions
471 *
472 *********************************************************/
480 
481 
482 // Obsolete functions, replaced by any general
483 #define D4D_GraphSetText D4D_SetText
484 
485 
486 
487 
488 #endif /* __D4D_GRAPH_H */
489 
490 
D4D_LINETYPE
Type definition of eGUI line type.
Definition: d4d_types.h:291
D4D_WCHAR D4D_TCHAR
Type definition of eGUI character (it depends on UNICODE setting if this is D4D_CHAR or D4D_WCHAR)...
Definition: d4d_types.h:284
Byte D4D_FONT
Definition: d4d_font.h:171
D4D_COOR lblSizeY
Definition: d4d_graph.h:204
D4D_COLOR color
Definition: d4d_graph.h:192
D4D_BOOL D4D_GraphSetScaleX(D4D_OBJECT_PTR pObj, Byte mul, Byte div)
Function sets the new scale of axis X of the graph.
Definition: d4d_graph.c:738
D4D_BOOL D4D_GraphAddTraceData(D4D_OBJECT_PTR pObj, D4D_INDEX trace_ix, D4D_GRAPH_VALUE value)
The function add new data to one trace.
Definition: d4d_graph.c:592
D4D_STRING textBuff
Definition: d4d_graph.h:219
D4D_GRAPH_DATA * pData
Definition: d4d_graph.h:226
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
D4D_GRAPH_VALUE * pData
Definition: d4d_graph.h:191
D4D_INDEX y_cnt
Definition: d4d_graph.h:212
D4D_COOR D4D_GraphGetSizeX(D4D_OBJECT_PTR pObj)
The function returns the size of graph traces in axis X.
Definition: d4d_graph.c:722
Word D4D_GRAPH_DATA_LEN
Definition: d4d_graph.h:186
D4D_INDEX drigDrawedX
Definition: d4d_graph.h:206
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
void(* D4D_GRAPH_ON_CHANGE)(D4D_OBJECT *pThis)
Type definition of graph on change callback function.
Definition: d4d_graph.h:165
D4D_LINETYPE line
Definition: d4d_graph.h:193
D4D_GRAPH_DATA_LEN lastShowPos
Definition: d4d_graph.h:200
D4D_GRAPH_SAMPLE_IX xPosCnt
Definition: d4d_graph.h:199
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
D4D_BOOL D4D_GraphSetDataWidth(D4D_OBJECT_PTR pObj, D4D_INDEX samples)
Function sets the new scale of the axis X of the graph.
Definition: d4d_graph.c:764
const D4D_OBJECT_SYS_FUNCTION d4d_graphSysFunc
Definition: d4d_graph.c:53
D4D_GRAPH_DATA_LEN lastDataPos
Definition: d4d_graph.h:201
D4D_GRAPH_ON_CHANGE OnValueChanged
Definition: d4d_graph.h:225
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
Byte D4D_GRAPH_VALUE
Type definition of graph value type - this is standard type used for graph data input.
Definition: d4d_graph.h:154
D4D_GRAPH_DATA_LEN dataShowX
Definition: d4d_graph.h:203
LWord D4D_INDEX
Type definition of eGUI general index variables.
Definition: d4d_types.h:206
The object main structure type definition.
Definition: d4d_object.h:167
D4D_GRAPH_DATA_LEN dataLenght
Definition: d4d_graph.h:222
LWord D4D_GRAPH_SAMPLE_IX
Type definition of graph dat asample type.
Definition: d4d_graph.h:156
D4D_TCHAR *(* D4D_GRAPH_ON_NEED_LABEL)(D4D_OBJECT_PTR pThis, D4D_BOOL axisX, D4D_INDEX gridIx, D4D_GRAPH_SAMPLE_IX sampleIx)
Type definition of graph on need label call back function.
Definition: d4d_graph.h:176
D4D_GRAPH_GRID grid
Definition: d4d_graph.h:220
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
D4D_FONT labelFont
Definition: d4d_graph.h:223
D4D_GRAPH_DATA_LEN initData
Definition: d4d_graph.h:202
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
D4D_GRAPH_ON_NEED_LABEL OnNeedLabelText
Definition: d4d_graph.h:224
void D4D_GraphAddTracesData(D4D_OBJECT_PTR pObj, D4D_GRAPH_VALUE *pValues)
The function add new data to all traces.
Definition: d4d_graph.c:655
const D4D_GRAPH_TRACE * traces
Definition: d4d_graph.h:221
D4D_INDEX x_cnt
Definition: d4d_graph.h:211
void D4D_GraphClearAll(D4D_OBJECT_PTR pObj)
The function clears all internal data of graph object.
Definition: d4d_graph.c:694
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
D4D_COOR columnDrawed
Definition: d4d_graph.h:205
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
LWord D4D_GraphGetSampleIndex(D4D_OBJECT_PTR pObj)
The function returns the current data sample index.
Definition: d4d_graph.c:711