QwtPlotRescaler - QwtPlotRescaler takes care of fixed aspect ratios for plot scales.
Contents
Constructor & Destructor Documentation
QwtPlotRescaler::QwtPlotRescaler(QWidget*canvas,intreferenceAxis=QwtPlot::xBottom,RescalePolicypolicy=Expanding)[explicit]
Constructor
Parameters:canvas Canvas
referenceAxis Reference axis, see RescalePolicy
policy Rescale policy
Seealso:setRescalePolicy(), setReferenceAxis()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
enumQwtPlotRescaler::ExpandingDirection
When rescalePolicy() is set to Expanding its direction depends on ExpandingDirection
EnumeratorExpandUp
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.
enumQwtPlotRescaler::RescalePolicy
The rescale policy defines how to rescale the reference axis and their depending axes.
Seealso:ExpandingDirection, setIntervalHint()EnumeratorFixed 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.
Member Function Documentation
doubleQwtPlotRescaler::aspectRatio(intaxis)constReturns:
Aspect ratio between an axis and the reference axis.
Parameters:axis Axis index ( see QwtPlot::AxisId )
Seealso:setAspectRatio()QWidget*QwtPlotRescaler::canvas()Returns:
plot canvas
constQWidget*QwtPlotRescaler::canvas()constReturns:
plot canvas
voidQwtPlotRescaler::canvasResizeEvent(QResizeEvent*event)[protected],[virtual]
Event handler for resize events of the plot canvas
Parameters:event Resize event
Seealso:rescale()QwtPlotRescaler::ExpandingDirectionQwtPlotRescaler::expandingDirection(intaxis)constReturns:
Direction in which an axis should be expanded
Parameters:axis Axis index ( see QwtPlot::AxisId )
Seealso:setExpandingDirection()QwtIntervalQwtPlotRescaler::expandInterval(constQwtInterval&interval,doublewidth,ExpandingDirectiondirection)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
QwtIntervalQwtPlotRescaler::expandScale(intaxis,constQSize&oldSize,constQSize&newSize)const[protected],[virtual]
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
QwtIntervalQwtPlotRescaler::interval(intaxis)const[protected]Parameters:axis Axis index ( see QwtPlot::AxisId )
Returns:
Normalized interval of an axis
QwtIntervalQwtPlotRescaler::intervalHint(intaxis)constParameters:axis Axis, see QwtPlot::AxisReturns:
Interval hint
Seealso:setIntervalHint(), RescalePolicyboolQwtPlotRescaler::isEnabled()constReturns:
true when enabled, false otherwise
Seealso:setEnabled, eventFilter()Qt::OrientationQwtPlotRescaler::orientation(intaxis)const[protected]Returns:
Orientation of an axis
Parameters:axis Axis index ( see QwtPlot::AxisId )
QwtPlot*QwtPlotRescaler::plot()Returns:
plot widget
constQwtPlot*QwtPlotRescaler::plot()constReturns:
plot widget
intQwtPlotRescaler::referenceAxis()constReturns:
Reference axis ( see RescalePolicy )
Seealso:setReferenceAxis()voidQwtPlotRescaler::rescale(constQSize&oldSize,constQSize&newSize)const[protected],[virtual]
Adjust the plot axes scales
Parameters:oldSize Previous size of the canvas
newSize New size of the canvas
QwtPlotRescaler::RescalePolicyQwtPlotRescaler::rescalePolicy()constReturns:
Rescale policy
Seealso:setRescalePolicy()voidQwtPlotRescaler::setAspectRatio(doubleratio)
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
Seealso:aspectRatio()voidQwtPlotRescaler::setAspectRatio(intaxis,doubleratio)
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
Seealso:aspectRatio()voidQwtPlotRescaler::setEnabled(boolon)
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
Seealso:isEnabled(), eventFilter()voidQwtPlotRescaler::setExpandingDirection(ExpandingDirectiondirection)
Set the direction in which all axis should be expanded
Parameters:direction Direction
Seealso:expandingDirection()voidQwtPlotRescaler::setExpandingDirection(intaxis,ExpandingDirectiondirection)
Set the direction in which an axis should be expanded
Parameters:axis Axis index ( see QwtPlot::AxisId )
direction Direction
Seealso:expandingDirection()voidQwtPlotRescaler::setIntervalHint(intaxis,constQwtInterval&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::Axisinterval Axis
Seealso:intervalHint(), RescalePolicyvoidQwtPlotRescaler::setReferenceAxis(intaxis)
Set the reference axis ( see RescalePolicy )
Parameters:axis Axis index ( QwtPlot::Axis )
Seealso:referenceAxis()voidQwtPlotRescaler::setRescalePolicy(RescalePolicypolicy)
Change the rescale policy
Parameters:policy Rescale policy
Seealso:rescalePolicy()QwtIntervalQwtPlotRescaler::syncScale(intaxis,constQwtInterval&reference,constQSize&size)const[protected],[virtual]
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
voidQwtPlotRescaler::updateScales(QwtIntervalintervals[QwtPlot::axisCnt])const[protected],[virtual]
Update the axes scales
Parameters:intervals Scale intervals
Name
QwtPlotRescaler - QwtPlotRescaler takes care of fixed aspect ratios for plot scales.
Synopsis
#include <qwt_plot_rescaler.h>
Inherits QObject.
PublicTypes
enum RescalePolicy { Fixed, Expanding, Fitting }
enum ExpandingDirection { ExpandUp, ExpandDown, ExpandBoth }
PublicMemberFunctionsQwtPlotRescaler (QWidget *canvas, int referenceAxis=QwtPlot::xBottom, RescalePolicy=Expanding)
virtual ~QwtPlotRescaler ()
Destructor.
void setEnabled (bool)
En/disable the rescaler.
bool isEnabled () const
void setRescalePolicy (RescalePolicy)
RescalePolicyrescalePolicy () const
void setExpandingDirection (ExpandingDirection)
void setExpandingDirection (int axis, ExpandingDirection)
ExpandingDirectionexpandingDirection (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 &)
QwtIntervalintervalHint (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.
ProtectedMemberFunctions
virtual void canvasResizeEvent (QResizeEvent *)
virtual void rescale (const QSize &oldSize, const QSize &newSize) const
virtual QwtIntervalexpandScale (int axis, const QSize &oldSize, const QSize &newSize) const
virtual QwtIntervalsyncScale (int axis, const QwtInterval &reference, const QSize &size) const
virtual void updateScales (QwtInterval intervals[QwtPlot::axisCnt]) const
Qt::Orientation orientation (int axis) const
QwtIntervalinterval (int axis) const
QwtIntervalexpandInterval (const QwtInterval &, double width, ExpandingDirection) const
