 |
KD Chart 2
[rev.2.8]
|
Go to the documentation of this file.
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() ) )
102 color = qobject_cast< const LeveyJenningsCoordinatePlane* >(
d->diagram()->coordinatePlane() )->gridAttributes().gridPen(
type ).color();
104 pen.setColor( color );
123 if ( other ==
this )
return true;
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 ) ) );
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 );
void setDateFormat(Qt::DateFormat format)
void setGeometry(const QRect &r) override
pure virtual in QLayoutItem
virtual bool isOrdinate() const
void setText(const QString &text)
virtual Position position() const
~LeveyJenningsAxis() override
const QPointF translate(const QPointF &diagramPoint) const override
Translate the given point in value space coordinates to a position in pixel space.
void setTextAttributes(const TextAttributes &a)
Use this to specify the text attributes to be used for axis labels.
float calculatedStandardDeviation() const
Returns the calculated standard deviation over all QC values.
The class for cartesian axes.
LeveyDiagram defines a Levey Jennings chart.
Levey Jennings coordinate plane This is actually nothing real more than a plain cartesian coordinate ...
static QPen scalePen(const QPen &pen)
void paint(QPainter *) override
AbstractCoordinatePlane * coordinatePlane() const
float expectedMeanValue() const
Returns the expected mean values over all QC values.
QSize sizeHint() const override
pure virtual in QLayoutItem
LeveyJenningsAxis(LeveyJenningsDiagram *diagram=0)
C'tor of the class for levey jennings axes.
Stores information about painting diagrams.
A set of text attributes.
void setLabels(const QStringList &list)
Use this to specify your own set of strings, to be used as axis labels.
The class for levey jennings axes.
virtual void paintAsOrdinate(PaintContext *)
virtual void paintAsAbscissa(PaintContext *)
QPainter * painter() const
bool compare(const LeveyJenningsAxis *other) const
Returns true if both axes have the same settings.
void paintCtx(PaintContext *) override
reimpl
QStringList labels() const
Returns a list of strings, that are used as axis labels, as set via setLabels.
AbstractDiagram defines the interface for diagram classes.
float calculatedMeanValue() const
Returns the calculated mean values over all QC values.
void setType(LeveyJenningsGridAttributes::GridType type)
Sets the type of the axis to type.
virtual const QString customizedLabel(const QString &label) const
Reimplement this method if you want to adjust axis labels before they are printed.
QPair< QDateTime, QDateTime > timeRange() const
Returns the timerange of the diagram's data.
QRect geometry() const override
pure virtual in QLayoutItem
void paintCtx(PaintContext *) override
reimpl
void setPen(const QPen &pen)
Set the pen to use for rendering the text.
const AbstractDiagram * diagram() const
Layout item showing a text.
LeveyJenningsGridAttributes::GridType type() const
float expectedStandardDeviation() const
Returns the expected standard deviation over all QC values.
virtual bool isAbscissa() const
@ MeasureOrientationMinimum
virtual void takeAxis(CartesianAxis *axis)
Removes the axis from the diagram, without deleting it.
Qt::DateFormat dateFormat() const
TextAttributes textAttributes() const
Returns the text attributes to be used for axis labels.