Fixing warnings from doxygen:
[synfig.git] / synfig-core / trunk / src / modules / lyr_std / insideout.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file insideout.cpp
3 **      \brief Template Header
4 **
5 **      \legal
6 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
7 **
8 **      This package is free software; you can redistribute it and/or
9 **      modify it under the terms of the GNU General Public License as
10 **      published by the Free Software Foundation; either version 2 of
11 **      the License, or (at your option) any later version.
12 **
13 **      This package is distributed in the hope that it will be useful,
14 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
15 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 **      General Public License for more details.
17 **      \endlegal
18 **
19 ** === N O T E S ===========================================================
20 **
21 ** ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "insideout.h"
33
34 #include <synfig/string.h>
35 #include <synfig/time.h>
36 #include <synfig/context.h>
37 #include <synfig/paramdesc.h>
38 #include <synfig/renddesc.h>
39 #include <synfig/surface.h>
40 #include <synfig/value.h>
41 #include <synfig/valuenode.h>
42 #include <synfig/transform.h>
43
44 #endif
45
46 /* === M A C R O S ========================================================= */
47
48 /* === G L O B A L S ======================================================= */
49
50 SYNFIG_LAYER_INIT(InsideOut);
51 SYNFIG_LAYER_SET_NAME(InsideOut,"inside_out");
52 SYNFIG_LAYER_SET_LOCAL_NAME(InsideOut,_("InsideOut"));
53 SYNFIG_LAYER_SET_CATEGORY(InsideOut,_("Distortions"));
54 SYNFIG_LAYER_SET_VERSION(InsideOut,"0.1");
55 SYNFIG_LAYER_SET_CVS_ID(InsideOut,"$Id: insideout.cpp,v 1.1.1.1 2005/01/04 01:23:10 darco Exp $");
56
57 /* === P R O C E D U R E S ================================================= */
58
59 /* === M E T H O D S ======================================================= */
60
61 InsideOut::InsideOut():
62         origin(0,0)
63 {
64 }
65
66 bool
67 InsideOut::set_param(const String & param, const ValueBase &value)
68 {
69         IMPORT(origin);
70         return false;
71 }
72
73 ValueBase
74 InsideOut::get_param(const String & param)const
75 {
76         EXPORT(origin);
77
78         EXPORT_NAME();
79         EXPORT_VERSION();
80
81         return ValueBase();
82 }
83
84 synfig::Layer::Handle
85 InsideOut::hit_check(synfig::Context context, const synfig::Point &p)const
86 {
87         Point pos(p-origin);
88         Real inv_mag=pos.inv_mag();
89         Point invpos(pos*inv_mag*inv_mag);
90         return context.hit_check(invpos+origin);
91 }
92
93 Color
94 InsideOut::get_color(Context context, const Point &p)const
95 {
96         Point pos(p-origin);
97         Real inv_mag=pos.inv_mag();
98         Point invpos(pos*inv_mag*inv_mag);
99         return context.get_color(invpos+origin);
100 }
101
102 class InsideOut_Trans : public Transform
103 {
104         etl::handle<const InsideOut> layer;
105 public:
106         InsideOut_Trans(const InsideOut* x):layer(x) { }
107
108         synfig::Vector perform(const synfig::Vector& x)const
109         {
110                 Point pos(x-layer->origin);
111                 Real inv_mag=pos.inv_mag();
112                 if(!isnan(inv_mag))
113                         return (pos*(inv_mag*inv_mag)+layer->origin);
114                 return x;
115         }
116
117         synfig::Vector unperform(const synfig::Vector& x)const
118         {
119                 Point pos(x-layer->origin);
120                 Real inv_mag=pos.inv_mag();
121                 if(!isnan(inv_mag))
122                         return (pos*(inv_mag*inv_mag)+layer->origin);
123                 return x;
124         }
125 };
126 etl::handle<Transform>
127 InsideOut::get_transform()const
128 {
129         return new InsideOut_Trans(this);
130 }
131
132 Layer::Vocab
133 InsideOut::get_param_vocab()const
134 {
135         Layer::Vocab ret;
136
137         ret.push_back(ParamDesc("origin")
138                 .set_local_name(_("Origin"))
139                 .set_description(_("Defines the where the center will be"))
140         );
141
142         return ret;
143 }