CustomLineGraph.h 682 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <QWidget>
  3. #include <QPaintEvent>
  4. #include <QPen>
  5. #include <QPainter>
  6. #include <vector>
  7. struct LineGraphSeries {
  8. std::vector<QPoint> data;
  9. double minX, maxX;
  10. double minY, maxY;
  11. double rangeX, rangeY;
  12. QColor color;
  13. };
  14. //bool compTest(QPoint a, QPoint b) {
  15. // return a.x() < b.x();
  16. //}
  17. class CustomLineGraph :public QWidget
  18. {
  19. Q_OBJECT
  20. public:
  21. CustomLineGraph(QWidget* parent);
  22. ~CustomLineGraph();
  23. void CustomLineGraph::paintEvent(QPaintEvent* event);
  24. private:
  25. std::vector<LineGraphSeries> seriesVec;
  26. QPen linePen, rectPen, axisPen;
  27. QPoint transformPoint(QPoint& point, LineGraphSeries& lgs, double stregth_factorX, double stregth_factorY);
  28. };