Merging graphics branch
Michael Goffioul
michael.goffioul at gmail.com
Mon Jun 16 07:28:58 CDT 2008
On Mon, Jun 16, 2008 at 1:53 PM, Bill Denney <bill at denney.ws> wrote:
> Michael Goffioul wrote:
>>
>> On Mon, Jun 16, 2008 at 1:31 PM, Bill Denney <bill at denney.ws> wrote:
>>
>>>
>>> Do you have linked properties yet? That's one of the big one to me for
>>> making custom graphics objects.
>>>
>>
>> What do you mean by "linked properties"?
>>
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/linkprop.html
This is not present yet, but this could be easily emulated using
property listeners (at least partially): linking a property in 2 objects
is the same as defining in each object a corresponding property
listener that update the property value in the other object.
As an illustration (code not tested, this is just to illustrate my words),
it could be done as follows (only one property name, extension is
trivial):
function linkprop (h, pname)
for hh = h(:)'
addlistener (hh, pname, {@do_update, pname, h});
endfor
function do_update (h, data, pname, hlist)
persistent updating;
if (isempty (updating))
updating = false;
endif
if (! updating)
updating = true;
pvalue = get (h, 'pname');
set (hlist, pname, pvalue);
updating = false;
endif
This might work out-of-the-box, but you get the idea.
I'm not gonna have a closer look at this as it is at a higher level than
my current (low-level) focus. So if anybody wants to implement it,
feel free to do it.
Note that in the other brand, "linkprop" returns an object that
encapsulate the linking info. I guess this can be again emulated
using the new object/class possibilities of octave.
Note also that the code above is not good, because "updating"
would be shared by all linked properties. The scope of
"updating" should be restricted to the current link object.
The use of new OO features would be useful here.
Michael.
More information about the Octave-maintainers
mailing list