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;
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:
51  Window();
52 
59  Window(const char* const title);
60 
69  Window(const int width, const int height, const char* const title="ArrayFire");
70 
78  Window(const af_window wnd);
82  ~Window();
83 
84  // FIXME handle copying properly
85 
89  af_window get() const { return wnd; }
90 
97  void setPos(const unsigned x, const unsigned y);
98 
104  void setTitle(const char* const title);
105 
106 #if AF_API_VERSION >= 31
107 
113  void setSize(const unsigned w, const unsigned h);
114 #endif
115 
121  void setColorMap(const ColorMap cmap);
122 
131  void image(const array& in, const char* title=NULL);
132 
142  void plot(const array& X, const array& Y, const char* const title=NULL);
143 
154  void hist(const array& X, const double minval, const double maxval, const char* const title=NULL);
155 
162  void grid(const int rows, const int cols);
163 
168  void show();
169 
177  bool close();
178 
189  inline Window& operator()(const int r, const int c) {
190  _r = r; _c = c;
191  return *this;
192  }
193 };
194 
195 }
196 #endif
197 
198 #ifdef __cplusplus
199 extern "C" {
200 #endif
201 
215 AFAPI af_err af_create_window(af_window *out, const int width, const int height, const char* const title);
216 
229 AFAPI af_err af_set_position(const af_window wind, const unsigned x, const unsigned y);
230 
242 AFAPI af_err af_set_title(const af_window wind, const char* const title);
243 
244 #if AF_API_VERSION >= 31
245 
257 AFAPI af_err af_set_size(const af_window wind, const unsigned w, const unsigned h);
258 #endif
259 
275 AFAPI af_err af_draw_image(const af_window wind, const af_array in, const af_cell* const props);
276 
293 AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array Y, const af_cell* const props);
294 
312 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);
313 
326 AFAPI af_err af_grid(const af_window wind, const int rows, const int cols);
327 
338 AFAPI af_err af_show(const af_window wind);
339 
352 AFAPI af_err af_is_window_closed(bool *out, const af_window wind);
353 
365 
366 #ifdef __cplusplus
367 }
368 
369 #endif
int col
Definition: graphics.h:19
Definition: algorithm.h:14
af_colormap cmap
Definition: graphics.h:21
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.
AFAPI af_err af_destroy_window(const af_window wind)
C Interface wrapper for destroying a window handle.
Window object to render af::arrays.
Definition: graphics.h:35
AFAPI af_err af_set_title(const af_window wind, const char *const title)
C Interface wrapper for setting window title.
const char * title
Definition: graphics.h:20
AFAPI af_err af_is_window_closed(bool *out, const af_window wind)
C Interface wrapper for checking if window is marked for close.
AFAPI af_err af_show(const af_window wind)
C Interface wrapper for showing a window.
A multi dimensional data container.
Definition: array.h:27
af_colormap
Definition: defines.h:293
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.
Definition: graphics.h:17
af_err
Definition: defines.h:67
#define AFAPI
Definition: defines.h:31
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.
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.
AFAPI af_err af_grid(const af_window wind, const int rows, const int cols)
C Interface wrapper for grid setup in a window.
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.
AFAPI af_err af_set_size(const af_window wind, const unsigned w, const unsigned h)
C Interface wrapper for setting window position.
void * af_array
Definition: defines.h:187
int row
Definition: graphics.h:18
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:189
unsigned long long af_window
Definition: graphics.h:15