@@ -110,10 +110,16 void AreaChartItem::updatePath() | |||||
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | path.closeSubpath(); |
|
112 | path.closeSubpath(); | |
113 | prepareGeometryChange(); |
|
113 | ||
114 | m_path = path; |
|
114 | // Only zoom in if the bounding rect of the path fits inside int limits. QWidget::update() uses | |
115 | m_rect = path.boundingRect(); |
|
115 | // a region that has to be compatible with QRect. | |
116 | update(); |
|
116 | if (path.boundingRect().height() <= INT_MAX | |
|
117 | && path.boundingRect().width() <= INT_MAX) { | |||
|
118 | prepareGeometryChange(); | |||
|
119 | m_path = path; | |||
|
120 | m_rect = path.boundingRect(); | |||
|
121 | update(); | |||
|
122 | } | |||
117 | } |
|
123 | } | |
118 |
|
124 | |||
119 | void AreaChartItem::handleUpdated() |
|
125 | void AreaChartItem::handleUpdated() |
@@ -276,13 +276,26 void LineChartItem::updateGeometry() | |||||
276 | stroker.setCapStyle(Qt::SquareCap); |
|
276 | stroker.setCapStyle(Qt::SquareCap); | |
277 | stroker.setMiterLimit(m_linePen.miterLimit()); |
|
277 | stroker.setMiterLimit(m_linePen.miterLimit()); | |
278 |
|
278 | |||
279 | prepareGeometryChange(); |
|
279 | QPainterPath checkShapePath = stroker.createStroke(fullPath); | |
|
280 | ||||
|
281 | // Only zoom in if the bounding rects of the paths fit inside int limits. QWidget::update() uses | |||
|
282 | // a region that has to be compatible with QRect. | |||
|
283 | if (checkShapePath.boundingRect().height() <= INT_MAX | |||
|
284 | && checkShapePath.boundingRect().width() <= INT_MAX | |||
|
285 | && linePath.boundingRect().height() <= INT_MAX | |||
|
286 | && linePath.boundingRect().width() <= INT_MAX | |||
|
287 | && fullPath.boundingRect().height() <= INT_MAX | |||
|
288 | && fullPath.boundingRect().width() <= INT_MAX) { | |||
|
289 | prepareGeometryChange(); | |||
280 |
|
290 | |||
281 | m_linePath = linePath; |
|
291 | m_linePath = linePath; | |
282 | m_fullPath = fullPath; |
|
292 | m_fullPath = fullPath; | |
283 | m_shapePath = stroker.createStroke(fullPath); |
|
293 | m_shapePath = checkShapePath; | |
284 |
|
294 | |||
285 | m_rect = m_shapePath.boundingRect(); |
|
295 | m_rect = m_shapePath.boundingRect(); | |
|
296 | } else { | |||
|
297 | update(); | |||
|
298 | } | |||
286 | } |
|
299 | } | |
287 |
|
300 | |||
288 | void LineChartItem::handleUpdated() |
|
301 | void LineChartItem::handleUpdated() |
@@ -126,31 +126,36 void ScatterChartItem::updateGeometry() | |||||
126 |
|
126 | |||
127 | QRectF clipRect(QPointF(0,0),domain()->size()); |
|
127 | QRectF clipRect(QPointF(0,0),domain()->size()); | |
128 |
|
128 | |||
129 | QVector<bool> offGridStatus = offGridStatusVector(); |
|
129 | // Only zoom in if the clipRect fits inside int limits. QWidget::update() uses | |
130 | const int seriesLastIndex = m_series->count() - 1; |
|
130 | // a region that has to be compatible with QRect. | |
131 |
|
131 | if (clipRect.height() <= INT_MAX | ||
132 | for (int i = 0; i < points.size(); i++) { |
|
132 | && clipRect.width() <= INT_MAX) { | |
133 | QGraphicsItem *item = items.at(i); |
|
133 | QVector<bool> offGridStatus = offGridStatusVector(); | |
134 | const QPointF &point = points.at(i); |
|
134 | const int seriesLastIndex = m_series->count() - 1; | |
135 | const QRectF &rect = item->boundingRect(); |
|
135 | ||
136 | // During remove animation series may have different number of points, |
|
136 | for (int i = 0; i < points.size(); i++) { | |
137 | // so ensure we don't go over the index. Animation handling itself ensures that |
|
137 | QGraphicsItem *item = items.at(i); | |
138 | // if there is actually no points in the series, then it won't generate a fake point, |
|
138 | const QPointF &point = points.at(i); | |
139 | // so we can be assured there is always at least one point in m_series here. |
|
139 | const QRectF &rect = item->boundingRect(); | |
140 | // Note that marker map values can be technically incorrect during the animation, |
|
140 | // During remove animation series may have different number of points, | |
141 | // if it was caused by an insert, but this shouldn't be a problem as the points are |
|
141 | // so ensure we don't go over the index. Animation handling itself ensures that | |
142 | // fake anyway. After remove animation stops, geometry is updated to correct one. |
|
142 | // if there is actually no points in the series, then it won't generate a fake point, | |
143 | m_markerMap[item] = m_series->at(qMin(seriesLastIndex, i)); |
|
143 | // so we can be assured there is always at least one point in m_series here. | |
144 | item->setPos(point.x() - rect.width() / 2, point.y() - rect.height() / 2); |
|
144 | // Note that marker map values can be technically incorrect during the animation, | |
145 |
|
145 | // if it was caused by an insert, but this shouldn't be a problem as the points are | ||
146 | if (!m_visible || offGridStatus.at(i)) |
|
146 | // fake anyway. After remove animation stops, geometry is updated to correct one. | |
147 | item->setVisible(false); |
|
147 | m_markerMap[item] = m_series->at(qMin(seriesLastIndex, i)); | |
148 | else |
|
148 | item->setPos(point.x() - rect.width() / 2, point.y() - rect.height() / 2); | |
149 | item->setVisible(true); |
|
149 | ||
150 | } |
|
150 | if (!m_visible || offGridStatus.at(i)) | |
|
151 | item->setVisible(false); | |||
|
152 | else | |||
|
153 | item->setVisible(true); | |||
|
154 | } | |||
151 |
|
155 | |||
152 | prepareGeometryChange(); |
|
156 | prepareGeometryChange(); | |
153 | m_rect = clipRect; |
|
157 | m_rect = clipRect; | |
|
158 | } | |||
154 | } |
|
159 | } | |
155 |
|
160 | |||
156 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
161 | void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
@@ -267,7 +267,6 void SplineChartItem::updateGeometry() | |||||
267 | } |
|
267 | } | |
268 | fullPath = splinePath; |
|
268 | fullPath = splinePath; | |
269 | } |
|
269 | } | |
270 | m_path = splinePath; |
|
|||
271 |
|
270 | |||
272 | QPainterPathStroker stroker; |
|
271 | QPainterPathStroker stroker; | |
273 | // The full path is comprised of three separate paths. |
|
272 | // The full path is comprised of three separate paths. | |
@@ -278,10 +277,20 void SplineChartItem::updateGeometry() | |||||
278 | stroker.setCapStyle(Qt::SquareCap); |
|
277 | stroker.setCapStyle(Qt::SquareCap); | |
279 | stroker.setMiterLimit(m_linePen.miterLimit()); |
|
278 | stroker.setMiterLimit(m_linePen.miterLimit()); | |
280 |
|
279 | |||
281 | prepareGeometryChange(); |
|
280 | // Only zoom in if the bounding rects of the path fit inside int limits. QWidget::update() uses | |
|
281 | // a region that has to be compatible with QRect. | |||
|
282 | QPainterPath checkShapePath = stroker.createStroke(fullPath); | |||
|
283 | if (checkShapePath.boundingRect().height() <= INT_MAX | |||
|
284 | && checkShapePath.boundingRect().width() <= INT_MAX | |||
|
285 | && splinePath.boundingRect().height() <= INT_MAX | |||
|
286 | && splinePath.boundingRect().width() <= INT_MAX) { | |||
|
287 | m_path = splinePath; | |||
282 |
|
288 | |||
283 | m_fullPath = stroker.createStroke(fullPath); |
|
289 | prepareGeometryChange(); | |
284 | m_rect = m_fullPath.boundingRect(); |
|
290 | ||
|
291 | m_fullPath = checkShapePath; | |||
|
292 | m_rect = m_fullPath.boundingRect(); | |||
|
293 | } | |||
285 | } |
|
294 | } | |
286 |
|
295 | |||
287 | /*! |
|
296 | /*! |
General Comments 0
You need to be logged in to leave comments.
Login now