Qwt User's Guide svn
Public Types | Public Member Functions | Protected Member Functions
QwtPlotRescaler Class Reference

#include <qwt_plot_rescaler.h>

List of all members.

Public Types

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

Public Member Functions

double aspectRatio (int axis) const
QwtPlotCanvascanvas ()
const QwtPlotCanvascanvas () const
virtual bool eventFilter (QObject *, QEvent *)
ExpandingDirection expandingDirection (int axis) const
QwtInterval intervalHint (int axis) const
bool isEnabled () const
QwtPlotplot ()
const QwtPlotplot () const
 QwtPlotRescaler (QwtPlotCanvas *, int referenceAxis=QwtPlot::xBottom, RescalePolicy=Expanding)
int referenceAxis () const
void rescale () const
RescalePolicy rescalePolicy () const
void setAspectRatio (double ratio)
void setAspectRatio (int axis, double ratio)
void setEnabled (bool)
void setExpandingDirection (ExpandingDirection)
void setExpandingDirection (int axis, ExpandingDirection)
void setIntervalHint (int axis, const QwtInterval &)
void setReferenceAxis (int axis)
void setRescalePolicy (RescalePolicy)
virtual ~QwtPlotRescaler ()

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

Detailed Description

QwtPlotRescaler takes care of fixed aspect ratios for plot scales.

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


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.

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 shrinked/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 ( QwtPlotCanvas canvas,
int  referenceAxis = QwtPlot::xBottom,
RescalePolicy  policy = Expanding 
) [explicit]

Constructor

Parameters:
canvasCanvas
referenceAxisReference axis, see RescalePolicy
policyRescale policy
See also:
setRescalePolicy(), setReferenceAxis()
QwtPlotRescaler::~QwtPlotRescaler ( ) [virtual]

Destructor.


Member Function Documentation

double QwtPlotRescaler::aspectRatio ( int  axis) const

Return aspect ratio between an axis and the reference axis.

Parameters:
axisAxis index ( see QwtPlot::AxisId )
See also:
setAspectRatio()
QwtPlotCanvas * QwtPlotRescaler::canvas ( )
Returns:
plot canvas
const QwtPlotCanvas * QwtPlotRescaler::canvas ( ) const
Returns:
plot canvas
void QwtPlotRescaler::canvasResizeEvent ( QResizeEvent *  event) [protected, virtual]

Event handler for resize events of the plot canvas

Parameters:
eventResize event
See also:
rescale()
bool QwtPlotRescaler::eventFilter ( QObject *  object,
QEvent *  event 
) [virtual]

Event filter for the plot canvas.

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

Return direction in which an axis should be expanded

Parameters:
axisAxis index ( see QwtPlot::AxisId )
See also:
setExpandingDirection()
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
QwtInterval QwtPlotRescaler::expandScale ( int  axis,
const QSize &  oldSize,
const QSize &  newSize 
) const [protected, virtual]

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
QwtInterval QwtPlotRescaler::interval ( int  axis) const [protected]

Return interval of an axis

Parameters:
axisAxis index ( see QwtPlot::AxisId )
QwtInterval QwtPlotRescaler::intervalHint ( int  axis) const
Parameters:
axisAxis, see QwtPlot::Axis
Returns:
Interval hint
See also:
setIntervalHint(), RescalePolicy
bool QwtPlotRescaler::isEnabled ( ) const
Returns:
true when enabled, false otherwise
See also:
setEnabled, eventFilter()
Qt::Orientation QwtPlotRescaler::orientation ( int  axis) const [protected]

Return orientation of an axis

Parameters:
axisAxis index ( see QwtPlot::AxisId )
QwtPlot * QwtPlotRescaler::plot ( )
Returns:
plot widget
const QwtPlot * QwtPlotRescaler::plot ( ) const
Returns:
plot widget
int QwtPlotRescaler::referenceAxis ( ) const
Returns:
Reference axis ( see RescalePolicy )
See also:
setReferenceAxis()
void QwtPlotRescaler::rescale ( ) const

Adjust the plot axes scales.

void QwtPlotRescaler::rescale ( const QSize &  oldSize,
const QSize &  newSize 
) const [protected, virtual]

Adjust the plot axes scales

Parameters:
oldSizePrevious size of the canvas
newSizeNew size of the canvas
QwtPlotRescaler::RescalePolicy QwtPlotRescaler::rescalePolicy ( ) const
Returns:
Rescale policy
See also:
setRescalePolicy()
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()
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()
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()
void QwtPlotRescaler::setExpandingDirection ( ExpandingDirection  direction)

Set the direction in which all axis should be expanded

Parameters:
directionDirection
See also:
expandingDirection()
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()
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 taht always needs to be displayed.

Parameters:
axisAxis, see QwtPlot::Axis
intervalAxis
See also:
intervalHint(), RescalePolicy
void QwtPlotRescaler::setReferenceAxis ( int  axis)

Set the reference axis ( see RescalePolicy )

Parameters:
axisAxis index ( QwtPlot::Axis )
See also:
referenceAxis()
void QwtPlotRescaler::setRescalePolicy ( RescalePolicy  policy)

Change the rescale policy

Parameters:
policyRescale policy
See also:
rescalePolicy()
QwtInterval QwtPlotRescaler::syncScale ( int  axis,
const QwtInterval reference,
const QSize &  size 
) const [protected, virtual]

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
void QwtPlotRescaler::updateScales ( QwtInterval  intervals[QwtPlot::axisCnt]) const [protected, virtual]

Update the axes scales

Parameters:
intervalsScale intervals
qmi style