24 #include "KDChartLeveyJenningsAxis_p.h"
32 #include "KDChartAbstractGrid.h"
33 #include "KDChartPainterSaver_p.h"
37 #include <KDABLibFakes>
41 using namespace KDChart;
55 while (
d->mDiagram ) {
65 void LeveyJenningsAxis::init ()
69 const QStringList
labels = QStringList() << tr(
"-3sd" ) << tr(
"-2sd" ) << tr(
"mean" )
70 << tr(
"+2sd" ) << tr(
"+3sd" );
94 if ( type !=
d->type )
99 if ( qobject_cast< const LeveyJenningsDiagram* >(
d->diagram() ) &&
100 qobject_cast< const LeveyJenningsCoordinatePlane* >(
d->diagram()->coordinatePlane() ) )
104 pen.setColor( color );
123 if ( other ==
this )
return true;
128 return ( static_cast<const CartesianAxis*>(
this)->
compare( other ) ) &&
135 Q_ASSERT_X (
d->diagram(),
"LeveyJenningsAxis::paint",
136 "Function call not allowed: The axis is not assigned to any diagram." );
139 Q_ASSERT_X ( plane,
"LeveyJenningsAxis::paint",
140 "Bad function call: PaintContext::coodinatePlane() NOT a levey jennings plane." );
144 if ( !
d->diagram()->model() )
165 const bool drawLabels = labelTA.
isVisible();
174 << ( meanValue - 2 * standardDeviation )
176 << ( meanValue + 2 * standardDeviation )
177 << ( meanValue + 3 * standardDeviation );
179 Q_ASSERT_X( values.count() <=
labels().count(),
"LeveyJenningsAxis::paintAsOrdinate",
"Need to have at least 5 labels" );
187 QPainter*
const painter = context->
painter();
188 const PainterSaver ps( painter );
189 painter->setRenderHint( QPainter::Antialiasing,
true );
190 painter->setClipping(
false );
194 for (
int i = 0; i < values.count(); ++i )
196 const QPointF labelPos = plane->
translate( QPointF( 0.0, values.at( i ) ) );
198 labelItem.setText( label );
199 const QSize size = labelItem.sizeHint();
201 labelItem.setGeometry( QRectF( QPointF( xPos, labelPos.y() - size.height() / 2.0 ), size ).toRect() );
210 labelItem.paint( painter );
219 setLabels( QStringList() << QString::fromLatin1(
" " ) );
228 const bool drawLabels = labelTA.
isVisible();
236 QPainter*
const painter = context->
painter();
237 const PainterSaver ps( painter );
238 painter->setRenderHint( QPainter::Antialiasing,
true );
239 painter->setClipping(
false );
247 QSize origSize = labelItem.
sizeHint();
248 if ( range.first.secsTo( range.second ) < 86400 )
257 labelItem.setGeometry( QRectF( QPointF(
geometry().left() - origSize.width() / 2.0, yPos ), size ).toRect() );
258 labelItem.paint( painter );
267 if ( range.first.secsTo( range.second ) < 86400 )
275 labelItem2.setGeometry( QRectF( QPointF(
geometry().right() - size.width() + origSize.width() / 2.0, yPos ), size ).toRect() );
276 labelItem2.paint( painter );