dk / Prima

prima.eu.org
Other
108 stars 27 forks source link

Prima::PS::Drawable::get_text_box #16

Closed run4flat closed 10 years ago

run4flat commented 10 years ago

Axis rendering in PDL::Graphics::Prima uses the get_text_box method to center the axis labels. This appears to have broken. Given the number of times I've had to re-install Prima throughout the different versions, this might only be an issue on my setup.

To reproduce the problem (or prove that it's a setup thing), install PDL::Graphics::Prima and run any example script. Save the figure to a file by right-clicking on the figure and selecting "Save to postscript" You should see the following output while the postscript figure is being produced:

Twiddling plot; close window or press q or Q to resume
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.

Also, the top and bottom axes will be missing.

dk commented 10 years ago

David, I've just tried that on win32 and ubuntu, seems totally fine, no problems at all .. I can't even see where in PS::Drawable::get_text_box the code can return undefs ... could you possibly try to debug that?

run4flat commented 10 years ago

Further investigations indicate that this is only a problem when working with postscript and Subcanvas. It might be a problem on my end, not properly establishing the paint state before invoking paint_with_widgets. I will investigate more and let you know what I find.

run4flat commented 10 years ago

I was wrong, it does not depend upon postscript. To see this, you can run grip.pl in the Prima examples, and use it to grip the contents of PDL::Graphics::Prima's examples/subfigure.pl. This, too, gives trouble. I have been experimenting with lots of variations on how to set up the canvas. I get this odd behavior even when the canvas is paint-enabled just before the call which returns undef (as confirmed with changes to the plotting libraries on_paint, as well as print statements in Axis.pm).

The problem, almost certainly, is that PDL::Graphics::Prima goes to great lengths to Do What You Mean when it comes to drawing on whatever canvas it may be given. It automatically turns on the paint state if the paint state was not enabled, for example. I suspect that this logic may be incorrect, and causing trouble. See https://github.com/run4flat/PDL-Graphics-Prima/blob/master/lib/PDL/Graphics/Prima.pm#L747

I need to take a break for now, but I think that PDL::Graphics::Prima's paint behavior may be at fault here, not Prima's paint_with_widgets.