Qwt User's Guide: QwtPlotRescaler Class Reference

Qwt User's Guide 6.1.4

Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotRescaler Class Reference

QwtPlotRescaler takes care of fixed aspect ratios for plot scales. More...

`#include <qwt_plot_rescaler.h>`

Inheritance diagram for QwtPlotRescaler:
[legend]

## Public Types
enum | RescalePolicy { Fixed, Expanding, Fitting }
enum | ExpandingDirection { ExpandUp, ExpandDown, ExpandBoth }

## Public Member Functions
| QwtPlotRescaler (QWidget *canvas, int referenceAxis=QwtPlot::xBottom, RescalePolicy=Expanding)
virtual | ~QwtPlotRescaler ()
| Destructor.
void | setEnabled (bool)
| En/disable the rescaler. More...
bool | isEnabled () const
void | setRescalePolicy (RescalePolicy)
RescalePolicy | rescalePolicy () const
void | setExpandingDirection (ExpandingDirection)
void | setExpandingDirection (int axis, ExpandingDirection)
ExpandingDirection | expandingDirection (int axis) const
void | setReferenceAxis (int axis)
int | referenceAxis () const
void | setAspectRatio (double ratio)
void | setAspectRatio (int axis, double ratio)
double | aspectRatio (int axis) const
void | setIntervalHint (int axis, const QwtInterval &)
QwtInterval | intervalHint (int axis) const
QWidget * | canvas ()
const QWidget * | canvas () const
QwtPlot * | plot ()
const QwtPlot * | plot () const
virtual bool | eventFilter (QObject *, QEvent *)
| Event filter for the plot canvas.
void | rescale () const
| Adjust the plot axes scales.

## Protected Member Functions
virtual void | canvasResizeEvent (QResizeEvent *)
virtual void | rescale (const QSize &oldSize, const QSize &newSize) const
virtual QwtInterval | expandScale (int axis, const QSize &oldSize, const QSize &newSize) const
virtual QwtInterval | syncScale (int axis, const QwtInterval &reference, const QSize &size) const
virtual void | updateScales (QwtInterval intervals[QwtPlot::axisCnt]) const
Qt::Orientation | orientation (int axis) const
QwtInterval | interval (int axis) const
QwtInterval | expandInterval (const QwtInterval &, double width, ExpandingDirection) const

## Detailed Description

QwtPlotRescaler takes care of fixed aspect ratios for plot scales.

QwtPlotRescaler auto adjusts the axes of a QwtPlot according to fixed aspect ratios.

## Member Enumeration Documentation

## ◆ ExpandingDirection

enum QwtPlotRescaler::ExpandingDirection

When rescalePolicy() is set to Expanding its direction depends on ExpandingDirection

Enumerator
ExpandUp | The upper limit of the scale is adjusted.
ExpandDown | The lower limit of the scale is adjusted.
ExpandBoth | Both limits of the scale are adjusted.

## ◆ RescalePolicy

enum QwtPlotRescaler::RescalePolicy

The rescale policy defines how to rescale the reference axis and their depending axes.

See also
  ExpandingDirection, setIntervalHint()

Enumerator
Fixed | The interval of the reference axis remains unchanged, when the geometry of the canvas changes. All other axes will be adjusted according to their aspect ratio.
Expanding | The interval of the reference axis will be shrunk/expanded, when the geometry of the canvas changes. All other axes will be adjusted according to their aspect ratio. The interval, that is represented by one pixel is fixed.
Fitting | The intervals of the axes are calculated, so that all axes include their interval hint.

## Constructor & Destructor Documentation

## ◆ QwtPlotRescaler()

QwtPlotRescaler::QwtPlotRescaler | ( | QWidget * | canvas,
|  | int | referenceAxis = `QwtPlot::xBottom`,
|  | RescalePolicy | policy = `Expanding`
| ) |  |
| explicit

Constructor

Parameters

  canvas | Canvas
  referenceAxis | Reference axis, see RescalePolicy
  policy | Rescale policy

See also
  setRescalePolicy(), setReferenceAxis()

## Member Function Documentation

## ◆ aspectRatio()

double QwtPlotRescaler::aspectRatio | ( | int | axis | ) | const

Returns
  Aspect ratio between an axis and the reference axis.

Parameters

  axis | Axis index ( see QwtPlot::AxisId )

See also
  setAspectRatio()

## ◆ canvas() [1/2]

QWidget * QwtPlotRescaler::canvas | ( |  | ) |

Returns
  plot canvas

## ◆ canvas() [2/2]

const QWidget * QwtPlotRescaler::canvas | ( |  | ) | const

Returns
  plot canvas

## ◆ canvasResizeEvent()

void QwtPlotRescaler::canvasResizeEvent | ( | QResizeEvent * | event | ) |
| protectedvirtual

Event handler for resize events of the plot canvas

Parameters

  event | Resize event

See also
  rescale()

## ◆ expandingDirection()

QwtPlotRescaler::ExpandingDirection QwtPlotRescaler::expandingDirection | ( | int | axis | ) | const

Returns
  Direction in which an axis should be expanded

Parameters

  axis | Axis index ( see QwtPlot::AxisId )

See also
  setExpandingDirection()

## ◆ expandInterval()

QwtInterval QwtPlotRescaler::expandInterval | ( | const QwtInterval & | interval,
|  | double | width,
|  | ExpandingDirection | direction
| ) |  | const
| protected

Expand the interval

Parameters

  interval | Interval to be expanded
  width | Distance to be added to the interval
  direction | Direction of the expand operation

Returns
  Expanded interval

## ◆ expandScale()

QwtInterval QwtPlotRescaler::expandScale | ( | int | axis,
|  | const QSize & | oldSize,
|  | const QSize & | newSize
| ) |  | const
| protectedvirtual

Calculate the new scale interval of a plot axis

Parameters

  axis | Axis index ( see QwtPlot::AxisId )
  oldSize | Previous size of the canvas
  newSize | New size of the canvas

Returns
  Calculated new interval for the axis

## ◆ interval()

QwtInterval QwtPlotRescaler::interval | ( | int | axis | ) | const
| protected

Parameters

  axis | Axis index ( see QwtPlot::AxisId )

Returns
  Normalized interval of an axis

## ◆ intervalHint()

QwtInterval QwtPlotRescaler::intervalHint | ( | int | axis | ) | const

Parameters

  axis | Axis, see QwtPlot::Axis

Returns
  Interval hint

See also
  setIntervalHint(), RescalePolicy

## ◆ isEnabled()

bool QwtPlotRescaler::isEnabled | ( |  | ) | const

Returns
  true when enabled, false otherwise

See also
  setEnabled, eventFilter()

## ◆ orientation()

Qt::Orientation QwtPlotRescaler::orientation | ( | int | axis | ) | const
| protected

Returns
  Orientation of an axis

Parameters

  axis | Axis index ( see QwtPlot::AxisId )

## ◆ plot() [1/2]

QwtPlot * QwtPlotRescaler::plot | ( |  | ) |

Returns
  plot widget

## ◆ plot() [2/2]

const QwtPlot * QwtPlotRescaler::plot | ( |  | ) | const

Returns
  plot widget

## ◆ referenceAxis()

int QwtPlotRescaler::referenceAxis | ( |  | ) | const

Returns
  Reference axis ( see RescalePolicy )

See also
  setReferenceAxis()

## ◆ rescale()

void QwtPlotRescaler::rescale | ( | const QSize & | oldSize,
|  | const QSize & | newSize
| ) |  | const
| protectedvirtual

Adjust the plot axes scales

Parameters

  oldSize | Previous size of the canvas
  newSize | New size of the canvas

## ◆ rescalePolicy()

QwtPlotRescaler::RescalePolicy QwtPlotRescaler::rescalePolicy | ( |  | ) | const

Returns
  Rescale policy

See also
  setRescalePolicy()

## ◆ setAspectRatio() [1/2]

void QwtPlotRescaler::setAspectRatio | ( | double | ratio | ) |

Set the aspect ratio between the scale of the reference axis and the other scales. The default ratio is 1.0

Parameters

  ratio | Aspect ratio

See also
  aspectRatio()

## ◆ setAspectRatio() [2/2]

void QwtPlotRescaler::setAspectRatio | ( | int | axis,
|  | double | ratio
| ) |  |

Set the aspect ratio between the scale of the reference axis and another scale. The default ratio is 1.0

Parameters

  axis | Axis index ( see QwtPlot::AxisId )
  ratio | Aspect ratio

See also
  aspectRatio()

## ◆ setEnabled()

void QwtPlotRescaler::setEnabled | ( | bool | on | ) |

En/disable the rescaler.

When enabled is true an event filter is installed for the canvas, otherwise the event filter is removed.

Parameters

  on | true or false

See also
  isEnabled(), eventFilter()

## ◆ setExpandingDirection() [1/2]

void QwtPlotRescaler::setExpandingDirection | ( | ExpandingDirection | direction | ) |

Set the direction in which all axis should be expanded

Parameters

  direction | Direction

See also
  expandingDirection()

## ◆ setExpandingDirection() [2/2]

void QwtPlotRescaler::setExpandingDirection | ( | int | axis,
|  | ExpandingDirection | direction
| ) |  |

Set the direction in which an axis should be expanded

Parameters

  axis | Axis index ( see QwtPlot::AxisId )
  direction | Direction

See also
  expandingDirection()

## ◆ setIntervalHint()

void QwtPlotRescaler::setIntervalHint | ( | int | axis,
|  | const QwtInterval & | interval
| ) |  |

Set an interval hint for an axis

In Fitting mode, the hint is used as minimal interval that always needs to be displayed.

Parameters

  axis | Axis, see QwtPlot::Axis
  interval | Axis

See also
  intervalHint(), RescalePolicy

## ◆ setReferenceAxis()

void QwtPlotRescaler::setReferenceAxis | ( | int | axis | ) |

Set the reference axis ( see RescalePolicy )

Parameters

  axis | Axis index ( QwtPlot::Axis )

See also
  referenceAxis()

## ◆ setRescalePolicy()

void QwtPlotRescaler::setRescalePolicy | ( | RescalePolicy | policy | ) |

Change the rescale policy

Parameters

  policy | Rescale policy

See also
  rescalePolicy()

## ◆ syncScale()

QwtInterval QwtPlotRescaler::syncScale | ( | int | axis,
|  | const QwtInterval & | reference,
|  | const QSize & | size
| ) |  | const
| protectedvirtual

Synchronize an axis scale according to the scale of the reference axis

Parameters

  axis | Axis index ( see QwtPlot::AxisId )
  reference | Interval of the reference axis
  size | Size of the canvas

Returns
  New interval for axis

## ◆ updateScales()

void QwtPlotRescaler::updateScales | ( | QwtInterval | intervals[QwtPlot::axisCnt] | ) | const
| protectedvirtual

Update the axes scales

Parameters

  intervals | Scale intervals