123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #pragma once
- #include <QWidget>
- #include <QPaintEvent>
- #include <QPen>
- #include <QPainter>
- #include <vector>
- struct GraphSeries {
- std::vector<QPointF>* data;
- double minX, maxX;
- double minY, maxY;
- QString name;
- QColor color;
- int lineWidth = 2;
- double circleRadius = 1.0;
- enum class SeriesType{ Line, Dot, LineDot};
- SeriesType type;
- };
- class GraphView :public QWidget
- {
- Q_OBJECT
- public:
- GraphView(QWidget* parent, QString title);
- ~GraphView();
- QString title;
- private:
- void GraphView::paintEvent(QPaintEvent* event);
- //Data
- std::vector<GraphSeries> graphSeriesVec;
- double minGraphX = 0, maxGraphX = 0, minGraphY = 0, maxGraphY = 0, rangeGraphX = 0, rangeGraphY = 0;
-
-
- //Visualization
- QString xAxisNumbers[11];
- QString yAxisNumbers[11];
- double hueoffset;
- QPen linePen, rectPen, axisPen;
- public:
- void generateAndAddRandomLine();
- void addLine(std::vector<QPointF>& line);
- void addLine(std::vector<QPointF>& line, QColor color);
- void addDots(std::vector<QPointF>& dots);
- void addDots(std::vector<QPointF>& dots, QColor color);
- private:
- void generateAxisNumberStrings();
- void calculateMinMaxGraphXY();
- void GraphView::calculateMinMaxXY(std::vector<QPointF>& line, GraphSeries& lgs);
- void addSeries(std::vector<QPointF>& line, QColor color, GraphSeries::SeriesType type);
- QColor generateNextColorForGraph();
- QPointF transformPoint(QPointF& point, double stregth_factorX, double stregth_factorY);
- };
|