Re: Gnome2::Canvas --> do I really need to worry about pixels_per_unit?



zentara wrote:
On Sun, 22 Jun 2008 20:20:33 -0700
walt<w41ter gmail com>  wrote:

...
The problem is that the vertical scroll region will just ignore
any height value below some arbitrary limit.
...

Could you post a small example where the data point can't
be scrolled to, and the "arbitrary limit" is hit?

It sounds to me like you have a predefined size set somewhere,
like a set_default_size in your mainwindow, or something.

I just posted a similar question recently, where my coordinates
seemed way off, and I couldn't explain it..... I figured it out as follows

################################
Doh!!!  Sorry I see the mistake. If the scrollregion is smaller than the default
canvas size, weird coordinate transforms occur. Maybe a bug?

$scroller->add( $canvas );
$window->add( $scroller );
$window->set_default_size( 500, 500 );

#if scrollregion is smaller than default size, odd
# coordinate problems occur
#$canvas->set_scroll_region( 0, 0, 400, 400 ); #bad

$canvas->set_scroll_region( 0, 0, 700, 700 );   #good and works fine

It would be a good "trick" question to throw at someone. :-)
########################################


See if that is it, otherwise post a minimal example.

My example is very similar to yours, but the numbers are smaller to show
the problem in an exaggerated way:

my $line = Gnome2::Canvas::Item->new
                            (
                            $root,
                             'Gnome2::Canvas::Line',
                             points=> [0,0,50,50],
                             width_pixels=> 1,
                             fill_color => 'black',
                             line_style => 'solid'
                            );

$window->set_default_size (500, 500);
$canvas->set_scroll_region(0,0,50,50);

my @region = $canvas->get_scroll_region;
print "@region\n";

This draws a diagonal line across the screen, of course.  My question
is how much of the 500x500 window should be filled with the line?

My answer is that the line should be visible across the entire window
because the scrolling region is set to the same size as the line
(0,0,50,50).  The absolute number of pixels in the window should have
nothing to do with how the line appears on the screen as long as the
scaling is correctly done, right?  At least that's how it worked in
Visual Basic, which is the only other way I've done this stuff.

To make it work according to my model, I would need to change both the
pixels_per_unit and the scrolling region every time I scroll to a new
part of the graph.  And that would also change the horizontal spacing
between data points, which I definitely don't want.

Maybe setting the scroll region isn't really the right way to do my
scaling?




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