Correct the release version for those valuenodes.
[synfig.git] / synfig-core / src / synfig / valuenode.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuenode.cpp
3 **      \brief Implementation of the "Placeholder" valuenode conversion.
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2007, 2008 Chris Moore
10 **  Copyright (c) 2008 Carlos López
11 **
12 **      This package is free software; you can redistribute it and/or
13 **      modify it under the terms of the GNU General Public License as
14 **      published by the Free Software Foundation; either version 2 of
15 **      the License, or (at your option) any later version.
16 **
17 **      This package is distributed in the hope that it will be useful,
18 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
19 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 **      General Public License for more details.
21 **      \endlegal
22 */
23 /* ========================================================================= */
24
25 /* === H E A D E R S ======================================================= */
26
27 #define SYNFIG_NO_ANGLE
28
29 //#define HAS_HASH_MAP 1
30
31 #ifdef USING_PCH
32 #       include "pch.h"
33 #else
34 #ifdef HAVE_CONFIG_H
35 #       include <config.h>
36 #endif
37
38 #include "valuenode.h"
39 #include "general.h"
40 #include "canvas.h"
41 #include "paramdesc.h"
42 #include "releases.h"
43
44 #include "valuenode_const.h"
45 #include "valuenode_linear.h"
46 #include "valuenode_composite.h"
47 #include "valuenode_reference.h"
48 #include "valuenode_greyed.h"
49 #include "valuenode_scale.h"
50 #include "valuenode_blinecalctangent.h"
51 #include "valuenode_blinecalcvertex.h"
52 #include "valuenode_blinecalcwidth.h"
53 #include "valuenode_blinereversetangent.h"
54 #include "valuenode_segcalctangent.h"
55 #include "valuenode_segcalcvertex.h"
56 #include "valuenode_repeat_gradient.h"
57 #include "valuenode_stripes.h"
58 #include "valuenode_range.h"
59 #include "valuenode_add.h"
60 #include "valuenode_subtract.h"
61 #include "valuenode_timedswap.h"
62 #include "valuenode_twotone.h"
63 #include "valuenode_bline.h"
64 #include "valuenode_dynamiclist.h"
65 #include "valuenode_radialcomposite.h"
66 #include "valuenode_gradientrotate.h"
67 #include "valuenode_sine.h"
68 #include "valuenode_cos.h"
69 #include "valuenode_atan2.h"
70 #include "valuenode_exp.h"
71 #include "valuenode_switch.h"
72 #include "valuenode_timeloop.h"
73 #include "valuenode_reciprocal.h"
74 #include "valuenode_duplicate.h"
75 #include "valuenode_integer.h"
76 #include "valuenode_step.h"
77 #include "valuenode_vectorangle.h"
78 #include "valuenode_vectorlength.h"
79 #include "valuenode_vectorx.h"
80 #include "valuenode_vectory.h"
81 #include "valuenode_gradientcolor.h"
82 #include "valuenode_dotproduct.h"
83 #include "valuenode_timestring.h"
84 #include "valuenode_realstring.h"
85 #include "valuenode_join.h"
86 #include "valuenode_anglestring.h"
87 #include "valuenode_intstring.h"
88 #include "valuenode_log.h"
89 #include "valuenode_pow.h"
90 #include "valuenode_compare.h"
91 #include "valuenode_not.h"
92 #include "valuenode_and.h"
93 #include "valuenode_or.h"
94
95 #include "layer.h"
96
97 #endif
98
99 /* === U S I N G =========================================================== */
100
101 using namespace std;
102 using namespace etl;
103 using namespace synfig;
104
105 /* === M A C R O S ========================================================= */
106
107 /* === G L O B A L S ======================================================= */
108
109 static int value_node_count(0);
110
111 static LinkableValueNode::Book *book_;
112
113
114 ValueNode::LooseHandle
115 synfig::find_value_node(const GUID& guid)
116 {
117         return guid_cast<ValueNode>(guid);
118 }
119
120 /* === P R O C E D U R E S ================================================= */
121
122 /* === M E T H O D S ======================================================= */
123
124 bool
125 ValueNode::subsys_init()
126 {
127         book_=new LinkableValueNode::Book();
128
129 #define ADD_VALUENODE(class,name,local,version)                                                                                                 \
130         (*book_)[name].factory=reinterpret_cast<LinkableValueNode::Factory>(&class::create);            \
131         (*book_)[name].check_type=&class::check_type;                                                                                           \
132         (*book_)[name].local_name=local;                                                                                                                        \
133         (*book_)[name].release_version=version
134
135 #define ADD_VALUENODE2(class,name,local,version)                                                                                                \
136         (*book_)[name].factory=reinterpret_cast<LinkableValueNode::Factory>(&class::create_from);       \
137         (*book_)[name].check_type=&class::check_type;                                                                                           \
138         (*book_)[name].local_name=local;                                                                                                                        \
139         (*book_)[name].release_version=version
140
141         ADD_VALUENODE(ValueNode_Linear,                   "linear",                       _("Linear"),                   RELEASE_VERSION_0_61_06);
142         ADD_VALUENODE(ValueNode_Composite,                "composite",            _("Composite"),                RELEASE_VERSION_0_61_06);
143         ADD_VALUENODE(ValueNode_RadialComposite,  "radial_composite", _("Radial Composite"), RELEASE_VERSION_0_61_06);
144         ADD_VALUENODE(ValueNode_Reference,                "reference",            _("Reference"),                RELEASE_VERSION_0_61_06);
145         ADD_VALUENODE(ValueNode_Scale,                    "scale",                        _("Scale"),                    RELEASE_VERSION_0_61_06);
146         ADD_VALUENODE(ValueNode_SegCalcTangent,   "segcalctangent",       _("Segment Tangent"),  RELEASE_VERSION_0_61_06);
147         ADD_VALUENODE(ValueNode_SegCalcVertex,    "segcalcvertex",        _("Segment Vertex"),   RELEASE_VERSION_0_61_06);
148         ADD_VALUENODE(ValueNode_Stripes,                  "stripes",              _("Stripes"),                  RELEASE_VERSION_0_61_06);
149         ADD_VALUENODE(ValueNode_Subtract,                 "subtract",             _("Subtract"),                 RELEASE_VERSION_0_61_06);
150         ADD_VALUENODE(ValueNode_TwoTone,                  "twotone",              _("Two-Tone"),                 RELEASE_VERSION_0_61_06);
151         ADD_VALUENODE(ValueNode_BLine,                    "bline",                        _("BLine"),                    RELEASE_VERSION_0_61_06);
152         ADD_VALUENODE2(ValueNode_DynamicList,     "dynamic_list",         _("Dynamic List"),     RELEASE_VERSION_0_61_06);
153         ADD_VALUENODE(ValueNode_GradientRotate,   "gradient_rotate",  _("Gradient Rotate"),      RELEASE_VERSION_0_61_06);
154         ADD_VALUENODE(ValueNode_Sine,                     "sine",                         _("Sine"),                     RELEASE_VERSION_0_61_06);
155
156         ADD_VALUENODE(ValueNode_TimedSwap,                "timed_swap",           _("Timed Swap"),               RELEASE_VERSION_0_61_07); // SVN r610
157         ADD_VALUENODE(ValueNode_Repeat_Gradient,  "repeat_gradient",  _("Repeat Gradient"),      RELEASE_VERSION_0_61_07); // SVN r666
158         ADD_VALUENODE(ValueNode_Exp,                      "exp",                          _("Exponential"),              RELEASE_VERSION_0_61_07); // SVN r739
159         ADD_VALUENODE(ValueNode_Add,                      "add",                          _("Add"),                              RELEASE_VERSION_0_61_07); // SVN r742
160         ADD_VALUENODE(ValueNode_BLineCalcTangent, "blinecalctangent", _("BLine Tangent"),        RELEASE_VERSION_0_61_07); // SVN r744
161         ADD_VALUENODE(ValueNode_BLineCalcVertex,  "blinecalcvertex",  _("BLine Vertex"),         RELEASE_VERSION_0_61_07); // SVN r744
162         ADD_VALUENODE(ValueNode_Range,                    "range",                        _("Range"),                    RELEASE_VERSION_0_61_07); // SVN r776
163
164         ADD_VALUENODE(ValueNode_Switch,                   "switch",                       _("Switch"),                   RELEASE_VERSION_0_61_08); // SVN r923
165         ADD_VALUENODE(ValueNode_Cos,                      "cos",                          _("Cos"),                              RELEASE_VERSION_0_61_08); // SVN r1111
166         ADD_VALUENODE(ValueNode_Atan2,                    "atan2",                        _("aTan2"),                    RELEASE_VERSION_0_61_08); // SVN r1132
167         ADD_VALUENODE(ValueNode_BLineRevTangent,  "blinerevtangent",  _("Reverse Tangent"),      RELEASE_VERSION_0_61_08); // SVN r1162
168         ADD_VALUENODE(ValueNode_TimeLoop,                 "timeloop",             _("Time Loop"),                RELEASE_VERSION_0_61_08); // SVN r1226
169         ADD_VALUENODE(ValueNode_Reciprocal,               "reciprocal",           _("Reciprocal"),               RELEASE_VERSION_0_61_08); // SVN r1238
170         ADD_VALUENODE(ValueNode_Duplicate,                "duplicate",            _("Duplicate"),                RELEASE_VERSION_0_61_08); // SVN r1267
171         ADD_VALUENODE(ValueNode_Integer,                  "fromint",              _("From Integer"),     RELEASE_VERSION_0_61_08); // SVN r1267
172         ADD_VALUENODE(ValueNode_Step,                     "step",                         _("Step"),                     RELEASE_VERSION_0_61_08); // SVN r1691
173         ADD_VALUENODE(ValueNode_BLineCalcWidth,   "blinecalcwidth",       _("BLine Width"),              RELEASE_VERSION_0_61_08); // SVN r1694
174
175         ADD_VALUENODE(ValueNode_VectorAngle,      "vectorangle",          _("Vector Angle"),     RELEASE_VERSION_0_61_09); // SVN r1880
176         ADD_VALUENODE(ValueNode_VectorLength,     "vectorlength",         _("Vector Length"),    RELEASE_VERSION_0_61_09); // SVN r1881
177         ADD_VALUENODE(ValueNode_VectorX,                  "vectorx",              _("Vector X"),                 RELEASE_VERSION_0_61_09); // SVN r1882
178         ADD_VALUENODE(ValueNode_VectorY,                  "vectory",              _("Vector Y"),                 RELEASE_VERSION_0_61_09); // SVN r1882
179         ADD_VALUENODE(ValueNode_GradientColor,    "gradientcolor",        _("Gradient Color"),   RELEASE_VERSION_0_61_09); // SVN r1885
180         ADD_VALUENODE(ValueNode_DotProduct,               "dotproduct",           _("Dot Product"),              RELEASE_VERSION_0_61_09); // SVN r1891
181         ADD_VALUENODE(ValueNode_TimeString,               "timestring",           _("Time String"),              RELEASE_VERSION_0_61_09); // SVN r2000
182         ADD_VALUENODE(ValueNode_RealString,               "realstring",           _("Real String"),              RELEASE_VERSION_0_61_09); // SVN r2003
183         ADD_VALUENODE(ValueNode_Join,                     "join",                         _("Joined List"),              RELEASE_VERSION_0_61_09); // SVN r2007
184         ADD_VALUENODE(ValueNode_AngleString,      "anglestring",          _("Angle String"),     RELEASE_VERSION_0_61_09); // SVN r2010
185         ADD_VALUENODE(ValueNode_IntString,                "intstring",            _("Int String"),               RELEASE_VERSION_0_61_09); // SVN r2010
186         ADD_VALUENODE(ValueNode_Logarithm,                "logarithm",            _("Logarithm"),                RELEASE_VERSION_0_61_09); // SVN r2034
187
188         ADD_VALUENODE(ValueNode_Greyed,                   "greyed",                       _("Greyed"),                   RELEASE_VERSION_0_62_00); // SVN r2305
189         ADD_VALUENODE(ValueNode_Pow,                  "power",                _("Power"),                    RELEASE_VERSION_0_62_00); // SVN r2362
190         ADD_VALUENODE(ValueNode_Compare,                  "compare",              _("Compare"),                  RELEASE_VERSION_0_62_00); // SVN r2364
191         ADD_VALUENODE(ValueNode_Not,                  "not",                      _("Not"),                              RELEASE_VERSION_0_62_00); // SVN r2364
192         ADD_VALUENODE(ValueNode_And,                  "and",                      _("And"),                              RELEASE_VERSION_0_62_00); // SVN r2364
193         ADD_VALUENODE(ValueNode_Or,                       "or",                   _("Or"),                                       RELEASE_VERSION_0_62_00); // SVN r2364
194
195 #undef ADD_VALUENODE
196 #undef ADD_VALUENODE2
197
198         return true;
199 }
200
201 bool
202 ValueNode::subsys_stop()
203 {
204         delete book_;
205 /*      if(global_value_node_map.size() || value_node_count)
206         {
207                 if(value_node_count)
208                         synfig::error("%d ValueNodes haven't been destroyed yet!",value_node_count);
209
210                 if(global_value_node_map.size()!=value_node_count)
211                         synfig::error("value node count mismatch! map.size()!=value_node_count (%d!=%d)",global_value_node_map.size(),value_node_count);
212
213                 GlobalValueNodeMap::iterator iter;
214                 for(iter=global_value_node_map.begin();iter!=global_value_node_map.end();++iter)
215                 {
216                         if(!iter->second->is_exported())
217                                 synfig::info(_("%s: count:%d name:%s type:%s"),
218                                         iter->first.get_string().c_str(),
219                                         iter->second->count(),
220                                         iter->second->get_name().c_str(),
221                                         ValueBase::type_local_name(iter->second->get_type()).c_str()
222                                 );
223                         else
224                                 synfig::info(_("%s: id:%s count:%d name:%s type:%s"),
225                                         iter->first.get_string().c_str(),
226                                         iter->second->get_id().c_str(),
227                                         iter->second->count(),
228                                         iter->second->get_name().c_str(),
229                                         ValueBase::type_local_name(iter->second->get_type()).c_str()
230                                 );
231                 }
232         }
233 */
234         return true;
235 }
236
237 ValueNode::ValueNode(ValueBase::Type type):type(type)
238 {
239         value_node_count++;
240 }
241
242 LinkableValueNode::Book&
243 LinkableValueNode::book()
244 {
245         return *book_;
246 }
247
248 LinkableValueNode::Handle
249 LinkableValueNode::create(const String &name, const ValueBase& x)
250 {
251         if(!book().count(name))
252                 return 0;
253
254         if (!check_type(name, x.get_type()) &&
255                 // the Duplicate ValueNode is an exception - we don't want the
256                 // user creating it for themselves, so check_type() fails for
257                 // it even when it is valid
258                 !(name == "duplicate" && x.get_type() == ValueBase::TYPE_REAL))
259         {
260                 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());
261                 return 0;
262         }
263
264         return book()[name].factory(x);
265 }
266
267 bool
268 LinkableValueNode::check_type(const String &name, ValueBase::Type x)
269 {
270         if(!book().count(name) || !book()[name].check_type)
271                 return false;
272         return book()[name].check_type(x);
273 }
274
275 bool
276 LinkableValueNode::set_link(int i,ValueNode::Handle x)
277 {
278         ValueNode::Handle previous(get_link(i));
279
280         if(set_link_vfunc(i,x))
281         {
282                 // Fix 2412072: remove the previous link from the parent_set unless one of the other links is also
283                 // using it when we convert a value to 'switch', both 'on' and 'off' are linked to the same valuenode
284                 // if we then disconnect one of the two, the one we disconnect is set to be a new valuenode_const
285                 // and the previously shared value is removed from the parent set even though the other is still
286                 // using it
287                 if(previous)
288                 {
289                         int size = link_count(), index;
290                         for (index=0; index < size; ++index)
291                         {
292                                 if (i == index) continue;
293                                 if (get_link(index) == previous)
294                                         break;
295                         }
296                         if (index == size)
297                                 remove_child(previous.get());
298                 }
299                 add_child(x.get());
300
301                 if(!x->is_exported() && get_parent_canvas())
302                 {
303                         x->set_parent_canvas(get_parent_canvas());
304                 }
305                 changed();
306                 return true;
307         }
308         return false;
309 }
310
311 ValueNode::LooseHandle
312 LinkableValueNode::get_link(int i)const
313 {
314         return get_link_vfunc(i);
315 }
316
317 void
318 LinkableValueNode::unlink_all()
319 {
320         for(int i=0;i<link_count();i++)
321         {
322                 ValueNode::LooseHandle value_node(get_link(i));
323                 if(value_node)
324                         value_node->parent_set.erase(this);
325         }
326 }
327
328 ValueNode::~ValueNode()
329 {
330         value_node_count--;
331
332         begin_delete();
333 }
334
335 void
336 ValueNode::on_changed()
337 {
338         etl::loose_handle<Canvas> parent_canvas = get_parent_canvas();
339         if(parent_canvas)
340                 do                                              // signal to all the ancestor canvases
341                         parent_canvas->signal_value_node_changed()(this);
342                 while (parent_canvas = parent_canvas->parent());
343         else if(get_root_canvas())
344                 get_root_canvas()->signal_value_node_changed()(this);
345
346         Node::on_changed();
347 }
348
349 int
350 ValueNode::replace(etl::handle<ValueNode> x)
351 {
352         if(x.get()==this)
353                 return 0;
354
355         while(parent_set.size())
356         {
357                 (*parent_set.begin())->add_child(x.get());
358                 (*parent_set.begin())->remove_child(this);
359                 //x->parent_set.insert(*parent_set.begin());
360                 //parent_set.erase(parent_set.begin());
361         }
362         int r(RHandle(this).replace(x));
363         x->changed();
364         return r;
365 }
366
367 void
368 ValueNode::set_id(const String &x)
369 {
370         if(name!=x)
371         {
372                 name=x;
373                 signal_id_changed_();
374         }
375 }
376
377 String
378 ValueNode::get_description(bool show_exported_name)const
379 {
380         String ret(_("ValueNode"));
381
382         if (dynamic_cast<const LinkableValueNode*>(this))
383                 return (dynamic_cast<const LinkableValueNode*>(this))->get_description(-1, show_exported_name);
384
385         if (show_exported_name && !is_exported())
386                 show_exported_name = false;
387
388         if (show_exported_name)
389                 ret += strprintf(" (%s)", get_id().c_str());
390
391         return ret;
392 }
393
394 ValueNodeList::ValueNodeList():
395         placeholder_count_(0)
396 {
397 }
398
399 bool
400 ValueNodeList::count(const String &id)const
401 {
402         const_iterator iter;
403
404         if(id.empty())
405                 return false;
406
407         for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter)
408                 ;
409
410         if(iter==end())
411                 return false;
412
413         return true;
414 }
415
416 ValueNode::Handle
417 ValueNodeList::find(const String &id)
418 {
419         iterator iter;
420
421         if(id.empty())
422                 throw Exception::IDNotFound("Empty ID");
423
424         for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter)
425                 ;
426
427         if(iter==end())
428                 throw Exception::IDNotFound("ValueNode in ValueNodeList: "+id);
429
430         return *iter;
431 }
432
433 ValueNode::ConstHandle
434 ValueNodeList::find(const String &id)const
435 {
436         const_iterator iter;
437
438         if(id.empty())
439                 throw Exception::IDNotFound("Empty ID");
440
441         for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter)
442                 ;
443
444         if(iter==end())
445                 throw Exception::IDNotFound("ValueNode in ValueNodeList: "+id);
446
447         return *iter;
448 }
449
450 ValueNode::Handle
451 ValueNodeList::surefind(const String &id)
452 {
453         if(id.empty())
454                 throw Exception::IDNotFound("Empty ID");
455
456         ValueNode::Handle value_node;
457
458         try
459         {
460                 value_node=find(id);
461         }
462         catch(Exception::IDNotFound)
463         {
464                 value_node=PlaceholderValueNode::create();
465                 value_node->set_id(id);
466                 push_back(value_node);
467                 placeholder_count_++;
468         }
469
470         return value_node;
471 }
472
473 bool
474 ValueNodeList::erase(ValueNode::Handle value_node)
475 {
476         assert(value_node);
477
478         iterator iter;
479
480         for(iter=begin();iter!=end();++iter)
481                 if(value_node.get()==iter->get())
482                 {
483                         std::list<ValueNode::RHandle>::erase(iter);
484                         if(PlaceholderValueNode::Handle::cast_dynamic(value_node))
485                                 placeholder_count_--;
486                         return true;
487                 }
488         return false;
489 }
490
491 bool
492 ValueNodeList::add(ValueNode::Handle value_node)
493 {
494         if(!value_node)
495                 return false;
496         if(value_node->get_id().empty())
497                 return false;
498
499         try
500         {
501                 ValueNode::RHandle other_value_node=find(value_node->get_id());
502                 if(PlaceholderValueNode::Handle::cast_dynamic(other_value_node))
503                 {
504                         other_value_node->replace(value_node);
505                         placeholder_count_--;
506                         return true;
507                 }
508
509                 return false;
510         }
511         catch(Exception::IDNotFound)
512         {
513                 push_back(value_node);
514                 return true;
515         }
516
517         return false;
518 }
519
520 void
521 ValueNodeList::audit()
522 {
523         iterator iter,next;
524
525         for(next=begin(),iter=next++;iter!=end();iter=next++)
526                 if(iter->count()==1)
527                         std::list<ValueNode::RHandle>::erase(iter);
528 }
529
530
531 String
532 PlaceholderValueNode::get_name()const
533 {
534         return "placeholder";
535 }
536
537 String
538 PlaceholderValueNode::get_local_name()const
539 {
540         return _("Placeholder");
541 }
542
543 ValueNode*
544 PlaceholderValueNode::clone(const GUID& deriv_guid)const
545 {
546         ValueNode* ret(new PlaceholderValueNode());
547         ret->set_guid(get_guid()^deriv_guid);
548         return ret;
549 }
550
551 PlaceholderValueNode::Handle
552 PlaceholderValueNode::create(ValueBase::Type type)
553 {
554         return new PlaceholderValueNode(type);
555 }
556
557 ValueBase
558 PlaceholderValueNode::operator()(Time /*t*/)const
559 {
560         assert(0);
561         return ValueBase();
562 }
563
564 PlaceholderValueNode::PlaceholderValueNode(ValueBase::Type type):
565         ValueNode(type)
566 {
567 }
568
569 ValueNode*
570 LinkableValueNode::clone(const GUID& deriv_guid)const
571 {
572         {
573                 ValueNode* x(find_value_node(get_guid()^deriv_guid).get());
574                 if(x)
575                         return x;
576         }
577
578         int i;
579         LinkableValueNode *ret=create_new();
580         ret->set_guid(get_guid()^deriv_guid);
581
582         for(i=0;i<link_count();i++)
583         {
584                 ValueNode::Handle link=get_link_vfunc(i);
585                 if(!link->is_exported())
586                 {
587                         ValueNode::LooseHandle value_node(find_value_node(link->get_guid()^deriv_guid));
588                         if(!value_node)
589                                 value_node=link->clone(deriv_guid);
590                         ret->set_link(i,value_node);
591                 }
592                 else
593                         ret->set_link(i,link);
594         }
595
596         return ret;
597 }
598
599 String
600 ValueNode::get_relative_id(etl::loose_handle<const Canvas> x)const
601 {
602         assert(is_exported());
603         assert(canvas_);
604
605         if(x.get()==canvas_.get())
606                 return get_id();
607
608         return canvas_->_get_relative_id(x)+':'+get_id();
609 }
610
611 void
612 ValueNode::set_parent_canvas(etl::loose_handle<Canvas> x)
613 {
614         canvas_=x; if(x) root_canvas_=x->get_root();
615 }
616
617 void
618 ValueNode::set_root_canvas(etl::loose_handle<Canvas> x)
619 {
620         root_canvas_=x->get_root();
621 }
622
623 void LinkableValueNode::get_times_vfunc(Node::time_set &set) const
624 {
625         ValueNode::LooseHandle  h;
626
627         int size = link_count();
628
629         //just add it to the set...
630         for(int i=0; i < size; ++i)
631         {
632                 h = get_link(i);
633
634                 if(h)
635                 {
636                         const Node::time_set &tset = h->get_times();
637                         set.insert(tset.begin(),tset.end());
638                 }
639         }
640 }
641
642 String
643 LinkableValueNode::get_description(int index, bool show_exported_name)const
644 {
645         String description;
646
647         if (index == -1)
648         {
649                 if (show_exported_name && is_exported())
650                         description += strprintf(" (%s)", get_id().c_str());
651         }
652         else
653         {
654                 description = String(":") + link_local_name(index);
655
656                 if (show_exported_name)
657                 {
658                         ValueNode::LooseHandle link(get_link(index));
659                         if (link->is_exported())
660                                 description += strprintf(" (%s)", link->get_id().c_str());
661                 }
662         }
663
664         const synfig::Node* node = this;
665         LinkableValueNode::ConstHandle parent_linkable_vn = 0;
666
667         // walk up through the valuenodes trying to find the layer at the top
668         while (!node->parent_set.empty() && !dynamic_cast<const Layer*>(node))
669         {
670                 LinkableValueNode::ConstHandle linkable_value_node(dynamic_cast<const LinkableValueNode*>(node));
671                 if (linkable_value_node)
672                 {
673                         String link;
674                         int cnt = linkable_value_node->link_count();
675                         for (int i = 0; i < cnt; i++)
676                                 if (linkable_value_node->get_link(i) == parent_linkable_vn)
677                                 {
678                                         link = String(":") + linkable_value_node->link_local_name(i);
679                                         break;
680                                 }
681
682                         description = linkable_value_node->get_local_name() + link + (parent_linkable_vn?">":"") + description;
683                 }
684                 node = *node->parent_set.begin();
685                 parent_linkable_vn = linkable_value_node;
686         }
687
688         Layer::ConstHandle parent_layer(dynamic_cast<const Layer*>(node));
689         if(parent_layer)
690         {
691                 String param;
692                 const Layer::DynamicParamList &dynamic_param_list(parent_layer->dynamic_param_list());
693                 // loop to find the parameter in the dynamic parameter list - this gives us its name
694                 for (Layer::DynamicParamList::const_iterator iter = dynamic_param_list.begin(); iter != dynamic_param_list.end(); iter++)
695                         if (iter->second == parent_linkable_vn)
696                                 param = String(":") + parent_layer->get_param_local_name(iter->first);
697                 description = strprintf("(%s)%s>%s",
698                                                                 parent_layer->get_non_empty_description().c_str(),
699                                                                 param.c_str(),
700                                                                 description.c_str());
701         }
702
703         return description;
704 }