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