[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: |
Tue, 07 Feb 2012 11:41:25 -0500 |
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
- Re: sombrero doesn't show (fltk), (continued)
- Re: sombrero doesn't show (fltk), Ben Abbott, 2012/02/01
- units updater for figures is broken when using fltk, Ben Abbott, 2012/02/04
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/04
- Re: units updater for figures is broken when using fltk, Michael Goffioul, 2012/02/04
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/04
- Re: units updater for figures is broken when using fltk, Michael Goffioul, 2012/02/04
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/04
- Re: units updater for figures is broken when using fltk, Michael Goffioul, 2012/02/05
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/05
- Re: units updater for figures is broken when using fltk, Michael Goffioul, 2012/02/07
- Re: units updater for figures is broken when using fltk,
Ben Abbott <=
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/07
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/10
- Re: units updater for figures is broken when using fltk, Michael Goffioul, 2012/02/11
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/11
- Re: units updater for figures is broken when using fltk, Michael Goffioul, 2012/02/11
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/11
- Re: units updater for figures is broken when using fltk, Ben Abbott, 2012/02/12