X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fvaluenode.cpp;h=51cd1ffba83879c0e2884cfb8d475c18c86c2cc1;hb=cdd61095e448109f06e50f2ea461459413082220;hp=61714a21e6fa8a33d868a6daa839ff4f0b290fc9;hpb=d8a0d032dc97e5c058ef37b79e245689b2ae7c10;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/valuenode.cpp b/synfig-core/trunk/src/synfig/valuenode.cpp index 61714a2..51cd1ff 100644 --- a/synfig-core/trunk/src/synfig/valuenode.cpp +++ b/synfig-core/trunk/src/synfig/valuenode.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ /*! \file valuenode.cpp -** \brief Template File +** \brief Implementation of the "Placeholder" 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 @@ -36,16 +37,22 @@ #include "valuenode.h" #include "general.h" #include "canvas.h" +#include "paramdesc.h" #include "valuenode_const.h" #include "valuenode_linear.h" #include "valuenode_composite.h" #include "valuenode_reference.h" #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" #include "valuenode_stripes.h" +#include "valuenode_range.h" +#include "valuenode_add.h" #include "valuenode_subtract.h" #include "valuenode_timedswap.h" #include "valuenode_twotone.h" @@ -54,7 +61,14 @@ #include "valuenode_radialcomposite.h" #include "valuenode_gradientrotate.h" #include "valuenode_sine.h" +#include "valuenode_cos.h" +#include "valuenode_atan2.h" #include "valuenode_exp.h" +#include "valuenode_switch.h" +#include "valuenode_timeloop.h" +#include "valuenode_reciprocal.h" +#include "valuenode_duplicate.h" +#include "valuenode_integer.h" #include "layer.h" @@ -106,9 +120,14 @@ ValueNode::subsys_init() ADD_VALUENODE(ValueNode_Reference, "reference", _("Reference") ); ADD_VALUENODE(ValueNode_Repeat_Gradient,"repeat_gradient", _("Repeat Gradient") ); 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") ); + ADD_VALUENODE(ValueNode_Range, "range", _("Range") ); + ADD_VALUENODE(ValueNode_Add, "add", _("Add") ); ADD_VALUENODE(ValueNode_Subtract, "subtract", _("Subtract") ); ADD_VALUENODE(ValueNode_TimedSwap, "timed_swap", _("Timed Swap") ); ADD_VALUENODE(ValueNode_TwoTone, "twotone", _("Two-Tone") ); @@ -116,7 +135,14 @@ ValueNode::subsys_init() ADD_VALUENODE2(ValueNode_DynamicList, "dynamic_list", _("Dynamic List") ); ADD_VALUENODE(ValueNode_GradientRotate, "gradient_rotate", _("Gradient Rotate") ); ADD_VALUENODE(ValueNode_Sine, "sine", _("Sine") ); + ADD_VALUENODE(ValueNode_Cos, "cos", _("Cos") ); + ADD_VALUENODE(ValueNode_Atan2, "atan2", _("aTan2") ); ADD_VALUENODE(ValueNode_Exp, "exp", _("Exponential") ); + 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 @@ -140,19 +166,19 @@ ValueNode::subsys_stop() for(iter=global_value_node_map.begin();iter!=global_value_node_map.end();++iter) { if(!iter->second->is_exported()) - synfig::info("%s: count:%d name:%s type:%s", + synfig::info(_("%s: count:%d name:%s type:%s"), iter->first.get_string().c_str(), iter->second->count(), iter->second->get_name().c_str(), - ValueBase::type_name(iter->second->get_type()).c_str() + ValueBase::type_local_name(iter->second->get_type()).c_str() ); else - synfig::info("%s: id:%s count:%d name:%s type:%s", + synfig::info(_("%s: id:%s count:%d name:%s type:%s"), iter->first.get_string().c_str(), iter->second->get_id().c_str(), iter->second->count(), iter->second->get_name().c_str(), - ValueBase::type_name(iter->second->get_type()).c_str() + ValueBase::type_local_name(iter->second->get_type()).c_str() ); } } @@ -176,6 +202,17 @@ LinkableValueNode::create(const String &name, const ValueBase& x) { if(!book().count(name)) return 0; + + if (!check_type(name, x.get_type()) && + // the Duplicate ValueNode is an exception - we don't want the + // user creating it for themselves, so check_type() fails for + // it even when it is valid + !(name == "duplicate" && x.get_type() == ValueBase::TYPE_REAL)) + { + error(_("Bad type: ValueNode '%s' doesn't accept type '%s'"), book()[name].local_name.c_str(), ValueBase::type_local_name(x.get_type()).c_str()); + return 0; + } + return book()[name].factory(x); } @@ -230,8 +267,6 @@ ValueNode::~ValueNode() value_node_count--; begin_delete(); - - //DEBUGPOINT(); } void @@ -276,6 +311,15 @@ ValueNode::set_id(const String &x) } } +String +ValueNode::get_description(bool show_exported_name)const +{ + if (dynamic_cast(this)) + return (dynamic_cast(this))->get_description(-1, show_exported_name); + + return "ValueNode"; +} + ValueNodeList::ValueNodeList(): placeholder_count_(0) { @@ -289,7 +333,8 @@ ValueNodeList::count(const String &id)const if(id.empty()) return false; - for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter); + for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter) + ; if(iter==end()) return false; @@ -305,7 +350,8 @@ ValueNodeList::find(const String &id) if(id.empty()) throw Exception::IDNotFound("Empty ID"); - for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter); + for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter) + ; if(iter==end()) throw Exception::IDNotFound("ValueNode in ValueNodeList: "+id); @@ -321,7 +367,8 @@ ValueNodeList::find(const String &id)const if(id.empty()) throw Exception::IDNotFound("Empty ID"); - for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter); + for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter) + ; if(iter==end()) throw Exception::IDNotFound("ValueNode in ValueNodeList: "+id); @@ -451,7 +498,12 @@ PlaceholderValueNode::PlaceholderValueNode(ValueBase::Type type): ValueNode* LinkableValueNode::clone(const GUID& deriv_guid)const { - { ValueNode* x(find_value_node(get_guid()^deriv_guid).get()); if(x)return x; } + // printf("%s:%d clone()\n", __FILE__, __LINE__); + { ValueNode* x(find_value_node(get_guid()^deriv_guid).get()); if(x) + { + printf("VALUENODE FOUND VALUENODE\n"); + return x; + }} int i; LinkableValueNode *ret=create_new(); @@ -516,3 +568,59 @@ void LinkableValueNode::get_times_vfunc(Node::time_set &set) const } } } + +String +LinkableValueNode::get_description(int index, bool show_exported_name)const +{ + String description; + + if (show_exported_name && !is_exported()) + show_exported_name = false; + + if (index != -1) + description = String(":") + link_local_name(index); + + const synfig::Node* node = this; + LinkableValueNode::ConstHandle parent_linkable_vn = 0; + + // walk up through the valuenodes trying to find the layer at the top + while (!node->parent_set.empty() && !dynamic_cast(node)) + { + LinkableValueNode::ConstHandle linkable_value_node(dynamic_cast(node)); + if (linkable_value_node) + { + String link; + int cnt = linkable_value_node->link_count(); + for (int i = 0; i < cnt; i++) + if (linkable_value_node->get_link(i) == parent_linkable_vn) + { + link = String(":") + linkable_value_node->link_local_name(i); + break; + } + + description = linkable_value_node->get_local_name() + link + (parent_linkable_vn?">":"") + description; + } + node = *node->parent_set.begin(); + parent_linkable_vn = linkable_value_node; + } + + Layer::ConstHandle parent_layer(dynamic_cast(node)); + if(parent_layer) + { + String param; + const Layer::DynamicParamList &dynamic_param_list(parent_layer->dynamic_param_list()); + // loop to find the parameter in the dynamic parameter list - this gives us its name + for (Layer::DynamicParamList::const_iterator iter = dynamic_param_list.begin(); iter != dynamic_param_list.end(); iter++) + if (iter->second == parent_linkable_vn) + param = String(":") + parent_layer->get_param_local_name(iter->first); + description = strprintf("(%s)%s>%s", + parent_layer->get_non_empty_description().c_str(), + param.c_str(), + description.c_str()); + } + + if (show_exported_name) + description += strprintf(" (%s)", get_id().c_str()); + + return description; +}