Forge
chart.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2015-2019, 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 <fg/defines.h>
13 #include <fg/image.h>
14 #include <fg/plot.h>
15 #include <fg/surface.h>
16 #include <fg/vector_field.h>
17 #include <fg/histogram.h>
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
37  const fg_chart_type pChartType);
38 
48 
57 
69  const char* pX,
70  const char* pY,
71  const char* pZ);
72 
87  const float pXmin, const float pXmax,
88  const float pYmin, const float pYmax,
89  const float pZmin, const float pZmax);
90 
101 FGAPI fg_err fg_set_chart_label_format(fg_chart pHandle, const char* pXFormat,
102  const char* pYFormat, const char* pZFormat);
103 
117 FGAPI fg_err fg_get_chart_axes_limits(float* pXmin, float* pXmax,
118  float* pYmin, float* pYmax,
119  float* pZmin, float* pZmax,
120  const fg_chart pHandle);
133 FGAPI fg_err fg_set_chart_legend_position(fg_chart pHandle, const float pX, const float pY);
134 
144 
154 
164 
174 
184 
200  const unsigned pWidth, const unsigned pHeight,
201  const fg_channel_format pFormat,
202  const fg_dtype pType);
203 
216  const unsigned pNBins, const fg_dtype pType);
217 
234  const unsigned pNPoints, const fg_dtype pType,
235  const fg_plot_type pPlotType, const fg_marker_type pMarkerType);
236 
253  const unsigned pXPoints, const unsigned pYPoints, const fg_dtype pType,
254  const fg_plot_type pPlotType, const fg_marker_type pMarkerType);
255 
267  const unsigned pNPoints, const fg_dtype pType);
268 
281 FGAPI fg_err fg_render_chart(const fg_window pWindow,
282  const fg_chart pChart,
283  const int pX, const int pY, const int pWidth, const int pHeight);
284 
293 FGAPI fg_err fg_get_chart_type(fg_chart_type *pChartType, const fg_chart pChart);
294 
297 #ifdef __cplusplus
298 }
299 #endif
300 
301 
302 #ifdef __cplusplus
303 
304 namespace forge
305 {
306 
316 class Chart {
317  private:
318  fg_chart mValue;
319 
320  public:
326  FGAPI Chart(const ChartType cType);
327 
331  FGAPI Chart(const Chart& pOther);
332 
336  FGAPI ~Chart();
337 
345  FGAPI void setAxesTitles(const char* pX,
346  const char* pY,
347  const char* pZ=NULL);
348 
359  FGAPI void setAxesLimits(const float pXmin, const float pXmax,
360  const float pYmin, const float pYmax,
361  const float pZmin=0, const float pZmax=0);
362 
372  FGAPI void setAxesLabelFormat(const char* pXFormat,
373  const char* pYFormat = "%4.1f",
374  const char* pZFormat = "%4.1f");
375 
386  FGAPI void getAxesLimits(float* pXmin, float* pXmax,
387  float* pYmin, float* pYmax,
388  float* pZmin = NULL, float* pZmax = NULL);
389 
399  FGAPI void setLegendPosition(const float pX, const float pY);
400 
406  FGAPI void add(const Image& pImage);
407 
413  FGAPI void add(const Histogram& pHistogram);
414 
420  FGAPI void add(const Plot& pPlot);
421 
427  FGAPI void add(const Surface& pSurface);
428 
434  FGAPI void add(const VectorField& pVectorField);
435 
446  FGAPI Image image(const unsigned pWidth, const unsigned pHeight,
447  const ChannelFormat pFormat=FG_RGBA, const dtype pDataType=f32);
448 
456  FGAPI Histogram histogram(const unsigned pNBins, const dtype pDataType);
457 
469  FGAPI Plot plot(const unsigned pNumPoints, const dtype pDataType,
470  const PlotType pPlotType=FG_PLOT_LINE, const MarkerType pMarkerType=FG_MARKER_NONE);
471 
483  FGAPI Surface surface(const unsigned pNumXPoints, const unsigned pNumYPoints, const dtype pDataType,
484  const PlotType pPlotType=FG_PLOT_SURFACE, const MarkerType pMarkerType=FG_MARKER_NONE);
485 
493  FGAPI VectorField vectorField(const unsigned pNumPoints, const dtype pDataType);
494 
504  FGAPI void render(const Window& pWindow,
505  const int pX, const int pY, const int pVPW, const int pVPH) const;
506 
510  FGAPI fg_chart get() const;
511 
515  FGAPI ChartType getChartType() const;
516 };
517 
518 }
519 
520 #endif
FGAPI ChartType getChartType() const
Get the type of the chart.
FGAPI fg_err fg_append_plot_to_chart(fg_chart pChart, fg_plot pPlot)
Add an existing plot object to chart.
VectorField is a line graph to display two dimensional data.
Definition: vector_field.h:180
FGAPI fg_err fg_render_chart(const fg_window pWindow, const fg_chart pChart, const int pX, const int pY, const int pWidth, const int pHeight)
Render the chart to given window.
Definition: defines.h:193
Four(Red, Green, Blue & Alpha) channels.
Definition: defines.h:113
FGAPI fg_err fg_release_chart(fg_chart pHandle)
Destroy the chart object.
void * fg_chart
Definition: defines.h:42
fg_marker_type
Definition: defines.h:166
No marker.
Definition: defines.h:167
Definition: chart.h:304
FGAPI void setLegendPosition(const float pX, const float pY)
Set legend position for Chart.
FGAPI void getAxesLimits(float *pXmin, float *pXmax, float *pYmin, float *pYmax, float *pZmin=NULL, float *pZmax=NULL)
Get axes data ranges.
FGAPI void setAxesLabelFormat(const char *pXFormat, const char *pYFormat="%4.1f", const char *pZFormat="%4.1f")
Set the format for display of axes labels.
FGAPI Histogram histogram(const unsigned pNBins, const dtype pDataType)
Create and add an Histogram object to the current chart.
fg_plot_type
Definition: defines.h:160
FGAPI fg_err fg_get_chart_axes_limits(float *pXmin, float *pXmax, float *pYmin, float *pYmax, float *pZmin, float *pZmax, const fg_chart pHandle)
Get axes data ranges.
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.
FGAPI fg_err fg_set_chart_axes_titles(fg_chart pHandle, const char *pX, const char *pY, const char *pZ)
Set axes titles for the chart.
dtype
Definition: defines.h:188
fg_channel_format
Definition: defines.h:108
Plot is a line graph to display two dimensional data.
Definition: plot.h:198
FGAPI fg_err fg_set_chart_axes_limits(fg_chart pHandle, const float pXmin, const float pXmax, const float pYmin, const float pYmax, const float pZmin, const float pZmax)
Set axes data ranges.
fg_chart_type
Definition: defines.h:117
FGAPI fg_err fg_get_chart_type(fg_chart_type *pChartType, const fg_chart pChart)
Render the type of a chart.
void * fg_vector_field
Definition: defines.h:47
FGAPI fg_err fg_add_vector_field_to_chart(fg_vector_field *pField, fg_chart pHandle, const unsigned pNPoints, const fg_dtype pType)
Create and add an Vector Field object to the current chart.
FGAPI fg_err fg_set_chart_legend_position(fg_chart pHandle, const float pX, const float pY)
Set legend position for Chart.
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.
FGAPI void add(const Image &pImage)
Add an existing Image object to the current chart.
#define FGAPI
Definition: defines.h:28
void * fg_surface
Definition: defines.h:46
FGAPI Chart(const ChartType cType)
Creates a Chart object with given dimensional property.
FGAPI fg_err fg_add_histogram_to_chart(fg_histogram *pHistogram, fg_chart pHandle, const unsigned pNBins, const fg_dtype pType)
Create and add an Histogram object to the current chart.
void * fg_plot
Definition: defines.h:45
FGAPI void setAxesTitles(const char *pX, const char *pY, const char *pZ=NULL)
Set axes titles for the chart.
void * fg_image
Definition: defines.h:43
FGAPI fg_err fg_append_vector_field_to_chart(fg_chart pChart, fg_vector_field pField)
Add an existing vector field object to chart.
fg_err
Definition: defines.h:49
Chart is base canvas where other plottable objects are rendered.
Definition: chart.h:316
Surface plot.
Definition: defines.h:163
FGAPI fg_err fg_append_histogram_to_chart(fg_chart pChart, fg_histogram pHistogram)
Add an existing histogram object to chart.
Surface is a graph to display three dimensional data.
Definition: surface.h:163
FGAPI fg_err fg_retain_chart(fg_chart *pOut, fg_chart pChart)
Increase reference count for the chart resource.
FGAPI fg_err fg_append_image_to_chart(fg_chart pChart, fg_image pImage)
Add an existing image object to chart.
FGAPI fg_err fg_add_image_to_chart(fg_image *pImage, fg_chart pHandle, const unsigned pWidth, const unsigned pHeight, const fg_channel_format pFormat, const fg_dtype pType)
Create and add an Image object to the current chart.
FGAPI fg_err fg_add_surface_to_chart(fg_surface *pSurface, fg_chart pHandle, const unsigned pXPoints, const unsigned pYPoints, const fg_dtype pType, const fg_plot_type pPlotType, const fg_marker_type pMarkerType)
Create and add an Plot object to the current chart.
FGAPI fg_err fg_append_surface_to_chart(fg_chart pChart, fg_surface pSurface)
Add an existing surface object to chart.
FGAPI ~Chart()
Chart destructor.
FGAPI VectorField vectorField(const unsigned pNumPoints, const dtype pDataType)
Create and add an Vector Field object to the current chart.
Image is plain rendering of an image over the window or sub-region of it.
Definition: image.h:174
Window is where other objects such as Images, Plots etc.
Definition: window.h:300
void * fg_histogram
Definition: defines.h:44
void * fg_window
Definition: defines.h:40
FGAPI fg_err fg_set_chart_label_format(fg_chart pHandle, const char *pXFormat, const char *pYFormat, const char *pZFormat)
Set the format for display of axes labels in a chart.
Line plot.
Definition: defines.h:161
FGAPI fg_err fg_create_chart(fg_chart *pHandle, const fg_chart_type pChartType)
Create a Chart object with given dimensional property.
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.
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.
fg_dtype
Definition: defines.h:150
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.
FGAPI fg_err fg_add_plot_to_chart(fg_plot *pPlot, fg_chart pHandle, const unsigned pNPoints, const fg_dtype pType, const fg_plot_type pPlotType, const fg_marker_type pMarkerType)
Create and add an Plot object to the current chart.
Histogram is a bar graph to display data frequencey.
Definition: histogram.h:163