From: <ai...@us...> - 2011-07-13 22:03:03
|
Revision: 11813 http://plplot.svn.sourceforge.net/plplot/?rev=11813&view=rev Author: airwin Date: 2011-07-13 22:02:56 +0000 (Wed, 13 Jul 2011) Log Message: ----------- Fix accident waiting to happen for get_subpage_per_mm (a static function which is called directly or indirectly by pllegend and plcolorbar). The only reason this function worked correctly before was it was always called after plvpor( 0., 1., 0., 1. ); plwind( 0., 1., 0., 1. ); But the point is the get_subpage_per_mm doesn't need to know anything about the viewport, and a call to plgspa returns all data required to calculate the x and y ratios of normalized subpage coordinates to mm. So get_subpage_per_mm can be substantially simplified, and that simplification insures that routine will give correct results when plvpor and plwind have been called with other than the above values. Modified Paths: -------------- trunk/src/pllegend.c Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-07-12 21:52:45 UTC (rev 11812) +++ trunk/src/pllegend.c 2011-07-13 22:02:56 UTC (rev 11813) @@ -295,17 +295,11 @@ static void get_subpage_per_mm( PLFLT *x_subpage_per_mm, PLFLT *y_subpage_per_mm ) { - // Normalized viewport limits - PLFLT vxmin, vxmax, vymin, vymax; // Size of subpage in mm PLFLT mxmin, mxmax, mymin, mymax; - // Viewport limits in world coordinates - PLFLT wxmin, wxmax, wymin, wymax; - plgvpsp( &vxmin, &vxmax, &vymin, &vymax ); plgspa( &mxmin, &mxmax, &mymin, &mymax ); - plgvpw( &wxmin, &wxmax, &wymin, &wymax ); - *x_subpage_per_mm = ( wxmax - wxmin ) / ( ( vxmax - vxmin ) * ( mxmax - mxmin ) ); - *y_subpage_per_mm = ( wymax - wymin ) / ( ( vymax - vymin ) * ( mymax - mymin ) ); + *x_subpage_per_mm = 1. / ( mxmax - mxmin ); + *y_subpage_per_mm = 1. / ( mymax - mymin ); } //-------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |