comparison src/graphics.cc @ 8560:5cc594679cdc

get display characteristics from system
author John W. Eaton <jwe@octave.org>
date Wed, 21 Jan 2009 21:43:05 -0500
parents ab82e19002c4
children b4fb0a52b15e
comparison
equal deleted inserted replaced
8559:07c93dae3fdb 8560:5cc594679cdc
38 #include "file-ops.h" 38 #include "file-ops.h"
39 #include "file-stat.h" 39 #include "file-stat.h"
40 40
41 #include "cmd-edit.h" 41 #include "cmd-edit.h"
42 #include "defun.h" 42 #include "defun.h"
43 #include "display.h"
43 #include "error.h" 44 #include "error.h"
44 #include "graphics.h" 45 #include "graphics.h"
45 #include "input.h" 46 #include "input.h"
46 #include "ov.h" 47 #include "ov.h"
47 #include "oct-obj.h" 48 #include "oct-obj.h"
94 else if (x >= 3.0/8.0 && x < 5.0/8.0) 95 else if (x >= 3.0/8.0 && x < 5.0/8.0)
95 cmap(i,2) = -4.0 * x + 5.0/2.0; 96 cmap(i,2) = -4.0 * x + 5.0/2.0;
96 } 97 }
97 98
98 return cmap; 99 return cmap;
100 }
101
102 static double
103 default_screendepth (void)
104 {
105 return display_info::depth ();
106 }
107
108 static Matrix
109 default_screensize (void)
110 {
111 Matrix retval (1, 4, 1.0);
112
113 retval(2) = display_info::width ();
114 retval(3) = display_info::height ();
115
116 return retval;
117 }
118
119 static double
120 default_screenpixelsperinch (void)
121 {
122 return (display_info::x_dpi () + display_info::y_dpi ()) / 2;
99 } 123 }
100 124
101 static Matrix 125 static Matrix
102 default_colororder (void) 126 default_colororder (void)
103 { 127 {
2008 2032
2009 callbackobject = val; 2033 callbackobject = val;
2010 } 2034 }
2011 else 2035 else
2012 gripe_set_invalid ("callbackobject"); 2036 gripe_set_invalid ("callbackobject");
2037 }
2038
2039 void
2040 root_figure::properties::update_units (void)
2041 {
2042 caseless_str xunits = get_units ();
2043
2044 Matrix ss = default_screensize ();
2045
2046 double dpi = get_screenpixelsperinch ();
2047
2048 if (xunits.compare ("inches"))
2049 {
2050 ss(0) = 0;
2051 ss(1) = 0;
2052 ss(2) /= dpi;
2053 ss(3) /= dpi;
2054 }
2055 else if (xunits.compare ("centimeters"))
2056 {
2057 ss(0) = 0;
2058 ss(1) = 0;
2059 ss(2) *= 2.54 / dpi;
2060 ss(3) *= 2.54 / dpi;
2061 }
2062 else if (xunits.compare ("normalized"))
2063 {
2064 ss = Matrix (1, 4, 1.0);
2065 }
2066 else if (xunits.compare ("points"))
2067 {
2068 ss(0) = 0;
2069 ss(1) = 0;
2070 ss(2) *= 72 / dpi;
2071 ss(3) *= 72 / dpi;
2072 }
2073
2074 set_screensize (ss);
2013 } 2075 }
2014 2076
2015 void 2077 void
2016 root_figure::properties::remove_child (const graphics_handle& gh) 2078 root_figure::properties::remove_child (const graphics_handle& gh)
2017 { 2079 {