From: <ai...@us...> - 2011-06-13 16:17:04
|
Revision: 11767 http://plplot.svn.sourceforge.net/plplot/?rev=11767&view=rev Author: airwin Date: 2011-06-13 16:16:57 +0000 (Mon, 13 Jun 2011) Log Message: ----------- Adjust viewport and windows coordinate limits consistently so that image, gradient, and shades colorbars now all have good positioning and clip results according to the new positioning scheme. ToDo: Make bounding box correspond to extent of text outside the core colorbar and modify colorbar part of example 33 to (a) pack more results per page, and (b) demonstrate the new colorbar functionality that has been recently introduced. Modified Paths: -------------- trunk/examples/c/x16c.c trunk/examples/c/x33c.c trunk/src/pllegend.c Modified: trunk/examples/c/x16c.c =================================================================== --- trunk/examples/c/x16c.c 2011-06-12 23:51:06 UTC (rev 11766) +++ trunk/examples/c/x16c.c 2011-06-13 16:16:57 UTC (rev 11767) @@ -243,8 +243,7 @@ plsmin( 0.0, 0.5 ); plcolorbar( &colorbar_width, &colorbar_height, - PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_BOUNDING_BOX, 0, -// PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 0, + PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, 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/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-06-12 23:51:06 UTC (rev 11766) +++ trunk/examples/c/x33c.c 2011-06-13 16:16:57 UTC (rev 11767) @@ -236,7 +236,7 @@ plvpor( 0.1, 0.9, 0.1, 0.9 ); plwind( 0.0, 1.0, 0.0, 1.0 ); plcolorbar( &colorbar_width, &colorbar_height, - opt | PL_COLORBAR_BOUNDING_BOX, position, + opt, position, x, y, x_length, y_length, 0, 1, 1, low_cap_color, high_cap_color, Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-06-12 23:51:06 UTC (rev 11766) +++ trunk/src/pllegend.c 2011-06-13 16:16:57 UTC (rev 11767) @@ -1148,6 +1148,7 @@ 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 @@ -1296,45 +1297,58 @@ // Specify the proper window ranges depending on orientation. if ( opt & PL_COLORBAR_ORIENT_RIGHT ) { - wx_min = plot_x_subpage; - wx_max = plot_x_subpage + bar_width; - wy_min = plot_y_subpage - bar_height; - wy_max = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + 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 = plot_x_subpage; - wx_max = plot_x_subpage + bar_width; - wy_min = plot_y_subpage - bar_height; - wy_max = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + wx_min = 0.0; + wx_max = 1.0; + wy_min = min_value; + wy_max = max_value; } else if ( opt & PL_COLORBAR_ORIENT_LEFT ) { - wx_max = plot_x_subpage; - wx_min = plot_x_subpage + bar_width; - wy_min = plot_y_subpage - bar_height; - wy_max = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + 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 = plot_x_subpage; - wx_max = plot_x_subpage + bar_width; - wy_max = plot_y_subpage - bar_height; - wy_min = plot_y_subpage; + vx_min = plot_x_subpage; + vx_max = plot_x_subpage + bar_width; + vy_min = plot_y_subpage - bar_height; + vy_max = plot_y_subpage; + wx_min = 0.0; + wx_max = 1.0; + wy_min = max_value; + wy_max = min_value; } else { plabort( "plcolorbar: Invalid PL_COLORBAR_ORIENT_* bits" ); } - // 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. ); + // Viewport and world coordinate ranges for all but cap and + // bounding-box areas. + plvpor( vx_min, vx_max, vy_min, vy_max ); + plwind( wx_min, wx_max, wy_min, wy_max ); - // 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 ) { @@ -1605,6 +1619,10 @@ // Draw end-caps + // Viewport and world coordinate ranges for cap and bounding-box areas. + plvpor( 0., 1., 0., 1. ); + plwind( 0., 1., 0., 1. ); + if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) cap_extent = cap_ratio * bar_height / aspspp; else @@ -1682,41 +1700,9 @@ // internals of plbox to support custom tick and label positions // along an axis. - 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" ); - } - + // Viewport and world coordinate ranges for all but cap and + // bounding-box areas. + plvpor( vx_min, vx_max, vy_min, vy_max ); plwind( wx_min, wx_max, wy_min, wy_max ); if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) @@ -1825,12 +1811,8 @@ plmtex( opt_string, label_offset, 0.5, 0.5, label ); } - // Internal viewport corresponds to sub-page so that all parts of the - // colorbar will be clipped at sub-page boundaries. + // Viewport and world coordinate ranges for cap and bounding-box areas. 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_BACKGROUND ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |