![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/GlPlotView.h>
View for plotting data. More...
View for plotting data.
Code examples for using GlPlotView:
Classes | |
struct | PlotInfo |
Data for a single plot handle. More... | |
Public Types | |
enum | Coordinate { X , Y , Z } |
Convenience enum for classification of coordinates. | |
enum | SelectionFocusMarkerStyle { DEFAULT_STYLE = -1 , DISABLED = 0 , CROSSES , VERTICAL_LINE , NR_STYLES } |
Configure the appearance of the focus marker. | |
enum | LogarithmicAxes { None = 0 , LogX = 1 , LogY = 2 , LogXY = 3 } |
Options for logarithmic scaling of axes. More... | |
enum | Marker { Point , Square , Cross , Triangle , NoMarker } |
Marker types for 2d plotting. | |
enum | LineStyle { Solid , Dashed , Bar , NoLine } |
Line styles for 2d plotting. | |
![]() | |
enum | Type { SLICE2D = 0 , SLICE3D = 1 , SPACE3D = 2 , OTHER = 3 } |
Type of the view. More... | |
Public Member Functions | |
template<typename T> | |
int | addPlot2d (int size, const T *x, const T *y, const std::string &style="r-", bool fit=false, bool sort=true) |
Add a 2d plot to the plot view by passing x and y values, takes ownership of data. | |
template<typename T> | |
int | addPlot2d (int size, const T *y, const std::string &style="r-", bool fit=false, bool sort=true) |
Add a 2d plot to the plot view by just passing y values (array of size size) The corresponding x values are set automatically as the sample indices from 0 to size-1. | |
template<typename T> | |
int | addPlot2d (const std::vector< T > &y, const std::string &style="r-", bool fit=false, bool sort=true) |
Add a 2d plot using y vector, see above for details. | |
template<typename T> | |
int | addPlot2d (const std::vector< T > &x, const std::vector< T > &y, const std::string &style="r-", bool fit=false, bool sort=true) |
Add a 2d plot using x and y vectors, see above for details. | |
int | addPlot2d (const Tensor< 1 > *xPtr, const Tensor< 1 > &y, const std::string &style="r-", bool fit=false, bool sort=true) |
Add a 2d plot using x and y rank 1 tensors, see above for details. | |
template<typename T> | |
void | updatePlot2d (int handle, const T *y) |
Updates the existing y values of a 2d plot with the passed y values. Passed y-array has to be of the same size as the existing plot. | |
void | addValuePlot2d (int handle, double y) |
Add a single Y data point to an existing plot. | |
void | addValuePlot2d (int handle, double x, double y, bool sort=true) |
Add a single X/Y data point to an existing plot. | |
void | clearPlot (int handle) |
Clear the data for an existing plot but keep the handle and attributes. | |
int | plotCount () const |
Return number of plots. | |
std::string | getNextUnusedStyle (bool allowAutoColors=false) const |
Returns the next unused style string using solid line or dashes. If allowAutoColors is set, the "o" (other) color flag may be used. | |
template<typename T> | |
int | addPlot3d (int size, const T *x, const T *y, const T *z, const std::string &style="r") |
Add a 3d plot to the plot view by passing x, y, z values, does not take ownership of data. | |
void | removePlot (int handle) |
Removes the plot for the given handle from the view. | |
void | clear () |
Clears all plots from the view. | |
void | setTitle (const std::string &title) |
Set the title of the plot view. | |
void | setLabels (const std::string &lx, const std::string &ly) |
Sets the labels of x- and y-axis. | |
void | setGrid (const bool grid, const bool halfGrid=false, const bool showNumbers=true, const bool dataGrid=true) |
Set the grid size along each axis, i.e. the number of grid lines an axis is split up into. | |
void | setGridSize (const int gridSizeX=10, const int gridSizeY=10, const int gridSizeZ=10) |
Set the grid size along each axis, i.e. the number of grid lines an axis is split up into. | |
void | setAdjustBounds (const bool rescale) |
Rescales min and max of the plot view to have a better scale at the axes. | |
void | setBounds (Coordinate coord, double min, double max) |
Set bounds (min/max values) for selected axis. | |
void | resetBounds () |
Reset bounds. | |
vec4 | bounds2D () const |
vec2 | extent2D () const |
void | setBounds2D (const vec4 &bounds) |
const double * | bounds () const |
void | setAxisEqual (const bool axisEqual) |
Makes x- and y-axis of equal scale (e.g. to avoid distorting circles) | |
void | setHeatmap (const bool heatMapOn) |
Sets whether the colors are based on a heat map, only in 3d plotting. | |
void | setFlatShaded (const bool optFlatShaded) |
Sets flat shading. | |
void | setIsolines (const bool iso) |
Sets isolines. | |
void | setBarWidth (const unsigned int width) |
Sets histogram bar width. | |
void | setXAxisRefersToSelection (bool on) |
In some scenarios, x-data of a 2D plot directly corresponds to the image set data of an algorithm. | |
bool | xAxisRefersToSelection () const |
void | updateSelectionFocusMarker (int focus) |
Update the selection focus marker. | |
void | setFocusImage (const SharedImageSet &img) |
void | setSelectionFocusMarkerStyle (int style, const std::string &color="w") |
int | selectionFocusMarkerStyle () const |
void | setLogarithmicAxes (LogarithmicAxes logAxes, bool refresh=false) |
Sets options for logarithmic scaling of axes. | |
LogarithmicAxes | logAxes () const |
bool | render () override |
Renders the plots on the view. If a LogAxes option is set, invalid coordinates will be skipped. | |
void | reset () |
Reset settings to their default values. | |
std::string | title () |
Get the title of the plot view. | |
Type | type () const override |
Return the type of this view. | |
virtual std::string | typeName () const |
bool | exportPlotsCsv (const std::string &filename) |
Export plots as CSV file. | |
std::string | markerToString (Marker m) const |
Converts a Marker value to the corresponding string, e.g. Cross becomes "+". | |
std::string | lineStyleToString (LineStyle l) const |
Convert a LineStyle value to the corresponding string, e.g. Solid becomes "-". | |
std::string | colorToString (const vec3 &color) const |
bool | setLineStyle (int handle, LineStyle style) |
bool | setMarkerStyle (int handle, Marker style) |
bool | setColor (int handle, const vec3 &color) |
std::string | styleToString (const PlotInfo &pi) const |
const std::vector< PlotInfo > & | plotData () const |
Read access to all the plot data. | |
bool | plotData (int handle, PlotInfo &plot) const |
Fetch copy of PlotInfo with specified handle. | |
bool | is3D () const |
Fetch information if plots are 3D or not. | |
bool | hasHistogramPlot () const |
Finds out if this GlPlotView contains one or more histograms (i.e. PlotInfos with LineStyle::Bar) | |
void | setWhiteBackgroundOverride (bool toWhite) |
Toggle background color between white and global background color. | |
vec2 | screenPixelToCoord (const vec2 &pixel) const |
vec2 | coordToScreenPixel (const vec2 &coord) const |
void | setMousePosition (const vec2i &val) |
void | setShowLabelAtCursor (bool v) |
void | setShowAllLabels (bool v) |
void | setPointLabels (int idx, const std::vector< std::string > &labels) |
bool | computeSpectrum (const PlotInfo &plot, std::vector< double > &Out, std::vector< double > &freqOut) const |
![]() | |
virtual void | setMatrix (const mat4 &mat) |
Sets the view matrix (view coordinates to world coordinates). | |
virtual const mat4 & | matrix () const |
Returns the current view matrix (view coordinates to world coordinates). | |
virtual void | resize (int width, int height) |
Set a new viewport size for this view. | |
virtual const GL::OrderIndependentTransparency * | orderIndependentTransparency () const |
Returns the optional OIT manager instance of the view if the feature is supported and enabled. | |
int | height () const |
Current viewport height of the view. | |
int | width () const |
Current viewport width of the view. | |
void | addObject (GlObject *object) |
Add a reference to a GlObject to be drawn by this view. | |
void | removeObject (GlObject *object) |
Remove a reference to a GlObject drawn by this view. | |
const std::vector< GlObject * > & | objects () const |
Return the set of GlObjects that are drawn by this view. | |
const GL::ViewState & | state () const |
Return the view state that was set during the last render() call. | |
Additional Inherited Members | |
![]() | |
GL::OrderIndependentTransparency * | sharedOitInstance () const |
Offers support for GlViews sharing GL::OrderIndependentTransparency instances to reduce GPU memory consumption. | |
![]() | |
std::vector< GlObject * > | m_objects |
Other objects to consider during rendering. | |
mat4 | m_matrix = mat4::Identity() |
Matrix converting view coordinates to world coords (inverse of a traditional OpenGL view matrix) | |
GL::ViewState | m_state |
OpenGL state describing viewport, projection and model-view matrix of last render call. | |
int | m_width = 0 |
int | m_height = 0 |
enum LogarithmicAxes |
Options for logarithmic scaling of axes.
int addPlot2d | ( | int | size, |
const T * | x, | ||
const T * | y, | ||
const std::string & | style = "r-", | ||
bool | fit = false, | ||
bool | sort = true ) |
Add a 2d plot to the plot view by passing x and y values, takes ownership of data.
The buffer of both arrays needs to be of size size and hence represents a size x 1 vector. Color, line style and marker of the plot can be defined by supplying the format string style, which is a combination of characters. (colors: r, g, b, c, m, y, k, w; line styles: -=solid, .=dashed, n=none, |=bar; markers: +=cross, *=point, s=square, t=triangle; marker sizes: 1 to 9, default=3) Returns a handle that can be used to remove or update the plot.
int addPlot2d | ( | int | size, |
const T * | y, | ||
const std::string & | style = "r-", | ||
bool | fit = false, | ||
bool | sort = true ) |
Add a 2d plot to the plot view by just passing y values (array of size size) The corresponding x values are set automatically as the sample indices from 0 to size-1.
Returns a handle that can be used to remove or update the plot.
int addPlot3d | ( | int | size, |
const T * | x, | ||
const T * | y, | ||
const T * | z, | ||
const std::string & | style = "r" ) |
Add a 3d plot to the plot view by passing x, y, z values, does not take ownership of data.
The buffer of all three arrays needs to be of size size*size. The format string in style so far only supports colors. Returns a handle that can be used to remove or update the plot. Note that the data points do not have to fall onto an orthonormal grid, which is why the x and y positions for each point have to be given individually. Also note that nonetheless the points are assumed to be on a sorted grid by the rendering code.
|
inline |
In some scenarios, x-data of a 2D plot directly corresponds to the image set data of an algorithm.
The position of the currently focused image can be marked for better visualization. To this end, the controller that owns the plotview needs to derive from SelectionListener. The listener needs to be added to the image data of the corresponding algorithm (and removed in the destructor). Override the selectionChanged() method to glPlotView->updateSelectionFocusMarker
(m_images->focus()); In the Controller::init()
, set the flag setXAxisRefersToSelection
and an optional marker style.
void updateSelectionFocusMarker | ( | int | focus | ) |
Update the selection focus marker.
This should be called from the selectionChanged()
method of the controller.
focus | Index of the focus image. |
void setLogarithmicAxes | ( | LogarithmicAxes | logAxes, |
bool | refresh = false ) |
Sets options for logarithmic scaling of axes.
refresh | Pass false if computation of bounds is not necessary (e.g. right after construction of PlotView) |
|
overridevirtual |
Renders the plots on the view. If a LogAxes option is set, invalid coordinates will be skipped.
Implements GlView.
bool plotData | ( | int | handle, |
PlotInfo & | plot ) const |
Fetch copy of PlotInfo with specified handle.