Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | 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:
Inheritance graph
[legend]

Classes

class  AxisData
 
class  PrivateData
 

Public Types

enum  ExpandingDirection { ExpandUp, ExpandDown, ExpandBoth }
 
enum  RescalePolicy { Fixed, Expanding, Fitting }
 

Public Member Functions

double aspectRatio (QwtAxisId) const
 
QWidget * canvas ()
 
const QWidget * canvas () const
 
virtual bool eventFilter (QObject *, QEvent *) QWT_OVERRIDE
 Event filter for the plot canvas. More...
 
ExpandingDirection expandingDirection (QwtAxisId) const
 
QwtInterval intervalHint (QwtAxisId) const
 
bool isEnabled () const
 
QwtPlotplot ()
 
const QwtPlotplot () const
 
 QwtPlotRescaler (QWidget *canvas, QwtAxisId referenceAxis=QwtAxis::XBottom, RescalePolicy=Expanding)
 
QwtAxisId referenceAxis () const
 
void rescale () const
 Adjust the plot axes scales. More...
 
RescalePolicy rescalePolicy () const
 
void setAspectRatio (double ratio)
 
void setAspectRatio (QwtAxisId, double ratio)
 
void setEnabled (bool)
 En/disable the rescaler. More...
 
void setExpandingDirection (ExpandingDirection)
 
void setExpandingDirection (QwtAxisId, ExpandingDirection)
 
void setIntervalHint (QwtAxisId, const QwtInterval &)
 
void setReferenceAxis (QwtAxisId)
 
void setRescalePolicy (RescalePolicy)
 
virtual ~QwtPlotRescaler ()
 Destructor. More...
 

Protected Member Functions

virtual void canvasResizeEvent (QResizeEvent *)
 
QwtInterval expandInterval (const QwtInterval &, double width, ExpandingDirection) const
 
virtual QwtInterval expandScale (QwtAxisId, const QSize &oldSize, const QSize &newSize) const
 
QwtInterval interval (QwtAxisId) const
 
Qt::Orientation orientation (QwtAxisId) const
 
virtual void rescale (const QSize &oldSize, const QSize &newSize) const
 
virtual QwtInterval syncScale (QwtAxisId, const QwtInterval &reference, const QSize &size) const
 
virtual void updateScales (QwtInterval intervals[QwtAxis::AxisPositions]) const
 

Private Member Functions

double pixelDist (QwtAxisId, const QSize &) const
 

Private Attributes

PrivateDatam_data
 

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.

Definition at line 29 of file qwt_plot_rescaler.h.

Member Enumeration Documentation

◆ 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.

Definition at line 70 of file qwt_plot_rescaler.h.

◆ 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.

Definition at line 40 of file qwt_plot_rescaler.h.

Constructor & Destructor Documentation

◆ QwtPlotRescaler()

QwtPlotRescaler::QwtPlotRescaler ( QWidget *  canvas,
QwtAxisId  referenceAxis = QwtAxis::XBottom,
RescalePolicy  policy = Expanding 
)
explicit

Constructor

Parameters
canvasCanvas
referenceAxisReference axis, see RescalePolicy
policyRescale policy
See also
setRescalePolicy(), setReferenceAxis()

Definition at line 71 of file qwt_plot_rescaler.cpp.

◆ ~QwtPlotRescaler()

QwtPlotRescaler::~QwtPlotRescaler ( )
virtual

Destructor.

Definition at line 83 of file qwt_plot_rescaler.cpp.

Member Function Documentation

◆ aspectRatio()

double QwtPlotRescaler::aspectRatio ( QwtAxisId  axisId) const
Returns
Aspect ratio between an axis and the reference axis.
Parameters
axisIdAxis
See also
setAspectRatio()

Definition at line 243 of file qwt_plot_rescaler.cpp.

◆ canvas() [1/2]

const QWidget * QwtPlotRescaler::canvas ( )
Returns
plot canvas

Definition at line 282 of file qwt_plot_rescaler.cpp.

◆ canvas() [2/2]

const QWidget* QwtPlotRescaler::canvas ( ) const

◆ canvasResizeEvent()

void QwtPlotRescaler::canvasResizeEvent ( QResizeEvent *  event)
protectedvirtual

Event handler for resize events of the plot canvas

Parameters
eventResize event
See also
rescale()

Definition at line 343 of file qwt_plot_rescaler.cpp.

◆ eventFilter()

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

Event filter for the plot canvas.

Definition at line 314 of file qwt_plot_rescaler.cpp.

◆ expandingDirection()

QwtPlotRescaler::ExpandingDirection QwtPlotRescaler::expandingDirection ( QwtAxisId  axisId) const
Returns
Direction in which an axis should be expanded
Parameters
axisIdAxis
See also
setExpandingDirection()

Definition at line 197 of file qwt_plot_rescaler.cpp.

◆ 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

Definition at line 526 of file qwt_plot_rescaler.cpp.

◆ 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

Definition at line 405 of file qwt_plot_rescaler.cpp.

◆ interval()

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

Definition at line 509 of file qwt_plot_rescaler.cpp.

◆ intervalHint()

QwtInterval QwtPlotRescaler::intervalHint ( QwtAxisId  axisId) const
Parameters
axisIdAxis
Returns
Interval hint
See also
setIntervalHint(), RescalePolicy

Definition at line 273 of file qwt_plot_rescaler.cpp.

◆ isEnabled()

bool QwtPlotRescaler::isEnabled ( ) const
Returns
true when enabled, false otherwise
See also
setEnabled, eventFilter()

Definition at line 118 of file qwt_plot_rescaler.cpp.

◆ orientation()

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

Definition at line 500 of file qwt_plot_rescaler.cpp.

◆ pixelDist()

double QwtPlotRescaler::pixelDist ( QwtAxisId  axisId,
const QSize &  size 
) const
private

Definition at line 553 of file qwt_plot_rescaler.cpp.

◆ plot() [1/2]

const QwtPlot * QwtPlotRescaler::plot ( )
Returns
plot widget

Definition at line 294 of file qwt_plot_rescaler.cpp.

◆ plot() [2/2]

const QwtPlot* QwtPlotRescaler::plot ( ) const

◆ referenceAxis()

QwtAxisId QwtPlotRescaler::referenceAxis ( ) const
Returns
Reference axis ( see RescalePolicy )
See also
setReferenceAxis()

Definition at line 158 of file qwt_plot_rescaler.cpp.

◆ rescale() [1/2]

void QwtPlotRescaler::rescale ( ) const

Adjust the plot axes scales.

Definition at line 355 of file qwt_plot_rescaler.cpp.

◆ 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

Definition at line 367 of file qwt_plot_rescaler.cpp.

◆ rescalePolicy()

QwtPlotRescaler::RescalePolicy QwtPlotRescaler::rescalePolicy ( ) const
Returns
Rescale policy
See also
setRescalePolicy()

Definition at line 138 of file qwt_plot_rescaler.cpp.

◆ 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
ratioAspect ratio
See also
aspectRatio()

Definition at line 212 of file qwt_plot_rescaler.cpp.

◆ setAspectRatio() [2/2]

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

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

Parameters
axisIdAxis
ratioAspect ratio
See also
aspectRatio()

Definition at line 226 of file qwt_plot_rescaler.cpp.

◆ 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
ontrue or false
See also
isEnabled(), eventFilter()

Definition at line 97 of file qwt_plot_rescaler.cpp.

◆ setExpandingDirection() [1/2]

void QwtPlotRescaler::setExpandingDirection ( ExpandingDirection  direction)

Set the direction in which all axis should be expanded

Parameters
directionDirection
See also
expandingDirection()

Definition at line 169 of file qwt_plot_rescaler.cpp.

◆ setExpandingDirection() [2/2]

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

Set the direction in which an axis should be expanded

Parameters
axisIdAxis
directionDirection
See also
expandingDirection()

Definition at line 183 of file qwt_plot_rescaler.cpp.

◆ setIntervalHint()

void QwtPlotRescaler::setIntervalHint ( QwtAxisId  axisId,
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
axisIdAxis
intervalAxis
See also
intervalHint(), RescalePolicy

Definition at line 261 of file qwt_plot_rescaler.cpp.

◆ setReferenceAxis()

void QwtPlotRescaler::setReferenceAxis ( QwtAxisId  axisId)

Set the reference axis ( see RescalePolicy )

Parameters
axisIdAxis
See also
referenceAxis()

Definition at line 149 of file qwt_plot_rescaler.cpp.

◆ setRescalePolicy()

void QwtPlotRescaler::setRescalePolicy ( RescalePolicy  policy)

Change the rescale policy

Parameters
policyRescale policy
See also
rescalePolicy()

Definition at line 129 of file qwt_plot_rescaler.cpp.

◆ 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

Definition at line 469 of file qwt_plot_rescaler.cpp.

◆ updateScales()

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

Update the axes scales

Parameters
intervalsScale intervals

Definition at line 588 of file qwt_plot_rescaler.cpp.

Member Data Documentation

◆ m_data

PrivateData* QwtPlotRescaler::m_data
private

Definition at line 140 of file qwt_plot_rescaler.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:29