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