##// END OF EJS Templates
improvements in execution time, colorbar ok, more work to do on axes,
winter -
r3:ab1c9ba54a31 default draft
parent child
Show More
@@ -1,84 +1,86
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 #include <QtWidgets/QApplication>
31 31 #include <QtWidgets/QMainWindow>
32 32 #include <QtCharts/QChartView>
33 33 #include <QtCharts/QColorMapSeries>
34 34 #include <QtCharts/colormapdatapart.h>
35 35
36 36 QT_CHARTS_USE_NAMESPACE
37 37
38 38 int main(int argc, char *argv[])
39 39 {
40 40 QApplication a(argc, argv);
41 41
42 42 QVector<double> *xSeries = new QVector<double>();
43 xSeries->reserve(1028);
43 44 for(int i=0;i<1028;i++)
44 45 {
45 xSeries->append(i*5.0);
46 xSeries->append(i);
46 47 }
47 48 QVector<double> *ySeries = new QVector<double>();
49 ySeries->reserve(768);
48 50 for(int i=0;i<768;i++)
49 51 {
50 ySeries->append(i*10.0);
52 ySeries->append(i);
51 53 }
52 54 QVector<double> *zSeries = new QVector<double>();
55 zSeries->reserve(1028*768);
53 56 for(int i=0;i<1028*768;i++)
54 57 {
55 // if(i%2 != 1)
56 // zSeries->append(0);
57 // else
58 // zSeries->append(1);
58 // if(i%2 != 1)
59 // zSeries->append(0);
60 // else
61 // zSeries->append(1);
59 62 zSeries->append(i);
60 63 }
61 64
62 65 ColorMapDataPart * data = new ColorMapDataPart(xSeries,ySeries,zSeries);
63 66
64 67 QColorMapSeries *series = new QColorMapSeries();
65 68 series->append(data);
66 69
67 70 QChart *chart = new QChart();
68 71 chart->addSeries(series);
69 72 chart->setTitle("Simple colormap example");
70 73 chart->createDefaultAxes();
71 74 chart->axisX()->setGridLineVisible(false);
72 75 chart->axisY()->setGridLineVisible(false);
73 76
74 77 QChartView *chartView = new QChartView(chart);
75 78 chartView->setRenderHint(QPainter::Antialiasing);
76 79
77 80 QMainWindow window;
78 81 window.setCentralWidget(chartView);
79 82 window.resize(100-77, 100-53);
80 83 window.show();
81 84
82
83 85 return a.exec();
84 86 }
@@ -1,144 +1,148
1 1 #include "chartcolorbaraxisy_p.h"
2 2 #include <QtCharts/QAbstractAxis>
3 3 #include <private/chartpresenter_p.h>
4 4 //#include <QtCharts/QColorBarAxis>
5 5 #include "colorbaraxis/qcolorbaraxis.h"
6 6 #include <private/abstractchartlayout_p.h>
7 7 #include <QtWidgets/QGraphicsLayout>
8 8 #include <QtCore/QtMath>
9 9 #include <QtCore/QDebug>
10 10
11 11 QT_CHARTS_BEGIN_NAMESPACE
12 12
13 ChartColorBarAxisY::ChartColorBarAxisY(QColorBarAxis *axis, QLinearGradient gradient, QGraphicsItem *item)
13 ChartColorBarAxisY::ChartColorBarAxisY(QColorBarAxis *axis, QPoint pos, qreal height, QLinearGradient gradient, QGraphicsItem *item)
14 14 : VerticalAxis(axis, item),
15 15 m_axis(axis),
16 m_gradient(gradient)
16 m_gradient(gradient),
17 m_position(pos),
18 m_height(height)
17 19 {
18 20 QObject::connect(m_axis, SIGNAL(tickCountChanged(int)), this, SLOT(handleTickCountChanged(int)));
19 21 QObject::connect(m_axis, SIGNAL(minorTickCountChanged(int)),
20 22 this, SLOT(handleMinorTickCountChanged(int)));
21 23 QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString)));
22 24
23 25 createColorBar();
24 26 }
25 27
26 28 ChartColorBarAxisY::~ChartColorBarAxisY()
27 29 {
28 30 }
29 31
30 32 QVector<qreal> ChartColorBarAxisY::calculateLayout() const
31 33 {
32 34 int tickCount = m_axis->tickCount();
33 35
34 36 Q_ASSERT(tickCount >= 2);
35 37
36 38 QVector<qreal> points;
37 39 points.resize(tickCount);
38 40
39 41 const QRectF &gridRect = gridGeometry();
40 42
41 43 const qreal deltaY = gridRect.height() / (qreal(tickCount) - 1.0);
42 44 for (int i = 0; i < tickCount; ++i)
43 45 points[i] = qreal(i) * -deltaY + gridRect.bottom();
44 46
45 47 return points;
46 48 }
47 49
48 50 void ChartColorBarAxisY::updateGeometry()
49 51 {
50 52 const QVector<qreal> &layout = ChartAxisElement::layout();
51 53 if (layout.isEmpty())
52 54 return;
53 55 setLabels(createValueLabels(min(),max(),layout.size(),m_axis->labelFormat()));
54 56 VerticalAxis::updateGeometry();
55 57 }
56 58
57 59 void ChartColorBarAxisY::handleTickCountChanged(int tick)
58 60 {
59 61 Q_UNUSED(tick);
60 62 QGraphicsLayoutItem::updateGeometry();
61 63 if (presenter()) presenter()->layout()->invalidate();
62 64 }
63 65
64 66 void ChartColorBarAxisY::handleMinorTickCountChanged(int tick)
65 67 {
66 68 Q_UNUSED(tick);
67 69 QGraphicsLayoutItem::updateGeometry();
68 70 if (presenter())
69 71 presenter()->layout()->invalidate();
70 72 }
71 73
72 74 void ChartColorBarAxisY::handleLabelFormatChanged(const QString &format)
73 75 {
74 76 Q_UNUSED(format);
75 77 QGraphicsLayoutItem::updateGeometry();
76 78 if(presenter()) presenter()->layout()->invalidate();
77 79 }
78 80
79 81 QSizeF ChartColorBarAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
80 82 {
81 83 Q_UNUSED(constraint)
82 84
83 85 QSizeF sh;
84 86 QSizeF base = VerticalAxis::sizeHint(which, constraint);
85 87 QStringList ticksList = createValueLabels(min(),max(),m_axis->tickCount(),m_axis->labelFormat());
86 88 qreal width = 0;
87 89 // Height of vertical axis sizeHint indicates the maximum distance labels can extend past
88 90 // first and last ticks. Base height is irrelevant.
89 91 qreal height = 0;
90 92
91 93 switch (which)
92 94 {
93 95 case Qt::MinimumSize: {
94 96 QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(),
95 97 QStringLiteral("..."),
96 98 axis()->labelsAngle());
97 width = boundingRect.width() + labelPadding() + base.width() + 1.0;
99 width = boundingRect.width() + labelPadding() + base.width() + 61.0; //TODO : hint changed 1.0 to 61.0
98 100 height = boundingRect.height() / 2.0;
99 101 sh = QSizeF(width, height);
100 102 break;
101 103 }
102 104 case Qt::PreferredSize: {
103 105 qreal labelWidth = 0.0;
104 106 qreal firstHeight = -1.0;
105 107 foreach (const QString& s, ticksList) {
106 108 QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle());
107 109 labelWidth = qMax(rect.width(), labelWidth);
108 110 height = rect.height();
109 111 if (firstHeight < 0.0)
110 112 firstHeight = height;
111 113 }
112 width = labelWidth + labelPadding() + base.width() + 2.0; //two pixels of tolerance
114 width = labelWidth + labelPadding() + base.width() + 62.0; //two pixels of tolerance //TODO : hint changed 2.0 to 62.0
113 115 height = qMax(height, firstHeight) / 2.0;
114 116 sh = QSizeF(width, height);
115 117 break;
116 118 }
117 119 default:
118 120 break;
119 121 }
120 122 return sh;
121 123 }
122 124
123 125 void ChartColorBarAxisY::createColorBar()
124 126 {
125 QGradientStops stops = m_gradient.stops();
127 //m_position.setX(80+m_position.x());// TODO : remove this when you know how to move labels
126 128
127 QLinearGradient gradient(0,0,1,250);
129 //gradient
130 QGradientStops stops = m_gradient.stops();
131 QLinearGradient gradient(0,0,1,m_height);
128 132 foreach(QGradientStop stop, stops)
129 133 {
130 134 gradient.setColorAt(1-stop.first,stop.second);
131 135 }
132 136
133 QPixmap image = QPixmap(50,250);
134 QPainter painter(&image);
135 QRectF rect(0,0,50,250);
136 painter.fillRect(rect,gradient);
137 //colorbar
138 QRectF rect(m_position.x(),m_position.y(),m_height/20,m_height);
137 139
138 140 QGraphicsRectItem *colorbar = new QGraphicsRectItem(rect, this);
141 colorbar->setZValue(ChartPresenter::AxisZValue);
142 colorbar->setBrush(gradient);
139 143 setGraphicsItem(colorbar);
140 144 }
141 145
142 146 #include "moc_chartcolorbaraxisy_p.cpp"
143 147
144 QT_CHARTS_END_NAMESPACE
148 QT_CHARTS_END_NAMESPACE
@@ -1,39 +1,41
1 1 #ifndef CHARTCOLORBARAXISY_H
2 2 #define CHARTCOLORBARAXISY_H
3 3
4 4 #include <private/verticalaxis_p.h>
5 5 #include <QtGui>
6 6
7 7 QT_CHARTS_BEGIN_NAMESPACE
8 8
9 9 class QColorBarAxis;
10 10
11 11 class ChartColorBarAxisY : public VerticalAxis
12 12 {
13 13 Q_OBJECT
14 14 public:
15 ChartColorBarAxisY(QColorBarAxis *axis, QLinearGradient gradient, QGraphicsItem *item = 0);
15 ChartColorBarAxisY(QColorBarAxis *axis, QPoint pos, qreal height, QLinearGradient gradient, QGraphicsItem *item = 0);
16 16 ~ChartColorBarAxisY();
17 17
18 18 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
19 19
20 20
21 21
22 22 protected:
23 23 QVector<qreal> calculateLayout() const;
24 24 void updateGeometry();
25 25 private Q_SLOTS:
26 26 void handleTickCountChanged(int tick);
27 27 void handleMinorTickCountChanged(int tick);
28 28 void handleLabelFormatChanged(const QString &format);
29 29 void createColorBar();
30 30
31 31
32 32 private:
33 33 QColorBarAxis *m_axis;
34 34 QLinearGradient m_gradient;
35 QPoint m_position;
36 qreal m_height;
35 37 };
36 38
37 39 QT_CHARTS_END_NAMESPACE
38 40
39 41 #endif // CHARTCOLORBARAXISY_H
@@ -1,247 +1,255
1 1 //#include <QtCharts/QColorBarAxis> // TODO : fix this
2 2 #include "colorbaraxis/qcolorbaraxis.h"
3 3 //#include <private/qcolorbaraxis_p.h>
4 4 #include "colorbaraxis/qcolorbaraxis_p.h"
5 5 #include <private/abstractdomain_p.h>
6 6 #include <private/chartdataset_p.h>
7 7 #include <private/chartpresenter_p.h>
8 8 #include <private/charttheme_p.h>
9 9
10 10 //#include <private/chartcolorbaraxisy_p.h>
11 11 #include <chartcolorbaraxisy_p.h>
12 12
13 13 #include <QtGui>
14 14
15 15 QT_CHARTS_BEGIN_NAMESPACE
16 16
17 17
18 18 /*!
19 19 Constructs an axis object which is a child of \a parent.
20 20 */
21 QColorBarAxis::QColorBarAxis(QLinearGradient gradient, qreal min, qreal max,QObject *parent) :
22 QAbstractAxis(*new QColorBarAxisPrivate(gradient, min, max, this), parent)
21 QColorBarAxis::QColorBarAxis(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max, QObject *parent) :
22 QAbstractAxis(*new QColorBarAxisPrivate(plotArea, gradient, min, max, this), parent)
23 23 {
24
24 setGridLineVisible(false);
25 25 }
26 26
27 27 /*!
28 28 \internal
29 29 */
30 30 QColorBarAxis::QColorBarAxis(QColorBarAxisPrivate &d, QObject *parent)
31 31 : QAbstractAxis(d, parent)
32 32 {
33 33
34 34 }
35 35
36 36 /*!
37 37 Destroys the object
38 38 */
39 39 QColorBarAxis::~QColorBarAxis()
40 40 {
41 41 Q_D(QColorBarAxis);
42 42 if (d->m_chart)
43 43 d->m_chart->removeAxis(this);
44 44 }
45 45
46 46 void QColorBarAxis::setMin(qreal min)
47 47 {
48 48 Q_D(QColorBarAxis);
49 49 setRange(min, qMax(d->m_max, min));
50 50 }
51 51
52 52 qreal QColorBarAxis::min() const
53 53 {
54 54 Q_D(const QColorBarAxis);
55 55 return d->m_min;
56 56 }
57 57
58 58 void QColorBarAxis::setMax(qreal max)
59 59 {
60 60 Q_D(QColorBarAxis);
61 61 setRange(qMin(d->m_min, max), max);
62 62 }
63 63
64 64 qreal QColorBarAxis::max() const
65 65 {
66 66 Q_D(const QColorBarAxis);
67 67 return d->m_max;
68 68 }
69 69
70 70 void QColorBarAxis::setRange(qreal min, qreal max)
71 71 {
72 72 Q_D(QColorBarAxis);
73 73 d->setRange(min,max);
74 74 }
75 75
76 76
77 77 void QColorBarAxis::setTickCount(int count)
78 78 {
79 79 Q_D(QColorBarAxis);
80 80 if (d->m_tickCount != count && count >= 2) {
81 81 d->m_tickCount = count;
82 82 emit tickCountChanged(count);
83 83 }
84 84 }
85 85
86 86 int QColorBarAxis::tickCount() const
87 87 {
88 88 Q_D(const QColorBarAxis);
89 89 return d->m_tickCount;
90 90 }
91 91
92 92 void QColorBarAxis::setMinorTickCount(int count)
93 93 {
94 94 Q_D(QColorBarAxis);
95 95 if (d->m_minorTickCount != count && count >= 0) {
96 96 d->m_minorTickCount = count;
97 97 emit minorTickCountChanged(count);
98 98 }
99 99 }
100 100
101 101 int QColorBarAxis::minorTickCount() const
102 102 {
103 103 Q_D(const QColorBarAxis);
104 104 return d->m_minorTickCount;
105 105 }
106 106
107 107 void QColorBarAxis::setLabelFormat(const QString &format)
108 108 {
109 109 Q_D(QColorBarAxis);
110 110 d->m_format = format;
111 111 emit labelFormatChanged(format);
112 112 }
113 113
114 114 QString QColorBarAxis::labelFormat() const
115 115 {
116 116 Q_D(const QColorBarAxis);
117 117 return d->m_format;
118 118 }
119 119
120 120 /*!
121 121 Returns the type of the axis
122 122 */
123 123 QAbstractAxis::AxisType QColorBarAxis::type() const
124 124 {
125 125 return AxisTypeValue;
126 126 //TODO : AxisTypeColorBar
127 127 }
128 128
129 129
130 130
131 131 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
132 132
133 QColorBarAxisPrivate::QColorBarAxisPrivate(QLinearGradient gradient, qreal min, qreal max, QColorBarAxis *q)
133 QColorBarAxisPrivate::QColorBarAxisPrivate(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max, QColorBarAxis *q)
134 134 : QAbstractAxisPrivate(q),
135 m_plotArea(plotArea),
135 136 m_min(min),
136 137 m_max(max),
137 m_tickCount(5),
138 m_minorTickCount(0),
138 m_tickCount(5),
139 m_minorTickCount(0),
139 140 m_format(QString::null),
140 // m_applying(false)
141 // m_applying(false)
141 142 m_gradient(gradient)
142 143 {
143 144
144 145 }
145 146
146 147 QColorBarAxisPrivate::~QColorBarAxisPrivate()
147 148 {
148 149
149 150 }
150 151
151 152 void QColorBarAxisPrivate::initializeGraphics(QGraphicsItem *parent)
152 153 {
153 154 Q_Q(QColorBarAxis);
154 155 ChartAxisElement *axis(0);
155 156
156 157 setAlignment(Qt::AlignRight); //also set orientation (Vertical in this case)
157 158
158 axis = new ChartColorBarAxisY(q, m_gradient, parent);
159 //TODO : change this position
160 qreal x1;
161 qreal y1;
162 qreal x2;
163 qreal y2;
164 m_plotArea.getCoords(&x1,&y1,&x2,&y2);
165 QPoint pos(x2+5,y1);
166 axis = new ChartColorBarAxisY(q, pos, m_plotArea.height(),m_gradient, parent);
159 167
160 168 m_item.reset(axis);
161 169 QAbstractAxisPrivate::initializeGraphics(parent);
162 170 }
163 171
164 172 void QColorBarAxisPrivate::initializeDomain(AbstractDomain *domain)
165 173 {
166 174 //domain is not supposed to have a rangeZ
167 175
168 // if (orientation() == Qt::Vertical) {
169 // if (!qFuzzyIsNull(m_max - m_min))
170 // domain->setRangeY(m_min, m_max);
171 // else
172 // setRange(domain->minY(), domain->maxY());
173 // }
176 // if (orientation() == Qt::Vertical) {
177 // if (!qFuzzyIsNull(m_max - m_min))
178 // domain->setRangeY(m_min, m_max);
179 // else
180 // setRange(domain->minY(), domain->maxY());
181 // }
174 182 }
175 183
176 184 void QColorBarAxisPrivate::setMin(const QVariant &min)
177 185 {
178 186 Q_Q(QColorBarAxis);
179 187 bool ok;
180 188 qreal value = min.toReal(&ok);
181 189 if (ok)
182 190 q->setMin(value);
183 191 }
184 192
185 193 void QColorBarAxisPrivate::setMax(const QVariant &max)
186 194 {
187 195 Q_Q(QColorBarAxis);
188 196 bool ok;
189 197 qreal value = max.toReal(&ok);
190 198 if (ok)
191 199 q->setMax(value);
192 200 }
193 201
194 202 void QColorBarAxisPrivate::setRange(const QVariant &min, const QVariant &max)
195 203 {
196 204 Q_Q(QColorBarAxis);
197 205 bool ok1;
198 206 bool ok2;
199 207 qreal value1 = min.toReal(&ok1);
200 208 qreal value2 = max.toReal(&ok2);
201 209 if (ok1 && ok2)
202 210 q->setRange(value1, value2);
203 211 }
204 212
205 213 void QColorBarAxisPrivate::setRange(qreal min,qreal max)
206 214 {
207 215 Q_Q(QColorBarAxis);
208 216 bool changed = false;
209 217
210 218 if (min > max)
211 219 return;
212 220
213 221 bool changeMin = false;
214 222 if (m_min == 0 || min == 0)
215 223 changeMin = !qFuzzyCompare(1 + m_min, 1 + min);
216 224 else
217 225 changeMin = !qFuzzyCompare(m_min, min);
218 226
219 227 bool changeMax = false;
220 228 if (m_max == 0 || max == 0)
221 229 changeMax = !qFuzzyCompare(1 + m_max, 1 + max);
222 230 else
223 231 changeMax = !qFuzzyCompare(m_max, max);
224 232
225 233 if (changeMin) {
226 234 m_min = min;
227 235 changed = true;
228 236 emit q->minChanged(min);
229 237 }
230 238
231 239 if (changeMax) {
232 240 m_max = max;
233 241 changed = true;
234 242 emit q->maxChanged(max);
235 243 }
236 244
237 245 if (changed) {
238 246 emit rangeChanged(min,max);
239 247 emit q->rangeChanged(min, max);
240 248 }
241 249 }
242 250
243 251
244 252 #include "moc_qcolorbaraxis.cpp"
245 253 #include "moc_qcolorbaraxis_p.cpp"
246 254
247 255 QT_CHARTS_END_NAMESPACE
@@ -1,54 +1,54
1 1 #ifndef QCOLORBARAXIS_H
2 2 #define QCOLORBARAXIS_H
3 3
4 4 #include <QtCharts/QAbstractAxis>
5 5
6 6 QT_CHARTS_BEGIN_NAMESPACE
7 7
8 8 class QColorBarAxisPrivate;
9 9
10 10 class QT_CHARTS_EXPORT QColorBarAxis : public QAbstractAxis
11 11 {
12 12 Q_OBJECT
13 13 public:
14 explicit QColorBarAxis(QLinearGradient gradient, qreal min, qreal max,QObject *parent = 0);
14 explicit QColorBarAxis(QRectF plotArea,QLinearGradient gradient, qreal min, qreal max,QObject *parent = 0);
15 15 ~QColorBarAxis();
16 16
17 17 protected:
18 18 QColorBarAxis(QColorBarAxisPrivate &d, QObject *parent = 0);
19 19
20 20 public:
21 21 AxisType type() const;
22 22
23 23 //range handling
24 24 void setMin(qreal min);
25 25 qreal min() const;
26 26 void setMax(qreal max);
27 27 qreal max() const;
28 28 void setRange(qreal min, qreal max);
29 29
30 30 //ticks handling
31 31 void setTickCount(int count);
32 32 int tickCount() const;
33 33 void setMinorTickCount(int count);
34 34 int minorTickCount() const;
35 35
36 36 void setLabelFormat(const QString &format);
37 37 QString labelFormat() const;
38 38
39 39 Q_SIGNALS:
40 40 void minChanged(qreal min);
41 41 void maxChanged(qreal max);
42 42 void rangeChanged(qreal min, qreal max);
43 43 void tickCountChanged(int tickCount);
44 44 void minorTickCountChanged(int tickCount);
45 45 void labelFormatChanged(const QString &format);
46 46
47 47 private:
48 48 Q_DECLARE_PRIVATE(QColorBarAxis)
49 49 Q_DISABLE_COPY(QColorBarAxis)
50 50 };
51 51
52 52 QT_CHARTS_END_NAMESPACE
53 53
54 54 #endif // QCOLORBARAXIS_H
@@ -1,43 +1,44
1 1 #ifndef QCOLORBARAXIS_P_H
2 2 #define QCOLORBARAXIS_P_H
3 3
4 4 //#include <QtCharts/QColorBarAxis> //TODO : fix this
5 5 #include "colorbaraxis/qcolorbaraxis.h"
6 6 #include <private/qabstractaxis_p.h>
7 7
8 8 QT_CHARTS_BEGIN_NAMESPACE
9 9
10 10 class QColorBarAxisPrivate : public QAbstractAxisPrivate
11 11 {
12 12 Q_OBJECT
13 13 public:
14 QColorBarAxisPrivate(QLinearGradient gradient, qreal min, qreal max,QColorBarAxis *q);
14 QColorBarAxisPrivate(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max,QColorBarAxis *q);
15 15 ~QColorBarAxisPrivate();
16 16
17 17 public:
18 18 void initializeGraphics(QGraphicsItem* parent);
19 19 void initializeDomain(AbstractDomain *domain);
20 20
21 21 qreal min() { return m_min; }
22 22 qreal max() { return m_max; }
23 23 void setRange(qreal min,qreal max);
24 24
25 25 protected:
26 26 void setMin(const QVariant &min);
27 27 void setMax(const QVariant &max);
28 28 void setRange(const QVariant &min, const QVariant &max);
29 29
30 30 private:
31 31 qreal m_min;
32 32 qreal m_max;
33 33 int m_tickCount;
34 34 int m_minorTickCount;
35 35 QString m_format;
36 36 // bool m_applying;
37 37 QLinearGradient m_gradient;
38 QRectF m_plotArea;
38 39 Q_DECLARE_PUBLIC(QColorBarAxis)
39 40 };
40 41
41 42 QT_CHARTS_END_NAMESPACE
42 43
43 44 #endif // QCOLORBARAXIS_P_H
@@ -1,226 +1,244
1 1 #include <private/colormapchart_p.h>
2 2 #include <QtCharts/QColorMapSeries>
3 3 #include <private/qcolormapseries_p.h>
4 4 #include <private/chartpresenter_p.h>
5 5 #include <private/abstractdomain_p.h>
6 6 #include <private/chartdataset_p.h>
7 7 #include <private/qabstractaxis_p.h>
8 8 #include <QtGui/QPainter>
9 9
10 //#include <QtCharts/QColorBarAxis> TODO : fix this
11 #include "qcolorbaraxis.h"
12
13 10 #include <QRgb>
14 11
15 12 #define nbOfColors 65000
16 13
17 14 QT_CHARTS_BEGIN_NAMESPACE
18 15
19 16 ColorMapChart::ColorMapChart(QColorMapSeries *series, QGraphicsItem *item)
20 17 : ChartItem(series->d_func(), item),
21 18 m_series(series),
22 19 m_dirty(true),
23 20 m_gradientType(Rainbow),
24 21 m_colorbar(false)
25 22 {
26 23 // QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int)));
27 24 // QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced()));
28 25 // QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int)));
29 26 // QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int)));
30 27 // QObject::connect(series, SIGNAL(pointsRemoved(int, int)), this, SLOT(handlePointsRemoved(int, int)));
31 28 // QObject::connect(this, SIGNAL(clicked(Point3D)), series, SIGNAL(clicked(Point3D)));
32 29 // QObject::connect(this, SIGNAL(hovered(Point3D,bool)), series, SIGNAL(hovered(Point3D,bool)));
33 30 // QObject::connect(this, SIGNAL(pressed(Point3D)), series, SIGNAL(pressed(Point3D)));
34 31 // QObject::connect(this, SIGNAL(released(Point3D)), series, SIGNAL(released(Point3D)));
35 32 // QObject::connect(this, SIGNAL(doubleClicked(Point3D)), series, SIGNAL(doubleClicked(Point3D)));
36 33
37 34 connect(this,SIGNAL(gradientTypeChanged()), this, SLOT(populateColorTable()));
38 35
39 36 m_colorTable = new QVector<QRgb>();
40 37 m_colorTable->reserve(nbOfColors);
41 38 populateColorTable();
42 39 }
43 40
44 41 void ColorMapChart::setDirty(bool dirty)
45 42 {
46 43 m_dirty = dirty;
47 44 }
48 45
49 46 QRectF ColorMapChart::boundingRect() const
50 47 {
51 48 return m_rect;
52 49 }
53 50
54 51 void ColorMapChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
55 52 {
56 53 Q_UNUSED(widget)
57 54 Q_UNUSED(option)
58 55
56 m_series->setUseOpenGL();
57
58 painter->save();
59
59 60 QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
60 61 painter->setClipRect(clipRect);
61 62
62 63 QRectF plotAreaRect = m_series->chart()->plotArea();
63 64 QImage colorMapImage(plotAreaRect.width(),plotAreaRect.height(),QImage::Format_RGB32);
64 65 //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.
65 66 colorMapImage.fill(QColor(Qt::white).rgb());
66 67
67 ColorMapDataPart * grid = m_series->getUniformGrid(0,0,plotAreaRect.width(),plotAreaRect.height(),QColorMapSeries::LastPixel);
68 QElapsedTimer timer;
69 timer.start();
70
71 QVector<double> * grid = m_series->getUniformGrid(0,0,plotAreaRect.width(),plotAreaRect.height(),QColorMapSeries::LastPixel);
72
73 int msec = timer.elapsed();
74 int msec2 = 0+msec;
68 75
69 76 double maxZ = m_series->maxZ();
70 77 double minZ = m_series->minZ();
71 78 double rangeZ = maxZ - minZ;
72 79
73 for(int i=0;i<colorMapImage.width();i++)
80 int imageWidth = colorMapImage.width();
81 int imageHeight = colorMapImage.height();
82
83 for(int i=0;i<imageWidth;i++)
74 84 {
75 for(int j=0;j<colorMapImage.height();j++)
85 for(int j=0;j<imageHeight;j++)
76 86 {
77 double value = grid->dataSeries().at(i+j*(colorMapImage.width()));
87 double value = grid->at(i+j*(imageWidth));
78 88 double pix=((value-minZ)/rangeZ);
79 89 int indexInColorTable = pix*(nbOfColors-1);
80 90 colorMapImage.setPixel(i,j,m_colorTable->at(indexInColorTable));
81 91 }
82 92 }
83 93
84 if(!m_colorbar)
85 addColorBar();
94 addColorBar(plotAreaRect);
95
86 96
87 97 painter->drawImage(clipRect,colorMapImage);
88 update();
98 update();//Qt docs: Warning: If you call repaint() in a function which may itself be called from paintEvent(), you may get infinite recursion. The update() function never causes recursion
99
100 painter->restore();
101
102
89 103 }
90 104
91 void ColorMapChart::addColorBar()
105 void ColorMapChart::addColorBar(QRectF plotAreaRect)
92 106 {
93 107 double maxZ = m_series->maxZ();
94 108 double minZ = m_series->minZ();
95 QColorBarAxis *colorbar = new QColorBarAxis(createColorMapGradient(m_gradientType),minZ, maxZ,this);
96 m_series->chart()->addAxis(colorbar, Qt::AlignRight);
97 m_colorbar = true;
109
110 if(m_isColorBarDrawn)
111 m_series->chart()->removeAxis(m_colorbar);
112
113 m_colorbar = new QColorBarAxis(plotAreaRect,createColorMapGradient(m_gradientType),minZ, maxZ,this);
114 m_series->chart()->addAxis(m_colorbar, Qt::AlignRight);
115 m_isColorBarDrawn = true;
98 116 }
99 117
100 118 /*!
101 119 Returns the predefined QLinearGradient corresponding to the \a gradientType passed as argument.
102 120 */
103 121 QLinearGradient ColorMapChart::createColorMapGradient(GradientType gradientType)
104 122 {
105 123 QLinearGradient gradient(0,0,1,100);
106 124 switch(gradientType)
107 125 {
108 126 case Rainbow :
109 127 gradient.setColorAt(1.0,Qt::darkRed);
110 128 gradient.setColorAt(0.8,Qt::red);
111 129 gradient.setColorAt(0.6,Qt::yellow);
112 130 gradient.setColorAt(0.4,Qt::green);
113 131 gradient.setColorAt(0.2,Qt::cyan);
114 132 gradient.setColorAt(0.0,Qt::blue);
115 133 break;
116 134 case CyclingRainbow :
117 135 gradient.setColorAt(1.0,Qt::red);
118 136 gradient.setColorAt(0.8,Qt::yellow);
119 137 gradient.setColorAt(0.6,Qt::green);
120 138 gradient.setColorAt(0.4,Qt::cyan);
121 139 gradient.setColorAt(0.2,Qt::blue);
122 140 gradient.setColorAt(0.0,Qt::magenta);
123 141 break;
124 142 case BlackAndWhite :
125 143 gradient.setColorAt(1.0, Qt::black);
126 144 gradient.setColorAt(0.0, Qt::white);
127 145 break;
128 146 case ReverseBlackAndWhite :
129 147 gradient.setColorAt(1.0, Qt::white);
130 148 gradient.setColorAt(0.0, Qt::black);
131 149 break;
132 150 default:
133 151 break;
134 152 }
135 153 return gradient;
136 154 }
137 155
138 156 /*!
139 157 Changes the type of gradient used to paint the ColorMap.
140 158 */
141 159 void ColorMapChart::changeGradient(GradientType gradientType)
142 160 {
143 161 if(m_gradientType == gradientType)
144 162 return;
145 163 else
146 164 m_gradientType = gradientType;
147 165 emit gradientTypeChanged();
148 166 }
149 167
150 168 /*!
151 169 Creates a color table corresponding to the gradient type currently selected.
152 170 */
153 171 void ColorMapChart::populateColorTable()
154 172 {
155 173 QLinearGradient gradient = createColorMapGradient(m_gradientType);
156 174 QGradientStops colorStops = gradient.stops();
157 175
158 176 for(int i=0;i<nbOfColors;i++)
159 177 {
160 178 double colorIndex = (double)i/nbOfColors;
161 179 for(int k =0;k<colorStops.size()-1;k++)
162 180 {
163 181 QGradientStop lowerBound = colorStops.at(k);
164 182 QGradientStop upperBound = colorStops.at(k+1);
165 183 if(colorIndex >= lowerBound.first && colorIndex < upperBound.first)
166 184 {
167 185 double ratio = (colorIndex-lowerBound.first)/(upperBound.first - lowerBound.first);
168 186 int red = (int)((1-ratio)*lowerBound.second.red() + ratio*upperBound.second.red());
169 187 int green = (int)((1-ratio)*lowerBound.second.green() + ratio*upperBound.second.green());
170 188 int blue = (int)((1-ratio)*lowerBound.second.blue() + ratio*upperBound.second.blue());
171 189 m_colorTable->append(qRgb(red, green, blue));
172 190 break;
173 191 }
174 192 else
175 193 {
176 194 if(k==colorStops.size()-2)
177 195 {
178 196 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()));
179 197 }
180 198 }
181 199 }
182 200 }
183 201 }
184 202
185 203
186 204 //handlers
187 205
188 206 void ColorMapChart::handlePointAdded(int index)
189 207 {
190 208
191 209 }
192 210
193 211 void ColorMapChart::handlePointRemoved(int index)
194 212 {
195 213
196 214 }
197 215
198 216 void ColorMapChart::handlePointsRemoved(int index, int count)
199 217 {
200 218
201 219 }
202 220
203 221 void ColorMapChart::handlePointReplaced(int index)
204 222 {
205 223
206 224 }
207 225
208 226 void ColorMapChart::handlePointsReplaced()
209 227 {
210 228
211 229 }
212 230
213 231 void ColorMapChart::handleDomainUpdated()
214 232 {
215 233
216 234 }
217 235
218 236 bool ColorMapChart::isEmpty()
219 237 {
220 238
221 239 }
222 240
223 241
224 242 #include "moc_colormapchart_p.cpp"
225 243
226 244 QT_CHARTS_END_NAMESPACE
@@ -1,123 +1,127
1 1 #ifndef COLORMAPCHART_H
2 2 #define COLORMAPCHART_H
3 3
4 4 #include "point3d.h"
5 5 #include <QtCharts/QChartGlobal>
6 6 #include <private/chartitem_p.h>
7 7 #include <QtCharts/QValueAxis>
8 8 #include <QtGui/QPen>
9 9
10 //#include <QtCharts/QColorBarAxis> TODO : fix this
11 #include "qcolorbaraxis.h"
12
10 13 QT_CHARTS_BEGIN_NAMESPACE
11 14
12 15 class ChartPresenter;
13 16 class QColorMapSeries;
14 17
15 18 class ColorMapChart : public ChartItem
16 19 {
17 20 Q_OBJECT
18 21 public:
19 22
20 23 enum GradientType
21 24 {
22 25 Rainbow,
23 26 CyclingRainbow,
24 27 BlackAndWhite,
25 28 ReverseBlackAndWhite
26 29 };
27 30
28 31 explicit ColorMapChart(QColorMapSeries *series,QGraphicsItem *item = 0);
29 32 ~ColorMapChart() {}
30 33
31 34 bool isDirty() const { return m_dirty; }
32 35 void setDirty(bool dirty);
33 36
34 37 // from QGraphicsItem
35 38 QRectF boundingRect() const;
36 39 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
37 40
38 41 public Q_SLOTS:
39 42 void handlePointAdded(int index);
40 43 void handlePointRemoved(int index);
41 44 void handlePointsRemoved(int index, int count);
42 45 void handlePointReplaced(int index);
43 46 void handlePointsReplaced();
44 47 void handleDomainUpdated();
45 48
46 49 private slots :
47 50 void populateColorTable();
48 51
49 52 Q_SIGNALS:
50 53 void clicked(const Point3D &point);
51 54 void hovered(const Point3D &point, bool state);
52 55 void pressed(const Point3D &point);
53 56 void released(const Point3D &point);
54 57 void doubleClicked(const Point3D &point);
55 58 void gradientTypeChanged();
56 59
57 60 private:
58 61 inline bool isEmpty();
59 void addColorBar();
62 void addColorBar(QRectF plotAreaRect);
60 63 QLinearGradient createColorMapGradient(GradientType gradientType);
61 64 void changeGradient(GradientType gradientType);
62 65
63 66 protected:
64 67 QColorMapSeries *m_series;
65 68 QVector<Point3D> m_points;
66 69 QRectF m_rect;
67 70 bool m_dirty;
68 71 QVector<QRgb> *m_colorTable;
69 72 GradientType m_gradientType;
70 bool m_colorbar;
73 bool m_isColorBarDrawn;
74 QColorBarAxis *m_colorbar;
71 75 };
72 76
73 77 //class PixmapMarker: public QGraphicsRectItem
74 78 //{
75 79
76 80 //public:
77 81 // PixmapMarker(qreal x, qreal y, qreal w, qreal h, ColorMapChart *parent)
78 82 // : QGraphicsRectItem(x, y, w, h, parent),
79 83 // m_parent(parent)
80 84 // {
81 85 // setAcceptHoverEvents(true);
82 86 // setFlag(QGraphicsItem::ItemIsSelectable);
83 87 // }
84 88
85 89 //protected:
86 90 // void mousePressEvent(QGraphicsSceneMouseEvent *event)
87 91 // {
88 92 // QGraphicsRectItem::mousePressEvent(event);
89 93 // m_parent->markerPressed(this);
90 94 // m_parent->setMousePressed();
91 95 // }
92 96 // void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
93 97 // {
94 98 // QGraphicsRectItem::hoverEnterEvent(event);
95 99 // m_parent->markerHovered(this, true);
96 100 // }
97 101 // void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
98 102 // {
99 103 // QGraphicsRectItem::hoverLeaveEvent(event);
100 104 // m_parent->markerHovered(this, false);
101 105 // }
102 106 // void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
103 107 // {
104 108 // QGraphicsRectItem::mouseReleaseEvent(event);
105 109 // m_parent->markerReleased(this);
106 110 // if (m_parent->mousePressed())
107 111 // m_parent->markerSelected(this);
108 112 // m_parent->setMousePressed(false);
109 113 // }
110 114 // void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
111 115 // {
112 116 // QGraphicsRectItem::mouseDoubleClickEvent(event);
113 117 // m_parent->markerDoubleClicked(this);
114 118 // }
115 119
116 120 //private:
117 121 // ColorMapChart *m_parent;
118 122 //};
119 123
120 124
121 125 QT_CHARTS_END_NAMESPACE
122 126
123 127 #endif // COLORMAPCHART_H
@@ -1,638 +1,631
1 1 #include "qcolormapseries.h"
2 2 #include <private/qcolormapseries_p.h>
3 3 #include <private/abstractdomain_p.h>
4 4 #include <QtCharts/QValueAxis>
5 5 #include <private/colormapchart_p.h>
6 6 #include <QtCharts/QColorMapLegendMarker>
7 7 #include <private/charthelpers_p.h>
8 8 #include <private/qchart_p.h>
9 9 #include <QtGui/QPainter>
10 10
11 11 //#include <algorithm>
12 12 #include <cmath>
13 13
14 14 #include "qcolorbaraxis.h"
15 15
16 16 QT_CHARTS_BEGIN_NAMESPACE
17 17
18 18 /*!
19 19 \internal
20 20
21 21 Constructs empty series object which is a child of \a parent.
22 22 When series object is added to QChart instance ownerships is transferred.
23 23 */
24 24 QColorMapSeries::QColorMapSeries(QObject *parent)
25 25 : QAbstractSeries(*new QColorMapSeriesPrivate(this), parent)
26 26 {
27 27 }
28 28
29 29 /*!
30 30 \internal
31 31
32 32 Constructs empty series object which is a child of \a parent.
33 33 When series object is added to QChart instance ownerships is transferred.
34 34 */
35 35 QColorMapSeries::QColorMapSeries(QColorMapSeriesPrivate &d, QObject *parent)
36 36 : QAbstractSeries(d, parent)
37 37 {
38 38 }
39 39
40 40
41 41 /*!
42 42 Destroys the object. Series added to QChart instances are owned by those,
43 43 and are destroyed when QChart instances are destroyed.
44 44 */
45 45 QColorMapSeries::~QColorMapSeries()
46 46 {
47 47 }
48 48
49 49 /*!
50 50 \fn virtual SeriesType QBoxPlotSeries::type() const
51 51 \brief Returns type of series.
52 52 \sa QAbstractSeries, SeriesType
53 53 */
54 54 QAbstractSeries::SeriesType QColorMapSeries::type() const
55 55 {
56 56 return QAbstractSeries::SeriesTypeColorMap;
57 57 }
58 58
59 59
60 60 /*!
61 61 Adds data part \a dataPart to the series.\n
62 62 If \a copy is true, adds a copy of the data part instead.
63 63 */
64 64 void QColorMapSeries::append(ColorMapDataPart* dataPart, bool copy)
65 65 {
66 66 Q_D(QColorMapSeries);
67 67 if(copy)
68 68 d->m_dataParts << new ColorMapDataPart(dataPart);
69 69 else
70 70 d->m_dataParts << dataPart;
71 71 d->recomputeDataRange();
72 72 emit dataPartAdded(d->m_dataParts.count() - 1);
73 73 }
74 74
75 75 /*!
76 76 This is an overloaded function.\n
77 77 Adds data parts \a dataParts to the series.\n
78 78 If \a copy is true, adds a copy of the data part instead.
79 79 */
80 80 void QColorMapSeries::append(const QList<ColorMapDataPart*> &dataParts, bool copy)
81 81 {
82 82 foreach (ColorMapDataPart* dataPart , dataParts)
83 83 append(dataPart,copy);
84 84 }
85 85
86 86
87 87 /*!
88 88 Returns number of data parts within series.
89 89 */
90 90 int QColorMapSeries::count() const
91 91 {
92 92 Q_D(const QColorMapSeries);
93 93 return d->m_dataParts.count();
94 94 }
95 95
96 96
97 97 /*!
98 98 Stream operator for adding a data part \a point to the series.
99 99 \sa append()
100 100 */
101 101 QColorMapSeries &QColorMapSeries::operator <<(const ColorMapDataPart &dataPart)
102 102 {
103 103 append(new ColorMapDataPart(dataPart));
104 104 return *this;
105 105 }
106 106
107 107 /*!
108 108 Stream operator for adding a vector of data parts \a dataParts to the series.
109 109 \sa append()
110 110 */
111 111 QColorMapSeries &QColorMapSeries::operator <<(const QList<ColorMapDataPart*> &dataParts)
112 112 {
113 113 append(dataParts);
114 114 return *this;
115 115 }
116 116
117 117 /*!
118 118 Returns a ColorMapData part containing a uniform grid of data points to be mapped in a ColorMapChart.\n
119 119 The rectangle of data returned is determined by \a width and \height,\n
120 120 from the position \a xpos , \a ypos (starting at the top left corner of the plot area).\n
121 121 When there are more points than pixels, \a strategy is applied to determine which to choose.
122 122 */
123 ColorMapDataPart *QColorMapSeries::getUniformGrid(int xpos, int ypos,int width, int height, QColorMapSeries::Strategy strategy)
123 QVector<double> *QColorMapSeries::getUniformGrid(int xpos, int ypos,int width, int height, QColorMapSeries::Strategy strategy)
124 124 {
125 125 Q_D(QColorMapSeries);
126 126 return d->getUniformGrid(xpos, ypos,width,height, strategy);
127 127 }
128 128
129 129 //void QColorMapSeries::attachAxis(QAbstractAxis *axis)
130 130 //{
131 131 // axis = static_cast<QColorBarAxis*>();
132 132 // if(axis)
133 133 // {
134 134
135 135 // }
136 136 // else
137 137 // {
138 138 // QAbstractSeries::attachAxis(axis);
139 139 // }
140 140 //}
141 141
142 142 /*!
143 143 Sets \a pen used for drawing points on the chart. If the pen is not defined, the
144 144 pen from chart theme is used.
145 145 \sa QChart::setTheme()
146 146 */
147 147 void QColorMapSeries::setPen(const QPen &pen)
148 148 {
149 149 Q_D(QColorMapSeries);
150 150 if (d->m_pen != pen)
151 151 {
152 152 //bool emitColorChanged = d->m_pen.color() != pen.color();
153 153 d->m_pen = pen;
154 154 emit d->updated();
155 155 // if (emitColorChanged)
156 156 // emit colorChanged(pen.color());
157 157 emit penChanged(pen);
158 158 }
159 159 }
160 160
161 161 QPen QColorMapSeries::pen() const
162 162 {
163 163 Q_D(const QColorMapSeries);
164 164 if (d->m_pen == QChartPrivate::defaultPen())
165 165 return QPen();
166 166 else
167 167 return d->m_pen;
168 168 }
169 169
170 170 /*!
171 171 Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
172 172 from chart theme setting is used.
173 173 \sa QChart::setTheme()
174 174 */
175 175 void QColorMapSeries::setBrush(const QBrush &brush)
176 176 {
177 177 Q_D(QColorMapSeries);
178 178 if (d->m_brush != brush)
179 179 {
180 180 d->m_brush = brush;
181 181 emit d->updated();
182 182 }
183 183 }
184 184
185 185 QBrush QColorMapSeries::brush() const
186 186 {
187 187 Q_D(const QColorMapSeries);
188 188 if (d->m_brush == QChartPrivate::defaultBrush())
189 189 return QBrush();
190 190 else
191 191 return d->m_brush;
192 192 }
193 193
194 194 //void QColorMapSeries::setColor(const QColor &color)
195 195 //{
196 196 // QPen p = pen();
197 197 // if (p.color() != color)
198 198 // {
199 199 // p.setColor(color);
200 200 // setPen(p);
201 201 // }
202 202 //}
203 203
204 204 //QColor QColorMapSeries::color() const
205 205 //{
206 206 // return pen().color();
207 207 //}
208 208
209 209 //void QColorMapSeries::setPointsVisible(bool visible)
210 210 //{
211 211 // Q_D(QColorMapSeries);
212 212 // if (d->m_pointsVisible != visible)
213 213 // {
214 214 // d->m_pointsVisible = visible;
215 215 // emit d->updated();
216 216 // }
217 217 //}
218 218
219 219 //bool QColorMapSeries::pointsVisible() const
220 220 //{
221 221 // Q_D(const QColorMapSeries);
222 222 // return d->m_pointsVisible;
223 223 //}
224 224
225 225 //void QColorMapSeries::setPointLabelsFormat(const QString &format)
226 226 //{
227 227 // Q_D(QColorMapSeries);
228 228 // if (d->m_pointLabelsFormat != format)
229 229 // {
230 230 // d->m_pointLabelsFormat = format;
231 231 // emit pointLabelsFormatChanged(format);
232 232 // }
233 233 //}
234 234
235 235 //QString QColorMapSeries::pointLabelsFormat() const
236 236 //{
237 237 // Q_D(const QColorMapSeries);
238 238 // return d->m_pointLabelsFormat;
239 239 //}
240 240
241 241 //void QColorMapSeries::setPointLabelsVisible(bool visible)
242 242 //{
243 243 // Q_D(QColorMapSeries);
244 244 // if (d->m_pointLabelsVisible != visible)
245 245 // {
246 246 // d->m_pointLabelsVisible = visible;
247 247 // emit pointLabelsVisibilityChanged(visible);
248 248 // }
249 249 //}
250 250
251 251 //bool QColorMapSeries::pointLabelsVisible() const
252 252 //{
253 253 // Q_D(const QColorMapSeries);
254 254 // return d->m_pointLabelsVisible;
255 255 //}
256 256
257 257 //void QColorMapSeries::setPointLabelsFont(const QFont &font)
258 258 //{
259 259 // Q_D(QColorMapSeries);
260 260 // if (d->m_pointLabelsFont != font) {
261 261 // d->m_pointLabelsFont = font;
262 262 // emit pointLabelsFontChanged(font);
263 263 // }
264 264 //}
265 265
266 266 //QFont QColorMapSeries::pointLabelsFont() const
267 267 //{
268 268 // Q_D(const QColorMapSeries);
269 269 // return d->m_pointLabelsFont;
270 270 //}
271 271
272 272 //void QColorMapSeries::setPointLabelsColor(const QColor &color)
273 273 //{
274 274 // Q_D(QColorMapSeries);
275 275 // if (d->m_pointLabelsColor != color) {
276 276 // d->m_pointLabelsColor = color;
277 277 // emit pointLabelsColorChanged(color);
278 278 // }
279 279 //}
280 280
281 281 //QColor QColorMapSeries::pointLabelsColor() const
282 282 //{
283 283 // Q_D(const QColorMapSeries);
284 284 // if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color())
285 285 // return QPen().color();
286 286 // else
287 287 // return d->m_pointLabelsColor;
288 288 //}
289 289
290 290 //void QColorMapSeries::setPointLabelsClipping(bool enabled)
291 291 //{
292 292 // Q_D(QColorMapSeries);
293 293 // if (d->m_pointLabelsClipping != enabled) {
294 294 // d->m_pointLabelsClipping = enabled;
295 295 // emit pointLabelsClippingChanged(enabled);
296 296 // }
297 297 //}
298 298
299 299 //bool QColorMapSeries::pointLabelsClipping() const
300 300 //{
301 301 // Q_D(const QColorMapSeries);
302 302 // return d->m_pointLabelsClipping;
303 303 //}
304 304 /*!
305 305 Returns the minimum value of the series on the X axis.
306 306 */
307 307 double QColorMapSeries::minX()
308 308 {
309 309 Q_D(QColorMapSeries);
310 310 return d->m_minX;
311 311 }
312 312
313 313 /*!
314 314 Returns the minimum value of the series on the Y axis.
315 315 */
316 316 double QColorMapSeries::minY()
317 317 {
318 318 Q_D(QColorMapSeries);
319 319 return d->m_minY;
320 320 }
321 321
322 322 /*!
323 323 Returns the minimum value of the series on the Z axis.
324 324 */
325 325 double QColorMapSeries::minZ()
326 326 {
327 327 Q_D(QColorMapSeries);
328 328 return d->m_minZ;
329 329 }
330 330
331 331 /*!
332 332 Returns the maximum value of the series on the X axis.
333 333 */
334 334 double QColorMapSeries::maxX()
335 335 {
336 336 Q_D(QColorMapSeries);
337 337 return d->m_maxX;
338 338 }
339 339
340 340 /*!
341 341 Returns the maximum value of the series on the Y axis.
342 342 */
343 343 double QColorMapSeries::maxY()
344 344 {
345 345 Q_D(QColorMapSeries);
346 346 return d->m_maxY;
347 347 }
348 348
349 349 /*!
350 350 Returns the maximum value of the series on the Z axis.
351 351 */
352 352 double QColorMapSeries::maxZ()
353 353 {
354 354 Q_D(QColorMapSeries);
355 355 return d->m_maxZ;
356 356 }
357 357
358 358 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
359 359
360 360 QColorMapSeriesPrivate::QColorMapSeriesPrivate(QColorMapSeries *q)
361 361 : QAbstractSeriesPrivate(q),
362 362 m_pen(QChartPrivate::defaultPen()),
363 363 m_brush(QChartPrivate::defaultBrush()),
364 364 m_pointsVisible(false),
365 365 m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")), //TODO : change
366 366 m_pointLabelsVisible(false),
367 367 m_pointLabelsFont(QChartPrivate::defaultFont()),
368 368 m_pointLabelsColor(QChartPrivate::defaultPen().color()),
369 369 m_pointLabelsClipping(true)
370 370 {
371 371 }
372 372
373 373 void QColorMapSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
374 374 {
375 375 Q_Q(QColorMapSeries);
376 376 ColorMapChart *colormap = new ColorMapChart(q,parent);
377 377 m_item.reset(colormap);
378 378 QAbstractSeriesPrivate::initializeGraphics(parent);
379 379 }
380 380
381 381 void QColorMapSeriesPrivate::initializeDomain()
382 382 {
383 383 domain()->setRange(m_minX, m_maxX, m_minY, m_maxY);
384 384 }
385 385
386 386 void QColorMapSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced)
387 387 {
388 388 // Q_Q(QColorMapSeries);
389 389
390 390 // const QList<QGradient> gradients = theme->seriesGradients();
391 391 // const QList<QColor> colors = theme->seriesColors();
392 392
393 393 // if (forced || QChartPrivate::defaultPen() == m_pen) {
394 394 // QPen pen;
395 395 // pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0));
396 396 // pen.setWidthF(2);
397 397 // q->setPen(pen);
398 398 // }
399 399
400 400 // if (forced || QChartPrivate::defaultBrush() == m_brush) {
401 401 // QBrush brush(colors.at(index % colors.size()));
402 402 // q->setBrush(brush);
403 403 // }
404 404
405 405 // if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
406 406 // QColor color = theme->labelBrush().color();
407 407 // q->setPointLabelsColor(color);
408 408 // }
409 409 }
410 410
411 411 QList<QLegendMarker*> QColorMapSeriesPrivate::createLegendMarkers(QLegend* legend)
412 412 {
413 413 Q_Q(QColorMapSeries);
414 414 QList<QLegendMarker*> list;
415 415 return list << new QColorMapLegendMarker(q,legend);
416 416 }
417 417
418 418 void QColorMapSeriesPrivate::initializeAxes()
419 419 {
420 420
421 421 }
422 422
423 423 QAbstractAxis::AxisType QColorMapSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
424 424 {
425 425 Q_UNUSED(orientation);
426 426 return QAbstractAxis::AxisTypeValue;
427 427 }
428 428
429 429 QAbstractAxis* QColorMapSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const
430 430 {
431 431 Q_UNUSED(orientation);
432 432 return new QValueAxis;
433 433 }
434 434
435 435
436 ColorMapDataPart *QColorMapSeriesPrivate::getUniformGrid(int xpos, int ypos, int width, int height, QColorMapSeries::Strategy strategy)
436 QVector<double> *QColorMapSeriesPrivate::getUniformGrid(int xpos, int ypos, int width, int height, QColorMapSeries::Strategy strategy)
437 437 {
438 // QVector<double> *timeSeries = new QVector<double>(width);
439 // QVector<double> *ySeries = new QVector<double>(height);
440 QVector<double> *dataSeries = new QVector<double>(width*height);
441 QVector<double> *timeSeries = new QVector<double>();
442 QVector<double> *ySeries = new QVector<double>();
443 ColorMapDataPart* grid = new ColorMapDataPart(timeSeries,ySeries,dataSeries);
438 QVector<double> *grid = new QVector<double>(width*height);
444 439
445 440 double dx = (m_maxX - m_minX)/(double)width;
446 441 double dy = (m_maxY - m_minY)/(double)height;
447 442
448 443 int x=0;
449 444 int y=0;
450 445
451 for(int i=0;i<width;i++) //width-1?
452 {
453 timeSeries->append((double)i);
454 }
446 QVector<Point3D> cluster;
447 cluster.reserve(height*width/1000);
455 448
456
457 for (auto cell= dataSeries->begin();cell<dataSeries->end();++cell)
449 for (auto cell= grid->begin();cell<grid->end();++cell)
458 450 {
459 QVector<Point3D> cluster;
451 cluster.resize(0);
460 452 this->buildCluster(x,y,dx,dy,cluster);
461 453 if(strategy == QColorMapSeries::LastPixel)
462 454 *cell=this->clusterStrategyLast(cluster);
463 455 else if(strategy == QColorMapSeries::MeanPixel)
464 456 *cell=this->clusterStrategyMean(cluster);
465 457 else if(strategy == QColorMapSeries::MedianPixel)
466 458 *cell=this->clusterStrategyMedian(cluster);
467 459 if(x<width-1)
468 460 {
469 461 x++;
470 462 }
471 463 else
472 464 {
473 465 x=0;
474 ySeries->append((double)y);
475 466 y++;
476
477 467 }
478 468 }
469
479 470 return grid;
480 471 }
481 472
482 473 /*!
483 474 Recompute the data range on X, Y and Z axes each time a ColorMapDataPart is added to the series.\n
484 475 The minimum distance between 2 adjacent values on X and Y axis is added to the maximum on X and Y respectively\n
485 476 in order to take account of the width of the last element.
486 477 */
487 478 void QColorMapSeriesPrivate::recomputeDataRange()
488 479 {
489 480 //TODO : if non empty
490 481 m_minX = m_dataParts.first()->timesSeries().first();
491 482 m_maxX = m_dataParts.last()->timesSeries().last();
492 483
493 484 m_minY = m_dataParts.last()->ySeries().last();
494 485 m_maxY = m_dataParts.last()->ySeries().first();
495 486 m_minZ = m_dataParts.first()->dataSeries().first();
496 487 m_maxZ = m_dataParts.last()->dataSeries().last();
497 488 double minDeltaX=m_maxX-m_minX;
498 489 double minDeltaY=m_minY-m_maxY;
499 490 foreach(ColorMapDataPart* datapart, m_dataParts)
500 491 {
501 492 m_minY = qMin(datapart->ySeries().first(),m_minY);
502 493 m_maxY = qMax(datapart->ySeries().last(),m_maxY);
503 494 for(int i=1;i<datapart->timesSeries().size();i++)
504 495 {
505 496 double newDeltaX=datapart->timesSeries()[i]-datapart->timesSeries()[i-1];
506 497 minDeltaX=qMin(minDeltaX,newDeltaX);
507 498 }
508 499 for(int i=1;i<datapart->ySeries().size();i++)
509 500 {
510 501 double newDeltaY=datapart->ySeries()[i]-datapart->ySeries()[i-1];
511 502 minDeltaY=qMin(minDeltaY,newDeltaY);
512 503 }
513 504
514 505 for (int i = 0; i < datapart->dataSeries().count(); i++)
515 506 {
516 507 double z = datapart->dataSeries().at(i);
517 508 m_minZ = qMin(m_minZ, z);
518 509 m_maxZ = qMax(m_maxZ, z);
519 510 }
520 511 }
521 512 m_maxX+=minDeltaX;
522 513 m_maxY+=minDeltaY;
523 514 }
524 515
525 516 /*!
526 517 Returns the last value (bottom right Z value) of a \a cluster of points passed as argument.
527 518 */
528 519 double QColorMapSeriesPrivate::clusterStrategyLast(QVector<Point3D>& cluster)
529 520 {
530 521 if(!cluster.isEmpty())
531 522 return cluster.last().value();
532 523 return 0;
533 524 }
534 525
535 526 /*!
536 527 Returns the mean value (mean Z value) of a \a cluster of points passed as argument.
537 528 */
538 529 double QColorMapSeriesPrivate::clusterStrategyMean(QVector<Point3D>& cluster)
539 530 {
540 531 if(!cluster.isEmpty())
541 532 {
542 533 double sum=0;
543 534 int count =0;
544 535 for(int i =0;i<cluster.size();i++)
545 536 {
546 537 if(!isnan(Point3D(cluster.at(i)).value()))
547 538 {
548 539 sum+= Point3D(cluster.at(i)).value();
549 540 count++;
550 541 }
551 542 }
552 543 return (sum/count);
553 544 }
554 545 return 0;
555 546 }
556 547
557 548 /*!
558 549 Returns the median value (median Z value) of a \a cluster of points passed as argument.
559 550 */
560 551 double QColorMapSeriesPrivate::clusterStrategyMedian(QVector<Point3D>& cluster)
561 552 {
562 553 if(!cluster.isEmpty())
563 554 {
564 555 QVector<double> *copy = new QVector<double>();
565 556
566 557 for(int i =0;i<cluster.size();i++)
567 558 {
568 559 if(!isnan(Point3D(cluster.at(i)).value()))
569 560 copy->append(Point3D(cluster.at(i)).value());
570 561 }
571 562
572 563 if(!copy->isEmpty())
573 564 {
574 565 std::sort(copy->begin(), copy->end());
575 566
576 567 if(copy->count() & 1) // odd
577 568 {
578 569 int middle = (copy->count()+1)/2;
579 570 return copy->at(middle-1);
580 571 }
581 572 else //even
582 573 {
583 574 int middle = copy->count()/2;
584 575 return (copy->at(middle-1)+copy->at(middle))/2;
585 576 }
586 577 }
587 578 }
588 579 return 0;
589 580 }
590 581
591 582 /*!
592 583 Computes which data points correspond to the given position and returns the in a \a cluster.
593 584 */
594 585 void QColorMapSeriesPrivate::buildCluster(int xpos, int ypos, double dx, double dy, QVector<Point3D>& cluster)
595 586 {
596 587 foreach(ColorMapDataPart *dataPart, m_dataParts)
597 588 {
598 589 QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(xpos+1)*dx);
599 590 QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_maxY-(ypos+1)*dy,m_maxY-ypos*dy);
600 591
592 int timeSeriesSize = dataPart->timesSeries().size();
593
601 594 if(xRange.first != xRange.second && yRange.first != yRange.second)
602 595 {
603 596 for(int i =xRange.first+1;i<xRange.second;i++)
604 597 {
605 598 qreal xval=dataPart->timesSeries()[i];
606 599 for(int j=yRange.first+1;j<yRange.second;j++)
607 600 {
608 601 qreal yval=dataPart->ySeries()[j];
609 qreal val=dataPart->dataSeries()[ i + (dataPart->timesSeries().size() * j)];
602 qreal val=dataPart->dataSeries()[ i + (timeSeriesSize * j)];
610 603 cluster.append(Point3D(xval,yval,val));
611 604 }
612 605 }
613 606 }
614 607 }
615 608 }
616 609
617 610
618 611 void QColorMapSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options,
619 612 int duration, QEasingCurve &curve)
620 613 {
621 614 // ColorMapChart *item = static_cast<ColorMapChart *>(m_item.data());
622 615 // Q_ASSERT(item);
623 616 // if (item->animation())
624 617 // item->animation()->stopAndDestroyLater();
625 618
626 619 // if (options.testFlag(QChart::SeriesAnimations))
627 620 // item->setAnimation(new XYAnimation(item, duration, curve));
628 621 // else
629 622 // item->setAnimation(0);
630 623 QAbstractSeriesPrivate::initializeAnimations(options, duration, curve);
631 624 }
632 625
633 626
634 627
635 628 #include "moc_qcolormapseries.cpp"
636 629 #include "moc_qcolormapseries_p.cpp"
637 630
638 631 QT_CHARTS_END_NAMESPACE
@@ -1,122 +1,122
1 1 #ifndef QCOLORMAPSERIES_H
2 2 #define QCOLORMAPSERIES_H
3 3
4 4 #include <QtCharts/QChartGlobal>
5 5 #include <QtCharts/QAbstractSeries>
6 6 #include <QtGui/QPen>
7 7 #include <QtGui/QBrush>
8 8 #include "colormapdatapart.h"
9 9
10 10 QT_CHARTS_BEGIN_NAMESPACE
11 11 class QColorMapSeriesPrivate;
12 12
13 13
14 14 class QT_CHARTS_EXPORT QColorMapSeries : public QAbstractSeries
15 15 {
16 16 Q_OBJECT
17 17 // Q_PROPERTY(bool pointsVisible READ pointsVisible WRITE setPointsVisible)
18 18 // Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
19 19 // Q_PROPERTY(QString pointLabelsFormat READ pointLabelsFormat WRITE setPointLabelsFormat NOTIFY pointLabelsFormatChanged)
20 20 // Q_PROPERTY(bool pointLabelsVisible READ pointLabelsVisible WRITE setPointLabelsVisible NOTIFY pointLabelsVisibilityChanged)
21 21 // Q_PROPERTY(QFont pointLabelsFont READ pointLabelsFont WRITE setPointLabelsFont NOTIFY pointLabelsFontChanged)
22 22 // Q_PROPERTY(QColor pointLabelsColor READ pointLabelsColor WRITE setPointLabelsColor NOTIFY pointLabelsColorChanged)
23 23 // Q_PROPERTY(bool pointLabelsClipping READ pointLabelsClipping WRITE setPointLabelsClipping NOTIFY pointLabelsClippingChanged)
24 24
25 25 protected:
26 26 explicit QColorMapSeries(QColorMapSeriesPrivate &d, QObject *parent =0);
27 27
28 28
29 29 public :
30 30
31 31 enum Strategy
32 32 {
33 33 LastPixel,
34 34 MeanPixel,
35 35 MedianPixel
36 36 };
37 37
38 38
39 39 explicit QColorMapSeries(QObject *parent =0);
40 40 ~QColorMapSeries();
41 41 QAbstractSeries::SeriesType type() const;
42 42 void append(ColorMapDataPart* dataPart, bool copy=true);
43 43 void append(const QList<ColorMapDataPart *> &dataParts, bool copy=true);
44 44
45 45 int count() const;
46 46 QVector<ColorMapDataPart*> dataParts() const;
47 47
48 48 QColorMapSeries &operator << (const ColorMapDataPart &dataPart);
49 49 QColorMapSeries &operator << (const QList<ColorMapDataPart *> &dataParts);
50 50
51 ColorMapDataPart* getUniformGrid(int xpos, int ypos,int width, int height, Strategy strategy);
52 //double getUniformGrid(int width, int height, Strategy lambda);
51 QVector<double> *getUniformGrid(int xpos, int ypos,int width, int height, Strategy strategy);
52 // QVector<double> *getUniformGrid(int width, int height, Strategy lambda);
53 53
54 54 // virtual void attachAxis(QAbstractAxis *axis);
55 55
56 56 virtual void setPen(const QPen &pen);
57 57 QPen pen() const;
58 58
59 59 virtual void setBrush(const QBrush &brush);
60 60 QBrush brush() const;
61 61
62 62 // virtual void setColor(const QColor &color);
63 63 // QColor color() const;
64 64
65 65 // void setPointsVisible(bool visible = true);
66 66 // bool pointsVisible() const;
67 67
68 68 // void setPointLabelsFormat(const QString &format);
69 69 // QString pointLabelsFormat() const;
70 70
71 71 // void setPointLabelsVisible(bool visible = true);
72 72 // bool pointLabelsVisible() const;
73 73
74 74 // void setPointLabelsFont(const QFont &font);
75 75 // QFont pointLabelsFont() const;
76 76
77 77 // void setPointLabelsColor(const QColor &color);
78 78 // QColor pointLabelsColor() const;
79 79
80 80 // void setPointLabelsClipping(bool enabled = true);
81 81 // bool pointLabelsClipping() const;
82 82
83 83 double minX();
84 84 double minY();
85 85 double minZ();
86 86 double maxX();
87 87 double maxY();
88 88 double maxZ();
89 89
90 90
91 91
92 92 Q_SIGNALS:
93 93 // void clicked(const Point3D &point);
94 94 // void hovered(const Point3D &point, bool state);
95 95 // void pressed(const Point3D &point);
96 96 // void released(const Point3D &point);
97 97 // void doubleClicked(const Point3D &point);
98 98 // void pointReplaced(int index);
99 99 // void pointRemoved(int index);
100 100 void dataPartAdded(int index);
101 101 // void colorChanged(QColor color);
102 102 // void pointsReplaced();
103 103 // void pointLabelsFormatChanged(const QString &format);
104 104 // void pointLabelsVisibilityChanged(bool visible);
105 105 // void pointLabelsFontChanged(const QFont &font);
106 106 // void pointLabelsColorChanged(const QColor &color);
107 107 // void pointLabelsClippingChanged(bool clipping);
108 108 // void pointsRemoved(int index, int count);
109 109 void penChanged(const QPen &pen);
110 110
111 111 private:
112 112 Q_DECLARE_PRIVATE(QColorMapSeries)
113 113 Q_DISABLE_COPY(QColorMapSeries)
114 114 friend class ColorMapLegendMarker;
115 115 friend class ColorMapChart;
116 116 friend class QColorMapLegendMarkerPrivate;
117 117
118 118 };
119 119
120 120 QT_CHARTS_END_NAMESPACE
121 121
122 122 #endif // QCOLORMAPSERIES_H
@@ -1,70 +1,68
1 1 #ifndef QCOLORMAPSERIES_P_H
2 2 #define QCOLORMAPSERIES_P_H
3 3
4 4 #include <private/qabstractseries_p.h>
5 5 #include "colormapdatapart.h"
6 6 #include <point3d.h>
7 7
8 8 QT_CHARTS_BEGIN_NAMESPACE
9 9
10 10 #include "qcolormapseries.h"
11 11
12 12 class QAbstractAxis;
13 13
14 14 class QColorMapSeriesPrivate : public QAbstractSeriesPrivate
15 15 {
16 16 Q_OBJECT
17 17
18 18 public :
19 19
20 20 QColorMapSeriesPrivate(QColorMapSeries *q);
21 21
22 22 void initializeDomain();
23 23 void initializeAxes();
24 24 void initializeGraphics(QGraphicsItem* parent);
25 25 void initializeTheme(int index, ChartTheme* theme, bool forced = false);
26 26 void initializeAnimations(QChart::AnimationOptions options, int duration,
27 27 QEasingCurve &curve);
28 28
29 29 QList<QLegendMarker *> createLegendMarkers(QLegend *legend);
30 30
31 31 QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const;
32 32 QAbstractAxis* createDefaultAxis(Qt::Orientation) const;
33 33
34 ColorMapDataPart* getUniformGrid(int xpos, int ypos,int width, int height, QColorMapSeries::Strategy strategy);
34 QVector<double> *getUniformGrid(int xpos, int ypos,int width, int height, QColorMapSeries::Strategy strategy);
35 35
36 36 Q_SIGNALS:
37 37 void updated();
38 38
39 39 protected:
40 40 QList<ColorMapDataPart*> m_dataParts;
41 41 QPen m_pen;
42 42 QBrush m_brush;
43 43 bool m_pointsVisible;
44 44 QString m_pointLabelsFormat;
45 45 bool m_pointLabelsVisible;
46 46 QFont m_pointLabelsFont;
47 47 QColor m_pointLabelsColor;
48 48 bool m_pointLabelsClipping;
49 49
50 50 private:
51 51 double m_minX;
52 52 double m_maxX;
53 53 double m_minY;
54 54 double m_maxY;
55 55 double m_minZ;
56 56 double m_maxZ;
57 57 void recomputeDataRange();
58 QPair<int,int> getLastX(double start, double end);
59 int getLastY(int x,double start, double end);
60 58 double clusterStrategyLast(QVector<Point3D>& cluster);
61 59 double clusterStrategyMean(QVector<Point3D> &cluster);
62 60 double clusterStrategyMedian(QVector<Point3D>& cluster);
63 61 void buildCluster(int xpos,int ypos, double dx,double dy,QVector<Point3D>& cluster);
64 62 Q_DECLARE_PUBLIC(QColorMapSeries)
65 63 };
66 64
67 65 QT_CHARTS_END_NAMESPACE
68 66
69 67
70 68 #endif // QCOLORMAPSERIES_P_H
General Comments 0
You need to be logged in to leave comments. Login now