From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/charts/ChartScene.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/charts/ChartScene.h (limited to 'src/charts/ChartScene.h') diff --git a/src/charts/ChartScene.h b/src/charts/ChartScene.h new file mode 100644 index 0000000..3a9af62 --- /dev/null +++ b/src/charts/ChartScene.h @@ -0,0 +1,55 @@ +#ifndef CHART_SCENE_H +#define CHART_SCENE_H + +#include +#include + +#include "Chart.h" +#include "DataPoint.h" + +class ChartScene: public QGraphicsScene +{ +public: + static const QSizeF Margin; + static const QSizeF Padding; + static const QSizeF DataSetPadding; + +public: + static QSizeF getBorder(); + +public: + ChartScene(Chart* chart); + void setDataSet(const QList& dataSet, int xTickInterval); + void setDataDirection(int direction) { dataDirection = direction; } + QString getXLabel() const { return chart->getXLabel(); } + QString getYLabel() const { return chart->getYLabel(); } + int getDataDirection() const { return dataDirection; } + QPointF getChartOrigin() const; + QRectF getChartRect() const; + QSizeF getDataSetSize() const; + QList getDataSet() const {return dataSet; } + qreal getXTickSpacing() const; + qreal getYPosFromValue(int value) const; + int getMinY() const { return yMin; } + int getMaxY() const { return yMax; } + int getYDiff() const { return yMax - yMin; } + int getYTickSpacing() const { return yTickSpacing; } + +private: + void initYScale(); + int computeMinY() const; + int computeMaxY() const; + int computeYTickSpacing() const; + void extendYMinMax(); + +private: + Chart* chart; + QList dataSet; + int yMin; + int yMax; + qreal yScale; + int yTickSpacing; + int dataDirection; +}; + +#endif -- cgit