From: <ai...@us...> - 2010-11-10 20:07:19
|
Revision: 11318 http://plplot.svn.sourceforge.net/plplot/?rev=11318&view=rev Author: airwin Date: 2010-11-10 20:07:12 +0000 (Wed, 10 Nov 2010) Log Message: ----------- Change pllegend API (for our core library and also for the python bindings) to make the internally calculated legend_width and legend_height accessible to the calling routine. Modified Paths: -------------- trunk/bindings/swig-support/plplotcapi.i trunk/examples/c/x04c.c trunk/examples/c/x26c.c trunk/examples/python/xw04.py trunk/examples/python/xw26.py trunk/examples/python/xw33.py trunk/include/plplot.h trunk/src/pllegend.c Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/bindings/swig-support/plplotcapi.i 2010-11-10 20:07:12 UTC (rev 11318) @@ -529,7 +529,8 @@ #ifdef SWIG_PYTHON %feature( "autodoc", "Create a discrete annotated legend using boxes, lines, and/or lines of symbols." ) pllegend; void -pllegend( PLINT opt, PLFLT x, PLFLT y, PLFLT plot_width, +pllegend( PLFLT *OUTPUT, PLFLT *OUTPUT, + PLINT opt, PLFLT x, PLFLT y, PLFLT plot_width, PLINT bg_color, PLINT bb_color, PLINT bb_style, PLINT nrow, PLINT ncolumn, PLINT n, const PLINT *Array, Modified: trunk/examples/c/x04c.c =================================================================== --- trunk/examples/c/x04c.c 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/examples/c/x04c.c 2010-11-10 20:07:12 UTC (rev 11318) @@ -55,6 +55,7 @@ PLINT line_widths[2]; PLINT symbol_numbers[2], symbol_colors[2]; PLFLT symbol_scales[2]; + PLFLT legend_width, legend_height; pladv( 0 ); @@ -141,7 +142,8 @@ // to do with boxes. plscol0a( 15, 32, 32, 32, 0.70 ); - pllegend( PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, + pllegend( &legend_width, &legend_height, + PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, 0.0, 0.0, 0.1, 15, 1, 1, 0, 0, nlegend, opt_array, Modified: trunk/examples/c/x26c.c =================================================================== --- trunk/examples/c/x26c.c 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/examples/c/x26c.c 2010-11-10 20:07:12 UTC (rev 11318) @@ -158,6 +158,7 @@ PLINT symbol_numbers[2], symbol_colors[2]; PLFLT symbol_scales[2]; char *symbols[2]; + PLFLT legend_width, legend_height; pladv( 0 ); @@ -241,7 +242,8 @@ // to do with boxes. plscol0a( 15, 32, 32, 32, 0.70 ); - pllegend( PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, + pllegend( &legend_width, &legend_height, + PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, 0.0, 0.0, 0.10, 15, 1, 1, 0, 0, nlegend, opt_array, Modified: trunk/examples/python/xw04.py =================================================================== --- trunk/examples/python/xw04.py 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/examples/python/xw04.py 2010-11-10 20:07:12 UTC (rev 11318) @@ -122,6 +122,7 @@ plscol0a( 15, 32, 32, 32, 0.70 ) + (legend_width, legend_height) = pllegend( PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, 0.0, 0.0, 0.1, 15, 1, 1, 0, 0, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, Modified: trunk/examples/python/xw26.py =================================================================== --- trunk/examples/python/xw26.py 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/examples/python/xw26.py 2010-11-10 20:07:12 UTC (rev 11318) @@ -192,11 +192,11 @@ plscol0a( 15, 32, 32, 32, 0.70 ) + (legend_width, legend_height) = pllegend( PL_LEGEND_BACKGROUND | PL_LEGEND_BOUNDING_BOX, 0.0, 0.0, 0.1, 15, 1, 1, 0, 0, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, symbol_colors, symbol_scales, symbol_numbers, symbols ) - main() Modified: trunk/examples/python/xw33.py =================================================================== --- trunk/examples/python/xw33.py 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/examples/python/xw33.py 2010-11-10 20:07:12 UTC (rev 11318) @@ -1,6 +1,6 @@ # -*- coding: utf-8; -*- # $Id$ -# Copyright (C) 2006-2010 Alan W. Irwin +# Copyright (C) 2010 Alan W. Irwin # Demonstrate most pllegend capability including unicode symbols. @@ -54,8 +54,8 @@ plvpor(0.25, 0.75, 0.25, 0.75) plwind(0.0, 1.0, 0.0, 1.0) plbox("bc", 0.0, 0, "bc", 0.0, 0) - plmtex("t", 7.5, 0.5, 0.5, "The 16 standard legend positions with") - plmtex("t", 6., 0.5, 0.5, "the same (0.05) offset in x and y") + plmtex("t", 8.0, 0.5, 0.5, "The 16 standard legend positions with") + plmtex("t", 6.0, 0.5, 0.5, "the same (0.05) offset in x and y") # Set up legend arrays with the correct size, type. nlegend = 1 @@ -94,7 +94,7 @@ line_colors[0] = 1 + (k % 8) symbol_colors[0] = 1 + (k % 8) - pllegend( opt, 0.05, 0.05, + (legend_width, legend_height) = pllegend( opt, 0.05, 0.05, 0.1, 15, 1, 1, 0, 0, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -106,7 +106,7 @@ plvpor(0.25, 0.75, 0.25, 0.75) plwind(0.0, 1.0, 0.0, 1.0) plbox("bc", 0.0, 0, "bc", 0.0, 0) - plmtex("t", 7.5, 0.5, 0.5, "The effect of nrow, ncolumn, PL_LEGEND_ROW_MAJOR,") + plmtex("t", 8.0, 0.5, 0.5, "The effect of nrow, ncolumn, PL_LEGEND_ROW_MAJOR,") plmtex("t", 6.0, 0.5, 0.5, "and position for the same legend data") # Set up legend arrays with the correct size, type. @@ -149,7 +149,7 @@ y = 0.1 nrow = 1 ncolumn = nlegend - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -160,7 +160,7 @@ y = 0.1 nrow = 1 ncolumn = nlegend - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -171,7 +171,7 @@ y = 0. nrow = nlegend ncolumn = 1 - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -182,7 +182,7 @@ y = 0. nrow = nlegend ncolumn = 1 - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -193,7 +193,7 @@ y = 0. nrow = 6 ncolumn = 2 - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -204,7 +204,7 @@ y = 0. nrow = 6 ncolumn = 2 - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, @@ -215,7 +215,7 @@ y = 0. nrow = 3 ncolumn = 3 - pllegend( opt, x, y, + (legend_width, legend_height) = pllegend( opt, x, y, 0.05, 15, 1, 1, nrow, ncolumn, opt_array, 1.0, 1.0, 2.0, 1., text_colors, text, box_colors, box_patterns, box_scales, line_colors, line_styles, line_widths, Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/include/plplot.h 2010-11-10 20:07:12 UTC (rev 11318) @@ -9,7 +9,7 @@ // affect any user programs in C as long as this file is included. // // Copyright (C) 1992 Maurice J. LeBrun, Geoff Furnish, Tony Richardson. -// Copyright (C) 2004 Alan W. Irwin +// Copyright (C) 2004-2010 Alan W. Irwin // Copyright (C) 2004 Rafael Laboissiere // Copyright (C) 2004 Andrew Ross // @@ -1226,7 +1226,8 @@ #define PL_LEGEND_OUTSIDE 8192 PLDLLIMPEXP void -c_pllegend( PLINT opt, PLFLT x, PLFLT y, PLFLT plot_width, +c_pllegend( PLFLT *p_legend_width, PLFLT *p_legend_height, + PLINT opt, PLFLT x, PLFLT y, PLFLT plot_width, PLINT bg_color, PLINT bb_color, PLINT bb_style, PLINT nrow, PLINT ncolumn, PLINT nlegend, const PLINT *opt_array, Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2010-11-10 18:14:32 UTC (rev 11317) +++ trunk/src/pllegend.c 2010-11-10 20:07:12 UTC (rev 11318) @@ -383,7 +383,8 @@ //! void -c_pllegend( PLINT opt, PLFLT x, PLFLT y, PLFLT plot_width, +c_pllegend( PLFLT *p_legend_width, PLFLT *p_legend_height, + PLINT opt, PLFLT x, PLFLT y, PLFLT plot_width, PLINT bg_color, PLINT bb_color, PLINT bb_style, PLINT nrow, PLINT ncolumn, PLINT nlegend, const PLINT *opt_array, @@ -422,7 +423,7 @@ PLFLT x_subpage_per_mm, y_subpage_per_mm, text_width0 = 0., text_width; PLFLT width_border, column_separation, - total_width, total_height, total_width_vc, total_height_vc; + legend_width, legend_height, legend_width_vc, legend_height_vc; PLFLT x_legend_position, y_legend_position, xsign, ysign; PLINT some_boxes = 0, some_lines = 0, some_symbols = 0; @@ -526,16 +527,18 @@ column_separation = 2.0 * character_width; // Total width and height of legend area in normalized subpage coordinates. - total_width = 2. * width_border + ( ncolumn - 1 ) * column_separation + + legend_width = 2. * width_border + ( ncolumn - 1 ) * column_separation + ncolumn * ( text_width + viewport_to_subpage_x( plot_width ) - viewport_to_subpage_x( 0. ) ); - total_height = nrow * text_spacing * character_height; + legend_height = nrow * text_spacing * character_height; + *p_legend_width = legend_width; + *p_legend_height = legend_height; // Total width and height of legend area in normalized external viewport // coordinates. - total_width_vc = subpage_to_viewport_x( total_width ) - subpage_to_viewport_x( 0. ); - total_height_vc = subpage_to_viewport_y( total_height ) - subpage_to_viewport_y( 0. ); + legend_width_vc = subpage_to_viewport_x( legend_width ) - subpage_to_viewport_x( 0. ); + legend_height_vc = subpage_to_viewport_y( legend_height ) - subpage_to_viewport_y( 0. ); // dcolumn is the spacing from one column to the next and // drow is the spacing from one row to the next. @@ -543,7 +546,7 @@ viewport_to_subpage_x( plot_width ) - viewport_to_subpage_x( 0. ); drow = text_spacing * character_height; - legend_position( opt, total_width_vc, total_height_vc, &x_legend_position, &y_legend_position, &xsign, &ysign ); + legend_position( opt, legend_width_vc, legend_height_vc, &x_legend_position, &y_legend_position, &xsign, &ysign ); plot_x = x * xsign + x_legend_position; plot_y = y * ysign + y_legend_position; plot_x_end = plot_x + plot_width; @@ -564,13 +567,13 @@ PLFLT xbg[4] = { plot_x_subpage, plot_x_subpage, - plot_x_subpage + total_width, - plot_x_subpage + total_width, + plot_x_subpage + legend_width, + plot_x_subpage + legend_width, }; PLFLT ybg[4] = { plot_y_subpage, - plot_y_subpage - total_height, - plot_y_subpage - total_height, + plot_y_subpage - legend_height, + plot_y_subpage - legend_height, plot_y_subpage, }; plpsty( 0 ); @@ -584,14 +587,14 @@ PLFLT xbb[5] = { plot_x_subpage, plot_x_subpage, - plot_x_subpage + total_width, - plot_x_subpage + total_width, + plot_x_subpage + legend_width, + plot_x_subpage + legend_width, plot_x_subpage, }; PLFLT ybb[5] = { plot_y_subpage, - plot_y_subpage - total_height, - plot_y_subpage - total_height, + plot_y_subpage - legend_height, + plot_y_subpage - legend_height, plot_y_subpage, plot_y_subpage, }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |