NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
customplot.h
Go to the documentation of this file.
1#ifndef CUSTOMPLOT_H
2#define CUSTOMPLOT_H
3
4#include "../dependencies/qcustomplot/qcustomplot.h"
5#include "../NeTrainSim/util/vector.h"
6
7
17class CustomPlot : public QCustomPlot
18{
19 Q_OBJECT
20
21public:
29 explicit CustomPlot(QWidget *parent = nullptr);
30
31protected:
39 virtual void mousePressEvent(QMouseEvent *event) override;
40
48 virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
49
57 virtual void mouseMoveEvent(QMouseEvent *event) override;
58
66 virtual void mouseReleaseEvent(QMouseEvent *event) override;
67
75 virtual void wheelEvent(QWheelEvent *event) override;
76
77private:
78 bool m_isPanning; // Flag to indicate if panning is in progress
79 double m_x0, m_y0; // Initial coordinates for panning
80 double m_xPress, m_yPress; // Press coordinates for panning
81 double m_curXRange, m_curYRange; // Current axis ranges
82 bool m_isScrollButtonClicked; // Flag to indicate if the scroll button is clicked
83
84 qint64 zoomResetTimeStamp; // Time stamp for last zoom reset
85 int zoomResetClickCounter; // Counter for consecutive zoom reset clicks
86
87 double panningSensitivity = 1.0; // Sensitivity factor for panning
88
89private:
96 void centerDrawing();
97
106 std::pair<Vector<double>, Vector<double>> getAllPointsPositions(QCPGraph &graph);
107
115 double calculateSensitivity();
116
125 QPointF getClosestPoint(QMouseEvent *event);
126
127signals:
134 void zoomReset();
135
143 void pointLeftSelected(QPointF point);
144
152 void pointRightSelected(QPointF point);
153
154public slots:
161 void resetZoom();
162};
163
164#endif // CUSTOMPLOT_H
The CustomPlot class is a subclass of QCustomPlot, providing additional functionality and customizati...
Definition customplot.h:18
void resetZoom()
Slot function for handling zoom reset.
Definition customplot.cpp:131
void zoomReset()
Signal emitted when the zoom is reset.
virtual void mouseDoubleClickEvent(QMouseEvent *event) override
Reimplemented mouseDoubleClickEvent from QCustomPlot.
Definition customplot.cpp:42
virtual void mouseMoveEvent(QMouseEvent *event) override
Reimplemented mouseMoveEvent from QCustomPlot.
Definition customplot.cpp:53
void pointRightSelected(QPointF point)
Signal emitted when a data point on the right side is selected.
virtual void wheelEvent(QWheelEvent *event) override
Reimplemented wheelEvent from QCustomPlot.
Definition customplot.cpp:88
void pointLeftSelected(QPointF point)
Signal emitted when a data point on the left side is selected.
virtual void mouseReleaseEvent(QMouseEvent *event) override
Reimplemented mouseReleaseEvent from QCustomPlot.
Definition customplot.cpp:77
virtual void mousePressEvent(QMouseEvent *event) override
Reimplemented mousePressEvent from QCustomPlot.
Definition customplot.cpp:12
A vector.
Definition vector.h:24