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