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