X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctgraphics%2Fezplot.cpp;fp=libctgraphics%2Fezplot.cpp;h=eab8cc37bebda290d0428b3b64a9a5ca98ab66e2;hp=8c385e057cd6c73f46b4b4fd33e3d2852051b6d9;hb=fd726516dd11fd37a675a94c1e7165c47d793b34;hpb=5ec5449357eaae253d6b1026621262480e2efa63 diff --git a/libctgraphics/ezplot.cpp b/libctgraphics/ezplot.cpp index 8c385e0..eab8cc3 100644 --- a/libctgraphics/ezplot.cpp +++ b/libctgraphics/ezplot.cpp @@ -6,7 +6,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ezplot.cpp,v 1.22 2000/12/25 21:54:26 kevin Exp $ +** $Id: ezplot.cpp,v 1.23 2000/12/26 21:13:15 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -441,8 +441,8 @@ EZPlot::plot () // adjust frame for title title_row = ya_max;; if (c_title.length() > 0) - ya_max -= 2 * charheight; - + ya_max -= 2 * charheight; + // calculate legend box boundaries int max_leg = 0; // longest legend in characters int num_leg = 0; // number of legend titles @@ -521,12 +521,19 @@ EZPlot::plot () // X-Label if (c_xlabel.length() > 0) - ya_min += 2.0 * charheight; + ya_min += 1.5 * charheight; xlbl_row = xp_min; // put x-label on bottom of plot frame // Y-Label - if (c_ylabel.length() > 0) - xa_min += 2.0 * charheight; + if (c_ylabel.length() > 0) { + rSGP.setTextAngle (HALFPI); + rSGP.setTextSize (1.5 * charheight); + double xExtent, yExtent; + rSGP.getTextExtent (c_ylabel.c_str(), &xExtent, &yExtent); + rSGP.setTextSize (charheight); + xa_min += xExtent; + rSGP.setTextAngle (0.0); + } ylbl_col = xp_min; /*------------------------------*/ @@ -776,9 +783,11 @@ EZPlot::drawAxes() rSGP.lineAbs (xt_min + xn_tickinc * i, ya_min); } } - rSGP.moveAbs (xa_min + (xa_max-xa_min)/2 - c_xlabel.length()*charwidth * 1.5, xlbl_row + charheight * 1.5); rSGP.setTextSize (charheight * 1.5); - rSGP.setTextColor (clr_label, -1); + rSGP.setTextColor (clr_label, -1); + double wText, hText; + rSGP.getTextExtent (c_xlabel.c_str(), &wText, &hText); + rSGP.moveAbs (xa_min + (xa_max-xa_min)/2 - wText / 2, xlbl_row + charheight * 1.5); rSGP.drawText (c_xlabel); rSGP.setTextSize (charheight); minorinc = xn_tickinc / (o_xminortick + 1); @@ -842,19 +851,13 @@ EZPlot::drawAxes() rSGP.lineAbs (xa_min, y); } } -#if 0 - rSGP.moveAbs(.5,.5); - char s[128]; - snprintf(s,sizeof(s),"%f, %f",charwidth, charheight); - rSGP.drawText(s); -#endif rSGP.setTextAngle (HALFPI); rSGP.setTextSize (1.5 * charheight); rSGP.setTextColor (clr_label, -1); double xExtent, yExtent; rSGP.getTextExtent (c_ylabel.c_str(), &xExtent, &yExtent); - rSGP.moveAbs (ylbl_col, ya_min + (ya_max-ya_min)/2 - yExtent); - rSGP.drawText (c_ylabel); + rSGP.moveAbs (ylbl_col, ya_min + (ya_max-ya_min)/2 - yExtent / 2); + rSGP.drawText (c_ylabel); rSGP.setTextAngle (0.0); rSGP.setTextSize (charheight); minorinc = yn_tickinc / (o_yminortick + 1);