changeset 12441:b932ae4381da

improvements in synchronization of axes position and outerposition
author Konstantinos Poulios <logari81@googlemail.com>
date Sun, 13 Feb 2011 17:44:21 +0100
parents 2ed62b9f949e
children 278902427e87
files src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 3 files changed, 35 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Feb 13 15:11:56 2011 +0100
+++ b/src/ChangeLog	Sun Feb 13 17:44:21 2011 +0100
@@ -1,3 +1,12 @@
+2011-02-13  Konstantinos Poulios  <logari81@googlemail.com>
+
+	* graphics.h.in (axes::properties::update_boundingbox,
+	axes::properties::update_dataaspectratio,
+	axes::properties::update_dataaspectratiomode,
+	axes::properties::update_plotboxaspectratio,
+	axes::properties::update_plotboxaspectratiomode):
+	Replace update_transform hooks with sync_positions. 
+
 2011-02-13  Konstantinos Poulios  <logari81@googlemail.com>
 
 	* graphics.h.in (axes::properties::get_extent,
--- a/src/graphics.cc	Sun Feb 13 15:11:56 2011 +0100
+++ b/src/graphics.cc	Sun Feb 13 17:44:21 2011 +0100
@@ -3279,37 +3279,54 @@
 
       double thrshldx = 0.005*outpos(2);
       double thrshldy = 0.005*outpos(3);
+      double minsizex = 0.2*outpos(2);
+      double minsizey = 0.2*outpos(3);
+      bool updatex = true, updatey = true; 
       for (int i = 0; i < 10; i++)
         {
           double dt;
           bool modified = false;
           dt = outpos(0)+outpos(2)-tightpos(0)-tightpos(2);
-          if (dt < -thrshldx)
+          if (dt < -thrshldx && updatex)
             {
               pos(2) += dt;
               modified = true;
             }
           dt = outpos(1)+outpos(3)-tightpos(1)-tightpos(3);
-          if (dt < -thrshldy)
+          if (dt < -thrshldy && updatey)
             {
               pos(3) += dt;
               modified = true;
             }
           dt = outpos(0)-tightpos(0);
-          if (dt > thrshldx)
+          if (dt > thrshldx && updatex)
             {
               pos(0) += dt;
               pos(2) -= dt;
               modified = true;
             }
           dt = outpos(1)-tightpos(1);
-          if (dt > thrshldy)
+          if (dt > thrshldy && updatey)
             {
               pos(1) += dt;
               pos(3) -= dt;
               modified = true;
             }
 
+          // Note: checking limit for minimum axes size
+          if (pos(2) < minsizex)
+            {
+              pos(0) -= 0.5*(minsizex-pos(2));
+              pos(2) = minsizex;
+              updatex = false;
+            }
+          if (pos(3) < minsizey)
+            {
+              pos(1) -= 0.5*(minsizey-pos(3));
+              pos(3) = minsizey;
+              updatey = false;
+            }
+
           if (modified)
             {
               position = pos;
--- a/src/graphics.h.in	Sun Feb 13 15:11:56 2011 +0100
+++ b/src/graphics.h.in	Sun Feb 13 17:44:21 2011 +0100
@@ -3083,7 +3083,7 @@
       {
         if (units_is ("normalized"))
           {
-            update_transform ();
+            sync_positions ();
             base_properties::update_boundingbox ();
           }
       }
@@ -3307,10 +3307,10 @@
     void update_zscale (void) { sz = get_zscale (); }
 
     void update_view (void) { sync_positions (); }
-    void update_dataaspectratio (void) { update_transform (); }
-    void update_dataaspectratiomode (void) { update_transform (); }
-    void update_plotboxaspectratio (void) { update_transform (); }
-    void update_plotboxaspectratiomode (void) { update_transform (); }
+    void update_dataaspectratio (void) { sync_positions (); }
+    void update_dataaspectratiomode (void) { sync_positions (); }
+    void update_plotboxaspectratio (void) { sync_positions (); }
+    void update_plotboxaspectratiomode (void) { sync_positions (); }
 
     void update_layer (void) { update_axes_layout (); }
     void update_yaxislocation (void) { update_axes_layout (); }