Namespaces¶
All objects and utility functions mentioned in this section have to be qualified by the namespace forge.
forge¶
Classes¶
Chart¶
-
class
forge
::
Chart
¶ Chart is base canvas where other plottable objects are rendered.
Charts come in two types:
FG_CHART_2D - Two dimensional charts
FG_CHART_3D - Three dimensional charts
Public Functions
-
FGAPI
Chart
(const ChartType cType)¶ Creates a Chart object with given dimensional property.
- Parameters
[in] cType
: is chart dimension property
-
FGAPI void setAxesTitles (const char *pX, const char *pY, const char *pZ=NULL)
Set axes titles for the chart.
- Parameters
[in] pX
: is x-axis title label[in] pY
: is y-axis title label[in] pZ
: is z-axis title label
-
FGAPI void setAxesLimits (const float pXmin, const float pXmax, const float pYmin, const float pYmax, const float pZmin=0, const float pZmax=0)
Set axes data ranges.
- Parameters
[in] pXmin
: is x-axis minimum data value[in] pXmax
: is x-axis maximum data value[in] pYmin
: is y-axis minimum data value[in] pYmax
: is y-axis maximum data value[in] pZmin
: is z-axis minimum data value[in] pZmax
: is z-axis maximum data value
-
FGAPI void setAxesLabelFormat (const char *pXFormat, const char *pYFormat="%4.1f", const char *pZFormat="%4.1f")
Set the format for display of axes labels.
Display format string follows printf style formating for numbers
- Parameters
[in] pXFormat
: sets the display format for numbers of X axis[in] pYFormat
: sets the display format for numbers of Y axis[in] pZFormat
: sets the display format for numbers of Z axis
-
FGAPI void getAxesLimits (float *pXmin, float *pXmax, float *pYmin, float *pYmax, float *pZmin=NULL, float *pZmax=NULL)
Get axes data ranges.
- Parameters
[out] pXmin
: is x-axis minimum data value[out] pXmax
: is x-axis maximum data value[out] pYmin
: is y-axis minimum data value[out] pYmax
: is y-axis maximum data value[out] pZmin
: is z-axis minimum data value[out] pZmax
: is z-axis maximum data value
-
FGAPI void setLegendPosition (const float pX, const float pY)
Set legend position for Chart.
- Note
By normalized coordinates, the range of these coordinates is expected to be [0-1]. (0,0) is the bottom hand left corner.
- Parameters
[in] pX
: is horizontal position in normalized coordinates[in] pY
: is vertical position in normalized coordinates
-
FGAPI void add (const Image &pImage)
Add an existing Image object to the current chart.
- Parameters
[in] pImage
: is the Image to render on the chart
-
FGAPI void add (const Histogram &pHistogram)
Add an existing Histogram object to the current chart.
- Parameters
[in] pHistogram
: is the Histogram to render on the chart
-
FGAPI void add (const Plot &pPlot)
Add an existing Plot object to the current chart.
- Parameters
[in] pPlot
: is the Plot to render on the chart
-
FGAPI void add (const Surface &pSurface)
Add an existing Surface object to the current chart.
- Parameters
[in] pSurface
: is the Surface to render on the chart
-
FGAPI void add (const VectorField &pVectorField)
Add an existing vector field object to the current chart.
- Parameters
[in] pVectorField
: is the Surface to render on the chart
-
FGAPI Image image (const unsigned pWidth, const unsigned pHeight, const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32)
Create and add an Image object to the current chart.
- Parameters
[in] pWidth
: Width of the image[in] pHeight
: Height of the image[in] pFormat
: Color channel format of image, uses one of the values of ChannelFormat[in] pDataType
: takes one of the values of dtype that indicates the integral data type of histogram data
-
FGAPI Histogram histogram (const unsigned pNBins, const dtype pDataType)
Create and add an Histogram object to the current chart.
- Parameters
[in] pNBins
: is number of bins the data is sorted out[in] pDataType
: takes one of the values of dtype that indicates the integral data type of histogram data
-
FGAPI Plot plot (const unsigned pNumPoints, const dtype pDataType, const PlotType pPlotType=FG_PLOT_LINE, const MarkerType pMarkerType=FG_MARKER_NONE)
Create and add an Plot object to the current chart.
- Parameters
[in] pNumPoints
: is number of data points to display[in] pDataType
: takes one of the values of dtype that indicates the integral data type of plot data[in] pPlotType
: dictates the type of plot/graph, it can take one of the values of PlotType[in] pMarkerType
: indicates which symbol is rendered as marker. It can take one of the values of MarkerType.
-
FGAPI Surface surface (const unsigned pNumXPoints, const unsigned pNumYPoints, const dtype pDataType, const PlotType pPlotType=FG_PLOT_SURFACE, const MarkerType pMarkerType=FG_MARKER_NONE)
Create and add an Plot object to the current chart.
- Parameters
[in] pNumXPoints
: is number of data points along X dimension[in] pNumYPoints
: is number of data points along Y dimension[in] pDataType
: takes one of the values of dtype that indicates the integral data type of plot data[in] pPlotType
: is the render type which can be one of PlotType (valid choices are FG_PLOT_SURFACE and FG_PLOT_SCATTER)[in] pMarkerType
: is the type of MarkerType to draw for FG_PLOT_SCATTER plot type
-
FGAPI VectorField vectorField (const unsigned pNumPoints, const dtype pDataType)
Create and add an Vector Field object to the current chart.
- Parameters
[in] pNumPoints
: is number of data points to display[in] pDataType
: takes one of the values of dtype that indicates the integral data type of vector field data
-
FGAPI void render (const Window &pWindow, const int pX, const int pY, const int pVPW, const int pVPH) const
Render the chart to given window.
- Parameters
[in] pWindow
: is target window to where chart will be rendered[in] pX
: is x coordinate of origin of viewport in window coordinates[in] pY
: is y coordinate of origin of viewport in window coordinates[in] pVPW
: is the width of the viewport[in] pVPH
: is the height of the viewport
-
FGAPI fg_chart get () const
Get the handle to internal implementation of Chart.
-
FGAPI ChartType getChartType () const
Get the type of the chart.
Error¶
Font¶
-
class
forge
::
Font
¶ Font object is a resource handler for the font you want to use.
Public Functions
-
FGAPI
Font
(const Font &other)¶ Copy constructor for Font.
- Parameters
[in] other
: is the Font object of which we make a copy of, this is not a deep copy.
-
FGAPI void loadFontFile (const char *const pFile)
Load a given font file.
- Parameters
[in] pFile
: True Type Font file path
-
FGAPI void loadSystemFont (const char *const pName)
Load a system font based on the name.
- Parameters
[in] pName
: True Type Font name
-
FGAPI fg_font get () const
Get handle for internal implementation of Font object.
-
FGAPI
Histogram¶
-
class
forge
::
Histogram
¶ Histogram is a bar graph to display data frequencey.
Public Functions
-
FGAPI
Histogram
(const unsigned pNBins, const dtype pDataType)¶ Creates a Histogram object.
- Parameters
[in] pNBins
: is number of bins the data is sorted out[in] pDataType
: takes one of the values of fg_dtype that indicates the integral data type of histogram data
-
FGAPI
Histogram
(const Histogram &pOther)¶ Copy constructor for Histogram.
- Parameters
[in] pOther
: is the Histogram of which we make a copy of.
-
explicit FGAPI
Histogram
(const fg_histogram pHandle)¶ Construct Histogram ojbect from fg_histogram resource handle.
- Note
This kind of construction assumes ownership of the resource handle is released during the Histogram object’s destruction.
- Parameters
[in] pHandle
: is the input fg_histogram resource handle
-
FGAPI void setColor (const Color pColor)
Set the color of bar in the bar graph(histogram)
- Parameters
[in] pColor
: takes values of type forge::Color to define bar color
-
FGAPI void setColor (const float pRed, const float pGreen, const float pBlue, const float pAlpha)
Set the color of bar in the bar graph(histogram)
This is global alpha value for the histogram rendering that takes effect if individual bar alphas are not set by calling the following member functions
- Parameters
[in] pRed
: is Red component in range [0, 1][in] pGreen
: is Green component in range [0, 1][in] pBlue
: is Blue component in range [0, 1][in] pAlpha
: is Alpha component in range [0, 1]
-
FGAPI void setLegend (const char *pLegend)
Set legend for histogram plot.
- Parameters
[in] pLegend
:
-
FGAPI unsigned vertices () const
Get the buffer identifier for vertices.
- Return
vertex buffer resource id.
-
FGAPI unsigned colors () const
Get the buffer identifier for color values per vertex.
- Return
colors buffer resource id.
-
FGAPI unsigned alphas () const
Get the buffer identifier for alpha values per vertex.
- Return
alpha values buffer resource id.
-
FGAPI unsigned verticesSize () const
Get the vertex buffer size in bytes.
- Return
vertex buffer size in bytes
-
FGAPI unsigned colorsSize () const
Get the colors buffer size in bytes.
- Return
colors buffer size in bytes
-
FGAPI unsigned alphasSize () const
Get the alpha values buffer size in bytes.
- Return
alpha buffer size in bytes
-
FGAPI fg_histogram get () const
Get the handle to internal implementation of Histogram.
-
FGAPI
Image¶
-
class
forge
::
Image
¶ Image helps rendering an image in a window.
Public Functions
-
FGAPI
Image
(const unsigned pWidth, const unsigned pHeight, const ChannelFormat pFormat = FG_RGBA, const dtype pDataType = f32)¶ Creates a Image object.
- Parameters
[in] pWidth
: Width of the image[in] pHeight
: Height of the image[in] pFormat
: Color channel format of image, uses one of the values of ChannelFormat[in] pDataType
: takes one of the values of dtype that indicates the integral data type of histogram data
-
FGAPI
Image
(const Image &pOther)¶ Copy constructor of Image.
- Parameters
[in] pOther
: is the Image of which we make a copy of.
-
explicit FGAPI
Image
(const fg_image pHandle)¶ Construct Image ojbect from fg_image resource handle.
- Note
This kind of construction assumes ownership of the resource handle is released during the Image object’s destruction.
- Parameters
[in] pHandle
: is the input fg_image resource handle
-
FGAPI void setAlpha (const float pAlpha)
Set a global alpha value for rendering the image.
- Parameters
[in] pAlpha
:
-
FGAPI void keepAspectRatio (const bool pKeep)
Set option to inform whether to maintain aspect ratio of original image.
- Parameters
[in] pKeep
:
-
FGAPI unsigned width () const
Get Image width.
- Return
image width
-
FGAPI unsigned height () const
Get Image height.
- Return
image width
-
FGAPI ChannelFormat pixelFormat () const
Get Image’s channel format.
- Return
ChannelFormat value of Image
-
FGAPI unsigned pixels () const
Get the resource id of image buffer.
- Return
image buffer id
-
FGAPI unsigned size () const
Get the image data size in bytes.
- Return
image buffer size in bytes
-
FGAPI void render (const Window &pWindow, const int pX, const int pY, const int pVPW, const int pVPH) const
Render the image to given window.
- Parameters
[in] pWindow
: is target window to where image will be rendered[in] pX
: is x coordinate of origin of viewport in window coordinates[in] pY
: is y coordinate of origin of viewport in window coordinates[in] pVPW
: is the width of the viewport[in] pVPH
: is the height of the viewport
-
FGAPI fg_image get () const
Get the handle to internal implementation of Image.
-
FGAPI
Plot¶
-
class
forge
::
Plot
¶ Plot is a line graph to display two dimensional data.
Public Functions
-
FGAPI
Plot
(const unsigned pNumPoints, const dtype pDataType, const ChartType pChartType, const PlotType pPlotType = FG_PLOT_LINE, const MarkerType pMarkerType = FG_MARKER_NONE)¶ Creates a Plot object.
- Parameters
[in] pNumPoints
: is number of data points to display[in] pDataType
: takes one of the values of dtype that indicates the integral data type of plot data[in] pChartType
: dictates the dimensionality of the chart[in] pPlotType
: dictates the type of plot/graph, it can take one of the values of PlotType[in] pMarkerType
: indicates which symbol is rendered as marker. It can take one of the values of MarkerType.
-
FGAPI
Plot
(const Plot &pOther)¶ Copy constructor for Plot.
- Parameters
[in] pOther
: is the Plot of which we make a copy of.
-
explicit FGAPI
Plot
(const fg_plot pHandle)¶ Construct Plot ojbect from fg_plot resource handle.
- Note
This kind of construction assumes ownership of the resource handle is released during the Plot object’s destruction.
- Parameters
[in] pHandle
: is the input fg_plot resource handle
-
FGAPI void setColor (const forge::Color pColor)
Set the color of line graph(plot)
- Parameters
[in] pColor
: takes values of forge::Color to define plot color
-
FGAPI void setColor (const float pRed, const float pGreen, const float pBlue, const float pAlpha)
Set the color of line graph(plot)
- Parameters
[in] pRed
: is Red component in range [0, 1][in] pGreen
: is Green component in range [0, 1][in] pBlue
: is Blue component in range [0, 1][in] pAlpha
: is Blue component in range [0, 1]
-
FGAPI void setLegend (const char *pLegend)
Set plot legend.
- Parameters
[in] pLegend
:
-
FGAPI void setMarkerSize (const float pMarkerSize)
Set global marker size.
This size will be used for rendering markers if no per vertex marker sizes are provided. This value defaults to 10
- Parameters
[in] pMarkerSize
: is the target marker size for scatter plots or line plots with markers
-
FGAPI unsigned vertices () const
Get the buffer identifier for vertices.
- Return
vertex buffer resource id.
-
FGAPI unsigned colors () const
Get the buffer identifier for color values per vertex.
- Return
colors buffer resource id.
-
FGAPI unsigned alphas () const
Get the buffer identifier for alpha values per vertex.
- Return
alpha values buffer resource id.
-
FGAPI unsigned radii () const
Get the buffer identifier for per vertex marker sizes.
- Return
marker sizes buffer resource id.
-
FGAPI unsigned verticesSize () const
Get the vertex buffer size in bytes.
- Return
vertex buffer size in bytes
-
FGAPI unsigned colorsSize () const
Get the colors buffer size in bytes.
- Return
colors buffer size in bytes
-
FGAPI unsigned alphasSize () const
Get the alpha values buffer size in bytes.
- Return
alpha buffer size in bytes
-
FGAPI unsigned radiiSize () const
Get the marker sizes buffer size in bytes.
- Return
marker sizes buffer size in bytes
-
FGAPI fg_plot get () const
Get the handle to internal implementation of plot.
-
FGAPI
Surface¶
-
class
forge
::
Surface
¶ Surface is a graph to display three dimensional data.
Public Functions
-
FGAPI
Surface
(const unsigned pNumXPoints, const unsigned pNumYPoints, const dtype pDataType, const PlotType pPlotType = FG_PLOT_SURFACE, const MarkerType pMarkerType = FG_MARKER_NONE)¶ Creates a Surface object.
- Parameters
[in] pNumXPoints
: is number of data points along X dimension[in] pNumYPoints
: is number of data points along Y dimension[in] pDataType
: takes one of the values of dtype that indicates the integral data type of surface data[in] pPlotType
: is the render type which can be one of PlotType (valid choices are FG_PLOT_SURFACE and FG_PLOT_SCATTER)[in] pMarkerType
: is the type of MarkerType to draw for FG_PLOT_SCATTER plot type
-
FGAPI
Surface
(const Surface &pOther)¶ Copy constructor for surface.
- Parameters
[in] pOther
: is the surface of which we make a copy of.
-
explicit FGAPI
Surface
(const fg_surface pHandle)¶ Construct Surface ojbect from fg_surface resource handle.
- Note
This kind of construction assumes ownership of the resource handle is released during the Surface object’s destruction.
- Parameters
[in] pHandle
: is the input fg_surface resource handle
-
FGAPI
~Surface
()¶ surface Destructor
-
FGAPI void setColor (const forge::Color pColor)
Set the color of line graph(surface)
- Parameters
[in] pColor
: takes values of forge::Color to define surface color
-
FGAPI void setColor (const float pRed, const float pGreen, const float pBlue, const float pAlpha)
Set the color of line graph(surface)
- Parameters
[in] pRed
: is Red component in range [0, 1][in] pGreen
: is Green component in range [0, 1][in] pBlue
: is Blue component in range [0, 1][in] pAlpha
: is Blue component in range [0, 1]
-
FGAPI void setLegend (const char *pLegend)
Set surface legend.
- Parameters
[in] pLegend
:
-
FGAPI unsigned vertices () const
Get the buffer identifier for vertices.
- Return
vertex buffer resource id.
-
FGAPI unsigned colors () const
Get the buffer identifier for color values per vertex.
- Return
colors buffer resource id.
-
FGAPI unsigned alphas () const
Get the buffer identifier for alpha values per vertex.
- Return
alpha values buffer resource id.
-
FGAPI unsigned verticesSize () const
Get the vertex buffer size in bytes.
- Return
vertex buffer size in bytes
-
FGAPI unsigned colorsSize () const
Get the colors buffer size in bytes.
- Return
colors buffer size in bytes
-
FGAPI unsigned alphasSize () const
Get the alpha values buffer size in bytes.
- Return
alpha buffer size in bytes
-
FGAPI fg_surface get () const
Get the handle to internal implementation of surface.
-
FGAPI
Window¶
-
class
forge
::
Window
¶ Window is where objects such as Images, Plots etc. are rendered.
Public Functions
-
FGAPI
Window
(const int pWidth, const 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
-
FGAPI
Window
(const Window &other)¶ Copy constructor for Window.
- Parameters
[in] other
: is the Window of which we make a copy of.
-
FGAPI void setFont (Font *pFont)
Set font to be used by the window to draw text.
- Parameters
[in] pFont
: Font object pointer
-
FGAPI void setTitle (const char *pTitle)
Set the window title.
- Parameters
[in] pTitle
: is the window title
-
FGAPI void setPos (const int pX, const int pY)
Set the start position where the window will appear.
- Parameters
[in] pX
: is horizontal coordinate[in] pY
: is vertical coordinate
-
FGAPI void setSize (const unsigned pWidth, const unsigned pHeight)
Set the size of the window programmatically.
- Parameters
[in] pWidth
: target width[in] pHeight
: target height
-
FGAPI void setColorMap (const ColorMap cmap)
Set the colormap to be used for subsequent rendering calls.
- Parameters
[in] cmap
: should be one of the enum values from ColorMap
-
FGAPI long long context () const
Get rendering backend context handle.
- Return
Context handle for the window’s rendering context
-
FGAPI long long display () const
Get Native Window display handle.
- Return
Display handle of the native window implemenation of Window
-
FGAPI int width () const
- Return
window width
-
FGAPI int height () const
- Return
window height
-
FGAPI fg_window get () const
- Return
internal handle for window implementation
-
FGAPI void makeCurrent ()
Make the current window’s rendering context active context.
-
FGAPI void hide ()
Hide the window.
-
FGAPI void show ()
Show the window if hidden, otherwise no effect.
-
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- Return
true | false
-
FGAPI void draw (const Image &pImage, const bool pKeepAspectRatio=true)
-
- Note
this draw call automatically swaps back buffer with front buffer (double buffering mechanism).
- Parameters
[in] pImage
: is an object of class Image[in] pKeepAspectRatio
: when set to true keeps the aspect ratio of the input image constant.
-
FGAPI void draw (const Chart &pChart)
Render a chart to Window.
- Note
this draw call automatically swaps back buffer with front buffer (double buffering mechanism).
- Parameters
[in] pChart
: is an chart object
-
FGAPI void draw (const int pRows, const int pCols, const int pIndex, const Image &pImage, const char *pTitle=0, const bool pKeepAspectRatio=true)
Render Image to given sub-region of the window in multiview mode.
- 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.
- Parameters
[in] pRows
: indicates the number of rows in grid layout[in] pCols
: indicates the number of columns in grid layout[in] pIndex
: indicates the index of cell in the layout represented bypRows
andpCols
[in] pImage
: is an object of class Image[in] pTitle
: is the title that will be displayed for the cell represented bypColId
andpRowId
[in] pKeepAspectRatio
: when set to true keeps the aspect ratio of the input image constant.
-
FGAPI void draw (const int pRows, const int pCols, const int pIndex, const Chart &pChart, const char *pTitle=0)
Render the chart to given sub-region of the window in multiview mode.
- 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.
- Parameters
[in] pRows
: indicates the number of rows in grid layout[in] pCols
: indicates the number of columns in grid layout[in] pIndex
: indicates the index of cell in the layout represented bypRows
andpCols
[in] pChart
: is a Chart with one or more plottable renderables[in] pTitle
: is the title that will be displayed for the cell represented bypColId
andpRowId
-
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
-
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.
-
FGAPI
Typedefs¶
-
typedef fg_channel_format
forge
::
ChannelFormat
¶
-
typedef fg_chart_type
forge
::
ChartType
¶
-
typedef fg_color_map
forge
::
ColorMap
¶
-
typedef fg_plot_type
forge
::
PlotType
¶
-
typedef fg_marker_type
forge
::
MarkerType
¶