-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcinterplot.h
168 lines (142 loc) · 5.14 KB
/
cinterplot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef _CINTERPLOT_H_
#define _CINTERPLOT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdatomic.h>
#include <SDL2/SDL.h>
#include "stream_buffer.h"
#define INITIAL_VARIABLE_LENGTH 16384
#define MAX_VARIABLE_LENGTH 16777216
#define MAX_NUM_ATTACHED_GRAPHS 4096
#define MAX_NUM_VERTICES 16
#define CINTERPLOT_INIT_WIDTH 1100
#define CINTERPLOT_INIT_HEIGHT 600
#define CINTERPLOT_TITLE "Cinterplot"
#define MAKE_COLOR(r,g,b) ((uint32_t) (((int)(r) << 16) | ((int)(g) << 8) | (int)(b)))
typedef struct CipColorScheme
{
uint32_t nLevels;
uint32_t *colors;
} CipColorScheme;
typedef struct CipGraph
{
StreamBuffer *sb;
uint32_t len;
atomic_flag readAccess;
atomic_flag insertAccess;
} CipGraph;
typedef struct CipArea
{
double x0;
double y0;
double x1;
double y1;
} CipArea;
typedef struct CipPosition
{
double x;
double y;
} CipPosition;
typedef struct CipHistogram
{
CipArea dataRange;
uint32_t w;
uint32_t h;
int *bins;
double (*xyzSums)[3];
} CipHistogram;
typedef uint64_t (*HistogramFun) (CipHistogram *hist, CipGraph *graph, uint32_t logMode, char plotType);
typedef struct GraphAttacher
{
CipGraph *graph;
CipColorScheme *colorScheme;
CipHistogram hist;
uint64_t lastGraphCounter;
char plotType;
char lastPlotType;
HistogramFun histogramFun;
} GraphAttacher;
typedef struct CipSubWindow
{
char *title;
GraphAttacher **attachedGraphs;
uint32_t maxNumAttachedGraphs;
uint32_t numAttachedGraphs;
uint32_t continuousScroll : 1;
uint32_t logMode : 2;
uint32_t gridMode : 2;
uint32_t selectedGraph;
CipPosition mouseDataPos;
CipArea dataRange;
CipArea defaultDataRange;
CipArea windowArea;
CipArea selectedWindowArea0;
CipArea selectedWindowArea1;
double rotMatrix[3][3];
} CipSubWindow;
#define KMOD_NONE 0
#define KMOD_SHIFT 1
#define KMOD_GUI 2
#define KMOD_ALT 4
#define KMOD_CTRL 8
typedef struct CipMouse
{
int x;
int y;
int lastX;
int lastY;
int pressX;
int pressY;
int releaseX;
int releaseY;
int clicks;
int button;
} CipMouse;
typedef struct CipState CipState;
int cip_autoscale (CipState *cs, uint32_t windowIndex);
int cip_autoscale_sw (CipSubWindow *sw);
int cip_set_crosshair_enabled (CipState *cs, uint32_t enabled);
void cip_update_color_scheme (CipState *cs, GraphAttacher *attacher, char *spec, uint32_t nLevels);
int cip_set_fullscreen (CipState *cs, uint32_t fullscreen);
int cip_zoom (CipSubWindow *sw, double xf, double yf);
int cip_move (CipSubWindow *sw, double xf, double yf);
int cip_set_tracking_mode (CipState *cs, uint32_t mode);
int cip_make_sub_windows (CipState *cs, uint32_t nRows, uint32_t nCols, uint32_t bordered, uint32_t margin);
void cip_set_range (CipSubWindow *sw, double xmin, double ymin, double xmax, double ymax, int setAsDefault);
void cip_set_x_range (CipState *cs, uint32_t windowIndex, double xmin, double xmax, int setAsDefault);
void cip_set_y_range (CipState *cs, uint32_t windowIndex, double ymin, double ymax, int setAsDefault);
int cip_set_grid_mode (CipState *cs, uint32_t windowIndex, uint32_t mode);
int cip_set_grid_mode_sw (CipSubWindow *sw, uint32_t mode);
int cip_set_log_mode_sw (CipSubWindow *sw, uint32_t mode);
int cip_set_log_mode (CipState *cs, uint32_t windowIndex, uint32_t mode);
int cip_set_statusline_enabled (CipState *cs, uint32_t enabled);
void cip_histogram_line (CipHistogram *hist, int x0, int y0, int x1, int y1);
void cip_recursive_free_sub_windows (CipState *cs);
void cip_remove_attached_graphs (CipState *cs, uint32_t wi);
int cip_force_refresh (CipState *cs);
CipGraph *cip_graph_new (int dim, uint32_t len);
void cip_graph_delete (CipGraph *graph);
void cip_graph_add_2d_point (CipGraph *graph, double x, double y);
void cip_graph_add_3d_point (CipGraph *graph, double x, double y, double z);
GraphAttacher *cip_graph_attach (CipState *cs, CipGraph *graph, uint32_t windowIndex, HistogramFun histogramFun, char plotType, char *colorSpec, uint32_t numColors);
int cip_graph_detach (CipState *cs, CipGraph *graph, uint32_t windowIndex);
void cip_graph_remove_points (CipGraph *graph);
int cip_is_running (CipState *cs);
int cip_quit (CipState *cs);
void cip_redraw_async (CipState *cs);
void cip_continuous_scroll_enable (CipState *cs, uint32_t windowIndex);
void cip_continuous_scroll_disable (CipState *cs, uint32_t windowIndex);
CipSubWindow *cip_get_sub_window (CipState *cs, uint32_t windowIndex);
void cip_set_bg_shade (CipState *cs, float bgShade);
void cip_set_sub_window_title (CipState *cs, uint32_t windowIndex, char *title);
int cip_toggle_paused (CipState *cs);
void cip_save_png (CipState* cs, char* imageDir, int frameCounter, int format);
void cip_set_app_keyboard_callback (CipState *cs, int (*app_on_keyboard) (CipState *cs, int key, int mod, int pressed, int repeat));
void cip_set_app_mouse_motion (CipState *cs, int (*app_on_mouse_motion) (CipState *cs, int windowIndex, double x, double y));
//void wait_for_access (atomic_flag* accessFlag);
//void release_access (atomic_flag* accessFlag);
#ifdef __cplusplus
} /* end extern C */
#endif
#endif /* _CINTERPLOT_H_ */