diff src/graphics.cc @ 7860:67edbcb19665

rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition * * * preserve axes position if mode is replace * * * use default_axes_postion when syncing outerposition and position * * * Update transformation matrices when axes position changes.
author Shai Ayal <shaiay@users.sourceforge.net>
date Fri, 14 Mar 2008 21:02:16 +0200
parents fdd465b00ec0
children 8f3459a90bf3
line wrap: on
line diff
--- a/src/graphics.cc	Wed Mar 12 22:20:01 2008 +0100
+++ b/src/graphics.cc	Fri Mar 14 21:02:16 2008 +0200
@@ -172,6 +172,8 @@
   return m;
 }
 
+
+
 static void
 xset_gcbo (const graphics_handle& h)
 {
@@ -1821,6 +1823,35 @@
 
 // ---------------------------------------------------------------------
 
+void 
+axes::properties::sync_positions (void)
+{
+  // FIXME -- this should take font metrics into consideration,
+  // for now we'll just make it position 90% of outerposition
+  if (activepositionproperty.is ("outerposition"))
+    {
+      Matrix outpos = outerposition.get ().matrix_value ();
+      Matrix defpos = default_axes_position ();
+      Matrix pos(outpos);
+      pos(0) = outpos(0) + defpos(0) * outpos(2);
+      pos(1) = outpos(1) + defpos(1) * outpos(3);
+      pos(2) = outpos(2) * defpos(2);
+      pos(3) = outpos(3) * defpos(3);
+      position = pos;
+    }
+  else
+    {
+      Matrix pos = position.get ().matrix_value ();
+      pos(0) -= pos(2)*0.05;
+      pos(1) -= pos(3)*0.05;
+      pos(2) *= 1.1;
+      pos(3) *= 1.1;
+      outerposition = pos;
+    }
+
+  update_transform ();
+}
+
 void
 axes::properties::set_title (const octave_value& v)
 {
@@ -1873,7 +1904,6 @@
 axes::properties::set_defaults (base_graphics_object& obj,
 				const std::string& mode)
 {
-  position = default_axes_position ();
   title = graphics_handle ();
   box = "on";
   key = "off";
@@ -1976,6 +2006,8 @@
       touterposition(2) = 1;
       touterposition(3) = 1;
       outerposition = touterposition;
+
+      position = default_axes_position ();
     }
 
   activepositionproperty = "outerposition";