File: graphaxiswidget.h

package info (click to toggle)
apitrace 7.1%2Bgit20170623.d38a69d6%2Brepack-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,992 kB
  • sloc: cpp: 179,347; ansic: 62,439; python: 33,058; java: 377; makefile: 105; sh: 26; xml: 26
file content (70 lines) | stat: -rw-r--r-- 1,528 bytes parent folder | download | duplicates (6)
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) override;
    virtual void mousePressEvent(QMouseEvent *e) override;
    virtual void mouseReleaseEvent(QMouseEvent *e) override;

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;
};