]> git.sesse.net Git - kdenlive/blob - src/onmonitoritems/rotoscoping/splineitem.h
f2e7562a40a7d6cd7ce2951600e948a789264b80
[kdenlive] / src / onmonitoritems / rotoscoping / splineitem.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Till Theato (root@ttill.de)                     *
3  *   This file is part of Kdenlive (www.kdenlive.org).                     *
4  *                                                                         *
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.                                   *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
18
19 #ifndef SPLINEITEM_H
20 #define SPLINEITEM_H
21
22 #include <QtCore>
23 #include <QGraphicsPathItem>
24
25 class BPoint;
26
27 class SplineItem : public QObject, public QGraphicsPathItem
28 {
29     Q_OBJECT
30
31 public:
32     SplineItem(const QList <BPoint> &points, QGraphicsItem* parent = 0, QGraphicsScene *scene = 0);
33
34     enum { Type = UserType + 10 };
35
36     virtual int type() const;
37
38     void updateSpline();
39     QList <BPoint> getPoints();
40
41     void removeChild(QGraphicsItem *child);
42
43 protected:
44     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
45     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
46     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
47     virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
48
49 private:
50     int getClosestPointOnCurve(QPointF point, double *tFinal);
51
52     bool m_closed;
53
54 signals:
55     void changed();
56 };
57
58 #endif