Added copyright lines for files I've edited this year.
[synfig.git] / synfig-core / trunk / src / modules / mod_particle / plant.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file plant.h
3 **      \brief Header file for implementation of the "Plant" layer
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2007, 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 /* === S T A R T =========================================================== */
25
26 #ifndef __SYNFIG_PLANT_H
27 #define __SYNFIG_PLANT_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include <list>
32 #include <vector>
33 #include <synfig/layer_composite.h>
34 #include <synfig/segment.h>
35 #include <synfig/blinepoint.h>
36 #include <synfig/value.h>
37 #include <synfig/gradient.h>
38 #include <synfig/angle.h>
39 #include "random.h"
40 #include <synfig/rect.h>
41
42 /* === M A C R O S ========================================================= */
43
44 /* === T Y P E D E F S ===================================================== */
45
46 /* === C L A S S E S & S T R U C T S ======================================= */
47
48 using namespace synfig;
49 using namespace std;
50 using namespace etl;
51
52 class Plant : public synfig::Layer_Composite
53 {
54         SYNFIG_LAYER_MODULE_EXT
55 private:
56
57         std::vector<synfig::BLinePoint> bline;
58         bool bline_loop;
59
60         Point offset;
61
62         synfig::Gradient gradient;
63
64         struct Particle
65         {
66                 synfig::Point point;
67                 synfig::Color color;
68
69                 Particle(const synfig::Point &point,const synfig::Color& color):
70                         point(point),color(color) { }
71         };
72
73         mutable std::vector<Particle> particle_list;
74         mutable synfig::Rect    bounding_rect;
75         synfig::Angle split_angle;
76         synfig::Vector gravity;
77         synfig::Real velocity;
78         synfig::Real perp_velocity;
79         synfig::Real step;
80         synfig::Real mass;
81         synfig::Real drag;
82         synfig::Real size;
83         int splits;
84         int sprouts;
85         synfig::Real random_factor;
86         Random random;
87
88         bool size_as_alpha;
89         bool reverse;
90         mutable bool needs_sync_;
91         mutable synfig::Mutex mutex;
92
93         void branch(int n, int depth,float t, float stunt_growth, synfig::Point position,synfig::Vector velocity)const;
94         void sync()const;
95         String version;
96         bool use_width;
97
98 public:
99
100         Plant();
101
102         void calc_bounding_rect()const;
103
104         virtual bool set_param(const String & param, const synfig::ValueBase &value);
105
106         virtual ValueBase get_param(const String & param)const;
107
108         virtual bool set_version(const synfig::String &ver);
109
110         virtual Vocab get_param_vocab()const;
111
112         virtual bool accelerated_render(synfig::Context context,synfig::Surface *surface,int quality, const synfig::RendDesc &renddesc, synfig::ProgressCallback *cb)const;\
113
114         virtual synfig::Rect get_bounding_rect(synfig::Context context)const;
115 };
116
117 /* === E N D =============================================================== */
118
119 #endif