From: <ai...@us...> - 2011-06-15 17:06:33
|
Revision: 11771 http://plplot.svn.sourceforge.net/plplot/?rev=11771&view=rev Author: airwin Date: 2011-06-15 17:06:26 +0000 (Wed, 15 Jun 2011) Log Message: ----------- Smaller cap angles imply large caps which are great for debugging cap position problems, but as far as I know those are all debugged now so return cap_angle to a larger cap_angle. I have currently chosen that to be 90 deg, but we may want to make the cap angle a bit smaller than that if people prefer a slightly larger cap style. Or we may want to make this style parameter something that the user can set. Adjust label_offset inside plcolorbar to account for exact cap extent. (This was debugged with a small cap angle ==> large cap.) Modified Paths: -------------- trunk/src/pllegend.c Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-15 16:55:17 UTC (rev 11770) +++ trunk/src/pllegend.c 2011-06-15 17:06:26 UTC (rev 11771) @@ -309,7 +309,7 @@ } //-------------------------------------------------------------------------- -//! Obtain character or symbol height in (y) subpage coordinates. +//! Obtain character or symbol height in (y) in normalized subpage coordinates. //! //! @param ifcharacter TRUE obtain character height, FALSE obtain symbol //! height. @@ -1119,7 +1119,7 @@ // direction of the orientation of the cap. In other words, // cap_angle completely controls the shape of the triangle, but // not its scale. - PLFLT cap_angle = 15.; + PLFLT cap_angle = 90.; // Ratio of length of cap in orientation direction // to the width of the bar (and cap) in the direction // perpendicular to the orientation in physical coordinates @@ -1178,8 +1178,9 @@ PLINT i, j, ni, nj, n_steps; PLFLT step_size; - // How far away from the axis should the label be drawn? - PLFLT label_offset; + // How far away from the axis should the label be drawn in units of + // the character height? + PLFLT label_offset = 0.; // For building plmtex option string. PLINT max_opts = 25; @@ -1192,6 +1193,9 @@ char *local_axis_opts; PLBOOL if_edge; + // Character height in x and y normalized subpage coordinates. + PLFLT character_height_x, character_height_y; + // Default position flags and sanity checks for position flags. if ( !( position & PL_POSITION_RIGHT ) && !( position & PL_POSITION_LEFT ) && !( position & PL_POSITION_TOP ) && !( position & PL_POSITION_BOTTOM ) ) { @@ -1709,24 +1713,29 @@ // Restore the previous drawing color to use for outlines and text plcol0( col0_save ); - label_offset = 0.0; - // Draw end-caps // Viewport and world coordinate ranges for cap and bounding-box areas. plvpor( 0., 1., 0., 1. ); plwind( 0., 1., 0., 1. ); + character_height_y = get_character_or_symbol_height( TRUE ); + // character height _in normalized subpage coordinates_ is smaller + // in the x direction if the subpage aspect ratio is larger than one. + character_height_x = character_height_y / aspspp; if ( opt & PL_COLORBAR_CAP_LOW ) { // Add an extra offset for the label so it does not bump in to the // cap if the label is placed on the same side as the cap. if ( ( opt & PL_COLORBAR_ORIENT_RIGHT && opt & PL_COLORBAR_LABEL_LEFT ) || - ( opt & PL_COLORBAR_ORIENT_TOP && opt & PL_COLORBAR_LABEL_BOTTOM ) || - ( opt & PL_COLORBAR_ORIENT_LEFT && opt & PL_COLORBAR_LABEL_RIGHT ) || + ( opt & PL_COLORBAR_ORIENT_LEFT && opt & PL_COLORBAR_LABEL_RIGHT ) ) + { + label_offset += cap_extent/character_height_x; + } + if ( ( opt & PL_COLORBAR_ORIENT_TOP && opt & PL_COLORBAR_LABEL_BOTTOM ) || ( opt & PL_COLORBAR_ORIENT_BOTTOM && opt & PL_COLORBAR_LABEL_TOP ) ) { - label_offset += 2.5; + label_offset += cap_extent/character_height_y; } // Draw a filled triangle (cap/arrow) at the low end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) @@ -1755,11 +1764,14 @@ // Add an extra offset for the label so it does not bump in to the // cap if the label is placed on the same side as the cap. if ( ( opt & PL_COLORBAR_ORIENT_RIGHT && opt & PL_COLORBAR_LABEL_RIGHT ) || - ( opt & PL_COLORBAR_ORIENT_TOP && opt & PL_COLORBAR_LABEL_TOP ) || - ( opt & PL_COLORBAR_ORIENT_LEFT && opt & PL_COLORBAR_LABEL_LEFT ) || + ( opt & PL_COLORBAR_ORIENT_LEFT && opt & PL_COLORBAR_LABEL_LEFT ) ) + { + label_offset += cap_extent/character_height_x; + } + if ( ( opt & PL_COLORBAR_ORIENT_TOP && opt & PL_COLORBAR_LABEL_TOP ) || ( opt & PL_COLORBAR_ORIENT_BOTTOM && opt & PL_COLORBAR_LABEL_BOTTOM ) ) { - label_offset += 2.5; + label_offset += cap_extent/character_height_y; } // Draw a filled triangle (cap/arrow) at the high end of the scale if ( opt & PL_COLORBAR_ORIENT_RIGHT ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |