Mercurial > hg > octave-terminal
changeset 8599:b4fb0a52b15e
Improve default property compatibility.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 27 Jan 2009 07:20:58 -0500 |
parents | 11cf7bc4a871 |
children | a6c1aa6f5915 |
files | src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 75 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2009-01-27 Ben Abbott <bpabbott@mac.com> + + * graphics.cc (convert_position): Handle character units. + (default_axes_tick, default_figure_papersize, + default_figure_paperposition): New functions. + * graphics.h.in (class figure::properties): Use them to + initialize papersize, paperposition, xtick, ytick, and ztick + properties. + 2009-01-27 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/qr.cc (Fqr): Treat empty matrices correctly.
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -188,6 +188,19 @@ } static Matrix +default_axes_tick (void) +{ + Matrix m (1, 6, 0.0); + m(0) = 0.0; + m(1) = 0.2; + m(2) = 0.4; + m(3) = 0.6; + m(4) = 0.8; + m(5) = 1.0; + return m; +} + +static Matrix default_figure_position (void) { Matrix m (1, 4, 0.0); @@ -199,6 +212,26 @@ } static Matrix +default_figure_papersize (void) +{ + Matrix m (1, 2, 0.0); + m(0) = 8.5; + m(1) = 11.5; + return m; +} + +static Matrix +default_figure_paperposition (void) +{ + Matrix m (1, 4, 0.0); + m(0) = 0.25; + m(1) = 2.50; + m(2) = 8.00; + m(3) = 6.00; + return m; +} + +static Matrix convert_position (const Matrix& pos, const caseless_str& from_units, const caseless_str& to_units, const Matrix& parent_dim = Matrix (1, 2, 0.0), @@ -218,7 +251,21 @@ } else if (from_units.compare ("characters")) { - // FIXME -- implement this. + res = backend.get_screen_resolution (); + + double f = 0.0; + + // FIXME -- this assumes the system font is Helvetica 10pt + // (for which "x" requires 6x12 pixels at 74.951 pixels/inch) + f = 12.0 * res / 74.951; + + if (f > 0) + { + retval(0) = 0.5 * pos(0) * f; + retval(1) = pos(1) * f; + retval(2) = 0.5 * pos(2) * f; + retval(3) = pos(3) * f; + } } else { @@ -253,7 +300,19 @@ } else if (to_units.compare ("characters")) { - // FIXME -- implement this. + res = backend.get_screen_resolution (); + + double f = 0.0; + + f = 12.0 * res / 74.951; + + if (f > 0) + { + retval(0) = 2 * retval(0) / f; + retval(1) = retval(1) / f; + retval(2) = 2 * retval(2) / f; + retval(3) = retval(3) / f; + } } else {
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -2353,9 +2353,9 @@ string_property name , "" bool_property numbertitle , "on" radio_property paperunits , "{inches}|centimeters|normalized|points" - array_property paperposition , Matrix (1, 4 , 0) + array_property paperposition , default_figure_paperposition () radio_property paperpositionmode , "auto|{manual}" - array_property papersize , Matrix (1, 2, 0) + array_property papersize , default_figure_papersize () radio_property papertype , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid|<custom>" radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand" array_property pointershapecdata , Matrix (16, 16, 0) @@ -2641,9 +2641,9 @@ bool_property xminorgrid , "off" bool_property yminorgrid , "off" bool_property zminorgrid , "off" - row_vector_property xtick m , Matrix () - row_vector_property ytick m , Matrix () - row_vector_property ztick m , Matrix () + row_vector_property xtick m , default_axes_tick () + row_vector_property ytick m , default_axes_tick () + row_vector_property ztick m , default_axes_tick () radio_property xtickmode , "{auto}|manual" radio_property ytickmode , "{auto}|manual" radio_property ztickmode , "{auto}|manual"