##// END OF EJS Templates
Fix crash when changing the values to empty model with logarithmic axis...
Miikka Heikkinen -
r2427:b3d485323aa9
parent child
Show More
@@ -1,91 +1,92
1 --------------------------------
1 --------------------------------
2 Commercial Charts Add-on 1.2.1
2 Commercial Charts Add-on 1.2.1
3 --------------------------------
3 --------------------------------
4
4
5 What's in Qt Commercial Charts
5 What's in Qt Commercial Charts
6 =============================
6 =============================
7
7
8 Directory structure:
8 Directory structure:
9
9
10 src/
10 src/
11 Source code of the Qt Commercial Charts
11 Source code of the Qt Commercial Charts
12 plugins/
12 plugins/
13 QML bindings plugin and QtCreator plugin
13 QML bindings plugin and QtCreator plugin
14 examples/
14 examples/
15 Some examples of using Qt Commercial Charts
15 Some examples of using Qt Commercial Charts
16 demos/
16 demos/
17 More versatile example applications showing how to customize charts,
17 More versatile example applications showing how to customize charts,
18 combine several chart types and implement interaction in charts
18 combine several chart types and implement interaction in charts
19 doc/
19 doc/
20 Documentation
20 Documentation
21 licenses/
21 licenses/
22 Licensing information
22 Licensing information
23
23
24 Building
24 Building
25 ========
25 ========
26 Please note that if you have already installed a previous version of
26 Please note that if you have already installed a previous version of
27 QtCommercial Charts, you should first uninstall it with
27 QtCommercial Charts, you should first uninstall it with
28 make uninstall
28 make uninstall
29
29
30 Configure project with qmake and build project with make:
30 Configure project with qmake and build project with make:
31 (Linux) make
31 (Linux) make
32 (Windows with MinGw) mingw32-make
32 (Windows with MinGw) mingw32-make
33 (Visual Studio) nmake
33 (Visual Studio) nmake
34 (OSX) make
34 (OSX) make
35
35
36 For debug builds:
36 For debug builds:
37 qmake CONFIG+=debug; make
37 qmake CONFIG+=debug; make
38 or
38 or
39 qmake CONFIG+=debug_and_release; make debug
39 qmake CONFIG+=debug_and_release; make debug
40
40
41 For release builds:
41 For release builds:
42 qmake CONFIG+=release ; make
42 qmake CONFIG+=release ; make
43 or
43 or
44 qmake CONFIG+=debug_and_release; make release
44 qmake CONFIG+=debug_and_release; make release
45
45
46 For both builds
46 For both builds
47 qmake CONFIG+="debug_and_release build_all"; make
47 qmake CONFIG+="debug_and_release build_all"; make
48
48
49 If you want to install the libraries to your Qt library directory use:
49 If you want to install the libraries to your Qt library directory use:
50 make install
50 make install
51
51
52 If you want to uninstall the libraries
52 If you want to uninstall the libraries
53 make uninstall
53 make uninstall
54
54
55 Building as a statically linked library
55 Building as a statically linked library
56 =======================================
56 =======================================
57
57
58 The same as above applies you will just have to add staticlib to the CONFIG:
58 The same as above applies you will just have to add staticlib to the CONFIG:
59 qmake CONFIG+=staticlib
59 qmake CONFIG+=staticlib
60
60
61 Documentation
61 Documentation
62 =============
62 =============
63 Documentation can be found from doc/html directory. The documentation
63 Documentation can be found from doc/html directory. The documentation
64 can also be generated with:
64 can also be generated with:
65 make docs
65 make docs
66
66
67 Main Changes between 1.2.0 and 1.2.1
67 Main Changes between 1.2.0 and 1.2.1
68 ===================================
68 ===================================
69
69
70 - Commercial Charts documentation also as *.qch file
70 - Commercial Charts documentation also as *.qch file
71
71
72 Bug Fixes
72 Bug Fixes
73 ==========
73 ==========
74 - Fixed: Crash with NaN, inf, -inf values (values are ignored)
74 - Fixed: Crash with NaN, inf, -inf values (values are ignored)
75 - Fixed: Axis label truncated with multiple axis
75 - Fixed: Axis label truncated with multiple axis
76 - Fixed: Using setLineVisible(false) on a QBarCategoryAxis gives blurry text
76 - Fixed: Using setLineVisible(false) on a QBarCategoryAxis gives blurry text
77 - Fixed: Set the range to min and max for default axes from previously added series
77 - Fixed: Set the range to min and max for default axes from previously added series
78 - Fixed: Axes use incorrect bounding rectangle to calculate sizeHint when labels are in non-default angle
78 - Fixed: Axes use incorrect bounding rectangle to calculate sizeHint when labels are in non-default angle
79 - Fixes: Axis titles can slightly overlap with axis labels and axis lines
79 - Fixed: Axis titles can slightly overlap with axis labels and axis lines
80 - Fixed: Charts crashes when changing the values to empty model with logarithmic axis
80
81
81 Known Issues
82 Known Issues
82 ============
83 ============
83 - Automatic scaling of the axes is only done when you add a series on a chart
84 - Automatic scaling of the axes is only done when you add a series on a chart
84 - DateTimeAxis is not supported on ARM because of floating point precision
85 - DateTimeAxis is not supported on ARM because of floating point precision
85 issues (qreals are floats)
86 issues (qreals are floats)
86 - Declarative plugin is available from Qt 4.7.4 onwards because of missing
87 - Declarative plugin is available from Qt 4.7.4 onwards because of missing
87 Q_REVISION macro in the earlier Qt releases
88 Q_REVISION macro in the earlier Qt releases
88 - Defining axis min-max values sometimes affects other axes with the same orientation
89 - Defining axis min-max values sometimes affects other axes with the same orientation
89 - See for example the secondary y-axis of QML Weather demo application
90 - See for example the secondary y-axis of QML Weather demo application
90 - The work-around is to set axis range dynamically instead of initializing min and
91 - The work-around is to set axis range dynamically instead of initializing min and
91 max properties to certain values
92 max properties to certain values
@@ -1,162 +1,160
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "xychart_p.h"
21 #include "xychart_p.h"
22 #include "qxyseries.h"
22 #include "qxyseries.h"
23 #include "qxyseries_p.h"
23 #include "qxyseries_p.h"
24 #include "chartpresenter_p.h"
24 #include "chartpresenter_p.h"
25 #include "abstractdomain_p.h"
25 #include "abstractdomain_p.h"
26 #include "qxymodelmapper.h"
26 #include "qxymodelmapper.h"
27 #include <QPainter>
27 #include <QPainter>
28 #include <QAbstractItemModel>
28 #include <QAbstractItemModel>
29
29
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 //TODO: optimize : remove points which are not visible
33 //TODO: optimize : remove points which are not visible
34
34
35 XYChart::XYChart(QXYSeries *series,QGraphicsItem* item):
35 XYChart::XYChart(QXYSeries *series,QGraphicsItem* item):
36 ChartItem(series->d_func(),item),
36 ChartItem(series->d_func(),item),
37 m_series(series),
37 m_series(series),
38 m_animation(0),
38 m_animation(0),
39 m_dirty(true)
39 m_dirty(true)
40 {
40 {
41 QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int)));
41 QObject::connect(series, SIGNAL(pointReplaced(int)), this, SLOT(handlePointReplaced(int)));
42 QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced()));
42 QObject::connect(series, SIGNAL(pointsReplaced()), this, SLOT(handlePointsReplaced()));
43 QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int)));
43 QObject::connect(series, SIGNAL(pointAdded(int)), this, SLOT(handlePointAdded(int)));
44 QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int)));
44 QObject::connect(series, SIGNAL(pointRemoved(int)), this, SLOT(handlePointRemoved(int)));
45 QObject::connect(this, SIGNAL(clicked(QPointF)), series, SIGNAL(clicked(QPointF)));
45 QObject::connect(this, SIGNAL(clicked(QPointF)), series, SIGNAL(clicked(QPointF)));
46 QObject::connect(this, SIGNAL(hovered(QPointF,bool)), series, SIGNAL(hovered(QPointF,bool)));
46 QObject::connect(this, SIGNAL(hovered(QPointF,bool)), series, SIGNAL(hovered(QPointF,bool)));
47 }
47 }
48
48
49 void XYChart::setGeometryPoints(const QVector<QPointF>& points)
49 void XYChart::setGeometryPoints(const QVector<QPointF>& points)
50 {
50 {
51 m_points = points;
51 m_points = points;
52 }
52 }
53
53
54 void XYChart::setAnimation(XYAnimation *animation)
54 void XYChart::setAnimation(XYAnimation *animation)
55 {
55 {
56 m_animation = animation;
56 m_animation = animation;
57 }
57 }
58
58
59 void XYChart::setDirty(bool dirty)
59 void XYChart::setDirty(bool dirty)
60 {
60 {
61 m_dirty = dirty;
61 m_dirty = dirty;
62 }
62 }
63
63
64 void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, int index)
64 void XYChart::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, int index)
65 {
65 {
66
66
67 if (m_animation) {
67 if (m_animation) {
68 m_animation->setup(oldPoints, newPoints, index);
68 m_animation->setup(oldPoints, newPoints, index);
69 m_points = newPoints;
69 m_points = newPoints;
70 setDirty(false);
70 setDirty(false);
71 presenter()->startAnimation(m_animation);
71 presenter()->startAnimation(m_animation);
72 } else {
72 } else {
73 m_points = newPoints;
73 m_points = newPoints;
74 updateGeometry();
74 updateGeometry();
75 }
75 }
76 }
76 }
77
77
78 //handlers
78 //handlers
79
79
80 void XYChart::handlePointAdded(int index)
80 void XYChart::handlePointAdded(int index)
81 {
81 {
82 Q_ASSERT(index < m_series->count());
82 Q_ASSERT(index < m_series->count());
83 Q_ASSERT(index >= 0);
83 Q_ASSERT(index >= 0);
84
84
85 QVector<QPointF> points;
85 QVector<QPointF> points;
86
86
87 if (m_dirty) {
87 if (m_dirty || m_points.isEmpty()) {
88 points = domain()->calculateGeometryPoints(m_series->points());
88 points = domain()->calculateGeometryPoints(m_series->points());
89 } else {
89 } else {
90 points = m_points;
90 points = m_points;
91 QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData);
91 QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData);
92 if (!m_validData) {
92 if (!m_validData)
93 m_points.clear();
93 m_points.clear();
94 return;
94 else
95 }
95 points.insert(index, point);
96 points.insert(index, point);
97 }
96 }
98
97
99 updateChart(m_points, points, index);
98 updateChart(m_points, points, index);
100 }
99 }
101
100
102 void XYChart::handlePointRemoved(int index)
101 void XYChart::handlePointRemoved(int index)
103 {
102 {
104 Q_ASSERT(index <= m_series->count());
103 Q_ASSERT(index <= m_series->count());
105 Q_ASSERT(index >= 0);
104 Q_ASSERT(index >= 0);
106
105
107 QVector<QPointF> points;
106 QVector<QPointF> points;
108
107
109 if (m_dirty) {
108 if (m_dirty || m_points.isEmpty()) {
110 points = domain()->calculateGeometryPoints(m_series->points());
109 points = domain()->calculateGeometryPoints(m_series->points());
111 } else {
110 } else {
112 points = m_points;
111 points = m_points;
113 points.remove(index);
112 points.remove(index);
114 }
113 }
115
114
116 updateChart(m_points, points, index);
115 updateChart(m_points, points, index);
117 }
116 }
118
117
119 void XYChart::handlePointReplaced(int index)
118 void XYChart::handlePointReplaced(int index)
120 {
119 {
121 Q_ASSERT(index < m_series->count());
120 Q_ASSERT(index < m_series->count());
122 Q_ASSERT(index >= 0);
121 Q_ASSERT(index >= 0);
123
122
124 QVector<QPointF> points;
123 QVector<QPointF> points;
125
124
126 if (m_dirty) {
125 if (m_dirty || m_points.isEmpty()) {
127 points = domain()->calculateGeometryPoints(m_series->points());
126 points = domain()->calculateGeometryPoints(m_series->points());
128 } else {
127 } else {
129 QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData);
128 QPointF point = domain()->calculateGeometryPoint(m_series->points()[index], m_validData);
130 if (!m_validData) {
129 if (!m_validData)
131 m_points.clear();
130 m_points.clear();
132 return;
133 }
134 points = m_points;
131 points = m_points;
135 points.replace(index, point);
132 if (m_validData)
133 points.replace(index, point);
136 }
134 }
137
135
138 updateChart(m_points, points, index);
136 updateChart(m_points, points, index);
139 }
137 }
140
138
141 void XYChart::handlePointsReplaced()
139 void XYChart::handlePointsReplaced()
142 {
140 {
143 // All the points were replaced -> recalculate
141 // All the points were replaced -> recalculate
144 QVector<QPointF> points = domain()->calculateGeometryPoints(m_series->points());
142 QVector<QPointF> points = domain()->calculateGeometryPoints(m_series->points());
145 updateChart(m_points, points, -1);
143 updateChart(m_points, points, -1);
146 }
144 }
147
145
148 void XYChart::handleDomainUpdated()
146 void XYChart::handleDomainUpdated()
149 {
147 {
150 if (isEmpty()) return;
148 if (isEmpty()) return;
151 QVector<QPointF> points = domain()->calculateGeometryPoints(m_series->points());
149 QVector<QPointF> points = domain()->calculateGeometryPoints(m_series->points());
152 updateChart(m_points, points);
150 updateChart(m_points, points);
153 }
151 }
154
152
155 bool XYChart::isEmpty()
153 bool XYChart::isEmpty()
156 {
154 {
157 return domain()->isEmpty() || m_series->points().isEmpty();
155 return domain()->isEmpty() || m_series->points().isEmpty();
158 }
156 }
159
157
160 #include "moc_xychart_p.cpp"
158 #include "moc_xychart_p.cpp"
161
159
162 QTCOMMERCIALCHART_END_NAMESPACE
160 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now