##// END OF EJS Templates
work on color bar axis
winter -
r1:35d010b06810 default draft
parent child
Show More
@@ -0,0 +1,173
1 //#include <QtCharts/QColorBarAxis> // TODO : fix this
2 #include "colorbaraxis/qcolorbaraxis.h"
3 //#include <private/qcolorbaraxis_p.h>
4 #include "colorbaraxis/qcolorbaraxis_p.h"
5 #include <private/abstractdomain_p.h>
6 #include <private/chartdataset_p.h>
7 #include <private/chartpresenter_p.h>
8 #include <private/charttheme_p.h>
9
10 #include <QtGui>
11
12 QT_CHARTS_BEGIN_NAMESPACE
13
14
15 /*!
16 Constructs an axis object which is a child of \a parent.
17 */
18 QColorBarAxis::QColorBarAxis(QLinearGradient gradient, qreal min, qreal max,QObject *parent) :
19 QAbstractAxis(*new QColorBarAxisPrivate(gradient, min, max, this), parent)
20 {
21
22 }
23
24 /*!
25 \internal
26 */
27 QColorBarAxis::QColorBarAxis(QColorBarAxisPrivate &d, QObject *parent)
28 : QAbstractAxis(d, parent)
29 {
30
31 }
32
33 /*!
34 Destroys the object
35 */
36 QColorBarAxis::~QColorBarAxis()
37 {
38 Q_D(QColorBarAxis);
39 if (d->m_chart)
40 d->m_chart->removeAxis(this);
41 }
42
43 qreal QColorBarAxis::min() const
44 {
45 Q_D(const QColorBarAxis);
46 return d->m_min;
47 }
48
49 qreal QColorBarAxis::max() const
50 {
51 Q_D(const QColorBarAxis);
52 return d->m_max;
53 }
54
55
56 //void QColorBarAxis::setTickCount(int count)
57 //{
58 // Q_D(QColorBarAxis);
59 // if (d->m_tickCount != count && count >= 2) {
60 // d->m_tickCount = count;
61 // emit tickCountChanged(count);
62 // }
63 //}
64
65 //int QColorBarAxis::tickCount() const
66 //{
67 // Q_D(const QColorBarAxis);
68 // return d->m_tickCount;
69 //}
70
71 //void QColorBarAxis::setMinorTickCount(int count)
72 //{
73 // Q_D(QColorBarAxis);
74 // if (d->m_minorTickCount != count && count >= 0) {
75 // d->m_minorTickCount = count;
76 // emit minorTickCountChanged(count);
77 // }
78 //}
79
80 //int QColorBarAxis::minorTickCount() const
81 //{
82 // Q_D(const QColorBarAxis);
83 // return d->m_minorTickCount;
84 //}
85
86 void QColorBarAxis::setLabelFormat(const QString &format)
87 {
88 Q_D(QColorBarAxis);
89 d->m_format = format;
90 emit labelFormatChanged(format);
91 }
92
93 QString QColorBarAxis::labelFormat() const
94 {
95 Q_D(const QColorBarAxis);
96 return d->m_format;
97 }
98
99 /*!
100 Returns the type of the axis
101 */
102 QAbstractAxis::AxisType QColorBarAxis::type() const
103 {
104 return AxisTypeValue;
105 //TODO : AxisTypeColorBar
106 }
107
108 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
109
110 QColorBarAxisPrivate::QColorBarAxisPrivate(QLinearGradient gradient, qreal min, qreal max, QColorBarAxis *q)
111 : QAbstractAxisPrivate(q),
112 m_min(min),
113 m_max(max),
114 // m_tickCount(5),
115 // m_minorTickCount(0),
116 m_format(QString::null),
117 // m_applying(false)
118 m_gradient(gradient)
119 {
120
121 }
122
123 QColorBarAxisPrivate::~QColorBarAxisPrivate()
124 {
125
126 }
127
128 void QColorBarAxisPrivate::initializeGraphics(QGraphicsItem *parent)
129 {
130 Q_Q(QColorBarAxis);
131 ChartAxisElement *axis(0);
132
133 setAlignment(Qt::AlignRight); //also set orientation (Vertical in this case)
134
135 QGradientStops stops = m_gradient.stops();
136
137 QLinearGradient gradient(0,0,1,250);
138 foreach(QGradientStop stop, stops)
139 {
140 gradient.setColorAt(1-stop.first,stop.second);
141 }
142
143 QPixmap image = QPixmap(50,250);
144 QPainter painter(&image);
145 painter.fillRect(0,0,50,250,gradient);
146
147 //m_item.reset(axis);
148 QAbstractAxisPrivate::initializeGraphics(parent);
149 }
150
151 void QColorBarAxisPrivate::initializeDomain(AbstractDomain *domain)
152 {
153 //domain is not supposed to have a rangeZ
154
155 // if (orientation() == Qt::Vertical) {
156 // if (!qFuzzyIsNull(m_max - m_min))
157 // domain->setRangeY(m_min, m_max);
158 // else
159 // setRange(domain->minY(), domain->maxY());
160 // }
161 // if (orientation() == Qt::Horizontal) {
162 // if (!qFuzzyIsNull(m_max - m_min))
163 // domain->setRangeX(m_min, m_max);
164 // else
165 // setRange(domain->minX(), domain->maxX());
166 // }
167 }
168
169
170 #include "moc_qcolorbaraxis.cpp"
171 #include "moc_qcolorbaraxis_p.cpp"
172
173 QT_CHARTS_END_NAMESPACE
@@ -0,0 +1,51
1 #ifndef QCOLORBARAXIS_H
2 #define QCOLORBARAXIS_H
3
4 #include <QtCharts/QAbstractAxis>
5
6 QT_CHARTS_BEGIN_NAMESPACE
7
8 class QColorBarAxisPrivate;
9
10 class QT_CHARTS_EXPORT QColorBarAxis : public QAbstractAxis
11 {
12 Q_OBJECT
13 public:
14 explicit QColorBarAxis(QLinearGradient gradient, qreal min, qreal max,QObject *parent = 0);
15 ~QColorBarAxis();
16
17 protected:
18 QColorBarAxis(QColorBarAxisPrivate &d, QObject *parent = 0);
19
20 public:
21 AxisType type() const;
22
23 //range handling
24 qreal min() const;
25 qreal max() const;
26
27 //ticks handling
28 // void setTickCount(int count);
29 // int tickCount() const;
30 // void setMinorTickCount(int count);
31 // int minorTickCount() const;
32
33 void setLabelFormat(const QString &format);
34 QString labelFormat() const;
35
36 Q_SIGNALS:
37 void minChanged(qreal min);
38 void maxChanged(qreal max);
39 void rangeChanged(qreal min, qreal max);
40 // void tickCountChanged(int tickCount);
41 // void minorTickCountChanged(int tickCount);
42 void labelFormatChanged(const QString &format);
43
44 private:
45 Q_DECLARE_PRIVATE(QColorBarAxis)
46 Q_DISABLE_COPY(QColorBarAxis)
47 };
48
49 QT_CHARTS_END_NAMESPACE
50
51 #endif // QCOLORBARAXIS_H
@@ -0,0 +1,41
1 #ifndef QCOLORBARAXIS_P_H
2 #define QCOLORBARAXIS_P_H
3
4 //#include <QtCharts/QColorBarAxis> //TODO : fix this
5 #include "colorbaraxis/qcolorbaraxis.h"
6 #include <private/qabstractaxis_p.h>
7
8 QT_CHARTS_BEGIN_NAMESPACE
9
10 class QColorBarAxisPrivate : public QAbstractAxisPrivate
11 {
12 Q_OBJECT
13 public:
14 QColorBarAxisPrivate(QLinearGradient gradient, qreal min, qreal max,QColorBarAxis *q);
15 ~QColorBarAxisPrivate();
16
17 public:
18 void initializeGraphics(QGraphicsItem* parent);
19 void initializeDomain(AbstractDomain *domain);
20
21 qreal min() { return m_min; }
22 qreal max() { return m_max; }
23 void setRange(qreal min,qreal max);
24
25 protected:
26 void setMin(const QVariant &min);
27 void setMax(const QVariant &max);
28 void setRange(const QVariant &min, const QVariant &max);
29
30 private:
31 qreal m_min;
32 qreal m_max;
33 // int m_tickCount;
34 // int m_minorTickCount;
35 QString m_format;
36 // bool m_applying;
37 QLinearGradient m_gradient;
38 Q_DECLARE_PUBLIC(QColorBarAxis)
39 };
40
41 #endif // QCOLORBARAXIS_P_H
@@ -4,13 +4,15 INCLUDEPATH += $$PWD \
4 $$PWD/valueaxis \
4 $$PWD/valueaxis \
5 $$PWD/barcategoryaxis \
5 $$PWD/barcategoryaxis \
6 $$PWD/categoryaxis \
6 $$PWD/categoryaxis \
7 $$PWD/logvalueaxis
7 $$PWD/logvalueaxis \
8 $$PWD/colorbaraxis
8
9
9 DEPENDPATH += $$PWD \
10 DEPENDPATH += $$PWD \
10 $$PWD/valueaxis \
11 $$PWD/valueaxis \
11 $$PWD/barcategoryaxis \
12 $$PWD/barcategoryaxis \
12 $$PWD/categoryaxis \
13 $$PWD/categoryaxis \
13 $$PWD/logvalueaxis
14 $$PWD/logvalueaxis \
15 $$PWD/colorbaraxis
14
16
15 SOURCES += \
17 SOURCES += \
16 $$PWD/chartaxiselement.cpp \
18 $$PWD/chartaxiselement.cpp \
@@ -29,7 +31,8 SOURCES += \
29 $$PWD/categoryaxis/qcategoryaxis.cpp \
31 $$PWD/categoryaxis/qcategoryaxis.cpp \
30 $$PWD/logvalueaxis/chartlogvalueaxisx.cpp \
32 $$PWD/logvalueaxis/chartlogvalueaxisx.cpp \
31 $$PWD/logvalueaxis/chartlogvalueaxisy.cpp \
33 $$PWD/logvalueaxis/chartlogvalueaxisy.cpp \
32 $$PWD/logvalueaxis/qlogvalueaxis.cpp
34 $$PWD/logvalueaxis/qlogvalueaxis.cpp \
35 $$PWD/colorbaraxis/qcolorbaraxis.cpp
33
36
34 PRIVATE_HEADERS += \
37 PRIVATE_HEADERS += \
35 $$PWD/chartaxiselement_p.h \
38 $$PWD/chartaxiselement_p.h \
@@ -49,7 +52,8 PRIVATE_HEADERS += \
49 $$PWD/categoryaxis/qcategoryaxis_p.h \
52 $$PWD/categoryaxis/qcategoryaxis_p.h \
50 $$PWD/logvalueaxis/chartlogvalueaxisx_p.h \
53 $$PWD/logvalueaxis/chartlogvalueaxisx_p.h \
51 $$PWD/logvalueaxis/chartlogvalueaxisy_p.h \
54 $$PWD/logvalueaxis/chartlogvalueaxisy_p.h \
52 $$PWD/logvalueaxis/qlogvalueaxis_p.h
55 $$PWD/logvalueaxis/qlogvalueaxis_p.h \
56 $$PWD/colorbaraxis/qcolorbaraxis_p.h
53
57
54 PUBLIC_HEADERS += \
58 PUBLIC_HEADERS += \
55 $$PWD/qabstractaxis.h \
59 $$PWD/qabstractaxis.h \
@@ -57,6 +61,7 PUBLIC_HEADERS += \
57 $$PWD/barcategoryaxis/qbarcategoryaxis.h \
61 $$PWD/barcategoryaxis/qbarcategoryaxis.h \
58 $$PWD/categoryaxis/qcategoryaxis.h \
62 $$PWD/categoryaxis/qcategoryaxis.h \
59 $$PWD/logvalueaxis/qlogvalueaxis.h \
63 $$PWD/logvalueaxis/qlogvalueaxis.h \
64 $$PWD/colorbaraxis/qcolorbaraxis.h
60
65
61 # polar
66 # polar
62 SOURCES += \
67 SOURCES += \
@@ -106,3 +111,5 PUBLIC_HEADERS += \
106 $$PWD/datetimeaxis/qdatetimeaxis.h
111 $$PWD/datetimeaxis/qdatetimeaxis.h
107 }
112 }
108
113
114
115
@@ -7,13 +7,20
7 #include <private/qabstractaxis_p.h>
7 #include <private/qabstractaxis_p.h>
8 #include <QtGui/QPainter>
8 #include <QtGui/QPainter>
9
9
10 //#include <QtCharts/QColorBarAxis> TODO : fix this
11 #include "qcolorbaraxis.h"
12
13 #include <QRgb>
14
15 #define nbOfColors 65000
10
16
11 QT_CHARTS_BEGIN_NAMESPACE
17 QT_CHARTS_BEGIN_NAMESPACE
12
18
13 ColorMapChart::ColorMapChart(QColorMapSeries *series, QGraphicsItem *item)
19 ColorMapChart::ColorMapChart(QColorMapSeries *series, QGraphicsItem *item)
14 : ChartItem(series->d_func(), item),
20 : ChartItem(series->d_func(), item),
15 m_series(series),
21 m_series(series),
16 m_dirty(true)
22 m_dirty(true),
23 m_gradientType(Rainbow)
17 {
24 {
18 // QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int)));
25 // QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int)));
19 // QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced()));
26 // QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced()));
@@ -26,9 +33,11 ColorMapChart::ColorMapChart(QColorMapSe
26 // QObject::connect(this, SIGNAL(released(Point3D)), series, SIGNAL(released(Point3D)));
33 // QObject::connect(this, SIGNAL(released(Point3D)), series, SIGNAL(released(Point3D)));
27 // QObject::connect(this, SIGNAL(doubleClicked(Point3D)), series, SIGNAL(doubleClicked(Point3D)));
34 // QObject::connect(this, SIGNAL(doubleClicked(Point3D)), series, SIGNAL(doubleClicked(Point3D)));
28
35
29 m_abscissTable = new QMap<int, int>() ;
36 connect(this,SIGNAL(gradientTypeChanged()), this, SLOT(populateColorTable()));
30 m_ordinateTable = new QMap<int, int>() ;
37
31 m_coordinateToColorTable = new QMap<QPair<int, int>,uint>();
38 m_colorTable = new QVector<QRgb>();
39 m_colorTable->reserve(nbOfColors);
40 populateColorTable();
32 }
41 }
33
42
34 void ColorMapChart::setDirty(bool dirty)
43 void ColorMapChart::setDirty(bool dirty)
@@ -45,10 +54,6 void ColorMapChart::paint(QPainter *pain
45 {
54 {
46 Q_UNUSED(widget)
55 Q_UNUSED(widget)
47 Q_UNUSED(option)
56 Q_UNUSED(option)
48 static double debug=0.0;
49 m_coordinateToColorTable->clear();
50 m_abscissTable->clear();
51 m_ordinateTable->clear();
52
57
53 QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
58 QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
54 painter->setClipRect(clipRect);
59 painter->setClipRect(clipRect);
@@ -58,52 +63,28 void ColorMapChart::paint(QPainter *pain
58 //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.
63 //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.
59 colorMapImage.fill(QColor(Qt::white).rgb());
64 colorMapImage.fill(QColor(Qt::white).rgb());
60
65
61 ColorMapDataPart * grid = m_series->getUniformGrid(0,0,plotAreaRect.width(),plotAreaRect.height(),QColorMapSeries::MeanPixel);
66 ColorMapDataPart * grid = m_series->getUniformGrid(0,0,plotAreaRect.width(),plotAreaRect.height(),QColorMapSeries::LastPixel);
62
63
64
67
65 double maxZ = m_series->maxZ();
68 double maxZ = m_series->maxZ();
66 double minZ = m_series->minZ();
69 double minZ = m_series->minZ();
67 double rangeZ = maxZ - minZ;
70 double rangeZ = maxZ - minZ;
68
71
69 QLinearGradient gradient = createColorMapGradient(Rainbow);
70 QGradientStops colorStops = gradient.stops();
71 QVector<QRgb> *values = new QVector<QRgb>();
72
73 for(int i=0;i<colorMapImage.width();i++)
72 for(int i=0;i<colorMapImage.width();i++)
74 {
73 {
75 for(int j=0;j<colorMapImage.height();j++)
74 for(int j=0;j<colorMapImage.height();j++)
76 {
75 {
77 double value = grid->dataSeries().at(i+j*colorMapImage.width());
76 double value = grid->dataSeries().at(i+j*(colorMapImage.width()));
78 double pix=((value-minZ)/rangeZ);
77 double pix=((value-minZ)/rangeZ);
79 for(int k =0;k<colorStops.size()-1;k++)
78 int indexInColorTable = pix*(nbOfColors-1);
80 {
79 colorMapImage.setPixel(i,j,m_colorTable->at(indexInColorTable));
81 QGradientStop lowerBound = colorStops.at(k);
82 QGradientStop upperBound = colorStops.at(k+1);
83 if(pix >= lowerBound.first && pix < upperBound.first)
84 {
85 double ratio = (pix-lowerBound.first)/(upperBound.first - lowerBound.first);
86 int red = (int)(ratio*lowerBound.second.red() + (1-ratio)*upperBound.second.red());
87 int green = (int)(ratio*lowerBound.second.green() + (1-ratio)*upperBound.second.green());
88 int blue = (int)(ratio*lowerBound.second.blue() + (1-ratio)*upperBound.second.blue());
89 colorMapImage.setPixel(i,j,qRgb(red, green, blue));
90 values->append(qRgb(red, green, blue));
91 break;
92 }
93 else
94 {
95 if(k==colorStops.size()-2)
96 {
97 colorMapImage.setPixel(i,j,qRgb(colorStops.at(colorStops.size()-1).second.red(), colorStops.at(colorStops.size()-1).second.green(), colorStops.at(colorStops.size()-1).second.blue()));
98 values->append(qRgb(colorStops.at(colorStops.size()-1).second.red(), colorStops.at(colorStops.size()-1).second.green(), colorStops.at(colorStops.size()-1).second.blue()));
99 }
100 }
101 }
102 }
80 }
103 }
81 }
104 painter->drawImage(clipRect,colorMapImage);
82 painter->drawImage(clipRect,colorMapImage);
105 update();
83 update();
106
84
85 QColorBarAxis *colorbar = new QColorBarAxis(createColorMapGradient(m_gradientType),minZ, maxZ,this);
86
87 m_series->chart()->addAxis(colorbar, Qt::AlignRight);
107 }
88 }
108
89
109 /*!
90 /*!
@@ -130,17 +111,66 QLinearGradient ColorMapChart::createCol
130 gradient.setColorAt(0.2,Qt::blue);
111 gradient.setColorAt(0.2,Qt::blue);
131 gradient.setColorAt(0.0,Qt::magenta);
112 gradient.setColorAt(0.0,Qt::magenta);
132 break;
113 break;
133 case Grey :
114 case BlackAndWhite :
134 gradient.setColorAt(1.0, Qt::black);
115 gradient.setColorAt(1.0, Qt::black);
135 gradient.setColorAt(0.0, Qt::white);
116 gradient.setColorAt(0.0, Qt::white);
136 break;
117 break;
118 case ReverseBlackAndWhite :
119 gradient.setColorAt(1.0, Qt::white);
120 gradient.setColorAt(0.0, Qt::black);
121 break;
137 default:
122 default:
138 break;
123 break;
139 }
124 }
140 return gradient;
125 return gradient;
126 }
127
128 /*!
129 Changes the type of gradient used to paint the ColorMap.
130 */
131 void ColorMapChart::changeGradient(GradientType gradientType)
132 {
133 if(m_gradientType == gradientType)
134 return;
135 else
136 m_gradientType = gradientType;
137 emit gradientTypeChanged();
141 }
138 }
142
139
140 /*!
141 Creates a color table corresponding to the gradient type currently selected.
142 */
143 void ColorMapChart::populateColorTable()
144 {
145 QLinearGradient gradient = createColorMapGradient(m_gradientType);
146 QGradientStops colorStops = gradient.stops();
143
147
148 for(int i=0;i<nbOfColors;i++)
149 {
150 double colorIndex = (double)i/nbOfColors;
151 for(int k =0;k<colorStops.size()-1;k++)
152 {
153 QGradientStop lowerBound = colorStops.at(k);
154 QGradientStop upperBound = colorStops.at(k+1);
155 if(colorIndex >= lowerBound.first && colorIndex < upperBound.first)
156 {
157 double ratio = (colorIndex-lowerBound.first)/(upperBound.first - lowerBound.first);
158 int red = (int)((1-ratio)*lowerBound.second.red() + ratio*upperBound.second.red());
159 int green = (int)((1-ratio)*lowerBound.second.green() + ratio*upperBound.second.green());
160 int blue = (int)((1-ratio)*lowerBound.second.blue() + ratio*upperBound.second.blue());
161 m_colorTable->append(qRgb(red, green, blue));
162 break;
163 }
164 else
165 {
166 if(k==colorStops.size()-2)
167 {
168 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()));
169 }
170 }
171 }
172 }
173 }
144
174
145
175
146 //handlers
176 //handlers
@@ -21,7 +21,8 public:
21 {
21 {
22 Rainbow,
22 Rainbow,
23 CyclingRainbow,
23 CyclingRainbow,
24 Grey
24 BlackAndWhite,
25 ReverseBlackAndWhite
25 };
26 };
26
27
27 explicit ColorMapChart(QColorMapSeries *series,QGraphicsItem *item = 0);
28 explicit ColorMapChart(QColorMapSeries *series,QGraphicsItem *item = 0);
@@ -42,26 +43,29 public Q_SLOTS:
42 void handlePointsReplaced();
43 void handlePointsReplaced();
43 void handleDomainUpdated();
44 void handleDomainUpdated();
44
45
46 private slots :
47 void populateColorTable();
48
45 Q_SIGNALS:
49 Q_SIGNALS:
46 void clicked(const Point3D &point);
50 void clicked(const Point3D &point);
47 void hovered(const Point3D &point, bool state);
51 void hovered(const Point3D &point, bool state);
48 void pressed(const Point3D &point);
52 void pressed(const Point3D &point);
49 void released(const Point3D &point);
53 void released(const Point3D &point);
50 void doubleClicked(const Point3D &point);
54 void doubleClicked(const Point3D &point);
55 void gradientTypeChanged();
51
56
52 private:
57 private:
53 inline bool isEmpty();
58 inline bool isEmpty();
54 QLinearGradient createColorMapGradient(GradientType gradientType);
59 QLinearGradient createColorMapGradient(GradientType gradientType);
60 void changeGradient(GradientType gradientType);
55
61
56 protected:
62 protected:
57 QColorMapSeries *m_series;
63 QColorMapSeries *m_series;
58 QVector<Point3D> m_points;
64 QVector<Point3D> m_points;
59 QRectF m_rect;
65 QRectF m_rect;
60 bool m_dirty;
66 bool m_dirty;
61 QMap<int, int> *m_abscissTable;
67 QVector<QRgb> *m_colorTable;
62 QMap<int, int> *m_ordinateTable;
68 GradientType m_gradientType;
63 QMap<QPair<int, int>,uint> *m_coordinateToColorTable;
64
65 };
69 };
66
70
67 //class PixmapMarker: public QGraphicsRectItem
71 //class PixmapMarker: public QGraphicsRectItem
@@ -438,6 +438,7 ColorMapDataPart *QColorMapSeriesPrivate
438 timeSeries->append((double)i);
438 timeSeries->append((double)i);
439 }
439 }
440
440
441
441 for (auto cell= dataSeries->begin();cell<dataSeries->end();++cell)
442 for (auto cell= dataSeries->begin();cell<dataSeries->end();++cell)
442 {
443 {
443 QVector<Point3D> cluster;
444 QVector<Point3D> cluster;
@@ -576,48 +577,48 double QColorMapSeriesPrivate::clusterSt
576 /*!
577 /*!
577 Computes which data points correspond to the given position and returns the in a \a cluster.
578 Computes which data points correspond to the given position and returns the in a \a cluster.
578 */
579 */
579 void QColorMapSeriesPrivate::buildCluster(int xpos, int ypos, double dx, double dy, QVector<Point3D>& cluster)
580 void QColorMapSeriesPrivate::buildCluster(int xpos, int ypos, double dx, double dy, QVector<Point3D>& cluster)
581 {
582 foreach(ColorMapDataPart *dataPart, m_dataParts)
580 {
583 {
581 foreach(ColorMapDataPart *dataPart, m_dataParts)
584 QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(xpos+1)*dx);
585 QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_maxY-(ypos+1)*dy,m_maxY-ypos*dy);
586
587 if(xRange.first != xRange.second && yRange.first != yRange.second)
582 {
588 {
583 QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(double)(xpos+1)*dx);
589 for(int i =xRange.first+1;i<xRange.second;i++)
584 QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_minY+ypos*dy,m_minY+(double)(ypos+1)*dy);
585
586 if(xRange.first != xRange.second && yRange.first != yRange.second)
587 {
590 {
588 for(int i =xRange.first+1;i<xRange.second;i++)
591 qreal xval=dataPart->timesSeries()[i];
592 for(int j=yRange.first+1;j<yRange.second;j++)
589 {
593 {
590 qreal xval=dataPart->timesSeries()[i];
594 qreal yval=dataPart->ySeries()[j];
591 for(int j=yRange.first+1;j<yRange.second;j++)
595 qreal val=dataPart->dataSeries()[ i + (dataPart->timesSeries().size() * j)];
592 {
596 cluster.append(Point3D(xval,yval,val));
593 qreal yval=dataPart->ySeries()[j];
594 qreal val=dataPart->dataSeries()[ i + (dataPart->timesSeries().size() * j)];
595 cluster.append(Point3D(xval,yval,val));
596 }
597 }
597 }
598 }
598 }
599 }
599 }
600 }
600 }
601 }
601
602
602
603
603 void QColorMapSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options,
604 void QColorMapSeriesPrivate::initializeAnimations(QtCharts::QChart::AnimationOptions options,
604 int duration, QEasingCurve &curve)
605 int duration, QEasingCurve &curve)
605 {
606 {
606 // ColorMapChart *item = static_cast<ColorMapChart *>(m_item.data());
607 // ColorMapChart *item = static_cast<ColorMapChart *>(m_item.data());
607 // Q_ASSERT(item);
608 // Q_ASSERT(item);
608 // if (item->animation())
609 // if (item->animation())
609 // item->animation()->stopAndDestroyLater();
610 // item->animation()->stopAndDestroyLater();
610
611
611 // if (options.testFlag(QChart::SeriesAnimations))
612 // if (options.testFlag(QChart::SeriesAnimations))
612 // item->setAnimation(new XYAnimation(item, duration, curve));
613 // item->setAnimation(new XYAnimation(item, duration, curve));
613 // else
614 // else
614 // item->setAnimation(0);
615 // item->setAnimation(0);
615 QAbstractSeriesPrivate::initializeAnimations(options, duration, curve);
616 QAbstractSeriesPrivate::initializeAnimations(options, duration, curve);
616 }
617 }
617
618
618
619
619
620
620 #include "moc_qcolormapseries.cpp"
621 #include "moc_qcolormapseries.cpp"
621 #include "moc_qcolormapseries_p.cpp"
622 #include "moc_qcolormapseries_p.cpp"
622
623
623 QT_CHARTS_END_NAMESPACE
624 QT_CHARTS_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now