@@ -1,18 +1,21 | |||||
1 | INCLUDEPATH += $$PWD |
|
1 | INCLUDEPATH += $$PWD | |
2 | DEPENDPATH += $$PWD |
|
2 | DEPENDPATH += $$PWD | |
3 |
|
3 | |||
|
4 | QMAKE_CXXFLAGS+= -fopenmp | |||
|
5 | QMAKE_LFLAGS += -fopenmp | |||
|
6 | ||||
4 | SOURCES += \ |
|
7 | SOURCES += \ | |
5 | $$PWD/qcolormapseries.cpp \ |
|
8 | $$PWD/qcolormapseries.cpp \ | |
6 | $$PWD/colormapchart.cpp \ |
|
9 | $$PWD/colormapchart.cpp \ | |
7 | $$PWD/colormapdatapart.cpp \ |
|
10 | $$PWD/colormapdatapart.cpp \ | |
8 | $$PWD/point3d.cpp |
|
11 | $$PWD/point3d.cpp | |
9 |
|
12 | |||
10 | PRIVATE_HEADERS += \ |
|
13 | PRIVATE_HEADERS += \ | |
11 | $$PWD/qcolormapseries_p.h \ |
|
14 | $$PWD/qcolormapseries_p.h \ | |
12 | $$PWD/colormapchart_p.h |
|
15 | $$PWD/colormapchart_p.h | |
13 |
|
16 | |||
14 | PUBLIC_HEADERS += \ |
|
17 | PUBLIC_HEADERS += \ | |
15 | $$PWD/qcolormapseries.h \ |
|
18 | $$PWD/qcolormapseries.h \ | |
16 | $$PWD/point3d.h \ |
|
19 | $$PWD/point3d.h \ | |
17 | $$PWD/colormapdatapart.h |
|
20 | $$PWD/colormapdatapart.h | |
18 |
|
21 |
@@ -1,627 +1,645 | |||||
1 | #include "qcolormapseries.h" |
|
1 | #include "qcolormapseries.h" | |
2 | #include <private/qcolormapseries_p.h> |
|
2 | #include <private/qcolormapseries_p.h> | |
3 | #include <private/abstractdomain_p.h> |
|
3 | #include <private/abstractdomain_p.h> | |
4 | #include <QtCharts/QValueAxis> |
|
4 | #include <QtCharts/QValueAxis> | |
5 | #include <private/colormapchart_p.h> |
|
5 | #include <private/colormapchart_p.h> | |
6 | #include <QtCharts/QColorMapLegendMarker> |
|
6 | #include <QtCharts/QColorMapLegendMarker> | |
7 | #include <private/charthelpers_p.h> |
|
7 | #include <private/charthelpers_p.h> | |
8 | #include <private/qchart_p.h> |
|
8 | #include <private/qchart_p.h> | |
9 | #include <QtGui/QPainter> |
|
9 | #include <QtGui/QPainter> | |
10 |
|
10 | |||
11 | //#include <algorithm> |
|
|||
12 | #include <cmath> |
|
11 | #include <cmath> | |
|
12 | #include "omp.h" | |||
13 |
|
13 | |||
14 | #include "qcolorbaraxis.h" |
|
14 | #include "qcolorbaraxis.h" | |
15 |
|
15 | |||
16 | QT_CHARTS_BEGIN_NAMESPACE |
|
16 | QT_CHARTS_BEGIN_NAMESPACE | |
17 |
|
17 | |||
18 | /*! |
|
18 | /*! | |
19 | \internal |
|
19 | \internal | |
20 |
|
20 | |||
21 | Constructs empty series object which is a child of \a parent. |
|
21 | Constructs empty series object which is a child of \a parent. | |
22 | When series object is added to QChart instance ownerships is transferred. |
|
22 | When series object is added to QChart instance ownerships is transferred. | |
23 | */ |
|
23 | */ | |
24 | QColorMapSeries::QColorMapSeries(QObject *parent) |
|
24 | QColorMapSeries::QColorMapSeries(QObject *parent) | |
25 | : QAbstractSeries(*new QColorMapSeriesPrivate(this), parent) |
|
25 | : QAbstractSeries(*new QColorMapSeriesPrivate(this), parent) | |
26 | { |
|
26 | { | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | /*! |
|
29 | /*! | |
30 | \internal |
|
30 | \internal | |
31 |
|
31 | |||
32 | Constructs empty series object which is a child of \a parent. |
|
32 | Constructs empty series object which is a child of \a parent. | |
33 | When series object is added to QChart instance ownerships is transferred. |
|
33 | When series object is added to QChart instance ownerships is transferred. | |
34 | */ |
|
34 | */ | |
35 | QColorMapSeries::QColorMapSeries(QColorMapSeriesPrivate &d, QObject *parent) |
|
35 | QColorMapSeries::QColorMapSeries(QColorMapSeriesPrivate &d, QObject *parent) | |
36 | : QAbstractSeries(d, parent) |
|
36 | : QAbstractSeries(d, parent) | |
37 | { |
|
37 | { | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | Destroys the object. Series added to QChart instances are owned by those, |
|
42 | Destroys the object. Series added to QChart instances are owned by those, | |
43 | and are destroyed when QChart instances are destroyed. |
|
43 | and are destroyed when QChart instances are destroyed. | |
44 | */ |
|
44 | */ | |
45 | QColorMapSeries::~QColorMapSeries() |
|
45 | QColorMapSeries::~QColorMapSeries() | |
46 | { |
|
46 | { | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \fn virtual SeriesType QBoxPlotSeries::type() const |
|
50 | \fn virtual SeriesType QBoxPlotSeries::type() const | |
51 | \brief Returns type of series. |
|
51 | \brief Returns type of series. | |
52 | \sa QAbstractSeries, SeriesType |
|
52 | \sa QAbstractSeries, SeriesType | |
53 | */ |
|
53 | */ | |
54 | QAbstractSeries::SeriesType QColorMapSeries::type() const |
|
54 | QAbstractSeries::SeriesType QColorMapSeries::type() const | |
55 | { |
|
55 | { | |
56 | return QAbstractSeries::SeriesTypeColorMap; |
|
56 | return QAbstractSeries::SeriesTypeColorMap; | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
61 | Adds data part \a dataPart to the series.\n |
|
61 | Adds data part \a dataPart to the series.\n | |
62 | If \a copy is true, adds a copy of the data part instead. |
|
62 | If \a copy is true, adds a copy of the data part instead. | |
63 | */ |
|
63 | */ | |
64 | void QColorMapSeries::append(ColorMapDataPart* dataPart, bool copy) |
|
64 | void QColorMapSeries::append(ColorMapDataPart* dataPart, bool copy) | |
65 | { |
|
65 | { | |
66 | Q_D(QColorMapSeries); |
|
66 | Q_D(QColorMapSeries); | |
67 | if(copy) |
|
67 | if(copy) | |
68 | d->m_dataParts << new ColorMapDataPart(dataPart); |
|
68 | d->m_dataParts << new ColorMapDataPart(dataPart); | |
69 | else |
|
69 | else | |
70 | d->m_dataParts << dataPart; |
|
70 | d->m_dataParts << dataPart; | |
71 | d->recomputeDataRange(); |
|
71 | d->recomputeDataRange(); | |
72 | emit dataPartAdded(d->m_dataParts.count() - 1); |
|
72 | emit dataPartAdded(d->m_dataParts.count() - 1); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | /*! |
|
75 | /*! | |
76 | This is an overloaded function.\n |
|
76 | This is an overloaded function.\n | |
77 | Adds data parts \a dataParts to the series.\n |
|
77 | Adds data parts \a dataParts to the series.\n | |
78 | If \a copy is true, adds a copy of the data part instead. |
|
78 | If \a copy is true, adds a copy of the data part instead. | |
79 | */ |
|
79 | */ | |
80 | void QColorMapSeries::append(const QList<ColorMapDataPart*> &dataParts, bool copy) |
|
80 | void QColorMapSeries::append(const QList<ColorMapDataPart*> &dataParts, bool copy) | |
81 | { |
|
81 | { | |
82 | foreach (ColorMapDataPart* dataPart , dataParts) |
|
82 | foreach (ColorMapDataPart* dataPart , dataParts) | |
83 | append(dataPart,copy); |
|
83 | append(dataPart,copy); | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 |
|
86 | |||
87 | /*! |
|
87 | /*! | |
88 | Returns number of data parts within series. |
|
88 | Returns number of data parts within series. | |
89 | */ |
|
89 | */ | |
90 | int QColorMapSeries::count() const |
|
90 | int QColorMapSeries::count() const | |
91 | { |
|
91 | { | |
92 | Q_D(const QColorMapSeries); |
|
92 | Q_D(const QColorMapSeries); | |
93 | return d->m_dataParts.count(); |
|
93 | return d->m_dataParts.count(); | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 |
|
96 | |||
97 | /*! |
|
97 | /*! | |
98 | Stream operator for adding a data part \a point to the series. |
|
98 | Stream operator for adding a data part \a point to the series. | |
99 | \sa append() |
|
99 | \sa append() | |
100 | */ |
|
100 | */ | |
101 | QColorMapSeries &QColorMapSeries::operator <<(const ColorMapDataPart &dataPart) |
|
101 | QColorMapSeries &QColorMapSeries::operator <<(const ColorMapDataPart &dataPart) | |
102 | { |
|
102 | { | |
103 | append(new ColorMapDataPart(dataPart)); |
|
103 | append(new ColorMapDataPart(dataPart)); | |
104 | return *this; |
|
104 | return *this; | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | Stream operator for adding a vector of data parts \a dataParts to the series. |
|
108 | Stream operator for adding a vector of data parts \a dataParts to the series. | |
109 | \sa append() |
|
109 | \sa append() | |
110 | */ |
|
110 | */ | |
111 | QColorMapSeries &QColorMapSeries::operator <<(const QList<ColorMapDataPart*> &dataParts) |
|
111 | QColorMapSeries &QColorMapSeries::operator <<(const QList<ColorMapDataPart*> &dataParts) | |
112 | { |
|
112 | { | |
113 | append(dataParts); |
|
113 | append(dataParts); | |
114 | return *this; |
|
114 | return *this; | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
118 | Returns a ColorMapData part containing a uniform grid of data points to be mapped in a ColorMapChart.\n |
|
118 | Returns a ColorMapData part containing a uniform grid of data points to be mapped in a ColorMapChart.\n | |
119 | The rectangle of data returned is determined by \a width and \height,\n |
|
119 | The rectangle of data returned is determined by \a width and \height,\n | |
120 | from the position \a xpos , \a ypos (starting at the top left corner of the plot area).\n |
|
120 | from the position \a xpos , \a ypos (starting at the top left corner of the plot area).\n | |
121 | When there are more points than pixels, \a strategy is applied to determine which to choose. |
|
121 | When there are more points than pixels, \a strategy is applied to determine which to choose. | |
122 | */ |
|
122 | */ | |
123 | void QColorMapSeries::getUniformGrid(int xpos, int ypos,int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy) |
|
123 | void QColorMapSeries::getUniformGrid(int xpos, int ypos,int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy) | |
124 | { |
|
124 | { | |
125 | Q_D(QColorMapSeries); |
|
125 | Q_D(QColorMapSeries); | |
126 | d->getUniformGrid(xpos, ypos,width,height, grid, strategy); |
|
126 | d->getUniformGrid(xpos, ypos,width,height, grid, strategy); | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | //void QColorMapSeries::attachAxis(QAbstractAxis *axis) |
|
129 | //void QColorMapSeries::attachAxis(QAbstractAxis *axis) | |
130 | //{ |
|
130 | //{ | |
131 | // axis = static_cast<QColorBarAxis*>(); |
|
131 | // axis = static_cast<QColorBarAxis*>(); | |
132 | // if(axis) |
|
132 | // if(axis) | |
133 | // { |
|
133 | // { | |
134 |
|
134 | |||
135 | // } |
|
135 | // } | |
136 | // else |
|
136 | // else | |
137 | // { |
|
137 | // { | |
138 | // QAbstractSeries::attachAxis(axis); |
|
138 | // QAbstractSeries::attachAxis(axis); | |
139 | // } |
|
139 | // } | |
140 | //} |
|
140 | //} | |
141 |
|
141 | |||
142 | /*! |
|
142 | /*! | |
143 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
143 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
144 | pen from chart theme is used. |
|
144 | pen from chart theme is used. | |
145 | \sa QChart::setTheme() |
|
145 | \sa QChart::setTheme() | |
146 | */ |
|
146 | */ | |
147 | void QColorMapSeries::setPen(const QPen &pen) |
|
147 | void QColorMapSeries::setPen(const QPen &pen) | |
148 | { |
|
148 | { | |
149 | Q_D(QColorMapSeries); |
|
149 | Q_D(QColorMapSeries); | |
150 | if (d->m_pen != pen) |
|
150 | if (d->m_pen != pen) | |
151 | { |
|
151 | { | |
152 | //bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
152 | //bool emitColorChanged = d->m_pen.color() != pen.color(); | |
153 | d->m_pen = pen; |
|
153 | d->m_pen = pen; | |
154 | emit d->updated(); |
|
154 | emit d->updated(); | |
155 | // if (emitColorChanged) |
|
155 | // if (emitColorChanged) | |
156 | // emit colorChanged(pen.color()); |
|
156 | // emit colorChanged(pen.color()); | |
157 | emit penChanged(pen); |
|
157 | emit penChanged(pen); | |
158 | } |
|
158 | } | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | QPen QColorMapSeries::pen() const |
|
161 | QPen QColorMapSeries::pen() const | |
162 | { |
|
162 | { | |
163 | Q_D(const QColorMapSeries); |
|
163 | Q_D(const QColorMapSeries); | |
164 | if (d->m_pen == QChartPrivate::defaultPen()) |
|
164 | if (d->m_pen == QChartPrivate::defaultPen()) | |
165 | return QPen(); |
|
165 | return QPen(); | |
166 | else |
|
166 | else | |
167 | return d->m_pen; |
|
167 | return d->m_pen; | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | /*! |
|
170 | /*! | |
171 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
171 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
172 | from chart theme setting is used. |
|
172 | from chart theme setting is used. | |
173 | \sa QChart::setTheme() |
|
173 | \sa QChart::setTheme() | |
174 | */ |
|
174 | */ | |
175 | void QColorMapSeries::setBrush(const QBrush &brush) |
|
175 | void QColorMapSeries::setBrush(const QBrush &brush) | |
176 | { |
|
176 | { | |
177 | Q_D(QColorMapSeries); |
|
177 | Q_D(QColorMapSeries); | |
178 | if (d->m_brush != brush) |
|
178 | if (d->m_brush != brush) | |
179 | { |
|
179 | { | |
180 | d->m_brush = brush; |
|
180 | d->m_brush = brush; | |
181 | emit d->updated(); |
|
181 | emit d->updated(); | |
182 | } |
|
182 | } | |
183 | } |
|
183 | } | |
184 |
|
184 | |||
185 | QBrush QColorMapSeries::brush() const |
|
185 | QBrush QColorMapSeries::brush() const | |
186 | { |
|
186 | { | |
187 | Q_D(const QColorMapSeries); |
|
187 | Q_D(const QColorMapSeries); | |
188 | if (d->m_brush == QChartPrivate::defaultBrush()) |
|
188 | if (d->m_brush == QChartPrivate::defaultBrush()) | |
189 | return QBrush(); |
|
189 | return QBrush(); | |
190 | else |
|
190 | else | |
191 | return d->m_brush; |
|
191 | return d->m_brush; | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | //void QColorMapSeries::setColor(const QColor &color) |
|
194 | //void QColorMapSeries::setColor(const QColor &color) | |
195 | //{ |
|
195 | //{ | |
196 | // QPen p = pen(); |
|
196 | // QPen p = pen(); | |
197 | // if (p.color() != color) |
|
197 | // if (p.color() != color) | |
198 | // { |
|
198 | // { | |
199 | // p.setColor(color); |
|
199 | // p.setColor(color); | |
200 | // setPen(p); |
|
200 | // setPen(p); | |
201 | // } |
|
201 | // } | |
202 | //} |
|
202 | //} | |
203 |
|
203 | |||
204 | //QColor QColorMapSeries::color() const |
|
204 | //QColor QColorMapSeries::color() const | |
205 | //{ |
|
205 | //{ | |
206 | // return pen().color(); |
|
206 | // return pen().color(); | |
207 | //} |
|
207 | //} | |
208 |
|
208 | |||
209 | //void QColorMapSeries::setPointsVisible(bool visible) |
|
209 | //void QColorMapSeries::setPointsVisible(bool visible) | |
210 | //{ |
|
210 | //{ | |
211 | // Q_D(QColorMapSeries); |
|
211 | // Q_D(QColorMapSeries); | |
212 | // if (d->m_pointsVisible != visible) |
|
212 | // if (d->m_pointsVisible != visible) | |
213 | // { |
|
213 | // { | |
214 | // d->m_pointsVisible = visible; |
|
214 | // d->m_pointsVisible = visible; | |
215 | // emit d->updated(); |
|
215 | // emit d->updated(); | |
216 | // } |
|
216 | // } | |
217 | //} |
|
217 | //} | |
218 |
|
218 | |||
219 | //bool QColorMapSeries::pointsVisible() const |
|
219 | //bool QColorMapSeries::pointsVisible() const | |
220 | //{ |
|
220 | //{ | |
221 | // Q_D(const QColorMapSeries); |
|
221 | // Q_D(const QColorMapSeries); | |
222 | // return d->m_pointsVisible; |
|
222 | // return d->m_pointsVisible; | |
223 | //} |
|
223 | //} | |
224 |
|
224 | |||
225 | //void QColorMapSeries::setPointLabelsFormat(const QString &format) |
|
225 | //void QColorMapSeries::setPointLabelsFormat(const QString &format) | |
226 | //{ |
|
226 | //{ | |
227 | // Q_D(QColorMapSeries); |
|
227 | // Q_D(QColorMapSeries); | |
228 | // if (d->m_pointLabelsFormat != format) |
|
228 | // if (d->m_pointLabelsFormat != format) | |
229 | // { |
|
229 | // { | |
230 | // d->m_pointLabelsFormat = format; |
|
230 | // d->m_pointLabelsFormat = format; | |
231 | // emit pointLabelsFormatChanged(format); |
|
231 | // emit pointLabelsFormatChanged(format); | |
232 | // } |
|
232 | // } | |
233 | //} |
|
233 | //} | |
234 |
|
234 | |||
235 | //QString QColorMapSeries::pointLabelsFormat() const |
|
235 | //QString QColorMapSeries::pointLabelsFormat() const | |
236 | //{ |
|
236 | //{ | |
237 | // Q_D(const QColorMapSeries); |
|
237 | // Q_D(const QColorMapSeries); | |
238 | // return d->m_pointLabelsFormat; |
|
238 | // return d->m_pointLabelsFormat; | |
239 | //} |
|
239 | //} | |
240 |
|
240 | |||
241 | //void QColorMapSeries::setPointLabelsVisible(bool visible) |
|
241 | //void QColorMapSeries::setPointLabelsVisible(bool visible) | |
242 | //{ |
|
242 | //{ | |
243 | // Q_D(QColorMapSeries); |
|
243 | // Q_D(QColorMapSeries); | |
244 | // if (d->m_pointLabelsVisible != visible) |
|
244 | // if (d->m_pointLabelsVisible != visible) | |
245 | // { |
|
245 | // { | |
246 | // d->m_pointLabelsVisible = visible; |
|
246 | // d->m_pointLabelsVisible = visible; | |
247 | // emit pointLabelsVisibilityChanged(visible); |
|
247 | // emit pointLabelsVisibilityChanged(visible); | |
248 | // } |
|
248 | // } | |
249 | //} |
|
249 | //} | |
250 |
|
250 | |||
251 | //bool QColorMapSeries::pointLabelsVisible() const |
|
251 | //bool QColorMapSeries::pointLabelsVisible() const | |
252 | //{ |
|
252 | //{ | |
253 | // Q_D(const QColorMapSeries); |
|
253 | // Q_D(const QColorMapSeries); | |
254 | // return d->m_pointLabelsVisible; |
|
254 | // return d->m_pointLabelsVisible; | |
255 | //} |
|
255 | //} | |
256 |
|
256 | |||
257 | //void QColorMapSeries::setPointLabelsFont(const QFont &font) |
|
257 | //void QColorMapSeries::setPointLabelsFont(const QFont &font) | |
258 | //{ |
|
258 | //{ | |
259 | // Q_D(QColorMapSeries); |
|
259 | // Q_D(QColorMapSeries); | |
260 | // if (d->m_pointLabelsFont != font) { |
|
260 | // if (d->m_pointLabelsFont != font) { | |
261 | // d->m_pointLabelsFont = font; |
|
261 | // d->m_pointLabelsFont = font; | |
262 | // emit pointLabelsFontChanged(font); |
|
262 | // emit pointLabelsFontChanged(font); | |
263 | // } |
|
263 | // } | |
264 | //} |
|
264 | //} | |
265 |
|
265 | |||
266 | //QFont QColorMapSeries::pointLabelsFont() const |
|
266 | //QFont QColorMapSeries::pointLabelsFont() const | |
267 | //{ |
|
267 | //{ | |
268 | // Q_D(const QColorMapSeries); |
|
268 | // Q_D(const QColorMapSeries); | |
269 | // return d->m_pointLabelsFont; |
|
269 | // return d->m_pointLabelsFont; | |
270 | //} |
|
270 | //} | |
271 |
|
271 | |||
272 | //void QColorMapSeries::setPointLabelsColor(const QColor &color) |
|
272 | //void QColorMapSeries::setPointLabelsColor(const QColor &color) | |
273 | //{ |
|
273 | //{ | |
274 | // Q_D(QColorMapSeries); |
|
274 | // Q_D(QColorMapSeries); | |
275 | // if (d->m_pointLabelsColor != color) { |
|
275 | // if (d->m_pointLabelsColor != color) { | |
276 | // d->m_pointLabelsColor = color; |
|
276 | // d->m_pointLabelsColor = color; | |
277 | // emit pointLabelsColorChanged(color); |
|
277 | // emit pointLabelsColorChanged(color); | |
278 | // } |
|
278 | // } | |
279 | //} |
|
279 | //} | |
280 |
|
280 | |||
281 | //QColor QColorMapSeries::pointLabelsColor() const |
|
281 | //QColor QColorMapSeries::pointLabelsColor() const | |
282 | //{ |
|
282 | //{ | |
283 | // Q_D(const QColorMapSeries); |
|
283 | // Q_D(const QColorMapSeries); | |
284 | // if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color()) |
|
284 | // if (d->m_pointLabelsColor == QChartPrivate::defaultPen().color()) | |
285 | // return QPen().color(); |
|
285 | // return QPen().color(); | |
286 | // else |
|
286 | // else | |
287 | // return d->m_pointLabelsColor; |
|
287 | // return d->m_pointLabelsColor; | |
288 | //} |
|
288 | //} | |
289 |
|
289 | |||
290 | //void QColorMapSeries::setPointLabelsClipping(bool enabled) |
|
290 | //void QColorMapSeries::setPointLabelsClipping(bool enabled) | |
291 | //{ |
|
291 | //{ | |
292 | // Q_D(QColorMapSeries); |
|
292 | // Q_D(QColorMapSeries); | |
293 | // if (d->m_pointLabelsClipping != enabled) { |
|
293 | // if (d->m_pointLabelsClipping != enabled) { | |
294 | // d->m_pointLabelsClipping = enabled; |
|
294 | // d->m_pointLabelsClipping = enabled; | |
295 | // emit pointLabelsClippingChanged(enabled); |
|
295 | // emit pointLabelsClippingChanged(enabled); | |
296 | // } |
|
296 | // } | |
297 | //} |
|
297 | //} | |
298 |
|
298 | |||
299 | //bool QColorMapSeries::pointLabelsClipping() const |
|
299 | //bool QColorMapSeries::pointLabelsClipping() const | |
300 | //{ |
|
300 | //{ | |
301 | // Q_D(const QColorMapSeries); |
|
301 | // Q_D(const QColorMapSeries); | |
302 | // return d->m_pointLabelsClipping; |
|
302 | // return d->m_pointLabelsClipping; | |
303 | //} |
|
303 | //} | |
304 | /*! |
|
304 | /*! | |
305 | Returns the minimum value of the series on the X axis. |
|
305 | Returns the minimum value of the series on the X axis. | |
306 | */ |
|
306 | */ | |
307 | double QColorMapSeries::minX() |
|
307 | double QColorMapSeries::minX() | |
308 | { |
|
308 | { | |
309 | Q_D(QColorMapSeries); |
|
309 | Q_D(QColorMapSeries); | |
310 | return d->m_minX; |
|
310 | return d->m_minX; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | /*! |
|
313 | /*! | |
314 | Returns the minimum value of the series on the Y axis. |
|
314 | Returns the minimum value of the series on the Y axis. | |
315 | */ |
|
315 | */ | |
316 | double QColorMapSeries::minY() |
|
316 | double QColorMapSeries::minY() | |
317 | { |
|
317 | { | |
318 | Q_D(QColorMapSeries); |
|
318 | Q_D(QColorMapSeries); | |
319 | return d->m_minY; |
|
319 | return d->m_minY; | |
320 | } |
|
320 | } | |
321 |
|
321 | |||
322 | /*! |
|
322 | /*! | |
323 | Returns the minimum value of the series on the Z axis. |
|
323 | Returns the minimum value of the series on the Z axis. | |
324 | */ |
|
324 | */ | |
325 | double QColorMapSeries::minZ() |
|
325 | double QColorMapSeries::minZ() | |
326 | { |
|
326 | { | |
327 | Q_D(QColorMapSeries); |
|
327 | Q_D(QColorMapSeries); | |
328 | return d->m_minZ; |
|
328 | return d->m_minZ; | |
329 | } |
|
329 | } | |
330 |
|
330 | |||
331 | /*! |
|
331 | /*! | |
332 | Returns the maximum value of the series on the X axis. |
|
332 | Returns the maximum value of the series on the X axis. | |
333 | */ |
|
333 | */ | |
334 | double QColorMapSeries::maxX() |
|
334 | double QColorMapSeries::maxX() | |
335 | { |
|
335 | { | |
336 | Q_D(QColorMapSeries); |
|
336 | Q_D(QColorMapSeries); | |
337 | return d->m_maxX; |
|
337 | return d->m_maxX; | |
338 | } |
|
338 | } | |
339 |
|
339 | |||
340 | /*! |
|
340 | /*! | |
341 | Returns the maximum value of the series on the Y axis. |
|
341 | Returns the maximum value of the series on the Y axis. | |
342 | */ |
|
342 | */ | |
343 | double QColorMapSeries::maxY() |
|
343 | double QColorMapSeries::maxY() | |
344 | { |
|
344 | { | |
345 | Q_D(QColorMapSeries); |
|
345 | Q_D(QColorMapSeries); | |
346 | return d->m_maxY; |
|
346 | return d->m_maxY; | |
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | /*! |
|
349 | /*! | |
350 | Returns the maximum value of the series on the Z axis. |
|
350 | Returns the maximum value of the series on the Z axis. | |
351 | */ |
|
351 | */ | |
352 | double QColorMapSeries::maxZ() |
|
352 | double QColorMapSeries::maxZ() | |
353 | { |
|
353 | { | |
354 | Q_D(QColorMapSeries); |
|
354 | Q_D(QColorMapSeries); | |
355 | return d->m_maxZ; |
|
355 | return d->m_maxZ; | |
356 | } |
|
356 | } | |
357 |
|
357 | |||
358 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
358 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
359 |
|
359 | |||
360 | QColorMapSeriesPrivate::QColorMapSeriesPrivate(QColorMapSeries *q) |
|
360 | QColorMapSeriesPrivate::QColorMapSeriesPrivate(QColorMapSeries *q) | |
361 | : QAbstractSeriesPrivate(q), |
|
361 | : QAbstractSeriesPrivate(q), | |
362 | m_pen(QChartPrivate::defaultPen()), |
|
362 | m_pen(QChartPrivate::defaultPen()), | |
363 | m_brush(QChartPrivate::defaultBrush()), |
|
363 | m_brush(QChartPrivate::defaultBrush()), | |
364 | m_pointsVisible(false), |
|
364 | m_pointsVisible(false), | |
365 | m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")), //TODO : change |
|
365 | m_pointLabelsFormat(QLatin1String("@xPoint, @yPoint")), //TODO : change | |
366 | m_pointLabelsVisible(false), |
|
366 | m_pointLabelsVisible(false), | |
367 | m_pointLabelsFont(QChartPrivate::defaultFont()), |
|
367 | m_pointLabelsFont(QChartPrivate::defaultFont()), | |
368 | m_pointLabelsColor(QChartPrivate::defaultPen().color()), |
|
368 | m_pointLabelsColor(QChartPrivate::defaultPen().color()), | |
369 | m_pointLabelsClipping(true) |
|
369 | m_pointLabelsClipping(true) | |
370 | { |
|
370 | { | |
371 | } |
|
371 | } | |
372 |
|
372 | |||
373 | void QColorMapSeriesPrivate::initializeGraphics(QGraphicsItem* parent) |
|
373 | void QColorMapSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |
374 | { |
|
374 | { | |
375 | Q_Q(QColorMapSeries); |
|
375 | Q_Q(QColorMapSeries); | |
376 | ColorMapChart *colormap = new ColorMapChart(q,parent); |
|
376 | ColorMapChart *colormap = new ColorMapChart(q,parent); | |
377 | m_item.reset(colormap); |
|
377 | m_item.reset(colormap); | |
378 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
378 | QAbstractSeriesPrivate::initializeGraphics(parent); | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | void QColorMapSeriesPrivate::initializeDomain() |
|
381 | void QColorMapSeriesPrivate::initializeDomain() | |
382 | { |
|
382 | { | |
383 | domain()->setRange(m_minX, m_maxX, m_minY, m_maxY); |
|
383 | domain()->setRange(m_minX, m_maxX, m_minY, m_maxY); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | void QColorMapSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) |
|
386 | void QColorMapSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) | |
387 | { |
|
387 | { | |
388 | // Q_Q(QColorMapSeries); |
|
388 | // Q_Q(QColorMapSeries); | |
389 |
|
389 | |||
390 | // const QList<QGradient> gradients = theme->seriesGradients(); |
|
390 | // const QList<QGradient> gradients = theme->seriesGradients(); | |
391 | // const QList<QColor> colors = theme->seriesColors(); |
|
391 | // const QList<QColor> colors = theme->seriesColors(); | |
392 |
|
392 | |||
393 | // if (forced || QChartPrivate::defaultPen() == m_pen) { |
|
393 | // if (forced || QChartPrivate::defaultPen() == m_pen) { | |
394 | // QPen pen; |
|
394 | // QPen pen; | |
395 | // pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0)); |
|
395 | // pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0)); | |
396 | // pen.setWidthF(2); |
|
396 | // pen.setWidthF(2); | |
397 | // q->setPen(pen); |
|
397 | // q->setPen(pen); | |
398 | // } |
|
398 | // } | |
399 |
|
399 | |||
400 | // if (forced || QChartPrivate::defaultBrush() == m_brush) { |
|
400 | // if (forced || QChartPrivate::defaultBrush() == m_brush) { | |
401 | // QBrush brush(colors.at(index % colors.size())); |
|
401 | // QBrush brush(colors.at(index % colors.size())); | |
402 | // q->setBrush(brush); |
|
402 | // q->setBrush(brush); | |
403 | // } |
|
403 | // } | |
404 |
|
404 | |||
405 | // if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) { |
|
405 | // if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) { | |
406 | // QColor color = theme->labelBrush().color(); |
|
406 | // QColor color = theme->labelBrush().color(); | |
407 | // q->setPointLabelsColor(color); |
|
407 | // q->setPointLabelsColor(color); | |
408 | // } |
|
408 | // } | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | QList<QLegendMarker*> QColorMapSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
411 | QList<QLegendMarker*> QColorMapSeriesPrivate::createLegendMarkers(QLegend* legend) | |
412 | { |
|
412 | { | |
413 | Q_Q(QColorMapSeries); |
|
413 | Q_Q(QColorMapSeries); | |
414 | QList<QLegendMarker*> list; |
|
414 | QList<QLegendMarker*> list; | |
415 | return list << new QColorMapLegendMarker(q,legend); |
|
415 | return list << new QColorMapLegendMarker(q,legend); | |
416 | } |
|
416 | } | |
417 |
|
417 | |||
418 | void QColorMapSeriesPrivate::initializeAxes() |
|
418 | void QColorMapSeriesPrivate::initializeAxes() | |
419 | { |
|
419 | { | |
420 |
|
420 | |||
421 | } |
|
421 | } | |
422 |
|
422 | |||
423 | QAbstractAxis::AxisType QColorMapSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
423 | QAbstractAxis::AxisType QColorMapSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
424 | { |
|
424 | { | |
425 | Q_UNUSED(orientation); |
|
425 | Q_UNUSED(orientation); | |
426 | return QAbstractAxis::AxisTypeValue; |
|
426 | return QAbstractAxis::AxisTypeValue; | |
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | QAbstractAxis* QColorMapSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
429 | QAbstractAxis* QColorMapSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
430 | { |
|
430 | { | |
431 | Q_UNUSED(orientation); |
|
431 | Q_UNUSED(orientation); | |
432 | return new QValueAxis; |
|
432 | return new QValueAxis; | |
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 |
|
435 | |||
436 | void QColorMapSeriesPrivate::getUniformGrid(int xpos, int ypos, int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy) |
|
436 | void QColorMapSeriesPrivate::getUniformGrid(int xpos, int ypos, int width, int height, QVector<double> &grid, QColorMapSeries::Strategy strategy) | |
437 | { |
|
437 | { | |
438 | double dx = (m_maxX - m_minX)/(double)width; |
|
438 | double dx = (m_maxX - m_minX)/(double)width; | |
439 | double dy = (m_maxY - m_minY)/(double)height; |
|
439 | double dy = (m_maxY - m_minY)/(double)height; | |
440 |
|
440 | |||
441 | int x=0; |
|
441 | int index=0; | |
442 | int y=0; |
|
|||
443 |
|
442 | |||
444 | QVector<Point3D> cluster; |
|
443 | QVector<Point3D> cluster; | |
445 | cluster.reserve(height*width/1000); |
|
444 | cluster.reserve(height*width/1000); | |
446 |
|
445 | |||
|
446 | int x = 0; | |||
|
447 | int y = 0; | |||
|
448 | ||||
447 | for (auto cell= grid.begin();cell<grid.end();++cell) |
|
449 | for (auto cell= grid.begin();cell<grid.end();++cell) | |
448 | { |
|
450 | { | |
|
451 | x = index%width; | |||
|
452 | y = index/width; | |||
449 | cluster.resize(0); |
|
453 | cluster.resize(0); | |
450 | this->buildCluster(x,y,dx,dy,cluster); |
|
454 | this->buildCluster(x,y,dx,dy,cluster); | |
451 | if(strategy == QColorMapSeries::LastPixel) |
|
455 | if(strategy == QColorMapSeries::LastPixel) | |
452 | *cell=this->clusterStrategyLast(cluster); |
|
456 | *cell=this->clusterStrategyLast(cluster); | |
453 | else if(strategy == QColorMapSeries::MeanPixel) |
|
457 | else if(strategy == QColorMapSeries::MeanPixel) | |
454 | *cell=this->clusterStrategyMean(cluster); |
|
458 | *cell=this->clusterStrategyMean(cluster); | |
455 | else if(strategy == QColorMapSeries::MedianPixel) |
|
459 | else if(strategy == QColorMapSeries::MedianPixel) | |
456 | *cell=this->clusterStrategyMedian(cluster); |
|
460 | *cell=this->clusterStrategyMedian(cluster); | |
457 | if(x<width-1) |
|
461 | index++; | |
458 | { |
|
|||
459 | x++; |
|
|||
460 |
|
|
462 | } | |
461 | else |
|
463 | ||
|
464 | //#pragma omp for | |||
|
465 | // for(int y = 0;y<height;y++) | |||
|
466 | // { | |||
|
467 | // for(int x =0;x<width;x++) | |||
|
468 | // { | |||
|
469 | // cluster.resize(0); | |||
|
470 | // this->buildCluster(x,y,dx,dy,cluster); | |||
|
471 | // if(strategy == QColorMapSeries::LastPixel) | |||
|
472 | // grid[width*y+x] = this->clusterStrategyLast(cluster); | |||
|
473 | // else if(strategy == QColorMapSeries::MeanPixel) | |||
|
474 | // grid[width*y+x] = this->clusterStrategyMean(cluster); | |||
|
475 | // else if(strategy == QColorMapSeries::MedianPixel) | |||
|
476 | // grid[width*y+x] = this->clusterStrategyMedian(cluster); | |||
|
477 | // } | |||
|
478 | // } | |||
|
479 | } | |||
|
480 | ||||
|
481 | double QColorMapSeriesPrivate::computeValuePixel() | |||
462 | { |
|
482 | { | |
463 | x=0; |
|
483 | ||
464 | y++; |
|
484 | ||
465 | } |
|
|||
466 | } |
|
|||
467 | } |
|
485 | } | |
468 |
|
486 | |||
469 | /*! |
|
487 | /*! | |
470 | Recompute the data range on X, Y and Z axes each time a ColorMapDataPart is added to the series.\n |
|
488 | Recompute the data range on X, Y and Z axes each time a ColorMapDataPart is added to the series.\n | |
471 | The minimum distance between 2 adjacent values on X and Y axis is added to the maximum on X and Y respectively\n |
|
489 | The minimum distance between 2 adjacent values on X and Y axis is added to the maximum on X and Y respectively\n | |
472 | in order to take account of the width of the last element. |
|
490 | in order to take account of the width of the last element. | |
473 | */ |
|
491 | */ | |
474 | void QColorMapSeriesPrivate::recomputeDataRange() |
|
492 | void QColorMapSeriesPrivate::recomputeDataRange() | |
475 | { |
|
493 | { | |
476 | //TODO : if non empty |
|
494 | //TODO : if non empty | |
477 | m_minX = m_dataParts.first()->timesSeries().first(); |
|
495 | m_minX = m_dataParts.first()->timesSeries().first(); | |
478 | m_maxX = m_dataParts.last()->timesSeries().last(); |
|
496 | m_maxX = m_dataParts.last()->timesSeries().last(); | |
479 |
|
497 | |||
480 | m_minY = m_dataParts.last()->ySeries().last(); |
|
498 | m_minY = m_dataParts.last()->ySeries().last(); | |
481 | m_maxY = m_dataParts.last()->ySeries().first(); |
|
499 | m_maxY = m_dataParts.last()->ySeries().first(); | |
482 | m_minZ = m_dataParts.first()->dataSeries().first(); |
|
500 | m_minZ = m_dataParts.first()->dataSeries().first(); | |
483 | m_maxZ = m_dataParts.last()->dataSeries().last(); |
|
501 | m_maxZ = m_dataParts.last()->dataSeries().last(); | |
484 | double minDeltaX=m_maxX-m_minX; |
|
502 | double minDeltaX=m_maxX-m_minX; | |
485 | double minDeltaY=m_minY-m_maxY; |
|
503 | double minDeltaY=m_minY-m_maxY; | |
486 | foreach(ColorMapDataPart* datapart, m_dataParts) |
|
504 | foreach(ColorMapDataPart* datapart, m_dataParts) | |
487 | { |
|
505 | { | |
488 | m_minY = qMin(datapart->ySeries().first(),m_minY); |
|
506 | m_minY = qMin(datapart->ySeries().first(),m_minY); | |
489 | m_maxY = qMax(datapart->ySeries().last(),m_maxY); |
|
507 | m_maxY = qMax(datapart->ySeries().last(),m_maxY); | |
490 | for(int i=1;i<datapart->timesSeries().size();i++) |
|
508 | for(int i=1;i<datapart->timesSeries().size();i++) | |
491 | { |
|
509 | { | |
492 | double newDeltaX=datapart->timesSeries()[i]-datapart->timesSeries()[i-1]; |
|
510 | double newDeltaX=datapart->timesSeries()[i]-datapart->timesSeries()[i-1]; | |
493 | minDeltaX=qMin(minDeltaX,newDeltaX); |
|
511 | minDeltaX=qMin(minDeltaX,newDeltaX); | |
494 | } |
|
512 | } | |
495 | for(int i=1;i<datapart->ySeries().size();i++) |
|
513 | for(int i=1;i<datapart->ySeries().size();i++) | |
496 | { |
|
514 | { | |
497 | double newDeltaY=datapart->ySeries()[i]-datapart->ySeries()[i-1]; |
|
515 | double newDeltaY=datapart->ySeries()[i]-datapart->ySeries()[i-1]; | |
498 | minDeltaY=qMin(minDeltaY,newDeltaY); |
|
516 | minDeltaY=qMin(minDeltaY,newDeltaY); | |
499 | } |
|
517 | } | |
500 |
|
518 | |||
501 | for (int i = 0; i < datapart->dataSeries().count(); i++) |
|
519 | for (int i = 0; i < datapart->dataSeries().count(); i++) | |
502 | { |
|
520 | { | |
503 | double z = datapart->dataSeries().at(i); |
|
521 | double z = datapart->dataSeries().at(i); | |
504 | m_minZ = qMin(m_minZ, z); |
|
522 | m_minZ = qMin(m_minZ, z); | |
505 | m_maxZ = qMax(m_maxZ, z); |
|
523 | m_maxZ = qMax(m_maxZ, z); | |
506 | } |
|
524 | } | |
507 | } |
|
525 | } | |
508 | m_maxX+=minDeltaX; |
|
526 | m_maxX+=minDeltaX; | |
509 | m_maxY+=minDeltaY; |
|
527 | m_maxY+=minDeltaY; | |
510 | } |
|
528 | } | |
511 |
|
529 | |||
512 | /*! |
|
530 | /*! | |
513 | Returns the last value (bottom right Z value) of a \a cluster of points passed as argument. |
|
531 | Returns the last value (bottom right Z value) of a \a cluster of points passed as argument. | |
514 | */ |
|
532 | */ | |
515 | double QColorMapSeriesPrivate::clusterStrategyLast(QVector<Point3D>& cluster) |
|
533 | double QColorMapSeriesPrivate::clusterStrategyLast(QVector<Point3D>& cluster) | |
516 | { |
|
534 | { | |
517 | if(!cluster.isEmpty()) |
|
535 | if(!cluster.isEmpty()) | |
518 | return cluster.last().value(); |
|
536 | return cluster.last().value(); | |
519 | return 0; |
|
537 | return 0; | |
520 | } |
|
538 | } | |
521 |
|
539 | |||
522 | /*! |
|
540 | /*! | |
523 | Returns the mean value (mean Z value) of a \a cluster of points passed as argument. |
|
541 | Returns the mean value (mean Z value) of a \a cluster of points passed as argument. | |
524 | */ |
|
542 | */ | |
525 | double QColorMapSeriesPrivate::clusterStrategyMean(QVector<Point3D>& cluster) |
|
543 | double QColorMapSeriesPrivate::clusterStrategyMean(QVector<Point3D>& cluster) | |
526 | { |
|
544 | { | |
527 | if(!cluster.isEmpty()) |
|
545 | if(!cluster.isEmpty()) | |
528 | { |
|
546 | { | |
529 | double sum=0; |
|
547 | double sum=0; | |
530 | int count =0; |
|
548 | int count =0; | |
531 | for(int i =0;i<cluster.size();i++) |
|
549 | for(int i =0;i<cluster.size();i++) | |
532 | { |
|
550 | { | |
533 | if(!isnan(Point3D(cluster.at(i)).value())) |
|
551 | if(!isnan(Point3D(cluster.at(i)).value())) | |
534 | { |
|
552 | { | |
535 | sum+= Point3D(cluster.at(i)).value(); |
|
553 | sum+= Point3D(cluster.at(i)).value(); | |
536 | count++; |
|
554 | count++; | |
537 | } |
|
555 | } | |
538 | } |
|
556 | } | |
539 | return (sum/count); |
|
557 | return (sum/count); | |
540 | } |
|
558 | } | |
541 | return 0; |
|
559 | return 0; | |
542 | } |
|
560 | } | |
543 |
|
561 | |||
544 | /*! |
|
562 | /*! | |
545 | Returns the median value (median Z value) of a \a cluster of points passed as argument. |
|
563 | Returns the median value (median Z value) of a \a cluster of points passed as argument. | |
546 | */ |
|
564 | */ | |
547 | double QColorMapSeriesPrivate::clusterStrategyMedian(QVector<Point3D>& cluster) |
|
565 | double QColorMapSeriesPrivate::clusterStrategyMedian(QVector<Point3D>& cluster) | |
548 | { |
|
566 | { | |
549 | if(!cluster.isEmpty()) |
|
567 | if(!cluster.isEmpty()) | |
550 | { |
|
568 | { | |
551 | QVector<double> *copy = new QVector<double>(); |
|
569 | QVector<double> *copy = new QVector<double>(); | |
552 |
|
570 | |||
553 | for(int i =0;i<cluster.size();i++) |
|
571 | for(int i =0;i<cluster.size();i++) | |
554 | { |
|
572 | { | |
555 | if(!isnan(Point3D(cluster.at(i)).value())) |
|
573 | if(!isnan(Point3D(cluster.at(i)).value())) | |
556 | copy->append(Point3D(cluster.at(i)).value()); |
|
574 | copy->append(Point3D(cluster.at(i)).value()); | |
557 | } |
|
575 | } | |
558 |
|
576 | |||
559 | if(!copy->isEmpty()) |
|
577 | if(!copy->isEmpty()) | |
560 | { |
|
578 | { | |
561 | std::sort(copy->begin(), copy->end()); |
|
579 | std::sort(copy->begin(), copy->end()); | |
562 |
|
580 | |||
563 | if(copy->count() & 1) // odd |
|
581 | if(copy->count() & 1) // odd | |
564 | { |
|
582 | { | |
565 | int middle = (copy->count()+1)/2; |
|
583 | int middle = (copy->count()+1)/2; | |
566 | return copy->at(middle-1); |
|
584 | return copy->at(middle-1); | |
567 | } |
|
585 | } | |
568 | else //even |
|
586 | else //even | |
569 | { |
|
587 | { | |
570 | int middle = copy->count()/2; |
|
588 | int middle = copy->count()/2; | |
571 | return (copy->at(middle-1)+copy->at(middle))/2; |
|
589 | return (copy->at(middle-1)+copy->at(middle))/2; | |
572 | } |
|
590 | } | |
573 | } |
|
591 | } | |
574 | } |
|
592 | } | |
575 | return 0; |
|
593 | return 0; | |
576 | } |
|
594 | } | |
577 |
|
595 | |||
578 | /*! |
|
596 | /*! | |
579 | Computes which data points correspond to the given position and returns the in a \a cluster. |
|
597 | Computes which data points correspond to the given position and returns the in a \a cluster. | |
580 | */ |
|
598 | */ | |
581 | void QColorMapSeriesPrivate::buildCluster(int xpos, int ypos, double dx, double dy, QVector<Point3D>& cluster) |
|
599 | void QColorMapSeriesPrivate::buildCluster(int xpos, int ypos, double dx, double dy, QVector<Point3D>& cluster) | |
582 | { |
|
600 | { | |
583 | foreach(ColorMapDataPart *dataPart, m_dataParts) |
|
601 | foreach(ColorMapDataPart *dataPart, m_dataParts) | |
584 | { |
|
602 | { | |
585 | QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(xpos+1)*dx); |
|
603 | QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(xpos+1)*dx); | |
586 | QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_maxY-(ypos+1)*dy,m_maxY-ypos*dy); |
|
604 | QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_maxY-(ypos+1)*dy,m_maxY-ypos*dy); | |
587 |
|
605 | |||
588 | int timeSeriesSize = dataPart->timesSeries().size(); |
|
606 | int timeSeriesSize = dataPart->timesSeries().size(); | |
589 |
|
607 | |||
590 | if(xRange.first != xRange.second && yRange.first != yRange.second) |
|
608 | if(xRange.first != xRange.second && yRange.first != yRange.second) | |
591 | { |
|
609 | { | |
592 | for(int i =xRange.first+1;i<xRange.second;i++) |
|
610 | for(int i =xRange.first+1;i<xRange.second;i++) | |
593 | { |
|
611 | { | |
594 | qreal xval=dataPart->timesSeries()[i]; |
|
612 | qreal xval=dataPart->timesSeries()[i]; | |
595 | for(int j=yRange.first+1;j<yRange.second;j++) |
|
613 | for(int j=yRange.first+1;j<yRange.second;j++) | |
596 | { |
|
614 | { | |
597 | qreal yval=dataPart->ySeries()[j]; |
|
615 | qreal yval=dataPart->ySeries()[j]; | |
598 | qreal val=dataPart->dataSeries()[ i + (timeSeriesSize * j)]; |
|
616 | qreal val=dataPart->dataSeries()[ i + (timeSeriesSize * j)]; | |
599 | cluster.append(Point3D(xval,yval,val)); |
|
617 | cluster.append(Point3D(xval,yval,val)); | |
600 | } |
|
618 | } | |
601 | } |
|
619 | } | |
602 | } |
|
620 | } | |
603 | } |
|
621 | } | |
604 | } |
|
622 | } | |
605 |
|
623 | |||
606 |
|
624 | |||
607 | void QColorMapSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options, |
|
625 | void QColorMapSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options, | |
608 | int duration, QEasingCurve &curve) |
|
626 | int duration, QEasingCurve &curve) | |
609 | { |
|
627 | { | |
610 | // ColorMapChart *item = static_cast<ColorMapChart *>(m_item.data()); |
|
628 | // ColorMapChart *item = static_cast<ColorMapChart *>(m_item.data()); | |
611 | // Q_ASSERT(item); |
|
629 | // Q_ASSERT(item); | |
612 | // if (item->animation()) |
|
630 | // if (item->animation()) | |
613 | // item->animation()->stopAndDestroyLater(); |
|
631 | // item->animation()->stopAndDestroyLater(); | |
614 |
|
632 | |||
615 | // if (options.testFlag(QChart::SeriesAnimations)) |
|
633 | // if (options.testFlag(QChart::SeriesAnimations)) | |
616 | // item->setAnimation(new XYAnimation(item, duration, curve)); |
|
634 | // item->setAnimation(new XYAnimation(item, duration, curve)); | |
617 | // else |
|
635 | // else | |
618 | // item->setAnimation(0); |
|
636 | // item->setAnimation(0); | |
619 | QAbstractSeriesPrivate::initializeAnimations(options, duration, curve); |
|
637 | QAbstractSeriesPrivate::initializeAnimations(options, duration, curve); | |
620 | } |
|
638 | } | |
621 |
|
639 | |||
622 |
|
640 | |||
623 |
|
641 | |||
624 | #include "moc_qcolormapseries.cpp" |
|
642 | #include "moc_qcolormapseries.cpp" | |
625 | #include "moc_qcolormapseries_p.cpp" |
|
643 | #include "moc_qcolormapseries_p.cpp" | |
626 |
|
644 | |||
627 | QT_CHARTS_END_NAMESPACE |
|
645 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now