##// END OF EJS Templates
Add more themes to piechartcustomization
Add more themes to piechartcustomization

File last commit:

r622:960bcf5125b7
r658:6c43bf929dc5
Show More
splinechartitem.cpp
116 lines | 2.8 KiB | text/x-c | CppLexer
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 #include "splinechartitem_p.h"
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 #include "chartpresenter_p.h"
Michal Klocek
Improves spline interpolation...
r622 #include "chartanimator_p.h"
Marek Rosa
Spline working somewhat
r401 #include <QPainter>
Marek Rosa
Spline initial
r295
Marek Rosa
Spline working somewhat
r401 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 SplineChartItem::SplineChartItem(QSplineSeries* series, QGraphicsItem *parent) :
Michal Klocek
Refactor line spline to common xyline...
r465 XYChartItem(series, parent),
Michal Klocek
Adds visible points handling to spline
r580 m_series(series),
m_pointsVisible(false)
Marek Rosa
Spline initial
r295 {
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 setZValue(ChartPresenter::LineChartZValue);
QObject::connect(series,SIGNAL(updated()),this,SLOT(handleUpdated()));
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
Improves spline interpolation...
r622 void SplineChartItem::updateLayout(QVector<QPointF>& oldPoints,QVector<QPointF>& newPoints,int index)
{
QVector<QPointF> controlPoints;
controlPoints.resize(newPoints.count()*2-2);
for (int i = 0; i < newPoints.size() - 1; i++)
{
controlPoints[2*i] = calculateGeometryControlPoint(2 * i);
controlPoints[2 * i + 1] = calculateGeometryControlPoint(2 * i + 1);
}
if(controlPoints.count()<2) {
setLayout(newPoints,controlPoints);
return;
}
if(m_animator){
m_animator->updateLayout(this,oldPoints,newPoints,m_controlPoints,controlPoints,index);
}else{
setLayout(newPoints,controlPoints);
}
}
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const
Marek Rosa
Spline working somewhat
r401 {
Michal Klocek
Refactor line spline to common xyline...
r465 return XYChartItem::calculateGeometryPoint(m_series->controlPoint(index));
Marek Rosa
Spline with problems
r419 }
Michal Klocek
Improves spline interpolation...
r622 void SplineChartItem::setLayout(QVector<QPointF>& points,QVector<QPointF>& controlPoints)
Marek Rosa
Spline with problems
r419 {
Michal Klocek
Improves spline interpolation...
r622 if(points.size()<2 || controlPoints.size()<2)
Marek Rosa
Added support for adding and removing data with model. Updated the example
r545 {
Michal Klocek
Unify naming setGeometry -> setLayout
r557 XYChartItem::setLayout(points);
Michal Klocek
Improves spline interpolation...
r622 m_controlPoints=controlPoints;
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
Marek Rosa
Spline chart example added
r434 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
Unify naming setGeometry -> setLayout
r557 XYChartItem::setLayout(points);
Michal Klocek
Improves spline interpolation...
r622 m_controlPoints=controlPoints;
Michal Klocek
Refactor line spline to common xyline...
r465 }
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 //handlers
void SplineChartItem::handleUpdated()
{
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)
Marek Rosa
Spline somewhat working
r423 painter->save();
Michal Klocek
Refactor line spline to common xyline...
r465 painter->setClipRect(clipRect());
Michal Klocek
Adds visible points handling to spline
r580 painter->setPen(m_linePen);
Marek Rosa
Spline somewhat working
r423 painter->drawPath(m_path);
Michal Klocek
Adds visible points handling to spline
r580 if(m_pointsVisible){
painter->setPen(m_pointPen);
painter->drawPoints(points());
}
Marek Rosa
Spline somewhat working
r423 painter->restore();
}
Marek Rosa
Experimenting
r417
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