QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | 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:

Classes

class  AxisData
 
class  PrivateData
 

Public Types

enum  RescalePolicy { Fixed , Expanding , Fitting }
 Rescale policies. More...
 
enum  ExpandingDirection { ExpandUp , ExpandDown , ExpandBoth }
 Expanding directions. More...
 

Public Member Functions

 QwtPlotRescaler (QWidget *canvas, QwtAxisId referenceAxis=QwtAxis::XBottom, RescalePolicy=Expanding)
 Constructs a rescaler for the given canvas.
 
void setEnabled (bool)
 Enables or disables the rescaler.
 
bool isEnabled () const
 Checks if the rescaler is enabled.
 
void setRescalePolicy (RescalePolicy)
 Sets the rescale policy.
 
RescalePolicy rescalePolicy () const
 Gets the rescale policy.
 
void setExpandingDirection (ExpandingDirection)
 Sets the expanding direction for all axes.
 
void setExpandingDirection (QwtAxisId, ExpandingDirection)
 Sets the expanding direction for a specific axis.
 
ExpandingDirection expandingDirection (QwtAxisId) const
 Gets the expanding direction for a specific axis.
 
void setReferenceAxis (QwtAxisId)
 Sets the reference axis.
 
QwtAxisId referenceAxis () const
 Gets the reference axis.
 
void setAspectRatio (double ratio)
 Sets the aspect ratio for all axes.
 
void setAspectRatio (QwtAxisId, double ratio)
 Sets the aspect ratio for a specific axis.
 
double aspectRatio (QwtAxisId) const
 Gets the aspect ratio for a specific axis.
 
void setIntervalHint (QwtAxisId, const QwtInterval &)
 Sets an interval hint for an axis.
 
QwtInterval intervalHint (QwtAxisId) const
 Gets the interval hint for an axis.
 
QWidget * canvas ()
 Gets the canvas widget.
 
const QWidget * canvas () const
 Gets the canvas widget (const version)
 
QwtPlotplot ()
 Gets the plot widget.
 
const QwtPlotplot () const
 Gets the plot widget (const version)
 
virtual bool eventFilter (QObject *, QEvent *) override
 Event filter for the plot canvas.
 
void rescale () const
 Rescales the plot axes.
 

Protected Member Functions

virtual void canvasResizeEvent (QResizeEvent *)
 Event handler for resize events of the plot canvas.
 
virtual void rescale (const QSize &oldSize, const QSize &newSize) const
 Adjust the plot axes scales.
 
virtual QwtInterval expandScale (QwtAxisId, const QSize &oldSize, const QSize &newSize) const
 Calculate the new scale interval of a plot axis.
 
virtual QwtInterval syncScale (QwtAxisId, const QwtInterval &reference, const QSize &size) const
 Synchronize an axis scale according to the scale of the reference axis.
 
virtual void updateScales (QwtInterval intervals[QwtAxis::AxisPositions]) const
 Update the axes scales.
 
Qt::Orientation orientation (QwtAxisId) const
 
QwtInterval interval (QwtAxisId) const
 
QwtInterval expandInterval (const QwtInterval &, double width, ExpandingDirection) const
 Expand the interval.
 

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

Expanding directions.

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

Rescale policies.

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,
QwtAxisId  referenceAxis = QwtAxis::XBottom,
RescalePolicy  policy = Expanding 
)
explicit

Constructs a rescaler for the given canvas.

Parameters
[in]canvasCanvas widget
[in]referenceAxisReference axis, see RescalePolicy
[in]policyRescale policy
See also
setRescalePolicy(), setReferenceAxis()

Destructs the rescaler

Member Function Documentation

◆ aspectRatio()

double QwtPlotRescaler::aspectRatio ( QwtAxisId  axisId) const

Gets the aspect ratio for a specific axis.

Parameters
[in]axisIdAxis identifier
Returns
Aspect ratio between the specified axis and the reference axis
See also
setAspectRatio()

◆ canvas() [1/2]

QWidget * QwtPlotRescaler::canvas ( )

Gets the canvas widget.

Returns
Canvas widget

◆ canvas() [2/2]

const QWidget * QwtPlotRescaler::canvas ( ) const

Gets the canvas widget (const version)

Returns
Canvas widget (const)

◆ canvasResizeEvent()

void QwtPlotRescaler::canvasResizeEvent ( QResizeEvent *  event)
protectedvirtual

Event handler for resize events of the plot canvas.

Parameters
eventResize event
See also
rescale()

◆ eventFilter()

bool QwtPlotRescaler::eventFilter ( QObject *  object,
QEvent *  event 
)
overridevirtual

Event filter for the plot canvas.

Handles resize and polish request events for the canvas.

Parameters
[in]objectObject that received the event
[in]eventEvent that was received
Returns
false to allow further processing of the event

◆ expandingDirection()

QwtPlotRescaler::ExpandingDirection QwtPlotRescaler::expandingDirection ( QwtAxisId  axisId) const

Gets the expanding direction for a specific axis.

Parameters
[in]axisIdAxis identifier
Returns
Expanding direction for the specified axis
See also
setExpandingDirection()

◆ expandInterval()

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

Expand the interval.

Parameters
intervalInterval to be expanded
widthDistance to be added to the interval
directionDirection of the expand operation
Returns
Expanded interval

◆ expandScale()

QwtInterval QwtPlotRescaler::expandScale ( QwtAxisId  axisId,
const QSize &  oldSize,
const QSize &  newSize 
) const
protectedvirtual

Calculate the new scale interval of a plot axis.

Parameters
axisIdAxis
oldSizePrevious size of the canvas
newSizeNew size of the canvas
Returns
Calculated new interval for the axis

◆ interval()

QwtInterval QwtPlotRescaler::interval ( QwtAxisId  axisId) const
protected
Parameters
axisIdAxis
Returns
Normalized interval of an axis

◆ intervalHint()

QwtInterval QwtPlotRescaler::intervalHint ( QwtAxisId  axisId) const

Gets the interval hint for an axis.

Parameters
[in]axisIdAxis identifier
Returns
Interval hint
See also
setIntervalHint(), RescalePolicy

◆ isEnabled()

bool QwtPlotRescaler::isEnabled ( ) const

Checks if the rescaler is enabled.

Returns
true if enabled, false otherwise
See also
setEnabled(), eventFilter()

◆ orientation()

Qt::Orientation QwtPlotRescaler::orientation ( QwtAxisId  axisId) const
protected
Returns
Orientation of an axis
Parameters
axisIdAxis

◆ plot() [1/2]

QwtPlot * QwtPlotRescaler::plot ( )

Gets the plot widget.

Returns
Plot widget

◆ plot() [2/2]

const QwtPlot * QwtPlotRescaler::plot ( ) const

Gets the plot widget (const version)

Returns
Plot widget (const)

◆ referenceAxis()

QwtAxisId QwtPlotRescaler::referenceAxis ( ) const

Gets the reference axis.

Returns
Reference axis identifier
See also
setReferenceAxis()

◆ rescale() [1/2]

void QwtPlotRescaler::rescale ( ) const

Rescales the plot axes.

Adjusts the plot axes scales based on the current canvas size.

◆ rescale() [2/2]

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

Adjust the plot axes scales.

Parameters
oldSizePrevious size of the canvas
newSizeNew size of the canvas

◆ rescalePolicy()

QwtPlotRescaler::RescalePolicy QwtPlotRescaler::rescalePolicy ( ) const

Gets the rescale policy.

Returns
Rescale policy
See also
setRescalePolicy()

◆ setAspectRatio() [1/2]

void QwtPlotRescaler::setAspectRatio ( double  ratio)

Sets the aspect ratio for all axes.

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

Parameters
[in]ratioAspect ratio
See also
aspectRatio()

◆ setAspectRatio() [2/2]

void QwtPlotRescaler::setAspectRatio ( QwtAxisId  axisId,
double  ratio 
)

Sets the aspect ratio for a specific axis.

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

Parameters
[in]axisIdAxis identifier
[in]ratioAspect ratio
See also
aspectRatio()

◆ setEnabled()

void QwtPlotRescaler::setEnabled ( bool  on)

Enables or disables the rescaler.

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

Parameters
[in]ontrue to enable, false to disable
See also
isEnabled(), eventFilter()

◆ setExpandingDirection() [1/2]

void QwtPlotRescaler::setExpandingDirection ( ExpandingDirection  direction)

Sets the expanding direction for all axes.

Parameters
[in]directionExpanding direction
See also
expandingDirection()

◆ setExpandingDirection() [2/2]

void QwtPlotRescaler::setExpandingDirection ( QwtAxisId  axisId,
ExpandingDirection  direction 
)

Sets the expanding direction for a specific axis.

Parameters
[in]axisIdAxis identifier
[in]directionExpanding direction
See also
expandingDirection()

◆ setIntervalHint()

void QwtPlotRescaler::setIntervalHint ( QwtAxisId  axisId,
const QwtInterval interval 
)

Sets an interval hint for an axis.

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

Parameters
[in]axisIdAxis identifier
[in]intervalInterval hint
See also
intervalHint(), RescalePolicy

◆ setReferenceAxis()

void QwtPlotRescaler::setReferenceAxis ( QwtAxisId  axisId)

Sets the reference axis.

The reference axis is used as the basis for rescale calculations.

Parameters
[in]axisIdAxis identifier
See also
referenceAxis()

◆ setRescalePolicy()

void QwtPlotRescaler::setRescalePolicy ( RescalePolicy  policy)

Sets the rescale policy.

Parameters
[in]policyRescale policy
See also
rescalePolicy()

◆ syncScale()

QwtInterval QwtPlotRescaler::syncScale ( QwtAxisId  axisId,
const QwtInterval reference,
const QSize &  size 
) const
protectedvirtual

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

Parameters
axisIdAxis
referenceInterval of the reference axis
sizeSize of the canvas
Returns
New interval for axis

◆ updateScales()

void QwtPlotRescaler::updateScales ( QwtInterval  intervals[QwtAxis::AxisPositions]) const
protectedvirtual

Update the axes scales.

Parameters
intervalsScale intervals

The documentation for this class was generated from the following files: