@@ -1,80 +1,80 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 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 | #ifndef QBARSET_H |
|
21 | #ifndef QBARSET_H | |
22 | #define QBARSET_H |
|
22 | #define QBARSET_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QBrush> |
|
26 | #include <QBrush> | |
27 | #include <QFont> |
|
27 | #include <QFont> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 | class QBarSetPrivate; |
|
30 | class QBarSetPrivate; | |
31 |
|
31 | |||
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject |
|
32 | class QTCOMMERCIALCHART_EXPORT QBarSet : public QObject | |
33 | { |
|
33 | { | |
34 | Q_OBJECT |
|
34 | Q_OBJECT | |
35 |
|
35 | |||
36 | public: |
|
36 | public: | |
37 | QBarSet(QString name, QObject *parent = 0); |
|
37 | QBarSet(QString name, QObject *parent = 0); | |
38 | virtual ~QBarSet(); |
|
38 | virtual ~QBarSet(); | |
39 |
|
39 | |||
40 | void setName(QString name); |
|
40 | void setName(QString name); | |
41 | QString name() const; |
|
41 | QString name() const; | |
42 | QBarSet& operator << (const qreal &value); // appends new value to set |
|
42 | QBarSet& operator << (const qreal &value); // appends new value to set | |
43 | void insertValue(int i, qreal value); |
|
43 | void insertValue(int i, qreal value); | |
44 | void removeValue(int i); |
|
44 | void removeValue(int i); | |
45 | int count() const; // count of values in set |
|
45 | int count() const; // count of values in set | |
46 | qreal valueAt(int index) const; // for modifying individual values |
|
46 | qreal valueAt(int index) const; // for modifying individual values | |
47 | void setValue(int index, qreal value); // setter for individual value |
|
47 | void setValue(int index, qreal value); // setter for individual value | |
48 | qreal sum() const; // sum of all values in the set |
|
48 | qreal sum() const; // sum of all values in the set | |
49 |
|
49 | |||
50 | void setPen(const QPen &pen); |
|
50 | void setPen(const QPen &pen); | |
51 | QPen pen() const; |
|
51 | QPen pen() const; | |
52 |
|
52 | |||
53 | void setBrush(const QBrush &brush); |
|
53 | void setBrush(const QBrush &brush); | |
54 | QBrush brush() const; |
|
54 | QBrush brush() const; | |
55 |
|
55 | |||
56 | void setLabelPen(const QPen &pen); |
|
56 | void setLabelPen(const QPen &pen); | |
57 | QPen labelPen() const; |
|
57 | QPen labelPen() const; | |
58 |
|
58 | |||
59 | void setLabelBrush(const QBrush &brush); |
|
59 | void setLabelBrush(const QBrush &brush); | |
60 | QBrush labelBrush() const; |
|
60 | QBrush labelBrush() const; | |
61 |
|
61 | |||
62 | void setLabelFont(const QFont &font); |
|
62 | void setLabelFont(const QFont &font); | |
63 | QFont labelFont() const; |
|
63 | QFont labelFont() const; | |
64 |
|
64 | |||
65 | void setLabelsVisible(bool visible = true); |
|
65 | void setLabelsVisible(bool visible = true); | |
66 | bool labelsVisible() const; |
|
66 | bool labelsVisible() const; | |
67 |
|
67 | |||
68 | Q_SIGNALS: |
|
68 | Q_SIGNALS: | |
69 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user |
|
69 | void clicked(QString category, Qt::MouseButtons button); // Clicked and hover signals exposed to user | |
70 |
|
70 | |||
71 | private: |
|
71 | private: | |
72 | QScopedPointer<QBarSetPrivate> d_ptr; |
|
72 | QScopedPointer<QBarSetPrivate> d_ptr; | |
73 | Q_DISABLE_COPY(QBarSet) |
|
73 | Q_DISABLE_COPY(QBarSet) | |
74 | friend class QBarSeries; |
|
74 | friend class QBarSeries; | |
75 |
|
75 | friend class BarLegendMarker; | ||
76 | }; |
|
76 | }; | |
77 |
|
77 | |||
78 | QTCOMMERCIALCHART_END_NAMESPACE |
|
78 | QTCOMMERCIALCHART_END_NAMESPACE | |
79 |
|
79 | |||
80 | #endif // QBARSET_H |
|
80 | #endif // QBARSET_H |
@@ -1,194 +1,195 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 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 | #include "legendmarker_p.h" |
|
21 | #include "legendmarker_p.h" | |
22 | #include "qxyseries.h" |
|
22 | #include "qxyseries.h" | |
23 | #include "qxyseries_p.h" |
|
23 | #include "qxyseries_p.h" | |
24 | #include "qlegend.h" |
|
24 | #include "qlegend.h" | |
25 | #include "qbarseries.h" |
|
25 | #include "qbarseries.h" | |
26 | #include "qpieseries.h" |
|
26 | #include "qpieseries.h" | |
27 | #include "qpieslice.h" |
|
27 | #include "qpieslice.h" | |
28 | #include "qbarset.h" |
|
28 | #include "qbarset.h" | |
|
29 | #include "qbarset_p.h" | |||
29 | #include "qareaseries.h" |
|
30 | #include "qareaseries.h" | |
30 | #include "qareaseries_p.h" |
|
31 | #include "qareaseries_p.h" | |
31 | #include <QPainter> |
|
32 | #include <QPainter> | |
32 | #include <QGraphicsSceneEvent> |
|
33 | #include <QGraphicsSceneEvent> | |
33 | #include <QGraphicsSimpleTextItem> |
|
34 | #include <QGraphicsSimpleTextItem> | |
34 |
|
35 | |||
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
36 |
|
37 | |||
37 | LegendMarker::LegendMarker(QSeries* series,QLegend *legend) : QGraphicsObject(legend), |
|
38 | LegendMarker::LegendMarker(QSeries* series,QLegend *legend) : QGraphicsObject(legend), | |
38 | m_series(series), |
|
39 | m_series(series), | |
39 | m_markerRect(0,0,10.0,10.0), |
|
40 | m_markerRect(0,0,10.0,10.0), | |
40 | m_boundingRect(0,0,0,0), |
|
41 | m_boundingRect(0,0,0,0), | |
41 | m_legend(legend), |
|
42 | m_legend(legend), | |
42 | m_textItem(new QGraphicsSimpleTextItem(this)), |
|
43 | m_textItem(new QGraphicsSimpleTextItem(this)), | |
43 | m_rectItem(new QGraphicsRectItem(this)) |
|
44 | m_rectItem(new QGraphicsRectItem(this)) | |
44 | { |
|
45 | { | |
45 | //setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton); |
|
46 | //setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton); | |
46 | m_rectItem->setRect(m_markerRect); |
|
47 | m_rectItem->setRect(m_markerRect); | |
47 | updateLayout(); |
|
48 | updateLayout(); | |
48 | } |
|
49 | } | |
49 |
|
50 | |||
50 | void LegendMarker::setPen(const QPen &pen) |
|
51 | void LegendMarker::setPen(const QPen &pen) | |
51 | { |
|
52 | { | |
52 | m_textItem->setPen(pen); |
|
53 | m_textItem->setPen(pen); | |
53 | updateLayout(); |
|
54 | updateLayout(); | |
54 | } |
|
55 | } | |
55 |
|
56 | |||
56 | QPen LegendMarker::pen() const |
|
57 | QPen LegendMarker::pen() const | |
57 | { |
|
58 | { | |
58 | return m_textItem->pen(); |
|
59 | return m_textItem->pen(); | |
59 | } |
|
60 | } | |
60 |
|
61 | |||
61 | void LegendMarker::setBrush(const QBrush &brush) |
|
62 | void LegendMarker::setBrush(const QBrush &brush) | |
62 | { |
|
63 | { | |
63 | m_rectItem->setBrush(brush); |
|
64 | m_rectItem->setBrush(brush); | |
64 | } |
|
65 | } | |
65 |
|
66 | |||
66 | QBrush LegendMarker::brush() const |
|
67 | QBrush LegendMarker::brush() const | |
67 | { |
|
68 | { | |
68 | return m_rectItem->brush(); |
|
69 | return m_rectItem->brush(); | |
69 | } |
|
70 | } | |
70 |
|
71 | |||
71 | void LegendMarker::setLabel(const QString name) |
|
72 | void LegendMarker::setLabel(const QString name) | |
72 | { |
|
73 | { | |
73 | m_textItem->setText(name); |
|
74 | m_textItem->setText(name); | |
74 | updateLayout(); |
|
75 | updateLayout(); | |
75 | } |
|
76 | } | |
76 |
|
77 | |||
77 | void LegendMarker::setSize(const QSize& size) |
|
78 | void LegendMarker::setSize(const QSize& size) | |
78 | { |
|
79 | { | |
79 | m_markerRect = QRectF(0,0,size.width(),size.height()); |
|
80 | m_markerRect = QRectF(0,0,size.width(),size.height()); | |
80 | } |
|
81 | } | |
81 |
|
82 | |||
82 | QString LegendMarker::label() const |
|
83 | QString LegendMarker::label() const | |
83 | { |
|
84 | { | |
84 | return m_textItem->text(); |
|
85 | return m_textItem->text(); | |
85 | } |
|
86 | } | |
86 |
|
87 | |||
87 | void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
88 | void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
88 | { |
|
89 | { | |
89 | Q_UNUSED(option) |
|
90 | Q_UNUSED(option) | |
90 | Q_UNUSED(widget) |
|
91 | Q_UNUSED(widget) | |
91 | Q_UNUSED(painter) |
|
92 | Q_UNUSED(painter) | |
92 | } |
|
93 | } | |
93 |
|
94 | |||
94 | QRectF LegendMarker::boundingRect() const |
|
95 | QRectF LegendMarker::boundingRect() const | |
95 | { |
|
96 | { | |
96 | return m_boundingRect; |
|
97 | return m_boundingRect; | |
97 | } |
|
98 | } | |
98 |
|
99 | |||
99 | void LegendMarker::updateLayout() |
|
100 | void LegendMarker::updateLayout() | |
100 | { |
|
101 | { | |
101 |
|
102 | |||
102 | static const qreal margin = 2; |
|
103 | static const qreal margin = 2; | |
103 | static const qreal space = 4; |
|
104 | static const qreal space = 4; | |
104 |
|
105 | |||
105 | const QRectF& textRect = m_textItem->boundingRect(); |
|
106 | const QRectF& textRect = m_textItem->boundingRect(); | |
106 | prepareGeometryChange(); |
|
107 | prepareGeometryChange(); | |
107 | m_boundingRect = QRectF(0,0,m_markerRect.width() + 2*margin + space + textRect.width(),qMax(m_markerRect.height()+2*margin,textRect.height()+2*margin)); |
|
108 | m_boundingRect = QRectF(0,0,m_markerRect.width() + 2*margin + space + textRect.width(),qMax(m_markerRect.height()+2*margin,textRect.height()+2*margin)); | |
108 | m_textItem->setPos(m_markerRect.width() + space + margin,m_boundingRect.height()/2 - textRect.height()/2); |
|
109 | m_textItem->setPos(m_markerRect.width() + space + margin,m_boundingRect.height()/2 - textRect.height()/2); | |
109 | m_rectItem->setPos(margin,m_boundingRect.height()/2 - m_markerRect.height()/2); |
|
110 | m_rectItem->setPos(margin,m_boundingRect.height()/2 - m_markerRect.height()/2); | |
110 |
|
111 | |||
111 | } |
|
112 | } | |
112 |
|
113 | |||
113 | void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
114 | void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event) | |
114 | { |
|
115 | { | |
115 | QGraphicsObject::mousePressEvent(event); |
|
116 | QGraphicsObject::mousePressEvent(event); | |
116 | emit selected(); |
|
117 | emit selected(); | |
117 | } |
|
118 | } | |
118 |
|
119 | |||
119 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
120 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
120 |
|
121 | |||
121 | AreaLegendMarker::AreaLegendMarker(QAreaSeries *series,QLegend *legend) : LegendMarker(series,legend), |
|
122 | AreaLegendMarker::AreaLegendMarker(QAreaSeries *series,QLegend *legend) : LegendMarker(series,legend), | |
122 | m_series(series) |
|
123 | m_series(series) | |
123 | { |
|
124 | { | |
124 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); |
|
125 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); | |
125 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); |
|
126 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); | |
126 | updated(); |
|
127 | updated(); | |
127 | } |
|
128 | } | |
128 |
|
129 | |||
129 | void AreaLegendMarker::updated() |
|
130 | void AreaLegendMarker::updated() | |
130 | { |
|
131 | { | |
131 | setBrush(m_series->brush()); |
|
132 | setBrush(m_series->brush()); | |
132 | setLabel(m_series->name()); |
|
133 | setLabel(m_series->name()); | |
133 | } |
|
134 | } | |
134 |
|
135 | |||
135 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
136 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
136 |
|
137 | |||
137 | BarLegendMarker::BarLegendMarker(QBarSeries *series,QBarSet *barset, QLegend *legend) : LegendMarker(series,legend), |
|
138 | BarLegendMarker::BarLegendMarker(QBarSeries *barseries,QBarSet *barset, QLegend *legend) : LegendMarker(barseries,legend), | |
138 | m_barset(barset) |
|
139 | m_barset(barset) | |
139 | { |
|
140 | { | |
140 | QObject::connect(this, SIGNAL(selected()),series, SIGNAL(selected())); |
|
141 | QObject::connect(this, SIGNAL(selected()),barseries, SIGNAL(selected())); | |
141 | QObject::connect(barset, SIGNAL(valueChanged()), this, SLOT(updated())); |
|
142 | QObject::connect(barset->d_ptr.data(), SIGNAL(valueChanged()), this, SLOT(updated())); | |
142 | updated(); |
|
143 | updated(); | |
143 | } |
|
144 | } | |
144 |
|
145 | |||
145 | void BarLegendMarker::updated() |
|
146 | void BarLegendMarker::updated() | |
146 | { |
|
147 | { | |
147 | setBrush(m_barset->brush()); |
|
148 | setBrush(m_barset->brush()); | |
148 | setLabel(m_barset->name()); |
|
149 | setLabel(m_barset->name()); | |
149 | } |
|
150 | } | |
150 |
|
151 | |||
151 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
152 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
152 |
|
153 | |||
153 | PieLegendMarker::PieLegendMarker(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) : LegendMarker(series,legend), |
|
154 | PieLegendMarker::PieLegendMarker(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) : LegendMarker(series,legend), | |
154 | m_pieslice(pieslice) |
|
155 | m_pieslice(pieslice) | |
155 | { |
|
156 | { | |
156 | QObject::connect(this, SIGNAL(selected()),pieslice, SIGNAL(selected())); |
|
157 | QObject::connect(this, SIGNAL(selected()),pieslice, SIGNAL(selected())); | |
157 | QObject::connect(pieslice, SIGNAL(changed()), this, SLOT(updated())); |
|
158 | QObject::connect(pieslice, SIGNAL(changed()), this, SLOT(updated())); | |
158 | QObject::connect(pieslice, SIGNAL(destroyed()), this, SLOT(deleteLater())); //TODO:checkthis |
|
159 | QObject::connect(pieslice, SIGNAL(destroyed()), this, SLOT(deleteLater())); //TODO:checkthis | |
159 | updated(); |
|
160 | updated(); | |
160 | } |
|
161 | } | |
161 |
|
162 | |||
162 | void PieLegendMarker::updated() |
|
163 | void PieLegendMarker::updated() | |
163 | { |
|
164 | { | |
164 | setBrush(m_pieslice->brush()); |
|
165 | setBrush(m_pieslice->brush()); | |
165 | setLabel(m_pieslice->label()); |
|
166 | setLabel(m_pieslice->label()); | |
166 | } |
|
167 | } | |
167 |
|
168 | |||
168 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
169 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
169 |
|
170 | |||
170 | XYLegendMarker::XYLegendMarker(QXYSeries *series, QLegend *legend) : LegendMarker(series,legend), |
|
171 | XYLegendMarker::XYLegendMarker(QXYSeries *series, QLegend *legend) : LegendMarker(series,legend), | |
171 | m_series(series) |
|
172 | m_series(series) | |
172 | { |
|
173 | { | |
173 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); |
|
174 | QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected())); | |
174 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); |
|
175 | QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated())); | |
175 | updated(); |
|
176 | updated(); | |
176 | } |
|
177 | } | |
177 |
|
178 | |||
178 | void XYLegendMarker::updated() |
|
179 | void XYLegendMarker::updated() | |
179 | { |
|
180 | { | |
180 | setLabel(m_series->name()); |
|
181 | setLabel(m_series->name()); | |
181 |
|
182 | |||
182 | if(m_series->type()== QSeries::SeriesTypeScatter) |
|
183 | if(m_series->type()== QSeries::SeriesTypeScatter) | |
183 | { |
|
184 | { | |
184 | setBrush(m_series->brush()); |
|
185 | setBrush(m_series->brush()); | |
185 |
|
186 | |||
186 | } |
|
187 | } | |
187 | else { |
|
188 | else { | |
188 | setBrush(QBrush(m_series->pen().color())); |
|
189 | setBrush(QBrush(m_series->pen().color())); | |
189 | } |
|
190 | } | |
190 | } |
|
191 | } | |
191 |
|
192 | |||
192 | #include "moc_legendmarker_p.cpp" |
|
193 | #include "moc_legendmarker_p.cpp" | |
193 |
|
194 | |||
194 | QTCOMMERCIALCHART_END_NAMESPACE |
|
195 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,128 +1,128 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 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 | #ifndef LEGENDMARKER_P_H |
|
21 | #ifndef LEGENDMARKER_P_H | |
22 | #define LEGENDMARKER_P_H |
|
22 | #define LEGENDMARKER_P_H | |
23 |
|
23 | |||
24 | #include "qchartglobal.h" |
|
24 | #include "qchartglobal.h" | |
25 | #include <QGraphicsObject> |
|
25 | #include <QGraphicsObject> | |
26 | #include <QBrush> |
|
26 | #include <QBrush> | |
27 | #include <QPen> |
|
27 | #include <QPen> | |
28 | #include <QGraphicsSimpleTextItem> |
|
28 | #include <QGraphicsSimpleTextItem> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
31 |
|
31 | |||
32 | class QSeries; |
|
32 | class QSeries; | |
33 | class QAreaSeries; |
|
33 | class QAreaSeries; | |
34 | class QXYSeries; |
|
34 | class QXYSeries; | |
35 | class QBarSet; |
|
35 | class QBarSet; | |
36 | class QBarSeries; |
|
36 | class QBarSeries; | |
37 | class QPieSlice; |
|
37 | class QPieSlice; | |
38 | class QLegend; |
|
38 | class QLegend; | |
39 | class QPieSeries; |
|
39 | class QPieSeries; | |
40 |
|
40 | |||
41 | class LegendMarker : public QGraphicsObject |
|
41 | class LegendMarker : public QGraphicsObject | |
42 | { |
|
42 | { | |
43 | Q_OBJECT |
|
43 | Q_OBJECT | |
44 |
|
44 | |||
45 | public: |
|
45 | public: | |
46 | explicit LegendMarker(QSeries* m_series,QLegend *parent); |
|
46 | explicit LegendMarker(QSeries* m_series,QLegend *parent); | |
47 |
|
47 | |||
48 | void setPen(const QPen &pen); |
|
48 | void setPen(const QPen &pen); | |
49 | QPen pen() const; |
|
49 | QPen pen() const; | |
50 | void setBrush(const QBrush &brush); |
|
50 | void setBrush(const QBrush &brush); | |
51 | QBrush brush() const; |
|
51 | QBrush brush() const; | |
52 |
|
52 | |||
53 | void setSize(const QSize& size); |
|
53 | void setSize(const QSize& size); | |
54 |
|
54 | |||
55 | void setLabel(const QString label); |
|
55 | void setLabel(const QString label); | |
56 | QString label() const; |
|
56 | QString label() const; | |
57 |
|
57 | |||
58 | QSeries* series() const { return m_series;} |
|
58 | QSeries* series() const { return m_series;} | |
59 |
|
59 | |||
60 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
60 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
61 |
|
61 | |||
62 | QRectF boundingRect() const; |
|
62 | QRectF boundingRect() const; | |
63 |
|
63 | |||
64 | void updateLayout(); |
|
64 | void updateLayout(); | |
65 |
|
65 | |||
66 | protected: |
|
66 | protected: | |
67 | // From QGraphicsObject |
|
67 | // From QGraphicsObject | |
68 | void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
68 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |
69 |
|
69 | |||
70 | Q_SIGNALS: |
|
70 | Q_SIGNALS: | |
71 | void selected(); |
|
71 | void selected(); | |
72 |
|
72 | |||
73 | public Q_SLOTS: |
|
73 | public Q_SLOTS: | |
74 | virtual void updated() = 0; |
|
74 | virtual void updated() = 0; | |
75 |
|
75 | |||
76 | protected: |
|
76 | protected: | |
77 | QSeries* m_series; |
|
77 | QSeries* m_series; | |
78 | QRectF m_markerRect; |
|
78 | QRectF m_markerRect; | |
79 | QRectF m_boundingRect; |
|
79 | QRectF m_boundingRect; | |
80 | QLegend* m_legend; |
|
80 | QLegend* m_legend; | |
81 | QGraphicsSimpleTextItem *m_textItem; |
|
81 | QGraphicsSimpleTextItem *m_textItem; | |
82 | QGraphicsRectItem *m_rectItem; |
|
82 | QGraphicsRectItem *m_rectItem; | |
83 |
|
83 | |||
84 | }; |
|
84 | }; | |
85 |
|
85 | |||
86 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
87 | class XYLegendMarker : public LegendMarker |
|
87 | class XYLegendMarker : public LegendMarker | |
88 | { |
|
88 | { | |
89 | public: |
|
89 | public: | |
90 | XYLegendMarker(QXYSeries *series, QLegend *legend); |
|
90 | XYLegendMarker(QXYSeries *series, QLegend *legend); | |
91 | protected: |
|
91 | protected: | |
92 | void updated(); |
|
92 | void updated(); | |
93 | private: |
|
93 | private: | |
94 | QXYSeries *m_series; |
|
94 | QXYSeries *m_series; | |
95 | }; |
|
95 | }; | |
96 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
96 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
97 | class AreaLegendMarker : public LegendMarker |
|
97 | class AreaLegendMarker : public LegendMarker | |
98 | { |
|
98 | { | |
99 | public: |
|
99 | public: | |
100 | AreaLegendMarker(QAreaSeries *series, QLegend *legend); |
|
100 | AreaLegendMarker(QAreaSeries *series, QLegend *legend); | |
101 | protected: |
|
101 | protected: | |
102 | void updated(); |
|
102 | void updated(); | |
103 | private: |
|
103 | private: | |
104 | QAreaSeries *m_series; |
|
104 | QAreaSeries *m_series; | |
105 | }; |
|
105 | }; | |
106 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
106 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
107 | class BarLegendMarker : public LegendMarker |
|
107 | class BarLegendMarker : public LegendMarker | |
108 | { |
|
108 | { | |
109 | public: |
|
109 | public: | |
110 |
BarLegendMarker(QBarSeries *barse |
|
110 | BarLegendMarker(QBarSeries *barseries, QBarSet *barset,QLegend *legend); | |
111 | protected: |
|
111 | protected: | |
112 | void updated(); |
|
112 | void updated(); | |
113 | private: |
|
113 | private: | |
114 | QBarSet *m_barset; |
|
114 | QBarSet *m_barset; | |
115 | }; |
|
115 | }; | |
116 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
116 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
117 | class PieLegendMarker : public LegendMarker |
|
117 | class PieLegendMarker : public LegendMarker | |
118 | { |
|
118 | { | |
119 | public: |
|
119 | public: | |
120 | PieLegendMarker(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend); |
|
120 | PieLegendMarker(QPieSeries *pieSeries, QPieSlice *pieslice, QLegend *legend); | |
121 | protected: |
|
121 | protected: | |
122 | void updated(); |
|
122 | void updated(); | |
123 | private: |
|
123 | private: | |
124 | QPieSlice *m_pieslice; |
|
124 | QPieSlice *m_pieslice; | |
125 | }; |
|
125 | }; | |
126 |
|
126 | |||
127 | QTCOMMERCIALCHART_END_NAMESPACE |
|
127 | QTCOMMERCIALCHART_END_NAMESPACE | |
128 | #endif // LEGENDMARKER_P_H |
|
128 | #endif // LEGENDMARKER_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now