From: pabs3 Date: Sun, 3 May 2009 04:07:37 +0000 (+0000) Subject: Apply patch #21: add boolean ValueNode conversions. Thanks to nikitakit. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1891afee8b0ad9e67c56b1c262a940a0bb5042cb;p=synfig.git Apply patch #21: add boolean ValueNode conversions. Thanks to nikitakit. git-svn-id: https://synfig.svn.sourceforge.net/svnroot/synfig@2364 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/AUTHORS b/synfig-core/trunk/AUTHORS index 8e6c4fe..d6d0efc 100644 --- a/synfig-core/trunk/AUTHORS +++ b/synfig-core/trunk/AUTHORS @@ -17,6 +17,7 @@ Gerco Ballintijn Daniel Hornung (rubikcube) Sean Bartell (wtachi) Cyril Brulebois (KiBi) +Nikita Kitaev (nikitakit) Translators: diff --git a/synfig-core/trunk/README b/synfig-core/trunk/README index db8a784..d7ce63c 100644 --- a/synfig-core/trunk/README +++ b/synfig-core/trunk/README @@ -31,6 +31,7 @@ Copyright 2006-2007 Paul Wise Copyright 2007-2008 Chris Moore Copyright 2008 Carlos López Copyright 2008 Gerco Ballintijn +Copyright 2009 Nikita Kitaev Licence diff --git a/synfig-core/trunk/po/POTFILES.in b/synfig-core/trunk/po/POTFILES.in index c37c4cf..5da5584 100644 --- a/synfig-core/trunk/po/POTFILES.in +++ b/synfig-core/trunk/po/POTFILES.in @@ -281,6 +281,8 @@ src/synfig/valuenode.cpp src/synfig/valuenode.h src/synfig/valuenode_add.cpp src/synfig/valuenode_add.h +src/synfig/valuenode_and.cpp +src/synfig/valuenode_and.h src/synfig/valuenode_animated.cpp src/synfig/valuenode_animated.h src/synfig/valuenode_bline.cpp @@ -295,6 +297,8 @@ src/synfig/valuenode_composite.cpp src/synfig/valuenode_composite.h src/synfig/valuenode_const.cpp src/synfig/valuenode_const.h +src/synfig/valuenode_compare.cpp +src/synfig/valuenode_compare.h src/synfig/valuenode_cos.cpp src/synfig/valuenode_cos.h src/synfig/valuenode_duplicate.cpp @@ -311,6 +315,12 @@ src/synfig/valuenode_join.cpp src/synfig/valuenode_join.h src/synfig/valuenode_linear.cpp src/synfig/valuenode_linear.h +src/synfig/valuenode_not.cpp +src/synfig/valuenode_not.h +src/synfig/valuenode_or.cpp +src/synfig/valuenode_or.h +src/synfig/valuenode_pow.cpp +src/synfig/valuenode_pow.h src/synfig/valuenode_radialcomposite.cpp src/synfig/valuenode_radialcomposite.h src/synfig/valuenode_range.cpp diff --git a/synfig-core/trunk/src/synfig/Makefile.am b/synfig-core/trunk/src/synfig/Makefile.am index 88a6b90..4ed8b13 100644 --- a/synfig-core/trunk/src/synfig/Makefile.am +++ b/synfig-core/trunk/src/synfig/Makefile.am @@ -61,6 +61,7 @@ IMPORTERSOURCES = \ VALUENODEHEADERS = \ valuenode_add.h \ + valuenode_and.h \ valuenode_anglestring.h \ valuenode_animated.h \ valuenode_atan2.h \ @@ -69,6 +70,7 @@ VALUENODEHEADERS = \ valuenode_blinecalcvertex.h \ valuenode_blinecalcwidth.h \ valuenode_blinereversetangent.h \ + valuenode_compare.h \ valuenode_composite.h \ valuenode_const.h \ valuenode_cos.h \ @@ -84,6 +86,8 @@ VALUENODEHEADERS = \ valuenode_join.h \ valuenode_linear.h \ valuenode_log.h \ + valuenode_not.h \ + valuenode_or.h \ valuenode_pow.h \ valuenode_radialcomposite.h \ valuenode_range.h \ @@ -110,6 +114,7 @@ VALUENODEHEADERS = \ VALUENODESOURCES = \ valuenode_add.cpp \ + valuenode_and.cpp \ valuenode_anglestring.cpp \ valuenode_animated.cpp \ valuenode_atan2.cpp \ @@ -118,6 +123,7 @@ VALUENODESOURCES = \ valuenode_blinecalcvertex.cpp \ valuenode_blinecalcwidth.cpp \ valuenode_blinereversetangent.cpp \ + valuenode_compare.cpp \ valuenode_composite.cpp \ valuenode_const.cpp \ valuenode_cos.cpp \ @@ -133,6 +139,8 @@ VALUENODESOURCES = \ valuenode_join.cpp \ valuenode_linear.cpp \ valuenode_log.cpp \ + valuenode_not.cpp \ + valuenode_or.cpp \ valuenode_pow.cpp \ valuenode_radialcomposite.cpp \ valuenode_range.cpp \ diff --git a/synfig-core/trunk/src/synfig/valuenode.cpp b/synfig-core/trunk/src/synfig/valuenode.cpp index 21645c8..d1e3256 100644 --- a/synfig-core/trunk/src/synfig/valuenode.cpp +++ b/synfig-core/trunk/src/synfig/valuenode.cpp @@ -87,6 +87,10 @@ #include "valuenode_intstring.h" #include "valuenode_log.h" #include "valuenode_pow.h" +#include "valuenode_compare.h" +#include "valuenode_not.h" +#include "valuenode_and.h" +#include "valuenode_or.h" #include "layer.h" @@ -182,7 +186,11 @@ ValueNode::subsys_init() ADD_VALUENODE(ValueNode_Logarithm, "logarithm", _("Logarithm"), RELEASE_VERSION_0_61_09); // SVN r2034 ADD_VALUENODE(ValueNode_Greyed, "greyed", _("Greyed"), RELEASE_VERSION_0_61_10); // SVN r2305 - ADD_VALUENODE(ValueNode_Pow, "power", _("Power"), RELEASE_VERSION_0_61_09); // SVN r2362 + ADD_VALUENODE(ValueNode_Pow, "power", _("Power"), RELEASE_VERSION_0_61_10); // SVN r2362 + ADD_VALUENODE(ValueNode_Compare, "compare", _("Compare"), RELEASE_VERSION_0_61_10); // SVN r2364 + ADD_VALUENODE(ValueNode_Not, "not", _("Not"), RELEASE_VERSION_0_61_10); // SVN r2364 + ADD_VALUENODE(ValueNode_And, "and", _("And"), RELEASE_VERSION_0_61_10); // SVN r2364 + ADD_VALUENODE(ValueNode_Or, "or", _("Or"), RELEASE_VERSION_0_61_10); // SVN r2364 #undef ADD_VALUENODE #undef ADD_VALUENODE2 diff --git a/synfig-core/trunk/src/synfig/valuenode_and.cpp b/synfig-core/trunk/src/synfig/valuenode_and.cpp new file mode 100644 index 0000000..974485c --- /dev/null +++ b/synfig-core/trunk/src/synfig/valuenode_and.cpp @@ -0,0 +1,168 @@ +/* === S Y N F I G ========================================================= */ +/*! \file valuenode_and.cpp +** \brief Implementation of the "And" valuenode conversion. +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore +** Copyright (c) 2009 Nikita Kitaev +** +** 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_and.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_And::ValueNode_And(const ValueBase &x): + LinkableValueNode(x.get_type()) +{ + bool value(x.get(bool())); + + set_link("link1", ValueNode_Const::create(bool(true))); + set_link("link2", ValueNode_Const::create(bool(false))); + if (value) + set_link("link2",ValueNode_Const::create(bool(true))); +} + +ValueNode_And* +ValueNode_And::create(const ValueBase &x) +{ + return new ValueNode_And(x); +} + +LinkableValueNode* +ValueNode_And::create_new()const +{ + return new ValueNode_And(get_type()); +} + +ValueNode_And::~ValueNode_And() +{ + unlink_all(); +} + +bool +ValueNode_And::set_link_vfunc(int i,ValueNode::Handle value) +{ + assert(i>=0 && i=0 && i=0 && i=0 && i Handle; + typedef etl::handle ConstHandle; + + ValueNode_And(const ValueBase &x); + + virtual ValueBase operator()(Time t)const; + + virtual ~ValueNode_And(); + + 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_And* create(const ValueBase &x); +}; // END of class ValueNode_And + +}; // END of namespace synfig + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-core/trunk/src/synfig/valuenode_compare.cpp b/synfig-core/trunk/src/synfig/valuenode_compare.cpp new file mode 100644 index 0000000..68c3427 --- /dev/null +++ b/synfig-core/trunk/src/synfig/valuenode_compare.cpp @@ -0,0 +1,197 @@ +/* === S Y N F I G ========================================================= */ +/*! \file valuenode_compare.cpp +** \brief Implementation of the "Compare" valuenode conversion. +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007, 2008 Chris Moore +** Copyright (c) 2009 Nikita Kitaev +** +** 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_compare.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_Compare::ValueNode_Compare(const ValueBase &x): + LinkableValueNode(x.get_type()) +{ + bool value(x.get(bool())); + + set_link("lhs", ValueNode_Const::create(Real(0))); + set_link("rhs", ValueNode_Const::create(Real(0))); + set_link("greater", ValueNode_Const::create(bool(false))); + if (value) + set_link("equal",ValueNode_Const::create(bool(true))); + else + set_link("equal",ValueNode_Const::create(bool(false))); + set_link("less", ValueNode_Const::create(bool(false))); +} + +ValueNode_Compare* +ValueNode_Compare::create(const ValueBase &x) +{ + return new ValueNode_Compare(x); +} + +LinkableValueNode* +ValueNode_Compare::create_new()const +{ + return new ValueNode_Compare(get_type()); +} + +ValueNode_Compare::~ValueNode_Compare() +{ + unlink_all(); +} + +bool +ValueNode_Compare::set_link_vfunc(int i,ValueNode::Handle value) +{ + assert(i>=0 && i=0 && i=0 && i=0 && i rhs) + return true; + if (equal && lhs == rhs) + return true; + if (less && lhs < rhs) + return true; + + return false; +} + +String +ValueNode_Compare::get_name()const +{ + return "compare"; +} + +String +ValueNode_Compare::get_local_name()const +{ + return _("Compare"); +} + +bool +ValueNode_Compare::check_type(ValueBase::Type type) +{ + return type==ValueBase::TYPE_BOOL; +} diff --git a/synfig-core/trunk/src/synfig/valuenode_compare.h b/synfig-core/trunk/src/synfig/valuenode_compare.h new file mode 100644 index 0000000..da156de --- /dev/null +++ b/synfig-core/trunk/src/synfig/valuenode_compare.h @@ -0,0 +1,85 @@ +/* === S Y N F I G ========================================================= */ +/*! \file valuenode_compare.h +** \brief Header file for implementation of the "Compare" valuenode conversion. +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore +** Copyright (c) 2009 Nikita Kitaev +** +** 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_COMPARE_H +#define __SYNFIG_VALUENODE_COMPARE_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_Compare : public LinkableValueNode +{ + ValueNode::RHandle lhs_; + ValueNode::RHandle rhs_; + ValueNode::RHandle greater_; + ValueNode::RHandle equal_; + ValueNode::RHandle less_; + +public: + typedef etl::handle Handle; + typedef etl::handle ConstHandle; + + ValueNode_Compare(const ValueBase &x); + + virtual ValueBase operator()(Time t)const; + + virtual ~ValueNode_Compare(); + + 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_Compare* create(const ValueBase &x); +}; // END of class ValueNode_Compare + +}; // END of namespace synfig + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-core/trunk/src/synfig/valuenode_not.cpp b/synfig-core/trunk/src/synfig/valuenode_not.cpp new file mode 100644 index 0000000..b7ca310 --- /dev/null +++ b/synfig-core/trunk/src/synfig/valuenode_not.cpp @@ -0,0 +1,159 @@ +/* === S Y N F I G ========================================================= */ +/*! \file valuenode_not.cpp +** \brief Implementation of the "Not" valuenode conversion. +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore +** Copyright (c) 2009 Nikita Kitaev +** +** 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_not.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_Not::ValueNode_Not(const ValueBase &x): + LinkableValueNode(x.get_type()) +{ + bool value(x.get(bool())); + + set_link("link", ValueNode_Const::create(!value)); +} + +ValueNode_Not* +ValueNode_Not::create(const ValueBase &x) +{ + return new ValueNode_Not(x); +} + +LinkableValueNode* +ValueNode_Not::create_new()const +{ + return new ValueNode_Not(get_type()); +} + +ValueNode_Not::~ValueNode_Not() +{ + unlink_all(); +} + +bool +ValueNode_Not::set_link_vfunc(int i,ValueNode::Handle value) +{ + assert(i>=0 && i=0 && i=0 && i=0 && i Handle; + typedef etl::handle ConstHandle; + + ValueNode_Not(const ValueBase &x); + + virtual ValueBase operator()(Time t)const; + + virtual ~ValueNode_Not(); + + 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_Not* create(const ValueBase &x); +}; // END of class ValueNode_Not + +}; // END of namespace synfig + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-core/trunk/src/synfig/valuenode_or.cpp b/synfig-core/trunk/src/synfig/valuenode_or.cpp new file mode 100644 index 0000000..a2d9e71 --- /dev/null +++ b/synfig-core/trunk/src/synfig/valuenode_or.cpp @@ -0,0 +1,168 @@ +/* === S Y N F I G ========================================================= */ +/*! \file valuenode_or.cpp +** \brief Implementation of the "Or" valuenode conversion. +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore +** Copyright (c) 2009 Nikita Kitaev +** +** 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_or.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_Or::ValueNode_Or(const ValueBase &x): + LinkableValueNode(x.get_type()) +{ + bool value(x.get(bool())); + + set_link("link1", ValueNode_Const::create(bool(false))); + set_link("link2", ValueNode_Const::create(bool(false))); + if (value) + set_link("link1",ValueNode_Const::create(bool(true))); +} + +ValueNode_Or* +ValueNode_Or::create(const ValueBase &x) +{ + return new ValueNode_Or(x); +} + +LinkableValueNode* +ValueNode_Or::create_new()const +{ + return new ValueNode_Or(get_type()); +} + +ValueNode_Or::~ValueNode_Or() +{ + unlink_all(); +} + +bool +ValueNode_Or::set_link_vfunc(int i,ValueNode::Handle value) +{ + assert(i>=0 && i=0 && i=0 && i=0 && i Handle; + typedef etl::handle ConstHandle; + + ValueNode_Or(const ValueBase &x); + + virtual ValueBase operator()(Time t)const; + + virtual ~ValueNode_Or(); + + 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_Or* create(const ValueBase &x); +}; // END of class ValueNode_Or + +}; // END of namespace synfig + +/* === E N D =============================================================== */ + +#endif