Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / 0.61.08 / src / modules / mod_geometry / circle.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file circle.h
3 **      \brief Header file for implementation of the "Circle" layer
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 /* === H E A D E R S ======================================================= */
24
25 #ifndef __SYNFIG_LAYER_CIRCLE_H__
26 #define __SYNFIG_LAYER_CIRCLE_H__
27
28 /* -- H E A D E R S --------------------------------------------------------- */
29
30 #include <synfig/layer_composite.h>
31 #include <synfig/color.h>
32 #include <synfig/vector.h>
33
34 using namespace synfig;
35 using namespace std;
36 using namespace etl;
37
38 /* -- M A C R O S ----------------------------------------------------------- */
39
40 /* -- T Y P E D E F S ------------------------------------------------------- */
41
42 /* -- S T R U C T S & C L A S S E S ----------------------------------------- */
43
44 class Circle : public synfig::Layer_Composite, public synfig::Layer_NoDeform
45 {
46         SYNFIG_LAYER_MODULE_EXT
47 private:
48         synfig::Color color;
49         synfig::Point pos;
50         synfig::Real radius;
51         synfig::Real feather;
52         bool invert;
53         int falloff;
54
55         //Caching system for circle
56         struct CircleDataCache
57         {
58                 Real inner_radius;
59                 Real outer_radius;
60
61                 Real inner_radius_sqd;
62                 Real outer_radius_sqd;
63
64                 Real diff_sqd;
65                 Real double_feather;
66         };
67
68         typedef Real    FALLOFF_FUNC(const CircleDataCache &c, const Real &mag_sqd);
69
70         FALLOFF_FUNC    *falloff_func;
71         CircleDataCache cache;
72
73         void constructcache();
74
75         static  Real    SqdFalloff(const CircleDataCache &c, const Real &mag_sqd);
76         static  Real    InvSqdFalloff(const CircleDataCache &c, const Real &mag_sqd);
77         static  Real    SqrtFalloff(const CircleDataCache &c, const Real &mag_sqd);
78         static  Real    InvSqrtFalloff(const CircleDataCache &c, const Real &mag_sqd);
79         static  Real    LinearFalloff(const CircleDataCache &c, const Real &mag_sqd);
80         static  Real    InvLinearFalloff(const CircleDataCache &c, const Real &mag_sqd);
81         static  Real    SigmondFalloff(const CircleDataCache &c, const Real &mag_sqd);
82         static  Real    InvSigmondFalloff(const CircleDataCache &c, const Real &mag_sqd);
83         static  Real    CosineFalloff(const CircleDataCache &c, const Real &mag_sqd);
84         static  Real    InvCosineFalloff(const CircleDataCache &c, const Real &mag_sqd);
85
86         FALLOFF_FUNC    *GetFalloffFunc()const;
87         bool ImportParameters(const String &param, const ValueBase &value);
88
89 public:
90         enum Falloff
91         {
92                 FALLOFF_SQUARED         =0,
93                 FALLOFF_INTERPOLATION_LINEAR            =1,
94                 FALLOFF_SMOOTH          =2,
95                 FALLOFF_COSINE          =2,
96                 FALLOFF_SIGMOND         =3,
97                 FALLOFF_SQRT            =4
98         };
99
100         Circle();
101
102         virtual bool set_param(const String &param, const ValueBase &value);
103
104         virtual ValueBase get_param(const String &param)const;
105
106         virtual Color get_color(Context context, const Point &pos)const;
107
108         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
109
110         virtual synfig::Rect get_full_bounding_rect(synfig::Context context)const;
111         virtual synfig::Rect get_bounding_rect()const;
112
113         synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
114
115         virtual Vocab get_param_vocab()const;
116 };
117
118 /* -- E X T E R N S --------------------------------------------------------- */
119
120
121 /* -- E N D ----------------------------------------------------------------- */
122
123 #endif