]> git.sesse.net Git - kdenlive/blob - src/beziercurve/bpoint.h
Integrate with the required MLT hooks for getting Movit to work.
[kdenlive] / src / beziercurve / bpoint.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 BPOINT_H
20 #define BPOINT_H
21
22 #include <QtCore>
23
24 /**
25  * @brief Represents a point in a cubic Bézier spline.
26  */
27
28 class BPoint
29 {
30 public:
31     /** @brief Sets the point to -1, -1 to mark it as unusable (until point + handles have proper values) */
32     BPoint();
33     /** @brief Sets up according to the params. Linking detecting is done using autoSetLinked(). */
34     BPoint(const QPointF &handle1, const QPointF &point, const QPointF &handle2);
35
36     /** @brief Returns h1 if i = 0, p if i = 1, h2 if i = 2. */
37     QPointF &operator[](int i);
38     /** @brief Returns h1 if i = 0, p if i = 1, h2 if i = 2. */
39     const QPointF &operator[](int i) const;
40     bool operator==(const BPoint &point) const;
41
42     /** @brief Sets p to @param point.
43      * @param updateHandles (default = true) Whether to make sure the handles keep their position relative to p. */
44     void setP(const QPointF &point, bool updateHandles = true);
45
46     /** @brief Sets h1 to @param handle1.
47      *
48      * If handlesLinked is true h2 is updated. */
49     void setH1(const QPointF &handle1);
50
51     /** @brief Sets h2 to @param handle2.
52      * 
53      * If handlesLinked is true h1 is updated. */
54     void setH2(const QPointF &handle2);
55     void keepInRange(qreal xMin, qreal xMax);
56
57     /** @brief Sets handlesLinked to true if the handles are in a linked state (line through h1, p, h2) otherwise to false. */
58     void autoSetLinked();
59
60     /** handle 1 */
61     QPointF h1;
62     /** point */
63     QPointF p;
64     /** handle 2 */
65     QPointF h2;
66
67     /** handles are linked to achieve a natural locking spline => PH1 = -r*PH2 ; a line can be drawn through h1, p, h2 */
68     bool handlesLinked;
69 };
70
71 #endif