10#include "qwt_abstract_scale_draw.h"
12#include "qwt_painter.h"
13#include "qwt_scale_map.h"
22class QwtAbstractScaleDraw::PrivateData
62 m_data =
new QwtAbstractScaleDraw::PrivateData;
83 m_data->components |= component;
85 m_data->components &= ~component;
97 return ( m_data->components & component );
108 m_data->labelCache.clear();
135 return m_data->scaleDiv;
149 m_data->penWidthF = width;
158 return m_data->penWidthF;
170 const QPalette& palette )
const
174 QPen pen = painter->pen();
175 pen.setWidthF( m_data->penWidthF );
177 painter->setPen( pen );
182 painter->setPen( palette.color( QPalette::Text ) );
187 for (
int i = 0; i < majorTicks.count(); i++ )
189 const double v = majorTicks[i];
190 if ( m_data->scaleDiv.
contains( v ) )
201 pen = painter->pen();
202 pen.setColor( palette.color( QPalette::WindowText ) );
203 pen.setCapStyle( Qt::FlatCap );
205 painter->setPen( pen );
210 const double tickLen = m_data->tickLength[tickType];
211 if ( tickLen <= 0.0 )
215 for (
int i = 0; i < ticks.count(); i++ )
217 const double v = ticks[i];
218 if ( m_data->scaleDiv.
contains( v ) )
230 pen = painter->pen();
231 pen.setColor( palette.color( QPalette::WindowText ) );
232 pen.setCapStyle( Qt::FlatCap );
234 painter->setPen( pen );
273 return m_data->spacing;
291 if ( minExtent < 0.0 )
294 m_data->minExtent = minExtent;
304 return m_data->minExtent;
327 const double maxTickLen = 1000.0;
328 if ( length > maxTickLen )
331 m_data->tickLength[tickType] = length;
346 return m_data->tickLength[tickType];
359 length = qwtMaxF( length, m_data->tickLength[i] );
377 return QLocale().toString( value );
394 const QFont& font,
double value )
const
397 if ( it1 != m_data->labelCache.constEnd() )
419 m_data->labelCache.clear();
void setSpacing(double)
Set the spacing between tick and labels.
void setScaleDiv(const QwtScaleDiv &)
virtual void drawBackbone(QPainter *painter) const =0
QwtAbstractScaleDraw()
Constructor.
const QwtScaleMap & scaleMap() const
@ Backbone
Backbone = the line where the ticks are located.
virtual void drawTick(QPainter *painter, double value, double len) const =0
double tickLength(QwtScaleDiv::TickType) const
void setPenWidthF(qreal width)
Specify the width of the scale pen.
void setTransformation(QwtTransform *)
void setTickLength(QwtScaleDiv::TickType, double length)
bool hasComponent(ScaleComponent) const
const QwtText & tickLabel(const QFont &, double value) const
Convert a value into its representing label and cache it.
virtual void drawLabel(QPainter *painter, double value) const =0
double maxTickLength() const
double minimumExtent() const
void setMinimumExtent(double)
Set a minimum for the extent.
virtual QwtText label(double) const
Convert a value into its representing label.
virtual void draw(QPainter *, const QPalette &) const
Draw the scale.
const QwtScaleDiv & scaleDiv() const
double spacing() const
Get the spacing.
virtual ~QwtAbstractScaleDraw()
Destructor.
QFlags< ScaleComponent > ScaleComponents
void enableComponent(ScaleComponent, bool enable=true)
A class representing a scale division.
double lowerBound() const
double upperBound() const
QList< double > ticks(int tickType) const
bool contains(double value) const
TickType
Scale tick types.
@ MediumTick
Medium ticks.
@ NTickTypes
Number of valid tick types.
void setScaleInterval(double s1, double s2)
Specify the borders of the scale interval.
void setTransformation(QwtTransform *)
A class representing a text.
void setLayoutAttribute(LayoutAttribute, bool on=true)
void setRenderFlags(int)
Change the render flags.