10#include "qwt_plot_scaleitem.h"
12#include "qwt_scale_map.h"
13#include "qwt_interval.h"
19class QwtPlotScaleItem::PrivateData
24 , borderDistance( -1 )
25 , scaleDivFromAxis( true )
42 bool scaleDivFromAxis;
46QwtInterval QwtPlotScaleItem::PrivateData::scaleInterval(
const QRectF& canvasRect,
79 m_data =
new PrivateData;
80 m_data->position = pos;
110 m_data->scaleDivFromAxis =
false;
117 return m_data->scaleDraw->
scaleDiv();
129 if ( on != m_data->scaleDivFromAxis )
131 m_data->scaleDivFromAxis = on;
152 return m_data->scaleDivFromAxis;
161 if (
palette != m_data->palette )
176 return m_data->palette;
185 if (
font != m_data->font )
218 delete m_data->scaleDraw;
238 return m_data->scaleDraw;
247 return m_data->scaleDraw;
263 if ( m_data->position != pos )
265 m_data->position = pos;
266 m_data->borderDistance = -1;
277 return m_data->position;
301 if ( distance != m_data->borderDistance )
303 m_data->borderDistance = distance;
314 return m_data->borderDistance;
348 const QRectF& canvasRect )
const
352 if ( m_data->scaleDivFromAxis )
355 m_data->scaleInterval( canvasRect, xMap, yMap );
365 QPen pen = painter->pen();
366 pen.setStyle( Qt::SolidLine );
367 painter->setPen( pen );
372 if ( m_data->borderDistance >= 0 )
375 y = canvasRect.top() + m_data->borderDistance;
378 y = canvasRect.bottom() - m_data->borderDistance;
387 if ( y < canvasRect.top() || y > canvasRect.bottom() )
390 sd->
move( canvasRect.left(), y );
402 if ( m_data->borderDistance >= 0 )
405 x = canvasRect.left() + m_data->borderDistance;
408 x = canvasRect.right() - m_data->borderDistance;
415 if ( x < canvasRect.left() || x > canvasRect.right() )
418 sd->
move( x, canvasRect.top() );
419 sd->
setLength( canvasRect.height() - 1 );
428 painter->setFont( m_data->font );
430 sd->
draw( painter, m_data->palette );
450 if ( m_data->scaleDivFromAxis &&
scaleDraw )
458 const QRectF canvasRect = plt->
canvas()->contentsRect();
460 const QwtInterval interval = m_data->scaleInterval(
void setScaleDiv(const QwtScaleDiv &)
void setTransformation(QwtTransform *)
virtual void draw(QPainter *, const QPalette &) const
Draw the scale.
const QwtScaleDiv & scaleDiv() const
A class representing an interval.
virtual QwtScaleMap canvasMap(QwtAxisId) const
const QwtScaleDiv & axisScaleDiv(QwtAxisId) const
Return the scale division of a specified axis.
Base class for items on the plot canvas.
QwtAxisId yAxis() const
Return yAxis.
virtual void legendChanged()
void setZ(double z)
Set the z value.
QwtPlot * plot() const
Return attached plot.
QwtAxisId xAxis() const
Return xAxis.
@ Rtti_PlotScale
For QwtPlotScaleItem.
void setItemInterest(ItemInterest, bool on=true)
virtual void itemChanged()
void setScaleDraw(QwtScaleDraw *)
Set a scale draw.
void setScaleDivFromAxis(bool on)
int borderDistance() const
const QwtScaleDiv & scaleDiv() const
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &) override
Update the item to changes of the axes scale division.
bool isScaleDivFromAxis() const
const QwtScaleDraw * scaleDraw() const
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const override
Draw the scale.
virtual int rtti() const override
virtual ~QwtPlotScaleItem()
Destructor.
void setFont(const QFont &)
void setPosition(double pos)
void setScaleDiv(const QwtScaleDiv &)
Assign a scale division.
QwtPlotScaleItem(QwtScaleDraw::Alignment=QwtScaleDraw::BottomScale, const double pos=0.0)
Constructor for scale item at the position pos.
void setBorderDistance(int)
Align the scale to the canvas.
void setAlignment(QwtScaleDraw::Alignment)
void setPalette(const QPalette &)
A class representing a scale division.
QwtInterval interval() const
void setInterval(double lowerBound, double upperBound)
A class for drawing scales.
void setLength(double length)
void move(double x, double y)
void setAlignment(Alignment)
Alignment alignment() const
Qt::Orientation orientation() const
@ BottomScale
The scale is below.
@ RightScale
The scale is right.
double transform(double s) const
const QwtTransform * transformation() const
Get the transformation.
double invTransform(double p) const
A class representing a text.