24 #include "KDChartLeveyJenningsAxis_p.h" 32 #include "KDChartAbstractGrid.h" 33 #include "KDChartPainterSaver_p.h" 37 #include <KDABLibFakes> 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 );
QPair< QDateTime, QDateTime > timeRange() const
Returns the timerange of the diagram's data.
virtual void paintAsOrdinate(PaintContext *)
void paintCtx(PaintContext *) override
reimpl
void setLabels(const QStringList &list)
Use this to specify your own set of strings, to be used as axis labels.
void setType(LeveyJenningsGridAttributes::GridType type)
Sets the type of the axis to type.
AbstractCoordinatePlane * coordinatePlane() const
void setPen(const QPen &pen)
Set the pen to use for rendering the text.
const QPointF translate(const QPointF &diagramPoint) const override
Translate the given point in value space coordinates to a position in pixel space.
QPainter * painter() const
Layout item showing a text.
void setDateFormat(Qt::DateFormat format)
Levey Jennings coordinate plane This is actually nothing real more than a plain cartesian coordinate ...
QSize sizeHint() const override
pure virtual in QLayoutItem
AbstractDiagram defines the interface for diagram classes.
QStringList labels() const
Returns a list of strings, that are used as axis labels, as set via setLabels.
const AbstractDiagram * diagram() const
LeveyDiagram defines a Levey Jennings chart.
void paintCtx(PaintContext *) override
reimpl
The class for cartesian axes.
void setTextAttributes(const TextAttributes &a)
Use this to specify the text attributes to be used for axis labels.
Qt::DateFormat dateFormat() const
bool compare(const LeveyJenningsAxis *other) const
Returns true if both axes have the same settings.
TextAttributes textAttributes() const
Returns the text attributes to be used for axis labels.
float calculatedStandardDeviation() const
Returns the calculated standard deviation over all QC values.
virtual bool isOrdinate() const
float expectedStandardDeviation() const
Returns the expected standard deviation over all QC values.
virtual bool isAbscissa() const
LeveyJenningsGridAttributes::GridType type() const
Stores information about painting diagrams.
virtual const Position position() const
QRect geometry() const override
pure virtual in QLayoutItem
LeveyJenningsAxis(LeveyJenningsDiagram *diagram=0)
C'tor of the class for levey jennings axes.
~LeveyJenningsAxis() override
Class only listed here to document inheritance of some KDChart classes.
static QPen scalePen(const QPen &pen)
virtual const QString customizedLabel(const QString &label) const
Reimplement this method if you want to adjust axis labels before they are printed.
virtual void paintAsAbscissa(PaintContext *)
The class for levey jennings axes.
virtual void takeAxis(CartesianAxis *axis)
Removes the axis from the diagram, without deleting it.
float expectedMeanValue() const
Returns the expected mean values over all QC values.
float calculatedMeanValue() const
Returns the calculated mean values over all QC values.
A set of text attributes.