From: <ai...@us...> - 2011-06-12 23:51:13
|
Revision: 11766 http://plplot.svn.sourceforge.net/plplot/?rev=11766&view=rev Author: airwin Date: 2011-06-12 23:51:06 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Update colorbar, tickmarks and numerical labels, and text to use the new positioning scheme for plcolorbar. ToDo: there is still work required to understand and fix the positioning of the shades case of colorbar and to expand the bounding box to account for more than just the core colorbar. However, if you ignore the shades case (i.e., focus on just the image and gradient cases) for example 33, the results look reasonable again so I am getting there. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-06-12 18:25:19 UTC (rev 11765) +++ trunk/examples/c/x16c.c 2011-06-12 23:51:06 UTC (rev 11766) @@ -292,7 +292,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -339,7 +339,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); @@ -385,7 +385,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.05, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, 2, 3, 0.0, 0, "bcvxm", "", ns + 1, shedge ); @@ -482,7 +482,7 @@ plcolorbar( &colorbar_width, &colorbar_height, PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, - 0.06, 0.15, 0.03, 0.7, 0, 1, 1, 0.0, 0.0, + 0.026, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0, cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-12 18:25:19 UTC (rev 11765) +++ trunk/src/pllegend.c 2011-06-12 23:51:06 UTC (rev 11766) @@ -1148,7 +1148,6 @@ line_style_save = plsc->line_style; // Position of the color bar in adopted coordinates. - PLFLT vx_min, vx_max, vy_min, vy_max; PLFLT wx_min, wx_max, wy_min, wy_max; // The data to plot @@ -1294,72 +1293,48 @@ plot_x_subpage = adopted_to_subpage_x( plot_x ); plot_y_subpage = adopted_to_subpage_y( plot_y ); - // Specify the proper viewport ranges along the requested side - // of the subpage - if ( position & PL_POSITION_LEFT ) - { - vx_min = x; - vy_min = y; - } - else if ( position & PL_POSITION_RIGHT ) - { - vx_min = 1.0 - x - x_length; - vy_min = y; - } - else if ( position & PL_POSITION_TOP ) - { - vx_min = x; - vy_min = 1.0 - y - y_length; - } - else if ( position & PL_POSITION_BOTTOM ) - { - vx_min = x; - vy_min = y; - } - else - { - plabort( "plcolorbar: Invalid PL_POSITION_* bits" ); - } - vx_max = vx_min + x_length; - vy_max = vy_min + y_length; - // Specify the proper window ranges depending on orientation. if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - wx_min = min_value; - wx_max = max_value; - wy_min = 0.0; - wy_max = 1.0; + wx_min = plot_x_subpage; + wx_max = plot_x_subpage + bar_width; + wy_min = plot_y_subpage - bar_height; + wy_max = plot_y_subpage; } else if ( opt & PL_COLORBAR_ORIENT_TOP ) { - wx_min = 0.0; - wx_max = 1.0; - wy_min = min_value; - wy_max = max_value; + wx_min = plot_x_subpage; + wx_max = plot_x_subpage + bar_width; + wy_min = plot_y_subpage - bar_height; + wy_max = plot_y_subpage; } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - wx_min = max_value; - wx_max = min_value; - wy_min = 0.0; - wy_max = 1.0; + wx_max = plot_x_subpage; + wx_min = plot_x_subpage + bar_width; + wy_min = plot_y_subpage - bar_height; + wy_max = plot_y_subpage; } else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) { - wx_min = 0.0; - wx_max = 1.0; - wy_min = max_value; - wy_max = min_value; + wx_min = plot_x_subpage; + wx_max = plot_x_subpage + bar_width; + wy_max = plot_y_subpage - bar_height; + wy_min = plot_y_subpage; } else { plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); } - plvpor( vx_min, vx_max, vy_min, vy_max ); - plwind( wx_min, wx_max, wy_min, wy_max ); + // Internal viewport corresponds to sub-page so that all parts of the + // colorbar will be clipped at sub-page boundaries. + plvpor( 0., 1., 0., 1. ); + // Internal world coordinates are the same as normalized internal + // viewport coordinates which are the same as normalized subpage coordinates. + plwind( 0., 1., 0., 1. ); + // What kind of color bar are we making? if ( opt & PL_COLORBAR_IMAGE ) { @@ -1630,14 +1605,6 @@ // Draw end-caps - // Internal viewport corresponds to sub-page so that all parts of the - // colorbar will be clipped at sub-page boundaries. - plvpor( 0., 1., 0., 1. ); - - // Internal world coordinates are the same as normalized internal - // viewport coordinates which are the same as normalized subpage coordinates. - plwind( 0., 1., 0., 1. ); - if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) cap_extent = cap_ratio * bar_height / aspspp; else @@ -1715,7 +1682,41 @@ // internals of plbox to support custom tick and label positions // along an axis. - plvpor( vx_min, vx_max, vy_min, vy_max ); + plvpor( wx_min, wx_max, wy_min, wy_max ); + // Specify the proper window ranges depending on orientation. + if ( opt & PL_COLORBAR_ORIENT_RIGHT ) + { + wx_min = min_value; + wx_max = max_value; + wy_min = 0.0; + wy_max = 1.0; + } + else if ( opt & PL_COLORBAR_ORIENT_TOP ) + { + wx_min = 0.0; + wx_max = 1.0; + wy_min = min_value; + wy_max = max_value; + } + else if ( opt & PL_COLORBAR_ORIENT_LEFT ) + { + wx_min = max_value; + wx_max = min_value; + wy_min = 0.0; + wy_max = 1.0; + } + else if ( opt & PL_COLORBAR_ORIENT_BOTTOM ) + { + wx_min = 0.0; + wx_max = 1.0; + wy_min = max_value; + wy_max = min_value; + } + else + { + plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); + } + plwind( wx_min, wx_max, wy_min, wy_max ); if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |