summaryrefslogtreecommitdiff
path: root/gui/graphing/graphaxiswidget.h
blob: a8d1c01a1b19bb488471c26ccf315c6f8793f696 (plain)
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
#pragma once

#include "graphing.h"

#include <QWidget>

/**
 * The generic base class of all graph axes.
 *
 * Handles orientation, simple selections, and view area.
 */
class GraphAxisWidget : public QWidget {
    Q_OBJECT
public:
    enum Orientation {
        Horizontal,
        Vertical
    };

    enum SelectionStyle {
        None,
        Single,
        Range
    };

public:
    GraphAxisWidget(QWidget* parent = 0);
    virtual ~GraphAxisWidget(){}

    /* Is this axis part of the active selection */
    bool hasSelection();

    void setSelectable(SelectionStyle selectable);
    void setSelectionState(SelectionState* state);

    void setOrientation(Orientation v);

    virtual void mouseMoveEvent(QMouseEvent *e);
    virtual void mousePressEvent(QMouseEvent *e);
    virtual void mouseReleaseEvent(QMouseEvent *e);

public slots:
    /* The minimum and maximum values of this axis */
    void setRange(qint64 min, qint64 max);

    /* The currently visible range of values */
    void setView(qint64 start, qint64 end);

signals:
    void selectionChanged();

protected:
    Orientation m_orientation;

    /* The min/max value of this axis */
    qint64 m_valueMin;
    qint64 m_valueMax;

    /* The highest and lowest currently visible value */
    qint64 m_valueBegin;
    qint64 m_valueEnd;

    /* Selection */
    SelectionStyle m_selectable;
    SelectionState* m_selectionState;

    /* Mouse tracking */
    QPoint m_mousePressPosition;
    qint64 m_mousePressValue;
};