@@ -40,22 +40,25 int main(int argc, char *argv[]) | |||||
40 | QApplication a(argc, argv); |
|
40 | QApplication a(argc, argv); | |
41 |
|
41 | |||
42 | QVector<double> *xSeries = new QVector<double>(); |
|
42 | QVector<double> *xSeries = new QVector<double>(); | |
|
43 | xSeries->reserve(1028); | |||
43 | for(int i=0;i<1028;i++) |
|
44 | for(int i=0;i<1028;i++) | |
44 | { |
|
45 | { | |
45 |
xSeries->append(i |
|
46 | xSeries->append(i); | |
46 | } |
|
47 | } | |
47 | QVector<double> *ySeries = new QVector<double>(); |
|
48 | QVector<double> *ySeries = new QVector<double>(); | |
|
49 | ySeries->reserve(768); | |||
48 | for(int i=0;i<768;i++) |
|
50 | for(int i=0;i<768;i++) | |
49 | { |
|
51 | { | |
50 |
ySeries->append(i |
|
52 | ySeries->append(i); | |
51 | } |
|
53 | } | |
52 | QVector<double> *zSeries = new QVector<double>(); |
|
54 | QVector<double> *zSeries = new QVector<double>(); | |
|
55 | zSeries->reserve(1028*768); | |||
53 | for(int i=0;i<1028*768;i++) |
|
56 | for(int i=0;i<1028*768;i++) | |
54 | { |
|
57 | { | |
55 |
|
|
58 | // if(i%2 != 1) | |
56 |
|
|
59 | // zSeries->append(0); | |
57 |
|
|
60 | // else | |
58 |
|
|
61 | // zSeries->append(1); | |
59 | zSeries->append(i); |
|
62 | zSeries->append(i); | |
60 | } |
|
63 | } | |
61 |
|
64 | |||
@@ -79,6 +82,5 int main(int argc, char *argv[]) | |||||
79 | window.resize(100-77, 100-53); |
|
82 | window.resize(100-77, 100-53); | |
80 | window.show(); |
|
83 | window.show(); | |
81 |
|
84 | |||
82 |
|
||||
83 | return a.exec(); |
|
85 | return a.exec(); | |
84 | } |
|
86 | } |
@@ -10,10 +10,12 | |||||
10 |
|
10 | |||
11 | QT_CHARTS_BEGIN_NAMESPACE |
|
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 | : VerticalAxis(axis, item), |
|
14 | : VerticalAxis(axis, item), | |
15 | m_axis(axis), |
|
15 | m_axis(axis), | |
16 | m_gradient(gradient) |
|
16 | m_gradient(gradient), | |
|
17 | m_position(pos), | |||
|
18 | m_height(height) | |||
17 | { |
|
19 | { | |
18 | QObject::connect(m_axis, SIGNAL(tickCountChanged(int)), this, SLOT(handleTickCountChanged(int))); |
|
20 | QObject::connect(m_axis, SIGNAL(tickCountChanged(int)), this, SLOT(handleTickCountChanged(int))); | |
19 | QObject::connect(m_axis, SIGNAL(minorTickCountChanged(int)), |
|
21 | QObject::connect(m_axis, SIGNAL(minorTickCountChanged(int)), | |
@@ -94,7 +96,7 QSizeF ChartColorBarAxisY::sizeHint(Qt:: | |||||
94 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
96 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), | |
95 | QStringLiteral("..."), |
|
97 | QStringLiteral("..."), | |
96 | axis()->labelsAngle()); |
|
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 | height = boundingRect.height() / 2.0; |
|
100 | height = boundingRect.height() / 2.0; | |
99 | sh = QSizeF(width, height); |
|
101 | sh = QSizeF(width, height); | |
100 | break; |
|
102 | break; | |
@@ -109,7 +111,7 QSizeF ChartColorBarAxisY::sizeHint(Qt:: | |||||
109 | if (firstHeight < 0.0) |
|
111 | if (firstHeight < 0.0) | |
110 | firstHeight = height; |
|
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 | height = qMax(height, firstHeight) / 2.0; |
|
115 | height = qMax(height, firstHeight) / 2.0; | |
114 | sh = QSizeF(width, height); |
|
116 | sh = QSizeF(width, height); | |
115 | break; |
|
117 | break; | |
@@ -122,23 +124,25 QSizeF ChartColorBarAxisY::sizeHint(Qt:: | |||||
122 |
|
124 | |||
123 | void ChartColorBarAxisY::createColorBar() |
|
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 | foreach(QGradientStop stop, stops) |
|
132 | foreach(QGradientStop stop, stops) | |
129 | { |
|
133 | { | |
130 | gradient.setColorAt(1-stop.first,stop.second); |
|
134 | gradient.setColorAt(1-stop.first,stop.second); | |
131 | } |
|
135 | } | |
132 |
|
136 | |||
133 | QPixmap image = QPixmap(50,250); |
|
137 | //colorbar | |
134 | QPainter painter(&image); |
|
138 | QRectF rect(m_position.x(),m_position.y(),m_height/20,m_height); | |
135 | QRectF rect(0,0,50,250); |
|
|||
136 | painter.fillRect(rect,gradient); |
|
|||
137 |
|
139 | |||
138 | QGraphicsRectItem *colorbar = new QGraphicsRectItem(rect, this); |
|
140 | QGraphicsRectItem *colorbar = new QGraphicsRectItem(rect, this); | |
|
141 | colorbar->setZValue(ChartPresenter::AxisZValue); | |||
|
142 | colorbar->setBrush(gradient); | |||
139 | setGraphicsItem(colorbar); |
|
143 | setGraphicsItem(colorbar); | |
140 | } |
|
144 | } | |
141 |
|
145 | |||
142 | #include "moc_chartcolorbaraxisy_p.cpp" |
|
146 | #include "moc_chartcolorbaraxisy_p.cpp" | |
143 |
|
147 | |||
144 | QT_CHARTS_END_NAMESPACE |
|
148 | QT_CHARTS_END_NAMESPACE |
@@ -12,7 +12,7 class ChartColorBarAxisY : public Vertic | |||||
12 | { |
|
12 | { | |
13 | Q_OBJECT |
|
13 | Q_OBJECT | |
14 | public: |
|
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 | ~ChartColorBarAxisY(); |
|
16 | ~ChartColorBarAxisY(); | |
17 |
|
17 | |||
18 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; |
|
18 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; | |
@@ -32,6 +32,8 private Q_SLOTS: | |||||
32 | private: |
|
32 | private: | |
33 | QColorBarAxis *m_axis; |
|
33 | QColorBarAxis *m_axis; | |
34 | QLinearGradient m_gradient; |
|
34 | QLinearGradient m_gradient; | |
|
35 | QPoint m_position; | |||
|
36 | qreal m_height; | |||
35 | }; |
|
37 | }; | |
36 |
|
38 | |||
37 | QT_CHARTS_END_NAMESPACE |
|
39 | QT_CHARTS_END_NAMESPACE |
@@ -18,10 +18,10 QT_CHARTS_BEGIN_NAMESPACE | |||||
18 | /*! |
|
18 | /*! | |
19 | Constructs an axis object which is a child of \a parent. |
|
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) : |
|
21 | QColorBarAxis::QColorBarAxis(QRectF plotArea, QLinearGradient gradient, qreal min, qreal max, QObject *parent) : | |
22 | QAbstractAxis(*new QColorBarAxisPrivate(gradient, min, max, this), parent) |
|
22 | QAbstractAxis(*new QColorBarAxisPrivate(plotArea, gradient, min, max, this), parent) | |
23 | { |
|
23 | { | |
24 |
|
24 | setGridLineVisible(false); | ||
25 | } |
|
25 | } | |
26 |
|
26 | |||
27 | /*! |
|
27 | /*! | |
@@ -130,14 +130,15 QAbstractAxis::AxisType QColorBarAxis::t | |||||
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 | : QAbstractAxisPrivate(q), |
|
134 | : QAbstractAxisPrivate(q), | |
|
135 | m_plotArea(plotArea), | |||
135 | m_min(min), |
|
136 | m_min(min), | |
136 | m_max(max), |
|
137 | m_max(max), | |
137 |
|
|
138 | m_tickCount(5), | |
138 |
|
|
139 | m_minorTickCount(0), | |
139 | m_format(QString::null), |
|
140 | m_format(QString::null), | |
140 | // m_applying(false) |
|
141 | // m_applying(false) | |
141 | m_gradient(gradient) |
|
142 | m_gradient(gradient) | |
142 | { |
|
143 | { | |
143 |
|
144 | |||
@@ -155,7 +156,14 void QColorBarAxisPrivate::initializeGra | |||||
155 |
|
156 | |||
156 | setAlignment(Qt::AlignRight); //also set orientation (Vertical in this case) |
|
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 | m_item.reset(axis); |
|
168 | m_item.reset(axis); | |
161 | QAbstractAxisPrivate::initializeGraphics(parent); |
|
169 | QAbstractAxisPrivate::initializeGraphics(parent); | |
@@ -165,12 +173,12 void QColorBarAxisPrivate::initializeDom | |||||
165 | { |
|
173 | { | |
166 | //domain is not supposed to have a rangeZ |
|
174 | //domain is not supposed to have a rangeZ | |
167 |
|
175 | |||
168 | // if (orientation() == Qt::Vertical) { |
|
176 | // if (orientation() == Qt::Vertical) { | |
169 | // if (!qFuzzyIsNull(m_max - m_min)) |
|
177 | // if (!qFuzzyIsNull(m_max - m_min)) | |
170 | // domain->setRangeY(m_min, m_max); |
|
178 | // domain->setRangeY(m_min, m_max); | |
171 | // else |
|
179 | // else | |
172 | // setRange(domain->minY(), domain->maxY()); |
|
180 | // setRange(domain->minY(), domain->maxY()); | |
173 | // } |
|
181 | // } | |
174 | } |
|
182 | } | |
175 |
|
183 | |||
176 | void QColorBarAxisPrivate::setMin(const QVariant &min) |
|
184 | void QColorBarAxisPrivate::setMin(const QVariant &min) |
@@ -11,7 +11,7 class QT_CHARTS_EXPORT QColorBarAxis : p | |||||
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 | public: |
|
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 | ~QColorBarAxis(); |
|
15 | ~QColorBarAxis(); | |
16 |
|
16 | |||
17 | protected: |
|
17 | protected: |
@@ -11,7 +11,7 class QColorBarAxisPrivate : public QAbs | |||||
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 | public: |
|
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 | ~QColorBarAxisPrivate(); |
|
15 | ~QColorBarAxisPrivate(); | |
16 |
|
16 | |||
17 | public: |
|
17 | public: | |
@@ -35,6 +35,7 private: | |||||
35 | QString m_format; |
|
35 | QString m_format; | |
36 | // bool m_applying; |
|
36 | // bool m_applying; | |
37 | QLinearGradient m_gradient; |
|
37 | QLinearGradient m_gradient; | |
|
38 | QRectF m_plotArea; | |||
38 | Q_DECLARE_PUBLIC(QColorBarAxis) |
|
39 | Q_DECLARE_PUBLIC(QColorBarAxis) | |
39 | }; |
|
40 | }; | |
40 |
|
41 |
@@ -7,9 +7,6 | |||||
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> |
|
10 | #include <QRgb> | |
14 |
|
11 | |||
15 | #define nbOfColors 65000 |
|
12 | #define nbOfColors 65000 | |
@@ -56,6 +53,10 void ColorMapChart::paint(QPainter *pain | |||||
56 | Q_UNUSED(widget) |
|
53 | Q_UNUSED(widget) | |
57 | Q_UNUSED(option) |
|
54 | Q_UNUSED(option) | |
58 |
|
55 | |||
|
56 | m_series->setUseOpenGL(); | |||
|
57 | ||||
|
58 | painter->save(); | |||
|
59 | ||||
59 | QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); |
|
60 | QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); | |
60 | painter->setClipRect(clipRect); |
|
61 | painter->setClipRect(clipRect); | |
61 |
|
62 | |||
@@ -64,37 +65,54 void ColorMapChart::paint(QPainter *pain | |||||
64 | //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 | //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 | colorMapImage.fill(QColor(Qt::white).rgb()); |
|
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 | double maxZ = m_series->maxZ(); |
|
76 | double maxZ = m_series->maxZ(); | |
70 | double minZ = m_series->minZ(); |
|
77 | double minZ = m_series->minZ(); | |
71 | double rangeZ = maxZ - minZ; |
|
78 | double rangeZ = maxZ - minZ; | |
72 |
|
79 | |||
73 |
|
|
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< |
|
85 | for(int j=0;j<imageHeight;j++) | |
76 | { |
|
86 | { | |
77 |
double value = grid-> |
|
87 | double value = grid->at(i+j*(imageWidth)); | |
78 | double pix=((value-minZ)/rangeZ); |
|
88 | double pix=((value-minZ)/rangeZ); | |
79 | int indexInColorTable = pix*(nbOfColors-1); |
|
89 | int indexInColorTable = pix*(nbOfColors-1); | |
80 | colorMapImage.setPixel(i,j,m_colorTable->at(indexInColorTable)); |
|
90 | colorMapImage.setPixel(i,j,m_colorTable->at(indexInColorTable)); | |
81 | } |
|
91 | } | |
82 | } |
|
92 | } | |
83 |
|
93 | |||
84 | if(!m_colorbar) |
|
94 | addColorBar(plotAreaRect); | |
85 | addColorBar(); |
|
95 | ||
86 |
|
96 | |||
87 | painter->drawImage(clipRect,colorMapImage); |
|
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 | double maxZ = m_series->maxZ(); |
|
107 | double maxZ = m_series->maxZ(); | |
94 | double minZ = m_series->minZ(); |
|
108 | double minZ = m_series->minZ(); | |
95 | QColorBarAxis *colorbar = new QColorBarAxis(createColorMapGradient(m_gradientType),minZ, maxZ,this); |
|
109 | ||
96 | m_series->chart()->addAxis(colorbar, Qt::AlignRight); |
|
110 | if(m_isColorBarDrawn) | |
97 | m_colorbar = true; |
|
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 | /*! |
@@ -7,6 +7,9 | |||||
7 | #include <QtCharts/QValueAxis> |
|
7 | #include <QtCharts/QValueAxis> | |
8 | #include <QtGui/QPen> |
|
8 | #include <QtGui/QPen> | |
9 |
|
9 | |||
|
10 | //#include <QtCharts/QColorBarAxis> TODO : fix this | |||
|
11 | #include "qcolorbaraxis.h" | |||
|
12 | ||||
10 | QT_CHARTS_BEGIN_NAMESPACE |
|
13 | QT_CHARTS_BEGIN_NAMESPACE | |
11 |
|
14 | |||
12 | class ChartPresenter; |
|
15 | class ChartPresenter; | |
@@ -56,7 +59,7 Q_SIGNALS: | |||||
56 |
|
59 | |||
57 | private: |
|
60 | private: | |
58 | inline bool isEmpty(); |
|
61 | inline bool isEmpty(); | |
59 | void addColorBar(); |
|
62 | void addColorBar(QRectF plotAreaRect); | |
60 | QLinearGradient createColorMapGradient(GradientType gradientType); |
|
63 | QLinearGradient createColorMapGradient(GradientType gradientType); | |
61 | void changeGradient(GradientType gradientType); |
|
64 | void changeGradient(GradientType gradientType); | |
62 |
|
65 | |||
@@ -67,7 +70,8 protected: | |||||
67 | bool m_dirty; |
|
70 | bool m_dirty; | |
68 | QVector<QRgb> *m_colorTable; |
|
71 | QVector<QRgb> *m_colorTable; | |
69 | GradientType m_gradientType; |
|
72 | GradientType m_gradientType; | |
70 |
bool m_ |
|
73 | bool m_isColorBarDrawn; | |
|
74 | QColorBarAxis *m_colorbar; | |||
71 | }; |
|
75 | }; | |
72 |
|
76 | |||
73 | //class PixmapMarker: public QGraphicsRectItem |
|
77 | //class PixmapMarker: public QGraphicsRectItem |
@@ -120,7 +120,7 QColorMapSeries &QColorMapSeries::operat | |||||
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 |
|
|
123 | QVector<double> *QColorMapSeries::getUniformGrid(int xpos, int ypos,int width, int height, QColorMapSeries::Strategy strategy) | |
124 | { |
|
124 | { | |
125 | Q_D(QColorMapSeries); |
|
125 | Q_D(QColorMapSeries); | |
126 | return d->getUniformGrid(xpos, ypos,width,height, strategy); |
|
126 | return d->getUniformGrid(xpos, ypos,width,height, strategy); | |
@@ -433,14 +433,9 QAbstractAxis* QColorMapSeriesPrivate::c | |||||
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 |
|
435 | |||
436 |
|
|
436 | QVector<double> *QColorMapSeriesPrivate::getUniformGrid(int xpos, int ypos, int width, int height, QColorMapSeries::Strategy strategy) | |
437 | { |
|
437 | { | |
438 |
|
|
438 | QVector<double> *grid = new QVector<double>(width*height); | |
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); |
|
|||
444 |
|
439 | |||
445 | double dx = (m_maxX - m_minX)/(double)width; |
|
440 | double dx = (m_maxX - m_minX)/(double)width; | |
446 | double dy = (m_maxY - m_minY)/(double)height; |
|
441 | double dy = (m_maxY - m_minY)/(double)height; | |
@@ -448,15 +443,12 ColorMapDataPart *QColorMapSeriesPrivate | |||||
448 | int x=0; |
|
443 | int x=0; | |
449 | int y=0; |
|
444 | int y=0; | |
450 |
|
445 | |||
451 | for(int i=0;i<width;i++) //width-1? |
|
446 | QVector<Point3D> cluster; | |
452 | { |
|
447 | cluster.reserve(height*width/1000); | |
453 | timeSeries->append((double)i); |
|
|||
454 | } |
|
|||
455 |
|
448 | |||
456 |
|
449 | for (auto cell= grid->begin();cell<grid->end();++cell) | ||
457 | for (auto cell= dataSeries->begin();cell<dataSeries->end();++cell) |
|
|||
458 | { |
|
450 | { | |
459 | QVector<Point3D> cluster; |
|
451 | cluster.resize(0); | |
460 | this->buildCluster(x,y,dx,dy,cluster); |
|
452 | this->buildCluster(x,y,dx,dy,cluster); | |
461 | if(strategy == QColorMapSeries::LastPixel) |
|
453 | if(strategy == QColorMapSeries::LastPixel) | |
462 | *cell=this->clusterStrategyLast(cluster); |
|
454 | *cell=this->clusterStrategyLast(cluster); | |
@@ -471,11 +463,10 ColorMapDataPart *QColorMapSeriesPrivate | |||||
471 | else |
|
463 | else | |
472 | { |
|
464 | { | |
473 | x=0; |
|
465 | x=0; | |
474 | ySeries->append((double)y); |
|
|||
475 | y++; |
|
466 | y++; | |
476 |
|
||||
477 | } |
|
467 | } | |
478 | } |
|
468 | } | |
|
469 | ||||
479 | return grid; |
|
470 | return grid; | |
480 | } |
|
471 | } | |
481 |
|
472 | |||
@@ -598,6 +589,8 void QColorMapSeriesPrivate::buildClust | |||||
598 | QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(xpos+1)*dx); |
|
589 | QPair<int,int> xRange = dataPart->getRange(dataPart->timesSeries(),m_minX+xpos*dx,m_minX+(xpos+1)*dx); | |
599 | QPair<int,int> yRange = dataPart->getRange(dataPart->ySeries(),m_maxY-(ypos+1)*dy,m_maxY-ypos*dy); |
|
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 | if(xRange.first != xRange.second && yRange.first != yRange.second) |
|
594 | if(xRange.first != xRange.second && yRange.first != yRange.second) | |
602 | { |
|
595 | { | |
603 | for(int i =xRange.first+1;i<xRange.second;i++) |
|
596 | for(int i =xRange.first+1;i<xRange.second;i++) | |
@@ -606,7 +599,7 void QColorMapSeriesPrivate::buildClust | |||||
606 | for(int j=yRange.first+1;j<yRange.second;j++) |
|
599 | for(int j=yRange.first+1;j<yRange.second;j++) | |
607 | { |
|
600 | { | |
608 | qreal yval=dataPart->ySeries()[j]; |
|
601 | qreal yval=dataPart->ySeries()[j]; | |
609 |
qreal val=dataPart->dataSeries()[ i + ( |
|
602 | qreal val=dataPart->dataSeries()[ i + (timeSeriesSize * j)]; | |
610 | cluster.append(Point3D(xval,yval,val)); |
|
603 | cluster.append(Point3D(xval,yval,val)); | |
611 | } |
|
604 | } | |
612 | } |
|
605 | } |
@@ -48,8 +48,8 public : | |||||
48 | QColorMapSeries &operator << (const ColorMapDataPart &dataPart); |
|
48 | QColorMapSeries &operator << (const ColorMapDataPart &dataPart); | |
49 | QColorMapSeries &operator << (const QList<ColorMapDataPart *> &dataParts); |
|
49 | QColorMapSeries &operator << (const QList<ColorMapDataPart *> &dataParts); | |
50 |
|
50 | |||
51 |
|
|
51 | QVector<double> *getUniformGrid(int xpos, int ypos,int width, int height, Strategy strategy); | |
52 | //double getUniformGrid(int width, int height, Strategy lambda); |
|
52 | // QVector<double> *getUniformGrid(int width, int height, Strategy lambda); | |
53 |
|
53 | |||
54 | // virtual void attachAxis(QAbstractAxis *axis); |
|
54 | // virtual void attachAxis(QAbstractAxis *axis); | |
55 |
|
55 |
@@ -31,7 +31,7 public : | |||||
31 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; |
|
31 | QAbstractAxis::AxisType defaultAxisType(Qt::Orientation orientation) const; | |
32 | QAbstractAxis* createDefaultAxis(Qt::Orientation) const; |
|
32 | QAbstractAxis* createDefaultAxis(Qt::Orientation) const; | |
33 |
|
33 | |||
34 |
|
|
34 | QVector<double> *getUniformGrid(int xpos, int ypos,int width, int height, QColorMapSeries::Strategy strategy); | |
35 |
|
35 | |||
36 | Q_SIGNALS: |
|
36 | Q_SIGNALS: | |
37 | void updated(); |
|
37 | void updated(); | |
@@ -55,8 +55,6 private: | |||||
55 | double m_minZ; |
|
55 | double m_minZ; | |
56 | double m_maxZ; |
|
56 | double m_maxZ; | |
57 | void recomputeDataRange(); |
|
57 | void recomputeDataRange(); | |
58 | QPair<int,int> getLastX(double start, double end); |
|
|||
59 | int getLastY(int x,double start, double end); |
|
|||
60 | double clusterStrategyLast(QVector<Point3D>& cluster); |
|
58 | double clusterStrategyLast(QVector<Point3D>& cluster); | |
61 | double clusterStrategyMean(QVector<Point3D> &cluster); |
|
59 | double clusterStrategyMean(QVector<Point3D> &cluster); | |
62 | double clusterStrategyMedian(QVector<Point3D>& cluster); |
|
60 | double clusterStrategyMedian(QVector<Point3D>& cluster); |
General Comments 0
You need to be logged in to leave comments.
Login now