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