help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: units updater for figures is broken when using fltk


From: Ben Abbott
Subject: Re: units updater for figures is broken when using fltk
Date: Fri, 10 Feb 2012 20:04:02 -0500

On Feb 7, 2012, at 9:18 PM, Ben Abbott wrote:

> On Feb 7, 2012, at 11:41 AM, Ben Abbott wrote:
> 
>> On Feb 7, 2012, at 10:40 AM, Michael Goffioul wrote:
>> 
>>> On Sun, Feb 5, 2012 at 5:00 PM, Ben Abbott <address@hidden> wrote:
>>>>> I think the problem is not in get_boundingbox, but in the incorrect
>>>>> interpretation of the position property in the FLTK code. Moreover,
>>>>> the code is probably not robust against feedback loops when changing
>>>>> properties, like:
>>>>> 1) the user change figure position
>>>>> 2) the backend is notified and move/resize the figure window
>>>>> 3) as in any toolkit, moving/resizing the window triggers corresponding 
>>>>> events
>>>>> 4) the backend receives events and propagates the changes back to the
>>>>> figure position (this is needed as the move/resize could be the result
>>>>> of a user action with the mouse)
>>>>> 5) if the newly computed position does not match the previous one, goto 1)
>>>>> 
>>>>> Step 4) above should not happen when the position change is coming
>>>>> from octave, but I suspect it does, which can explain the infinite
>>>>> loop you're seeing.
>>>>> 
>>>>> Michael.
>>>> 
>>>> The loop may have been due to my not understanding what I was doing. I 
>>>> used ...
>>>> 
>>>>      Matrix pos = fp.get_boundingbox (true);
>>>> 
>>>> But I don't understand what the boolean arg is intended for. In 
>>>> graphics.cc (figure::properties::get_boundingbox) the boolean is named 
>>>> "internal" and is references in the snippet below.
>>>> 
>>>>      Matrix pos = (internal ?
>>>>                    get_position ().matrix_value () :
>>>>                    get_outerposition ().matrix_value ());
>>>> 
>>>> I choose get_boundingbox (true) because I don't know the purpose of the 
>>>> outerposition property for figures (there's none in Matlab). I notice you 
>>>> added it  below.
>>>> 
>>>>      
>>>> http://hg.savannah.gnu.org/hgweb/octave/annotate/d99aa455296e/src/graphics.cc
>>>> 
>>>> What is the figure's outerposition property for ?
>>> 
>>> http://www.mathworks.co.uk/help/techdoc/ref/figure_props.html#OuterPosition
>>> 
>>>> Back to the need to obtain the figure position property in pixels, I 
>>>> attempted the change below, but ran into scoping problems.
>>>> 
>>>> void draw (void)
>>>> {
>>>>  Matrix screen_size = screen_size_pixels ();
>>>>  Matrix pos = fp.get_position ().matrix_value ();
>>>>  pos = convert_position (pos, get_units (), "pixels", screen_size);
>>>>  Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h);
>>>> 
>>>>  return Fl_Window::draw ();
>>>> }
>>> 
>>> The code above does not flip the Y axis. If you also flip the Y-axis,
>>> it will be equivalent to get_boundingbox(true) and you'll probably run
>>> into the same endless loop.
>> 
>> I've been experimented with a few approaches, but always encounter the loop 
>> problem. 
>> 
>> Even the example below starts looping if the windows is moved with the mouse.
>> 
>> diff --git a/src/DLD-FUNCTIONS/__init_fltk__.cc 
>> b/src/DLD-FUNCTIONS/__init_fltk__.cc
>> --- a/src/DLD-FUNCTIONS/__init_fltk__.cc
>> +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc
>> @@ -1173,9 +1173,14 @@
>> 
>>  void draw (void)
>>  {
>> +    // Get the figure position in pixels
>> +    octave_value funits = fp.get_units ();
>> +    fp.set_units (octave_value ("pixels"));
>>    Matrix pos = fp.get_position ().matrix_value ();
>> +    fp.set_units (funits);
>> +    // Adjust for the menu and status bars
>>    Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h);
>> -
>> +    // Draw the figure
>>    return Fl_Window::draw ();
>>  }
>> 
>> My impression is another place where a similar change is needed ... either 
>> that or I'm just missing something ? 
>> 
>> Ben
> 
> There are two locations in __init_fltk__.cc that fp.get_postion() and one 
> that fp.set_postion(). 
> 
> I've managed a working changeset that relies upon switching the figure units 
> to and from pixels in each instance.
> 
> I'll attempt a solution that does have the liability of having listeners 
> trigger when the figure's units property is changed.
> 
> Ben

I've attached a changeset that works for me on the defualt branch with tip 
below. I've avoided triggering listeners. However, I'm very inexperienced in 
c++ ... so a quick look over would be appreciated.

$ hg tip
changeset:   14357:c097c22e9294
tag:         tip
user:        Ben Abbott  <address@hidden>
date:        Fri Feb 10 18:57:55 2012 -0500
summary:     print.m: Restore figure properties in reverse of the order of 
modification.

Ben

Attachment: changeset-7.patch
Description: Binary data






reply via email to

[Prev in Thread] Current Thread [Next in Thread]