]> git.cworth.org Git - apitrace/blob - gui/graphing/graphaxiswidget.h
d3dretrace: Force DWM traces to run on a window.
[apitrace] / gui / graphing / graphaxiswidget.h
1 #ifndef GRAPHAXISWIDGET_H
2 #define GRAPHAXISWIDGET_H
3
4 #include "graphing.h"
5
6 #include <QWidget>
7
8 /**
9  * The generic base class of all graph axes.
10  *
11  * Handles orientation, simple selections, and view area.
12  */
13 class GraphAxisWidget : public QWidget {
14     Q_OBJECT
15 public:
16     enum Orientation {
17         Horizontal,
18         Vertical
19     };
20
21     enum SelectionStyle {
22         None,
23         Single,
24         Range
25     };
26
27 public:
28     GraphAxisWidget(QWidget* parent = 0);
29     virtual ~GraphAxisWidget(){}
30
31     /* Is this axis part of the active selection */
32     bool hasSelection();
33
34     void setSelectable(SelectionStyle selectable);
35     void setSelectionState(SelectionState* state);
36
37     void setOrientation(Orientation v);
38
39     virtual void mouseMoveEvent(QMouseEvent *e);
40     virtual void mousePressEvent(QMouseEvent *e);
41     virtual void mouseReleaseEvent(QMouseEvent *e);
42
43 public slots:
44     /* The minimum and maximum values of this axis */
45     void setRange(qint64 min, qint64 max);
46
47     /* The currently visible range of values */
48     void setView(qint64 start, qint64 end);
49
50 signals:
51     void selectionChanged();
52
53 protected:
54     Orientation m_orientation;
55
56     /* The min/max value of this axis */
57     qint64 m_valueMin;
58     qint64 m_valueMax;
59
60     /* The highest and lowest currently visible value */
61     qint64 m_valueBegin;
62     qint64 m_valueEnd;
63
64     /* Selection */
65     SelectionStyle m_selectable;
66     SelectionState* m_selectionState;
67
68     /* Mouse tracking */
69     QPoint m_mousePressPosition;
70     qint64 m_mousePressValue;
71 };
72
73 #endif