Add LayerParamSetStatic and LayerParamUnSetStatic actions.
[synfig.git] / synfig-core / 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 **      Copyright (c) 2008 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === H E A D E R S ======================================================= */
25
26 #ifndef __SYNFIG_LAYER_CIRCLE_H__
27 #define __SYNFIG_LAYER_CIRCLE_H__
28
29 /* -- H E A D E R S --------------------------------------------------------- */
30
31 #include <synfig/layer_composite.h>
32 #include <synfig/color.h>
33 #include <synfig/vector.h>
34
35 using namespace synfig;
36 using namespace std;
37 using namespace etl;
38
39 /* -- M A C R O S ----------------------------------------------------------- */
40
41 /* -- T Y P E D E F S ------------------------------------------------------- */
42
43 /* -- S T R U C T S & C L A S S E S ----------------------------------------- */
44
45 class Circle : public synfig::Layer_Composite, public synfig::Layer_NoDeform
46 {
47         SYNFIG_LAYER_MODULE_EXT
48 private:
49         synfig::Color color;
50         synfig::Point origin;
51         synfig::Real radius;
52         synfig::Real feather;
53         bool invert;
54         int falloff;
55
56         bool color_static;
57         bool origin_static;
58         bool radius_static;
59         bool feather_static;
60         bool invert_static;
61         bool falloff_static;
62
63         //Caching system for circle
64         struct CircleDataCache
65         {
66                 Real inner_radius;
67                 Real outer_radius;
68
69                 Real inner_radius_sqd;
70                 Real outer_radius_sqd;
71
72                 Real diff_sqd;
73                 Real double_feather;
74         };
75
76         typedef Real    FALLOFF_FUNC(const CircleDataCache &c, const Real &mag_sqd);
77
78         FALLOFF_FUNC    *falloff_func;
79         CircleDataCache cache;
80
81         void constructcache();
82
83         static  Real    SqdFalloff(const CircleDataCache &c, const Real &mag_sqd);
84         static  Real    InvSqdFalloff(const CircleDataCache &c, const Real &mag_sqd);
85         static  Real    SqrtFalloff(const CircleDataCache &c, const Real &mag_sqd);
86         static  Real    InvSqrtFalloff(const CircleDataCache &c, const Real &mag_sqd);
87         static  Real    LinearFalloff(const CircleDataCache &c, const Real &mag_sqd);
88         static  Real    InvLinearFalloff(const CircleDataCache &c, const Real &mag_sqd);
89         static  Real    SigmondFalloff(const CircleDataCache &c, const Real &mag_sqd);
90         static  Real    InvSigmondFalloff(const CircleDataCache &c, const Real &mag_sqd);
91         static  Real    CosineFalloff(const CircleDataCache &c, const Real &mag_sqd);
92         static  Real    InvCosineFalloff(const CircleDataCache &c, const Real &mag_sqd);
93
94         FALLOFF_FUNC    *GetFalloffFunc()const;
95         bool ImportParameters(const String &param, const ValueBase &value);
96
97 public:
98         enum Falloff
99         {
100                 FALLOFF_SQUARED         =0,
101                 FALLOFF_INTERPOLATION_LINEAR            =1,
102                 FALLOFF_SMOOTH          =2,
103                 FALLOFF_COSINE          =2,
104                 FALLOFF_SIGMOND         =3,
105                 FALLOFF_SQRT            =4
106         };
107
108         Circle();
109
110         virtual bool set_param(const String &param, const ValueBase &value);
111
112         virtual ValueBase get_param(const String &param)const;
113
114         virtual bool set_param_static(const String &param, const bool x);
115         virtual bool get_param_static(const String &param) const;
116
117         virtual Color get_color(Context context, const Point &pos)const;
118
119         virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
120
121         virtual synfig::Rect get_full_bounding_rect(synfig::Context context)const;
122         virtual synfig::Rect get_bounding_rect()const;
123
124         synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const;
125
126         virtual Vocab get_param_vocab()const;
127 };
128
129 /* -- E X T E R N S --------------------------------------------------------- */
130
131
132 /* -- E N D ----------------------------------------------------------------- */
133
134 #endif