1 /***************************************************************************
2 * Copyright (C) 2011 by Till Theato (root@ttill.de) *
3 * This file is part of Kdenlive (www.kdenlive.org). *
5 * Kdenlive is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * Kdenlive is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with Kdenlive. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
19 #include "splineitem.h"
20 #include "bpointitem.h"
22 #include <QGraphicsScene>
24 SplineItem::SplineItem(const QList< BPoint >& points, QGraphicsItem* parent, QGraphicsScene *scene) :
25 QGraphicsPathItem(parent, scene)
27 QPen framepen(Qt::SolidLine);
28 framepen.setColor(Qt::yellow);
30 setBrush(Qt::NoBrush);
35 QPainterPath path(points.at(0).p);
37 for (int i = 0; i < points.count(); ++i) {
38 new BPointItem(points.at(i), this);
39 j = (i + 1) % points.count();
40 path.cubicTo(points.at(i).h2, points.at(j).h1, points.at(j).p);
45 int SplineItem::type() const
50 void SplineItem::updateSpline()
52 QPainterPath path(qgraphicsitem_cast<BPointItem *>(childItems().at(0))->getPoint().p);
56 for (int i = 0; i < childItems().count(); ++i) {
57 j = (i + 1) % childItems().count();
58 p1 = qgraphicsitem_cast<BPointItem *>(childItems().at(i))->getPoint();
59 p2 = qgraphicsitem_cast<BPointItem *>(childItems().at(j))->getPoint();
60 path.cubicTo(p1.h2, p2.h1, p2.p);
67 QList <BPoint> SplineItem::getPoints()
69 QList <BPoint> points;
70 foreach (QGraphicsItem *child, childItems())
71 points << qgraphicsitem_cast<BPointItem *>(child)->getPoint();
75 #include "splineitem.moc"