Mercurial > hg > octave-lojdl
changeset 14266:37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
* graphics.cc: Set correct value for screensize when units are normalized.
Add tests.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 24 Jan 2012 20:52:12 -0500 |
parents | 284656167c25 |
children | 527ed2a51d54 |
files | src/graphics.cc |
diffstat | 1 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -3029,6 +3029,8 @@ else if (xunits.compare ("normalized")) { ss = Matrix (1, 4, 1.0); + ss(0) = 0; + ss(1) = 0; } else if (xunits.compare ("points")) { @@ -3041,6 +3043,23 @@ set_screensize (ss); } +/* +%!test +%! set (0, "units", "pixels") +%! sz = get (0, "screensize") - [1, 1, 0, 0]; +%! dpi = get (0, "screenpixelsperinch"); +%! set (0, "units", "inches") +%! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi) +%! set (0, "units", "centimeters") +%! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54) +%! set (0, "units", "points") +%! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72) +%! set (0, "units", "normalized") +%! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]) +%! set (0, "units", "pixels") +%! assert (get (0, "screensize"), sz + [1, 1, 0, 0]) +*/ + void root_figure::properties::remove_child (const graphics_handle& gh) { @@ -3686,6 +3705,17 @@ get_units (), screen_size_pixels ())); } +/* +%!test +%! figure (1, "visible", false) +%! set (0, "units", "pixels") +%! rsz = get (0, "screensize"); +%! set (gcf (), "units", "pixels") +%! fsz = get (gcf (), "position"); +%! set (gcf (), "units", "normalized") +%! assert (get (gcf (), "position"), (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4])) +*/ + std::string figure::properties::get_title (void) const {