Mercurial > hg > octave-avbm
changeset 7832:e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Wed, 20 Feb 2008 16:22:42 +0100 |
parents | c7925666f0bf |
children | 8ff92634982d |
files | src/ChangeLog src/graphics.h.in |
diffstat | 2 files changed, 38 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -15,6 +15,12 @@ 2008-06-04 Michael Goffioul <michael.goffioul@gmail.com> + * graphics.h.in (base_scaler::is_linear, lin_scaler::is_linear, + scaler::is_linear): New method to detect linear scales. + (graphics_xform::scale(Matrix)): New method to scale 2D/3D coordinates + directly. + (patch::properties::facelighting): Set default value to "none". + * graphics.h.in (axes::axes): Be sure to initialize transformation data correctly.
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -215,6 +215,9 @@ virtual base_scaler* clone () const { return new base_scaler (); } + + virtual bool is_linear (void) const + { return false; } }; class lin_scaler : public base_scaler @@ -231,6 +234,8 @@ double unscale (double d) const { return d; } base_scaler* clone (void) const { return new lin_scaler (); } + + bool is_linear (void) const { return true; } }; class log_scaler : public base_scaler @@ -292,6 +297,9 @@ double unscale (double d) const { return rep->unscale (d); } + bool is_linear (void) const + { return rep->is_linear (); } + scaler& operator = (const scaler& s) { if (rep) @@ -2376,6 +2384,29 @@ Matrix yscale (const Matrix& m) const { return sy.scale (m); } Matrix zscale (const Matrix& m) const { return sz.scale (m); } + Matrix scale (const Matrix& m) const + { + bool has_z = (m.columns () > 2); + + if (sx.is_linear () && sy.is_linear () + && (! has_z || sz.is_linear ())) + return m; + + Matrix retval (m.dims ()); + + int r = m.rows (); + + for (int i = 0; i < r; i++) + { + retval(i,0) = sx.scale (m(i,0)); + retval(i,1) = sy.scale (m(i,1)); + if (has_z) + retval(i,2) = sz.scale (m(i,2)); + } + + return retval; + } + private: Matrix xform; Matrix xform_inv; @@ -2867,7 +2898,7 @@ radio_property normalmode , "{auto}|manual" color_property facecolor , "{flat}|none|interp" double_property facealpha , 1.0 - radio_property facelighting , "{flat}|none|gouraud|phong" + radio_property facelighting , "flat|{none}|gouraud|phong" color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) double_property edgealpha , 1.0 radio_property edgelighting , "{none}|flat|gouraud|phong"