]> git.sesse.net Git - kdenlive/blob - src/onmonitoritems/rotoscoping/splineitem.h
da403e117a5b138f130c842c843c463622c4a47c
[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 class QGraphicsView;
27
28 class SplineItem : public QObject, public QGraphicsPathItem
29 {
30     Q_OBJECT
31
32 public:
33     explicit SplineItem(const QList <BPoint> &points, QGraphicsItem* parent = 0, QGraphicsScene *scene = 0);
34
35     enum { Type = UserType + 10 };
36
37     virtual int type() const;
38
39     bool editing() const;
40
41     void updateSpline(bool editing = false);
42     QList <BPoint> getPoints() const;
43     void setPoints(const QList <BPoint> &points);
44
45     void removeChild(QGraphicsItem *child);
46
47 protected:
48     void mousePressEvent(QGraphicsSceneMouseEvent *event);
49     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
50     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
51     void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
52
53 private:
54     int getClosestPointOnCurve(const QPointF &point, double *tFinal);
55
56     bool m_closed;
57     bool m_editing;
58     QGraphicsView *m_view;
59
60 signals:
61     void changed(bool editing);
62 };
63
64 #endif