changeset 12467:2f83974d5a6d

implement looseinset property for axes
author Konstantinos Poulios <logari81@googlemail.com>
date Tue, 22 Feb 2011 19:52:55 +0100
parents 67f98480b181
children 46b3883d800c
files src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 3 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Feb 21 21:15:45 2011 +0100
+++ b/src/ChangeLog	Tue Feb 22 19:52:55 2011 +0100
@@ -1,3 +1,13 @@
+2011-02-22  Konstantinos Poulios  <logari81@googlemail.com>
+
+	* graphics.h.in (class axes::properties): New hidden property
+	looseinset.
+	(axes::properties::update_looseinset): New function.
+	* graphics.cc (axes::properties::init): Initialize looseinset.
+	(axes::properties::sync_positions): Take looseinset into account
+	instead of default_axes_position.
+	(axes::properties::set_defaults): Default values for looseinset.
+
 2011-02-21  Kai Habel  <kai.habel@gmx.de>
 
 	* src/DLD-FUNCTIONS/__fltk_uigetfile__cc:
--- a/src/graphics.cc	Mon Feb 21 21:15:45 2011 +0100
+++ b/src/graphics.cc	Tue Feb 22 19:52:55 2011 +0100
@@ -3176,6 +3176,7 @@
   currentpoint.add_constraint (dim_vector (2, 3));
   ticklength.add_constraint (dim_vector (1, 2));
   tightinset.add_constraint (dim_vector (1, 4));
+  looseinset.add_constraint (dim_vector (1, 4));
 
   x_zlim.resize (1, 2);
 
@@ -3227,6 +3228,11 @@
   adopt (ylabel.handle_value ());
   adopt (zlabel.handle_value ());
   adopt (title.handle_value ());
+
+  Matrix tlooseinset = default_axes_position ();
+  tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
+  tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
+  looseinset = tlooseinset;
 }
 
 Matrix
@@ -3262,16 +3268,20 @@
 void
 axes::properties::sync_positions (void)
 {
-  Matrix defpos = default_axes_position ();
   Matrix pos = position.get ().matrix_value ();
   Matrix outpos = outerposition.get ().matrix_value ();
+  Matrix lins = looseinset.get ().matrix_value ();
+  double lratio = lins(0);
+  double bratio = lins(1);
+  double wratio = 1-lins(0)-lins(2);
+  double hratio = 1-lins(1)-lins(3);
   if (activepositionproperty.is ("outerposition"))
     {
       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);
+      pos(0) = outpos(0)+lratio*outpos(2);
+      pos(1) = outpos(1)+bratio*outpos(3);
+      pos(2) = wratio*outpos(2);
+      pos(3) = hratio*outpos(3);
 
       position = pos;
       update_transform ();
@@ -3341,10 +3351,10 @@
     {
       update_transform ();
 
-      outpos(0) = pos(0)-pos(2)*defpos(0)/defpos(2);
-      outpos(1) = pos(1)-pos(3)*defpos(1)/defpos(3);
-      outpos(2) = pos(2)/defpos(2);
-      outpos(3) = pos(3)/defpos(3);
+      outpos(0) = pos(0)-pos(2)*lratio/wratio;
+      outpos(1) = pos(1)-pos(3)*bratio/hratio;
+      outpos(2) = pos(2)/wratio;
+      outpos(3) = pos(3)/hratio;
 
       outerposition = calc_tightbox (outpos);
     }
@@ -3557,6 +3567,11 @@
 
       position = default_axes_position ();
 
+      Matrix tlooseinset = default_axes_position ();
+      tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
+      tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
+      looseinset = tlooseinset;
+
       activepositionproperty = "outerposition";
     }
 
--- a/src/graphics.h.in	Mon Feb 21 21:15:45 2011 +0100
+++ b/src/graphics.h.in	Tue Feb 22 19:52:55 2011 +0100
@@ -3296,6 +3296,8 @@
       row_vector_property xmtick h , Matrix ()
       row_vector_property ymtick h , Matrix ()
       row_vector_property zmtick h , Matrix ()
+      // hidden properties for inset
+      array_property looseinset hu , Matrix (1, 4, 0.0)
    END_PROPERTIES
 
   protected:
@@ -3394,6 +3396,8 @@
       sync_positions ();
     }
 
+    void update_looseinset (void) { sync_positions (); }
+
     double calc_tick_sep (double minval, double maxval);
     void calc_ticks_and_lims (array_property& lims, array_property& ticks, array_property& mticks,
                               bool limmode_is_auto, bool is_logscale);