GraphPlott.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <vector>
  3. #include "Plott.h"
  4. #include "RunData.h"
  5. #include "GraphViewSettingDialog.h"
  6. #include <QString>
  7. #include <QLabel>
  8. #include <string>
  9. #include "Scratchpad.h"
  10. #include "HoverButton.h"
  11. #include "InformationPopUp.h"
  12. class GraphViewSettingDialog;
  13. struct GraphPlottSeries {
  14. std::vector<GraphDataPoint>* data;
  15. double xMin, xMax;
  16. double yMin, yMax;
  17. std::string runName;
  18. //Settings for visual
  19. QString description;
  20. QColor color;
  21. int lineWidth = 2;
  22. double circleRadius = 2.0;
  23. enum class SeriesType { Line, Dot, LineDot };
  24. bool useDataPointColor = false;
  25. SeriesType type;
  26. bool hide = false;
  27. };
  28. class GraphPlott : public Plott
  29. {
  30. Q_OBJECT
  31. public:
  32. GraphPlott(QWidget *parent,bool settingsButton = true, bool informationButton = true, bool gridButton = true);
  33. ~GraphPlott();
  34. void addSeries(std::vector<GraphDataPoint>* line, std::string runName, QString description, QColor color, GraphPlottSeries::SeriesType type);
  35. void removeRunData(RunData* run);
  36. void removeAll();
  37. void setInformation(QString information);
  38. std::vector<GraphPlottSeries>& getSeriesVector();
  39. void virtual resetToDefaultWindow() override;
  40. void virtual frameGraphInView();
  41. void setDisplayLabel(QString file);
  42. void setScratchpad(Scratchpad* pad);
  43. protected:
  44. QHBoxLayout* buttonPanel;
  45. void showInformation();
  46. void drawData(QPainter& painter) override;
  47. void mouseMoveEvent(QMouseEvent* event) override;
  48. std::vector<GraphPlottSeries> seriesVec;
  49. virtual void handleSelectedWindow(VisibleWindow& window, QMouseEvent* event) override;
  50. int stayStillTimeMS = 300;
  51. virtual void searchForPointUnderCursor();
  52. virtual void addPointsInWindowToScratchPad(VisibleWindow& window);
  53. //Help Function:
  54. double sqaredDistance(const QPointF& a, const QPointF& b);
  55. QPoint lastPosition;
  56. QTimer* timer = new QTimer(this);
  57. Scratchpad* pad = nullptr;
  58. HoverButton* informationButton = new HoverButton();
  59. InformationPopUp* popupWidget = new InformationPopUp(nullptr);
  60. private:
  61. QMenu* selectMenu = new QMenu(this);
  62. QAction* displayAreaAction = new QAction("Display this area", this);
  63. QAction* scratchpadAction = new QAction("Add points to Scratchpad", this);
  64. GraphViewSettingDialog* dialog;
  65. QString displayNameOfDataThatIsDisplayed = "";
  66. QString informationButtonString = "No information.";
  67. QString graphplottInformation = "<h3><u>Control:</u></h3><b>Scrolling:</b> Zooms in and out.<br><b>Scrolling + CTRL:</b> Zooms only horizontally.<br><b>Scrolling + SHIFT:</b> Zooms only vertically.<br><b>Drag & Drop LMB:</b> Moves the visible area.<br><b>Drag & Drop RMB:</b> Selects area to display or add solutions to Scratchpad.<br><b>Drag & Drop RMB + CTRL:</b> Selects area to display.<br><b>Drag & Drop RMB + ALT:</b> Adds solutions to Scratchpad.<br><b>Arrow Keys:</b> Moves the visible area<br><b>Page Up:</b> Zooms in.<br><b>Page Down:</b> Zooms out.<br><b>CTRL + R:</b> Resets the visible area.<br>";
  68. QLabel* displayLabel;
  69. virtual void keyPressEvent(QKeyEvent* event) override;
  70. };