From: <ai...@us...> - 2011-06-21 18:08:15
|
Revision: 11776 http://plplot.svn.sourceforge.net/plplot/?rev=11776&view=rev Author: airwin Date: 2011-06-21 18:08:09 +0000 (Tue, 21 Jun 2011) Log Message: ----------- Update bounding box to include both vertical and horizontal components of numerical labelling exponents for horizontal axes. Example 33 confirms this improvement is working properly. This completes the bounding box calculation for horizontal axes of plbox. ToDo: Need to implement similar functionality for vertical axes of plbox, horizontal and vertical axes of custom labels, and overall colorbar label. Modified Paths: -------------- trunk/examples/c/x33c.c trunk/src/plbox.c Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-21 16:43:35 UTC (rev 11775) +++ trunk/examples/c/x33c.c 2011-06-21 18:08:09 UTC (rev 11776) @@ -844,9 +844,9 @@ // Use unsaturated green background colour to contrast with black caps. plscolbg( 70, 185, 70 ); // Color bar examples - PLFLT values_small[2] = { 0.0, 1.0 }; - PLFLT values_uneven[9] = { 0.0, 2.0, 2.6, 3.4, 6.0, 7.0, 8.0, 9.0, 10.0 }; - PLFLT values_even[9] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + PLFLT values_small[2] = { 0.0e-200, 1.0e-200 }; + PLFLT values_uneven[9] = { 0.0e-200, 2.0e-200, 2.6e-200, 3.4e-200, 6.0e-200, 7.0e-200, 8.0e-200, 9.0e-200, 10.0e-200 }; + PLFLT values_even[9] = { 0.0e-200, 1.0e-200, 2.0e-200, 3.0e-200, 4.0e-200, 5.0e-200, 6.0e-200, 7.0e-200, 8.0e-200 }; // Cut out the greatest and smallest bits of the color spectrum to // leave colors for the end caps. Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2011-06-21 16:43:35 UTC (rev 11775) +++ trunk/src/plbox.c 2011-06-21 18:08:09 UTC (rev 11776) @@ -1455,7 +1455,8 @@ if ( plsc->if_boxbb ) { string_length_mm = plstrl( string ); - pos_mm = ( plsc->vppxmi + pos * ( plsc->vppxma - plsc->vppxmi ) ) / + pos_mm = ( plsc->vppxmi + pos * + ( plsc->vppxma - plsc->vppxmi ) ) / plsc->xpmm; } if ( lnx ) @@ -1516,10 +1517,21 @@ // Bottom axis exponent. if ( plsc->if_boxbb ) { - // FIXME: Add Y bounding box calculations for - // exponent. - // FIXME: Add X bounding box calculations for - // exponent that slops over the end of the axis. + // Height of zero corresponds to character centred on edge + // so should add 0.5 to height to obtain bounding box edge + // in direction away from edge if no exponent. + // Add an additional offset to make exponent fit. + height_mm = ( height + 0.9 ) * char_height_mm; + plsc->boxbb_ymin = MIN( plsc->boxbb_ymin, plsc->vppymi / + plsc->ypmm - height_mm ); + string_length_mm = plstrl( string ); + pos_mm = ( plsc->vppxmi + pos * + ( plsc->vppxma - plsc->vppxmi ) ) / + plsc->xpmm; + plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, + pos_mm - 0.5 * string_length_mm ); + plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, + pos_mm + 0.5 * string_length_mm ); } else { @@ -1531,10 +1543,21 @@ // Top axis exponent. if ( plsc->if_boxbb ) { - // FIXME: Add Y bounding box calculations for - // exponent. - // FIXME: Add X bounding box calculations for - // exponent that slops over the end of the axis. + // Height of zero corresponds to character centred on edge + // so should add 0.5 to height to obtain bounding box edge + // in direction away from edge if no exponent. + // Add an additional offset to make exponent fit. + height_mm = ( height + 1.4 ) * char_height_mm; + plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma / + plsc->ypmm + height_mm ); + string_length_mm = plstrl( string ); + pos_mm = ( plsc->vppxmi + pos * + ( plsc->vppxma - plsc->vppxmi ) ) / + plsc->xpmm; + plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, + pos_mm - 0.5 * string_length_mm ); + plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, + pos_mm + 0.5 * string_length_mm ); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |