##// END OF EJS Templates
Fixed a documentation bug in examples page
Fixed a documentation bug in examples page

File last commit:

r1782:3a2daa7222eb
r2039:48ddf64744c9
Show More
splinechartitem.cpp
171 lines | 4.5 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
Michal Klocek
Refactor xychartitem -> xychart
r1218 **
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Jani Honkonen
Add license headers
r794
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 #include "splinechartitem_p.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "qsplineseries_p.h"
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 #include "chartpresenter_p.h"
Michal Klocek
Refactor animator...
r1735 #include "splineanimation_p.h"
Marek Rosa
Spline working somewhat
r401 #include <QPainter>
Michal Klocek
Refactor xychartitem -> xychart
r1218 #include <QGraphicsSceneMouseEvent>
Marek Rosa
Spline initial
r295
Marek Rosa
Spline working somewhat
r401 QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 SplineChartItem::SplineChartItem(QSplineSeries *series, ChartPresenter *presenter) :
Tero Ahola
Visible property to abstract series
r1342 XYChart(series, presenter),
QGraphicsItem(presenter ? presenter->rootItem() : 0),
m_series(series),
m_pointsVisible(false),
m_animation(0)
Marek Rosa
Spline initial
r295 {
Michal Klocek
Fixes mouse handling in base class of chartseries
r1747 setZValue(ChartPresenter::SplineChartZValue);
Michal Klocek
Adds big fat pimpl to series classes...
r938 QObject::connect(m_series->d_func(),SIGNAL(updated()),this,SLOT(handleUpdated()));
Tero Ahola
Visible property to abstract series
r1342 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 handleUpdated();
Marek Rosa
Spline initial
r295 }
Michal Klocek
Refactor line spline to common xyline...
r465 QRectF SplineChartItem::boundingRect() const
{
return m_rect;
}
Marek Rosa
Spline initial
r295
Michal Klocek
Refactor line spline to common xyline...
r465 QPainterPath SplineChartItem::shape() const
{
return m_path;
}
Marek Rosa
Spline working somewhat
r401
Michal Klocek
Refactors animation handling for xyseries
r1217 void SplineChartItem::setAnimation(SplineAnimation* animation)
{
m_animation=animation;
Michal Klocek
Refactor xychartitem -> xychart
r1218 XYChart::setAnimation(animation);
Michal Klocek
Refactors animation handling for xyseries
r1217 }
Michal Klocek
Refactor animator...
r1735 ChartAnimation* SplineChartItem::animation() const
{
return m_animation;
}
Michal Klocek
Refactors animation handling for xyseries
r1217 void SplineChartItem::setControlGeometryPoints(QVector<QPointF>& points)
{
m_controlPoints=points;
}
QVector<QPointF> SplineChartItem::controlGeometryPoints() const
{
return m_controlPoints;
}
void SplineChartItem::updateChart(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index)
Michal Klocek
Bugfixes for spline vector allocation issues
r1082 {
Michal Klocek
Improves spline interpolation...
r622 QVector<QPointF> controlPoints;
Michal Klocek
Refactors animation handling for xyseries
r1217 if(newPoints.count()>=2) {
Michal Klocek
Bugfixes for spline vector allocation issues
r1082 controlPoints.resize(newPoints.count()*2-2);
}
Michal Klocek
Improves spline interpolation...
r622
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 for (int i = 0; i < newPoints.size() - 1; i++) {
Michal Klocek
Improves spline interpolation...
r622 controlPoints[2*i] = calculateGeometryControlPoint(2 * i);
controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1);
}
Tero Ahola
Minor: extra colons, commented out code
r1782 if (m_animation)
m_animation->setup(oldPoints, newPoints, m_controlPoints, controlPoints, index);
Michal Klocek
Improves spline interpolation...
r622
Tero Ahola
Minor: extra colons, commented out code
r1782 m_points = newPoints;
m_controlPoints = controlPoints;
Michal Klocek
Refactor spline animation handling...
r1770 setDirty(false);
Michal Klocek
Refactors animation handling for xyseries
r1217 if (m_animation) {
Michal Klocek
Refactors axis animation, line animations
r1241 presenter()->startAnimation(m_animation);
Michal Klocek
Refactor spline animation handling...
r1770 } else {
Michal Klocek
Refactors animation handling for xyseries
r1217 updateGeometry();
Michal Klocek
Improves spline interpolation...
r622 }
}
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const
Marek Rosa
Spline working somewhat
r401 {
Michal Klocek
Refactor xychartitem -> xychart
r1218 return XYChart::calculateGeometryPoint(m_series->d_func()->controlPoint(index));
Marek Rosa
Spline with problems
r419 }
Michal Klocek
Refactors animation handling for xyseries
r1217 void SplineChartItem::updateGeometry()
Tero Ahola
Work-around for a bug in Clang compiler
r946 {
Tero Ahola
Minor: extra colons, commented out code
r1782 const QVector<QPointF> &points = m_points;
const QVector<QPointF> &controlPoints = m_controlPoints;
Tero Ahola
Work-around for a bug in Clang compiler
r946
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 if ((points.size()<2) || (controlPoints.size()<2)) {
Michal Klocek
adds QLineAnimation fixes
r1271 prepareGeometryChange();
Marek Rosa
XYSeries model support refactored
r1085 m_path = QPainterPath();
Michal Klocek
adds QLineAnimation fixes
r1271 m_rect = QRect();
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 return;
}
Marek Rosa
Spline somewhat working
r423
Michal Klocek
Improves spline interpolation...
r622 Q_ASSERT(points.count()*2-2 == controlPoints.count());
QPainterPath splinePath(points.at(0));
Marek Rosa
Spline somewhat working
r423
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 for (int i = 0; i < points.size() - 1; i++) {
Marek Rosa
Spline somewhat working
r423 const QPointF& point = points.at(i + 1);
Michal Klocek
Improves spline interpolation...
r622 splinePath.cubicTo(controlPoints[2*i],controlPoints[2 * i + 1],point);
Marek Rosa
Spline somewhat working
r423 }
prepareGeometryChange();
m_path = splinePath;
m_rect = splinePath.boundingRect();
Michal Klocek
Refactor xychartitem -> xychart
r1218 setPos(origin());
Michal Klocek
Refactor line spline to common xyline...
r465 }
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 //handlers
void SplineChartItem::handleUpdated()
{
Tero Ahola
Fixed isVisible implementation in XY series
r1346 setVisible(m_series->isVisible());
Michal Klocek
Adds visible points handling to spline
r580 m_pointsVisible = m_series->pointsVisible();
m_linePen = m_series->pen();
m_pointPen = m_series->pen();
m_pointPen.setWidthF(2*m_pointPen.width());
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 update();
}
//painter
Michal Klocek
Refactor line spline to common xyline...
r465
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Marek Rosa
Spline somewhat working
r423 {
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(widget)
Q_UNUSED(option)
Tero Ahola
Fixed isVisible implementation in XY series
r1346
painter->save();
painter->setClipRect(clipRect());
painter->setPen(m_linePen);
painter->drawPath(m_path);
if (m_pointsVisible) {
painter->setPen(m_pointPen);
painter->drawPoints(geometryPoints());
Michal Klocek
Adds visible points handling to spline
r580 }
Tero Ahola
Fixed isVisible implementation in XY series
r1346 painter->restore();
Marek Rosa
Spline somewhat working
r423 }
Marek Rosa
Experimenting
r417
Michal Klocek
Refactor xychartitem -> xychart
r1218 void SplineChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
emit XYChart::clicked(calculateDomainPoint(event->pos()));
Michal Klocek
Fixes mouse handling in base class of chartseries
r1747 QGraphicsItem::mousePressEvent(event);
Michal Klocek
Refactor xychartitem -> xychart
r1218 }
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 #include "moc_splinechartitem_p.cpp"
Marek Rosa
Spline working somewhat
r401
QTCOMMERCIALCHART_END_NAMESPACE