graphics.h Source File

- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

graphics.h
Go to the documentation of this file.
1 /*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10 #pragma once
11
12 #include <af/defines.h>
13 #include <af/array.h>
14
15 typedef unsigned long long af_window;
16
17 typedef struct {
18 int row;
19 int col;
20 const char* title;
21 af_colormap cmap;
22 } af_cell;
23
24 #ifdef __cplusplus
25 namespace af
26 {
27
35 class AFAPI Window {
36 private:
37 af_window wnd;
38 /* below attributes are used to track which
39 * cell in the grid is being rendered currently */
40 int _r;
41 int _c;
42 ColorMap _cmap;
43
44 void initWindow(const int width, const int height, const char* const title);
45
46 public:
53 Window();
54
63 Window(const char* const title);
64
75 Window(const int width, const int height, const char* const title="ArrayFire");
76
86 Window(const af_window wnd);
92 ~Window();
93
94 // FIXME handle copying properly
95
101 af_window get() const { return wnd; }
102
111 void setPos(const unsigned x, const unsigned y);
112
120 void setTitle(const char* const title);
121
122 #if AF_API_VERSION >= 31
123
131 void setSize(const unsigned w, const unsigned h);
132 #endif
133
141 void setColorMap(const ColorMap cmap);
142
153 void image(const array& in, const char* title=NULL);
154
155 #if AF_API_VERSION >= 32
156
166 void plot3(const array& in, const char* title=NULL);
167 #endif
168
181 void plot(const array& X, const array& Y, const char* const title=NULL);
182
195 void hist(const array& X, const double minval, const double maxval, const char* const title=NULL);
196
197 #if AF_API_VERSION >= 32
198
208 void surface(const array& S, const char* const title);
209 #endif
210
211 #if AF_API_VERSION >= 32
212
224 void surface(const array& xVals, const array& yVals, const array& S, const char* const title);
225 #endif
226
235 void grid(const int rows, const int cols);
236
243 void show();
244
254 bool close();
255
268 inline Window& operator()(const int r, const int c) {
269 _r = r; _c = c;
270 return *this;
271 }
272 };
273
274 }
275 #endif
276
277 #ifdef __cplusplus
278 extern "C" {
279 #endif
280
294 AFAPI af_err af_create_window(af_window *out, const int width, const int height, const char* const title);
295
308 AFAPI af_err af_set_position(const af_window wind, const unsigned x, const unsigned y);
309
321 AFAPI af_err af_set_title(const af_window wind, const char* const title);
322
323 #if AF_API_VERSION >= 31
324
336 AFAPI af_err af_set_size(const af_window wind, const unsigned w, const unsigned h);
337 #endif
338
354 AFAPI af_err af_draw_image(const af_window wind, const af_array in, const af_cell* const props);
355
372 AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array Y, const af_cell* const props);
373
374 #if AF_API_VERSION >= 32
375
390 AFAPI af_err af_draw_plot3(const af_window wind, const af_array P, const af_cell* const props);
391 #endif
392
410 AFAPI af_err af_draw_hist(const af_window wind, const af_array X, const double minval, const double maxval, const af_cell* const props);
411
412 #if AF_API_VERSION >= 32
413
430 af_err af_draw_surface(const af_window wind, const af_array xVals, const af_array yVals, const af_array S, const af_cell* const props);
431 #endif
432
445 AFAPI af_err af_grid(const af_window wind, const int rows, const int cols);
446
457 AFAPI af_err af_show(const af_window wind);
458
471 AFAPI af_err af_is_window_closed(bool *out, const af_window wind);
472
483 AFAPI af_err af_destroy_window(const af_window wind);
484
485 #ifdef __cplusplus
486 }
487
488 #endif
af_cell::col
int col
Definition: graphics.h:19
af
Definition: algorithm.h:14
af_cell::cmap
af_colormap cmap
Definition: graphics.h:21
af_draw_hist
AFAPI af_err af_draw_hist(const af_window wind, const af_array X, const double minval, const double maxval, const af_cell *const props)
C Interface wrapper for drawing an array as a histogram.
array.h
af_destroy_window
AFAPI af_err af_destroy_window(const af_window wind)
C Interface wrapper for destroying a window handle.
af::Window
Window object to render af::arrays.
Definition: graphics.h:35
af_set_title
AFAPI af_err af_set_title(const af_window wind, const char *const title)
C Interface wrapper for setting window title.
af_cell::title
const char * title
Definition: graphics.h:20
af_is_window_closed
AFAPI af_err af_is_window_closed(bool *out, const af_window wind)
C Interface wrapper for checking if window is marked for close.
af_show
AFAPI af_err af_show(const af_window wind)
C Interface wrapper for showing a window.
af::array
A multi dimensional data container.
Definition: array.h:27
af_colormap
af_colormap
Definition: defines.h:329
af_draw_plot3
AFAPI af_err af_draw_plot3(const af_window wind, const af_array P, const af_cell *const props)
C Interface wrapper for drawing an array as a plot.
af_create_window
AFAPI af_err af_create_window(af_window *out, const int width, const int height, const char *const title)
C Interface wrapper for creating a window.
af_cell
Definition: graphics.h:17
af_err
af_err
Definition: defines.h:67
defines.h
AFAPI
#define AFAPI
Definition: defines.h:31
af_draw_plot
AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array Y, const af_cell *const props)
C Interface wrapper for drawing an array as a plot.
af_set_position
AFAPI af_err af_set_position(const af_window wind, const unsigned x, const unsigned y)
C Interface wrapper for setting the start position when window is displayed.
af_grid
AFAPI af_err af_grid(const af_window wind, const int rows, const int cols)
C Interface wrapper for grid setup in a window.
af_draw_image
AFAPI af_err af_draw_image(const af_window wind, const af_array in, const af_cell *const props)
C Interface wrapper for drawing an array as an image.
af_set_size
AFAPI af_err af_set_size(const af_window wind, const unsigned w, const unsigned h)
C Interface wrapper for setting window position.
af_draw_surface
af_err af_draw_surface(const af_window wind, const af_array xVals, const af_array yVals, const af_array S, const af_cell *const props)
C Interface wrapper for drawing arrayis as a surface.
af_array
void * af_array
Definition: defines.h:219
af_cell::row
int row
Definition: graphics.h:18
af::Window::operator()
Window & operator()(const int r, const int c)
This function is used to keep track of which cell in the grid mode is being currently rendered...
Definition: graphics.h:268
af_window
unsigned long long af_window
Definition: graphics.h:15