##// END OF EJS Templates
Adds class diagram image
Adds class diagram image

File last commit:

r465:7f683774d508
r472:3e4145ef29a1
Show More
splinechartitem.cpp
84 lines | 2.2 KiB | text/x-c | CppLexer
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 #include "splinechartitem_p.h"
Marek Rosa
Spline working somewhat
r401 #include <QPainter>
Marek Rosa
Spline initial
r295
Marek Rosa
Spline working somewhat
r401 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 SplineChartItem::SplineChartItem(QSplineSeries* series, QGraphicsObject *parent) :
Michal Klocek
Refactor line spline to common xyline...
r465 XYChartItem(series, parent),
m_series(series)
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
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
Refactors linechart update calls
r464 void SplineChartItem::setGeometry(QVector<QPointF>& points)
Marek Rosa
Spline with problems
r419 {
Marek Rosa
Spline somewhat working
r423 if(points.size()==0) return;
QPainterPath splinePath;
const QPointF& point = points.at(0);
splinePath.moveTo(point);
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);
splinePath.cubicTo(calculateGeometryControlPoint(2 * i), calculateGeometryControlPoint(2 * i + 1), point);
}
prepareGeometryChange();
m_path = splinePath;
m_rect = splinePath.boundingRect();
Michal Klocek
Refactor line spline to common xyline...
r465 XYChartItem::setGeometry(points);
}
void SplineChartItem::setPen(const QPen& pen)
{
m_pen = pen;
Marek Rosa
Spline working somewhat
r401 }
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 {
Q_UNUSED(widget);
Q_UNUSED(option);
painter->save();
Michal Klocek
Refactor line spline to common xyline...
r465 painter->setClipRect(clipRect());
Marek Rosa
Spline somewhat working
r423 painter->drawPath(m_path);
Michal Klocek
Refactor line spline to common xyline...
r465 const QVector<QPointF> points = XYChartItem::points();
for (int i = 0; i < points.size() - 1; i++)
Marek Rosa
Spline somewhat working
r423 {
painter->setPen(Qt::red);
Michal Klocek
Refactor line spline to common xyline...
r465 painter->drawEllipse(points[i], 2, 2);
Marek Rosa
Spline somewhat working
r423
painter->setPen(Qt::blue);
// painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i));
// painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1));
Marek Rosa
Added automatic refresh of control points on add/remove point. Spline example updated
r431 // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4);
// painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4);
}
Michal Klocek
Refactor line spline to common xyline...
r465 if (points.count() > 0)
Marek Rosa
Added automatic refresh of control points on add/remove point. Spline example updated
r431 {
painter->setPen(Qt::red);
Michal Klocek
Refactor line spline to common xyline...
r465 painter->drawEllipse(points[points.count() - 1], 2, 2);
Marek Rosa
Spline somewhat working
r423 }
painter->restore();
}
Marek Rosa
Experimenting
r417
Marek Rosa
Renamed SplinePresenter to SplineChartItem
r460 #include "moc_splinechartitem_p.cpp"
Marek Rosa
Spline working somewhat
r401
QTCOMMERCIALCHART_END_NAMESPACE