# HG changeset patch # User jwe # Date 1201848468 0 # Node ID 464a55f1a5c2858d4aaa63093cc5beb625afecdd # Parent 600a3af7963e58204f6ff551e87e72ba9d12b118 [project @ 2008-02-01 06:47:48 by jwe] diff -r 600a3af7963e -r 464a55f1a5c2 src/ChangeLog --- a/src/ChangeLog Fri Feb 01 06:34:12 2008 +0000 +++ b/src/ChangeLog Fri Feb 01 06:47:48 2008 +0000 @@ -1,3 +1,16 @@ +2008-01-30 Michael Goffioul + + * graphics.h.in (axes::properties::get_transform_matrix, + axes::properties::get_inverse_transform_matrix, + axes::properties::get_opengl_matrix_1, + axes::properties::get_opengl_matrix_2, + axes::properties::get_transform_zlim): New accessors. + (base_properties::is_clipping): New accessor. + (class graphics_xform): New class encapsulating axes transformation. + (axes::properties::get_transform): New method returning a + graphics_xform object. + * graphics.cc (class graphics_xform): New class. + 2008-01-31 David Bateman * ov.cc (octave_value::octave_value (const ArrayN&), diff -r 600a3af7963e -r 464a55f1a5c2 src/graphics.cc --- a/src/graphics.cc Fri Feb 01 06:34:12 2008 +0000 +++ b/src/graphics.cc Fri Feb 01 06:47:48 2008 +0000 @@ -2068,6 +2068,44 @@ return pos; } +ColumnVector +graphics_xform::xform_vector (double x, double y, double z) +{ return ::xform_vector (x, y, z); } + +Matrix +graphics_xform::xform_eye (void) +{ return ::xform_matrix (); } + +ColumnVector +graphics_xform::transform (double x, double y, double z, + bool use_scale) const +{ + if (use_scale) + { + x = sx.scale (x); + y = sy.scale (y); + z = sz.scale (z); + } + + return ::transform (xform, x, y, z); +} + +ColumnVector +graphics_xform::untransform (double x, double y, double z, + bool use_scale) const +{ + ColumnVector v = ::transform (xform_inv, x, y, z); + + if (use_scale) + { + v(0) = sx.unscale (v(0)); + v(1) = sy.unscale (v(1)); + v(2) = sz.unscale (v(2)); + } + + return v; +} + octave_value axes::get_default (const caseless_str& name) const { diff -r 600a3af7963e -r 464a55f1a5c2 src/graphics.h.in --- a/src/graphics.h.in Fri Feb 01 06:34:12 2008 +0000 +++ b/src/graphics.h.in Fri Feb 01 06:47:48 2008 +0000 @@ -1274,6 +1274,7 @@ octave_value get_buttondownfcn (void) const { return buttondownfcn.get (); } + bool is_clipping (void) const { return clipping.is_on (); } std::string get_clipping (void) const { return clipping.current_value (); } void execute_createfcn (const octave_value& data = octave_value ()) const @@ -2166,6 +2167,56 @@ // --------------------------------------------------------------------- +class OCTINTERP_API graphics_xform +{ +public: + graphics_xform (void) + : xform (xform_eye ()), xform_inv (xform_eye ()) + { + sx = sy = sz = "linear"; + } + + graphics_xform (const Matrix& xm, const Matrix& xim, + const scaler& x, const scaler& y, const scaler& z) + : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z) { } + + graphics_xform (const graphics_xform& g) + : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx), + sy (g.sy), sz (g.sz) { } + + ~graphics_xform (void) { } + + graphics_xform& operator = (const graphics_xform& g) + { + xform = g.xform; + xform_inv = g.xform_inv; + sx = g.sx; + sy = g.sy; + sz = g.sz; + + return *this; + } + + static ColumnVector xform_vector (double x, double y, double z); + + static Matrix xform_eye (void); + + ColumnVector transform (double x, double y, double z, + bool scale = true) const; + + ColumnVector untransform (double x, double y, double z, + bool scale = true) const; + + Matrix xscale (const Matrix& m) const { return sx.scale (m); } + Matrix yscale (const Matrix& m) const { return sy.scale (m); } + Matrix zscale (const Matrix& m) const { return sz.scale (m); } + +private: + Matrix xform; + Matrix xform_inv; + scaler sx, sy, sz; +}; + class OCTINTERP_API axes : public base_graphics_object { public: @@ -2192,6 +2243,15 @@ update_camera (); } + graphics_xform get_transform (void) const + { return graphics_xform (x_render, x_render_inv, sx, sy, sz); } + + Matrix get_transform_matrix (void) const { return x_render; } + Matrix get_inverse_transform_matrix (void) const { return x_render_inv; } + Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; } + Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; } + Matrix get_transform_zlim (void) const { return x_zlim; } + private: scaler sx, sy, sz; Matrix x_render, x_render_inv;