Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / stable / src / synfig / blinepoint.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file blinepoint.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_BLINEPOINT_H
26 #define __SYNFIG_BLINEPOINT_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include "vector.h"
31 #include "uniqueid.h"
32 #include <algorithm>
33
34 /* === M A C R O S ========================================================= */
35
36 /* === T Y P E D E F S ===================================================== */
37
38 /* === C L A S S E S & S T R U C T S ======================================= */
39
40 namespace synfig {
41
42 class BLinePoint : public UniqueID
43 {
44 private:
45         Point   vertex_;
46         Vector  tangent_[2];
47         float   width_;
48         float   origin_;
49         bool    split_tangent_;
50
51 public:
52
53         BLinePoint():
54                 vertex_(Point(0,0)),
55                 width_(0.01),
56                 origin_(0.0),
57                 split_tangent_(false)
58         { tangent_[0] = Point(0,0); tangent_[1] = Point(0,0); }
59
60         const Point& get_vertex()const { return vertex_; }
61         void set_vertex(const Point& x) { vertex_=x; }
62
63
64         const Vector& get_tangent1()const { return tangent_[0]; }
65         const Vector& get_tangent2()const { return split_tangent_?tangent_[1]:tangent_[0]; }
66         void set_tangent(const Vector& x) { tangent_[0]=tangent_[1]=x; }
67         void set_tangent1(const Vector& x) { tangent_[0]=x; }
68         void set_tangent2(const Vector& x) { tangent_[1]=x; }
69
70
71         const float& get_width()const { return width_; }
72         void set_width(float x) { width_=x; }
73
74         // We store the origin offset by 0.5 so that
75         // can have the origin set to the default by zeroing
76         // out the structure.
77         float get_origin()const { return origin_+0.5f; }
78         void set_origin(float x) { origin_=x-0.5f; }
79
80
81         const bool& get_split_tangent_flag()const { return split_tangent_; }
82         void set_split_tangent_flag(bool x=true) { split_tangent_=x; }
83
84         void reverse();
85
86 }; // END of class BLinePoint
87
88 }; // END of namespace synfig
89
90 /* === E N D =============================================================== */
91
92 #endif