From cb064c3af5e45aaf528df49e82267c37ba10af60 Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 22 Nov 2007 00:28:08 +0000 Subject: [PATCH] Add new valuenode convert type called "Reverse Tangent" to allow blinepoint's tangents to be reversed. git-svn-id: http://svn.voria.com/code@1162 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/Makefile.am | 4 +- synfig-core/trunk/src/synfig/valuenode.cpp | 2 + .../src/synfig/valuenode_blinereversetangent.cpp | 201 +++++++++++++++++++++ .../src/synfig/valuenode_blinereversetangent.h | 80 ++++++++ 4 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 synfig-core/trunk/src/synfig/valuenode_blinereversetangent.cpp create mode 100644 synfig-core/trunk/src/synfig/valuenode_blinereversetangent.h diff --git a/synfig-core/trunk/src/synfig/Makefile.am b/synfig-core/trunk/src/synfig/Makefile.am index 39f3998..c25e993 100644 --- a/synfig-core/trunk/src/synfig/Makefile.am +++ b/synfig-core/trunk/src/synfig/Makefile.am @@ -14,8 +14,8 @@ TARGETSOURCES=target_scanline.cpp target_tile.cpp target_multi.cpp target_null.c IMPORTERHEADERS=listimporter.h IMPORTERSOURCES=listimporter.cpp -VALUENODEHEADERS=valuenode_exp.h valuenode_sine.h valuenode_cos.h valuenode_atan2.h valuenode_radialcomposite.h valuenode_bline.h valuenode_blinecalcvertex.h valuenode_blinecalctangent.h valuenode_segcalcvertex.h valuenode_segcalctangent.h valuenode_twotone.h valuenode_repeat_gradient.h valuenode_stripes.h valuenode_add.h valuenode_subtract.h valuenode_const.h valuenode_range.h valuenode_reference.h valuenode_linear.h valuenode_composite.h valuenode_dynamiclist.h valuenode_animated.h valuenode_scale.h valuenode_timedswap.h valuenode_gradientrotate.h valuenode_switch.h -VALUENODESOURCES=valuenode_exp.cpp valuenode_sine.cpp valuenode_cos.cpp valuenode_atan2.cpp valuenode_radialcomposite.cpp valuenode_bline.cpp valuenode_blinecalcvertex.cpp valuenode_blinecalctangent.cpp valuenode_segcalcvertex.cpp valuenode_segcalctangent.cpp valuenode_twotone.cpp valuenode_repeat_gradient.cpp valuenode_stripes.cpp valuenode_add.cpp valuenode_subtract.cpp valuenode_const.cpp valuenode_range.cpp valuenode_reference.cpp valuenode_linear.cpp valuenode_composite.cpp valuenode_dynamiclist.cpp valuenode_animated.cpp valuenode_scale.cpp valuenode_timedswap.cpp valuenode_gradientrotate.cpp valuenode_switch.cpp +VALUENODEHEADERS=valuenode_exp.h valuenode_sine.h valuenode_cos.h valuenode_atan2.h valuenode_radialcomposite.h valuenode_bline.h valuenode_blinecalcvertex.h valuenode_blinecalctangent.h valuenode_blinereversetangent.h valuenode_segcalcvertex.h valuenode_segcalctangent.h valuenode_twotone.h valuenode_repeat_gradient.h valuenode_stripes.h valuenode_add.h valuenode_subtract.h valuenode_const.h valuenode_range.h valuenode_reference.h valuenode_linear.h valuenode_composite.h valuenode_dynamiclist.h valuenode_animated.h valuenode_scale.h valuenode_timedswap.h valuenode_gradientrotate.h valuenode_switch.h +VALUENODESOURCES=valuenode_exp.cpp valuenode_sine.cpp valuenode_cos.cpp valuenode_atan2.cpp valuenode_radialcomposite.cpp valuenode_bline.cpp valuenode_blinecalcvertex.cpp valuenode_blinecalctangent.cpp valuenode_blinereversetangent.cpp valuenode_segcalcvertex.cpp valuenode_segcalctangent.cpp valuenode_twotone.cpp valuenode_repeat_gradient.cpp valuenode_stripes.cpp valuenode_add.cpp valuenode_subtract.cpp valuenode_const.cpp valuenode_range.cpp valuenode_reference.cpp valuenode_linear.cpp valuenode_composite.cpp valuenode_dynamiclist.cpp valuenode_animated.cpp valuenode_scale.cpp valuenode_timedswap.cpp valuenode_gradientrotate.cpp valuenode_switch.cpp VALUEHEADERS=blinepoint.h gradient.h value.h VALUESOURCES=blinepoint.cpp gradient.cpp value.cpp diff --git a/synfig-core/trunk/src/synfig/valuenode.cpp b/synfig-core/trunk/src/synfig/valuenode.cpp index 3654ab9..7db2649 100644 --- a/synfig-core/trunk/src/synfig/valuenode.cpp +++ b/synfig-core/trunk/src/synfig/valuenode.cpp @@ -45,6 +45,7 @@ #include "valuenode_scale.h" #include "valuenode_blinecalctangent.h" #include "valuenode_blinecalcvertex.h" +#include "valuenode_blinereversetangent.h" #include "valuenode_segcalctangent.h" #include "valuenode_segcalcvertex.h" #include "valuenode_repeat_gradient.h" @@ -116,6 +117,7 @@ ValueNode::subsys_init() ADD_VALUENODE(ValueNode_Scale, "scale", _("Scale") ); ADD_VALUENODE(ValueNode_BLineCalcTangent,"blinecalctangent",_("BLine Tangent") ); ADD_VALUENODE(ValueNode_BLineCalcVertex,"blinecalcvertex", _("BLine Vertex") ); + ADD_VALUENODE(ValueNode_BLineRevTangent,"blinerevtangent", _("Reverse Tangent") ); ADD_VALUENODE(ValueNode_SegCalcTangent, "segcalctangent", _("Segment Tangent") ); ADD_VALUENODE(ValueNode_SegCalcVertex, "segcalcvertex", _("Segment Vertex") ); ADD_VALUENODE(ValueNode_Stripes, "stripes", _("Stripes") ); diff --git a/synfig-core/trunk/src/synfig/valuenode_blinereversetangent.cpp b/synfig-core/trunk/src/synfig/valuenode_blinereversetangent.cpp new file mode 100644 index 0000000..b687798 --- /dev/null +++ b/synfig-core/trunk/src/synfig/valuenode_blinereversetangent.cpp @@ -0,0 +1,201 @@ +/* === S Y N F I G ========================================================= */ +/*! \file valuenode_blinerevtangent.cpp +** \brief Template File +** +** $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 +#endif + +#include "valuenode_blinereversetangent.h" +#include "valuenode_bline.h" +#include "valuenode_const.h" +#include "valuenode_composite.h" +#include "general.h" +#include "exception.h" +#include +#include + +#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_BLineRevTangent::ValueNode_BLineRevTangent(const ValueBase::Type &x): + LinkableValueNode(x) +{ +} + +ValueNode_BLineRevTangent::ValueNode_BLineRevTangent(const ValueNode::Handle &x): + LinkableValueNode(x->get_type()) +{ + if(x->get_type()!=ValueBase::TYPE_BLINEPOINT) + throw Exception::BadType(ValueBase::type_name(x->get_type())); + + set_link("reference",x); + set_link("reverse",ValueNode_Const::create(bool(false))); +} + +ValueNode_BLineRevTangent* +ValueNode_BLineRevTangent::create(const ValueBase &x) +{ + return new ValueNode_BLineRevTangent(ValueNode_Const::create(x)); +} + +LinkableValueNode* +ValueNode_BLineRevTangent::create_new()const +{ + return new ValueNode_BLineRevTangent(get_type()); +} + +ValueNode_BLineRevTangent::~ValueNode_BLineRevTangent() +{ + unlink_all(); +} + +ValueBase +ValueNode_BLineRevTangent::operator()(Time t)const +{ + if ((*reverse_)(t).get(bool())) + { + BLinePoint reference((*reference_)(t)); + BLinePoint ret(reference); + if(ret.get_split_tangent_flag()) + { + ret.set_tangent1(-reference.get_tangent2()); + ret.set_tangent2(-reference.get_tangent1()); + } + else + { + // \todo what should we do here really? + // it seems that there's some pre-existing bug + // with the 'reference' convert, too - referencing + // a non-split blinepoint causes some problems + ret.set_tangent1(-reference.get_tangent1()); + } + return ret; + } + else + return (*reference_)(t); +} + +String +ValueNode_BLineRevTangent::get_name()const +{ + return "blinerevtangent"; +} + +String +ValueNode_BLineRevTangent::get_local_name()const +{ + return _("Reverse Tangent"); +} + +bool +ValueNode_BLineRevTangent::set_link_vfunc(int i,ValueNode::Handle x) +{ + assert(i>=0 && i=0 && i=0 && i=0 && i Handle; + typedef etl::handle ConstHandle; + + virtual ValueBase operator()(Time t)const; + + virtual ~ValueNode_BLineRevTangent(); + + 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: + virtual bool set_link_vfunc(int i,ValueNode::Handle x); + LinkableValueNode* create_new()const; + +public: + using synfig::LinkableValueNode::get_link_vfunc; + using synfig::LinkableValueNode::set_link_vfunc; + static bool check_type(ValueBase::Type type); + static ValueNode_BLineRevTangent* create(const ValueBase &x=ValueBase::TYPE_VECTOR); +}; // END of class ValueNode_BLineRevTangent + +}; // END of namespace synfig + +/* === E N D =============================================================== */ + +#endif -- 2.7.4