1 /* === S Y N F I G ========================================================= */
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
36 /* === U S I N G =========================================================== */
40 using namespace synfig;
41 using namespace studio;
43 /* === M A C R O S ========================================================= */
45 /* === G L O B A L S ======================================================= */
47 int studio::Duck::duck_count(0);
55 synfig::error("%d ducks not yet deleted!",counter);
59 int _DuckCounter::counter(0);
62 /* === P R O C E D U R E S ================================================= */
64 /* === M E T H O D S ======================================================= */
72 { duck_count++; _DuckCounter::counter++; }
74 Duck::Duck(const synfig::Point &point):
83 { duck_count++; _DuckCounter::counter++;}
85 Duck::Duck(const synfig::Point &point,const synfig::Point &origin):
93 { duck_count++; _DuckCounter::counter++;}
95 Duck::~Duck() { duck_count--; _DuckCounter::counter--;}
98 Duck::get_data_guid()const
100 if(value_desc_.is_value_node())
101 return value_desc_.get_value_node()->get_guid();
102 return GUID::hasher(get_name());
106 Duck::set_name(const synfig::String &x)
109 if(guid_==GUID::zero())
111 guid_=GUID::hasher(name);
117 Duck::operator==(const Duck &rhs)const
123 scalar==rhs.scalar &&
125 transform_stack_.size()==rhs.transform_stack_.size();
127 //(origin_duck?*origin_duck==*rhs.origin_duck:origin==rhs.origin) &&
128 //(shared_point?*shared_point==*rhs.shared_point:point==rhs.point) ;
132 Duck::get_trans_point()const
134 return transform_stack_.perform(get_sub_trans_point());
138 Duck::set_trans_point(const synfig::Point &x)
140 set_sub_trans_point(transform_stack_.unperform(x));
143 //! Sets the origin point.
145 Duck::set_origin(const synfig::Point &x)
147 origin=x; origin_duck=0;
150 //! Sets the origin point as another duck
152 Duck::set_origin(const etl::handle<Duck> &x)
157 //! Retrieves the origin location
159 Duck::get_origin()const
161 return origin_duck?origin_duck->get_point():origin;
164 //! Retrieves the origin duck
165 const etl::handle<Duck> &
166 Duck::get_origin_duck() const
171 //! Retrieves the origin location
173 Duck::get_trans_origin()const
175 return transform_stack_.perform(get_sub_trans_origin());
179 Duck::get_sub_trans_point()const
181 return get_point()*get_scalar()+get_sub_trans_origin();
185 Duck::set_sub_trans_point(const synfig::Point &x)
187 set_point((x-get_sub_trans_origin())/get_scalar());
191 Duck::get_sub_trans_origin()const
193 return origin_duck?origin_duck->get_sub_trans_point():origin;