-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistoryGraph.h
More file actions
128 lines (70 loc) · 2.98 KB
/
HistoryGraph.h
File metadata and controls
128 lines (70 loc) · 2.98 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// HistoryGraph.h
// Declares the SnapshotsGraph class representing a UI widget that displays the allocation history of several snapshots
#ifndef SNAPSHOTSGRAPH_H
#define SNAPSHOTSGRAPH_H
#include <memory>
#include <QWidget>
// fwd:
class QItemSelectionModel;
class Project;
typedef std::shared_ptr<Project> ProjectPtr;
class CodeLocation;
class Snapshot;
class HistoryModel;
typedef std::shared_ptr<HistoryModel> HistoryModelPtr;
class HistoryGraph:
public QWidget
{
typedef QWidget Super;
Q_OBJECT
public:
explicit HistoryGraph(QWidget * a_Parent = nullptr);
/** Sets the project whose snapshots are to be displayed. */
void setProject(ProjectPtr a_Project, HistoryModel * a_Model, QItemSelectionModel * a_Selection);
signals:
public slots:
/** Called when the project data has changed and the display should be recalculated. */
void projectDataChanged();
/** Called when the selection of the project data has changed and the display should redraw. */
void selectionChanged();
protected:
/** The project whose snapshots are to be displayed. */
ProjectPtr m_Project;
/** The minimum timestamp value out of all snapshots in the project. */
quint64 m_MinTimestamp;
/** The maximum timestamp value out of all snapshots in the project. */
quint64 m_MaxTimestamp;
/** The difference between max and min timestamps, or 1 if below. */
quint64 m_RangeTimestamp;
/** The maximum heap size value out of all snapshots in the project. */
quint64 m_MaxHeapSize;
/** The maximum heap extra size value out of all snapshots in the project. */
quint64 m_MaxHeapExtraSize;
/** The maximum sum of heap size and heap extra size out of all snapshots in the project. */
quint64 m_MaxTotalSize;
/** The maximum value of the total size, as used for the graph coord projection (never zero) */
quint64 m_RangeTotalSize;
/** Width of the widget's paint area, used for projection. */
int m_Width;
/** Height of the widget's paint area, used for projection. */
int m_Height;
/** The model that provides the graphed data. */
HistoryModel * m_Model;
/** The selection that is used to display the highlights. */
QItemSelectionModel * m_Selection;
/** Updates the internal variables needed for correct projection of X and Y values. */
void updateProjection();
// QWidget overrides:
virtual void paintEvent(QPaintEvent * a_PaintEvent) override;
/** Paints the graph part of the widget, into the rect [0, 0, m_Width, m_Height]. */
void paintGraph(QPainter & a_Painter);
/** Projects the specified value into the graph X coordinate. */
int projectionX(quint64 a_ValueX);
/** Projects the specified value into the graph Y coordinate. */
int projectionY(quint64 a_ValueY);
/** Projects the m_GraphedCodeLocations[] values into graph Y coordinates.
a_OutCoords is an array that receives the Y coords.
The code locations' sizes are accumulated on top of each other. */
void projectCodeLocationsY(Snapshot * a_Snapshot, std::vector<int> & a_OutCoords);
};
#endif // SNAPSHOTSGRAPH_H