blob: 03848bf97f00ed57846d04e025c9adebb11df89f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#pragma once
#include "graphing.h"
#include <QWidget>
/**
* The generic base class for a graph's view, this is the component that
* displays the actual data for the graph.
*
* - Stores the view area within the graph
* - Simple user interaction such as translating and zooming with mouse
* - Selection tracking synchronised with axis
*/
class GraphView : public QWidget {
Q_OBJECT
public:
GraphView(QWidget* parent = 0);
virtual ~GraphView(){}
virtual void update();
virtual void resizeEvent(QResizeEvent *) override;
virtual void wheelEvent(QWheelEvent *e) override;
virtual void mouseMoveEvent(QMouseEvent *e) override;
virtual void mousePressEvent(QMouseEvent *e) override;
virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
virtual void setSelectionState(SelectionState* state);
void setHorizontalView(qint64 start, qint64 end);
void setVerticalView(qint64 start, qint64 end);
protected:
void setDefaultView(qint64 min, qint64 max);
signals:
void selectionChanged();
void verticalViewChanged(qint64 start, qint64 end);
void verticalRangeChanged(qint64 min, qint64 max);
void horizontalRangeChanged(qint64 min, qint64 max);
void horizontalViewChanged(qint64 start, qint64 end);
protected:
/* Viewport area */
qint64 m_viewLeft;
qint64 m_viewRight;
qint64 m_viewBottom;
qint64 m_viewTop;
/* Graph limits */
qint64 m_graphLeft;
qint64 m_graphRight;
qint64 m_graphBottom;
qint64 m_graphTop;
/* Viewport width (m_viewRight - m_viewLeft), used for zoom */
qint64 m_viewWidth;
qint64 m_viewWidthMin;
qint64 m_viewWidthMax;
/* Viewport height (m_viewTop - m_viewBottom), used for zoom */
qint64 m_viewHeight;
qint64 m_viewHeightMin;
qint64 m_viewHeightMax;
/* Mouse tracking */
QPoint m_mousePressPosition;
qint64 m_mousePressViewLeft;
qint64 m_mousePressViewBottom;
/* Selection */
SelectionState* m_selectionState;
/* State from the last update() call */
struct PreviousUpdate {
qint64 m_viewLeft;
qint64 m_viewRight;
qint64 m_viewBottom;
qint64 m_viewTop;
qint64 m_graphLeft;
qint64 m_graphRight;
qint64 m_graphBottom;
qint64 m_graphTop;
} m_previous;
};
|