From: <ai...@us...> - 2011-05-30 19:11:58
|
Revision: 11755 http://plplot.svn.sourceforge.net/plplot/?rev=11755&view=rev Author: airwin Date: 2011-05-30 19:11:52 +0000 (Mon, 30 May 2011) Log Message: ----------- Put the "m" and "n" axis_opts under user control rather than specifying them internally within the plcolorbar code. This change completes my goal of removing cross-talk between PL_POSITION_* bits (now reserved for specifying only the position of the colorbar) and other characteristics of the plcolorbar result. There is still a lot of work I have planned for plcolorbar. First on that agenda is to use the same positioning logic as is used for pllegend. This planned change is only possible because of the prior work of removing the cross-talk mentioned above. 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-05-17 22:16:51 UTC (rev 11754) +++ trunk/examples/c/x16c.c 2011-05-30 19:11:52 UTC (rev 11755) @@ -243,7 +243,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -289,7 +289,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -335,7 +335,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -380,7 +380,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.05, 0.15, 0.03, 0.7, 0.0, 0.0, - 2, 3, 0.0, 0, "bcvx", "", + 2, 3, 0.0, 0, "bcvxm", "", ns + 1, shedge ); // Reset text and tick sizes @@ -476,7 +476,7 @@ plcolorbar( PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL, PL_POSITION_RIGHT, 0.06, 0.15, 0.03, 0.7, 0.0, 0.0, - cont_color, cont_width, 0.0, 0, "bcvt", "", + cont_color, cont_width, 0.0, 0, "bcvtm", "", ns + 1, shedge ); // Reset text and tick sizes Modified: trunk/examples/c/x33c.c =================================================================== --- trunk/examples/c/x33c.c 2011-05-17 22:16:51 UTC (rev 11754) +++ trunk/examples/c/x33c.c 2011-05-30 19:11:52 UTC (rev 11755) @@ -156,7 +156,7 @@ PLFLT ticks; PLINT sub_ticks; PLFLT low_cap_color, high_cap_color; - PLINT vertical; + PLINT vertical, ifn; const char *axis_opts; char label[200]; char title[200]; @@ -180,6 +180,7 @@ colorbar_cap_options[cap_i]; vertical = position & PL_POSITION_LEFT || position & PL_POSITION_RIGHT; + ifn = position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM; // Set the offset position on the page if ( vertical ) @@ -197,15 +198,29 @@ y_length = 0.05; } - // Set appropriate labeling options + // Set appropriate labelling options. + if ( ifn ) + { if ( cont_color == 0 || cont_width == 0 ) { - axis_opts = "uwtv"; + axis_opts = "uwtvn"; } else { - axis_opts = "uwxv"; + axis_opts = "uwxvn"; } + } + else + { + if ( cont_color == 0 || cont_width == 0 ) + { + axis_opts = "uwtvm"; + } + else + { + axis_opts = "uwxvm"; + } + } sprintf( label, "%s, %s", colorbar_position_option_labels[position_i], Modified: trunk/src/pllegend.c =================================================================== --- trunk/src/pllegend.c 2011-05-17 22:16:51 UTC (rev 11754) +++ trunk/src/pllegend.c 2011-05-30 19:11:52 UTC (rev 11755) @@ -1,9 +1,9 @@ // $Id$ -// pllegend(...) (which plots a discrete plot legend) and the static -// routines which support it. +// All routines that help to create a discrete legend (pllegend) or +// a continuous legend (plcolorbar). // -// Copyright (C) 2010 Hezekiah M. Carty -// Copyright (C) 2010 Alan W. Irwin +// Copyright (C) 2010-2011 Hezekiah M. Carty +// Copyright (C) 2010-2011 Alan W. Irwin // // This file is part of PLplot. // @@ -1114,7 +1114,7 @@ // For building axis option string PLINT max_opts = 25; char opt_string[max_opts]; - const char *tick_label_string, *edge_string; + const char *edge_string; size_t length_axis_opts = strlen( axis_opts ); char *local_axis_opts; PLBOOL if_edge; @@ -1142,11 +1142,6 @@ } strcpy( local_axis_opts, axis_opts ); - - // Sanity checking on local_axis_opts to remove all control characters - // that are specified by other means inside this routine. - remove_characters( local_axis_opts, "MmNn" ); - if_edge = plP_stsearch( local_axis_opts, 'b' ) && !plP_stsearch( local_axis_opts, 'u' ) && plP_stsearch( local_axis_opts, 'c' ) && @@ -1633,15 +1628,6 @@ plmtex( opt_string, label_offset, 0.5, 0.5, label ); } - if ( position & PL_POSITION_LEFT || position & PL_POSITION_BOTTOM ) - { - tick_label_string = "n"; - } - else if ( position & PL_POSITION_RIGHT || position & PL_POSITION_TOP ) - { - tick_label_string = "m"; - } - // Draw numerical labels and tick marks if this is a shade color bar // TODO: A better way to handle this would be to update the // internals of plbox to support custom tick and label positions @@ -1649,16 +1635,12 @@ if ( opt & PL_COLORBAR_SHADE && opt & PL_COLORBAR_SHADE_LABEL ) { - snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); if ( opt & PL_COLORBAR_ORIENT_RIGHT || opt & PL_COLORBAR_ORIENT_LEFT ) - label_box_custom( opt_string, n_values, values, "", 0, NULL ); + label_box_custom( local_axis_opts, n_values, values, "", 0, NULL ); else - label_box_custom( "", 0, NULL, opt_string, n_values, values ); - // Exclude tick labels for plbox call below since those tick - // labels have already been handled in a custom way above. - tick_label_string = ""; - // Exclude ticks for plbox call below since those tick marks - // have already been handled in a custom way above. + label_box_custom( "", 0, NULL, local_axis_opts, n_values, values ); + // Exclude ticks for plbox call below since those tick marks and + // associated labels have already been handled in a custom way above. remove_characters( local_axis_opts, "TtXx" ); } @@ -1668,14 +1650,13 @@ edge_string = "bc"; else edge_string = "uw"; - snprintf( opt_string, max_opts, "%s%s", tick_label_string, local_axis_opts ); if ( opt & PL_COLORBAR_ORIENT_TOP || opt & PL_COLORBAR_ORIENT_BOTTOM ) { - plbox( edge_string, 0.0, 0, opt_string, ticks, sub_ticks ); + plbox( edge_string, 0.0, 0, local_axis_opts, ticks, sub_ticks ); } else { - plbox( opt_string, ticks, sub_ticks, edge_string, 0.0, 0 ); + plbox( local_axis_opts, ticks, sub_ticks, edge_string, 0.0, 0 ); } free( local_axis_opts ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |