File: graphwidget.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 (109 lines) | stat: -rw-r--r-- 3,025 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once

#include "graphview.h"
#include "graphaxiswidget.h"
#include "graphlabelwidget.h"

class QScrollBar;

/**
 * The generic GraphWidget class which combines the elements of a graph,
 * the axis, view, scrollbars and label.
 */
class GraphWidget : public QWidget {
    Q_OBJECT
public:
    enum AxisPosition {
        AxisTop,
        AxisLeft,
        AxisRight,
        AxisBottom
    };

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

    GraphView* view();
    GraphLabelWidget* label();
    GraphAxisWidget* axis(AxisPosition pos);

    void setView(GraphView* view);
    void setLabel(GraphLabelWidget* label);
    void setAxis(AxisPosition pos, GraphAxisWidget* axis);

    void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy);
    void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy);

    virtual void resizeEvent(QResizeEvent *e) override;

protected:
    /* Used if a selection would be shared between graphs with different axis */
    virtual SelectionState transformSelectionIn(SelectionState state);
    virtual SelectionState transformSelectionOut(SelectionState state);

    /* Update the scrollbars based on current view */
    void updateScrollbars();

    /* Update all signal / slot connections */
    void updateConnections();

    /* Recalculate child widget layout */
    void updateLayout();

public slots:
    void setSelection(SelectionState state);

    /* Set view areas */
    void setHorizontalView(qint64 start, qint64 end);
    void setVerticalView(qint64 start, qint64 end);

protected slots:
    /* View changed by translation / zooming */
    void verticalViewChange(qint64 start, qint64 end);
    void verticalRangeChange(qint64 start, qint64 end);
    void horizontalViewChange(qint64 start, qint64 end);
    void horizontalRangeChange(qint64 start, qint64 end);

    /* User interaction with scroll bars */
    void horizontalScrollAction(int action);
    void verticalScrollAction(int action);

    /* Update child elements when selection changes */
    void updateSelection(bool emitSignal = true);

signals:
    void selectionChanged(SelectionState state);

    void verticalViewChanged(qint64 start, qint64 end);
    void verticalRangeChanged(qint64 start, qint64 end);

    void horizontalViewChanged(qint64 start, qint64 end);
    void horizontalRangeChanged(qint64 start, qint64 end);

protected:
    SelectionState m_selection;

    GraphView* m_view;

    GraphLabelWidget* m_label;

    GraphAxisWidget* m_axisTop;
    GraphAxisWidget* m_axisLeft;
    GraphAxisWidget* m_axisRight;
    GraphAxisWidget* m_axisBottom;

    QScrollBar* m_horizontalScrollbar;
    qint64 m_horizontalMin;
    qint64 m_horizontalMax;
    qint64 m_horizontalStart;
    qint64 m_horizontalEnd;
    Qt::ScrollBarPolicy m_horizontalScrollbarPolicy;

    QScrollBar* m_verticalScrollbar;
    qint64 m_verticalMin;
    qint64 m_verticalMax;
    qint64 m_verticalStart;
    qint64 m_verticalEnd;
    Qt::ScrollBarPolicy m_verticalScrollbarPolicy;
};