Workspace 6.21.5
Public Types | Public Member Functions | List of all members
Plot Class Reference

The plot class holds the information required to generate a 2D plot. More...

#include <DataAnalysis/Plot2D/plot.h>

Public Types

enum  LegendAnchor { PlotBoxTopLeft , PlotBoxTopRight }
 Specifies what anchor point the legend should be relative to. More...
 

Public Member Functions

 Plot ()
 
 Plot (const Plot &)
 
 ~Plot ()
 
void addOverlay (ImageOverlay &overlay)
 
void addPlotItem (const PlotItem &plotItem)
 
void clear ()
 
QStringList findXAxisAutoLimits (double &minimum, double &maximum) const
 
QStringList findXAxisLimits (double &minimum, double &maximum) const
 
QStringList findYAxisAutoLimits (double &minimum, double &maximum) const
 
QStringList findYAxisLimits (double &minimum, double &maximum) const
 
const QFont & getAxesLabelFont () const
 
double getAxesLineWidth () const
 
double getAxesMajorTickLength () const
 
double getAxesMinorTickLength () const
 
const QFont & getAxesTickLabelFont () const
 
const QColor & getBackgroundColor () const
 
double getDataLineWidth () const
 
int getDistBetweenLabels () const
 
bool getDynamicMarginsOveride () const
 
const QColor & getForegroundColor () const
 
LegendAnchor getLegendAnchor () const
 
const QFont & getLegendFont () const
 
const QPoint & getLegendOffset () const
 
int getLongestYLabel () const
 
int getMarginBottom () const
 
int getMarginLeft () const
 
int getMarginRight () const
 
int getMarginTop () const
 
unsigned getNumOverlays () const
 
uint getOpenGLSamples () const
 
const ImageOverlaygetOverlay (unsigned index) const
 
const PlotItemgetPlotItem (unsigned i) const
 
bool getShowLegend () const
 
const QString & getTitle () const
 
const QFont & getTitleFont () const
 
bool getUseOpenGL () const
 
bool getUseTightAutoLimitsForXAxis () const
 
bool getUseTightAutoLimitsForYAxis () const
 
QRect getViewport (const QSize &canvasSize) const
 
const AxisSettingsgetXAxisSettings () const
 
const AxisSettingsgetYAxisSettings () const
 
unsigned numEnabledPlotItems () const
 
unsigned numPlotItems () const
 
Plotoperator= (const Plot &)
 
void removeOverlay (ImageOverlay &overlay)
 
void setAxesLabelFont (const QFont &font)
 
void setAxesLineWidth (double w)
 
void setAxesMajorTickLength (double t)
 
void setAxesMinorTickLength (double t)
 
void setAxesTickLabelFont (const QFont &font)
 
void setBackgroundColor (const QColor &color)
 
void setDataLineWidth (double d)
 
void setDistBetweenLabels (int)
 
void setDynamicMarginsOveride (bool dynamicMarginsOveride)
 
void setForegroundColor (const QColor &color)
 
void setLegendAnchor (LegendAnchor anchor)
 
void setLegendFont (const QFont &font)
 
void setLegendOffset (const QPoint &p)
 
void setLongestYLabel (int longestYLabel)
 
void setMarginBottom (int pixels)
 
void setMarginLeft (int pixels)
 
void setMarginRight (int pixels)
 
void setMarginTop (int pixels)
 
void setOpenGLSamples (uint samples)
 
void setShowLegend (bool b)
 
void setTitle (const QString &title)
 
void setTitleFont (const QFont &font)
 
void setUseOpenGL (bool use)
 
void setUseTightAutoLimitsForXAxis (bool use)
 
void setUseTightAutoLimitsForYAxis (bool use)
 
void setXAxisSettings (const AxisSettings &axisSettings)
 
void setYAxisSettings (const AxisSettings &axisSettings)
 

Detailed Description

The Plot class acts as a container holding everything needed for some other class to generate the actual plot image. The data stored in the Plot class includes:

Member Enumeration Documentation

◆ LegendAnchor

Enumerator
PlotBoxTopLeft 

The legend offset is relative to the top-left corner of the plot box. The legend will typically be drawn over the plot, hopefully with an offset that puts the legend in a region where no data is plotted!

PlotBoxTopRight 

The legend offset is relative to the top-right corner of the plot box. This is particularly useful for putting the legend to the right of the plot box when the right hand margin is sufficiently wide.

Constructor & Destructor Documentation

◆ Plot() [1/2]

Plot ( )

◆ Plot() [2/2]

Plot ( const Plot plot)

◆ ~Plot()

~Plot ( )

Member Function Documentation

◆ addOverlay()

void addOverlay ( ImageOverlay overlay)
Parameters
overlayThe overlay to add to the plot

Adds an image overlay to the plot which will be displayed on top of the plot data.

◆ addPlotItem()

void addPlotItem ( const PlotItem plotItem)
Parameters
plotItemThe item to add to the plot. This will be copied, but note that only a pointer to the data collection within the item is copied (ie a shallow copy). Thus, while the plotItem does not have to survive after this call, the data collection it refers to must.

◆ clear()

void clear ( )

Removes all plot items from the plot. If you also want to reset the axes and legend to their default settings, you should assign a default constructed plot instead of calling clear().

◆ findXAxisAutoLimits()

QStringList findXAxisAutoLimits ( double &  minimum,
double &  maximum 
) const

◆ findXAxisLimits()

QStringList findXAxisLimits ( double &  minimum,
double &  maximum 
) const
Parameters
minimumOn exit, this will hold the minimum of the X axis. The value on entry will be ignored.
maximumOn exit, this will hold the maximum of the X axis. The value on entry will be ignored.
Returns
A list of error and warning messages generated as part of working out the axis limits. It is guaranteed that there will be no duplicate messages.
Postcondition
minimum will be less than maximum and if the axis is using a logarithmic scale, both minimum and maximum will be positive numbers.

◆ findYAxisAutoLimits()

QStringList findYAxisAutoLimits ( double &  minimum,
double &  maximum 
) const

◆ findYAxisLimits()

QStringList findYAxisLimits ( double &  minimum,
double &  maximum 
) const
Parameters
minimumOn exit, this will hold the minimum of the Y axis. The value on entry will be ignored.
maximumOn exit, this will hold the maximum of the Y axis. The value on entry will be ignored.
Returns
A list of error and warning messages generated as part of working out the axis limits. It is guaranteed that there will be no duplicate messages.
Postcondition
minimum will be less than maximum and if the axis is using a logarithmic scale, both minimum and maximum will be positive numbers.

◆ getAxesLabelFont()

const QFont & getAxesLabelFont ( ) const
Returns
The font being used for axis labels.
See also
setAxesLabelFont(), getAxesTickLabelFont()

◆ getAxesLineWidth()

double getAxesLineWidth ( ) const
Returns
The width of lines used to draw the axes. The width of any tick marks is also based on this value.
See also
setAxesLineWidth()

◆ getAxesMajorTickLength()

double getAxesMajorTickLength ( ) const
Returns
The length of any major tick marks on the axes.
See also
setMajorTickLength(), getMinorTickLength()

◆ getAxesMinorTickLength()

double getAxesMinorTickLength ( ) const
Returns
The length of any minor tick marks on the axes.
See also
setMinorTickLength(), getMajorTickLength()

◆ getAxesTickLabelFont()

const QFont & getAxesTickLabelFont ( ) const
Returns
The font being used for axis tick labels.
See also
setAxesTickLabelFont(), getAxesLabelFont()

◆ getBackgroundColor()

const QColor & getBackgroundColor ( ) const
Returns
The currently set background color.
See also
setBackgroundColor(), getForegroundColor()

◆ getDataLineWidth()

double getDataLineWidth ( ) const
Returns
The line width for the plotted data.
See also
setDataLineWidth()

◆ getDistBetweenLabels()

int getDistBetweenLabels ( ) const
Returns
Number of pixels that will seperate labels
See also
setDistBetweenLabels()

◆ getDynamicMarginsOveride()

bool getDynamicMarginsOveride ( ) const

◆ getForegroundColor()

const QColor & getForegroundColor ( ) const
Returns
The currently set foreground color.
See also
setForegroundColor(), getBackgroundColor()

◆ getLegendAnchor()

Plot::LegendAnchor getLegendAnchor ( ) const
Returns
The anchor point for the legend. The legend offset will be relative to this anchor point.
See also
setLegendAnchor(), getLegendOffset()

◆ getLegendFont()

const QFont & getLegendFont ( ) const
Returns
The font to be used for the legend labels.
See also
setLegendFont()

◆ getLegendOffset()

const QPoint & getLegendOffset ( ) const
Returns
The offset from the legend's anchor point at which the legend should be drawn.
See also
setLegendOffset(), getLegendAnchor()

◆ getLongestYLabel()

int getLongestYLabel ( ) const
Returns
Width of the longest tick label of Y-axis
See also
setLongestYLabel()

◆ getMarginBottom()

int getMarginBottom ( ) const

◆ getMarginLeft()

int getMarginLeft ( ) const

◆ getMarginRight()

int getMarginRight ( ) const

◆ getMarginTop()

int getMarginTop ( ) const

◆ getNumOverlays()

unsigned getNumOverlays ( ) const
Returns
The number of overlays attached to the plot.

◆ getOpenGLSamples()

uint getOpenGLSamples ( ) const

◆ getOverlay()

const ImageOverlay & getOverlay ( unsigned  index) const
Parameters
indexThe index of the overlay to retrieve.
Returns
the overlay corresponding to the specified index.

◆ getPlotItem()

const PlotItem & getPlotItem ( unsigned  index) const
Returns
The plot item at the specified index.
Precondition
index must be less than the result returned from numPlotItems().

◆ getShowLegend()

bool getShowLegend ( ) const
Returns
True if the legend will be shown.
See also
setShowLegend()

◆ getTitle()

const QString & getTitle ( ) const
Returns
The title currently set for the plot.

◆ getTitleFont()

const QFont & getTitleFont ( ) const
Returns
The font being used for the plot title.
See also
setTitleFont()

◆ getUseOpenGL()

bool getUseOpenGL ( ) const

◆ getUseTightAutoLimitsForXAxis()

bool getUseTightAutoLimitsForXAxis ( ) const

◆ getUseTightAutoLimitsForYAxis()

bool getUseTightAutoLimitsForYAxis ( ) const

◆ getViewport()

QRect getViewport ( const QSize &  canvasSize) const

◆ getXAxisSettings()

const AxisSettings & getXAxisSettings ( ) const
Returns
The settings specific to the X axis.

◆ getYAxisSettings()

const AxisSettings & getYAxisSettings ( ) const
Returns
The settings specific to the Y axis.

◆ numEnabledPlotItems()

unsigned numEnabledPlotItems ( ) const
Returns
The number of enabled items in the plot.

◆ numPlotItems()

unsigned numPlotItems ( ) const
Returns
The number of items in the plot.

◆ operator=()

Plot & operator= ( const Plot plot)

◆ removeOverlay()

void removeOverlay ( ImageOverlay overlay)
Parameters
overlayThe overlay to remove from the plot.

◆ setAxesLabelFont()

void setAxesLabelFont ( const QFont &  font)
Parameters
fontThe font to use for axis labels.
See also
getAxesLabelFont(), setAxesTickLabelFont()

◆ setAxesLineWidth()

void setAxesLineWidth ( double  w)
Parameters
wThe width of lines used to draw the axes. The width of any tick marks is also based on this value, but will typically be smaller than w.
See also
getAxesLineWidth()

◆ setAxesMajorTickLength()

void setAxesMajorTickLength ( double  t)
Parameters
tThe length of any major tick marks on the axes. These would normally be longer than the minor tick length.
See also
getMajorTickLength(), setMinorTickLength()

◆ setAxesMinorTickLength()

void setAxesMinorTickLength ( double  t)
Parameters
tThe length of any minor tick marks on the axes. These would normally be shorter than the major tick length.
See also
getMinorTickLength(), setMajorTickLength()

◆ setAxesTickLabelFont()

void setAxesTickLabelFont ( const QFont &  font)
Parameters
fontThe font to use for axis tick labels.
See also
getAxesLabelFont(), setAxesTickLabelFont()

◆ setBackgroundColor()

void setBackgroundColor ( const QColor &  color)
Parameters
colorThe color to use for the background of the plot. Note that a fully transparent color can be useful when overlaying the plot onto something else, such as a watermark image. Otherwise, white or in some cases black backgrounds are recommended. The default is white, since the default line color for plot items is black.
See also
getBackgroundColor(), setForegroundColor()

◆ setDataLineWidth()

void setDataLineWidth ( double  d)
Parameters
dThe line width for the plotted data.
See also
getDataLineWidth()

◆ setDistBetweenLabels()

void setDistBetweenLabels ( int  distBetweenLabels)
Parameters
distBetweenLabelsNumber of pixels that will seperate labels
See also
getDistBetweenLabels()

◆ setDynamicMarginsOveride()

void setDynamicMarginsOveride ( bool  dynamicMarginsOveride)
Parameters
dynamicMarginsOverideFlag to overide margins to make room for plot labels
See also
getDynamicMarginsOveride()

◆ setForegroundColor()

void setForegroundColor ( const QColor &  color)
Parameters
colorThe color to use for the axes and title of the plot. The foreground color applies to all axis labels, lines and tick marks. The default is black.
See also
getForegroundColor(), setBackgroundColor()

◆ setLegendAnchor()

void setLegendAnchor ( Plot::LegendAnchor  anchor)
Parameters
anchorThe anchor point for the legend. The legend offset will be relative to this anchor point.
See also
getLegendAnchor(), setLegendOffset()

◆ setLegendFont()

void setLegendFont ( const QFont &  font)
Parameters
fontThe font to use for the labels in the legend. The labels will use the plot's foreground color whereas the lines and glyphs will use each item's color.
See also
getLegendFont()

◆ setLegendOffset()

void setLegendOffset ( const QPoint &  p)
Parameters
pThe offset from the legend's anchor point at which the legend should be drawn. This will be the top-left of the invisible box around the legend.
See also
getLegendOffset(), setLegendAnchor()

◆ setLongestYLabel()

void setLongestYLabel ( int  longestYLabel)
Parameters
longestYLabelWidth of the longest tick label of Y-axis
See also
getLongestYLabel()

◆ setMarginBottom()

void setMarginBottom ( int  pixels)

◆ setMarginLeft()

void setMarginLeft ( int  pixels)

◆ setMarginRight()

void setMarginRight ( int  pixels)

◆ setMarginTop()

void setMarginTop ( int  pixels)

◆ setOpenGLSamples()

void setOpenGLSamples ( uint  samples)

◆ setShowLegend()

void setShowLegend ( bool  b)
Parameters
bIf set to true, the legend will be shown.
See also
getShowLegend()

◆ setTitle()

void setTitle ( const QString &  title)
Parameters
titleThe new title for the plot.
See also
getTitle()

◆ setTitleFont()

void setTitleFont ( const QFont &  font)
Parameters
fontThe font to use for the plot title.
See also
getTitleFont()

◆ setUseOpenGL()

void setUseOpenGL ( bool  use)

◆ setUseTightAutoLimitsForXAxis()

void setUseTightAutoLimitsForXAxis ( bool  use)

◆ setUseTightAutoLimitsForYAxis()

void setUseTightAutoLimitsForYAxis ( bool  use)

◆ setXAxisSettings()

void setXAxisSettings ( const AxisSettings settings)
Parameters
settingsThe axis-specific settings to use for the X axis.

◆ setYAxisSettings()

void setYAxisSettings ( const AxisSettings settings)
Parameters
settingsThe axis-specific settings to use for the Y axis.