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 (int axis) const
 
QWidget * canvas ()
 
const QWidget * canvas () const
 
virtual bool eventFilter (QObject *, QEvent *)
 Event filter for the plot canvas. More...
 
ExpandingDirection expandingDirection (int axis) const
 
QwtInterval intervalHint (int axis) const
 
bool isEnabled () const
 
QwtPlotplot ()
 
const QwtPlotplot () const
 
 QwtPlotRescaler (QWidget *canvas, int referenceAxis=QwtPlot::xBottom, RescalePolicy=Expanding)
 
int referenceAxis () const
 
void rescale () const
 Adjust the plot axes scales. More...
 
RescalePolicy rescalePolicy () const
 
void setAspectRatio (double ratio)
 
void setAspectRatio (int axis, double ratio)
 
void setEnabled (bool)
 En/disable the rescaler. More...
 
void setExpandingDirection (ExpandingDirection)
 
void setExpandingDirection (int axis, ExpandingDirection)
 
void setIntervalHint (int axis, const QwtInterval &)
 
void setReferenceAxis (int axis)
 
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 (int axis, const QSize &oldSize, const QSize &newSize) const
 
QwtInterval interval (int axis) const
 
Qt::Orientation orientation (int axis) const
 
virtual void rescale (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
 

Private Member Functions

double pixelDist (int axis, const QSize &) const
 

Private Attributes

PrivateDatad_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 28 of file qwt_plot_rescaler.h.

Member Enumeration Documentation

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 67 of file qwt_plot_rescaler.h.

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 37 of file qwt_plot_rescaler.h.

Constructor & Destructor Documentation

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

Constructor

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

Definition at line 61 of file qwt_plot_rescaler.cpp.

QwtPlotRescaler::~QwtPlotRescaler ( )
virtual

Destructor.

Definition at line 73 of file qwt_plot_rescaler.cpp.

Member Function Documentation

double QwtPlotRescaler::aspectRatio ( int  axis) const
Returns
Aspect ratio between an axis and the reference axis.
Parameters
axisAxis index ( see QwtPlot::AxisId )
See also
setAspectRatio()

Definition at line 231 of file qwt_plot_rescaler.cpp.

QWidget * QwtPlotRescaler::canvas ( )
Returns
plot canvas

Definition at line 270 of file qwt_plot_rescaler.cpp.

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

Definition at line 276 of file qwt_plot_rescaler.cpp.

void QwtPlotRescaler::canvasResizeEvent ( QResizeEvent *  event)
protectedvirtual

Event handler for resize events of the plot canvas

Parameters
eventResize event
See also
rescale()

Definition at line 331 of file qwt_plot_rescaler.cpp.

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

Event filter for the plot canvas.

Definition at line 302 of file qwt_plot_rescaler.cpp.

QwtPlotRescaler::ExpandingDirection QwtPlotRescaler::expandingDirection ( int  axis) const
Returns
Direction in which an axis should be expanded
Parameters
axisAxis index ( see QwtPlot::AxisId )
See also
setExpandingDirection()

Definition at line 187 of file qwt_plot_rescaler.cpp.

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 511 of file qwt_plot_rescaler.cpp.

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

Calculate the new scale interval of a plot axis

Parameters
axisAxis index ( see QwtPlot::AxisId )
oldSizePrevious size of the canvas
newSizeNew size of the canvas
Returns
Calculated new interval for the axis

Definition at line 388 of file qwt_plot_rescaler.cpp.

QwtInterval QwtPlotRescaler::interval ( int  axis) const
protected
Parameters
axisAxis index ( see QwtPlot::AxisId )
Returns
Normalized interval of an axis

Definition at line 494 of file qwt_plot_rescaler.cpp.

QwtInterval QwtPlotRescaler::intervalHint ( int  axis) const
Parameters
axisAxis, see QwtPlot::Axis
Returns
Interval hint
See also
setIntervalHint(), RescalePolicy

Definition at line 261 of file qwt_plot_rescaler.cpp.

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

Definition at line 108 of file qwt_plot_rescaler.cpp.

Qt::Orientation QwtPlotRescaler::orientation ( int  axis) const
protected
Returns
Orientation of an axis
Parameters
axisAxis index ( see QwtPlot::AxisId )

Definition at line 482 of file qwt_plot_rescaler.cpp.

double QwtPlotRescaler::pixelDist ( int  axis,
const QSize &  size 
) const
private

Definition at line 538 of file qwt_plot_rescaler.cpp.

QwtPlot * QwtPlotRescaler::plot ( )
Returns
plot widget

Definition at line 282 of file qwt_plot_rescaler.cpp.

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

Definition at line 292 of file qwt_plot_rescaler.cpp.

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

Definition at line 148 of file qwt_plot_rescaler.cpp.

void QwtPlotRescaler::rescale ( ) const

Adjust the plot axes scales.

Definition at line 345 of file qwt_plot_rescaler.cpp.

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 357 of file qwt_plot_rescaler.cpp.

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

Definition at line 128 of file qwt_plot_rescaler.cpp.

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 202 of file qwt_plot_rescaler.cpp.

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
axisAxis index ( see QwtPlot::AxisId )
ratioAspect ratio
See also
aspectRatio()

Definition at line 216 of file qwt_plot_rescaler.cpp.

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 87 of file qwt_plot_rescaler.cpp.

void QwtPlotRescaler::setExpandingDirection ( ExpandingDirection  direction)

Set the direction in which all axis should be expanded

Parameters
directionDirection
See also
expandingDirection()

Definition at line 159 of file qwt_plot_rescaler.cpp.

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

Set the direction in which an axis should be expanded

Parameters
axisAxis index ( see QwtPlot::AxisId )
directionDirection
See also
expandingDirection()

Definition at line 173 of file qwt_plot_rescaler.cpp.

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
axisAxis, see QwtPlot::Axis
intervalAxis
See also
intervalHint(), RescalePolicy

Definition at line 249 of file qwt_plot_rescaler.cpp.

void QwtPlotRescaler::setReferenceAxis ( int  axis)

Set the reference axis ( see RescalePolicy )

Parameters
axisAxis index ( QwtPlot::Axis )
See also
referenceAxis()

Definition at line 139 of file qwt_plot_rescaler.cpp.

void QwtPlotRescaler::setRescalePolicy ( RescalePolicy  policy)

Change the rescale policy

Parameters
policyRescale policy
See also
rescalePolicy()

Definition at line 119 of file qwt_plot_rescaler.cpp.

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
axisAxis index ( see QwtPlot::AxisId )
referenceInterval of the reference axis
sizeSize of the canvas
Returns
New interval for axis

Definition at line 451 of file qwt_plot_rescaler.cpp.

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

Update the axes scales

Parameters
intervalsScale intervals

Definition at line 571 of file qwt_plot_rescaler.cpp.

Member Data Documentation

PrivateData* QwtPlotRescaler::d_data
private

Definition at line 138 of file qwt_plot_rescaler.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18