]> git.cworth.org Git - apitrace/blob - gui/timelinewidget.h
Improve internal format of profile results.
[apitrace] / gui / timelinewidget.h
1 #ifndef TIMELINEWIDGET_H
2 #define TIMELINEWIDGET_H
3
4 #include <QWidget>
5 #include <QList>
6 #include <QPen>
7 #include "trace_profiler.hpp"
8
9 class TimelineWidget : public QWidget
10 {
11     Q_OBJECT
12
13     enum MousePressMode {
14         NoMousePress,
15         DragView,
16         RulerZoom,
17         RulerSelect
18     };
19
20 public:
21     TimelineWidget(QWidget *parent = 0);
22
23     void setProfile(trace::Profile* profile);
24
25 protected:
26     virtual void wheelEvent(QWheelEvent *e);
27     virtual void mousePressEvent(QMouseEvent *e);
28     virtual void mouseMoveEvent(QMouseEvent *e);
29     virtual void mouseReleaseEvent(QMouseEvent *e);
30     virtual void mouseDoubleClickEvent(QMouseEvent *e);
31
32     virtual void paintEvent(QPaintEvent *e);
33     virtual void resizeEvent(QResizeEvent *e);
34
35 public slots:
36     void setHorizontalScrollValue(int value);
37     void setVerticalScrollValue(int value);
38
39 signals:
40     void verticalScrollMaxChanged(int max);
41     void verticalScrollValueChanged(int value);
42
43     void horizontalScrollMaxChanged(int max);
44     void horizontalScrollValueChanged(int value);
45
46     void jumpToCall(int call);
47
48     void selectionChanged(int64_t start, int64_t end);
49
50 private:
51     void setSelection(int64_t start, int64_t end, bool notify = false);
52     void setRowScroll(int position, bool notify = true);
53     void setTimeScroll(int64_t time, bool notify = true);
54
55     void drawHeat(QPainter& painter, int x, int64_t heat, bool isCpu);
56
57     double timeToPosition(int64_t time);
58     int64_t positionToTime(int pos);
59
60     void calculateRows();
61
62     const trace::Profile::Frame* frameAtTime(int64_t time);
63     const trace::Profile::Call* cpuCallAtTime(int64_t time);
64     const trace::Profile::Call* drawCallAtTime(int64_t time, int program);
65
66 private:
67     /* Data */
68     trace::Profile* m_profile;
69     std::vector<int> m_rowPrograms;
70
71     /* Scrollbars */
72     int m_scrollX;
73     int m_scrollY;
74     int m_maxScrollX;
75     int m_maxScrollY;
76
77     /* Viewport */
78     int m_viewWidth;
79     int m_viewHeight;
80
81     /* Visible Times */
82     int64_t m_time;
83     int64_t m_timeMin;
84     int64_t m_timeMax;
85     int64_t m_timeWidth;
86     int64_t m_timeWidthMin;
87     int64_t m_timeWidthMax;
88     int64_t m_timeSelectionStart;
89     int64_t m_timeSelectionEnd;
90
91     /* Visible Rows */
92     int m_row;
93     int m_rowCount;
94
95     /* Mouse data */
96     int m_mousePressRow;
97     int64_t m_mousePressTime;
98     QPoint m_mousePosition;
99     QPoint m_mousePressPosition;
100     MousePressMode m_mousePressMode;
101
102     /* Style */
103     int m_rowHeight;
104     int m_axisWidth;
105     int m_axisHeight;
106     QPen m_axisLine;
107     QPen m_axisBorder;
108     QPen m_axisForeground;
109     QBrush m_axisBackground;
110     QPen m_itemBorder;
111     QPen m_itemForeground;
112     QBrush m_itemBackground;
113     QPen m_selectionBorder;
114     QBrush m_selectionBackground;
115     QPen m_zoomBorder;
116     QBrush m_zoomBackground;
117 };
118
119 #endif // TIMELINEWIDGET_H