@@ -0,0 +1,179 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include "chartcolorbaraxisy_p.h" | |
|
24 | #include <QtCharts/QAbstractAxis> | |
|
25 | #include <private/chartpresenter_p.h> | |
|
26 | //#include <QtCharts/QColorBarAxis> | |
|
27 | #include "colorbaraxis/qcolorbaraxis.h" | |
|
28 | #include <private/abstractchartlayout_p.h> | |
|
29 | #include <QtWidgets/QGraphicsLayout> | |
|
30 | #include <QtCore/QtMath> | |
|
31 | #include <QtCore/QDebug> | |
|
32 | ||
|
33 | QT_CHARTS_BEGIN_NAMESPACE | |
|
34 | ||
|
35 | ChartColorBarAxisY::ChartColorBarAxisY(QColorBarAxis *axis, QPoint pos, qreal height, QLinearGradient gradient, QGraphicsItem *item) | |
|
36 | : VerticalAxis(axis, item), | |
|
37 | m_axis(axis), | |
|
38 | m_gradient(gradient), | |
|
39 | m_position(pos), | |
|
40 | m_height(height) | |
|
41 | { | |
|
42 | QObject::connect(m_axis, SIGNAL(tickCountChanged(int)), this, SLOT(handleTickCountChanged(int))); | |
|
43 | QObject::connect(m_axis, SIGNAL(minorTickCountChanged(int)), | |
|
44 | this, SLOT(handleMinorTickCountChanged(int))); | |
|
45 | QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString))); | |
|
46 | ||
|
47 | createColorBar(); | |
|
48 | ||
|
49 | } | |
|
50 | ||
|
51 | ChartColorBarAxisY::~ChartColorBarAxisY() | |
|
52 | { | |
|
53 | } | |
|
54 | ||
|
55 | QVector<qreal> ChartColorBarAxisY::calculateLayout() const | |
|
56 | { | |
|
57 | int tickCount = m_axis->tickCount(); | |
|
58 | ||
|
59 | Q_ASSERT(tickCount >= 2); | |
|
60 | ||
|
61 | QVector<qreal> points; | |
|
62 | points.resize(tickCount); | |
|
63 | ||
|
64 | const QRectF &gridRect = gridGeometry(); | |
|
65 | ||
|
66 | const qreal deltaY = gridRect.height() / (qreal(tickCount) - 1.0); | |
|
67 | for (int i = 0; i < tickCount; ++i) | |
|
68 | points[i] = qreal(i) * -deltaY + gridRect.bottom(); | |
|
69 | ||
|
70 | return points; | |
|
71 | } | |
|
72 | ||
|
73 | void ChartColorBarAxisY::updateGeometry() | |
|
74 | { | |
|
75 | const QVector<qreal> &layout = ChartAxisElement::layout(); | |
|
76 | if (layout.isEmpty()) | |
|
77 | return; | |
|
78 | setLabels(createValueLabels(min(),max(),layout.size(),m_axis->labelFormat())); | |
|
79 | VerticalAxis::updateGeometry(); | |
|
80 | } | |
|
81 | ||
|
82 | void ChartColorBarAxisY::handleTickCountChanged(int tick) | |
|
83 | { | |
|
84 | Q_UNUSED(tick); | |
|
85 | QGraphicsLayoutItem::updateGeometry(); | |
|
86 | if (presenter()) presenter()->layout()->invalidate(); | |
|
87 | } | |
|
88 | ||
|
89 | void ChartColorBarAxisY::handleMinorTickCountChanged(int tick) | |
|
90 | { | |
|
91 | Q_UNUSED(tick); | |
|
92 | QGraphicsLayoutItem::updateGeometry(); | |
|
93 | if (presenter()) | |
|
94 | presenter()->layout()->invalidate(); | |
|
95 | } | |
|
96 | ||
|
97 | void ChartColorBarAxisY::handleLabelFormatChanged(const QString &format) | |
|
98 | { | |
|
99 | Q_UNUSED(format); | |
|
100 | QGraphicsLayoutItem::updateGeometry(); | |
|
101 | if(presenter()) presenter()->layout()->invalidate(); | |
|
102 | } | |
|
103 | ||
|
104 | QSizeF ChartColorBarAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
|
105 | { | |
|
106 | Q_UNUSED(constraint) | |
|
107 | ||
|
108 | QSizeF sh; | |
|
109 | QSizeF base = VerticalAxis::sizeHint(which, constraint); | |
|
110 | QStringList ticksList = createValueLabels(min(),max(),m_axis->tickCount(),m_axis->labelFormat()); | |
|
111 | qreal width = 0; | |
|
112 | // Height of vertical axis sizeHint indicates the maximum distance labels can extend past | |
|
113 | // first and last ticks. Base height is irrelevant. | |
|
114 | qreal height = 0; | |
|
115 | ||
|
116 | switch (which) | |
|
117 | { | |
|
118 | case Qt::MinimumSize: { | |
|
119 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), | |
|
120 | QStringLiteral("..."), | |
|
121 | axis()->labelsAngle()); | |
|
122 | width = boundingRect.width() + labelPadding() + base.width() + 61.0; //TODO : hint changed 1.0 to 61.0 | |
|
123 | height = boundingRect.height() / 2.0; | |
|
124 | sh = QSizeF(width, height); | |
|
125 | break; | |
|
126 | } | |
|
127 | case Qt::PreferredSize: { | |
|
128 | qreal labelWidth = 0.0; | |
|
129 | qreal firstHeight = -1.0; | |
|
130 | foreach (const QString& s, ticksList) { | |
|
131 | QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle()); | |
|
132 | labelWidth = qMax(rect.width(), labelWidth); | |
|
133 | height = rect.height(); | |
|
134 | if (firstHeight < 0.0) | |
|
135 | firstHeight = height; | |
|
136 | } | |
|
137 | width = labelWidth + labelPadding() + base.width() + 62.0; //two pixels of tolerance //TODO : hint changed 2.0 to 62.0 | |
|
138 | height = qMax(height, firstHeight) / 2.0; | |
|
139 | sh = QSizeF(width, height); | |
|
140 | break; | |
|
141 | } | |
|
142 | default: | |
|
143 | break; | |
|
144 | } | |
|
145 | return sh; | |
|
146 | } | |
|
147 | ||
|
148 | void ChartColorBarAxisY::createColorBar() | |
|
149 | { | |
|
150 | m_axis->setLabelsColor(QColor(0,0,255,0)); //make automatic labels disappear without changing layout (as it would be the case with setlabelVisible(false)) | |
|
151 | ||
|
152 | //gradient | |
|
153 | QGradientStops stops = m_gradient.stops(); | |
|
154 | QLinearGradient gradient(0,m_position.y(),1,m_height); | |
|
155 | foreach(QGradientStop stop, stops) | |
|
156 | { | |
|
157 | gradient.setColorAt(1-stop.first,stop.second); | |
|
158 | } | |
|
159 | ||
|
160 | //colorbar | |
|
161 | QRectF rect(m_position.x()+10,m_position.y(),m_height/20,m_height); //remove +10 if needed | |
|
162 | ||
|
163 | QGraphicsRectItem *colorbar = new QGraphicsRectItem(rect, this); | |
|
164 | colorbar->setZValue(ChartPresenter::AxisZValue); | |
|
165 | colorbar->setBrush(gradient); | |
|
166 | ||
|
167 | //colorbar labels | |
|
168 | for(int i=0;i<m_axis->tickCount();i++) | |
|
169 | { | |
|
170 | qreal value = m_axis->max() - (i * (m_axis->max() - m_axis->min()) / (m_axis->tickCount() - 1)); | |
|
171 | QGraphicsTextItem *label = new QGraphicsTextItem(this); | |
|
172 | label->setPlainText(QString::number(value)); | |
|
173 | label->setPos((m_position.x()+10+m_height/20+1),(m_position.y()*0.85+i*(m_height/(m_axis->tickCount()-1)))); //remove +10 if needed | |
|
174 | } | |
|
175 | } | |
|
176 | ||
|
177 | #include "moc_chartcolorbaraxisy_p.cpp" | |
|
178 | ||
|
179 | QT_CHARTS_END_NAMESPACE |
@@ -0,0 +1,63 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef CHARTCOLORBARAXISY_H | |
|
24 | #define CHARTCOLORBARAXISY_H | |
|
25 | ||
|
26 | #include <private/verticalaxis_p.h> | |
|
27 | #include <QtGui> | |
|
28 | ||
|
29 | QT_CHARTS_BEGIN_NAMESPACE | |
|
30 | ||
|
31 | class QColorBarAxis; | |
|
32 | ||
|
33 | class ChartColorBarAxisY : public VerticalAxis | |
|
34 | { | |
|
35 | Q_OBJECT | |
|
36 | public: | |
|
37 | ChartColorBarAxisY(QColorBarAxis *axis, QPoint pos, qreal height, QLinearGradient gradient, QGraphicsItem *item = 0); | |
|
38 | ~ChartColorBarAxisY(); | |
|
39 | ||
|
40 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; | |
|
41 | ||
|
42 | ||
|
43 | ||
|
44 | protected: | |
|
45 | QVector<qreal> calculateLayout() const; | |
|
46 | void updateGeometry(); | |
|
47 | private Q_SLOTS: | |
|
48 | void handleTickCountChanged(int tick); | |
|
49 | void handleMinorTickCountChanged(int tick); | |
|
50 | void handleLabelFormatChanged(const QString &format); | |
|
51 | void createColorBar(); | |
|
52 | ||
|
53 | ||
|
54 | private: | |
|
55 | QColorBarAxis *m_axis; | |
|
56 | QLinearGradient m_gradient; | |
|
57 | QPoint m_position; | |
|
58 | qreal m_height; | |
|
59 | }; | |
|
60 | ||
|
61 | QT_CHARTS_END_NAMESPACE | |
|
62 | ||
|
63 | #endif // CHARTCOLORBARAXISY_H |
@@ -0,0 +1,277 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | //#include <QtCharts/QColorBarAxis> // TODO : fix this | |
|
24 | #include "colorbaraxis/qcolorbaraxis.h" | |
|
25 | //#include <private/qcolorbaraxis_p.h> | |
|
26 | #include "colorbaraxis/qcolorbaraxis_p.h" | |
|
27 | #include <private/abstractdomain_p.h> | |
|
28 | #include <private/chartdataset_p.h> | |
|
29 | #include <private/chartpresenter_p.h> | |
|
30 | #include <private/charttheme_p.h> | |
|
31 | ||
|
32 | //#include <private/chartcolorbaraxisy_p.h> | |
|
33 | #include <chartcolorbaraxisy_p.h> | |
|
34 | ||
|
35 | #include <QtGui> | |
|
36 | ||
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
|
38 | ||
|
39 | ||
|
40 | /*! | |
|
41 | Constructs an axis object which is a child of \a parent. | |
|
42 | */ | |
|
43 | QColorBarAxis::QColorBarAxis(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max, QObject *parent) : | |
|
44 | QAbstractAxis(*new QColorBarAxisPrivate(plotArea, gradient, min, max, this), parent) | |
|
45 | { | |
|
46 | setGridLineVisible(false); | |
|
47 | } | |
|
48 | ||
|
49 | /*! | |
|
50 | \internal | |
|
51 | */ | |
|
52 | QColorBarAxis::QColorBarAxis(QColorBarAxisPrivate &d, QObject *parent) | |
|
53 | : QAbstractAxis(d, parent) | |
|
54 | { | |
|
55 | ||
|
56 | } | |
|
57 | ||
|
58 | /*! | |
|
59 | Destroys the object | |
|
60 | */ | |
|
61 | QColorBarAxis::~QColorBarAxis() | |
|
62 | { | |
|
63 | Q_D(QColorBarAxis); | |
|
64 | if (d->m_chart) | |
|
65 | d->m_chart->removeAxis(this); | |
|
66 | } | |
|
67 | ||
|
68 | void QColorBarAxis::setMin(qreal min) | |
|
69 | { | |
|
70 | Q_D(QColorBarAxis); | |
|
71 | setRange(min, qMax(d->m_max, min)); | |
|
72 | } | |
|
73 | ||
|
74 | qreal QColorBarAxis::min() const | |
|
75 | { | |
|
76 | Q_D(const QColorBarAxis); | |
|
77 | return d->m_min; | |
|
78 | } | |
|
79 | ||
|
80 | void QColorBarAxis::setMax(qreal max) | |
|
81 | { | |
|
82 | Q_D(QColorBarAxis); | |
|
83 | setRange(qMin(d->m_min, max), max); | |
|
84 | } | |
|
85 | ||
|
86 | qreal QColorBarAxis::max() const | |
|
87 | { | |
|
88 | Q_D(const QColorBarAxis); | |
|
89 | return d->m_max; | |
|
90 | } | |
|
91 | ||
|
92 | void QColorBarAxis::setRange(qreal min, qreal max) | |
|
93 | { | |
|
94 | Q_D(QColorBarAxis); | |
|
95 | d->setRange(min,max); | |
|
96 | } | |
|
97 | ||
|
98 | ||
|
99 | void QColorBarAxis::setTickCount(int count) | |
|
100 | { | |
|
101 | Q_D(QColorBarAxis); | |
|
102 | if (d->m_tickCount != count && count >= 2) { | |
|
103 | d->m_tickCount = count; | |
|
104 | emit tickCountChanged(count); | |
|
105 | } | |
|
106 | } | |
|
107 | ||
|
108 | int QColorBarAxis::tickCount() const | |
|
109 | { | |
|
110 | Q_D(const QColorBarAxis); | |
|
111 | return d->m_tickCount; | |
|
112 | } | |
|
113 | ||
|
114 | void QColorBarAxis::setMinorTickCount(int count) | |
|
115 | { | |
|
116 | Q_D(QColorBarAxis); | |
|
117 | if (d->m_minorTickCount != count && count >= 0) { | |
|
118 | d->m_minorTickCount = count; | |
|
119 | emit minorTickCountChanged(count); | |
|
120 | } | |
|
121 | } | |
|
122 | ||
|
123 | int QColorBarAxis::minorTickCount() const | |
|
124 | { | |
|
125 | Q_D(const QColorBarAxis); | |
|
126 | return d->m_minorTickCount; | |
|
127 | } | |
|
128 | ||
|
129 | void QColorBarAxis::setLabelFormat(const QString &format) | |
|
130 | { | |
|
131 | Q_D(QColorBarAxis); | |
|
132 | d->m_format = format; | |
|
133 | emit labelFormatChanged(format); | |
|
134 | } | |
|
135 | ||
|
136 | QString QColorBarAxis::labelFormat() const | |
|
137 | { | |
|
138 | Q_D(const QColorBarAxis); | |
|
139 | return d->m_format; | |
|
140 | } | |
|
141 | ||
|
142 | /*! | |
|
143 | Returns the type of the axis | |
|
144 | */ | |
|
145 | QAbstractAxis::AxisType QColorBarAxis::type() const | |
|
146 | { | |
|
147 | return AxisTypeValue; | |
|
148 | //TODO : AxisTypeColorBar | |
|
149 | } | |
|
150 | ||
|
151 | ||
|
152 | ||
|
153 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
154 | ||
|
155 | QColorBarAxisPrivate::QColorBarAxisPrivate(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max, QColorBarAxis *q) | |
|
156 | : QAbstractAxisPrivate(q), | |
|
157 | m_plotArea(plotArea), | |
|
158 | m_min(min), | |
|
159 | m_max(max), | |
|
160 | m_tickCount(5), | |
|
161 | m_minorTickCount(0), | |
|
162 | m_format(QString::null), | |
|
163 | // m_applying(false) | |
|
164 | m_gradient(gradient) | |
|
165 | { | |
|
166 | ||
|
167 | } | |
|
168 | ||
|
169 | QColorBarAxisPrivate::~QColorBarAxisPrivate() | |
|
170 | { | |
|
171 | ||
|
172 | } | |
|
173 | ||
|
174 | void QColorBarAxisPrivate::initializeGraphics(QGraphicsItem *parent) | |
|
175 | { | |
|
176 | Q_Q(QColorBarAxis); | |
|
177 | ChartAxisElement *axis(0); | |
|
178 | ||
|
179 | setAlignment(Qt::AlignRight); //also set orientation (Vertical in this case) | |
|
180 | ||
|
181 | //TODO : change this position | |
|
182 | qreal x1; | |
|
183 | qreal y1; | |
|
184 | qreal x2; | |
|
185 | qreal y2; | |
|
186 | m_plotArea.getCoords(&x1,&y1,&x2,&y2); | |
|
187 | QPoint pos(x2+5,y1); | |
|
188 | axis = new ChartColorBarAxisY(q, pos, m_plotArea.height(),m_gradient, parent); | |
|
189 | ||
|
190 | m_item.reset(axis); | |
|
191 | QAbstractAxisPrivate::initializeGraphics(parent); | |
|
192 | } | |
|
193 | ||
|
194 | void QColorBarAxisPrivate::initializeDomain(AbstractDomain *domain) | |
|
195 | { | |
|
196 | //domain is not supposed to have a rangeZ | |
|
197 | ||
|
198 | // if (orientation() == Qt::Vertical) { | |
|
199 | // if (!qFuzzyIsNull(m_max - m_min)) | |
|
200 | // domain->setRangeY(m_min, m_max); | |
|
201 | // else | |
|
202 | // setRange(domain->minY(), domain->maxY()); | |
|
203 | // } | |
|
204 | } | |
|
205 | ||
|
206 | void QColorBarAxisPrivate::setMin(const QVariant &min) | |
|
207 | { | |
|
208 | Q_Q(QColorBarAxis); | |
|
209 | bool ok; | |
|
210 | qreal value = min.toReal(&ok); | |
|
211 | if (ok) | |
|
212 | q->setMin(value); | |
|
213 | } | |
|
214 | ||
|
215 | void QColorBarAxisPrivate::setMax(const QVariant &max) | |
|
216 | { | |
|
217 | Q_Q(QColorBarAxis); | |
|
218 | bool ok; | |
|
219 | qreal value = max.toReal(&ok); | |
|
220 | if (ok) | |
|
221 | q->setMax(value); | |
|
222 | } | |
|
223 | ||
|
224 | void QColorBarAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |
|
225 | { | |
|
226 | Q_Q(QColorBarAxis); | |
|
227 | bool ok1; | |
|
228 | bool ok2; | |
|
229 | qreal value1 = min.toReal(&ok1); | |
|
230 | qreal value2 = max.toReal(&ok2); | |
|
231 | if (ok1 && ok2) | |
|
232 | q->setRange(value1, value2); | |
|
233 | } | |
|
234 | ||
|
235 | void QColorBarAxisPrivate::setRange(qreal min,qreal max) | |
|
236 | { | |
|
237 | Q_Q(QColorBarAxis); | |
|
238 | bool changed = false; | |
|
239 | ||
|
240 | if (min > max) | |
|
241 | return; | |
|
242 | ||
|
243 | bool changeMin = false; | |
|
244 | if (m_min == 0 || min == 0) | |
|
245 | changeMin = !qFuzzyCompare(1 + m_min, 1 + min); | |
|
246 | else | |
|
247 | changeMin = !qFuzzyCompare(m_min, min); | |
|
248 | ||
|
249 | bool changeMax = false; | |
|
250 | if (m_max == 0 || max == 0) | |
|
251 | changeMax = !qFuzzyCompare(1 + m_max, 1 + max); | |
|
252 | else | |
|
253 | changeMax = !qFuzzyCompare(m_max, max); | |
|
254 | ||
|
255 | if (changeMin) { | |
|
256 | m_min = min; | |
|
257 | changed = true; | |
|
258 | emit q->minChanged(min); | |
|
259 | } | |
|
260 | ||
|
261 | if (changeMax) { | |
|
262 | m_max = max; | |
|
263 | changed = true; | |
|
264 | emit q->maxChanged(max); | |
|
265 | } | |
|
266 | ||
|
267 | if (changed) { | |
|
268 | emit rangeChanged(min,max); | |
|
269 | emit q->rangeChanged(min, max); | |
|
270 | } | |
|
271 | } | |
|
272 | ||
|
273 | ||
|
274 | #include "moc_qcolorbaraxis.cpp" | |
|
275 | #include "moc_qcolorbaraxis_p.cpp" | |
|
276 | ||
|
277 | QT_CHARTS_END_NAMESPACE |
@@ -0,0 +1,76 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef QCOLORBARAXIS_H | |
|
24 | #define QCOLORBARAXIS_H | |
|
25 | ||
|
26 | #include <QtCharts/QAbstractAxis> | |
|
27 | ||
|
28 | QT_CHARTS_BEGIN_NAMESPACE | |
|
29 | ||
|
30 | class QColorBarAxisPrivate; | |
|
31 | ||
|
32 | class QT_CHARTS_EXPORT QColorBarAxis : public QAbstractAxis | |
|
33 | { | |
|
34 | Q_OBJECT | |
|
35 | public: | |
|
36 | explicit QColorBarAxis(QRectF plotArea,QLinearGradient gradient, qreal min, qreal max,QObject *parent = 0); | |
|
37 | ~QColorBarAxis(); | |
|
38 | ||
|
39 | protected: | |
|
40 | QColorBarAxis(QColorBarAxisPrivate &d, QObject *parent = 0); | |
|
41 | ||
|
42 | public: | |
|
43 | AxisType type() const; | |
|
44 | ||
|
45 | //range handling | |
|
46 | void setMin(qreal min); | |
|
47 | qreal min() const; | |
|
48 | void setMax(qreal max); | |
|
49 | qreal max() const; | |
|
50 | void setRange(qreal min, qreal max); | |
|
51 | ||
|
52 | //ticks handling | |
|
53 | void setTickCount(int count); | |
|
54 | int tickCount() const; | |
|
55 | void setMinorTickCount(int count); | |
|
56 | int minorTickCount() const; | |
|
57 | ||
|
58 | void setLabelFormat(const QString &format); | |
|
59 | QString labelFormat() const; | |
|
60 | ||
|
61 | Q_SIGNALS: | |
|
62 | void minChanged(qreal min); | |
|
63 | void maxChanged(qreal max); | |
|
64 | void rangeChanged(qreal min, qreal max); | |
|
65 | void tickCountChanged(int tickCount); | |
|
66 | void minorTickCountChanged(int tickCount); | |
|
67 | void labelFormatChanged(const QString &format); | |
|
68 | ||
|
69 | private: | |
|
70 | Q_DECLARE_PRIVATE(QColorBarAxis) | |
|
71 | Q_DISABLE_COPY(QColorBarAxis) | |
|
72 | }; | |
|
73 | ||
|
74 | QT_CHARTS_END_NAMESPACE | |
|
75 | ||
|
76 | #endif // QCOLORBARAXIS_H |
@@ -0,0 +1,66 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef QCOLORBARAXIS_P_H | |
|
24 | #define QCOLORBARAXIS_P_H | |
|
25 | ||
|
26 | //#include <QtCharts/QColorBarAxis> //TODO : fix this | |
|
27 | #include "colorbaraxis/qcolorbaraxis.h" | |
|
28 | #include <private/qabstractaxis_p.h> | |
|
29 | ||
|
30 | QT_CHARTS_BEGIN_NAMESPACE | |
|
31 | ||
|
32 | class QColorBarAxisPrivate : public QAbstractAxisPrivate | |
|
33 | { | |
|
34 | Q_OBJECT | |
|
35 | public: | |
|
36 | QColorBarAxisPrivate(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max,QColorBarAxis *q); | |
|
37 | ~QColorBarAxisPrivate(); | |
|
38 | ||
|
39 | public: | |
|
40 | void initializeGraphics(QGraphicsItem* parent); | |
|
41 | void initializeDomain(AbstractDomain *domain); | |
|
42 | ||
|
43 | qreal min() { return m_min; } | |
|
44 | qreal max() { return m_max; } | |
|
45 | void setRange(qreal min,qreal max); | |
|
46 | ||
|
47 | protected: | |
|
48 | void setMin(const QVariant &min); | |
|
49 | void setMax(const QVariant &max); | |
|
50 | void setRange(const QVariant &min, const QVariant &max); | |
|
51 | ||
|
52 | private: | |
|
53 | qreal m_min; | |
|
54 | qreal m_max; | |
|
55 | int m_tickCount; | |
|
56 | int m_minorTickCount; | |
|
57 | QString m_format; | |
|
58 | // bool m_applying; | |
|
59 | QLinearGradient m_gradient; | |
|
60 | QRectF m_plotArea; | |
|
61 | Q_DECLARE_PUBLIC(QColorBarAxis) | |
|
62 | }; | |
|
63 | ||
|
64 | QT_CHARTS_END_NAMESPACE | |
|
65 | ||
|
66 | #endif // QCOLORBARAXIS_P_H |
@@ -0,0 +1,299 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include <private/colormapchart_p.h> | |
|
24 | #include <QtCharts/QColorMapSeries> | |
|
25 | #include <private/qcolormapseries_p.h> | |
|
26 | #include <private/chartpresenter_p.h> | |
|
27 | #include <private/abstractdomain_p.h> | |
|
28 | #include <private/chartdataset_p.h> | |
|
29 | #include <private/qabstractaxis_p.h> | |
|
30 | #include <QtGui/QPainter> | |
|
31 | #include <QColorBarAxis> | |
|
32 | ||
|
33 | #include <QRgb> | |
|
34 | ||
|
35 | #define nbOfColors 65000 | |
|
36 | ||
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
|
38 | ||
|
39 | ColorMapChart::ColorMapChart(QColorMapSeries *series, QGraphicsItem *item) | |
|
40 | : ChartItem(series->d_func(), item), | |
|
41 | m_series(series), | |
|
42 | m_dirty(true), | |
|
43 | m_gradientType(Rainbow), | |
|
44 | m_colorbar(Q_NULLPTR), | |
|
45 | m_isColorBarDrawn(false), | |
|
46 | m_currentClipRect(QRectF()) | |
|
47 | { | |
|
48 | // QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int))); | |
|
49 | // QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced())); | |
|
50 | // QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int))); | |
|
51 | // QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int))); | |
|
52 | // QObject::connect(series, SIGNAL(pointsRemoved(int, int)), this, SLOT(handlePointsRemoved(int, int))); | |
|
53 | // QObject::connect(this, SIGNAL(clicked(Point3D)), series, SIGNAL(clicked(Point3D))); | |
|
54 | // QObject::connect(this, SIGNAL(hovered(Point3D,bool)), series, SIGNAL(hovered(Point3D,bool))); | |
|
55 | // QObject::connect(this, SIGNAL(pressed(Point3D)), series, SIGNAL(pressed(Point3D))); | |
|
56 | // QObject::connect(this, SIGNAL(released(Point3D)), series, SIGNAL(released(Point3D))); | |
|
57 | // QObject::connect(this, SIGNAL(doubleClicked(Point3D)), series, SIGNAL(doubleClicked(Point3D))); | |
|
58 | ||
|
59 | connect(this,SIGNAL(gradientTypeChanged()), this, SLOT(populateColorTable())); | |
|
60 | ||
|
61 | m_colorTable = new QVector<QRgb>(); | |
|
62 | m_colorTable->reserve(nbOfColors); | |
|
63 | populateColorTable(); | |
|
64 | } | |
|
65 | ||
|
66 | ColorMapChart::~ColorMapChart() | |
|
67 | { | |
|
68 | delete m_colorTable; | |
|
69 | delete m_colorbar; | |
|
70 | } | |
|
71 | ||
|
72 | void ColorMapChart::setDirty(bool dirty) | |
|
73 | { | |
|
74 | m_dirty = dirty; | |
|
75 | } | |
|
76 | ||
|
77 | QRectF ColorMapChart::boundingRect() const | |
|
78 | { | |
|
79 | return m_rect; | |
|
80 | } | |
|
81 | ||
|
82 | void ColorMapChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
|
83 | { | |
|
84 | Q_UNUSED(widget) | |
|
85 | Q_UNUSED(option) | |
|
86 | ||
|
87 | painter->save(); | |
|
88 | //m_series->setUseOpenGL(); | |
|
89 | ||
|
90 | QRectF plotAreaRect = m_series->chart()->plotArea(); | |
|
91 | QRectF clipRect = mapColorMapToPlotArea(); | |
|
92 | painter->setClipRect(clipRect); | |
|
93 | ||
|
94 | if(m_currentClipRect !=clipRect) | |
|
95 | { | |
|
96 | m_currentClipRect = clipRect; | |
|
97 | m_grid.reserve(clipRect.width()*clipRect.height()); | |
|
98 | m_grid.resize(clipRect.width()*clipRect.height()); | |
|
99 | ||
|
100 | m_series->getUniformGrid(qMax(m_series->minX(),domain()->minX()),qMin(m_series->maxX(),domain()->maxX()),qMax(m_series->minY(),domain()->minY()),qMin(m_series->maxY(),domain()->maxY()), clipRect.width(),clipRect.height(),m_grid, QColorMapSeries::LastPixel); | |
|
101 | addColorBar(plotAreaRect); | |
|
102 | } | |
|
103 | ||
|
104 | QImage colorMapImage(clipRect.width(),clipRect.height(),QImage::Format_RGB32); | |
|
105 | //http://doc.qt.io/qt-4.8/qimage.html#details :Warning: This will create a QImage with uninitialized data. Call fill() to fill the image with an appropriate pixel value before drawing onto it with QPainter. | |
|
106 | colorMapImage.fill(QColor(Qt::white).rgb()); | |
|
107 | ||
|
108 | fillColorMapImage(colorMapImage); | |
|
109 | ||
|
110 | painter->drawImage(clipRect,colorMapImage); | |
|
111 | painter->restore(); | |
|
112 | } | |
|
113 | ||
|
114 | void ColorMapChart::addColorBar(QRectF plotAreaRect) | |
|
115 | { | |
|
116 | double maxZ = m_series->maxZ(); | |
|
117 | double minZ = m_series->minZ(); | |
|
118 | ||
|
119 | if(m_isColorBarDrawn) | |
|
120 | m_series->chart()->removeAxis(m_colorbar); | |
|
121 | ||
|
122 | m_colorbar = new QColorBarAxis(plotAreaRect,createColorMapGradient(m_gradientType),minZ, maxZ,this); | |
|
123 | m_series->chart()->addAxis(m_colorbar, Qt::AlignRight); | |
|
124 | m_isColorBarDrawn = true; | |
|
125 | } | |
|
126 | ||
|
127 | QRectF ColorMapChart::mapColorMapToPlotArea() | |
|
128 | { | |
|
129 | QRectF plotAreaRect = m_series->chart()->plotArea(); | |
|
130 | ||
|
131 | double seriesMinX = m_series->minX(); | |
|
132 | double seriesMaxX = m_series->maxX(); | |
|
133 | double seriesMinY = m_series->minY(); | |
|
134 | double seriesMaxY = m_series->maxY(); | |
|
135 | ||
|
136 | double domainMinX = domain()->minX(); | |
|
137 | double domainMaxX = domain()->maxX(); | |
|
138 | double domainMinY = domain()->minY(); | |
|
139 | double domainMaxY = domain()->maxY(); | |
|
140 | ||
|
141 | double widthToPaint = (qMin(seriesMaxX, domainMaxX)-qMax(seriesMinX, domainMinX))*plotAreaRect.width()/(domainMaxX-domainMinX); | |
|
142 | double heightTopaint= (qMin(seriesMaxY, domainMaxY)-qMax(seriesMinY, domainMinY))*plotAreaRect.height()/(domainMaxY-domainMinY); | |
|
143 | ||
|
144 | QSizeF size = QSize(widthToPaint,heightTopaint); | |
|
145 | ||
|
146 | double pointX = (qMax(seriesMinX,domainMinX)-domainMinX)*plotAreaRect.width()/(domainMaxX-domainMinX); | |
|
147 | double pointY = (domainMaxY-qMin(seriesMaxY,domainMaxY))*plotAreaRect.height()/(domainMaxY-domainMinY); | |
|
148 | ||
|
149 | return QRectF(QPointF(pointX,pointY) ,size); | |
|
150 | } | |
|
151 | ||
|
152 | void ColorMapChart::fillColorMapImage(QImage &colorMapImage) | |
|
153 | { | |
|
154 | double maxZ = m_series->maxZ(); | |
|
155 | double minZ = m_series->minZ(); | |
|
156 | double rangeZ = maxZ - minZ; | |
|
157 | ||
|
158 | int imageWidth = colorMapImage.width(); | |
|
159 | int imageHeight = colorMapImage.height(); | |
|
160 | ||
|
161 | for(int i=0;i<imageWidth;i++) | |
|
162 | { | |
|
163 | for(int j=0;j<imageHeight;j++) | |
|
164 | { | |
|
165 | double value = m_grid.at(i+j*(imageWidth)); | |
|
166 | double pix=((value-minZ)/rangeZ); | |
|
167 | int indexInColorTable = pix*(nbOfColors-1); | |
|
168 | colorMapImage.setPixel(i,j,m_colorTable->at(indexInColorTable)); | |
|
169 | } | |
|
170 | } | |
|
171 | } | |
|
172 | ||
|
173 | /*! | |
|
174 | Returns the predefined QLinearGradient corresponding to the \a gradientType passed as argument. | |
|
175 | */ | |
|
176 | QLinearGradient ColorMapChart::createColorMapGradient(GradientType gradientType) | |
|
177 | { | |
|
178 | QLinearGradient gradient(0,0,1,100); | |
|
179 | switch(gradientType) | |
|
180 | { | |
|
181 | case Rainbow : | |
|
182 | gradient.setColorAt(1.0,Qt::darkRed); | |
|
183 | gradient.setColorAt(0.8,Qt::red); | |
|
184 | gradient.setColorAt(0.6,Qt::yellow); | |
|
185 | gradient.setColorAt(0.4,Qt::green); | |
|
186 | gradient.setColorAt(0.2,Qt::cyan); | |
|
187 | gradient.setColorAt(0.0,Qt::blue); | |
|
188 | break; | |
|
189 | case CyclingRainbow : | |
|
190 | gradient.setColorAt(1.0,Qt::red); | |
|
191 | gradient.setColorAt(0.8,Qt::yellow); | |
|
192 | gradient.setColorAt(0.6,Qt::green); | |
|
193 | gradient.setColorAt(0.4,Qt::cyan); | |
|
194 | gradient.setColorAt(0.2,Qt::blue); | |
|
195 | gradient.setColorAt(0.0,Qt::magenta); | |
|
196 | break; | |
|
197 | case BlackAndWhite : | |
|
198 | gradient.setColorAt(1.0, Qt::black); | |
|
199 | gradient.setColorAt(0.0, Qt::white); | |
|
200 | break; | |
|
201 | case ReverseBlackAndWhite : | |
|
202 | gradient.setColorAt(1.0, Qt::white); | |
|
203 | gradient.setColorAt(0.0, Qt::black); | |
|
204 | break; | |
|
205 | default: | |
|
206 | break; | |
|
207 | } | |
|
208 | return gradient; | |
|
209 | } | |
|
210 | ||
|
211 | /*! | |
|
212 | Changes the type of gradient used to paint the ColorMap. | |
|
213 | */ | |
|
214 | void ColorMapChart::changeGradient(GradientType gradientType) | |
|
215 | { | |
|
216 | if(m_gradientType == gradientType) | |
|
217 | return; | |
|
218 | else | |
|
219 | m_gradientType = gradientType; | |
|
220 | emit gradientTypeChanged(); | |
|
221 | } | |
|
222 | ||
|
223 | /*! | |
|
224 | Creates a color table corresponding to the gradient type currently selected. | |
|
225 | */ | |
|
226 | void ColorMapChart::populateColorTable() | |
|
227 | { | |
|
228 | QLinearGradient gradient = createColorMapGradient(m_gradientType); | |
|
229 | QGradientStops colorStops = gradient.stops(); | |
|
230 | ||
|
231 | for(int i=0;i<nbOfColors;i++) | |
|
232 | { | |
|
233 | double colorIndex = (double)i/nbOfColors; | |
|
234 | for(int k =0;k<colorStops.size()-1;k++) | |
|
235 | { | |
|
236 | QGradientStop lowerBound = colorStops.at(k); | |
|
237 | QGradientStop upperBound = colorStops.at(k+1); | |
|
238 | if(colorIndex >= lowerBound.first && colorIndex < upperBound.first) | |
|
239 | { | |
|
240 | double ratio = (colorIndex-lowerBound.first)/(upperBound.first - lowerBound.first); | |
|
241 | int red = (int)((1-ratio)*lowerBound.second.red() + ratio*upperBound.second.red()); | |
|
242 | int green = (int)((1-ratio)*lowerBound.second.green() + ratio*upperBound.second.green()); | |
|
243 | int blue = (int)((1-ratio)*lowerBound.second.blue() + ratio*upperBound.second.blue()); | |
|
244 | m_colorTable->append(qRgb(red, green, blue)); | |
|
245 | break; | |
|
246 | } | |
|
247 | else | |
|
248 | { | |
|
249 | if(k==colorStops.size()-2) | |
|
250 | { | |
|
251 | m_colorTable->append(qRgb(colorStops.at(colorStops.size()-1).second.red(), colorStops.at(colorStops.size()-1).second.green(), colorStops.at(colorStops.size()-1).second.blue())); | |
|
252 | } | |
|
253 | } | |
|
254 | } | |
|
255 | } | |
|
256 | } | |
|
257 | ||
|
258 | ||
|
259 | //handlers | |
|
260 | ||
|
261 | void ColorMapChart::handlePointAdded(int index) | |
|
262 | { | |
|
263 | ||
|
264 | } | |
|
265 | ||
|
266 | void ColorMapChart::handlePointRemoved(int index) | |
|
267 | { | |
|
268 | ||
|
269 | } | |
|
270 | ||
|
271 | void ColorMapChart::handlePointsRemoved(int index, int count) | |
|
272 | { | |
|
273 | ||
|
274 | } | |
|
275 | ||
|
276 | void ColorMapChart::handlePointReplaced(int index) | |
|
277 | { | |
|
278 | ||
|
279 | } | |
|
280 | ||
|
281 | void ColorMapChart::handlePointsReplaced() | |
|
282 | { | |
|
283 | ||
|
284 | } | |
|
285 | ||
|
286 | void ColorMapChart::handleDomainUpdated() | |
|
287 | { | |
|
288 | ||
|
289 | } | |
|
290 | ||
|
291 | bool ColorMapChart::isEmpty() | |
|
292 | { | |
|
293 | ||
|
294 | } | |
|
295 | ||
|
296 | ||
|
297 | #include "moc_colormapchart_p.cpp" | |
|
298 | ||
|
299 | QT_CHARTS_END_NAMESPACE |
@@ -0,0 +1,21 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | QT+=concurrent | |
|
4 | #QMAKE_CXXFLAGS+= -fopenmp | |
|
5 | #QMAKE_LFLAGS += -fopenmp | |
|
6 | ||
|
7 | SOURCES += \ | |
|
8 | $$PWD/qcolormapseries.cpp \ | |
|
9 | $$PWD/colormapchart.cpp \ | |
|
10 | $$PWD/colormapdatapart.cpp \ | |
|
11 | $$PWD/point3d.cpp | |
|
12 | ||
|
13 | PRIVATE_HEADERS += \ | |
|
14 | $$PWD/qcolormapseries_p.h \ | |
|
15 | $$PWD/colormapchart_p.h | |
|
16 | ||
|
17 | PUBLIC_HEADERS += \ | |
|
18 | $$PWD/qcolormapseries.h \ | |
|
19 | $$PWD/point3d.h \ | |
|
20 | $$PWD/colormapdatapart.h | |
|
21 |
@@ -0,0 +1,154 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef COLORMAPCHART_H | |
|
24 | #define COLORMAPCHART_H | |
|
25 | ||
|
26 | #include "point3d.h" | |
|
27 | #include <QtCharts/QChartGlobal> | |
|
28 | #include <private/chartitem_p.h> | |
|
29 | #include <QtCharts/QValueAxis> | |
|
30 | #include <QtGui/QPen> | |
|
31 | ||
|
32 | //#include <QtCharts/QColorBarAxis> TODO : fix this | |
|
33 | #include "qcolorbaraxis.h" | |
|
34 | ||
|
35 | QT_CHARTS_BEGIN_NAMESPACE | |
|
36 | ||
|
37 | class ChartPresenter; | |
|
38 | class QColorMapSeries; | |
|
39 | ||
|
40 | class ColorMapChart : public ChartItem | |
|
41 | { | |
|
42 | Q_OBJECT | |
|
43 | public: | |
|
44 | ||
|
45 | enum GradientType | |
|
46 | { | |
|
47 | Rainbow, | |
|
48 | CyclingRainbow, | |
|
49 | BlackAndWhite, | |
|
50 | ReverseBlackAndWhite | |
|
51 | }; | |
|
52 | ||
|
53 | explicit ColorMapChart(QColorMapSeries *series,QGraphicsItem *item = 0); | |
|
54 | ~ColorMapChart(); | |
|
55 | ||
|
56 | bool isDirty() const { return m_dirty; } | |
|
57 | void setDirty(bool dirty); | |
|
58 | ||
|
59 | // from QGraphicsItem | |
|
60 | QRectF boundingRect() const; | |
|
61 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | |
|
62 | ||
|
63 | public Q_SLOTS: | |
|
64 | void handlePointAdded(int index); | |
|
65 | void handlePointRemoved(int index); | |
|
66 | void handlePointsRemoved(int index, int count); | |
|
67 | void handlePointReplaced(int index); | |
|
68 | void handlePointsReplaced(); | |
|
69 | void handleDomainUpdated(); | |
|
70 | ||
|
71 | private slots : | |
|
72 | void populateColorTable(); | |
|
73 | ||
|
74 | Q_SIGNALS: | |
|
75 | void clicked(const Point3D &point); | |
|
76 | void hovered(const Point3D &point, bool state); | |
|
77 | void pressed(const Point3D &point); | |
|
78 | void released(const Point3D &point); | |
|
79 | void doubleClicked(const Point3D &point); | |
|
80 | void gradientTypeChanged(); | |
|
81 | ||
|
82 | private: | |
|
83 | inline bool isEmpty(); | |
|
84 | void addColorBar(QRectF plotAreaRect); | |
|
85 | ||
|
86 | QRectF mapColorMapToPlotArea(); | |
|
87 | void fillColorMapImage(QImage &colorMapImage); | |
|
88 | QLinearGradient createColorMapGradient(GradientType gradientType); | |
|
89 | void changeGradient(GradientType gradientType); | |
|
90 | ||
|
91 | protected: | |
|
92 | QColorMapSeries *m_series; | |
|
93 | QVector<Point3D> m_points; | |
|
94 | QRectF m_rect; | |
|
95 | bool m_dirty; | |
|
96 | QVector<QRgb> *m_colorTable; | |
|
97 | GradientType m_gradientType; | |
|
98 | bool m_isColorBarDrawn; | |
|
99 | QColorBarAxis *m_colorbar; | |
|
100 | QRectF m_currentClipRect; | |
|
101 | QVector<double> m_grid; | |
|
102 | }; | |
|
103 | ||
|
104 | //class PixmapMarker: public QGraphicsRectItem | |
|
105 | //{ | |
|
106 | ||
|
107 | //public: | |
|
108 | // PixmapMarker(qreal x, qreal y, qreal w, qreal h, ColorMapChart *parent) | |
|
109 | // : QGraphicsRectItem(x, y, w, h, parent), | |
|
110 | // m_parent(parent) | |
|
111 | // { | |
|
112 | // setAcceptHoverEvents(true); | |
|
113 | // setFlag(QGraphicsItem::ItemIsSelectable); | |
|
114 | // } | |
|
115 | ||
|
116 | //protected: | |
|
117 | // void mousePressEvent(QGraphicsSceneMouseEvent *event) | |
|
118 | // { | |
|
119 | // QGraphicsRectItem::mousePressEvent(event); | |
|
120 | // m_parent->markerPressed(this); | |
|
121 | // m_parent->setMousePressed(); | |
|
122 | // } | |
|
123 | // void hoverEnterEvent(QGraphicsSceneHoverEvent *event) | |
|
124 | // { | |
|
125 | // QGraphicsRectItem::hoverEnterEvent(event); | |
|
126 | // m_parent->markerHovered(this, true); | |
|
127 | // } | |
|
128 | // void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | |
|
129 | // { | |
|
130 | // QGraphicsRectItem::hoverLeaveEvent(event); | |
|
131 | // m_parent->markerHovered(this, false); | |
|
132 | // } | |
|
133 | // void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) | |
|
134 | // { | |
|
135 | // QGraphicsRectItem::mouseReleaseEvent(event); | |
|
136 | // m_parent->markerReleased(this); | |
|
137 | // if (m_parent->mousePressed()) | |
|
138 | // m_parent->markerSelected(this); | |
|
139 | // m_parent->setMousePressed(false); | |
|
140 | // } | |
|
141 | // void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) | |
|
142 | // { | |
|
143 | // QGraphicsRectItem::mouseDoubleClickEvent(event); | |
|
144 | // m_parent->markerDoubleClicked(this); | |
|
145 | // } | |
|
146 | ||
|
147 | //private: | |
|
148 | // ColorMapChart *m_parent; | |
|
149 | //}; | |
|
150 | ||
|
151 | ||
|
152 | QT_CHARTS_END_NAMESPACE | |
|
153 | ||
|
154 | #endif // COLORMAPCHART_H |
@@ -0,0 +1,78 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include "colormapdatapart.h" | |
|
24 | ||
|
25 | QT_CHARTS_BEGIN_NAMESPACE | |
|
26 | ||
|
27 | ColorMapDataPart::ColorMapDataPart() | |
|
28 | { | |
|
29 | ||
|
30 | } | |
|
31 | ||
|
32 | ColorMapDataPart::ColorMapDataPart(ColorMapDataPart *dataPart) | |
|
33 | {/* | |
|
34 | QVector<double> *m_timeSeries; | |
|
35 | QVector<double> *m_ySeries; | |
|
36 | QVector<double> *m_dataSeries;*/ | |
|
37 | this->m_dataSeries = new QVector<double>(dataPart->dataSeries()); | |
|
38 | this->m_ySeries = new QVector<double>(dataPart->ySeries()); | |
|
39 | this->m_timeSeries = new QVector<double>(dataPart->timesSeries()); | |
|
40 | } | |
|
41 | ||
|
42 | ColorMapDataPart::ColorMapDataPart(QVector<double> *timeSeries, QVector<double> *ySeries, QVector<double> *dataSeries) | |
|
43 | : m_timeSeries(timeSeries),m_ySeries(ySeries),m_dataSeries(dataSeries) | |
|
44 | { | |
|
45 | ||
|
46 | } | |
|
47 | ||
|
48 | ColorMapDataPart::~ColorMapDataPart() | |
|
49 | { | |
|
50 | delete m_dataSeries; | |
|
51 | delete m_ySeries; | |
|
52 | delete m_timeSeries; | |
|
53 | } | |
|
54 | ||
|
55 | int ColorMapDataPart::find(double val, const QVector<double> &vect, bool more) | |
|
56 | { | |
|
57 | if(val >=vect.last() && more) | |
|
58 | return vect.count(); | |
|
59 | if(val <= vect.first() && !more) | |
|
60 | return -1; | |
|
61 | ||
|
62 | int guessedIndex = (val-vect.first())*vect.count()/(vect.last()-vect.first()); | |
|
63 | if(guessedIndex>(vect.count()-1))guessedIndex=vect.count()-1; | |
|
64 | ||
|
65 | if(more) | |
|
66 | while(vect[guessedIndex]<val){guessedIndex++;} | |
|
67 | else | |
|
68 | while(vect[guessedIndex--]>val){} | |
|
69 | return guessedIndex; | |
|
70 | } | |
|
71 | ||
|
72 | QPair<int, int> ColorMapDataPart::getRange(const QVector<double> &vect, double start, double stop) | |
|
73 | { | |
|
74 | return QPair<int, int>(find(start,vect, false),find(stop,vect, true)); | |
|
75 | } | |
|
76 | ||
|
77 | ||
|
78 | QT_CHARTS_END_NAMESPACE |
@@ -0,0 +1,55 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef COLORMAPDATAPART_H | |
|
24 | #define COLORMAPDATAPART_H | |
|
25 | ||
|
26 | #include <QtCharts/QChartGlobal> | |
|
27 | #include <QtCore> | |
|
28 | ||
|
29 | QT_CHARTS_BEGIN_NAMESPACE | |
|
30 | ||
|
31 | class QT_CHARTS_EXPORT ColorMapDataPart | |
|
32 | { | |
|
33 | public: | |
|
34 | explicit ColorMapDataPart(); | |
|
35 | ColorMapDataPart(ColorMapDataPart* dataPart); | |
|
36 | explicit ColorMapDataPart(QVector<double> *timeSeries, QVector<double> *ySeries, QVector<double> *dataSeries); | |
|
37 | ~ColorMapDataPart(); | |
|
38 | inline const QVector<double>& timesSeries(){return *this->m_timeSeries;} | |
|
39 | inline const QVector<double>& ySeries(){return *this->m_ySeries;} | |
|
40 | inline const QVector<double>& dataSeries(){return *this->m_dataSeries;} | |
|
41 | inline void setTimeSeries(QVector<double> *timeSeries){this->m_timeSeries =timeSeries;} | |
|
42 | inline void setYSeries(QVector<double> *ySeries){this->m_ySeries =ySeries;} | |
|
43 | inline void setDataSeries(QVector<double> *dataSeries){this->m_dataSeries =dataSeries;} | |
|
44 | QPair<int,int> getRange(const QVector<double> &vect, double start, double stop); | |
|
45 | protected: | |
|
46 | QVector<double> *m_timeSeries; | |
|
47 | QVector<double> *m_ySeries; | |
|
48 | QVector<double> *m_dataSeries; | |
|
49 | private: | |
|
50 | int find(double val, const QVector<double> &vect, bool more); | |
|
51 | }; | |
|
52 | ||
|
53 | QT_CHARTS_END_NAMESPACE | |
|
54 | ||
|
55 | #endif // COLORMAPDATAPART_H |
@@ -0,0 +1,35 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include "point3d.h" | |
|
24 | ||
|
25 | ||
|
26 | Point3D::Point3D() | |
|
27 | : QPointF() | |
|
28 | { | |
|
29 | } | |
|
30 | ||
|
31 | Point3D::Point3D(qreal x, qreal y, qreal value) | |
|
32 | : QPointF(x,y), | |
|
33 | m_value(value) | |
|
34 | { | |
|
35 | } |
@@ -0,0 +1,38 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef POINT3D_H | |
|
24 | #define POINT3D_H | |
|
25 | ||
|
26 | #include <QPointF> | |
|
27 | ||
|
28 | class Point3D : public QPointF | |
|
29 | { | |
|
30 | public: | |
|
31 | Point3D(); | |
|
32 | Point3D(qreal x, qreal y, qreal value); | |
|
33 | inline void setValue(qreal value){this->m_value = value;} | |
|
34 | inline qreal value(){return this->m_value;} | |
|
35 | private: | |
|
36 | qreal m_value; | |
|
37 | }; | |
|
38 | #endif // POINT3D_H |
@@ -0,0 +1,1 | |||
|
1 | #include "../../src/charts/legend/qcolormaplegendmarker.h" |
@@ -0,0 +1,1 | |||
|
1 | #include "../../../../../src/charts/legend/qcolormaplegendmarker_p.h" |
This diff has been collapsed as it changes many lines, (658 lines changed) Show them Hide them | |||
@@ -0,0 +1,658 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include "qcolormapseries.h" | |
|
24 | #include <private/qcolormapseries_p.h> | |
|
25 | #include <private/abstractdomain_p.h> | |
|
26 | #include <QtCharts/QValueAxis> | |
|
27 | #include <private/colormapchart_p.h> | |
|
28 | #include <QtCharts/QColorMapLegendMarker> | |
|
29 | #include <private/charthelpers_p.h> | |
|
30 | #include <private/qchart_p.h> | |
|
31 | #include <QtGui/QPainter> | |
|
32 | #include <cmath> | |
|
33 | ||
|
34 | #include <cmath> | |
|
35 | #include <QtConcurrent> | |
|
36 | ||
|
37 | #include "qcolorbaraxis.h" | |
|
38 | ||
|
39 | QT_CHARTS_BEGIN_NAMESPACE | |
|
40 | ||
|
41 | /*! | |
|
42 | \internal | |
|
43 | ||
|
44 | Constructs empty series object which is a child of \a parent. | |
|
45 | When series object is added to QChart instance ownerships is transferred. | |
|
46 | */ | |
|
47 | QColorMapSeries::QColorMapSeries(QObject *parent) | |
|
48 | : QAbstractSeries(*new QColorMapSeriesPrivate(this), parent) | |
|
49 | { | |
|
50 | } | |
|
51 | ||
|
52 | /*! | |
|
53 | \internal | |
|
54 | ||
|
55 | Constructs empty series object which is a child of \a parent. | |
|
56 | When series object is added to QChart instance ownerships is transferred. | |
|
57 | */ | |
|
58 | QColorMapSeries::QColorMapSeries(QColorMapSeriesPrivate &d, QObject *parent) | |
|
59 | : QAbstractSeries(d, parent) | |
|
60 | { | |
|
61 | } | |
|
62 | ||
|
63 | ||
|
64 | /*! | |
|
65 | Destroys the object. Series added to QChart instances are owned by those, | |
|
66 | and are destroyed when QChart instances are destroyed. | |
|
67 | */ | |
|
68 | QColorMapSeries::~QColorMapSeries() | |
|
69 | { | |
|
70 | } | |
|
71 | ||
|
72 | /*! | |
|
73 | \fn virtual SeriesType QBoxPlotSeries::type() const | |
|
74 | \brief Returns type of series. | |
|
75 | \sa QAbstractSeries, SeriesType | |
|
76 | */ | |
|
77 | QAbstractSeries::SeriesType QColorMapSeries::type() const | |
|
78 | { | |
|
79 | return QAbstractSeries::SeriesTypeColorMap; | |
|
80 | } | |
|
81 | ||
|
82 | ||
|
83 | /*! | |
|
84 | Adds data part \a dataPart to the series.\n | |
|
85 | If \a copy is true, adds a copy of the data part instead. | |
|
86 | */ | |
|
87 | void QColorMapSeries::append(ColorMapDataPart* dataPart, bool copy) | |
|
88 | { | |
|
89 | Q_D(QColorMapSeries); | |
|
90 | if(copy) | |
|
91 | d->m_dataParts << new ColorMapDataPart(dataPart); | |
|
92 | else | |
|
93 | d->m_dataParts << dataPart; | |
|
94 | d->recomputeDataRange(); | |
|
95 | emit dataPartAdded(d->m_dataParts.count() - 1); | |
|
96 | } | |
|
97 | ||
|
98 | /*! | |
|
99 | This is an overloaded function.\n | |
|
100 | Adds data parts \a dataParts to the series.\n | |
|
101 | If \a copy is true, adds a copy of the data part instead. | |
|
102 | */ | |
|
103 | void QColorMapSeries::append(const QList<ColorMapDataPart*> &dataParts, bool copy) | |
|
104 | { | |
|
105 | foreach (ColorMapDataPart* dataPart , dataParts) | |
|
106 | append(dataPart,copy); | |
|
107 | } | |
|
108 | ||
|
109 | ||
|
110 | /*! | |
|
111 | Returns number of data parts within series. | |
|
112 | */ | |
|
113 | int QColorMapSeries::count() const | |
|
114 | { | |
|
115 | Q_D(const QColorMapSeries); | |
|
116 | return d->m_dataParts.count(); | |
|
117 | } | |
|
118 | ||
|
119 | ||
|
120 | /*! | |
|
121 | Stream operator for adding a data part \a point to the series. | |
|
122 | \sa append() | |
|
123 | */ | |
|
124 | QColorMapSeries &QColorMapSeries::operator <<(const ColorMapDataPart &dataPart) | |
|
125 | { | |
|
126 | append(new ColorMapDataPart(dataPart)); | |
|
127 | return *this; | |
|
128 | } | |
|
129 | ||
|
130 | /*! | |
|
131 | Stream operator for adding a vector of data parts \a dataParts to the series. | |
|
132 | \sa append() | |
|
133 | */ | |
|
134 | QColorMapSeries &QColorMapSeries::operator <<(const QList<ColorMapDataPart*> &dataParts) | |
|
135 | { | |
|
136 | append(dataParts); | |
|
137 | return *this; | |
|
138 | } | |
|
139 | ||
|
140 | /*! | |
|
141 | Returns a ColorMapData part containing a uniform grid of data points to be mapped in a ColorMapChart.\n | |
|
142 | The rectangle of data returned is determined by \a width and \height,\n | |
|
143 | from the position \a xpos , \a ypos (starting at the top left corner of the plot area).\n | |
|
144 | When there are more points than pixels, \a strategy is applied to determine which to choose. | |
|
145 | */ | |
|
146 | void QColorMapSeries::getUniformGrid(double minX, double maxX, double minY, double maxY, int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy) | |
|
147 | { | |
|
148 | Q_D(QColorMapSeries); | |
|
149 | d->getUniformGrid(minX, maxX,minY,maxY,width,height, grid, strategy); | |
|
150 | } | |
|
151 | ||
|
152 | //void QColorMapSeries::attachAxis(QAbstractAxis *axis) | |
|
153 | //{ | |
|
154 | // axis = static_cast<QColorBarAxis*>(); | |
|
155 | // if(axis) | |
|
156 | // { | |
|
157 | ||
|
158 | // } | |
|
159 | // else | |
|
160 | // { | |
|
161 | // QAbstractSeries::attachAxis(axis); | |
|
162 | // } | |
|
163 | //} | |
|
164 | ||
|
165 | /*! | |
|
166 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
|
167 | pen from chart theme is used. | |
|
168 | \sa QChart::setTheme() | |
|
169 | */ | |
|
170 | void QColorMapSeries::setPen(const QPen &pen) | |
|
171 | { | |
|
172 | Q_D(QColorMapSeries); | |
|
173 | if (d->m_pen != pen) | |
|
174 | { | |
|
175 | //bool emitColorChanged = d->m_pen.color() != pen.color(); | |
|
176 | d->m_pen = pen; | |
|
177 | emit d->updated(); | |
|
178 | // if (emitColorChanged) | |
|
179 | // emit colorChanged(pen.color()); | |
|
180 | emit penChanged(pen); | |
|
181 | } | |
|
182 | } | |
|
183 | ||
|
184 | QPen QColorMapSeries::pen() const | |
|
185 | { | |
|
186 | Q_D(const QColorMapSeries); | |
|
187 | if (d->m_pen == QChartPrivate::defaultPen()) | |
|
188 | return QPen(); | |
|
189 | else | |
|
190 | return d->m_pen; | |
|
191 | } | |
|
192 | ||
|
193 | /*! | |
|
194 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
|
195 | from chart theme setting is used. | |
|
196 | \sa QChart::setTheme() | |
|
197 | */ | |
|
198 | void QColorMapSeries::setBrush(const QBrush &brush) | |
|
199 | { | |
|
200 | Q_D(QColorMapSeries); | |
|
201 | if (d->m_brush != brush) | |
|
202 | { | |
|
203 | d->m_brush = brush; | |
|
204 | emit d->updated(); | |
|
205 | } | |
|
206 | } | |
|
207 | ||
|
208 | QBrush QColorMapSeries::brush() const | |
|
209 | { | |
|
210 | Q_D(const QColorMapSeries); | |
|
211 | if (d->m_brush == QChartPrivate::defaultBrush()) | |
|
212 | return QBrush(); | |
|
213 | else | |
|
214 | return d->m_brush; | |
|
215 | } | |
|
216 | ||
|
217 | //void QColorMapSeries::setColor(const QColor &color) | |
|
218 | //{ | |
|
219 | // QPen p = pen(); | |
|
220 | // if (p.color() != color) | |
|
221 | // { | |
|
222 | // p.setColor(color); | |
|
223 | // setPen(p); | |
|
224 | // } | |
|
225 | //} | |
|
226 | ||
|
227 | //QColor QColorMapSeries::color() const | |
|
228 | //{ | |
|
229 | // return pen().color(); | |
|
230 | //} | |
|
231 | ||
|
232 | //void QColorMapSeries::setPointsVisible(bool visible) | |
|
233 | //{ | |
|
234 | // Q_D(QColorMapSeries); | |
|
235 | // if (d->m_pointsVisible != visible) | |
|
236 | // { | |
|
237 | // d->m_pointsVisible = visible; | |
|
238 | // emit d->updated(); | |
|
239 | // } | |
|
240 | //} | |
|
241 | ||
|
242 | //bool QColorMapSeries::pointsVisible() const | |
|
243 | //{ | |
|
244 | // Q_D(const QColorMapSeries); | |
|
245 | // return d->m_pointsVisible; | |
|
246 | //} | |
|
247 | ||
|
248 | //void QColorMapSeries::setPointLabelsFormat(const QString &format) | |
|
249 | //{ | |
|
250 | // Q_D(QColorMapSeries); | |
|
251 | // if (d->m_pointLabelsFormat != format) | |
|
252 | // { | |
|
253 | // d->m_pointLabelsFormat = format; | |
|
254 | // emit pointLabelsFormatChanged(format); | |
|
255 | // } | |
|
256 | //} | |
|
257 | ||
|
258 | //QString QColorMapSeries::pointLabelsFormat() const | |
|
259 | //{ | |
|
260 | // Q_D(const QColorMapSeries); | |
|
261 | // return d->m_pointLabelsFormat; | |
|
262 | //} | |
|
263 | ||
|
264 | //void QColorMapSeries::setPointLabelsVisible(bool visible) | |
|
265 | //{ | |
|
266 | // Q_D(QColorMapSeries); | |
|
267 | // if (d->m_pointLabelsVisible != visible) | |
|
268 | // { | |
|
269 | // d->m_pointLabelsVisible = visible; | |
|
270 | // emit pointLabelsVisibilityChanged(visible); | |
|
271 | // } | |
|
272 | //} | |
|
273 | ||
|
274 | //bool QColorMapSeries::pointLabelsVisible() const | |
|
275 | //{ | |
|
276 | // Q_D(const QColorMapSeries); | |
|
277 | // return d->m_pointLabelsVisible; | |
|
278 | //} | |
|
279 | ||
|
280 | //void QColorMapSeries::setPointLabelsFont(const QFont &font) | |
|
281 | //{ | |
|
282 | // Q_D(QColorMapSeries); | |
|
283 | // if (d->m_pointLabelsFont != font) { | |
|
284 | // d->m_pointLabelsFont = font; | |
|
285 | // emit pointLabelsFontChanged(font); | |
|
286 | // } | |
|
287 | //} | |
|
288 | ||
|
289 | //QFont QColorMapSeries::pointLabelsFont() const | |
|
290 | //{ | |
|
291 | // Q_D(const QColorMapSeries); | |
|
292 | // return d->m_pointLabelsFont; | |
|
293 | //} | |
|
294 | ||
|
295 | //void QColorMapSeries::setPointLabelsColor(const QColor &color) | |
|
296 | //{ | |
|
297 | // Q_D(QColorMapSeries); | |
|
298 | // if (d->m_pointLabelsColor != color) { | |
|
299 | // d->m_pointLabelsColor = color; | |
|
300 | // emit pointLabelsColorChanged(color); | |
|
301 | // } | |
|
302 | //} | |
|
303 | ||
|
304 | //QColor QColorMapSeries::pointLabelsColor() const | |
|
305 | //{ | |
|
306 | // Q_D(const QColorMapSeries); | |
|
307 | // if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color()) | |
|
308 | // return QPen().color(); | |
|
309 | // else | |
|
310 | // return d->m_pointLabelsColor; | |
|
311 | //} | |
|
312 | ||
|
313 | //void QColorMapSeries::setPointLabelsClipping(bool enabled) | |
|
314 | //{ | |
|
315 | // Q_D(QColorMapSeries); | |
|
316 | // if (d->m_pointLabelsClipping != enabled) { | |
|
317 | // d->m_pointLabelsClipping = enabled; | |
|
318 | // emit pointLabelsClippingChanged(enabled); | |
|
319 | // } | |
|
320 | //} | |
|
321 | ||
|
322 | //bool QColorMapSeries::pointLabelsClipping() const | |
|
323 | //{ | |
|
324 | // Q_D(const QColorMapSeries); | |
|
325 | // return d->m_pointLabelsClipping; | |
|
326 | //} | |
|
327 | /*! | |
|
328 | Returns the minimum value of the series on the X axis. | |
|
329 | */ | |
|
330 | double QColorMapSeries::minX() | |
|
331 | { | |
|
332 | Q_D(QColorMapSeries); | |
|
333 | return d->m_minX; | |
|
334 | } | |
|
335 | ||
|
336 | /*! | |
|
337 | Returns the minimum value of the series on the Y axis. | |
|
338 | */ | |
|
339 | double QColorMapSeries::minY() | |
|
340 | { | |
|
341 | Q_D(QColorMapSeries); | |
|
342 | return d->m_minY; | |
|
343 | } | |
|
344 | ||
|
345 | /*! | |
|
346 | Returns the minimum value of the series on the Z axis. | |
|
347 | */ | |
|
348 | double QColorMapSeries::minZ() | |
|
349 | { | |
|
350 | Q_D(QColorMapSeries); | |
|
351 | return d->m_minZ; | |
|
352 | } | |
|
353 | ||
|
354 | /*! | |
|
355 | Returns the maximum value of the series on the X axis. | |
|
356 | */ | |
|
357 | double QColorMapSeries::maxX() | |
|
358 | { | |
|
359 | Q_D(QColorMapSeries); | |
|
360 | return d->m_maxX; | |
|
361 | } | |
|
362 | ||
|
363 | /*! | |
|
364 | Returns the maximum value of the series on the Y axis. | |
|
365 | */ | |
|
366 | double QColorMapSeries::maxY() | |
|
367 | { | |
|
368 | Q_D(QColorMapSeries); | |
|
369 | return d->m_maxY; | |
|
370 | } | |
|
371 | ||
|
372 | /*! | |
|
373 | Returns the maximum value of the series on the Z axis. | |
|
374 | */ | |
|
375 | double QColorMapSeries::maxZ() | |
|
376 | { | |
|
377 | Q_D(QColorMapSeries); | |
|
378 | return d->m_maxZ; | |
|
379 | } | |
|
380 | ||
|
381 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
382 | ||
|
383 | QColorMapSeriesPrivate::QColorMapSeriesPrivate(QColorMapSeries *q) | |
|
384 | : QAbstractSeriesPrivate(q), | |
|
385 | m_pen(QChartPrivate::defaultPen()), | |
|
386 | m_brush(QChartPrivate::defaultBrush()), | |
|
387 | m_pointsVisible(false), | |
|
388 | m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")), //TODO : change | |
|
389 | m_pointLabelsVisible(false), | |
|
390 | m_pointLabelsFont(QChartPrivate::defaultFont()), | |
|
391 | m_pointLabelsColor(QChartPrivate::defaultPen().color()), | |
|
392 | m_pointLabelsClipping(true) | |
|
393 | { | |
|
394 | } | |
|
395 | ||
|
396 | void QColorMapSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |
|
397 | { | |
|
398 | Q_Q(QColorMapSeries); | |
|
399 | ColorMapChart *colormap = new ColorMapChart(q,parent); | |
|
400 | m_item.reset(colormap); | |
|
401 | QAbstractSeriesPrivate::initializeGraphics(parent); | |
|
402 | } | |
|
403 | ||
|
404 | void QColorMapSeriesPrivate::initializeDomain() | |
|
405 | { | |
|
406 | domain()->setRange(m_minX, m_maxX, m_minY, m_maxY); | |
|
407 | } | |
|
408 | ||
|
409 | void QColorMapSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) | |
|
410 | { | |
|
411 | // Q_Q(QColorMapSeries); | |
|
412 | ||
|
413 | // const QList<QGradient> gradients = theme->seriesGradients(); | |
|
414 | // const QList<QColor> colors = theme->seriesColors(); | |
|
415 | ||
|
416 | // if (forced || QChartPrivate::defaultPen() == m_pen) { | |
|
417 | // QPen pen; | |
|
418 | // pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0)); | |
|
419 | // pen.setWidthF(2); | |
|
420 | // q->setPen(pen); | |
|
421 | // } | |
|
422 | ||
|
423 | // if (forced || QChartPrivate::defaultBrush() == m_brush) { | |
|
424 | // QBrush brush(colors.at(index % colors.size())); | |
|
425 | // q->setBrush(brush); | |
|
426 | // } | |
|
427 | ||
|
428 | // if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) { | |
|
429 | // QColor color = theme->labelBrush().color(); | |
|
430 | // q->setPointLabelsColor(color); | |
|
431 | // } | |
|
432 | } | |
|
433 | ||
|
434 | QList<QLegendMarker*> QColorMapSeriesPrivate::createLegendMarkers(QLegend* legend) | |
|
435 | { | |
|
436 | Q_Q(QColorMapSeries); | |
|
437 | QList<QLegendMarker*> list; | |
|
438 | return list << new QColorMapLegendMarker(q,legend); | |
|
439 | } | |
|
440 | ||
|
441 | void QColorMapSeriesPrivate::initializeAxes() | |
|
442 | { | |
|
443 | ||
|
444 | } | |
|
445 | ||
|
446 | QAbstractAxis::AxisType QColorMapSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
|
447 | { | |
|
448 | Q_UNUSED(orientation); | |
|
449 | return QAbstractAxis::AxisTypeValue; | |
|
450 | } | |
|
451 | ||
|
452 | QAbstractAxis* QColorMapSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
|
453 | { | |
|
454 | Q_UNUSED(orientation); | |
|
455 | return new QValueAxis; | |
|
456 | } | |
|
457 | ||
|
458 | ||
|
459 | void QColorMapSeriesPrivate::getUniformGrid(double minX, double maxX, double minY, double maxY, int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy) | |
|
460 | { | |
|
461 | m_imageHeight = height; | |
|
462 | m_imageWidth = width; | |
|
463 | m_strategy = strategy; | |
|
464 | ||
|
465 | m_requestedMinX = minX; | |
|
466 | m_requestedMaxX = maxX; | |
|
467 | m_requestedMinY = minY; | |
|
468 | m_requestedMaxY = maxY; | |
|
469 | ||
|
470 | int index=0; | |
|
471 | std::generate(grid.begin(),grid.end(),[&index]{return index++;}); | |
|
472 | ||
|
473 | QFuture<void> futureWatcher = QtConcurrent::map(grid,[this] (double &index) { return computePixelValue(index); }); | |
|
474 | ||
|
475 | futureWatcher.waitForFinished(); | |
|
476 | } | |
|
477 | ||
|
478 | double QColorMapSeriesPrivate::computePixelValue(double &index) | |
|
479 | { | |
|
480 | QVector<Point3D> cluster; | |
|
481 | cluster.reserve(m_imageHeight*m_imageWidth/1000); | |
|
482 | cluster.resize(0); | |
|
483 | ||
|
484 | double dx = (m_requestedMaxX - m_requestedMinX)/m_imageWidth; | |
|
485 | double dy = (m_requestedMaxY - m_requestedMinY)/m_imageHeight; | |
|
486 | ||
|
487 | int x = (int)index%m_imageWidth; | |
|
488 | int y = (int)index/m_imageWidth; | |
|
489 | this->buildCluster(x,y,dx,dy,cluster); | |
|
490 | if(m_strategy == QColorMapSeries::LastPixel) | |
|
491 | index = this->clusterStrategyLast(cluster); | |
|
492 | else if(m_strategy == QColorMapSeries::MeanPixel) | |
|
493 | index = this->clusterStrategyMean(cluster); | |
|
494 | else if(m_strategy == QColorMapSeries::MedianPixel) | |
|
495 | index = this->clusterStrategyMedian(cluster); | |
|
496 | ||
|
497 | return index;//not used | |
|
498 | } | |
|
499 | ||
|
500 | /*! | |
|
501 | Recompute the data range on X, Y and Z axes each time a ColorMapDataPart is added to the series.\n | |
|
502 | The minimum distance between 2 adjacent values on X and Y axis is added to the maximum on X and Y respectively\n | |
|
503 | in order to take account of the width of the last element. | |
|
504 | */ | |
|
505 | void QColorMapSeriesPrivate::recomputeDataRange() | |
|
506 | { | |
|
507 | //TODO : if non empty | |
|
508 | m_minX = m_dataParts.first()->timesSeries().first(); | |
|
509 | m_maxX = m_dataParts.last()->timesSeries().last(); | |
|
510 | ||
|
511 | m_minY = m_dataParts.last()->ySeries().last(); | |
|
512 | m_maxY = m_dataParts.last()->ySeries().first(); | |
|
513 | m_minZ = m_dataParts.first()->dataSeries().first(); | |
|
514 | m_maxZ = m_dataParts.last()->dataSeries().last(); | |
|
515 | double minDeltaX=m_maxX-m_minX; | |
|
516 | double minDeltaY=m_minY-m_maxY; | |
|
517 | foreach(ColorMapDataPart* datapart, m_dataParts) | |
|
518 | { | |
|
519 | m_minY = qMin(datapart->ySeries().first(),m_minY); | |
|
520 | m_maxY = qMax(datapart->ySeries().last(),m_maxY); | |
|
521 | for(int i=1;i<datapart->timesSeries().size();i++) | |
|
522 | { | |
|
523 | double newDeltaX=datapart->timesSeries()[i]-datapart->timesSeries()[i-1]; | |
|
524 | minDeltaX=qMin(minDeltaX,newDeltaX); | |
|
525 | } | |
|
526 | for(int i=1;i<datapart->ySeries().size();i++) | |
|
527 | { | |
|
528 | double newDeltaY=datapart->ySeries()[i]-datapart->ySeries()[i-1]; | |
|
529 | minDeltaY=qMin(minDeltaY,newDeltaY); | |
|
530 | } | |
|
531 | ||
|
532 | for (int i = 0; i < datapart->dataSeries().count(); i++) | |
|
533 | { | |
|
534 | double z = datapart->dataSeries().at(i); | |
|
535 | m_minZ = qMin(m_minZ, z); | |
|
536 | m_maxZ = qMax(m_maxZ, z); | |
|
537 | } | |
|
538 | } | |
|
539 | m_maxX+=minDeltaX; | |
|
540 | m_maxY+=minDeltaY; | |
|
541 | } | |
|
542 | ||
|
543 | /*! | |
|
544 | Returns the last value (bottom right Z value) of a \a cluster of points passed as argument. | |
|
545 | */ | |
|
546 | double QColorMapSeriesPrivate::clusterStrategyLast(QVector<Point3D>& cluster) | |
|
547 | { | |
|
548 | if(!cluster.isEmpty()) | |
|
549 | return cluster.last().value(); | |
|
550 | return 0; | |
|
551 | } | |
|
552 | ||
|
553 | /*! | |
|
554 | Returns the mean value (mean Z value) of a \a cluster of points passed as argument. | |
|
555 | */ | |
|
556 | double QColorMapSeriesPrivate::clusterStrategyMean(QVector<Point3D>& cluster) | |
|
557 | { | |
|
558 | if(!cluster.isEmpty()) | |
|
559 | { | |
|
560 | double sum=0; | |
|
561 | int count =0; | |
|
562 | for(int i =0;i<cluster.size();i++) | |
|
563 | { | |
|
564 | if(!std::isnan(Point3D(cluster.at(i)).value())) | |
|
565 | { | |
|
566 | sum+= Point3D(cluster.at(i)).value(); | |
|
567 | count++; | |
|
568 | } | |
|
569 | } | |
|
570 | return (sum/count); | |
|
571 | } | |
|
572 | return 0; | |
|
573 | } | |
|
574 | ||
|
575 | /*! | |
|
576 | Returns the median value (median Z value) of a \a cluster of points passed as argument. | |
|
577 | */ | |
|
578 | double QColorMapSeriesPrivate::clusterStrategyMedian(QVector<Point3D>& cluster) | |
|
579 | { | |
|
580 | if(!cluster.isEmpty()) | |
|
581 | { | |
|
582 | QVector<double> *copy = new QVector<double>(); | |
|
583 | ||
|
584 | for(int i =0;i<cluster.size();i++) | |
|
585 | { | |
|
586 | if(!std::isnan(Point3D(cluster.at(i)).value())) | |
|
587 | copy->append(Point3D(cluster.at(i)).value()); | |
|
588 | } | |
|
589 | ||
|
590 | if(!copy->isEmpty()) | |
|
591 | { | |
|
592 | std::sort(copy->begin(), copy->end()); | |
|
593 | ||
|
594 | if(copy->count() & 1) // odd | |
|
595 | { | |
|
596 | int middle = (copy->count()+1)/2; | |
|
597 | return copy->at(middle-1); | |
|
598 | } | |
|
599 | else //even | |
|
600 | { | |
|
601 | int middle = copy->count()/2; | |
|
602 | return (copy->at(middle-1)+copy->at(middle))/2; | |
|
603 | } | |
|
604 | } | |
|
605 | } | |
|
606 | return 0; | |
|
607 | } | |
|
608 | ||
|
609 | /*! | |
|
610 | Computes which data points correspond to the given position and returns the in a \a cluster. | |
|
611 | */ | |
|
612 | void QColorMapSeriesPrivate::buildCluster(int xpos, int ypos, double dx, double dy, QVector<Point3D>& cluster) | |
|
613 | { | |
|
614 | foreach(ColorMapDataPart *dataPart, m_dataParts) | |
|
615 | { | |
|
616 | QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_requestedMinX+xpos*dx,m_requestedMinX+(xpos+1)*dx); | |
|
617 | QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_requestedMaxY-(ypos+1)*dy,m_requestedMaxY-ypos*dy); | |
|
618 | ||
|
619 | int timeSeriesSize = dataPart->timesSeries().size(); | |
|
620 | ||
|
621 | if(xRange.first != xRange.second && yRange.first != yRange.second) | |
|
622 | { | |
|
623 | for(int i =xRange.first+1;i<xRange.second;i++) | |
|
624 | { | |
|
625 | qreal xval=dataPart->timesSeries()[i]; | |
|
626 | for(int j=yRange.first+1;j<yRange.second;j++) | |
|
627 | { | |
|
628 | qreal yval=dataPart->ySeries()[j]; | |
|
629 | qreal val=dataPart->dataSeries()[ i + (timeSeriesSize * j)]; | |
|
630 | cluster.append(Point3D(xval,yval,val)); | |
|
631 | } | |
|
632 | } | |
|
633 | } | |
|
634 | } | |
|
635 | } | |
|
636 | ||
|
637 | ||
|
638 | void QColorMapSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options, | |
|
639 | int duration, QEasingCurve &curve) | |
|
640 | { | |
|
641 | // ColorMapChart *item = static_cast<ColorMapChart *>(m_item.data()); | |
|
642 | // Q_ASSERT(item); | |
|
643 | // if (item->animation()) | |
|
644 | // item->animation()->stopAndDestroyLater(); | |
|
645 | ||
|
646 | // if (options.testFlag(QChart::SeriesAnimations)) | |
|
647 | // item->setAnimation(new XYAnimation(item, duration, curve)); | |
|
648 | // else | |
|
649 | // item->setAnimation(0); | |
|
650 | QAbstractSeriesPrivate::initializeAnimations(options, duration, curve); | |
|
651 | } | |
|
652 | ||
|
653 | ||
|
654 | ||
|
655 | #include "moc_qcolormapseries.cpp" | |
|
656 | #include "moc_qcolormapseries_p.cpp" | |
|
657 | ||
|
658 | QT_CHARTS_END_NAMESPACE |
@@ -0,0 +1,144 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef QCOLORMAPSERIES_H | |
|
24 | #define QCOLORMAPSERIES_H | |
|
25 | ||
|
26 | #include <QtCharts/QChartGlobal> | |
|
27 | #include <QtCharts/QAbstractSeries> | |
|
28 | #include <QtGui/QPen> | |
|
29 | #include <QtGui/QBrush> | |
|
30 | #include "colormapdatapart.h" | |
|
31 | ||
|
32 | QT_CHARTS_BEGIN_NAMESPACE | |
|
33 | class QColorMapSeriesPrivate; | |
|
34 | ||
|
35 | ||
|
36 | class QT_CHARTS_EXPORT QColorMapSeries : public QAbstractSeries | |
|
37 | { | |
|
38 | Q_OBJECT | |
|
39 | // Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible) | |
|
40 | // Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) | |
|
41 | // Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged) | |
|
42 | // Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged) | |
|
43 | // Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged) | |
|
44 | // Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged) | |
|
45 | // Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged) | |
|
46 | ||
|
47 | protected: | |
|
48 | explicit QColorMapSeries(QColorMapSeriesPrivate &d, QObject *parent =0); | |
|
49 | ||
|
50 | ||
|
51 | public : | |
|
52 | ||
|
53 | enum Strategy | |
|
54 | { | |
|
55 | LastPixel, | |
|
56 | MeanPixel, | |
|
57 | MedianPixel | |
|
58 | }; | |
|
59 | ||
|
60 | ||
|
61 | explicit QColorMapSeries(QObject *parent =0); | |
|
62 | ~QColorMapSeries(); | |
|
63 | QAbstractSeries::SeriesType type() const; | |
|
64 | void append(ColorMapDataPart* dataPart, bool copy=true); | |
|
65 | void append(const QList<ColorMapDataPart *> &dataParts, bool copy=true); | |
|
66 | ||
|
67 | int count() const; | |
|
68 | QVector<ColorMapDataPart*> dataParts() const; | |
|
69 | ||
|
70 | QColorMapSeries &operator << (const ColorMapDataPart &dataPart); | |
|
71 | QColorMapSeries &operator << (const QList<ColorMapDataPart *> &dataParts); | |
|
72 | ||
|
73 | void getUniformGrid(double minX, double maxX, double minY, double maxY, int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy); | |
|
74 | // QVector<double> *getUniformGrid(int width, int height, QVector<double> &grid, Strategy lambda); | |
|
75 | ||
|
76 | // virtual void attachAxis(QAbstractAxis *axis); | |
|
77 | ||
|
78 | virtual void setPen(const QPen &pen); | |
|
79 | QPen pen() const; | |
|
80 | ||
|
81 | virtual void setBrush(const QBrush &brush); | |
|
82 | QBrush brush() const; | |
|
83 | ||
|
84 | // virtual void setColor(const QColor &color); | |
|
85 | // QColor color() const; | |
|
86 | ||
|
87 | // void setPointsVisible(bool visible = true); | |
|
88 | // bool pointsVisible() const; | |
|
89 | ||
|
90 | // void setPointLabelsFormat(const QString &format); | |
|
91 | // QString pointLabelsFormat() const; | |
|
92 | ||
|
93 | // void setPointLabelsVisible(bool visible = true); | |
|
94 | // bool pointLabelsVisible() const; | |
|
95 | ||
|
96 | // void setPointLabelsFont(const QFont &font); | |
|
97 | // QFont pointLabelsFont() const; | |
|
98 | ||
|
99 | // void setPointLabelsColor(const QColor &color); | |
|
100 | // QColor pointLabelsColor() const; | |
|
101 | ||
|
102 | // void setPointLabelsClipping(bool enabled = true); | |
|
103 | // bool pointLabelsClipping() const; | |
|
104 | ||
|
105 | double minX(); | |
|
106 | double minY(); | |
|
107 | double minZ(); | |
|
108 | double maxX(); | |
|
109 | double maxY(); | |
|
110 | double maxZ(); | |
|
111 | ||
|
112 | ||
|
113 | ||
|
114 | Q_SIGNALS: | |
|
115 | // void clicked(const Point3D &point); | |
|
116 | // void hovered(const Point3D &point, bool state); | |
|
117 | // void pressed(const Point3D &point); | |
|
118 | // void released(const Point3D &point); | |
|
119 | // void doubleClicked(const Point3D &point); | |
|
120 | // void pointReplaced(int index); | |
|
121 | // void pointRemoved(int index); | |
|
122 | void dataPartAdded(int index); | |
|
123 | // void colorChanged(QColor color); | |
|
124 | // void pointsReplaced(); | |
|
125 | // void pointLabelsFormatChanged(const QString &format); | |
|
126 | // void pointLabelsVisibilityChanged(bool visible); | |
|
127 | // void pointLabelsFontChanged(const QFont &font); | |
|
128 | // void pointLabelsColorChanged(const QColor &color); | |
|
129 | // void pointLabelsClippingChanged(bool clipping); | |
|
130 | // void pointsRemoved(int index, int count); | |
|
131 | void penChanged(const QPen &pen); | |
|
132 | ||
|
133 | private: | |
|
134 | Q_DECLARE_PRIVATE(QColorMapSeries) | |
|
135 | Q_DISABLE_COPY(QColorMapSeries) | |
|
136 | friend class ColorMapLegendMarker; | |
|
137 | friend class ColorMapChart; | |
|
138 | friend class QColorMapLegendMarkerPrivate; | |
|
139 | ||
|
140 | }; | |
|
141 | ||
|
142 | QT_CHARTS_END_NAMESPACE | |
|
143 | ||
|
144 | #endif // QCOLORMAPSERIES_H |
@@ -0,0 +1,100 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #ifndef QCOLORMAPSERIES_P_H | |
|
24 | #define QCOLORMAPSERIES_P_H | |
|
25 | ||
|
26 | #include <private/qabstractseries_p.h> | |
|
27 | #include "colormapdatapart.h" | |
|
28 | #include <point3d.h> | |
|
29 | ||
|
30 | QT_CHARTS_BEGIN_NAMESPACE | |
|
31 | ||
|
32 | #include "qcolormapseries.h" | |
|
33 | ||
|
34 | class QAbstractAxis; | |
|
35 | ||
|
36 | class QColorMapSeriesPrivate : public QAbstractSeriesPrivate | |
|
37 | { | |
|
38 | Q_OBJECT | |
|
39 | ||
|
40 | public : | |
|
41 | ||
|
42 | QColorMapSeriesPrivate(QColorMapSeries *q); | |
|
43 | ||
|
44 | void initializeDomain(); | |
|
45 | void initializeAxes(); | |
|
46 | void initializeGraphics(QGraphicsItem* parent); | |
|
47 | void initializeTheme(int index, ChartTheme* theme, bool forced = false); | |
|
48 | void initializeAnimations(QChart::AnimationOptions options, int duration, | |
|
49 | QEasingCurve &curve); | |
|
50 | ||
|
51 | QList<QLegendMarker *> createLegendMarkers(QLegend *legend); | |
|
52 | ||
|
53 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; | |
|
54 | QAbstractAxis* createDefaultAxis(Qt::Orientation) const; | |
|
55 | ||
|
56 | void getUniformGrid(double minX, double maxX, double minY, double maxY, int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy); | |
|
57 | ||
|
58 | Q_SIGNALS: | |
|
59 | void updated(); | |
|
60 | ||
|
61 | protected: | |
|
62 | QList<ColorMapDataPart*> m_dataParts; | |
|
63 | QPen m_pen; | |
|
64 | QBrush m_brush; | |
|
65 | bool m_pointsVisible; | |
|
66 | QString m_pointLabelsFormat; | |
|
67 | bool m_pointLabelsVisible; | |
|
68 | QFont m_pointLabelsFont; | |
|
69 | QColor m_pointLabelsColor; | |
|
70 | bool m_pointLabelsClipping; | |
|
71 | ||
|
72 | private: | |
|
73 | double m_minX; | |
|
74 | double m_maxX; | |
|
75 | double m_minY; | |
|
76 | double m_maxY; | |
|
77 | double m_minZ; | |
|
78 | double m_maxZ; | |
|
79 | int m_imageHeight; | |
|
80 | int m_imageWidth; | |
|
81 | QColorMapSeries::Strategy m_strategy; | |
|
82 | ||
|
83 | double m_requestedMinX; | |
|
84 | double m_requestedMaxX; | |
|
85 | double m_requestedMinY; | |
|
86 | double m_requestedMaxY; | |
|
87 | ||
|
88 | void recomputeDataRange(); | |
|
89 | double computePixelValue(double &index); | |
|
90 | double clusterStrategyLast(QVector<Point3D>& cluster); | |
|
91 | double clusterStrategyMean(QVector<Point3D> &cluster); | |
|
92 | double clusterStrategyMedian(QVector<Point3D>& cluster); | |
|
93 | void buildCluster(int xpos,int ypos, double dx,double dy,QVector<Point3D>& cluster); | |
|
94 | Q_DECLARE_PUBLIC(QColorMapSeries) | |
|
95 | }; | |
|
96 | ||
|
97 | QT_CHARTS_END_NAMESPACE | |
|
98 | ||
|
99 | ||
|
100 | #endif // QCOLORMAPSERIES_P_H |
@@ -0,0 +1,105 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | ||
|
23 | #include <QtCharts/QColorMapLegendMarker> | |
|
24 | #include <private/qcolormapseries_p.h> | |
|
25 | #include <private/qcolormaplegendmarker_p.h> | |
|
26 | #include <QtCharts/QColorMapSeries> | |
|
27 | ||
|
28 | QT_CHARTS_BEGIN_NAMESPACE | |
|
29 | ||
|
30 | QColorMapLegendMarker::QColorMapLegendMarker(QColorMapSeries *series, QLegend *legend, QObject *parent) | |
|
31 | : QLegendMarker(*new QColorMapLegendMarkerPrivate(this,series,legend), parent) | |
|
32 | { | |
|
33 | d_ptr->updated(); | |
|
34 | } | |
|
35 | ||
|
36 | QColorMapLegendMarker::~QColorMapLegendMarker() | |
|
37 | { | |
|
38 | } | |
|
39 | ||
|
40 | QColorMapLegendMarker::QColorMapLegendMarker(QColorMapLegendMarkerPrivate &d, QObject *parent) : | |
|
41 | QLegendMarker(d, parent) | |
|
42 | { | |
|
43 | } | |
|
44 | ||
|
45 | QColorMapSeries* QColorMapLegendMarker::series() | |
|
46 | { | |
|
47 | Q_D(QColorMapLegendMarker); | |
|
48 | return d->m_series; | |
|
49 | } | |
|
50 | ||
|
51 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
52 | ||
|
53 | QColorMapLegendMarkerPrivate::QColorMapLegendMarkerPrivate(QColorMapLegendMarker *q, QColorMapSeries *series, QLegend *legend) : | |
|
54 | QLegendMarkerPrivate(q,legend), | |
|
55 | q_ptr(q), | |
|
56 | m_series(series) | |
|
57 | { | |
|
58 | QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated())); | |
|
59 | QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated())); | |
|
60 | } | |
|
61 | ||
|
62 | QColorMapLegendMarkerPrivate::~QColorMapLegendMarkerPrivate() | |
|
63 | { | |
|
64 | } | |
|
65 | ||
|
66 | QAbstractSeries* QColorMapLegendMarkerPrivate::series() | |
|
67 | { | |
|
68 | return m_series; | |
|
69 | } | |
|
70 | ||
|
71 | QObject* QColorMapLegendMarkerPrivate::relatedObject() | |
|
72 | { | |
|
73 | return m_series; | |
|
74 | } | |
|
75 | ||
|
76 | void QColorMapLegendMarkerPrivate::updated() | |
|
77 | { | |
|
78 | bool labelChanged = false; | |
|
79 | bool brushChanged = false; | |
|
80 | ||
|
81 | if (!m_customLabel && (m_item->label() != m_series->name())) { | |
|
82 | m_item->setLabel(m_series->name()); | |
|
83 | labelChanged = true; | |
|
84 | } | |
|
85 | ||
|
86 | QBrush emptyBrush; | |
|
87 | if (!m_customBrush | |
|
88 | && (m_item->brush() == emptyBrush | |
|
89 | || m_item->brush().color() != m_series->pen().color())) { | |
|
90 | m_item->setBrush(QBrush(m_series->pen().color())); | |
|
91 | brushChanged = true; | |
|
92 | } | |
|
93 | ||
|
94 | invalidateLegend(); | |
|
95 | ||
|
96 | if (labelChanged) | |
|
97 | emit q_ptr->labelChanged(); | |
|
98 | if (brushChanged) | |
|
99 | emit q_ptr->brushChanged(); | |
|
100 | } | |
|
101 | ||
|
102 | //#include "moc_qcolormaplegendmarker.cpp" | |
|
103 | //#include "moc_qcolormaplegendmarker_p.cpp" | |
|
104 | ||
|
105 | QT_CHARTS_END_NAMESPACE |
@@ -0,0 +1,55 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the ColorMapChart API | |
|
3 | -- Copyright (C) 2016, Plasma Physics Laboratory - CNRS | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | -------------------------------------------------------------------------------*/ | |
|
19 | /*-- Author : Hugo Winter | |
|
20 | -- Mail : hugo.winter@lpp.polytechnique.fr | |
|
21 | ----------------------------------------------------------------------------*/ | |
|
22 | #ifndef QCOLORMAPLEGENDMARKER_H | |
|
23 | #define QCOLORMAPLEGENDMARKER_H | |
|
24 | ||
|
25 | #include <QtCharts/QChartGlobal> | |
|
26 | #include <QtCharts/QLegendMarker> | |
|
27 | #include <QtCharts/QColorMapSeries> | |
|
28 | ||
|
29 | QT_CHARTS_BEGIN_NAMESPACE | |
|
30 | ||
|
31 | class QColorMapLegendMarkerPrivate; | |
|
32 | ||
|
33 | class QColorMapLegendMarker : public QLegendMarker | |
|
34 | { | |
|
35 | Q_OBJECT | |
|
36 | public: | |
|
37 | explicit QColorMapLegendMarker(QColorMapSeries *series, QLegend *legend, QObject *parent = 0); | |
|
38 | virtual ~QColorMapLegendMarker(); | |
|
39 | ||
|
40 | virtual LegendMarkerType type() { return LegendMarkerTypeColorMap; } | |
|
41 | ||
|
42 | // Related series | |
|
43 | virtual QColorMapSeries* series(); | |
|
44 | ||
|
45 | protected: | |
|
46 | QColorMapLegendMarker(QColorMapLegendMarkerPrivate &d, QObject *parent = 0); | |
|
47 | ||
|
48 | private: | |
|
49 | Q_DECLARE_PRIVATE(QColorMapLegendMarker) | |
|
50 | Q_DISABLE_COPY(QColorMapLegendMarker) | |
|
51 | }; | |
|
52 | ||
|
53 | QT_CHARTS_END_NAMESPACE | |
|
54 | ||
|
55 | #endif // QCOLORMAPLEGENDMARKER_H |
@@ -0,0 +1,35 | |||
|
1 | #ifndef QCOLORMAPLEGENDMARKER_P_H | |
|
2 | #define QCOLORMAPLEGENDMARKER_P_H | |
|
3 | ||
|
4 | #include <QtCharts/QChartGlobal> | |
|
5 | #include <private/qlegendmarker_p.h> | |
|
6 | #include <private/legendmarkeritem_p.h> | |
|
7 | #include <QtCharts/QColorMapSeries> | |
|
8 | ||
|
9 | QT_CHARTS_BEGIN_NAMESPACE | |
|
10 | ||
|
11 | class QColorMapLegendMarker; | |
|
12 | ||
|
13 | class QColorMapLegendMarkerPrivate : public QLegendMarkerPrivate | |
|
14 | { | |
|
15 | Q_OBJECT | |
|
16 | public: | |
|
17 | explicit QColorMapLegendMarkerPrivate(QColorMapLegendMarker *q, QColorMapSeries *series, QLegend *legend); | |
|
18 | virtual ~QColorMapLegendMarkerPrivate(); | |
|
19 | ||
|
20 | virtual QAbstractSeries* series(); | |
|
21 | virtual QObject* relatedObject(); | |
|
22 | ||
|
23 | public Q_SLOTS: | |
|
24 | virtual void updated(); | |
|
25 | ||
|
26 | private: | |
|
27 | QColorMapLegendMarker *q_ptr; | |
|
28 | QColorMapSeries *m_series; | |
|
29 | ||
|
30 | Q_DECLARE_PUBLIC(QColorMapLegendMarker) | |
|
31 | }; | |
|
32 | ||
|
33 | QT_CHARTS_END_NAMESPACE | |
|
34 | ||
|
35 | #endif // QCOLORMAPLEGENDMARKER_P_H |
@@ -1,99 +1,105 | |||
|
1 | 1 | #Subdirectiores are defined here, because qt creator doesn't handle nested include(foo.pri) chains very well. |
|
2 | 2 | |
|
3 | 3 | INCLUDEPATH += $$PWD \ |
|
4 | 4 | $$PWD/valueaxis \ |
|
5 | 5 | $$PWD/barcategoryaxis \ |
|
6 | 6 | $$PWD/categoryaxis \ |
|
7 | $$PWD/logvalueaxis | |
|
7 | $$PWD/logvalueaxis \ | |
|
8 | $$PWD/colorbaraxis | |
|
8 | 9 | |
|
9 | 10 | SOURCES += \ |
|
10 | 11 | $$PWD/chartaxiselement.cpp \ |
|
11 | 12 | $$PWD/cartesianchartaxis.cpp \ |
|
12 | 13 | $$PWD/qabstractaxis.cpp \ |
|
13 | 14 | $$PWD/verticalaxis.cpp \ |
|
14 | 15 | $$PWD/horizontalaxis.cpp \ |
|
15 | 16 | $$PWD/valueaxis/chartvalueaxisx.cpp \ |
|
16 | 17 | $$PWD/valueaxis/chartvalueaxisy.cpp \ |
|
17 | 18 | $$PWD/valueaxis/qvalueaxis.cpp \ |
|
18 | 19 | $$PWD/barcategoryaxis/chartbarcategoryaxisx.cpp \ |
|
19 | 20 | $$PWD/barcategoryaxis/chartbarcategoryaxisy.cpp \ |
|
20 | 21 | $$PWD/barcategoryaxis/qbarcategoryaxis.cpp \ |
|
21 | 22 | $$PWD/categoryaxis/chartcategoryaxisx.cpp \ |
|
22 | 23 | $$PWD/categoryaxis/chartcategoryaxisy.cpp \ |
|
23 | 24 | $$PWD/categoryaxis/qcategoryaxis.cpp \ |
|
24 | 25 | $$PWD/logvalueaxis/chartlogvalueaxisx.cpp \ |
|
25 | 26 | $$PWD/logvalueaxis/chartlogvalueaxisy.cpp \ |
|
26 | $$PWD/logvalueaxis/qlogvalueaxis.cpp | |
|
27 | $$PWD/logvalueaxis/qlogvalueaxis.cpp \ | |
|
28 | $$PWD/colorbaraxis/qcolorbaraxis.cpp \ | |
|
29 | $$PWD/colorbaraxis/chartcolorbaraxisy.cpp | |
|
27 | 30 | |
|
28 | 31 | PRIVATE_HEADERS += \ |
|
29 | 32 | $$PWD/chartaxiselement_p.h \ |
|
30 | 33 | $$PWD/cartesianchartaxis_p.h \ |
|
31 | 34 | $$PWD/qabstractaxis_p.h \ |
|
32 | 35 | $$PWD/verticalaxis_p.h \ |
|
33 | 36 | $$PWD/horizontalaxis_p.h \ |
|
34 | 37 | $$PWD/linearrowitem_p.h \ |
|
35 | 38 | $$PWD/valueaxis/chartvalueaxisx_p.h \ |
|
36 | 39 | $$PWD/valueaxis/chartvalueaxisy_p.h \ |
|
37 | 40 | $$PWD/valueaxis/qvalueaxis_p.h \ |
|
38 | 41 | $$PWD/barcategoryaxis/chartbarcategoryaxisx_p.h \ |
|
39 | 42 | $$PWD/barcategoryaxis/chartbarcategoryaxisy_p.h \ |
|
40 | 43 | $$PWD/barcategoryaxis/qbarcategoryaxis_p.h \ |
|
41 | 44 | $$PWD/categoryaxis/chartcategoryaxisx_p.h \ |
|
42 | 45 | $$PWD/categoryaxis/chartcategoryaxisy_p.h \ |
|
43 | 46 | $$PWD/categoryaxis/qcategoryaxis_p.h \ |
|
44 | 47 | $$PWD/logvalueaxis/chartlogvalueaxisx_p.h \ |
|
45 | 48 | $$PWD/logvalueaxis/chartlogvalueaxisy_p.h \ |
|
46 | $$PWD/logvalueaxis/qlogvalueaxis_p.h | |
|
49 | $$PWD/logvalueaxis/qlogvalueaxis_p.h \ | |
|
50 | $$PWD/colorbaraxis/qcolorbaraxis_p.h \ | |
|
51 | $$PWD/colorbaraxis/chartcolorbaraxisy_p.h | |
|
47 | 52 | |
|
48 | 53 | PUBLIC_HEADERS += \ |
|
49 | 54 | $$PWD/qabstractaxis.h \ |
|
50 | 55 | $$PWD/valueaxis/qvalueaxis.h \ |
|
51 | 56 | $$PWD/barcategoryaxis/qbarcategoryaxis.h \ |
|
52 | 57 | $$PWD/categoryaxis/qcategoryaxis.h \ |
|
53 | 58 | $$PWD/logvalueaxis/qlogvalueaxis.h \ |
|
59 | $$PWD/colorbaraxis/qcolorbaraxis.h | |
|
54 | 60 | |
|
55 | 61 | # polar |
|
56 | 62 | SOURCES += \ |
|
57 | 63 | $$PWD/polarchartaxis.cpp \ |
|
58 | 64 | $$PWD/polarchartaxisangular.cpp \ |
|
59 | 65 | $$PWD/polarchartaxisradial.cpp \ |
|
60 | 66 | $$PWD/valueaxis/polarchartvalueaxisangular.cpp \ |
|
61 | 67 | $$PWD/valueaxis/polarchartvalueaxisradial.cpp \ |
|
62 | 68 | $$PWD/logvalueaxis/polarchartlogvalueaxisangular.cpp \ |
|
63 | 69 | $$PWD/logvalueaxis/polarchartlogvalueaxisradial.cpp \ |
|
64 | 70 | $$PWD/categoryaxis/polarchartcategoryaxisangular.cpp \ |
|
65 | 71 | $$PWD/categoryaxis/polarchartcategoryaxisradial.cpp |
|
66 | 72 | |
|
67 | 73 | PRIVATE_HEADERS += \ |
|
68 | 74 | $$PWD/polarchartaxis_p.h \ |
|
69 | 75 | $$PWD/polarchartaxisangular_p.h \ |
|
70 | 76 | $$PWD/polarchartaxisradial_p.h \ |
|
71 | 77 | $$PWD/valueaxis/polarchartvalueaxisangular_p.h \ |
|
72 | 78 | $$PWD/valueaxis/polarchartvalueaxisradial_p.h \ |
|
73 | 79 | $$PWD/logvalueaxis/polarchartlogvalueaxisangular_p.h \ |
|
74 | 80 | $$PWD/logvalueaxis/polarchartlogvalueaxisradial_p.h \ |
|
75 | 81 | $$PWD/categoryaxis/polarchartcategoryaxisangular_p.h \ |
|
76 | 82 | $$PWD/categoryaxis/polarchartcategoryaxisradial_p.h |
|
77 | 83 | |
|
78 | 84 | !contains(QT_COORD_TYPE, float): { |
|
79 | 85 | INCLUDEPATH += \ |
|
80 | 86 | $$PWD/datetimeaxis |
|
81 | 87 | |
|
82 | 88 | SOURCES += \ |
|
83 | 89 | $$PWD/datetimeaxis/chartdatetimeaxisx.cpp \ |
|
84 | 90 | $$PWD/datetimeaxis/chartdatetimeaxisy.cpp \ |
|
85 | 91 | $$PWD/datetimeaxis/qdatetimeaxis.cpp \ |
|
86 | 92 | $$PWD/datetimeaxis/polarchartdatetimeaxisangular.cpp \ |
|
87 | 93 | $$PWD/datetimeaxis/polarchartdatetimeaxisradial.cpp |
|
88 | 94 | |
|
89 | 95 | PRIVATE_HEADERS += \ |
|
90 | 96 | $$PWD/datetimeaxis/chartdatetimeaxisx_p.h \ |
|
91 | 97 | $$PWD/datetimeaxis/chartdatetimeaxisy_p.h \ |
|
92 | 98 | $$PWD/datetimeaxis/qdatetimeaxis_p.h \ |
|
93 | 99 | $$PWD/datetimeaxis/polarchartdatetimeaxisangular_p.h \ |
|
94 | 100 | $$PWD/datetimeaxis/polarchartdatetimeaxisradial_p.h |
|
95 | 101 | |
|
96 | 102 | PUBLIC_HEADERS += \ |
|
97 | 103 | $$PWD/datetimeaxis/qdatetimeaxis.h |
|
98 | 104 | } |
|
99 | 105 |
@@ -1,90 +1,91 | |||
|
1 | 1 | ############################# BUILD CONFIG ###################################### |
|
2 | 2 | |
|
3 | 3 | TARGET = QtCharts |
|
4 | 4 | |
|
5 | 5 | QT = core gui widgets |
|
6 | 6 | contains(QT_COORD_TYPE, float): DEFINES += QT_QREAL_IS_FLOAT |
|
7 | 7 | |
|
8 | 8 | QMAKE_DOCS = $$PWD/doc/qtcharts.qdocconf |
|
9 | 9 | |
|
10 | 10 | QMAKE_TARGET_PRODUCT = "Qt Charts (Qt $$QT_VERSION)" |
|
11 | 11 | QMAKE_TARGET_DESCRIPTION = "Charts component for Qt." |
|
12 | 12 | |
|
13 | 13 | ############################# SOURCES ########################################## |
|
14 | 14 | |
|
15 | 15 | SOURCES += \ |
|
16 | 16 | $$PWD/chartdataset.cpp \ |
|
17 | 17 | $$PWD/chartpresenter.cpp \ |
|
18 | 18 | $$PWD/chartthememanager.cpp \ |
|
19 | 19 | $$PWD/qchart.cpp \ |
|
20 | 20 | $$PWD/qchartview.cpp \ |
|
21 | 21 | $$PWD/qabstractseries.cpp \ |
|
22 | 22 | $$PWD/chartbackground.cpp \ |
|
23 | 23 | $$PWD/chartelement.cpp \ |
|
24 | 24 | $$PWD/chartitem.cpp \ |
|
25 | 25 | $$PWD/scroller.cpp \ |
|
26 | 26 | $$PWD/charttitle.cpp \ |
|
27 | 27 | $$PWD/qpolarchart.cpp |
|
28 | 28 | |
|
29 | 29 | contains(QT_CONFIG, opengl): SOURCES += $$PWD/glwidget.cpp |
|
30 | 30 | |
|
31 | 31 | PRIVATE_HEADERS += \ |
|
32 | 32 | $$PWD/chartdataset_p.h \ |
|
33 | 33 | $$PWD/chartitem_p.h \ |
|
34 | 34 | $$PWD/chartpresenter_p.h \ |
|
35 | 35 | $$PWD/chartthememanager_p.h \ |
|
36 | 36 | $$PWD/chartbackground_p.h \ |
|
37 | 37 | $$PWD/chartelement_p.h \ |
|
38 | 38 | $$PWD/chartconfig_p.h \ |
|
39 | 39 | $$PWD/qchart_p.h \ |
|
40 | 40 | $$PWD/qchartview_p.h \ |
|
41 | 41 | $$PWD/scroller_p.h \ |
|
42 | 42 | $$PWD/qabstractseries_p.h \ |
|
43 | 43 | $$PWD/charttitle_p.h \ |
|
44 | 44 | $$PWD/charthelpers_p.h |
|
45 | 45 | |
|
46 | 46 | contains(QT_CONFIG, opengl): PRIVATE_HEADERS += $$PWD/glwidget_p.h |
|
47 | 47 | |
|
48 | 48 | PUBLIC_HEADERS += \ |
|
49 | 49 | $$PWD/qchart.h \ |
|
50 | 50 | $$PWD/qchartglobal.h \ |
|
51 | 51 | $$PWD/qabstractseries.h \ |
|
52 | 52 | $$PWD/qchartview.h \ |
|
53 | 53 | $$PWD/chartsnamespace.h \ |
|
54 | 54 | $$PWD/qpolarchart.h |
|
55 | 55 | |
|
56 | 56 | include($$PWD/animations/animations.pri) |
|
57 | 57 | include($$PWD/areachart/areachart.pri) |
|
58 | 58 | include($$PWD/axis/axis.pri) |
|
59 | 59 | include($$PWD/domain/domain.pri) |
|
60 | 60 | include($$PWD/barchart/barchart.pri) |
|
61 | 61 | include($$PWD/legend/legend.pri) |
|
62 | 62 | include($$PWD/linechart/linechart.pri) |
|
63 | 63 | include($$PWD/piechart/piechart.pri) |
|
64 | 64 | include($$PWD/scatterchart/scatter.pri) |
|
65 | 65 | include($$PWD/splinechart/splinechart.pri) |
|
66 | 66 | include($$PWD/themes/themes.pri) |
|
67 | 67 | include($$PWD/xychart/xychart.pri) |
|
68 | 68 | include($$PWD/layout/layout.pri) |
|
69 | 69 | include($$PWD/boxplotchart/boxplotchart.pri) |
|
70 | include($$PWD/colormapchart/colormapchart.pri) | |
|
70 | 71 | |
|
71 | 72 | HEADERS += $$PUBLIC_HEADERS |
|
72 | 73 | HEADERS += $$PRIVATE_HEADERS |
|
73 | 74 | HEADERS += $$THEMES |
|
74 | 75 | |
|
75 | 76 | OTHER_FILES += doc/qtcharts.qdocconf \ |
|
76 | 77 | doc/src/* \ |
|
77 | 78 | doc/images/* |
|
78 | 79 | |
|
79 | 80 | msvc { |
|
80 | 81 | # Suppress "conversion from 'size_t' to 'int', possible loss of data" warnings in 64bit |
|
81 | 82 | # builds resulting from usage of str::sort |
|
82 | 83 | QMAKE_CXXFLAGS_WARN_ON += -wd4267 |
|
83 | 84 | } |
|
84 | 85 | |
|
85 | 86 | win32:!winrt:!wince { |
|
86 | 87 | # ChartThemeSystem uses Windows native API |
|
87 | 88 | LIBS += -luser32 |
|
88 | 89 | } |
|
89 | 90 | |
|
90 | 91 | load(qt_module) |
@@ -1,35 +1,38 | |||
|
1 | 1 | INCLUDEPATH += $$PWD |
|
2 | 2 | |
|
3 | 3 | SOURCES += \ |
|
4 | 4 | $$PWD/qlegend.cpp \ |
|
5 | 5 | $$PWD/legendlayout.cpp \ |
|
6 | 6 | $$PWD/qlegendmarker.cpp \ |
|
7 | 7 | $$PWD/qpielegendmarker.cpp \ |
|
8 | 8 | $$PWD/legendmarkeritem.cpp \ |
|
9 | 9 | $$PWD/qbarlegendmarker.cpp \ |
|
10 | 10 | $$PWD/qxylegendmarker.cpp \ |
|
11 | 11 | $$PWD/qarealegendmarker.cpp \ |
|
12 | 12 | $$PWD/legendscroller.cpp \ |
|
13 | $$PWD/qboxplotlegendmarker.cpp | |
|
13 | $$PWD/qboxplotlegendmarker.cpp \ | |
|
14 | $$PWD/qcolormaplegendmarker.cpp | |
|
14 | 15 | |
|
15 | 16 | PRIVATE_HEADERS += \ |
|
16 | 17 | $$PWD/legendscroller_p.h \ |
|
17 | 18 | $$PWD/qlegend_p.h \ |
|
18 | 19 | $$PWD/legendlayout_p.h \ |
|
19 | 20 | $$PWD/qlegendmarker_p.h \ |
|
20 | 21 | $$PWD/legendmarkeritem_p.h \ |
|
21 | 22 | $$PWD/qpielegendmarker_p.h \ |
|
22 | 23 | $$PWD/qbarlegendmarker_p.h \ |
|
23 | 24 | $$PWD/qxylegendmarker_p.h \ |
|
24 | 25 | $$PWD/qarealegendmarker_p.h \ |
|
25 | $$PWD/qboxplotlegendmarker_p.h | |
|
26 | $$PWD/qboxplotlegendmarker_p.h \ | |
|
27 | $$PWD/qcolormaplegendmarker_p.h | |
|
26 | 28 | |
|
27 | 29 | |
|
28 | 30 | PUBLIC_HEADERS += \ |
|
29 | 31 | $$PWD/qlegend.h \ |
|
30 | 32 | $$PWD/qlegendmarker.h \ |
|
31 | 33 | $$PWD/qpielegendmarker.h \ |
|
32 | 34 | $$PWD/qbarlegendmarker.h \ |
|
33 | 35 | $$PWD/qxylegendmarker.h \ |
|
34 | 36 | $$PWD/qarealegendmarker.h \ |
|
35 | $$PWD/qboxplotlegendmarker.h | |
|
37 | $$PWD/qboxplotlegendmarker.h \ | |
|
38 | $$PWD/qcolormaplegendmarker.h |
@@ -1,116 +1,117 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
4 | 4 | ** Contact: https://www.qt.io/licensing/ |
|
5 | 5 | ** |
|
6 | 6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
7 | 7 | ** |
|
8 | 8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
9 | 9 | ** Commercial License Usage |
|
10 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
11 | 11 | ** accordance with the 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 The Qt Company. For licensing terms |
|
14 | 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
|
15 | 15 | ** information use the contact form at https://www.qt.io/contact-us. |
|
16 | 16 | ** |
|
17 | 17 | ** GNU General Public License Usage |
|
18 | 18 | ** Alternatively, this file may be used under the terms of the GNU |
|
19 | 19 | ** General Public License version 3 or (at your option) any later version |
|
20 | 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
|
21 | 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
|
22 | 22 | ** included in the packaging of this file. Please review the following |
|
23 | 23 | ** information to ensure the GNU General Public License requirements will |
|
24 | 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
25 | 25 | ** |
|
26 | 26 | ** $QT_END_LICENSE$ |
|
27 | 27 | ** |
|
28 | 28 | ****************************************************************************/ |
|
29 | 29 | |
|
30 | 30 | #ifndef QLEGENDMARKER_H |
|
31 | 31 | #define QLEGENDMARKER_H |
|
32 | 32 | |
|
33 | 33 | #include <QtCharts/QChartGlobal> |
|
34 | 34 | #include <QtCore/QObject> |
|
35 | 35 | #include <QtGui/QPen> |
|
36 | 36 | #include <QtGui/QBrush> |
|
37 | 37 | #include <QtGui/QFont> |
|
38 | 38 | |
|
39 | 39 | QT_CHARTS_BEGIN_NAMESPACE |
|
40 | 40 | |
|
41 | 41 | class QLegendMarkerPrivate; |
|
42 | 42 | class QAbstractSeries; |
|
43 | 43 | class QLegend; |
|
44 | 44 | |
|
45 | 45 | class QT_CHARTS_EXPORT QLegendMarker : public QObject |
|
46 | 46 | { |
|
47 | 47 | Q_OBJECT |
|
48 | 48 | |
|
49 | 49 | public: |
|
50 | 50 | enum LegendMarkerType { |
|
51 | 51 | LegendMarkerTypeArea, |
|
52 | 52 | LegendMarkerTypeBar, |
|
53 | 53 | LegendMarkerTypePie, |
|
54 | 54 | LegendMarkerTypeXY, |
|
55 | LegendMarkerTypeBoxPlot | |
|
55 | LegendMarkerTypeBoxPlot, | |
|
56 | LegendMarkerTypeColorMap | |
|
56 | 57 | }; |
|
57 | 58 | |
|
58 | 59 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
|
59 | 60 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
|
60 | 61 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
|
61 | 62 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
|
62 | 63 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
|
63 | 64 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
64 | 65 | Q_ENUMS(LegendMarkerType) |
|
65 | 66 | |
|
66 | 67 | public: |
|
67 | 68 | virtual ~QLegendMarker(); |
|
68 | 69 | virtual LegendMarkerType type() = 0; |
|
69 | 70 | |
|
70 | 71 | QString label() const; |
|
71 | 72 | void setLabel(const QString &label); |
|
72 | 73 | |
|
73 | 74 | QBrush labelBrush() const; |
|
74 | 75 | void setLabelBrush(const QBrush &brush); |
|
75 | 76 | |
|
76 | 77 | QFont font() const; |
|
77 | 78 | void setFont(const QFont &font); |
|
78 | 79 | |
|
79 | 80 | QPen pen() const; |
|
80 | 81 | void setPen(const QPen &pen); |
|
81 | 82 | |
|
82 | 83 | QBrush brush() const; |
|
83 | 84 | void setBrush(const QBrush &brush); |
|
84 | 85 | |
|
85 | 86 | bool isVisible() const; |
|
86 | 87 | void setVisible(bool visible); |
|
87 | 88 | |
|
88 | 89 | virtual QAbstractSeries* series() = 0; |
|
89 | 90 | |
|
90 | 91 | Q_SIGNALS: |
|
91 | 92 | void clicked(); |
|
92 | 93 | void hovered(bool status); |
|
93 | 94 | void labelChanged(); |
|
94 | 95 | void labelBrushChanged(); |
|
95 | 96 | void fontChanged(); |
|
96 | 97 | void penChanged(); |
|
97 | 98 | void brushChanged(); |
|
98 | 99 | void visibleChanged(); |
|
99 | 100 | |
|
100 | 101 | protected: |
|
101 | 102 | explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = Q_NULLPTR); |
|
102 | 103 | |
|
103 | 104 | QScopedPointer<QLegendMarkerPrivate> d_ptr; |
|
104 | 105 | friend class QLegendPrivate; |
|
105 | 106 | friend class QLegendMarkerPrivate; |
|
106 | 107 | friend class LegendMarkerItem; |
|
107 | 108 | friend class LegendLayout; |
|
108 | 109 | friend class LegendScroller; |
|
109 | 110 | |
|
110 | 111 | private: |
|
111 | 112 | Q_DISABLE_COPY(QLegendMarker) |
|
112 | 113 | }; |
|
113 | 114 | |
|
114 | 115 | QT_CHARTS_END_NAMESPACE |
|
115 | 116 | |
|
116 | 117 | #endif // QLEGENDMARKER_H |
@@ -1,112 +1,113 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
|
4 | 4 | ** Contact: https://www.qt.io/licensing/ |
|
5 | 5 | ** |
|
6 | 6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
|
7 | 7 | ** |
|
8 | 8 | ** $QT_BEGIN_LICENSE:GPL$ |
|
9 | 9 | ** Commercial License Usage |
|
10 | 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
|
11 | 11 | ** accordance with the 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 The Qt Company. For licensing terms |
|
14 | 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
|
15 | 15 | ** information use the contact form at https://www.qt.io/contact-us. |
|
16 | 16 | ** |
|
17 | 17 | ** GNU General Public License Usage |
|
18 | 18 | ** Alternatively, this file may be used under the terms of the GNU |
|
19 | 19 | ** General Public License version 3 or (at your option) any later version |
|
20 | 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
|
21 | 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
|
22 | 22 | ** included in the packaging of this file. Please review the following |
|
23 | 23 | ** information to ensure the GNU General Public License requirements will |
|
24 | 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
|
25 | 25 | ** |
|
26 | 26 | ** $QT_END_LICENSE$ |
|
27 | 27 | ** |
|
28 | 28 | ****************************************************************************/ |
|
29 | 29 | |
|
30 | 30 | #ifndef QABSTRACTSERIES_H |
|
31 | 31 | #define QABSTRACTSERIES_H |
|
32 | 32 | |
|
33 | 33 | #include <QtCharts/QChartGlobal> |
|
34 | 34 | #include <QtCharts/QAbstractAxis> |
|
35 | 35 | #include <QtCore/QObject> |
|
36 | 36 | #include <QtGui/QPen> |
|
37 | 37 | |
|
38 | 38 | QT_CHARTS_BEGIN_NAMESPACE |
|
39 | 39 | |
|
40 | 40 | class QAbstractSeriesPrivate; |
|
41 | 41 | class QChart; |
|
42 | 42 | |
|
43 | 43 | class QT_CHARTS_EXPORT QAbstractSeries : public QObject |
|
44 | 44 | { |
|
45 | 45 | Q_OBJECT |
|
46 | 46 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) |
|
47 | 47 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
48 | 48 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) |
|
49 | 49 | Q_PROPERTY(SeriesType type READ type) |
|
50 | 50 | Q_PROPERTY(bool useOpenGL READ useOpenGL WRITE setUseOpenGL NOTIFY useOpenGLChanged) |
|
51 | 51 | Q_ENUMS(SeriesType) |
|
52 | 52 | |
|
53 | 53 | public: |
|
54 | 54 | enum SeriesType { |
|
55 | 55 | SeriesTypeLine, |
|
56 | 56 | SeriesTypeArea, |
|
57 | 57 | SeriesTypeBar, |
|
58 | 58 | SeriesTypeStackedBar, |
|
59 | 59 | SeriesTypePercentBar, |
|
60 | 60 | SeriesTypePie, |
|
61 | 61 | SeriesTypeScatter, |
|
62 | 62 | SeriesTypeSpline, |
|
63 | 63 | SeriesTypeHorizontalBar, |
|
64 | 64 | SeriesTypeHorizontalStackedBar, |
|
65 | 65 | SeriesTypeHorizontalPercentBar, |
|
66 | SeriesTypeBoxPlot | |
|
66 | SeriesTypeBoxPlot, | |
|
67 | SeriesTypeColorMap | |
|
67 | 68 | }; |
|
68 | 69 | |
|
69 | 70 | protected: |
|
70 | 71 | QAbstractSeries(QAbstractSeriesPrivate &d, QObject *parent = Q_NULLPTR); |
|
71 | 72 | |
|
72 | 73 | public: |
|
73 | 74 | ~QAbstractSeries(); |
|
74 | 75 | virtual SeriesType type() const = 0; |
|
75 | 76 | |
|
76 | 77 | void setName(const QString &name); |
|
77 | 78 | QString name() const; |
|
78 | 79 | void setVisible(bool visible = true); |
|
79 | 80 | bool isVisible() const; |
|
80 | 81 | qreal opacity() const; |
|
81 | 82 | void setOpacity(qreal opacity); |
|
82 | 83 | void setUseOpenGL(bool enable = true); |
|
83 | 84 | bool useOpenGL() const; |
|
84 | 85 | |
|
85 | 86 | QChart *chart() const; |
|
86 | 87 | |
|
87 | 88 | bool attachAxis(QAbstractAxis *axis); |
|
88 | 89 | bool detachAxis(QAbstractAxis *axis); |
|
89 | 90 | QList<QAbstractAxis*> attachedAxes(); |
|
90 | 91 | |
|
91 | 92 | void show(); |
|
92 | 93 | void hide(); |
|
93 | 94 | |
|
94 | 95 | Q_SIGNALS: |
|
95 | 96 | void nameChanged(); |
|
96 | 97 | void visibleChanged(); |
|
97 | 98 | void opacityChanged(); |
|
98 | 99 | void useOpenGLChanged(); |
|
99 | 100 | |
|
100 | 101 | protected: |
|
101 | 102 | QScopedPointer<QAbstractSeriesPrivate> d_ptr; |
|
102 | 103 | friend class ChartDataSet; |
|
103 | 104 | friend class ChartPresenter; |
|
104 | 105 | friend class ChartThemeManager; |
|
105 | 106 | friend class QLegendPrivate; |
|
106 | 107 | friend class DeclarativeChart; |
|
107 | 108 | friend class QAreaSeries; |
|
108 | 109 | }; |
|
109 | 110 | |
|
110 | 111 | QT_CHARTS_END_NAMESPACE |
|
111 | 112 | |
|
112 | 113 | #endif // QABSTRACTSERIES_H |
General Comments 0
You need to be logged in to leave comments.
Login now