changeset 7435:464a55f1a5c2

[project @ 2008-02-01 06:47:48 by jwe]
author jwe
date Fri, 01 Feb 2008 06:47:48 +0000
parents 600a3af7963e
children 7d06a404b8f9
files src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 3 files changed, 111 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2008-01-30  Michael Goffioul  <michael.goffioul@gmail.com>
+
+	* 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  <dbateman@free.fr>
 
 	* ov.cc (octave_value::octave_value (const ArrayN<bool>&),
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -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
 {
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -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;