[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: addlistener() question
From: |
Shai Ayal |
Subject: |
Re: addlistener() question |
Date: |
Thu, 1 Jan 2009 06:52:08 +0200 |
On Thu, Jan 1, 2009 at 1:45 AM, Ben Abbott <address@hidden> wrote:
> I've been experimenting with addlistener() with the intent of adding
> listeners for particular aspects of the graphics backend(s).
>
>> addlistener (H, PROP, FCN)
>> PROP must be a string naming a valid property of the graphics object
>> handle, H.
>> FCN can be a function handle, a string or a cell array whose first element
>> is a function handle.
>
> So my question is; Does anyone have a thought of how to listen for a change
> to "units" and have the call back function modify the value(s) associated
> with the units? For example, consider the Matlab commands below
>
>>> figure(1)
>>> get (gcf, 'position')
>
> ans = 440 314 560 420
>
>>> set (gcf, 'units', 'inches')
>>> get (gcf, 'position')
>
> ans = 5.8572 4.1761 7.4716 5.6037
>
> To implement this action in Octave, both the "units" setting prior to and
> after the "set" command must be known. Might there be a creative way to pass
> the units setting prior to the "set" command to the callback?
I'm not sure this is the best way. The way it is currently implemented
is the graphics system always storing the values in a fixed set of
units and doing the translation "on-the-fly" when you set/get the
values (e.g. for the position property, always keep the value in
pixels, and if the units are not pixels, set/get will translate the
values into the appropriate units): I think the mechanism is already
in place:
http://hg.savannah.gnu.org/hgweb/octave/file/cc3ac5eb6be3/src/graphics.cc#l177
but maybe Michael has a better grasp of this portion of the code...
Shai