My Project
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
15typedef unsigned long long af_window;
16
17typedef struct {
18 int row;
19 int col;
20 const char* title;
22} af_cell;
23
24#ifdef __cplusplus
25namespace af
26{
27
38 private:
39 af_window wnd;
40 /* below attributes are used to track which
41 * cell in the grid is being rendered currently */
42 int _r;
43 int _c;
44 ColorMap _cmap;
45
46 void initWindow(const int width, const int height, const char* const title);
47
48 Window(const Window&); // Prevent copy-construction
49 Window& operator=(const Window&); // Prevent assignment
50
51 public:
59
68 Window(const char* const title);
69
80 Window(const int width, const int height, const char* const title="ArrayFire");
81
91 Window(const af_window wnd);
92
99
100 // FIXME handle copying properly
101
107 af_window get() const { return wnd; }
108
117 void setPos(const unsigned x, const unsigned y);
118
126 void setTitle(const char* const title);
127
128#if AF_API_VERSION >= 31
137 void setSize(const unsigned w, const unsigned h);
138#endif
139
147 void setColorMap(const ColorMap cmap);
148
159 void image(const array& in, const char* title=NULL);
160
161#if AF_API_VERSION >= 32
172 void plot3(const array& in, const char* title=NULL);
173#endif
174
186 void plot(const array& X, const array& Y, const char* const title=NULL);
187
188#if AF_API_VERSION >= 33
201 void scatter(const array& X, const array& Y,
202 const af::markerType marker = AF_MARKER_POINT, const char* const title = NULL);
203#endif
204
205#if AF_API_VERSION >= 33
215 void scatter3(const array& P, const af::markerType marker = AF_MARKER_POINT,
216 const char* const title = NULL);
217#endif
218
231 void hist(const array& X, const double minval, const double maxval, const char* const title=NULL);
232
233#if AF_API_VERSION >= 32
244 void surface(const array& S, const char* const title = NULL);
245#endif
246
247#if AF_API_VERSION >= 32
260 void surface(const array& xVals, const array& yVals, const array& S, const char* const title = NULL);
261#endif
262
271 void grid(const int rows, const int cols);
272
279 void show();
280
290 bool close();
291
292#if AF_API_VERSION >= 33
300 void setVisibility(const bool isVisible);
301#endif
302
315 inline Window& operator()(const int r, const int c) {
316 _r = r; _c = c;
317 return *this;
318 }
319};
320
321}
322#endif
323
324#ifdef __cplusplus
325extern "C" {
326#endif
327
341AFAPI af_err af_create_window(af_window *out, const int width, const int height, const char* const title);
342
355AFAPI af_err af_set_position(const af_window wind, const unsigned x, const unsigned y);
356
368AFAPI af_err af_set_title(const af_window wind, const char* const title);
369
370#if AF_API_VERSION >= 31
383AFAPI af_err af_set_size(const af_window wind, const unsigned w, const unsigned h);
384#endif
385
401AFAPI af_err af_draw_image(const af_window wind, const af_array in, const af_cell* const props);
402
419AFAPI af_err af_draw_plot(const af_window wind, const af_array X, const af_array Y, const af_cell* const props);
420
421#if AF_API_VERSION >= 33
440 const af_marker_type marker, const af_cell* const props);
441#endif
442
443#if AF_API_VERSION >= 33
459 const af_marker_type marker, const af_cell* const props);
460#endif
461
462#if AF_API_VERSION >= 32
478AFAPI af_err af_draw_plot3(const af_window wind, const af_array P, const af_cell* const props);
479#endif
480
498AFAPI af_err af_draw_hist(const af_window wind, const af_array X, const double minval, const double maxval, const af_cell* const props);
499
500#if AF_API_VERSION >= 32
518AFAPI 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);
519#endif
520
533AFAPI af_err af_grid(const af_window wind, const int rows, const int cols);
534
546
560
561#if AF_API_VERSION >= 33
570AFAPI af_err af_set_visibility(const af_window wind, const bool is_visible);
571#endif
572
584
585#ifdef __cplusplus
586}
587
588#endif
Window object to render af::arrays.
Definition graphics.h:37
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:315
A multi dimensional data container.
Definition array.h:27
af_colormap
Definition defines.h:332
af_err
Definition defines.h:63
void * af_array
Definition defines.h:222
#define AFAPI
Definition defines.h:31
af_marker_type
Definition defines.h:385
@ AF_MARKER_POINT
Definition defines.h:387
unsigned long long af_window
Definition graphics.h:15
void surface(const array &S, const char *const title=NULL)
Renders the input arrays as a 3D surface plot to the window.
void surface(const array &xVals, const array &yVals, const array &S, const char *const title=NULL)
Renders the input arrays as a 3D surface plot to the window.
AFAPI af_err af_draw_scatter(const af_window wind, const af_array X, const af_array Y, const af_marker_type marker, const af_cell *const props)
C Interface wrapper for drawing an array as a plot.
void scatter3(const array &P, const af::markerType marker=AF_MARKER_POINT, const char *const title=NULL)
Renders the input arrays as a 3D scatter-plot to the 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.
void scatter(const array &X, const array &Y, const af::markerType marker=AF_MARKER_POINT, const char *const title=NULL)
Renders the input arrays as a 2D scatter-plot to the window.
AFAPI af_err af_draw_scatter3(const af_window wind, const af_array P, const af_marker_type marker, const af_cell *const props)
C Interface wrapper for drawing an array as a plot.
void plot(const array &X, const array &Y, const char *const title=NULL)
Renders the input arrays as a 2D plot to the window.
void plot3(const array &in, const char *title=NULL)
Renders the input array as an 3d line plot to the window.
AFAPI 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.
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.
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.
void image(const array &in, const char *title=NULL)
Renders the input array as an image to the window.
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.
void hist(const array &X, const double minval, const double maxval, const char *const title=NULL)
Renders the input array as a histogram to the window.
Window()
Creates a window object with default width and height with title set to "ArrayFire".
Window(const int width, const int height, const char *const title="ArrayFire")
Creates a window object using the parameters provided by the user.
af_window get() const
Definition graphics.h:107
~Window()
Destroys the window handle.
void setSize(const unsigned w, const unsigned h)
Set the window size.
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_set_title(const af_window wind, const char *const title)
C Interface wrapper for setting window title.
bool close()
Check if window is marked for close.
AFAPI af_err af_destroy_window(const af_window wind)
C Interface wrapper for destroying a window handle.
void show()
This function swaps the background buffer to current view and polls for any key strokes while the win...
AFAPI af_err af_show(const af_window wind)
C Interface wrapper for showing a window.
Window(const af_window wnd)
Creates a window object with default width and height with title set to "ArrayFire".
void setTitle(const char *const title)
Set the window title.
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.
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.
void setPos(const unsigned x, const unsigned y)
Set the start position where the window will appear.
void setVisibility(const bool isVisible)
Hide/Show the window.
AFAPI af_err af_set_size(const af_window wind, const unsigned w, const unsigned h)
C Interface wrapper for setting window position.
AFAPI af_err af_is_window_closed(bool *out, const af_window wind)
C Interface wrapper for checking if window is marked for close.
void setColorMap(const ColorMap cmap)
Set the colormap to be used for subsequent rendering calls.
AFAPI af_err af_set_visibility(const af_window wind, const bool is_visible)
Hide/Show a window.
Window(const char *const title)
Creates a window object with default width and height using the title provided by the user.
void grid(const int rows, const int cols)
Setup grid layout for multiview mode in a window.
Definition algorithm.h:15
Definition graphics.h:17
af_colormap cmap
Definition graphics.h:21
const char * title
Definition graphics.h:20
int row
Definition graphics.h:18
int col
Definition graphics.h:19