Mercurial > octave-nkf
comparison src/graphics.cc @ 8599:b4fb0a52b15e
Improve default property compatibility.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 27 Jan 2009 07:20:58 -0500 |
parents | 5cc594679cdc |
children | ee70d438a5b4 |
comparison
equal
deleted
inserted
replaced
8598:11cf7bc4a871 | 8599:b4fb0a52b15e |
---|---|
186 m(2) = m(3) = 1.0; | 186 m(2) = m(3) = 1.0; |
187 return m; | 187 return m; |
188 } | 188 } |
189 | 189 |
190 static Matrix | 190 static Matrix |
191 default_axes_tick (void) | |
192 { | |
193 Matrix m (1, 6, 0.0); | |
194 m(0) = 0.0; | |
195 m(1) = 0.2; | |
196 m(2) = 0.4; | |
197 m(3) = 0.6; | |
198 m(4) = 0.8; | |
199 m(5) = 1.0; | |
200 return m; | |
201 } | |
202 | |
203 static Matrix | |
191 default_figure_position (void) | 204 default_figure_position (void) |
192 { | 205 { |
193 Matrix m (1, 4, 0.0); | 206 Matrix m (1, 4, 0.0); |
194 m(0) = 300; | 207 m(0) = 300; |
195 m(1) = 200; | 208 m(1) = 200; |
197 m(3) = 420; | 210 m(3) = 420; |
198 return m; | 211 return m; |
199 } | 212 } |
200 | 213 |
201 static Matrix | 214 static Matrix |
215 default_figure_papersize (void) | |
216 { | |
217 Matrix m (1, 2, 0.0); | |
218 m(0) = 8.5; | |
219 m(1) = 11.5; | |
220 return m; | |
221 } | |
222 | |
223 static Matrix | |
224 default_figure_paperposition (void) | |
225 { | |
226 Matrix m (1, 4, 0.0); | |
227 m(0) = 0.25; | |
228 m(1) = 2.50; | |
229 m(2) = 8.00; | |
230 m(3) = 6.00; | |
231 return m; | |
232 } | |
233 | |
234 static Matrix | |
202 convert_position (const Matrix& pos, const caseless_str& from_units, | 235 convert_position (const Matrix& pos, const caseless_str& from_units, |
203 const caseless_str& to_units, | 236 const caseless_str& to_units, |
204 const Matrix& parent_dim = Matrix (1, 2, 0.0), | 237 const Matrix& parent_dim = Matrix (1, 2, 0.0), |
205 const graphics_backend& backend = graphics_backend ()) | 238 const graphics_backend& backend = graphics_backend ()) |
206 { | 239 { |
216 retval(2) = pos(2) * parent_dim(0); | 249 retval(2) = pos(2) * parent_dim(0); |
217 retval(3) = pos(3) * parent_dim(1); | 250 retval(3) = pos(3) * parent_dim(1); |
218 } | 251 } |
219 else if (from_units.compare ("characters")) | 252 else if (from_units.compare ("characters")) |
220 { | 253 { |
221 // FIXME -- implement this. | 254 res = backend.get_screen_resolution (); |
255 | |
256 double f = 0.0; | |
257 | |
258 // FIXME -- this assumes the system font is Helvetica 10pt | |
259 // (for which "x" requires 6x12 pixels at 74.951 pixels/inch) | |
260 f = 12.0 * res / 74.951; | |
261 | |
262 if (f > 0) | |
263 { | |
264 retval(0) = 0.5 * pos(0) * f; | |
265 retval(1) = pos(1) * f; | |
266 retval(2) = 0.5 * pos(2) * f; | |
267 retval(3) = pos(3) * f; | |
268 } | |
222 } | 269 } |
223 else | 270 else |
224 { | 271 { |
225 res = backend.get_screen_resolution (); | 272 res = backend.get_screen_resolution (); |
226 | 273 |
251 retval(2) /= parent_dim(0); | 298 retval(2) /= parent_dim(0); |
252 retval(3) /= parent_dim(1); | 299 retval(3) /= parent_dim(1); |
253 } | 300 } |
254 else if (to_units.compare ("characters")) | 301 else if (to_units.compare ("characters")) |
255 { | 302 { |
256 // FIXME -- implement this. | 303 res = backend.get_screen_resolution (); |
304 | |
305 double f = 0.0; | |
306 | |
307 f = 12.0 * res / 74.951; | |
308 | |
309 if (f > 0) | |
310 { | |
311 retval(0) = 2 * retval(0) / f; | |
312 retval(1) = retval(1) / f; | |
313 retval(2) = 2 * retval(2) / f; | |
314 retval(3) = retval(3) / f; | |
315 } | |
257 } | 316 } |
258 else | 317 else |
259 { | 318 { |
260 if (res <= 0) | 319 if (res <= 0) |
261 res = backend.get_screen_resolution (); | 320 res = backend.get_screen_resolution (); |