GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
widgets
gp_widget_graph.h
Go to the documentation of this file.
1
//SPDX-License-Identifier: LGPL-2.0-or-later
2
3
/*
4
5
Copyright (c) 2014-2024 Cyril Hrubis <metan@ucw.cz>
6
7
*/
8
25
#ifndef GP_WIDGET_GRAPH_H
26
#define GP_WIDGET_GRAPH_H
27
28
#include <
utils/gp_cbuffer.h
>
29
#include <
widgets/gp_widget_types.h
>
30
#include <
widgets/gp_widget_size_units.h
>
31
35
enum
gp_widget_graph_style
{
41
GP_WIDGET_GRAPH_POINT
,
47
GP_WIDGET_GRAPH_LINE
,
53
GP_WIDGET_GRAPH_FILL
,
55
GP_WIDGET_GRAPH_STYLE_MAX
,
56
};
57
61
extern
const
char
*
gp_widget_graph_style_names
[
GP_WIDGET_GRAPH_STYLE_MAX
];
62
66
struct
gp_widget_graph_point
{
68
double
x
;
70
double
y
;
71
};
72
73
struct
gp_widget_graph {
74
gp_widget_size
min_w;
75
gp_widget_size
min_h;
76
77
const
char
*x_label;
78
const
char
*y_label;
79
80
long
min_y_fixed:1;
81
long
max_y_fixed:1;
82
83
/* Graph scaling window */
84
double
min_x;
85
double
max_x;
86
double
min_y;
87
double
max_y;
88
89
/* Graph data */
90
enum
gp_widget_graph_style
graph_style;
91
enum
gp_widgets_color
color;
92
gp_cbuffer
data_idx;
93
struct
gp_widget_graph_point
*data;
94
};
95
107
gp_widget
*
gp_widget_graph_new
(
gp_widget_size
min_w,
gp_widget_size
min_h,
108
const
char
*x_label,
const
char
*y_label,
109
size_t
max_data_points);
110
121
void
gp_widget_graph_point_add
(
gp_widget
*self,
double
x
,
double
y
);
122
129
void
gp_widget_graph_style_set
(
gp_widget
*self,
enum
gp_widget_graph_style
style);
130
140
void
gp_widget_graph_yrange_set
(
gp_widget
*self,
double
min_y,
double
max_y);
141
150
void
gp_widget_graph_ymin_set
(
gp_widget
*self,
double
min_y);
151
160
void
gp_widget_graph_ymax_set
(
gp_widget
*self,
double
max_y);
161
169
void
gp_widget_graph_yrange_clear
(
gp_widget
*self);
170
177
void
gp_widget_graph_color_set
(
gp_widget
*self,
enum
gp_widgets_color
color);
178
179
#endif
/* GP_WIDGET_GRAPH_H */
gp_cbuffer.h
Circular buffer indexing and iterators.
gp_widget_graph_style
gp_widget_graph_style
A graph drawing style.
Definition
gp_widget_graph.h:35
GP_WIDGET_GRAPH_LINE
@ GP_WIDGET_GRAPH_LINE
Points connected by line.
Definition
gp_widget_graph.h:47
GP_WIDGET_GRAPH_POINT
@ GP_WIDGET_GRAPH_POINT
Point graph.
Definition
gp_widget_graph.h:41
GP_WIDGET_GRAPH_FILL
@ GP_WIDGET_GRAPH_FILL
Area below graph is filled.
Definition
gp_widget_graph.h:53
GP_WIDGET_GRAPH_STYLE_MAX
@ GP_WIDGET_GRAPH_STYLE_MAX
Maximal number of styles.
Definition
gp_widget_graph.h:55
gp_widget_graph_new
gp_widget * gp_widget_graph_new(gp_widget_size min_w, gp_widget_size min_h, const char *x_label, const char *y_label, size_t max_data_points)
Allocates and initializes a new graph widget.
gp_widget_graph_point_add
void gp_widget_graph_point_add(gp_widget *self, double x, double y)
Adds a graph point.
gp_widget_graph_style_names
const char * gp_widget_graph_style_names[GP_WIDGET_GRAPH_STYLE_MAX]
A graph style names.
gp_widget_graph_style_set
void gp_widget_graph_style_set(gp_widget *self, enum gp_widget_graph_style style)
Sets a graph style.
gp_widget_graph_yrange_clear
void gp_widget_graph_yrange_clear(gp_widget *self)
Clears graph y range.
gp_widget_graph_ymin_set
void gp_widget_graph_ymin_set(gp_widget *self, double min_y)
Sets graph y minimum.
gp_widget_graph_color_set
void gp_widget_graph_color_set(gp_widget *self, enum gp_widgets_color color)
Sets graph color.
gp_widget_graph_yrange_set
void gp_widget_graph_yrange_set(gp_widget *self, double min_y, double max_y)
Sets graph y range.
gp_widget_graph_ymax_set
void gp_widget_graph_ymax_set(gp_widget *self, double max_y)
Sets graph y maximum.
gp_widget_size_units.h
A widget size units.
gp_widget_types.h
Common widget types.
gp_widgets_color
gp_widgets_color
Widget theme colors.
Definition
gp_widgets_color_scheme.h:74
gp_cbuffer
A circular buffer indexes.
Definition
gp_cbuffer.h:19
gp_widget_graph_point
A graph point.
Definition
gp_widget_graph.h:66
gp_widget_graph_point::y
double y
An y value.
Definition
gp_widget_graph.h:70
gp_widget_graph_point::x
double x
An x value.
Definition
gp_widget_graph.h:68
gp_widget_size
A compound size.
Definition
gp_widget_size_units.h:31
gp_widget
A widget base.
Definition
gp_widget.h:28
Generated by
1.9.8