|
From: <and...@us...> - 2009-02-03 13:45:23
|
Revision: 9443
http://plplot.svn.sourceforge.net/plplot/?rev=9443&view=rev
Author: andrewross
Date: 2009-02-03 13:45:19 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
Replace call to strftime in plbox with equivalent call to qsastime
library. For now everything else is unchanged. Eventually there will be
more routines for time handling. This should now work consistently
across all platforms.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2009-02-03 12:35:31 UTC (rev 9442)
+++ trunk/src/plbox.c 2009-02-03 13:45:19 UTC (rev 9443)
@@ -23,6 +23,7 @@
*/
#include "plplotP.h"
+#include "../lib/qsastime/MJDtime.h"
static PLFLT xlog[8] =
{
@@ -1199,8 +1200,8 @@
PLFLT pos, tn, tp, offset, height;
PLFLT factor, tstart;
const char *timefmt;
- struct tm *tm;
- time_t t;
+ MJDtime tm;
+ double t;
/* Set plot options from input */
@@ -1246,9 +1247,9 @@
tp = xtick1 * (1. + floor(vpwxmi / xtick1));
for (tn = tp; BETW(tn, vpwxmi, vpwxma); tn += xtick1) {
if (ldx) {
- t = (time_t) tn;
- tm = gmtime(&t);
- strftime(string, 40, timefmt, tm);
+ t = (double) tn;
+ setFromUT(1970,1,1,0,0,t,&tm,0);
+ strfMJD(string, 40, timefmt, &tm, 0);
}
else {
plform(tn, xscale, xprec, string, llx, lfx);
@@ -1295,9 +1296,9 @@
tp = ytick1 * (1. + floor(vpwymi / ytick1));
for (tn = tp; BETW(tn, vpwymi, vpwyma); tn += ytick1) {
if (ldy) {
- t = (time_t) tn;
- tm = gmtime(&t);
- strftime(string, 40, timefmt, tm);
+ t = (double) tn;
+ setFromUT(1970,1,1,0,0,t,&tm,0);
+ strfMJD(string, 40, timefmt, &tm, 0);
}
else {
plform(tn, yscale, yprec, string, lly, lfy);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2009-02-18 06:31:16
|
Revision: 9544
http://plplot.svn.sourceforge.net/plplot/?rev=9544&view=rev
Author: airwin
Date: 2009-02-18 06:31:14 +0000 (Wed, 18 Feb 2009)
Log Message:
-----------
Minimal and fairly crude use of newly defined and implemented public API for
libqsastime as a proof of concept.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2009-02-18 06:29:13 UTC (rev 9543)
+++ trunk/src/plbox.c 2009-02-18 06:31:14 UTC (rev 9544)
@@ -1204,7 +1204,7 @@
PLFLT pos, tn, tp, offset, height;
PLFLT factor, tstart;
const char *timefmt;
- MJDtime tm;
+ double tm;
double t;
/* Set plot options from input */
@@ -1252,8 +1252,10 @@
for (tn = tp; BETW(tn, vpwxmi, vpwxma); tn += xtick1) {
if (ldx) {
t = (double) tn;
- setFromUT(1970,0,1,0,0,t,&tm,0);
- strfMJD(string, STRING_LEN, timefmt, &tm, 0);
+ configqsas(0., 0., 0., 0x0);
+ ctimeqsas(1970,0,1,0,0,t,&tm);
+ strfqsas(string, STRING_LEN, timefmt, tm);
+ closeqsas();
}
else {
plform(tn, xscale, xprec, string, STRING_LEN, llx, lfx);
@@ -1301,8 +1303,10 @@
for (tn = tp; BETW(tn, vpwymi, vpwyma); tn += ytick1) {
if (ldy) {
t = (double) tn;
- setFromUT(1970,0,1,0,0,t,&tm,0);
- strfMJD(string, STRING_LEN, timefmt, &tm, 0);
+ configqsas(0., 0., 0., 0x0);
+ ctimeqsas(1970,0,1,0,0,t,&tm);
+ strfqsas(string, STRING_LEN, timefmt, tm);
+ closeqsas();
}
else {
plform(tn, yscale, yprec, string, STRING_LEN, lly, lfy);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2009-02-21 00:43:58
|
Revision: 9569
http://plplot.svn.sourceforge.net/plplot/?rev=9569&view=rev
Author: airwin
Date: 2009-02-21 00:43:48 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Simplify plbox to use the new time API.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2009-02-21 00:32:28 UTC (rev 9568)
+++ trunk/src/plbox.c 2009-02-21 00:43:48 UTC (rev 9569)
@@ -1203,7 +1203,6 @@
PLFLT pos, tn, tp, offset, height;
PLFLT factor, tstart;
const char *timefmt;
- double tm;
double t;
/* Set plot options from input */
@@ -1250,9 +1249,7 @@
tp = xtick1 * (1. + floor(vpwxmi / xtick1));
for (tn = tp; BETW(tn, vpwxmi, vpwxma); tn += xtick1) {
if (ldx) {
- t = (double) tn;
- ctimeqsas(1970,0,1,0,0,t,&tm, plsc->qsasconfig);
- strfqsas(string, STRING_LEN, timefmt, tm, plsc->qsasconfig);
+ strfqsas(string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig);
}
else {
plform(tn, xscale, xprec, string, STRING_LEN, llx, lfx);
@@ -1299,9 +1296,7 @@
tp = ytick1 * (1. + floor(vpwymi / ytick1));
for (tn = tp; BETW(tn, vpwymi, vpwyma); tn += ytick1) {
if (ldy) {
- t = (double) tn;
- ctimeqsas(1970,0,1,0,0,t,&tm, plsc->qsasconfig);
- strfqsas(string, STRING_LEN, timefmt, tm, plsc->qsasconfig);
+ strfqsas(string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig);
}
else {
plform(tn, yscale, yprec, string, STRING_LEN, lly, lfy);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2013-10-24 18:22:33
|
Revision: 12624
http://sourceforge.net/p/plplot/code/12624
Author: airwin
Date: 2013-10-24 18:22:29 +0000 (Thu, 24 Oct 2013)
Log Message:
-----------
Fix bug in logic which allowed uninitialized values (for height, pos,
and just) for the fairly common case when label_func and label_data
were non-NULL. Improve code clarity so it is obvious these values
must be initialized by the code logic.
N.B. the gcc options -O3 -Wunintialized found this bug, but the above
fix does not quiet the warning message, i.e., this bug fix turns this
warning about uninitialized variables into a false alarm.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-10-24 17:38:37 UTC (rev 12623)
+++ trunk/src/plbox.c 2013-10-24 18:22:29 UTC (rev 12624)
@@ -1400,6 +1400,10 @@
PLFLT default_mm, char_height_mm, height_mm;
PLFLT string_length_mm = 0.0, pos_mm = 0.0;
+ // Assume label data is for placement of exponents if no custom
+ // label function is provided.
+ PLBOOL custom_exponent_placement = !plsc->label_func && plsc->label_data;
+
plgchr( &default_mm, &char_height_mm );
// Set plot options from input
@@ -1526,9 +1530,7 @@
if ( !llx && !ldx && !lox && xmode )
{
- // Assume label data is for placement of exponents if no custom
- // label function is provided.
- if ( !plsc->label_func && plsc->label_data )
+ if ( custom_exponent_placement )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -1770,7 +1772,7 @@
if ( !lly && !ldy && !loy && ymode )
{
snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
- if ( !plsc->label_func && plsc->label_data )
+ if ( custom_exponent_placement )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -1787,7 +1789,7 @@
// Left axis exponent
if ( lny )
{
- if ( !plsc->label_data )
+ if ( !custom_exponent_placement )
{
height = 3.2;
pos = 1.0 + offset;
@@ -1825,7 +1827,7 @@
// Right axis exponent.
if ( lmy )
{
- if ( !plsc->label_data )
+ if ( !custom_exponent_placement )
{
height = 3.4; // Extra space for superscript
pos = 1.0 + offset;
@@ -1888,6 +1890,10 @@
PLFLT default_mm, char_height_mm, height_mm;
PLFLT string_length_mm = 0.0, pos_mm = 0.0;
+ // Assume label data is for placement of exponents if no custom
+ // label function is provided.
+ PLBOOL custom_exponent_placement = !plsc->label_func && plsc->label_data;
+
plgchr( &default_mm, &char_height_mm );
// Save some parameters
@@ -2068,9 +2074,7 @@
if ( !llx && !ldx && !lox && xmode )
{
- // Assume label data is for placement of exponents if no custom
- // label function is provided.
- if ( !plsc->label_func && plsc->label_data )
+ if ( custom_exponent_placement )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -2326,7 +2330,7 @@
if ( !lly && !ldy && !loy && ymode )
{
snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
- if ( !plsc->label_func && plsc->label_data )
+ if ( custom_exponent_placement )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -2343,7 +2347,7 @@
// Left axis exponent.
if ( lny )
{
- if ( !plsc->label_data )
+ if ( !custom_exponent_placement )
{
height = 3.2;
pos = 1.0 + offset;
@@ -2381,7 +2385,7 @@
// Right axis exponent.
if ( lmy )
{
- if ( !plsc->label_data )
+ if ( !custom_exponent_placement )
{
height = 3.4; // Extra space for superscript
pos = 1.0 + offset;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hez...@us...> - 2011-01-01 01:21:07
|
Revision: 11415
http://plplot.svn.sourceforge.net/plplot/?rev=11415&view=rev
Author: hezekiahcarty
Date: 2011-01-01 01:21:01 +0000 (Sat, 01 Jan 2011)
Log Message:
-----------
Split out default PLplot axis labeling functions
These are not exposed in the public PLplot API, but they are
now ready (pending a name change) for exposure at some point
in the future.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2011-01-01 01:13:42 UTC (rev 11414)
+++ trunk/src/plbox.c 2011-01-01 01:21:01 UTC (rev 11415)
@@ -1509,6 +1509,71 @@
}
//--------------------------------------------------------------------------
+//
+// Default labeling functions for PLplot
+//
+// These are the functions which are used internally by PLplot under various
+// conditions.
+//
+// They have been separated out for use in other PLplot functions and
+// potential exposure in the PLplot API.
+//
+//--------------------------------------------------------------------------
+void plP_default_label_log( PLINT axis, PLFLT value, char *string, PLINT len, void *data )
+{
+ // Exponential, i.e. 10^-1, 10^0, 10^1, etc
+ snprintf( string, len, "10#u%d", (int) ROUND( value ) );
+}
+
+void plP_default_label_log_fixed( PLINT axis, PLFLT value, char *string, PLINT len, void *data )
+{
+ // Fixed point, i.e. .1, 1, 10, etc
+
+ int exponent = ROUND( value );
+
+ value = pow( 10.0, exponent );
+ if ( exponent < 0 )
+ {
+ char form[FORMAT_LEN];
+ snprintf( form, FORMAT_LEN, "%%.%df", ABS( exponent ) );
+ snprintf( string, len, form, value );
+ }
+ else
+ {
+ snprintf( string, len, "%d", (int) value );
+ }
+}
+
+void plP_default_label( PLINT axis, PLFLT value, char *string, PLINT len, void *data )
+{
+ PLINT scale, prec;
+ PLINT setpre, precis;
+ char form[FORMAT_LEN], temp[TEMP_LEN];
+ double scale2;
+
+ scale = ((PLINT *)data)[0];
+ prec = ((PLINT *)data)[1];
+
+ plP_gprec( &setpre, &precis );
+
+ if ( setpre )
+ prec = precis;
+
+ if ( scale )
+ value /= pow( 10., (double) scale );
+
+ // This is necessary to prevent labels like "-0.0" on some systems
+
+ scale2 = pow( 10., prec );
+ value = floor( ( value * scale2 ) + .5 ) / scale2;
+
+ snprintf( form, FORMAT_LEN, "%%.%df", (int) prec );
+ snprintf( temp, TEMP_LEN, form, value );
+ strncpy( string, temp, len - 1 );
+ string[len - 1] = '\0';
+}
+
+//--------------------------------------------------------------------------
// void plform()
//
// Formats a PLFLT value in one of the following formats.
@@ -1556,53 +1621,19 @@
if ( lf )
{
// Fixed point, i.e. .1, 1, 10, etc
-
- int exponent = ROUND( value );
-
- value = pow( 10.0, exponent );
- if ( exponent < 0 )
- {
- char form[FORMAT_LEN];
- snprintf( form, FORMAT_LEN, "%%.%df", ABS( exponent ) );
- snprintf( string, len, form, value );
- }
- else
- {
- snprintf( string, len, "%d", (int) value );
- }
+ plP_default_label_log_fixed( axis, value, string, len, NULL );
}
else
{
// Exponential, i.e. 10^-1, 10^0, 10^1, etc
-
- snprintf( string, len, "10#u%d", (int) ROUND( value ) );
+ plP_default_label_log( axis, value, string, len, NULL );
}
}
else
{
// Linear
-
- PLINT setpre, precis;
- char form[FORMAT_LEN], temp[TEMP_LEN];
- double scale2;
-
- plP_gprec( &setpre, &precis );
-
- if ( setpre )
- prec = precis;
-
- if ( scale )
- value /= pow( 10., (double) scale );
-
- // This is necessary to prevent labels like "-0.0" on some systems
-
- scale2 = pow( 10., prec );
- value = floor( ( value * scale2 ) + .5 ) / scale2;
-
- snprintf( form, FORMAT_LEN, "%%.%df", (int) prec );
- snprintf( temp, TEMP_LEN, form, value );
- strncpy( string, temp, len - 1 );
- string[len - 1] = '\0';
+ PLINT scale_prec[2] = { scale, prec };
+ plP_default_label( axis, value, string, len, (void *)scale_prec );
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2011-05-12 20:17:46
|
Revision: 11747
http://plplot.svn.sourceforge.net/plplot/?rev=11747&view=rev
Author: airwin
Date: 2011-05-12 20:17:40 +0000 (Thu, 12 May 2011)
Log Message:
-----------
If both "b" and "u" options specified for xopt or yopt argument for
plaxes (or plbox), "u" option has the priority.
If both "c" and "w" options specified for xopt or yopt argument for
plaxes (or plbox), "w" option has the priority.
Implement "x" option for xopt or yopt argument for plaxes (or plbox).
This option has all the side effects of "t" such as numerical tick
labelling (if specified), but the actual ticks are not drawn.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2011-05-06 20:24:10 UTC (rev 11746)
+++ trunk/src/plbox.c 2011-05-12 20:17:40 UTC (rev 11747)
@@ -106,9 +106,13 @@
// o: Label text is generated by a user-defined function
// t: Draw major tick marks
// s: Draw minor tick marks
-// u: like b except exclude drawing the edge.
-// w: like c except exclude drawing the edge.
+// u: like b (including all side effects such as tick marks and numerical
+// labels for those) except exclude drawing the edge.
+// w: like c (including all side effects such as tick marks and numerical
+// labels for those) except exclude drawing the edge.
// v: (for Y only) Label vertically
+// x: like t (including the side effect of the numerical labels for the major
+// ticks) except exclude drawing the major and minor tick marks.
//
// xtick, ytick are the major tick intervals required, zero for
// automatic selection
@@ -122,8 +126,8 @@
const char *xopt, PLFLT xtick, PLINT nxsub,
const char *yopt, PLFLT ytick, PLINT nysub )
{
- PLBOOL lax, lbx, lcx, ldx, lgx, lix, llx, lsx, ltx, lux, lwx;
- PLBOOL lay, lBy, lby, lCy, lcy, ldy, lgy, liy, lly, lsy, lty, luy, lwy;
+ PLBOOL lax, lbx, lcx, ldx, lgx, lix, llx, lsx, ltx, lux, lwx, lxx;
+ PLBOOL lay, lBy, lby, lCy, lcy, ldy, lgy, liy, lly, lsy, lty, luy, lwy, lxy;
PLINT xmajor, xminor, ymajor, yminor;
PLINT i, i1x, i2x, i3x, i4x, i1y, i2y, i3y, i4y;
PLINT nxsub1, nysub1;
@@ -170,6 +174,7 @@
ltx = plP_stsearch( xopt, 't' );
lux = plP_stsearch( xopt, 'u' );
lwx = plP_stsearch( xopt, 'w' );
+ lxx = plP_stsearch( xopt, 'x' );
lay = plP_stsearch( yopt, 'a' );
lby = plP_stsearch( yopt, 'b' );
@@ -180,8 +185,9 @@
lly = plP_stsearch( yopt, 'l' );
lsy = plP_stsearch( yopt, 's' );
lty = plP_stsearch( yopt, 't' );
- luy = plP_stsearch( xopt, 'u' );
- lwy = plP_stsearch( xopt, 'w' );
+ luy = plP_stsearch( yopt, 'u' );
+ lwy = plP_stsearch( yopt, 'w' );
+ lxy = plP_stsearch( yopt, 'x' );
// Tick and subtick sizes in device coords
@@ -208,10 +214,10 @@
// Calculate tick spacing
- if ( ltx || lgx )
+ if ( ltx || lgx || lxx )
pldtik( vpwxmi, vpwxma, &xtick1, &nxsub1, ldx );
- if ( lty || lgy )
+ if ( lty || lgy || lxy )
pldtik( vpwymi, vpwyma, &ytick1, &nysub1, ldy );
// n.b. large change; xtick1, nxsub1, ytick1, nysub1 always positive.
@@ -251,12 +257,12 @@
if ( lbx || lux )
{
- if ( lbx )
+ if ( !lux )
{
plP_movphy( vppxmi, vppymi );
plP_draphy( vppxma, vppymi );
}
- if ( ltx )
+ if ( ltx && !lxx )
{
if ( ldx )
{
@@ -301,12 +307,12 @@
if ( lcy || lwy )
{
- if ( lcy )
+ if ( !lwy )
{
plP_movphy( vppxma, vppymi );
plP_draphy( vppxma, vppyma );
}
- if ( lty )
+ if ( lty && !lxy )
{
if ( ldy )
{
@@ -351,12 +357,12 @@
if ( lcx || lwx )
{
- if ( lcx )
+ if ( !lwx )
{
plP_movphy( vppxma, vppyma );
plP_draphy( vppxmi, vppyma );
}
- if ( ltx )
+ if ( ltx && !lxx )
{
if ( ldx )
{
@@ -401,12 +407,12 @@
if ( lby || luy )
{
- if ( lby )
+ if ( !luy )
{
plP_movphy( vppxmi, vppyma );
plP_draphy( vppxmi, vppymi );
}
- if ( lty )
+ if ( lty && !lxy )
{
if ( ldy )
{
@@ -453,7 +459,7 @@
{
plP_movphy( vppxmi, (PLINT) yp0 );
plP_draphy( vppxma, (PLINT) yp0 );
- if ( ltx )
+ if ( ltx && !lxx )
{
tp = xtick1 * floor( vpwxmi / xtick1 );
for (;; )
@@ -494,7 +500,7 @@
{
plP_movphy( (PLINT) xp0, vppymi );
plP_draphy( (PLINT) xp0, vppyma );
- if ( lty )
+ if ( lty && !lxy )
{
tp = ytick1 * floor( vpwymi / ytick1 );
for (;; )
@@ -1330,8 +1336,8 @@
label_box( const char *xopt, PLFLT xtick1, const char *yopt, PLFLT ytick1 )
{
static char string[STRING_LEN];
- PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx, lox;
- PLBOOL ldy, lfy, liy, lly, lmy, lny, lty, lvy, loy;
+ PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx, lox, lxx;
+ PLBOOL ldy, lfy, liy, lly, lmy, lny, lty, lvy, loy, lxy;
PLFLT vpwxmi, vpwxma, vpwymi, vpwyma;
PLFLT vpwxmin, vpwxmax, vpwymin, vpwymax;
PLFLT pos, tn, tp, offset, height, just;
@@ -1348,6 +1354,7 @@
lnx = plP_stsearch( xopt, 'n' );
ltx = plP_stsearch( xopt, 't' );
lox = plP_stsearch( xopt, 'o' );
+ lxx = plP_stsearch( xopt, 'x' );
ldy = plP_stsearch( yopt, 'd' );
lfy = plP_stsearch( yopt, 'f' );
@@ -1358,6 +1365,7 @@
lty = plP_stsearch( yopt, 't' );
lvy = plP_stsearch( yopt, 'v' );
loy = plP_stsearch( yopt, 'o' );
+ lxy = plP_stsearch( yopt, 'x' );
plP_xgvpw( &vpwxmin, &vpwxmax, &vpwymin, &vpwymax );
// n.b. large change; vpwxmi always numerically less than vpwxma, and
@@ -1369,7 +1377,7 @@
// Write horizontal label(s)
- if ( ( lmx || lnx ) && ltx )
+ if ( ( lmx || lnx ) && ( ltx || lxx ) )
{
PLINT xmode, xprec, xdigmax, xdigits, xscale;
@@ -1434,7 +1442,7 @@
// Write vertical label(s)
- if ( ( lmy || lny ) && lty )
+ if ( ( lmy || lny ) && ( lty || lxy ) )
{
PLINT ymode, yprec, ydigmax, ydigits, yscale;
@@ -1536,8 +1544,8 @@
label_box_custom( const char *xopt, PLINT n_xticks, const PLFLT *xticks, const char *yopt, PLINT n_yticks, const PLFLT *yticks )
{
static char string[STRING_LEN];
- PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx, lox;
- PLBOOL ldy, lfy, liy, lly, lmy, lny, lty, lvy, loy;
+ PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx, lox, lxx;
+ PLBOOL ldy, lfy, liy, lly, lmy, lny, lty, lvy, loy, lxy;
PLFLT vpwxmi, vpwxma, vpwymi, vpwyma;
PLFLT vpwxmin, vpwxmax, vpwymin, vpwymax;
PLFLT pos, tn, offset, height, just;
@@ -1573,6 +1581,7 @@
lnx = plP_stsearch( xopt, 'n' );
ltx = plP_stsearch( xopt, 't' );
lox = plP_stsearch( xopt, 'o' );
+ lxx = plP_stsearch( xopt, 'x' );
ldy = plP_stsearch( yopt, 'd' );
lfy = plP_stsearch( yopt, 'f' );
@@ -1583,6 +1592,7 @@
lty = plP_stsearch( yopt, 't' );
lvy = plP_stsearch( yopt, 'v' );
loy = plP_stsearch( yopt, 'o' );
+ lxy = plP_stsearch( yopt, 'x' );
plP_xgvpw( &vpwxmin, &vpwxmax, &vpwymin, &vpwymax );
// n.b. large change; vpwxmi always numerically less than vpwxma, and
@@ -1594,7 +1604,7 @@
// Write horizontal label(s)
- if ( ( lmx || lnx ) && ltx )
+ if ( ( lmx || lnx ) && ( ltx || lxx ) )
{
PLINT xmode, xprec, xscale;
PLFLT x_spacing, x_spacing_tmp;
@@ -1638,8 +1648,11 @@
plmtex( "b", height, pos, 0.5, string );
if ( lmx )
plmtex( "t", height, pos, 0.5, string );
- plwxtik( tn, vpwymin, FALSE, !lix );
- plwxtik( tn, vpwymax, FALSE, lix );
+ if ( !lxx )
+ {
+ plwxtik( tn, vpwymin, FALSE, !lix );
+ plwxtik( tn, vpwymax, FALSE, lix );
+ }
}
}
xdigits = 2;
@@ -1673,7 +1686,7 @@
// Write vertical label(s)
- if ( ( lmy || lny ) && lty )
+ if ( ( lmy || lny ) && ( lty || lxy ) )
{
PLINT ymode, yprec, yscale;
PLFLT y_spacing, y_spacing_tmp;
@@ -1739,8 +1752,11 @@
}
}
ydigits = MAX( ydigits, (PLINT) strlen( string ) );
- plwytik( vpwxmin, tn, FALSE, !liy );
- plwytik( vpwxmax, tn, FALSE, liy );
+ if ( !lxy )
+ {
+ plwytik( vpwxmin, tn, FALSE, !liy );
+ plwytik( vpwxmax, tn, FALSE, liy );
+ }
}
}
if ( !lvy )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2011-07-11 22:12:01
|
Revision: 11808
http://plplot.svn.sourceforge.net/plplot/?rev=11808&view=rev
Author: airwin
Date: 2011-07-11 22:11:54 +0000 (Mon, 11 Jul 2011)
Log Message:
-----------
Update bounding box to include both vertical and horizontal components
of numerical labelling of vertical axes. Example 33 confirms this
improvement is working properly. This completes (aside from the
vertical axis exponents) the bounding box calculation for vertical
axes of plbox which has been verified using example 33 with and without
the "v" option in axis_opts.
ToDo: Still need to implement vertical axis exponents for plbox
bounding box. For plcolorbar also need to implement bounding-box
functionality for horizontal and vertical axes of custom labels and
bounding-box functionality for overall colorbar label.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2011-07-11 22:04:24 UTC (rev 11807)
+++ trunk/src/plbox.c 2011-07-11 22:11:54 UTC (rev 11808)
@@ -1405,7 +1405,7 @@
vpwymi = ( vpwymax > vpwymin ) ? vpwymin : vpwymax;
vpwyma = ( vpwymax > vpwymin ) ? vpwymax : vpwymin;
-// Write horizontal label(s)
+ // Write label(s) for horizontal axes.
if ( ( lmx || lnx ) && ( ltx || lxx ) )
{
PLINT xmode, xprec, xdigmax, xdigits, xscale;
@@ -1426,10 +1426,11 @@
height = lix ? 1.75 : 1.5;
if ( plsc->if_boxbb )
{
- // Height of zero corresponds to character centred on edge
- // so should add 0.5 to height to obtain bounding box edge
- // in direction away from edge. However, experimentally
- // found 0.7 gave a better looking result.
+ // For horizontal axes, height of zero corresponds to
+ // character centred on edge so should add 0.5 to height
+ // to obtain bounding box edge in direction away from
+ // edge. However, experimentally found 0.7 gave a better
+ // looking result.
height_mm = ( height + 0.7 ) * char_height_mm;
if ( lnx )
plsc->boxbb_ymin = MIN( plsc->boxbb_ymin, plsc->vppymi /
@@ -1517,10 +1518,11 @@
// Bottom axis exponent.
if ( plsc->if_boxbb )
{
- // Height of zero corresponds to character centred on edge
- // so should add 0.5 to height to obtain bounding box edge
- // in direction away from edge if no exponent.
- // Add an additional offset to make exponent fit.
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
height_mm = ( height + 0.9 ) * char_height_mm;
plsc->boxbb_ymin = MIN( plsc->boxbb_ymin, plsc->vppymi /
plsc->ypmm - height_mm );
@@ -1543,10 +1545,11 @@
// Top axis exponent.
if ( plsc->if_boxbb )
{
- // Height of zero corresponds to character centred on edge
- // so should add 0.5 to height to obtain bounding box edge
- // in direction away from edge if no exponent.
- // Add an additional offset to make exponent fit.
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
height_mm = ( height + 1.4 ) * char_height_mm;
plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
plsc->ypmm + height_mm );
@@ -1567,7 +1570,7 @@
}
}
-// Write vertical label(s)
+ // Write label(s) for vertical axes.
if ( ( lmy || lny ) && ( lty || lxy ) )
{
@@ -1604,30 +1607,61 @@
if ( lvy )
{
// Left axis with text written perpendicular to edge.
+ height = liy ? 1.0 : 0.5;
if ( plsc->if_boxbb )
{
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
+ // For vertical axes with text written
+ // perpendicular to edge, height of zero
+ // corresponds character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge, and
+ // that value apparently works.
+ height_mm = ( height + 0.0 ) * char_height_mm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, plsc->vppxmi /
+ plsc->xpmm - height_mm - string_length_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ // Expected offset is 0.5, but adjust to improve
+ // look of result.
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.6 * char_height_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.7 * char_height_mm );
}
else
{
- height = liy ? 1.0 : 0.5;
plmtex( "lv", height, pos, 1.0, string );
}
}
else
{
- // Top axis.
+ // Left axis with text written parallel to edge.
+ height = liy ? 1.75 : 1.5;
if ( plsc->if_boxbb )
{
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
+ // For vertical axes with text written
+ // parallel to edge, height of zero
+ // corresponds to character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge,
+ // However, experimentally found 0.8 gave a
+ // better looking result.
+ height_mm = ( height + 0.8 ) * char_height_mm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, plsc->vppxmi /
+ plsc->xpmm - height_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.5 * string_length_mm );
}
else
{
- height = liy ? 1.75 : 1.5;
plmtex( "l", height, pos, 0.5, string );
}
}
@@ -1636,31 +1670,62 @@
{
if ( lvy )
{
- // Top axis.
+ // Right axis with text written perpendicular to edge.
+ height = liy ? 1.0 : 0.5;
if ( plsc->if_boxbb )
{
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
+ // For vertical axes with text written
+ // perpendicular to edge, height of zero
+ // corresponds character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge, and
+ // that value apparently works.
+ height_mm = ( height + 0.0 ) * char_height_mm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, plsc->vppxma /
+ plsc->xpmm + height_mm + string_length_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ // Expected offset is 0.5, but adjust to improve
+ // look of result.
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.6 * char_height_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.7 * char_height_mm );
}
else
{
- height = liy ? 1.0 : 0.5;
plmtex( "rv", height, pos, 0.0, string );
}
}
else
{
- // Top axis.
+ // Right axis with text written parallel to edge.
+ height = liy ? 1.75 : 1.5;
if ( plsc->if_boxbb )
{
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
+ // For vertical axes with text written
+ // parallel to edge, height of zero
+ // corresponds to character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge,
+ // However, experimentally found 0.8 gave a
+ // better looking result.
+ height_mm = ( height + 0.8 ) * char_height_mm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, plsc->vppxma /
+ plsc->xpmm + height_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.5 * string_length_mm );
}
else
{
- height = liy ? 1.75 : 1.5;
plmtex( "r", height, pos, 0.5, string );
}
}
@@ -1691,24 +1756,33 @@
{
pos = 0.0 - offset;
just = 1.0;
+ if ( plsc->if_boxbb )
+ {
+ // FIXME: Add X bounding box calculations for
+ // numerical labels that slop over the end of the
+ // axis.
+ }
+ else
+ {
+ plmtex( "t", height, pos, just, string );
+ }
}
if ( lmy )
{
pos = 1.0 + offset;
just = 0.0;
+ if ( plsc->if_boxbb )
+ {
+ // FIXME: Add X bounding box calculations for
+ // numerical labels that slop over the end of the
+ // axis.
+ }
+ else
+ {
+ plmtex( "t", height, pos, just, string );
+ }
}
}
- // Top axis.
- if ( plsc->if_boxbb )
- {
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2011-07-12 04:17:01
|
Revision: 11810
http://plplot.svn.sourceforge.net/plplot/?rev=11810&view=rev
Author: airwin
Date: 2011-07-12 04:16:54 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Update bounding box to include vertical axis exponents for plbox
bounding box. Example 33 confirms this improvement is working
properly. This completes the bounding box calculation for plbox!
ToDo: For plcolorbar still need to implement bounding-box
functionality for horizontal and vertical axes of custom labels and
bounding-box functionality for overall colorbar label.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2011-07-12 01:47:09 UTC (rev 11809)
+++ trunk/src/plbox.c 2011-07-12 04:16:54 UTC (rev 11810)
@@ -1752,30 +1752,54 @@
{
offset = 0.02;
height = 2.0;
+ // Left axis exponent
if ( lny )
{
pos = 0.0 - offset;
just = 1.0;
if ( plsc->if_boxbb )
{
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
}
else
{
plmtex( "t", height, pos, just, string );
}
}
+ // Right axis exponent.
if ( lmy )
{
pos = 1.0 + offset;
just = 0.0;
if ( plsc->if_boxbb )
{
- // FIXME: Add X bounding box calculations for
- // numerical labels that slop over the end of the
- // axis.
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2011-07-12 05:48:47
|
Revision: 11811
http://plplot.svn.sourceforge.net/plplot/?rev=11811&view=rev
Author: airwin
Date: 2011-07-12 05:48:39 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Implement bounding-box functionality for horizontal and vertical axes
of custom labels following what is done in plbox. The bounding-box
results for custom labels look the same (good) as for more ordinary
labels done with plbox in example 33.
ToDo: For plcolorbar still need to implement adjustment of overall
colorbar label position relative to plbox bounding box and implement
bounding-box functionality for (moved) overall colorbar label.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2011-07-12 04:16:54 UTC (rev 11810)
+++ trunk/src/plbox.c 2011-07-12 05:48:39 UTC (rev 11811)
@@ -1650,7 +1650,7 @@
// better looking result.
height_mm = ( height + 0.8 ) * char_height_mm;
plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, plsc->vppxmi /
- plsc->xpmm - height_mm );
+ plsc->xpmm - height_mm );
pos_mm = ( plsc->vppymi + pos *
( plsc->vppyma - plsc->vppymi ) ) /
plsc->ypmm;
@@ -1714,7 +1714,7 @@
// better looking result.
height_mm = ( height + 0.8 ) * char_height_mm;
plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, plsc->vppxma /
- plsc->xpmm + height_mm );
+ plsc->xpmm + height_mm );
pos_mm = ( plsc->vppymi + pos *
( plsc->vppyma - plsc->vppymi ) ) /
plsc->ypmm;
@@ -1759,20 +1759,20 @@
just = 1.0;
if ( plsc->if_boxbb )
{
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
}
else
{
@@ -1786,20 +1786,20 @@
just = 0.0;
if ( plsc->if_boxbb )
{
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
}
else
{
@@ -1833,7 +1833,11 @@
PLINT ydigmax, ydigits, ydigmax_old, ydigits_old;
PLINT lxmin, lxmax, lymin, lymax;
PLINT pxmin, pxmax, pymin, pymax;
+ PLFLT default_mm, char_height_mm, height_mm;
+ PLFLT string_length_mm, pos_mm;
+ plgchr( &default_mm, &char_height_mm );
+
// Save some parameters
plgxax( &xdigmax, &xdigits );
plgyax( &ydigmax, &ydigits );
@@ -1904,197 +1908,436 @@
plsc->boxbb_xmax += ymajor / plsc->xpmm;
}
}
- else
+ // Write label(s) for horizontal axes.
+
+ if ( ( lmx || lnx ) && ( ltx || lxx ) )
{
-// Write horizontal label(s)
+ PLINT xmode, xprec, xscale;
+ PLFLT x_spacing, x_spacing_tmp;
- if ( ( lmx || lnx ) && ( ltx || lxx ) )
+ // Determine spacing between ticks
+ // Use the x-size of the window
+ x_spacing = vpwxma - vpwxmi;
+ if ( n_xticks > 1 )
{
- PLINT xmode, xprec, xscale;
- PLFLT x_spacing, x_spacing_tmp;
-
- // Determine spacing between ticks
- // Use the x-size of the window
- x_spacing = vpwxma - vpwxmi;
- if ( n_xticks > 1 )
+ // Use the smallest space between ticks
+ for ( i = 1; i < n_xticks; i++ )
{
- // Use the smallest space between ticks
- for ( i = 1; i < n_xticks; i++ )
- {
- x_spacing_tmp = fabs( xticks[i] - xticks[i - 1] );
- x_spacing = MIN( x_spacing, x_spacing_tmp );
- }
+ x_spacing_tmp = fabs( xticks[i] - xticks[i - 1] );
+ x_spacing = MIN( x_spacing, x_spacing_tmp );
}
+ }
- plgxax( &xdigmax, &xdigits );
- pldprec( vpwxmi, vpwxma, x_spacing, lfx, &xmode, &xprec, xdigmax, &xscale );
- timefmt = plP_gtimefmt();
+ plgxax( &xdigmax, &xdigits );
+ pldprec( vpwxmi, vpwxma, x_spacing, lfx, &xmode, &xprec, xdigmax, &xscale );
+ timefmt = plP_gtimefmt();
- // Loop through all of the tick marks
- for ( i = 0; i < n_xticks; i++ )
+ height = lix ? 1.75 : 1.5;
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds to
+ // character centred on edge so should add 0.5 to height
+ // to obtain bounding box edge in direction away from
+ // edge. However, experimentally found 0.7 gave a better
+ // looking result.
+ height_mm = ( height + 0.7 ) * char_height_mm;
+ if ( lnx )
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin, plsc->vppymi /
+ plsc->ypmm - height_mm );
+ if ( lmx )
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ }
+ // Loop through all of the tick marks
+ for ( i = 0; i < n_xticks; i++ )
+ {
+ tn = xticks[i];
+ if ( BETW( tn, vpwxmi, vpwxma ) )
{
- tn = xticks[i];
- if ( BETW( tn, vpwxmi, vpwxma ) )
+ if ( !lxx && !plsc->if_boxbb )
{
- if ( !lxx )
+ plwxtik( tn, vpwymin, FALSE, !lix );
+ plwxtik( tn, vpwymax, FALSE, lix );
+ }
+ if ( ldx )
+ {
+ strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig );
+ }
+ else
+ {
+ plform( PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox );
+ }
+ pos = ( vpwxmax > vpwxmin ) ?
+ ( tn - vpwxmi ) / ( vpwxma - vpwxmi ) :
+ ( vpwxma - tn ) / ( vpwxma - vpwxmi );
+ if ( plsc->if_boxbb )
+ {
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ }
+ if ( lnx )
+ {
+ // Bottom axis.
+ if ( plsc->if_boxbb )
{
- plwxtik( tn, vpwymin, FALSE, !lix );
- plwxtik( tn, vpwymax, FALSE, lix );
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax,
+ pos_mm + 0.5 * string_length_mm );
}
- if ( ldx )
+ else
{
- strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig );
+ plmtex( "b", height, pos, 0.5, string );
}
+ }
+ if ( lmx )
+ {
+ // Top axis.
+ if ( plsc->if_boxbb )
+ {
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax,
+ pos_mm + 0.5 * string_length_mm );
+ }
else
{
- plform( PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox );
+ plmtex( "t", height, pos, 0.5, string );
}
- height = lix ? 1.75 : 1.5;
- pos = ( vpwxmax > vpwxmin ) ?
- ( tn - vpwxmi ) / ( vpwxma - vpwxmi ) :
- ( vpwxma - tn ) / ( vpwxma - vpwxmi );
- if ( lnx )
- plmtex( "b", height, pos, 0.5, string );
- if ( lmx )
- plmtex( "t", height, pos, 0.5, string );
}
}
- xdigits = 2;
- plsxax( xdigmax, xdigits );
+ }
+ xdigits = 2;
+ plsxax( xdigmax, xdigits );
- // Write separate exponential label if mode = 1.
+ // Write separate exponential label if mode = 1.
- if ( !llx && !ldx && !lox && xmode )
+ if ( !llx && !ldx && !lox && xmode )
+ {
+ // Assume label data is for placement of exponents if no custom
+ // label function is provided.
+ if ( plsc->label_data )
{
- // Assume label data is for placement of exponents if no custom
- // label function is provided.
- if ( plsc->label_data )
+ height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
+ pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
+ just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
+ }
+ else
+ {
+ height = 3.2;
+ pos = 1.0;
+ just = 0.5;
+ }
+ snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale );
+ if ( lnx )
+ {
+ // Bottom axis exponent.
+ if ( plsc->if_boxbb )
{
- height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
- pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
- just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 0.9 ) * char_height_mm;
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin, plsc->vppymi /
+ plsc->ypmm - height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax,
+ pos_mm + 0.5 * string_length_mm );
}
else
{
- height = 3.2;
- pos = 1.0;
- just = 0.5;
+ plmtex( "b", height, pos, just, string );
}
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale );
- if ( lnx )
- plmtex( "b", height, pos, just, string );
- if ( lmx )
+ }
+ if ( lmx )
+ {
+ // Top axis exponent.
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax,
+ pos_mm + 0.5 * string_length_mm );
+ }
+ else
+ {
plmtex( "t", height, pos, just, string );
+ }
}
}
+ }
-// Write vertical label(s)
+ // Write label(s) for vertical axes.
+ if ( ( lmy || lny ) && ( lty || lxy ) )
+ {
+ PLINT ymode, yprec, yscale;
+ PLFLT y_spacing, y_spacing_tmp;
- if ( ( lmy || lny ) && ( lty || lxy ) )
+ // Determine spacing between ticks
+ // Use the y-size of the window
+ y_spacing = vpwyma - vpwymi;
+ if ( n_yticks > 1 )
{
- PLINT ymode, yprec, yscale;
- PLFLT y_spacing, y_spacing_tmp;
-
- // Determine spacing between ticks
- // Use the y-size of the window
- y_spacing = vpwyma - vpwymi;
- if ( n_yticks > 1 )
+ // Use the smallest space between ticks
+ for ( i = 1; i < n_yticks; i++ )
{
- // Use the smallest space between ticks
- for ( i = 1; i < n_yticks; i++ )
- {
- y_spacing_tmp = fabs( yticks[i] - yticks[i - 1] );
- y_spacing = MIN( y_spacing, y_spacing_tmp );
- }
+ y_spacing_tmp = fabs( yticks[i] - yticks[i - 1] );
+ y_spacing = MIN( y_spacing, y_spacing_tmp );
}
+ }
- plgyax( &ydigmax, &ydigits );
- pldprec( vpwymi, vpwyma, y_spacing, lfy, &ymode, &yprec, ydigmax, &yscale );
- timefmt = plP_gtimefmt();
+ plgyax( &ydigmax, &ydigits );
+ pldprec( vpwymi, vpwyma, y_spacing, lfy, &ymode, &yprec, ydigmax, &yscale );
+ timefmt = plP_gtimefmt();
- ydigits = 0;
- for ( i = 0; i < n_yticks; i++ )
+ ydigits = 0;
+ for ( i = 0; i < n_yticks; i++ )
+ {
+ tn = yticks[i];
+ if ( BETW( tn, vpwymi, vpwyma ) )
{
- tn = yticks[i];
- if ( BETW( tn, vpwymi, vpwyma ) )
+ if ( !lxy && !plsc->if_boxbb )
{
- if ( !lxy )
+ plwytik( vpwxmin, tn, FALSE, !liy );
+ plwytik( vpwxmax, tn, FALSE, liy );
+ }
+ if ( ldy )
+ {
+ strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig );
+ }
+ else
+ {
+ plform( PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy );
+ }
+ pos = ( vpwymax > vpwymin ) ?
+ ( tn - vpwymi ) / ( vpwyma - vpwymi ) :
+ ( vpwyma - tn ) / ( vpwyma - vpwymi );
+ if ( lny )
+ {
+ if ( lvy )
{
- plwytik( vpwxmin, tn, FALSE, !liy );
- plwytik( vpwxmax, tn, FALSE, liy );
+ // Left axis with text written perpendicular to edge.
+ height = liy ? 1.0 : 0.5;
+ if ( plsc->if_boxbb )
+ {
+ // For vertical axes with text written
+ // perpendicular to edge, height of zero
+ // corresponds character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge, and
+ // that value apparently works.
+ height_mm = ( height + 0.0 ) * char_height_mm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, plsc->vppxmi /
+ plsc->xpmm - height_mm - string_length_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ // Expected offset is 0.5, but adjust to improve
+ // look of result.
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.6 * char_height_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.7 * char_height_mm );
+ }
+ else
+ {
+ plmtex( "lv", height, pos, 1.0, string );
+ }
}
- if ( ldy )
- {
- strfqsas( string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig );
- }
else
{
- plform( PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy );
- }
- pos = ( vpwymax > vpwymin ) ?
- ( tn - vpwymi ) / ( vpwyma - vpwymi ) :
- ( vpwyma - tn ) / ( vpwyma - vpwymi );
- if ( lny )
- {
- if ( lvy )
+ // Left axis with text written parallel to edge.
+ height = liy ? 1.75 : 1.5;
+ if ( plsc->if_boxbb )
{
- height = liy ? 1.0 : 0.5;
- plmtex( "lv", height, pos, 1.0, string );
+ // For vertical axes with text written
+ // parallel to edge, height of zero
+ // corresponds to character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge,
+ // However, experimentally found 0.8 gave a
+ // better looking result.
+ height_mm = ( height + 0.8 ) * char_height_mm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin, plsc->vppxmi /
+ plsc->xpmm - height_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.5 * string_length_mm );
}
else
{
- height = liy ? 1.75 : 1.5;
plmtex( "l", height, pos, 0.5, string );
}
}
- if ( lmy )
+ }
+ if ( lmy )
+ {
+ if ( lvy )
{
- if ( lvy )
+ // Right axis with text written perpendicular to edge.
+ height = liy ? 1.0 : 0.5;
+ if ( plsc->if_boxbb )
{
- height = liy ? 1.0 : 0.5;
+ // For vertical axes with text written
+ // perpendicular to edge, height of zero
+ // corresponds character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge, and
+ // that value apparently works.
+ height_mm = ( height + 0.0 ) * char_height_mm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, plsc->vppxma /
+ plsc->xpmm + height_mm + string_length_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ // Expected offset is 0.5, but adjust to improve
+ // look of result.
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.6 * char_height_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.7 * char_height_mm );
+ }
+ else
+ {
plmtex( "rv", height, pos, 0.0, string );
}
+ }
+ else
+ {
+ // Right axis with text written parallel to edge.
+ height = liy ? 1.75 : 1.5;
+ if ( plsc->if_boxbb )
+ {
+ // For vertical axes with text written
+ // parallel to edge, height of zero
+ // corresponds to character centred on edge so
+ // should add 0.5 to height to obtain bounding
+ // box edge in direction away from edge,
+ // However, experimentally found 0.8 gave a
+ // better looking result.
+ height_mm = ( height + 0.8 ) * char_height_mm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmax, plsc->vppxma /
+ plsc->xpmm + height_mm );
+ pos_mm = ( plsc->vppymi + pos *
+ ( plsc->vppyma - plsc->vppymi ) ) /
+ plsc->ypmm;
+ string_length_mm = plstrl( string );
+ plsc->boxbb_ymin = MIN( plsc->boxbb_ymin,
+ pos_mm - 0.5 * string_length_mm );
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax,
+ pos_mm + 0.5 * string_length_mm );
+ }
else
{
- height = liy ? 1.75 : 1.5;
plmtex( "r", height, pos, 0.5, string );
}
}
- ydigits = MAX( ydigits, (PLINT) strlen( string ) );
}
+ ydigits = MAX( ydigits, (PLINT) strlen( string ) );
}
- if ( !lvy )
- ydigits = 2;
+ }
+ if ( !lvy )
+ ydigits = 2;
- plsyax( ydigmax, ydigits );
+ plsyax( ydigmax, ydigits );
- // Write separate exponential label if mode = 1.
+ // Write separate exponential label if mode = 1.
- if ( !lly && !ldy && !loy && ymode )
+ if ( !lly && !ldy && !loy && ymode )
+ {
+ snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
+ if ( plsc->label_data )
{
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
- if ( plsc->label_data )
+ height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
+ pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
+ just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
+ }
+ else
+ {
+ offset = 0.02;
+ height = 2.0;
+ // Left axis exponent.
+ if ( lny )
{
- height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
- pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
- just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
+ pos = 0.0 - offset;
+ just = 1.0;
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ ...
[truncated message content] |
|
From: <ai...@us...> - 2013-03-29 00:06:01
|
Revision: 12302
http://sourceforge.net/p/plplot/code/12302
Author: airwin
Date: 2013-03-29 00:05:43 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
AWI commit of patch from Mark de Wever <m.d...@da...>
to check plsc->label_func for NULL where appropriate. I also
added a one-line comment change.
Tested by: Alan W. Irwin <ai...@us...>. This was a
light test demonstrating the PLplot library and example 19 continued
to build without issues, and by demonstrating that running example 19
with the ps device under valgrind provided valgrind-clean results.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-03-20 06:24:58 UTC (rev 12301)
+++ trunk/src/plbox.c 2013-03-29 00:05:43 UTC (rev 12302)
@@ -1509,7 +1509,7 @@
{
// Assume label data is for placement of exponents if no custom
// label function is provided.
- if ( plsc->label_data )
+ if ( !plsc->label_func && plsc->label_data )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -1751,7 +1751,7 @@
if ( !lly && !ldy && !loy && ymode )
{
snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
- if ( plsc->label_data )
+ if ( !plsc->label_func && plsc->label_data )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -2026,7 +2026,7 @@
{
// Assume label data is for placement of exponents if no custom
// label function is provided.
- if ( plsc->label_data )
+ if ( !plsc->label_func && plsc->label_data )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -2282,7 +2282,7 @@
if ( !lly && !ldy && !loy && ymode )
{
snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
- if ( plsc->label_data )
+ if ( !plsc->label_func && plsc->label_data )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
@@ -2453,6 +2453,7 @@
plform( PLINT axis, PLFLT value, PLINT scale, PLINT prec, char *string, PLINT len, PLBOOL ll, PLBOOL lf, PLBOOL lo )
{
// Check to see if a custom labeling function is defined. If not,
+ // use default.
if ( lo && plsc->label_func )
{
( *plsc->label_func )( axis, value, string, len, plsc->label_data );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <and...@us...> - 2013-06-05 06:54:54
|
Revision: 12368
http://sourceforge.net/p/plplot/code/12368
Author: andrewross
Date: 2013-06-05 06:54:51 +0000 (Wed, 05 Jun 2013)
Log Message:
-----------
Apply fix from Steve Schwartz for mis-alignment of the major axes and grid with time axis ("d" option).
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-06-05 01:52:14 UTC (rev 12367)
+++ trunk/src/plbox.c 2013-06-05 06:54:51 UTC (rev 12368)
@@ -455,7 +455,7 @@
if ( ldy )
{
pldtfac( vpwymi, vpwyma, &factor, &tstart );
- tp = ytick1 * ( floor( ( vpwymi - tstart ) / ytick1 ) + 1 ) + tstart;
+ tp = ytick1 * ( floor( ( vpwyma - tstart ) / ytick1 ) + 1 ) + tstart;
}
else
tp = ytick1 * ( floor( vpwyma / ytick1 ) + 1 );
@@ -1259,11 +1259,12 @@
grid_box( const char *xopt, PLFLT xtick1, PLINT nxsub1,
const char *yopt, PLFLT ytick1, PLINT nysub1 )
{
- PLINT lgx, lhx, llx;
- PLINT lgy, lhy, lly;
+ PLINT lgx, lhx, llx, ldx;
+ PLINT lgy, lhy, lly, ldy;
PLFLT vpwxmi, vpwxma, vpwymi, vpwyma;
PLFLT vpwxmin, vpwxmax, vpwymin, vpwymax;
PLFLT tn, temp, tcrit, tspace = 0.1;
+ PLFLT tstart, factor;
PLINT i;
// Set plot options from input
@@ -1271,10 +1272,12 @@
lgx = plP_stsearch( xopt, 'g' );
lhx = plP_stsearch( xopt, 'h' );
llx = plP_stsearch( xopt, 'l' );
+ ldx = plP_stsearch( xopt, 'd' );
lgy = plP_stsearch( yopt, 'g' );
lhy = plP_stsearch( yopt, 'h' );
lly = plP_stsearch( yopt, 'l' );
+ ldy = plP_stsearch( yopt, 'd' );
plP_xgvpw( &vpwxmin, &vpwxmax, &vpwymin, &vpwymax );
// n.b. large change; vpwxmi always numerically less than vpwxma, and
@@ -1288,8 +1291,16 @@
if ( lgx )
{
- for ( tn = xtick1 * floor( vpwxmi / xtick1 );
- tn <= vpwxma; tn += xtick1 )
+ if ( ldx )
+ {
+ pldtfac( vpwxmi, vpwxma, &factor, &tstart);
+ tn = xtick1*( floor((vpwxmi-tstart )/xtick1 )) + tstart;
+ }
+ else
+ {
+ tn = xtick1*floor( vpwxmi / xtick1 );
+ }
+ for ( ; tn <= vpwxma; tn += xtick1 )
{
if ( lhx )
{
@@ -1326,9 +1337,16 @@
if ( lgy )
{
- tn = ytick1 * floor( vpwymi / ytick1 + tspace );
- for ( tn = ytick1 * floor( vpwymi / ytick1 );
- tn <= vpwyma; tn += ytick1 )
+ if ( ldy )
+ {
+ pldtfac( vpwymi, vpwyma, &factor, &tstart);
+ tn = ytick1*( floor((vpwymi-tstart )/ytick1 )) + tstart;
+ }
+ else
+ {
+ tn = ytick1*floor( vpwymi / ytick1 );
+ }
+ for ( ; tn <= vpwyma; tn += ytick1 )
{
if ( lhy )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <and...@us...> - 2013-06-06 21:32:52
|
Revision: 12371
http://sourceforge.net/p/plplot/code/12371
Author: andrewross
Date: 2013-06-06 21:32:48 +0000 (Thu, 06 Jun 2013)
Log Message:
-----------
Commit patch from Steve Schwartz to fix several bugs in placement of exponential labels.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-06-06 20:05:05 UTC (rev 12370)
+++ trunk/src/plbox.c 2013-06-06 21:32:48 UTC (rev 12371)
@@ -1776,64 +1776,89 @@
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
}
- else
- {
- offset = 0.02;
- height = 2.0;
- // Left axis exponent
- if ( lny )
- {
- pos = 0.0 - offset;
- just = 1.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
+ if ( lvy )
+ {
+ offset = 0.1; // more space to clear labels in "v" mode
+ }
+ else
+ {
+ offset = 0.02;
+ }
+ // Left axis exponent
+ if ( lny )
+ {
+ if (!plsc->label_data)
+ {
+ height = 3.2;
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "lv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "l", height, pos, just, string );
+ }
+ }
+ }
+ // Right axis exponent.
+ if ( lmy )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.4; // Extra space for superscript
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "rv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "r", height, pos, just, string );
+ }
}
- // Right axis exponent.
- if ( lmy )
- {
- pos = 1.0 + offset;
- just = 0.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
- }
}
}
}
@@ -2307,63 +2332,88 @@
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
}
- else
- {
- offset = 0.02;
- height = 2.0;
- // Left axis exponent.
- if ( lny )
- {
- pos = 0.0 - offset;
- just = 1.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
+ if ( lvy )
+ {
+ offset = 0.1; // more space to clear labels in "v" mode
+ }
+ else
+ {
+ offset = 0.02;
+ }
+ // Left axis exponent.
+ if ( lny )
+ {
+ if (!plsc->label_data)
+ {
+ height = 3.2;
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "lv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "l", height, pos, just, string );
}
- else
- {
- plmtex( "t", height, pos, just, string );
- }
}
- // Right axis exponent.
- if ( lmy )
- {
- pos = 1.0 + offset;
- just = 0.0;
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
- }
- else
- {
- plmtex( "t", height, pos, just, string );
- }
+ }
+ // Right axis exponent.
+ if ( lmy )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.4; // Extra space for superscript
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "rv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "r", height, pos, just, string );
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <and...@us...> - 2013-06-06 21:44:57
|
Revision: 12373
http://sourceforge.net/p/plplot/code/12373
Author: andrewross
Date: 2013-06-06 21:44:55 +0000 (Thu, 06 Jun 2013)
Log Message:
-----------
Style recent changes.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-06-06 21:44:33 UTC (rev 12372)
+++ trunk/src/plbox.c 2013-06-06 21:44:55 UTC (rev 12373)
@@ -1292,16 +1292,16 @@
if ( lgx )
{
if ( ldx )
- {
- pldtfac( vpwxmi, vpwxma, &factor, &tstart);
- tn = xtick1*( floor((vpwxmi-tstart )/xtick1 )) + tstart;
- }
- else
- {
- tn = xtick1*floor( vpwxmi / xtick1 );
- }
- for ( ; tn <= vpwxma; tn += xtick1 )
{
+ pldtfac( vpwxmi, vpwxma, &factor, &tstart );
+ tn = xtick1 * ( floor( ( vpwxmi - tstart ) / xtick1 ) ) + tstart;
+ }
+ else
+ {
+ tn = xtick1 * floor( vpwxmi / xtick1 );
+ }
+ for (; tn <= vpwxma; tn += xtick1 )
+ {
if ( lhx )
{
if ( llx )
@@ -1338,16 +1338,16 @@
if ( lgy )
{
if ( ldy )
- {
- pldtfac( vpwymi, vpwyma, &factor, &tstart);
- tn = ytick1*( floor((vpwymi-tstart )/ytick1 )) + tstart;
- }
- else
- {
- tn = ytick1*floor( vpwymi / ytick1 );
- }
- for ( ; tn <= vpwyma; tn += ytick1 )
{
+ pldtfac( vpwymi, vpwyma, &factor, &tstart );
+ tn = ytick1 * ( floor( ( vpwymi - tstart ) / ytick1 ) ) + tstart;
+ }
+ else
+ {
+ tn = ytick1 * floor( vpwymi / ytick1 );
+ }
+ for (; tn <= vpwyma; tn += ytick1 )
+ {
if ( lhy )
{
if ( lly )
@@ -1776,90 +1776,90 @@
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
}
- if ( lvy )
- {
- offset = 0.1; // more space to clear labels in "v" mode
- }
- else
- {
- offset = 0.02;
- }
- // Left axis exponent
- if ( lny )
- {
- if (!plsc->label_data)
- {
- height = 3.2;
- pos = 1.0 + offset;
- just = 0.5;
- }
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
- }
- else
- {
- if ( lvy )
- {
- plmtex( "lv", height, pos, just, string );
- }
- else
- {
- plmtex( "l", height, pos, just, string );
- }
- }
- }
- // Right axis exponent.
- if ( lmy )
- {
- if ( !plsc->label_data )
- {
- height = 3.4; // Extra space for superscript
- pos = 1.0 + offset;
- just = 0.5;
- }
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
- }
- else
- {
- if ( lvy )
- {
- plmtex( "rv", height, pos, just, string );
- }
- else
- {
- plmtex( "r", height, pos, just, string );
- }
+ if ( lvy )
+ {
+ offset = 0.1; // more space to clear labels in "v" mode
+ }
+ else
+ {
+ offset = 0.02;
+ }
+ // Left axis exponent
+ if ( lny )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.2;
+ pos = 1.0 + offset;
+ just = 0.5;
}
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "lv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "l", height, pos, just, string );
+ }
+ }
}
+ // Right axis exponent.
+ if ( lmy )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.4; // Extra space for superscript
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "rv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "r", height, pos, just, string );
+ }
+ }
+ }
}
}
}
@@ -2332,89 +2332,89 @@
pos = ( (PLLabelDefaults *) plsc->label_data )->exp_label_pos;
just = ( (PLLabelDefaults *) plsc->label_data )->exp_label_just;
}
- if ( lvy )
- {
- offset = 0.1; // more space to clear labels in "v" mode
- }
- else
- {
- offset = 0.02;
- }
- // Left axis exponent.
- if ( lny )
- {
- if (!plsc->label_data)
- {
- height = 3.2;
- pos = 1.0 + offset;
- just = 0.5;
- }
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
- pos_mm - string_length_mm );
- }
- else
- {
- if ( lvy )
- {
- plmtex( "lv", height, pos, just, string );
- }
- else
- {
- plmtex( "l", height, pos, just, string );
+ if ( lvy )
+ {
+ offset = 0.1; // more space to clear labels in "v" mode
+ }
+ else
+ {
+ offset = 0.02;
+ }
+ // Left axis exponent.
+ if ( lny )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.2;
+ pos = 1.0 + offset;
+ just = 0.5;
+ }
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmin = MIN( plsc->boxbb_xmin,
+ pos_mm - string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "lv", height, pos, just, string );
}
+ else
+ {
+ plmtex( "l", height, pos, just, string );
+ }
}
- }
- // Right axis exponent.
- if ( lmy )
- {
- if ( !plsc->label_data )
- {
- height = 3.4; // Extra space for superscript
- pos = 1.0 + offset;
- just = 0.5;
- }
- if ( plsc->if_boxbb )
- {
- // For horizontal axes, height of zero corresponds
- // to character centred on edge so should add 0.5
- // to height to obtain bounding box edge in
- // direction away from edge if no exponent. Add
- // an additional offset to make exponent fit.
- height_mm = ( height + 1.4 ) * char_height_mm;
- plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
- plsc->ypmm + height_mm );
- string_length_mm = plstrl( string );
- pos_mm = ( plsc->vppxmi + pos *
- ( plsc->vppxma - plsc->vppxmi ) ) /
- plsc->xpmm;
- plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
- pos_mm + string_length_mm );
- }
- else
- {
- if ( lvy )
- {
- plmtex( "rv", height, pos, just, string );
- }
- else
- {
- plmtex( "r", height, pos, just, string );
- }
+ }
+ // Right axis exponent.
+ if ( lmy )
+ {
+ if ( !plsc->label_data )
+ {
+ height = 3.4; // Extra space for superscript
+ pos = 1.0 + offset;
+ just = 0.5;
}
+ if ( plsc->if_boxbb )
+ {
+ // For horizontal axes, height of zero corresponds
+ // to character centred on edge so should add 0.5
+ // to height to obtain bounding box edge in
+ // direction away from edge if no exponent. Add
+ // an additional offset to make exponent fit.
+ height_mm = ( height + 1.4 ) * char_height_mm;
+ plsc->boxbb_ymax = MAX( plsc->boxbb_ymax, plsc->vppyma /
+ plsc->ypmm + height_mm );
+ string_length_mm = plstrl( string );
+ pos_mm = ( plsc->vppxmi + pos *
+ ( plsc->vppxma - plsc->vppxmi ) ) /
+ plsc->xpmm;
+ plsc->boxbb_xmax = MAX( plsc->boxbb_xmin,
+ pos_mm + string_length_mm );
+ }
+ else
+ {
+ if ( lvy )
+ {
+ plmtex( "rv", height, pos, just, string );
+ }
+ else
+ {
+ plmtex( "r", height, pos, just, string );
+ }
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2013-11-16 07:25:11
|
Revision: 12705
http://sourceforge.net/p/plplot/code/12705
Author: airwin
Date: 2013-11-16 07:24:58 +0000 (Sat, 16 Nov 2013)
Log Message:
-----------
Several different functions in plbox incorrectly assume that the
PLplot string escape character is '#'. Fix that assumption by
implementing a small static function that returns the string (not
integer code) corresponding to the current escape character, and use
that instead.
(Lightly) tested by: Alan W. Irwin <ai...@us...> on Linux
by running a run-time test where
plsesc( '@');
was called in example 1 and showing that no longer interfered with
the exponent used on the viewport Y label axis for one of the
plots.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-11-16 01:36:52 UTC (rev 12704)
+++ trunk/src/plbox.c 2013-11-16 07:24:58 UTC (rev 12705)
@@ -74,6 +74,9 @@
static void
plP_default_label( PLINT axis, PLFLT value, char *string, PLINT len, void *data );
+static const char *
+plgesc_string( void );
+
//--------------------------------------------------------------------------
// void plbox()
//
@@ -793,7 +796,8 @@
PLFLT pos, tn, tp, temp, height, tick1, vmin, vmax;
// Note that 'tspace' is the minimim distance away (in fractional number
// of ticks) from the boundary that an X or Y numerical label can be drawn.
- PLFLT dwx, dwy, lambda, tcrit, tspace = 0.1;
+ PLFLT dwx, dwy, lambda, tcrit, tspace = 0.1;
+ const char * esc_string = plgesc_string();
vmin = ( vmax_in > vmin_in ) ? vmin_in : vmax_in;
vmax = ( vmax_in > vmin_in ) ? vmax_in : vmin_in;
@@ -927,7 +931,7 @@
*digits = 2;
if ( !ll && !lo && mode )
{
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) scale );
+ snprintf( string, STRING_LEN, "(x10%su%d%sd)", esc_string, (int) scale, esc_string );
plxytx( wx1, wy1, wx2, wy2, height, 1.0, 0.5, string );
}
}
@@ -1020,6 +1024,7 @@
PLFLT pos, tn, tp, temp, height, tick1;
PLFLT dwy, lambda, diag, major, minor, xmajor, xminor;
PLFLT ymajor, yminor, dxm, dym, vmin, vmax;
+ const char * esc_string = plgesc_string();
vmin = ( vmax_in > vmin_in ) ? vmin_in : vmax_in;
vmax = ( vmax_in > vmin_in ) ? vmax_in : vmin_in;
@@ -1163,7 +1168,7 @@
}
if ( !ll && !lo && mode )
{
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) scale );
+ snprintf( string, STRING_LEN, "(x10%su%d%sd)", esc_string, (int) scale, esc_string );
pos = 1.15;
height = 0.5;
if ( ln && !right )
@@ -1408,7 +1413,8 @@
// -O3 -Wuninitialized warnings that are obvious false alarms from
// the clarity of the code associated with the true or false
// result for custom_exponent_placement.
- PLFLT pos = 0.0, height = 0.0, just = 0.0;
+ PLFLT pos = 0.0, height = 0.0, just = 0.0;
+ const char * esc_string = plgesc_string();
plgchr( &default_mm, &char_height_mm );
@@ -1548,7 +1554,7 @@
pos = 1.0;
just = 0.5;
}
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale );
+ snprintf( string, STRING_LEN, "(x10%su%d%sd)", esc_string, (int) xscale, esc_string );
if ( lnx )
{
// Bottom axis exponent.
@@ -1777,7 +1783,7 @@
if ( !lly && !ldy && !loy && ymode )
{
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
+ snprintf( string, STRING_LEN, "(x10%su%d%sd)", esc_string, (int) yscale, esc_string );
if ( custom_exponent_placement )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
@@ -1904,7 +1910,8 @@
// -O3 -Wuninitialized warnings that are obvious false alarms from
// the clarity of the code associated with the true or false
// result for custom_exponent_placement.
- PLFLT pos = 0.0, height = 0.0, just = 0.0;
+ PLFLT pos = 0.0, height = 0.0, just = 0.0;
+ const char * esc_string = plgesc_string();
plgchr( &default_mm, &char_height_mm );
@@ -2098,7 +2105,7 @@
pos = 1.0;
just = 0.5;
}
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) xscale );
+ snprintf( string, STRING_LEN, "(x10%su%d%sd)", esc_string, (int) xscale, esc_string );
if ( lnx )
{
// Bottom axis exponent.
@@ -2341,7 +2348,7 @@
if ( !lly && !ldy && !loy && ymode )
{
- snprintf( string, STRING_LEN, "(x10#u%d#d)", (int) yscale );
+ snprintf( string, STRING_LEN, "(x10%su%d%sd)", esc_string, (int) yscale, esc_string );
if ( custom_exponent_placement )
{
height = ( (PLLabelDefaults *) plsc->label_data )->exp_label_disp;
@@ -2456,8 +2463,9 @@
//--------------------------------------------------------------------------
void plP_default_label_log( PLINT PL_UNUSED( axis ), PLFLT value, char *string, PLINT len, void * PL_UNUSED( data ) )
{
+ const char * esc_string = plgesc_string();
// Exponential, i.e. 10^-1, 10^0, 10^1, etc
- snprintf( string, (size_t) len, "10#u%d", (int) ROUND( value ) );
+ snprintf( string, (size_t) len, "10%su%d", esc_string, (int) ROUND( value ) );
}
void plP_default_label_log_fixed( PLINT PL_UNUSED( axis ), PLFLT value, char *string, PLINT len, void * PL_UNUSED( data ) )
@@ -2602,3 +2610,45 @@
plsc->label_func = label_func;
plsc->label_data = label_data;
}
+
+static const char *
+plgesc_string( void )
+{
+ static const char *esc_strings = { "!\0#\0$\0%\0&\0*\0@\0^\0~\0" };
+ int d;
+ switch ( plsc->esc )
+ {
+ case '!':
+ d = 0;
+ break;
+ case '#':
+ d = 1;
+ break;
+ case '$':
+ d = 2;
+ break;
+ case '%':
+ d = 3;
+ break;
+ case '&':
+ d = 4;
+ break;
+ case '*':
+ d = 5;
+ break;
+ case '@':
+ d = 6;
+ break;
+ case '^':
+ d = 7;
+ break;
+ case '~':
+ d = 8;
+ break;
+ default:
+ plwarn( "plgesc_string: Invalid escape character, assuming '#' instead" );
+ d = 1;
+ break;
+ }
+ return &( esc_strings[d * 2] );
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2013-11-16 19:15:21
|
Revision: 12706
http://sourceforge.net/p/plplot/code/12706
Author: airwin
Date: 2013-11-16 19:15:17 +0000 (Sat, 16 Nov 2013)
Log Message:
-----------
In plgesc_string, follow plgesc logic which is to set the default escape
if plsc->esc is in its initial state. This change gets rid of lots of
plgesc_string warning messages about plsc->esc being invalid.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2013-11-16 07:24:58 UTC (rev 12705)
+++ trunk/src/plbox.c 2013-11-16 19:15:17 UTC (rev 12706)
@@ -2616,6 +2616,11 @@
{
static const char *esc_strings = { "!\0#\0$\0%\0&\0*\0@\0^\0~\0" };
int d;
+ // Follow plgesc logic here which is to set the default escape
+ // if plsc->esc is in its initial state.
+ if ( plsc->esc == '\0' )
+ plsc->esc = '#';
+
switch ( plsc->esc )
{
case '!':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ai...@us...> - 2014-04-07 21:43:21
|
Revision: 13099
http://sourceforge.net/p/plplot/code/13099
Author: airwin
Date: 2014-04-07 21:43:17 +0000 (Mon, 07 Apr 2014)
Log Message:
-----------
Fix an integer overflow by only calculating physical coordinates of
the origin of the axes when those additional axes are actually used
(i.e., when the "a" option is specified and the drawn axis is
going to be inside the viewport).
This fix solves an integer overflow issue discovered by Hazen for page
5 and larger for example 29 where the 0., 0., world coordinates of the
unused axes generated with plbox were so far from the actual X
world-coordinate range of the plot that integer overflow occurred when
calculating the unused physical coordinates corresponding the the
0.,0., world coordinates of the axes origin.
Modified Paths:
--------------
trunk/src/plbox.c
Modified: trunk/src/plbox.c
===================================================================
--- trunk/src/plbox.c 2014-04-06 19:41:22 UTC (rev 13098)
+++ trunk/src/plbox.c 2014-04-07 21:43:17 UTC (rev 13099)
@@ -176,11 +176,6 @@
plsc->boxbb_ymax = plsc->vppyma / plsc->ypmm;
}
-// Convert world coordinates to physical
-
- xp0 = plP_wcpcx( x0 );
- yp0 = plP_wcpcy( y0 );
-
// Set plot options from input
lax = plP_stsearch( xopt, 'a' );
@@ -495,6 +490,8 @@
// Draw the horizontal axis.
if ( lax )
{
+ // Convert world coordinates to physical
+ yp0 = plP_wcpcy( y0 );
plP_movphy( vppxmi, (PLINT) yp0 );
plP_draphy( vppxma, (PLINT) yp0 );
if ( ltx && !lxx )
@@ -535,6 +532,8 @@
// Draw the vertical axis.
if ( lay )
{
+ // Convert world coordinates to physical
+ xp0 = plP_wcpcx( x0 );
plP_movphy( (PLINT) xp0, vppymi );
plP_draphy( (PLINT) xp0, vppyma );
if ( lty && !lxy )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|