diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 |
commit | d24f813f3f2a05c112e803e4256b53535895fc98 (patch) | |
tree | 601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/charts/ChartScene.h |
Diffstat (limited to 'src/charts/ChartScene.h')
-rw-r--r-- | src/charts/ChartScene.h | 55 |
1 files changed, 55 insertions, 0 deletions
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 <QtCore> +#include <QtWidgets> + +#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<DataPoint>& 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<DataPoint> 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<DataPoint> dataSet; + int yMin; + int yMax; + qreal yScale; + int yTickSpacing; + int dataDirection; +}; + +#endif |