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