statistics: convert box-and-whiskers plot to QSG

This is lazy: Derive from the bar chart item and add whiskers
in the subclassed render() function. The code is ugly, because
the base class function clears the dirty flags and therefore
the derived class has to remember them. Oh well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-17 21:07:57 +01:00 committed by bstoeger
parent 5d5ebfcf3c
commit 409f159e1d
4 changed files with 117 additions and 56 deletions

View file

@ -5,13 +5,12 @@
#ifndef BOX_SERIES_H
#define BOX_SERIES_H
#include "chartitem.h"
#include "statsseries.h"
#include "statsvariables.h" // for StatsQuartiles
#include <memory>
#include <vector>
#include <QGraphicsLineItem>
#include <QGraphicsRectItem>
struct InformationBox;
class QGraphicsScene;
@ -36,16 +35,12 @@ private:
int getItemUnderMouse(const QPointF &f);
struct Item {
QGraphicsRectItem box;
QGraphicsLineItem topWhisker, bottomWhisker;
QGraphicsLineItem topBar, bottomBar;
QGraphicsLineItem center;
QRectF bounding; // bounding box in screen coordinates
~Item();
std::unique_ptr<ChartBoxItem> item;
double lowerBound, upperBound;
StatsQuartiles q;
QString binName;
Item(QGraphicsScene *scene, BoxSeries *series, double lowerBound, double upperBound, const StatsQuartiles &q, const QString &binName);
Item(StatsView &view, BoxSeries *series, double lowerBound, double upperBound, const StatsQuartiles &q, const QString &binName);
~Item();
void updatePosition(BoxSeries *series);
void highlight(bool highlight);
};