changeset 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 7397a0026ca8
files src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 3 files changed, 52 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Mar 12 22:20:01 2008 +0100
+++ b/src/ChangeLog	Fri Mar 14 21:02:16 2008 +0200
@@ -1,5 +1,15 @@
 2008-06-04  Shai Ayal  <shaiay@users.sourceforge.net>
 
+	* graphics.cc (axes::properties::set_defaults): Preserve position
+	if mode is replace.
+	(axes::properties::sync_positions): Use default_axes_postion for
+	consistency.
+
+	* graphics.h.in (axes::properties::sync_positions,
+	axes::properties::update_position,
+	axes::properties::update_outerposition): New functions to sync
+	outerposition and position.
+
 	* graphics.h.in (axes::properties::update_xlim,
 	axes::properties::update_ylim, axes::properties::update_zlim):
 	pass is_logscale flag to axes::properties::calc_ticks_and_lims
@@ -37,6 +47,9 @@
 
 2008-06-04  Michael Goffioul <michael.goffioul@gmail.com>
 
+	* graphics.cc (axes::properties::sync_positions): Update
+	transformation data.
+
 	* graphics.cc (Faddlistener): Rename from Fadd_listener.
 
 	* graphics.h.in (axes::properties::pixel2coord): Center Z coordinate
--- 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";
--- a/src/graphics.h.in	Wed Mar 12 22:20:01 2008 +0100
+++ b/src/graphics.h.in	Fri Mar 14 21:02:16 2008 +0200
@@ -2566,7 +2566,7 @@
     // properties declarations.
 
     BEGIN_PROPERTIES(axes)
-      array_property position , default_axes_position ()
+      array_property position u , default_axes_position ()
       mutable handle_property title GSO , graphics_handle ()
       bool_property box , "on"
       bool_property key , "off"
@@ -2625,7 +2625,7 @@
       radio_property xaxislocation , "{bottom}|top|zero"
       array_property view u , Matrix ()
       radio_property nextplot , "add|replace_children|{replace}"
-      array_property outerposition , default_axes_outerposition ()
+      array_property outerposition u , default_axes_outerposition ()
       radio_property activepositionproperty , "{outerposition}|position"
       radio_property __colorbar__ h , "{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"
       color_property ambientlightcolor , color_values (1, 1, 1)
@@ -2713,6 +2713,10 @@
     void update_ydir (void) { update_camera (); }
     void update_zdir (void) { update_camera (); }
 
+    void sync_positions (void);
+    void update_outerposition (void) { sync_positions ();}
+    void update_position (void) { sync_positions (); }
+
     double calc_tick_sep (double minval, double maxval);
     void calc_ticks_and_lims (array_property& lims, array_property& ticks, bool limmode_is_auto, bool is_logscale);
     void fix_limits (array_property& lims)