surfacenew.cpp pch.h synfig.nsh
LAYERHEADERS = \
- layer_bitmap.h layer_composite.h layer_mime.h layer_motionblur.h layer_pastecanvas.h \
- layer_polygon.h layer_shape.h layer_solidcolor.h
+ layer_bitmap.h layer_composite.h layer_duplicate.h layer_mime.h layer_motionblur.h \
+ layer_pastecanvas.h layer_polygon.h layer_shape.h layer_solidcolor.h
LAYERSOURCES = \
- layer_bitmap.cpp layer_composite.cpp layer_mime.cpp layer_motionblur.cpp layer_pastecanvas.cpp \
- layer_polygon.cpp layer_shape.cpp layer_solidcolor.cpp
+ layer_bitmap.cpp layer_composite.cpp layer_duplicate.cpp layer_mime.cpp layer_motionblur.cpp \
+ layer_pastecanvas.cpp layer_polygon.cpp layer_shape.cpp layer_solidcolor.cpp
TARGETHEADERS = \
target_multi.h target_null.h target_null_tile.h target_scanline.h target_tile.h
VALUENODEHEADERS = \
valuenode_add.h valuenode_animated.h valuenode_atan2.h valuenode_bline.h valuenode_blinecalctangent.h \
valuenode_blinecalcvertex.h valuenode_blinereversetangent.h valuenode_composite.h valuenode_const.h \
- valuenode_cos.h valuenode_dynamiclist.h valuenode_exp.h valuenode_gradientrotate.h valuenode_linear.h \
- valuenode_radialcomposite.h valuenode_range.h valuenode_reciprocal.h valuenode_reference.h \
- valuenode_repeat_gradient.h valuenode_scale.h valuenode_segcalctangent.h valuenode_segcalcvertex.h \
- valuenode_sine.h valuenode_stripes.h valuenode_subtract.h valuenode_switch.h valuenode_timedswap.h \
+ valuenode_cos.h valuenode_duplicate.h valuenode_dynamiclist.h valuenode_exp.h \
+ valuenode_gradientrotate.h valuenode_integer.h valuenode_linear.h valuenode_radialcomposite.h \
+ valuenode_range.h valuenode_reciprocal.h valuenode_reference.h valuenode_repeat_gradient.h \
+ valuenode_scale.h valuenode_segcalctangent.h valuenode_segcalcvertex.h valuenode_sine.h \
+ valuenode_stripes.h valuenode_subtract.h valuenode_switch.h valuenode_timedswap.h \
valuenode_timeloop.h valuenode_twotone.h
VALUENODESOURCES = \
valuenode_add.cpp valuenode_animated.cpp valuenode_atan2.cpp valuenode_bline.cpp valuenode_blinecalctangent.cpp \
valuenode_blinecalcvertex.cpp valuenode_blinereversetangent.cpp valuenode_composite.cpp valuenode_const.cpp \
- valuenode_cos.cpp valuenode_dynamiclist.cpp valuenode_exp.cpp valuenode_gradientrotate.cpp valuenode_linear.cpp \
- valuenode_radialcomposite.cpp valuenode_range.cpp valuenode_reciprocal.cpp valuenode_reference.cpp \
- valuenode_repeat_gradient.cpp valuenode_scale.cpp valuenode_segcalctangent.cpp valuenode_segcalcvertex.cpp \
- valuenode_sine.cpp valuenode_stripes.cpp valuenode_subtract.cpp valuenode_switch.cpp valuenode_timedswap.cpp \
+ valuenode_cos.cpp valuenode_duplicate.cpp valuenode_dynamiclist.cpp valuenode_exp.cpp \
+ valuenode_gradientrotate.cpp valuenode_integer.cpp valuenode_linear.cpp valuenode_radialcomposite.cpp \
+ valuenode_range.cpp valuenode_reciprocal.cpp valuenode_reference.cpp valuenode_repeat_gradient.cpp \
+ valuenode_scale.cpp valuenode_segcalctangent.cpp valuenode_segcalcvertex.cpp valuenode_sine.cpp \
+ valuenode_stripes.cpp valuenode_subtract.cpp valuenode_switch.cpp valuenode_timedswap.cpp \
valuenode_timeloop.cpp valuenode_twotone.cpp
VALUEHEADERS = \
#include "layer_polygon.h"
#include "layer_pastecanvas.h"
#include "layer_motionblur.h"
+#include "layer_duplicate.h"
#include "valuenode_const.h"
INCLUDE_LAYER(Layer_PasteCanvas); LAYER_ALIAS(Layer_PasteCanvas, "paste_canvas");
INCLUDE_LAYER(Layer_Polygon); LAYER_ALIAS(Layer_Polygon, "Polygon");
INCLUDE_LAYER(Layer_MotionBlur); LAYER_ALIAS(Layer_MotionBlur, "motion_blur");
+ INCLUDE_LAYER(Layer_Duplicate);
#undef INCLUDE_LAYER
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file layer_duplicate.cpp
+** \brief Implementation of the "Duplicate" layer
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "string.h"
+#include "layer_duplicate.h"
+#include "time.h"
+#include "context.h"
+#include "paramdesc.h"
+#include "renddesc.h"
+#include "surface.h"
+#include "value.h"
+#include "valuenode.h"
+#include "canvas.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace synfig;
+using namespace etl;
+using namespace std;
+
+/* === G L O B A L S ======================================================= */
+
+SYNFIG_LAYER_INIT(Layer_Duplicate);
+SYNFIG_LAYER_SET_NAME(Layer_Duplicate,"duplicate");
+SYNFIG_LAYER_SET_LOCAL_NAME(Layer_Duplicate,N_("Duplicate"));
+SYNFIG_LAYER_SET_CATEGORY(Layer_Duplicate,N_("Other"));
+SYNFIG_LAYER_SET_VERSION(Layer_Duplicate,"0.1");
+SYNFIG_LAYER_SET_CVS_ID(Layer_Duplicate,"$Id$");
+
+/* === M E M B E R S ======================================================= */
+
+Layer_Duplicate::Layer_Duplicate():
+ Layer_Composite(1.0,Color::BLEND_COMPOSITE)
+{
+}
+
+bool
+Layer_Duplicate::set_param(const String ¶m, const ValueBase &value)
+{
+ IMPORT(index);
+ return Layer_Composite::set_param(param,value);
+}
+
+ValueBase
+Layer_Duplicate::get_param(const String ¶m)const
+{
+ EXPORT(index);
+
+ EXPORT_NAME();
+ EXPORT_VERSION();
+
+ return Layer_Composite::get_param(param);
+}
+
+void
+Layer_Duplicate::set_time(Context context, Time time)const
+{
+ context.set_time(time);
+ time_cur=time;
+}
+
+void
+Layer_Duplicate::set_time(Context context, Time time, const Point &pos)const
+{
+ context.set_time(time,pos);
+ time_cur=time;
+}
+
+Color
+Layer_Duplicate::get_color(Context context, const Point &pos)const
+{
+ return context.get_color(pos);
+}
+
+Layer::Vocab
+Layer_Duplicate::get_param_vocab()const
+{
+ Layer::Vocab ret;
+ //ret=Layer_Composite::get_param_vocab();
+
+ ret.push_back(ParamDesc("index")
+ .set_local_name(_("Index"))
+ .set_description(_("Copy Index"))
+ );
+
+ return ret;
+}
+
+bool
+Layer_Duplicate::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
+{
+ if(quality == 10)
+ return context.accelerated_render(surface,quality,renddesc,cb);
+
+ if(context->empty())
+ {
+ surface->set_wh(renddesc.get_w(),renddesc.get_h());
+ surface->clear();
+ return true;
+ }
+
+ SuperCallback subimagecb;
+ Surface tmp;
+ int i = 0;
+
+ const DynamicParamList &dpl = dynamic_param_list();
+ DynamicParamList::const_iterator iter = dpl.find("index");
+ if (iter == dpl.end())
+ return context.accelerated_render(surface,quality,renddesc,cb);
+
+ etl::rhandle<ValueNode> param(iter->second);
+ handle<ValueNode_Duplicate> duplicate_param(handle<ValueNode_Duplicate>::cast_dynamic(param));
+
+ if (!duplicate_param)
+ return context.accelerated_render(surface,quality,renddesc,cb);
+
+ surface->set_wh(renddesc.get_w(),renddesc.get_h());
+ surface->clear();
+
+ Color::BlendMethod blend_method(get_blend_method());
+ int steps = duplicate_param->count_steps(time_cur);
+
+ duplicate_param->reset_index(time_cur);
+ do
+ {
+ subimagecb=SuperCallback(cb,i*(5000/steps),(i+1)*(5000/steps),5000);
+ // \todo can we force a re-evaluation of all the variables without changing the time twice?
+ context.set_time(time_cur+1);
+ context.set_time(time_cur);
+ if(!context.accelerated_render(&tmp,quality,renddesc,&subimagecb)) return false;
+
+ Surface::alpha_pen apen(surface->begin());
+ apen.set_alpha(1.0);
+ // \todo have a checkbox allowing use of 'behind' to reverse the order?
+ apen.set_blend_method(blend_method);
+ tmp.blit_to(apen);
+ i++;
+ } while (duplicate_param->step(time_cur));
+
+ duplicate_param->reset_index(time_cur);
+
+ return true;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file layer_duplicate.h
+** \brief Header file for implementation of the "Duplicate" layer
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_LAYER_DUPLICATE_H__
+#define __SYNFIG_LAYER_DUPLICATE_H__
+
+/* === H E A D E R S ======================================================= */
+
+#include "valuenode_duplicate.h"
+#include "layer_composite.h"
+#include "time.h"
+
+/* === S T R U C T S & C L A S S E S ======================================= */
+
+namespace synfig {
+
+class Layer_Duplicate : public synfig::Layer_Composite
+{
+ SYNFIG_LAYER_MODULE_EXT
+
+private:
+ mutable int index;
+ mutable Time time_cur;
+
+public:
+
+ Layer_Duplicate();
+
+ virtual bool set_param(const String & param, const synfig::ValueBase &value);
+
+ virtual ValueBase get_param(const String & param)const;
+
+ virtual Color get_color(Context context, const Point &pos)const;
+
+ virtual void set_time(Context context, Time time)const;
+
+ virtual void set_time(Context context, Time time, const Point &point)const;
+
+ virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
+
+ virtual Vocab get_param_vocab()const;
+
+}; // END of class Layer_Duplicate
+
+}; // END of namespace synfig
+
+/* === E N D =============================================================== */
+
+#endif
#include "valuenode_switch.h"
#include "valuenode_timeloop.h"
#include "valuenode_reciprocal.h"
+#include "valuenode_duplicate.h"
+#include "valuenode_integer.h"
#include "layer.h"
ADD_VALUENODE(ValueNode_Switch, "switch", _("Switch") );
ADD_VALUENODE(ValueNode_TimeLoop, "timeloop", _("Time Loop") );
ADD_VALUENODE(ValueNode_Reciprocal, "reciprocal", _("Reciprocal") );
+ ADD_VALUENODE(ValueNode_Duplicate, "duplicate", _("Duplicate") );
+ ADD_VALUENODE(ValueNode_Integer, "fromint", _("From Integer") );
#undef ADD_VALUENODE
#undef ADD_VALUENODE2
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file valuenode_duplicate.cpp
+** \brief Implementation of the "Duplicate" valuenode conversion.
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "valuenode_duplicate.h"
+#include "valuenode_const.h"
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+ValueNode_Duplicate::ValueNode_Duplicate(const ValueBase::Type &x):
+ LinkableValueNode(x)
+{
+}
+
+ValueNode_Duplicate::ValueNode_Duplicate(const ValueNode::Handle &x):
+ LinkableValueNode(x->get_type())
+{
+ set_link("from", ValueNode_Const::create(int(0)));
+ set_link("to", ValueNode_Const::create(int(3)));
+ set_link("step", ValueNode_Const::create(int(1)));
+}
+
+ValueNode_Duplicate*
+ValueNode_Duplicate::create(const ValueBase &x)
+{
+ return new ValueNode_Duplicate(ValueNode_Const::create(x));
+}
+
+LinkableValueNode*
+ValueNode_Duplicate::create_new()const
+{
+ return new ValueNode_Duplicate(get_type());
+}
+
+ValueNode_Duplicate::~ValueNode_Duplicate()
+{
+ unlink_all();
+}
+
+bool
+ValueNode_Duplicate::set_link_vfunc(int i,ValueNode::Handle x)
+{
+ assert(i >= 0 && i < link_count());
+ switch(i)
+ {
+ case 0: from_ = x; break;
+ case 1: to_ = x; break;
+ case 2: step_ = x; break;
+ default: return false;
+ }
+
+ signal_child_changed()(i);
+ signal_value_changed()();
+ return true;
+}
+
+ValueNode::LooseHandle
+ValueNode_Duplicate::get_link_vfunc(int i)const
+{
+ assert(i >= 0 && i < link_count());
+ if(i==0) return from_;
+ if(i==1) return to_;
+ if(i==2) return step_;
+
+ return 0;
+}
+
+int
+ValueNode_Duplicate::link_count()const
+{
+ return 3;
+}
+
+String
+ValueNode_Duplicate::link_local_name(int i)const
+{
+ assert(i >= 0 && i < link_count());
+ if(i==0) return _("From");
+ if(i==1) return _("To");
+ if(i==2) return _("Step");
+ return String();
+}
+
+String
+ValueNode_Duplicate::link_name(int i)const
+{
+ assert(i >= 0 && i < link_count());
+ if(i==0) return "from";
+ if(i==1) return "to";
+ if(i==2) return "step";
+ return String();
+}
+
+int
+ValueNode_Duplicate::get_link_index_from_name(const String &name)const
+{
+ if(name=="from") return 0;
+ if(name=="to") return 1;
+ if(name=="step") return 2;
+
+ throw Exception::BadLinkName(name);
+}
+
+void
+ValueNode_Duplicate::reset_index(Time t)const
+{
+ int from = (*from_)(t).get(int());
+ index = from;
+}
+
+bool
+ValueNode_Duplicate::step(Time t)const
+{
+ int from = (*from_)(t).get(int());
+ int to = (*to_ )(t).get(int());
+ int step = (*step_)(t).get(int());
+
+ if (step == 0) return false;
+
+ step = abs(step);
+
+ if (from < to)
+ {
+ index += step;
+ return index <= to;
+ }
+ else
+ {
+ index -= step;
+ return index >= to;
+ }
+}
+
+int
+ValueNode_Duplicate::count_steps(Time t)const
+{
+ int from = (*from_)(t).get(int());
+ int to = (*to_ )(t).get(int());
+ int step = (*step_)(t).get(int());
+
+ if (step == 0) return 1;
+
+ return abs((from - to) / step) + 1;
+}
+
+ValueBase
+ValueNode_Duplicate::operator()(Time t)const
+{
+ return index;
+}
+
+String
+ValueNode_Duplicate::get_name()const
+{
+ return "duplicate";
+}
+
+String
+ValueNode_Duplicate::get_local_name()const
+{
+ return _("Duplicate");
+}
+
+bool
+ValueNode_Duplicate::check_type(ValueBase::Type type)
+{
+ return type==ValueBase::TYPE_INTEGER;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file valuenode_duplicate.h
+** \brief Header file for implementation of the "Duplicate" valuenode conversion.
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_VALUENODE_DUPLICATE_H
+#define __SYNFIG_VALUENODE_DUPLICATE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "valuenode.h"
+
+/* === M A C R O S ========================================================= */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfig {
+
+class ValueNode_Duplicate : public LinkableValueNode
+{
+ ValueNode::RHandle from_;
+ ValueNode::RHandle to_;
+ ValueNode::RHandle step_;
+ mutable int index;
+
+public:
+ typedef etl::handle<ValueNode_Duplicate> Handle;
+ typedef etl::handle<const ValueNode_Duplicate> ConstHandle;
+
+ ValueNode_Duplicate(const ValueBase::Type &x);
+ ValueNode_Duplicate(const ValueNode::Handle &x);
+
+ virtual ValueBase operator()(Time t)const;
+ void reset_index(Time t)const;
+ bool step(Time t)const;
+ int count_steps(Time t)const;
+
+ virtual ~ValueNode_Duplicate();
+
+ virtual String get_name()const;
+ virtual String get_local_name()const;
+
+
+ virtual ValueNode::LooseHandle get_link_vfunc(int i)const;
+ virtual int link_count()const;
+ virtual String link_name(int i)const;
+
+ virtual String link_local_name(int i)const;
+ virtual int get_link_index_from_name(const String &name)const;
+
+protected:
+ LinkableValueNode* create_new()const;
+ virtual bool set_link_vfunc(int i,ValueNode::Handle x);
+
+public:
+ using synfig::LinkableValueNode::get_link_vfunc;
+
+ using synfig::LinkableValueNode::set_link_vfunc;
+ static bool check_type(ValueBase::Type type);
+ static ValueNode_Duplicate* create(const ValueBase &x);
+}; // END of class ValueNode_Duplicate
+
+}; // END of namespace synfig
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file valuenode_integer.cpp
+** \brief Implementation of the "Integer" valuenode conversion.
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "valuenode_integer.h"
+#include "valuenode_const.h"
+#include "general.h"
+#include <ETL/misc>
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+ValueNode_Integer::ValueNode_Integer(const ValueBase::Type &x):
+ LinkableValueNode(x)
+{
+}
+
+ValueNode_Integer::ValueNode_Integer(const ValueBase &x):
+ LinkableValueNode(x.get_type())
+{
+ switch(x.get_type())
+ {
+ case ValueBase::TYPE_ANGLE:
+ set_link("integer", ValueNode_Const::create(round_to_int(Angle::deg(x.get(Angle())).get())));
+ break;
+ case ValueBase::TYPE_BOOL:
+ set_link("integer", ValueNode_Const::create(int(x.get(bool()))));
+ break;
+ case ValueBase::TYPE_REAL:
+ set_link("integer", ValueNode_Const::create(round_to_int(x.get(Real()))));
+ break;
+ case ValueBase::TYPE_TIME:
+ set_link("integer", ValueNode_Const::create(round_to_int(x.get(Time()))));
+ break;
+ default:
+ assert(0);
+ throw runtime_error("synfig::ValueNode_Integer:Bad type "+ValueBase::type_name(x.get_type()));
+ }
+}
+
+ValueNode_Integer*
+ValueNode_Integer::create(const ValueBase &x)
+{
+ return new ValueNode_Integer(x);
+}
+
+LinkableValueNode*
+ValueNode_Integer::create_new()const
+{
+ return new ValueNode_Integer(get_type());
+}
+
+ValueNode_Integer::~ValueNode_Integer()
+{
+ unlink_all();
+}
+
+bool
+ValueNode_Integer::set_link_vfunc(int i,ValueNode::Handle x)
+{
+ assert(i >= 0 && i < link_count());
+ switch(i)
+ {
+ case 0: integer_ = x; break;
+ default: return false;
+ }
+
+ signal_child_changed()(i);
+ signal_value_changed()();
+ return true;
+}
+
+ValueNode::LooseHandle
+ValueNode_Integer::get_link_vfunc(int i)const
+{
+ assert(i >= 0 && i < link_count());
+ if(i==0) return integer_;
+
+ return 0;
+}
+
+int
+ValueNode_Integer::link_count()const
+{
+ return 1;
+}
+
+String
+ValueNode_Integer::link_local_name(int i)const
+{
+ assert(i >= 0 && i < link_count());
+ if(i==0) return _("Integer");
+ return String();
+}
+
+String
+ValueNode_Integer::link_name(int i)const
+{
+ assert(i >= 0 && i < link_count());
+ if(i==0) return "integer";
+ return String();
+}
+
+int
+ValueNode_Integer::get_link_index_from_name(const String &name)const
+{
+ if(name=="integer") return 0;
+
+ throw Exception::BadLinkName(name);
+}
+
+ValueBase
+ValueNode_Integer::operator()(Time t)const
+{
+ int integer = (*integer_)(t).get(int());
+
+ switch (get_type())
+ {
+ case ValueBase::TYPE_ANGLE:
+ return Angle::deg(integer);
+ case ValueBase::TYPE_BOOL:
+ return bool(integer);
+ case ValueBase::TYPE_REAL:
+ return Real(integer);
+ case ValueBase::TYPE_TIME:
+ return Time(integer);
+ default:
+ assert(0);
+ throw runtime_error("synfig::ValueNode_Integer:Bad type "+ValueBase::type_name(get_type()));
+ }
+}
+
+String
+ValueNode_Integer::get_name()const
+{
+ return "fromint";
+}
+
+String
+ValueNode_Integer::get_local_name()const
+{
+ return _("From Integer");
+}
+
+bool
+ValueNode_Integer::check_type(ValueBase::Type type)
+{
+ return
+ type==ValueBase::TYPE_ANGLE ||
+ type==ValueBase::TYPE_BOOL ||
+ type==ValueBase::TYPE_REAL ||
+ type==ValueBase::TYPE_TIME;
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file valuenode_integer.h
+** \brief Header file for implementation of the "Integer" valuenode conversion.
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_VALUENODE_INTEGER_H
+#define __SYNFIG_VALUENODE_INTEGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "valuenode.h"
+
+/* === M A C R O S ========================================================= */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfig {
+
+class ValueNode_Integer : public LinkableValueNode
+{
+ ValueNode::RHandle integer_;
+
+public:
+ typedef etl::handle<ValueNode_Integer> Handle;
+ typedef etl::handle<const ValueNode_Integer> ConstHandle;
+
+ ValueNode_Integer(const ValueBase::Type &x);
+ ValueNode_Integer(const ValueBase &x);
+
+ virtual ValueBase operator()(Time t)const;
+
+ virtual ~ValueNode_Integer();
+
+ virtual String get_name()const;
+ virtual String get_local_name()const;
+
+
+ virtual ValueNode::LooseHandle get_link_vfunc(int i)const;
+ virtual int link_count()const;
+ virtual String link_name(int i)const;
+
+ virtual String link_local_name(int i)const;
+ virtual int get_link_index_from_name(const String &name)const;
+
+protected:
+ LinkableValueNode* create_new()const;
+ virtual bool set_link_vfunc(int i,ValueNode::Handle x);
+
+public:
+ using synfig::LinkableValueNode::get_link_vfunc;
+
+ using synfig::LinkableValueNode::set_link_vfunc;
+ static bool check_type(ValueBase::Type type);
+ static ValueNode_Integer* create(const ValueBase &x);
+}; // END of class ValueNode_Integer
+
+}; // END of namespace synfig
+
+/* === E N D =============================================================== */
+
+#endif