11#include "qwt_scale_widget.h"
12#include "qwt_scale_map.h"
13#include "qwt_scale_div.h"
14#include "qwt_scale_engine.h"
15#include "qwt_interval.h"
44 scaleWidget->setObjectName( name );
48 const QFont fscl( plot->fontInfo().family(), 10 );
49 const QFont fttl( plot->fontInfo().family(), 12, QFont::Bold );
52 scaleWidget->setTransformation( scaleEngine->transformation() );
54 scaleWidget->setFont( fscl );
55 scaleWidget->setMargin( 2 );
57 QwtText text = scaleWidget->title();
59 scaleWidget->setTitle( text );
80class QwtPlot::ScaleData
93 inline AxisData& axisData( QwtAxisId axisId )
95 return m_axisData[ axisId ];
98 inline const AxisData& axisData( QwtAxisId axisId )
const
100 return m_axisData[ axisId ];
104 AxisData m_axisData[ QwtAxis::AxisPositions ];
107void QwtPlot::initAxesData()
109 m_scaleData =
new ScaleData(
this );
115void QwtPlot::deleteAxesData()
144 return m_scaleData->axisData( axisId ).scaleWidget;
156 return m_scaleData->axisData( axisId ).scaleWidget;
171 if (
isAxisValid( axisId ) && scaleEngine != NULL )
173 AxisData& d = m_scaleData->axisData( axisId );
175 delete d.scaleEngine;
176 d.scaleEngine = scaleEngine;
193 return m_scaleData->axisData( axisId ).scaleEngine;
205 return m_scaleData->axisData( axisId ).scaleEngine;
216 return m_scaleData->axisData( axisId ).doAutoScale;
228 return m_scaleData->axisData( axisId ).isVisible;
254 return m_scaleData->axisData( axisId ).maxMajor;
267 return m_scaleData->axisData( axisId ).maxMinor;
286 return m_scaleData->axisData( axisId ).scaleDiv;
289 return dummyScaleDiv;
335 return m_scaleData->axisData( axisId ).stepSize;
353 return m_scaleData->axisData( axisId ).scaleDiv.
interval();
382 if (
isAxisValid( axisId ) && on != m_scaleData->axisData( axisId ).isVisible )
384 m_scaleData->axisData( axisId ).isVisible = on;
455 if (
isAxisValid( axisId ) && ( m_scaleData->axisData( axisId ).doAutoScale != on ) )
457 m_scaleData->axisData( axisId ).doAutoScale = on;
481 AxisData& d = m_scaleData->axisData( axisId );
483 d.doAutoScale =
false;
488 d.stepSize = stepSize;
510 AxisData& d = m_scaleData->axisData( axisId );
512 d.doAutoScale =
false;
513 d.scaleDiv = scaleDiv;
586 maxMinor = qBound( 0, maxMinor, 100 );
588 AxisData& d = m_scaleData->axisData( axisId );
589 if ( maxMinor != d.maxMinor )
591 d.maxMinor = maxMinor;
610 maxMajor = qBound( 1, maxMajor, 10000 );
612 AxisData& d = m_scaleData->axisData( axisId );
613 if ( maxMajor != d.maxMajor )
615 d.maxMajor = maxMajor;
675 QwtInterval boundingIntervals[QwtAxis::AxisPositions];
679 QwtPlotItemIterator it;
680 for ( it = itmList.begin(); it != itmList.end(); ++it )
690 const QwtAxisId xAxis = item->
xAxis();
691 const QwtAxisId yAxis = item->
yAxis();
698 boundingIntervals[xAxis] |=
QwtInterval( rect.left(), rect.right() );
701 boundingIntervals[yAxis] |=
QwtInterval( rect.top(), rect.bottom() );
707 for (
int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
710 const QwtAxisId axisId( axisPos );
712 AxisData& d = m_scaleData->axisData( axisId );
714 double minValue = d.minValue;
715 double maxValue = d.maxValue;
716 double stepSize = d.stepSize;
718 const QwtInterval& interval = boundingIntervals[axisId];
720 if ( d.doAutoScale && interval.
isValid() )
728 minValue, maxValue, stepSize );
733 minValue, maxValue, d.maxMajor, d.maxMinor, stepSize );
740 int startDist, endDist;
746 for ( it = itmList.begin(); it != itmList.end(); ++it )
A class representing an interval.
A scale engine for linear scales.
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
double transform(QwtAxisId, double value) const
Transform a value into a coordinate in the plotting region.
void setAxisVisible(QwtAxisId, bool on=true)
Hide or show a specified axis.
QFont axisFont(QwtAxisId) const
void updateAxes()
Rebuild the axes scales.
void setAxisLabelAlignment(QwtAxisId, Qt::Alignment)
void setAxisScale(QwtAxisId, double min, double max, double stepSize=0)
Disable autoscaling and specify a fixed scale for a selected axis.
QwtScaleEngine * axisScaleEngine(QwtAxisId)
double axisStepSize(QwtAxisId) const
Return the step size parameter that has been set in setAxisScale.
void setAxisScaleDraw(QwtAxisId, QwtScaleDraw *)
Set a scale draw.
void setAxisLabelRotation(QwtAxisId, double rotation)
void setAxisFont(QwtAxisId, const QFont &)
Change the font of an axis.
void setAxisTitle(QwtAxisId, const QString &)
Change the title of a specified axis.
void setAxisAutoScale(QwtAxisId, bool on=true)
Enable autoscaling for a specified axis.
void setAxisScaleEngine(QwtAxisId, QwtScaleEngine *)
void setAxisMaxMajor(QwtAxisId, int maxMajor)
bool isAxisVisible(QwtAxisId) const
bool axisAutoScale(QwtAxisId) const
QwtInterval axisInterval(QwtAxisId) const
Return the current interval of the specified axis.
double invTransform(QwtAxisId, double pos) const
QwtText axisTitle(QwtAxisId) const
bool isAxisValid(QwtAxisId) const
void setAxisMaxMinor(QwtAxisId, int maxMinor)
const QwtScaleWidget * axisWidget(QwtAxisId) const
virtual QwtScaleMap canvasMap(QwtAxisId) const
int axisMaxMinor(QwtAxisId) const
virtual void updateLayout()
Adjust plot content to its current size.
void autoRefresh()
Replots the plot if autoReplot() is true.
const QwtScaleDiv & axisScaleDiv(QwtAxisId) const
Return the scale division of a specified axis.
void setAxisScaleDiv(QwtAxisId, const QwtScaleDiv &)
Disable autoscaling and specify a fixed scale for a selected axis.
const QwtScaleDraw * axisScaleDraw(QwtAxisId) const
Return the scale draw of a specified axis.
int axisMaxMajor(QwtAxisId) const
Base class for items on the plot canvas.
QwtAxisId yAxis() const
Return yAxis.
QwtAxisId xAxis() const
Return xAxis.
bool testItemInterest(ItemInterest) const
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &)
Update the item to changes of the axes scale division.
bool testItemAttribute(ItemAttribute) const
virtual QRectF boundingRect() const
A class representing a scale division.
QwtInterval interval() const
A class for drawing scales.
@ BottomScale
The scale is below.
@ TopScale
The scale is above.
@ RightScale
The scale is right.
@ LeftScale
The scale is left.
Base class for scale engines.
QwtTransform * transformation() const
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
A class representing a text.
void setFont(const QFont &)
@ YRight
Y axis right of the canvas.
@ XTop
X axis above the canvas.
@ XBottom
X axis below the canvas.
@ YLeft
Y axis left of the canvas.
bool isValid(int axisPos)