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 ***************************************************************************/
30 BPoint::BPoint(const QPointF &handle1, const QPointF &point, const QPointF &handle2) :
38 QPointF &BPoint::operator[](int i)
40 return i == 0 ? h1 : (i == 1 ? p : h2);
43 const QPointF &BPoint::operator[](int i) const
45 return i == 0 ? h1 : (i == 1 ? p : h2);
48 bool BPoint::operator==(const BPoint& point) const
50 return point.h1 == h1 &&
55 void BPoint::setP(const QPointF &point, bool updateHandles)
57 QPointF offset = point - p;
65 void BPoint::setH1(const QPointF &handle1)
69 qreal angle = QLineF(h1, p).angle();
70 QLineF l = QLineF(p, h2);
76 void BPoint::setH2(const QPointF &handle2)
80 qreal angle = QLineF(h2, p).angle();
81 QLineF l = QLineF(p, h1);
87 void BPoint::keepInRange(qreal xMin, qreal xMax)
93 void BPoint::autoSetLinked()
95 // sometimes the angle is returned as 360°
96 // due to rounding problems the angle is sometimes not quite 0
97 qreal angle = QLineF(h1, p).angleTo(QLineF(p, h2));
98 handlesLinked = angle < 1e-3 || qRound(angle) == 360;