9#include "KChartRulerAttributes.h"
11#include "KChartMath_p.h"
27 QPen majorTickMarkPen;
28 QPen minorTickMarkPen;
31 bool majorTickMarkPenIsSet : 1;
32 bool minorTickMarkPenIsSet : 1;
34 bool showMajorTickMarks : 1;
35 bool showMinorTickMarks : 1;
37 bool showRulerLine : 1;
39 bool majorTickLengthIsSet : 1;
40 bool minorTickLengthIsSet : 1;
42 bool showFirstTick : 1;
51RulerAttributes::Private::Private()
55 , majorTickMarkPenIsSet( false )
56 , minorTickMarkPenIsSet( false )
57 , showMajorTickMarks( true )
58 , showMinorTickMarks( true )
59 , showRulerLine( false )
60 , majorTickLengthIsSet( false )
61 , minorTickLengthIsSet( false )
62 , showFirstTick( true )
64 , majorTickLength( 3 )
65 , minorTickLength( 2 )
72RulerAttributes::RulerAttributes()
79 : _d( new Private( *r.d ) )
88QPen RulerAttributes::tickMarkPen()
const
90 return d->tickMarkPen;
95 d->majorTickMarkPen = pen;
96 d->majorTickMarkPenIsSet =
true;
99bool RulerAttributes::majorTickMarkPenIsSet()
const
101 return d->majorTickMarkPenIsSet;
104QPen RulerAttributes::majorTickMarkPen()
const
106 return d->majorTickMarkPenIsSet ? d->majorTickMarkPen : d->tickMarkPen;
111 d->minorTickMarkPen = pen;
112 d->minorTickMarkPenIsSet =
true;
115bool RulerAttributes::minorTickMarkPenIsSet()
const
117 return d->minorTickMarkPenIsSet;
120QPen RulerAttributes::minorTickMarkPen()
const
122 return d->minorTickMarkPenIsSet ? d->minorTickMarkPen : d->tickMarkPen;
127 if ( !d->customTickMarkPens.contains( value ) )
128 d->customTickMarkPens.insert( value, pen );
131QPen RulerAttributes::tickMarkPen( qreal value )
const
134 while ( it.hasNext() ) {
136 if ( qAbs( value - it.key() ) < std::numeric_limits< float >::epsilon() )
139 return d->tickMarkPen;
144 return d->customTickMarkPens;
147bool RulerAttributes::hasTickMarkPenAt( qreal value )
const
150 while ( it.hasNext() ) {
152 if ( qAbs( value - it.key() ) < std::numeric_limits< float >::epsilon() )
160 d->tickMarkPen.setColor( color );
163QColor RulerAttributes::tickMarkColor()
const
165 return d->tickMarkPen.color();
170 d->showMajorTickMarks = show;
173bool RulerAttributes::showMajorTickMarks()
const
175 return d->showMajorTickMarks;
180 d->showMinorTickMarks = show;
183bool RulerAttributes::showMinorTickMarks()
const
185 return d->showMinorTickMarks;
190 d->labelMargin = margin;
193int RulerAttributes::labelMargin()
const
195 return d->labelMargin;
200 d->majorTickLength = length;
201 d->majorTickLengthIsSet =
true;
204int RulerAttributes::majorTickMarkLength()
const
206 return d->majorTickLength;
209bool RulerAttributes::majorTickMarkLengthIsSet()
const
211 return d->majorTickLengthIsSet;
216 d->minorTickLength = length;
217 d->minorTickLengthIsSet =
true;
220int RulerAttributes::minorTickMarkLength()
const
222 return d->minorTickLength;
225bool RulerAttributes::minorTickMarkLengthIsSet()
const
227 return d->minorTickLengthIsSet;
232 d->showFirstTick = show;
235bool RulerAttributes::showFirstTick()
const
237 return d->showFirstTick;
250RulerAttributes::~RulerAttributes()
252 delete _d; _d =
nullptr;
257 bool isEqual = tickMarkPen() == r.tickMarkPen() &&
258 majorTickMarkPen() == r.majorTickMarkPen() &&
259 minorTickMarkPen() == r.minorTickMarkPen() &&
260 majorTickMarkPenIsSet() == r.majorTickMarkPenIsSet() &&
261 minorTickMarkPenIsSet() == r.minorTickMarkPenIsSet() &&
262 showMajorTickMarks() == r.showMajorTickMarks() &&
263 showMinorTickMarks() == r.showMinorTickMarks() &&
265 showRulerLine() == r.showRulerLine() &&
266 majorTickMarkLengthIsSet() == r.majorTickMarkLengthIsSet() &&
267 minorTickMarkLengthIsSet() == r.minorTickMarkLengthIsSet() &&
268 showFirstTick() == r.showFirstTick() &&
269 d->customTickMarkPens.size() == r.d->customTickMarkPens.size();
275 for ( ; it != d->customTickMarkPens.constEnd(); ++it, ++it2 ) {
285 d->rulerLinePen = pen;
290 return d->rulerLinePen;
293void RulerAttributes::setShowRulerLine(
bool show )
295 d->showRulerLine = show;
298bool RulerAttributes::showRulerLine()
const
300 return d->showRulerLine;
303#if !defined( QT_NO_DEBUG_STREAM )
306 dbg <<
"KChart::RulerAttributes("
307 <<
"tickMarkPen=" << a.tickMarkPen()
308 <<
"majorTickMarkPen=" << a.majorTickMarkPen()
309 <<
"minorTickMarkPen=" << a.minorTickMarkPen();
312 while ( it.hasNext() ) {
314 dbg <<
"customTickMarkPen=(" << it.
value() <<
" : " << it.
key() <<
")";
A set of attributes controlling the appearance of axis rulers.
void setLabelMargin(int margin)
Set margin that should be used between the labels and the ticks.
void setTickMarkColor(const QColor &color)
Color setter method provided for convenience.
void setShowMinorTickMarks(bool show)
Shows or hides minor tick marks.
void setMinorTickMarkLength(int length)
Sets the length of minor tick marks.
void setRulerLinePen(const QPen &pen)
Set the ruler line pen to pen.
void setShowFirstTick(bool show)
Shows or hides the first tick.
void setMajorTickMarkPen(const QPen &pen)
Sets the pen used to draw major tick marks.
void setMajorTickMarkLength(int length)
Sets the length of major tick marks.
void setMinorTickMarkPen(const QPen &pen)
Sets the pen used to draw minor tick marks.
void setShowMajorTickMarks(bool show)
Shows or hides major tick marks.
void setTickMarkPen(const QPen &pen)
Sets the pen used to draw the tick marks.
QPen rulerLinePen() const
Key key(const T &value, const Key &defaultKey) const const
T value(const Key &key, const T &defaultValue) const const