Forge: Window Class Reference

Forge

Public Member Functions
Window Class Reference

Window is where other objects such as Images, Plots etc. More...

`#include <window.h>`

## Public Member Functions
FGAPI | Window (int pWidth, int pHeight, const char *pTitle, const Window *pWindow=0, const bool invisible=false)
| Creates a Window object. More...
FGAPI | Window (const Window &other)
| Copy constructor for Window. More...
FGAPI | ~Window ()
| Window Destructor. More...
FGAPI void | setFont (Font *pFont)
| Set font to be used by the window to draw text. More...
FGAPI void | setTitle (const char *pTitle)
| Set the window title. More...
FGAPI void | setPos (int pX, int pY)
| Set the start position where the window will appear. More...
FGAPI void | setSize (unsigned pWidth, unsigned pHeight)
| Set the size of the window programmatically. More...
FGAPI void | setColorMap (ColorMap cmap)
| Set the colormap to be used for subsequent rendering calls. More...
FGAPI long long | context () const
| Get rendering backend context handle. More...
FGAPI long long | display () const
| Get Native Window display handle. More...
FGAPI int | width () const
FGAPI int | height () const
FGAPI fg_window | get () const
FGAPI void | makeCurrent ()
| Make the current window's rendering context active context. More...
FGAPI int | gridRows () const
FGAPI int | gridCols () const
FGAPI void | hide ()
| Hide the window. More...
FGAPI void | show ()
| Show the window if hidden, otherwise no effect. More...
FGAPI bool | close ()
| Check if the window is ready for close. More...
FGAPI void | draw (const Image &pImage, const bool pKeepAspectRatio=true)
| Render an Image to Window. More...
FGAPI void | draw (const Chart &pChart)
| Render a chart to Window. More...
FGAPI void | grid (int pRows, int pCols)
| Setup grid layout for multivew mode. More...
FGAPI void | draw (int pRowId, int pColId, const Image &pImage, const char *pTitle=0, const bool pKeepAspectRatio=true)
| Render Image to given sub-region of the window in multiview mode. More...
FGAPI void | draw (int pRowId, int pColId, const Chart &pChart, const char *pTitle=0)
| Render the chart to given sub-region of the window in multiview mode. More...
FGAPI void | swapBuffers ()
| Swaps background buffer with front buffer. More...
FGAPI void | saveFrameBuffer (const char *pFullPath)
| Save window frame buffer to give location in provided image format. More...

## Detailed Description

Window is where other objects such as Images, Plots etc.

are rendered.

Examples:
  cpu/bubblechart.cpp, cpu/field.cpp, cpu/fractal.cpp, cpu/histogram.cpp, cpu/plot3.cpp, cpu/plotting.cpp, cpu/stream.cpp, cpu/surface.cpp, opencl/bubblechart.cpp, opencl/cl_helpers.h, opencl/field.cpp, opencl/fractal.cpp, opencl/histogram.cpp, opencl/plot3.cpp, opencl/plotting.cpp, opencl/stream.cpp, and opencl/surface.cpp.

## Constructor & Destructor Documentation

## § Window() [1/2]

FGAPI Window | ( | int | pWidth,
|  | int | pHeight,
|  | const char * | pTitle,
|  | const Window * | pWindow = `0`,
|  | const bool | invisible = `false`
| ) |  |

Creates a Window object.

Parameters

  [in] | pWidth | Width of the display window
  [in] | pHeight | Height of the display window
  [in] | pTitle | window Title
  [in] | pWindow | An already existing window with which the window to be created should share the rendering context.
  [in] | invisible | window is created in invisible mode. User has to call Window::show() when they decide to actually display the window

## § Window() [2/2]

FGAPI Window | ( | const Window & | other | ) |

Copy constructor for Window.

Parameters

  [in] | other | is the Window of which we make a copy of.

## § ~Window()

FGAPI ~Window | ( |  | ) |

Window Destructor.

## Member Function Documentation

## § close()

FGAPI bool close | ( |  | ) |

Check if the window is ready for close.

This happens when an user presses `ESC` key while the window is in focus or clicks on the close button of the window

Returns
  true | false

Examples:
  cpu/field.cpp, cpu/fractal.cpp, cpu/histogram.cpp, cpu/plot3.cpp, cpu/plotting.cpp, cpu/stream.cpp, cpu/surface.cpp, opencl/bubblechart.cpp, opencl/field.cpp, opencl/fractal.cpp, opencl/histogram.cpp, opencl/plot3.cpp, opencl/plotting.cpp, opencl/stream.cpp, and opencl/surface.cpp.

## § context()

FGAPI long long context | ( |  | ) | const

Get rendering backend context handle.

Returns
  Context handle for the window's rendering context

Examples:
  opencl/cl_helpers.h.

## § display()

FGAPI long long display | ( |  | ) | const

Get Native Window display handle.

Returns
  Display handle of the native window implemenation of Window

Examples:
  opencl/cl_helpers.h.

## § draw() [1/4]

FGAPI void draw | ( | const Image & | pImage,
|  | const bool | pKeepAspectRatio = `true`
| ) |  |

Render an Image to Window.

Parameters

  [in] | pImage | is an object of class Image
  [in] | pKeepAspectRatio | when set to true keeps the aspect ratio of the input image constant.

Note
  this draw call automatically swaps back buffer with front buffer (double buffering mechanism).

Examples:
  cpu/field.cpp, cpu/fractal.cpp, cpu/histogram.cpp, cpu/plot3.cpp, cpu/plotting.cpp, cpu/stream.cpp, cpu/surface.cpp, opencl/bubblechart.cpp, opencl/field.cpp, opencl/fractal.cpp, opencl/histogram.cpp, opencl/plot3.cpp, opencl/plotting.cpp, opencl/stream.cpp, and opencl/surface.cpp.

## § draw() [2/4]

FGAPI void draw | ( | const Chart & | pChart | ) |

Render a chart to Window.

Parameters

  [in] | pChart | is an chart object

Note
  this draw call automatically swaps back buffer with front buffer (double buffering mechanism).

## § draw() [3/4]

FGAPI void draw | ( | int | pRowId,
|  | int | pColId,
|  | const Image & | pImage,
|  | const char * | pTitle = `0`,
|  | const bool | pKeepAspectRatio = `true`
| ) |  |

Render Image to given sub-region of the window in multiview mode.

Window::grid should have been already called before any of the draw calls that accept coloum index and row index is used to render an object.

Parameters

  [in] | pColId | is coloumn index
  [in] | pRowId | is row index
  [in] | pImage | is an object of class Image
  [in] | pTitle | is the title that will be displayed for the cell represented by `pColId` and `pRowId`
  [in] | pKeepAspectRatio | when set to true keeps the aspect ratio of the input image constant.

Note
  this draw call doesn't automatically swap back buffer with front buffer (double buffering mechanism) since it doesn't have the knowledge of which sub-regions already got rendered. We should call Window::draw() once all draw calls corresponding to all sub-regions are called when in multiview mode.

## § draw() [4/4]

FGAPI void draw | ( | int | pRowId,
|  | int | pColId,
|  | const Chart & | pChart,
|  | const char * | pTitle = `0`
| ) |  |

Render the chart to given sub-region of the window in multiview mode.

Window::grid should have been already called before any of the draw calls that accept coloum index and row index is used to render an object.

Parameters

  [in] | pColId | is coloumn index
  [in] | pRowId | is row index
  [in] | pChart | is a Chart with one or more plottable renderables
  [in] | pTitle | is the title that will be displayed for the cell represented by `pColId` and `pRowId`

Note
  this draw call doesn't automatically swap back buffer with front buffer (double buffering mechanism) since it doesn't have the knowledge of which sub-regions already got rendered. We should call Window::draw() once all draw calls corresponding to all sub-regions are called when in multiview mode.

## § get()

FGAPI fg_window get | ( |  | ) | const

Returns
  internal handle for window implementation

## § grid()

FGAPI void grid | ( | int | pRows,
|  | int | pCols
| ) |  |

Setup grid layout for multivew mode.

Multiview mode is where you can render different objects to different sub-regions of a given window

Parameters

  [in] | pRows | is number of rows in grid layout
  [in] | pCols | is number of coloumns in grid layout

Examples:
  cpu/histogram.cpp, and opencl/histogram.cpp.

## § gridCols()

FGAPI int gridCols | ( |  | ) | const

Returns
  The window grid columns

## § gridRows()

FGAPI int gridRows | ( |  | ) | const

Returns
  The window grid rows

## § height()

FGAPI int height | ( |  | ) | const

Returns
  window height

## § hide()

FGAPI void hide | ( |  | ) |

Hide the window.

## § makeCurrent()

FGAPI void makeCurrent | ( |  | ) |

Make the current window's rendering context active context.

Examples:
  cpu/field.cpp, cpu/fractal.cpp, cpu/histogram.cpp, cpu/plot3.cpp, cpu/plotting.cpp, cpu/stream.cpp, cpu/surface.cpp, opencl/bubblechart.cpp, opencl/field.cpp, opencl/fractal.cpp, opencl/histogram.cpp, opencl/plot3.cpp, opencl/plotting.cpp, opencl/stream.cpp, and opencl/surface.cpp.

## § saveFrameBuffer()

FGAPI void saveFrameBuffer | ( | const char * | pFullPath | ) |

Save window frame buffer to give location in provided image format.

The image format to be saved in is inferred from the file extension provided in the path string.

Parameters

  [in] | pFullPath | should be the absolute path of the target location where the framebuffer should be stored. The target image format is inferred from the file extension.

## § setColorMap()

FGAPI void setColorMap | ( | ColorMap | cmap | ) |

Set the colormap to be used for subsequent rendering calls.

Parameters

  [in] | cmap | should be one of the enum values from ColorMap

## § setFont()

FGAPI void setFont | ( | Font * | pFont | ) |

Set font to be used by the window to draw text.

Parameters

  [in] | pFont | Font object pointer

Examples:
  cpu/fractal.cpp.

## § setPos()

FGAPI void setPos | ( | int | pX,
|  | int | pY
| ) |  |

Set the start position where the window will appear.

Parameters

  [in] | pX | is horizontal coordinate
  [in] | pY | is vertical coordinate

## § setSize()

FGAPI void setSize | ( | unsigned | pWidth,
|  | unsigned | pHeight
| ) |  |

Set the size of the window programmatically.

Parameters

  [in] | pWidth | target width
  [in] | pHeight | target height

## § setTitle()

FGAPI void setTitle | ( | const char * | pTitle | ) |

Set the window title.

Parameters

  [in] | pTitle | is the window title

## § show()

FGAPI void show | ( |  | ) |

Show the window if hidden, otherwise no effect.

## § swapBuffers()

FGAPI void swapBuffers | ( |  | ) |

Swaps background buffer with front buffer.

This draw call should only be used when the window is displaying something in multiview mode

Examples:
  cpu/histogram.cpp, and opencl/histogram.cpp.

## § width()

FGAPI int width | ( |  | ) | const

Returns
  window width

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

- window.h