12#include "KDChartLeveyJenningsDiagram_p.h"
16#include "KDChartPainterSaver_p.h"
20#include <QFontMetrics>
22#include <QSvgRenderer>
25#include <KDABLibFakes>
30LeveyJenningsDiagram::Private::Private()
34LeveyJenningsDiagram::Private::~Private()
46void LeveyJenningsDiagram::init()
55 d->expectedMeanValue = 0.0;
56 d->expectedStandardDeviation = 0.0;
104 if (
d->lotChangedPosition ==
pos)
107 d->lotChangedPosition =
pos;
116 return d->lotChangedPosition;
125 if (
d->fluidicsPackChangedPosition ==
pos)
128 d->fluidicsPackChangedPosition =
pos;
137 return d->fluidicsPackChangedPosition;
146 if (
d->sensorChangedPosition ==
pos)
149 d->sensorChangedPosition =
pos;
158 return d->sensorChangedPosition;
166 if (
d->fluidicsPackChanges ==
changes)
178 return d->fluidicsPackChanges;
198 if (
d->scanLinePen ==
pen)
201 d->scanLinePen =
pen;
210 return d->scanLinePen;
229 delete d->iconRenderer[
symbol];
242 return d->sensorChanges;
263 return d->expectedMeanValue;
271 if (
d->expectedStandardDeviation ==
sd)
274 d->expectedStandardDeviation =
sd;
284 return d->expectedStandardDeviation;
292 return d->calculatedMeanValue;
300 return d->calculatedStandardDeviation;
352 for (
int row = 0; row < rowCount; ++row) {
369 const int N = values.
count();
371 d->calculatedMeanValue =
sum /
N;
412 const qreal yMin =
d->expectedMeanValue - 4 *
d->expectedStandardDeviation;
413 const qreal yMax =
d->expectedMeanValue + 4 *
d->expectedStandardDeviation;
445 if (begin.
secsTo(end) > 86400) {
451 }
else if (begin.
secsTo(end) > 3600) {
497 d->reverseMapper.clear();
525 for (
int row = 0; row < rowCount; ++row) {
556 value *=
d->expectedStandardDeviation;
557 value +=
d->expectedMeanValue;
573 }
else if (row > 0) {
582 ctx->coordinatePlane()->translate(location),
593 painter->
setPen(
d->scanLinePen);
594 painter->
drawLine(
ctx->coordinatePlane()->translate(
QPointF(
xValue,
d->expectedMeanValue - 4 *
d->expectedStandardDeviation)),
595 ctx->coordinatePlane()->translate(
QPointF(
xValue,
d->expectedMeanValue + 4 *
d->expectedStandardDeviation)));
602 ctx->setCoordinatePlane(plane);
631 QPointF(
pos.x(),
d->lotChangedPosition &
Qt::AlignTop ?
d->expectedMeanValue + 4 *
d->expectedStandardDeviation :
d->expectedMeanValue - 4 *
d->expectedStandardDeviation));
648 QPointF(
pos.x(),
d->sensorChangedPosition &
Qt::AlignTop ?
d->expectedMeanValue + 4 *
d->expectedStandardDeviation :
d->expectedMeanValue - 4 *
d->expectedStandardDeviation));
665 QPointF(
pos.x(),
d->fluidicsPackChangedPosition &
Qt::AlignTop ?
d->expectedMeanValue + 4 *
d->expectedStandardDeviation :
d->expectedMeanValue - 4 *
d->expectedStandardDeviation));
692 if (
d->iconRenderer[
symbol] == 0)
695 return d->iconRenderer[
symbol];
static QDateTime floorHour(const QDateTime &dt)
static QDate floorDay(const QDateTime &dt)
static QDateTime ceilHour(const QDateTime &dt)
static QDate ceilDay(const QDateTime &dt)
@ MeasureCalculationModeAuto
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=nullptr)
virtual bool checkInvariants(bool justReturnTheStatus=false) const
void setPen(const QModelIndex &index, const QPen &pen)
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
AbstractCoordinatePlane * coordinatePlane() const
static bool isBoundariesValid(const QRectF &r)
Levey Jennings coordinate plane This is actually nothing real more than a plain cartesian coordinate ...
LeveyDiagram defines a Levey Jennings chart.
LeveyJenningsDiagram(QWidget *parent=nullptr, LeveyJenningsCoordinatePlane *plane=nullptr)
void setModel(QAbstractItemModel *model) override
void setScanLinePen(const QPen &pen)
void setExpectedMeanValue(float meanValue)
void setLotChangedSymbolPosition(Qt::Alignment pos)
void setFluidicsPackChanges(const QVector< QDateTime > &changes)
void drawChanges(PaintContext *paintContext)
void setFluidicsPackChangedSymbolPosition(Qt::Alignment pos)
void setExpectedStandardDeviation(float sd)
void calculateMeanAndStandardDeviation() const
QVector< QDateTime > fluidicsPackChanges() const
float expectedStandardDeviation() const
~LeveyJenningsDiagram() override
float calculatedStandardDeviation() const
QVector< QDateTime > sensorChanges() const
float expectedMeanValue() const
QString symbol(Symbol symbol) const
Qt::Alignment sensorChangedSymbolPosition() const
Qt::Alignment fluidicsPackChangedSymbolPosition() const
float calculatedMeanValue() const
void paint(PaintContext *paintContext) override
virtual void drawDataPointSymbol(PaintContext *paintContext, const QPointF &pos, bool ok)
virtual void drawFluidicsPackChangedSymbol(PaintContext *paintContext, const QPointF &pos)
LineDiagram * clone() const override
void setSymbol(Symbol symbol, const QString &filename)
void setSensorChangedSymbolPosition(Qt::Alignment pos)
QPair< QDateTime, QDateTime > timeRange() const
virtual QRectF iconRect() const
QSvgRenderer * iconRenderer(Symbol symbol)
void setTimeRange(const QPair< QDateTime, QDateTime > &timeRange)
bool compare(const LeveyJenningsDiagram *other) const
Qt::Alignment lotChangedSymbolPosition() const
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
void setSensorChanges(const QVector< QDateTime > &changes)
virtual void drawSensorChangedSymbol(PaintContext *paintContext, const QPointF &pos)
virtual void drawLotChangeSymbol(PaintContext *paintContext, const QPointF &pos)
LineDiagram defines a common line diagram.
Measure is used to specify relative and absolute sizes in KDChart, e.g. font sizes.
Stores information about painting diagrams.
A set of text attributes.
void setFontSize(const Measure &measure)
void columnsInserted(const QModelIndex &parent, int first, int last)
void columnsRemoved(const QModelIndex &parent, int first, int last)
virtual QVariant data(const QModelIndex &index, int role) const const=0
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
void layoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
virtual int rowCount(const QModelIndex &parent) const const=0
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
QAbstractItemModel * model() const const
QModelIndex rootIndex() const const
void setSelectionMode(QAbstractItemView::SelectionMode mode)
QItemSelectionModel * selectionModel() const const
virtual void setModel(QAbstractItemModel *model)
QDate addDays(qint64 ndays) const const
QDateTime startOfDay(Qt::TimeSpec spec, int offsetSeconds) const const
QDateTime addSecs(qint64 s) const const
qint64 secsTo(const QDateTime &other) const const
qint64 toSecsSinceEpoch() const const
QModelIndex currentIndex() const const
QModelIndex sibling(int row, int column) const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QObject * parent() const const
T qobject_cast(QObject *object)
void drawLine(const QLineF &line)
const QPen & pen() const const
void setClipping(bool enable)
void setPen(const QColor &color)
void setRenderHint(QPainter::RenderHint hint, bool on)
void translate(const QPointF &offset)
void setDashPattern(const QVector< qreal > &pattern)
QPoint toPoint() const const
QString fromLatin1(const char *str, int size)
bool toBool() const const
QDateTime toDateTime() const const
int toInt(bool *ok) const const
qreal toReal(bool *ok) const const
int count(const T &value) const const