]> git.cworth.org Git - apitrace/blob - gui/graphing/heatmapview.h
Update downloads link.
[apitrace] / gui / graphing / heatmapview.h
1 #ifndef HEATMAPVIEW_H
2 #define HEATMAPVIEW_H
3
4 #include "graphview.h"
5
6 /**
7  * The heatmap iterator will only return data when there is something to draw,
8  * this allows much faster access to the data in the case where the view is
9  * zoomed out to the point of where there is multiple calls in one pixel,
10  * it automagically calculates the heat for that pixel.
11  */
12 class HeatmapRowIterator {
13 public:
14     virtual ~HeatmapRowIterator(){}
15
16     /* Go to the next visible heat map */
17     virtual bool next() = 0;
18
19     /* Is the current value GPU or CPU heat */
20     virtual bool isGpu() const = 0;
21
22     /* Current step (normally x coordinate) */
23     virtual int step() const = 0;
24
25     /* Current width (in steps) */
26     virtual int width() const = 0;
27
28     /* Current heat */
29     virtual float heat() const = 0;
30
31     /* Heat value for selected calls */
32     virtual float selectedHeat() const = 0;
33
34     /* Label only used when there is a single call in this heat */
35     virtual QString label() const = 0;
36 };
37
38
39 /**
40  * Data provider for the whole heatmap
41  */
42 class HeatmapDataProvider {
43 public:
44     virtual ~HeatmapDataProvider(){}
45
46     /* The start and end values (time on x-axis) for the heatmap */
47     virtual qint64 start() const = 0;
48     virtual qint64 end() const = 0;
49
50     /*
51      * Header rows (fixed at top of heatmap view)
52      */
53
54     /* Header row count */
55     virtual unsigned headerRows() const = 0;
56
57     /* Label to be used in the vertical axis */
58     virtual QString headerLabel(unsigned row) const = 0;
59
60     /* Get identifier (program no) for row */
61     virtual qint64 headerRowAt(unsigned row) const = 0;
62
63     /* Get item at row and time */
64     virtual qint64 headerItemAt(unsigned row, qint64 time) const = 0;
65
66     /* Get iterator for a row between start and end time for steps */
67     virtual HeatmapRowIterator* headerRowIterator(int row, qint64 start, qint64 end, int steps) const = 0;
68
69     /*
70      * Data rows (scrollable in heatmap view)
71      */
72
73     /* Data row count */
74     virtual unsigned dataRows() const = 0;
75
76     /* Label to be used in the vertical axis */
77     virtual QString dataLabel(unsigned row) const = 0;
78
79     /* Get identifier (program no) for row */
80     virtual qint64 dataRowAt(unsigned row) const = 0;
81
82     /* Get item at row and time */
83     virtual qint64 dataItemAt(unsigned row, qint64 time) const = 0;
84
85     /* Get iterator for a row between start and end time for steps */
86     virtual HeatmapRowIterator* dataRowIterator(int row, qint64 start, qint64 end, int steps) const = 0;
87
88     /* Handle double click on item */
89     virtual void itemDoubleClicked(qint64 index) const = 0;
90
91     /* Get mouse over tooltip for item */
92     virtual QString itemTooltip(qint64 index) const = 0;
93
94     /* Set the selection */
95     virtual void setSelectionState(SelectionState* state) = 0;
96 };
97
98
99 /**
100  * A not very generic heatmap for row based data
101  */
102 class HeatmapView : public GraphView {
103 public:
104     HeatmapView(QWidget* parent);
105
106     void setDataProvider(HeatmapDataProvider* data);
107     void setSelectionState(SelectionState* state);
108
109     virtual void mouseMoveEvent(QMouseEvent *e);
110     virtual void mouseDoubleClickEvent(QMouseEvent *e);
111
112     virtual void paintEvent(QPaintEvent *e);
113     virtual void paintRow(QPainter& painter, HeatmapRowIterator* itr);
114
115
116 protected:
117     qint64 itemAtPosition(QPoint pos);
118
119 protected:
120     int m_rowHeight;
121     HeatmapDataProvider* m_data;
122 };
123
124 #endif