@@ -1,149 +1,151 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef CHARTAXISELEMENT_H |
|
31 | 31 | #define CHARTAXISELEMENT_H |
|
32 | 32 | |
|
33 | 33 | #include "qchartglobal.h" |
|
34 | 34 | #include "chartelement_p.h" |
|
35 | 35 | #include "axisanimation_p.h" |
|
36 | 36 | #include <QGraphicsItem> |
|
37 | 37 | #include <QGraphicsLayoutItem> |
|
38 | 38 | #include <QFont> |
|
39 | 39 | |
|
40 | 40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
41 | 41 | |
|
42 | 42 | class ChartPresenter; |
|
43 | 43 | class QAbstractAxis; |
|
44 | 44 | |
|
45 | 45 | class ChartAxisElement : public ChartElement, public QGraphicsLayoutItem |
|
46 | 46 | { |
|
47 | 47 | Q_OBJECT |
|
48 | ||
|
49 | using QGraphicsLayoutItem::setGeometry; | |
|
48 | 50 | public: |
|
49 | 51 | ChartAxisElement(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis = false); |
|
50 | 52 | ~ChartAxisElement(); |
|
51 | 53 | |
|
52 | 54 | virtual QRectF gridGeometry() const = 0; |
|
53 | 55 | virtual void setGeometry(const QRectF &axis, const QRectF &grid) = 0; |
|
54 | 56 | virtual bool isEmpty() = 0; |
|
55 | 57 | |
|
56 | 58 | void setAnimation(AxisAnimation *animation) { m_animation = animation; } |
|
57 | 59 | AxisAnimation *animation() const { return m_animation; } |
|
58 | 60 | |
|
59 | 61 | QAbstractAxis *axis() const { return m_axis; } |
|
60 | 62 | void setLayout(QVector<qreal> &layout) { m_layout = layout; } |
|
61 | 63 | QVector<qreal> &layout() { return m_layout; } // Modifiable reference |
|
62 | 64 | inline qreal labelPadding() const { return qreal(1.0); } |
|
63 | 65 | inline qreal titlePadding() const { return qreal(1.0); } |
|
64 | 66 | void setLabels(const QStringList &labels) { m_labelsList = labels; } |
|
65 | 67 | QStringList labels() const { return m_labelsList; } |
|
66 | 68 | |
|
67 | 69 | qreal min() const; |
|
68 | 70 | qreal max() const; |
|
69 | 71 | |
|
70 | 72 | QRectF axisGeometry() const { return m_axisRect; } |
|
71 | 73 | void setAxisGeometry(const QRectF &axisGeometry) { m_axisRect = axisGeometry; } |
|
72 | 74 | |
|
73 | 75 | void axisSelected(); |
|
74 | 76 | |
|
75 | 77 | //this flag indicates that axis is used to show intervals it means labels are in between ticks |
|
76 | 78 | bool intervalAxis() const { return m_intervalAxis; } |
|
77 | 79 | |
|
78 | 80 | static QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format); |
|
79 | 81 | static QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString &format); |
|
80 | 82 | static QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format); |
|
81 | 83 | |
|
82 | 84 | // from QGraphicsLayoutItem |
|
83 | 85 | QRectF boundingRect() const |
|
84 | 86 | { |
|
85 | 87 | return QRectF(); |
|
86 | 88 | } |
|
87 | 89 | |
|
88 | 90 | // from QGraphicsLayoutItem |
|
89 | 91 | void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) |
|
90 | 92 | { |
|
91 | 93 | } |
|
92 | 94 | |
|
93 | 95 | protected: |
|
94 | 96 | virtual QVector<qreal> calculateLayout() const = 0; |
|
95 | 97 | virtual void updateLayout(QVector<qreal> &layout) = 0; |
|
96 | 98 | |
|
97 | 99 | QList<QGraphicsItem *> gridItems() { return m_grid->childItems(); } |
|
98 | 100 | QList<QGraphicsItem *> labelItems() { return m_labels->childItems(); } |
|
99 | 101 | QList<QGraphicsItem *> shadeItems() { return m_shades->childItems(); } |
|
100 | 102 | QList<QGraphicsItem *> arrowItems() { return m_arrow->childItems(); } |
|
101 | 103 | QGraphicsTextItem *titleItem() const { return m_title.data(); } |
|
102 | 104 | QGraphicsItemGroup *gridGroup() { return m_grid.data(); } |
|
103 | 105 | QGraphicsItemGroup *labelGroup() { return m_labels.data(); } |
|
104 | 106 | QGraphicsItemGroup *shadeGroup() { return m_shades.data(); } |
|
105 | 107 | QGraphicsItemGroup *arrowGroup() { return m_arrow.data(); } |
|
106 | 108 | |
|
107 | 109 | public Q_SLOTS: |
|
108 | 110 | void handleVisibleChanged(bool visible); |
|
109 | 111 | void handleArrowVisibleChanged(bool visible); |
|
110 | 112 | void handleGridVisibleChanged(bool visible); |
|
111 | 113 | void handleLabelsVisibleChanged(bool visible); |
|
112 | 114 | void handleShadesVisibleChanged(bool visible); |
|
113 | 115 | void handleLabelsAngleChanged(int angle); |
|
114 | 116 | virtual void handleShadesBrushChanged(const QBrush &brush) = 0; |
|
115 | 117 | virtual void handleShadesPenChanged(const QPen &pen) = 0; |
|
116 | 118 | virtual void handleArrowPenChanged(const QPen &pen) = 0; |
|
117 | 119 | virtual void handleGridPenChanged(const QPen &pen) = 0; |
|
118 | 120 | void handleLabelsPenChanged(const QPen &pen); |
|
119 | 121 | void handleLabelsBrushChanged(const QBrush &brush); |
|
120 | 122 | void handleLabelsFontChanged(const QFont &font); |
|
121 | 123 | void handleTitlePenChanged(const QPen &pen); |
|
122 | 124 | void handleTitleBrushChanged(const QBrush &brush); |
|
123 | 125 | void handleTitleFontChanged(const QFont &font); |
|
124 | 126 | void handleTitleTextChanged(const QString &title); |
|
125 | 127 | void handleTitleVisibleChanged(bool visible); |
|
126 | 128 | void handleRangeChanged(qreal min, qreal max); |
|
127 | 129 | |
|
128 | 130 | Q_SIGNALS: |
|
129 | 131 | void clicked(); |
|
130 | 132 | |
|
131 | 133 | private: |
|
132 | 134 | void connectSlots(); |
|
133 | 135 | |
|
134 | 136 | QAbstractAxis *m_axis; |
|
135 | 137 | AxisAnimation *m_animation; |
|
136 | 138 | QVector<qreal> m_layout; |
|
137 | 139 | QStringList m_labelsList; |
|
138 | 140 | QRectF m_axisRect; |
|
139 | 141 | QScopedPointer<QGraphicsItemGroup> m_grid; |
|
140 | 142 | QScopedPointer<QGraphicsItemGroup> m_arrow; |
|
141 | 143 | QScopedPointer<QGraphicsItemGroup> m_shades; |
|
142 | 144 | QScopedPointer<QGraphicsItemGroup> m_labels; |
|
143 | 145 | QScopedPointer<QGraphicsTextItem> m_title; |
|
144 | 146 | bool m_intervalAxis; |
|
145 | 147 | }; |
|
146 | 148 | |
|
147 | 149 | QTCOMMERCIALCHART_END_NAMESPACE |
|
148 | 150 | |
|
149 | 151 | #endif /* CHARTAXISELEMENT_H */ |
General Comments 0
You need to be logged in to leave comments.
Login now