Window Class Reference

Window object to render af::arrays. More...

#include <graphics.h>

Public Member Functions

 Window ()
 Creates a window object with default width and height with title set to "ArrayFire". More...
 
 Window (const char *const title)
 Creates a window object with default width and height using the title provided by the user. More...
 
 Window (const int width, const int height, const char *const title="ArrayFire")
 Creates a window object using the parameters provided by the user. More...
 
 Window (const af_window wnd)
 Creates a window object with default width and height with title set to "ArrayFire". More...
 
 ~Window ()
 Destroys the window handle. More...
 
af_window get () const
 
void setPos (const unsigned x, const unsigned y)
 Set the start position where the window will appear. More...
 
void setTitle (const char *const title)
 Set the window title. More...
 
void setColorMap (const ColorMap cmap)
 Set the colormap to be used for subsequent rendering calls. More...
 
void image (const array &in, const char *title=NULL)
 Renders the input array as an image to the window. More...
 
void plot (const array &X, const array &Y, const char *const title=NULL)
 Renders the input arrays as a 2D plot to the window. More...
 
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. More...
 
void grid (const int rows, const int cols)
 Setup grid layout for multiview mode in a window. More...
 
void show ()
 This function swaps the background buffer to current view and polls for any key strokes while the window was in focus. More...
 
bool close ()
 Check if window is marked for close. More...
 
Windowoperator() (const int r, const int c)
 This function is used to keep track of which cell in the grid mode is being currently rendered. More...
 

Detailed Description

Constructor & Destructor Documentation

Window ( )

Creates a window object with default width and height with title set to "ArrayFire".

Window ( const char *const  title)

Creates a window object with default width and height using the title provided by the user.

Parameters
[in]titleis the window title
Window ( const int  width,
const int  height,
const char *const  title = "ArrayFire" 
)

Creates a window object using the parameters provided by the user.

Parameters
[in]widthis the window width
[in]heightis the window height
[in]titleis the window title with default value as "ArrayFire"
Window ( const af_window  wnd)

Creates a window object with default width and height with title set to "ArrayFire".

Parameters
[in]wndis an af_window handle which can be retrieved by doing a get call on any Window object
~Window ( )

Destroys the window handle.

Member Function Documentation

bool close ( )

Check if window is marked for close.

This usually happens when user presses ESC key while the window is in focus.

Returns
AF_SUCCESS if window show is successful, otherwise an appropriate error code is returned.
Examples:
conway.cpp, conway_pretty.cpp, harris.cpp, and plot2d.cpp.
af_window get ( ) const
inline
Returns
Returns the af_window window handle.
void grid ( const int  rows,
const int  cols 
)

Setup grid layout for multiview mode in a window.

Parameters
[in]rowsis number of rows you want to show in a window
[in]colsis number of coloumns you want to show in a window
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.

Parameters
[in]Xis the data frequency array
[in]minvalis the value of the minimum data point of the array whose histogram(X) is going to be rendered.
[in]maxvalis the value of the maximum data point of the array whose histogram(X) is going to be rendered.
[in]titleparameter is used when this function is called in grid mode
Note
X should be a vector.
void image ( const array in,
const char *  title = NULL 
)

Renders the input array as an image to the window.

Parameters
[in]inis an array
[in]titleparameter is used when this function is called in grid mode
Note
in should be 2d array or 3d array with 3 channels.
Examples:
conway.cpp, conway_pretty.cpp, and harris.cpp.
Window& operator() ( const int  r,
const int  c 
)
inline

This function is used to keep track of which cell in the grid mode is being currently rendered.

When a user does Window(0,0), we internally store the cell coordinates and return a reference to the very object that called upon this function. This reference can be used later to issue draw calls using rendering functions.

Returns
a reference to the object pointed by this to enable cascading this call with rendering functions.
void plot ( const array X,
const array Y,
const char *const  title = NULL 
)

Renders the input arrays as a 2D plot to the window.

Parameters
[in]Xis an array with the x-axis data points
[in]Yis an array with the y-axis data points
[in]titleparameter is used when this function is called in grid mode
Note
X and Y should be vectors.
Examples:
plot2d.cpp.
void setColorMap ( const ColorMap  cmap)

Set the colormap to be used for subsequent rendering calls.

Parameters
[in]cmapshould be one of the enum values from ColorMap
void setPos ( const unsigned  x,
const unsigned  y 
)

Set the start position where the window will appear.

Parameters
[in]xis horizontal coordinate
[in]yis vertical coordinate
Examples:
conway_pretty.cpp.
void setTitle ( const char *const  title)

Set the window title.

Parameters
[in]titleis the window title
void show ( )

This function swaps the background buffer to current view and polls for any key strokes while the window was in focus.


The documentation for this class was generated from the following file: