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