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