Mercurial > hg > octave-nkf
changeset 14498:36cfbd23fe9f
Fix papersize updater. Bug # 35908.
* grpahics.cc (figure::properities::update_papersize): Save papersize in
proper units. Add tests.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Mon, 26 Mar 2012 17:37:56 -0400 |
parents | 9fc75cdf61ab |
children | f6eb8337d077 60e5cf354d80 |
files | src/graphics.cc |
diffstat | 1 files changed, 37 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -3585,8 +3585,8 @@ } else if (punits == "points") { - sz(0) = 72.0; - sz(1) = 72.0; + sz(0) /= 72.0; + sz(1) /= 72.0; } if (punits == "normalized") { @@ -3656,6 +3656,16 @@ // update_papersize and update_papertype papertype.set (typ); } + if (punits == "centimeters") + { + sz(0) *= 2.54; + sz(1) *= 2.54; + } + else if (punits == "points") + { + sz(0) *= 72.0; + sz(1) *= 72.0; + } if (get_paperorientation () == "landscape") { std::swap (sz(0), sz(1)); @@ -3663,6 +3673,31 @@ } } +/* +%!test +%! figure (1, "visible", "off"); +%! set (1, "paperunits", "inches"); +%! set (1, "papersize", [5, 4]) +%! set (1, "paperunits", "points"); +%! assert (get (1, "papersize"), [5, 4] * 72, 1) +%! papersize = get (gcf, "papersize"); +%! set (1, "papersize", papersize + 1); +%! set (1, "papersize", papersize) +%! assert (get (1, "papersize"), [5, 4] * 72, 1) +%! close (1) +%!test +%! figure (1, "visible", "off"); +%! set (1, "paperunits", "inches"); +%! set (1, "papersize", [5, 4]) +%! set (1, "paperunits", "centimeters"); +%! assert (get (1, "papersize"), [5, 4] * 2.54, 2.54/72) +%! papersize = get (gcf, "papersize"); +%! set (1, "papersize", papersize + 1); +%! set (1, "papersize", papersize) +%! assert (get (1, "papersize"), [5, 4] * 2.54, 2.54/72) +%! close (1) +*/ + void figure::properties::update_paperorientation (void) {