changeset 7826:68550ad9ee9c

Add support for extern updaters. Add set_figure_position interface to graphics_backend.
author Michael Goffioul <michael.goffioul@gmail.com>
date Tue, 12 Feb 2008 16:37:56 +0100
parents 13871b7de124
children 3584f37eac69
files src/ChangeLog src/genprops.awk src/graphics.h.in
diffstat 3 files changed, 46 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Feb 11 16:42:14 2008 +0100
+++ b/src/ChangeLog	Tue Feb 12 16:37:56 2008 +0100
@@ -1,5 +1,14 @@
 2008-06-04  Michael Goffioul <michael.goffioul@gmail.com>
 
+	* genprops.awk: Add 'U' modifier to support extern updaters.
+	* graphics.h.in (base_graphics_backend::gripe_invalid): New method
+	to simplify error reporting.
+	(class base_graphics_backend): Use it.
+	(base_graphics_backend::set_figure_position): New backend method.
+	(graphics_backend::set_figure_position): Likewise.
+	(figure::properties::position): Mark property with updater.
+	(figure::properties::update_position): New updater.
+
 	* graphics.h.in (root_figure::properties::callbackobject):
 	New root property.
 	(root_figure::properties::cbo_stack): New field.
--- a/src/genprops.awk	Mon Feb 11 16:42:14 2008 +0100
+++ b/src/genprops.awk	Tue Feb 12 16:37:56 2008 +0100
@@ -291,7 +291,7 @@
         printf ("\n  {\n    if (! error_state)\n      {\n        %s = val;\n",
           name[i]);
         if (updater[i])
-          printf ("        %s ();\n", updater[i]);
+          printf ("        update_%s ();\n", name[i]);
         if (limits[i])
           printf ("        update_axis_limits (\"%s\");\n", name[i]);
         if (mode[i])
@@ -302,6 +302,11 @@
         printf (";\n\n");
     }
 
+    if (updater[i] == "extern")
+    {
+      printf ("  void update_%s (void);\n\n", name[i]);
+    }
+
 ##    if (emit_ov_set[i])
 ##    {
 ##      printf ("  void set_%s (const octave_value& val)", name[i]);
@@ -528,10 +533,15 @@
 	if (index (quals, "r"))
 	  readonly[idx] = 1;
 
-        ## There is an updater method that should be called
+        ## There is an inline updater method that should be called
         ## from the set method
         if (index (quals, "u"))
-          updater[idx] = ("update_" name[idx]);
+          updater[idx] = "inline";
+        
+	## There is an extern updater method that should be called
+        ## from the set method
+        if (index (quals, "U"))
+          updater[idx] = "extern";
 
 ##        ## emmit an asignment set function
 ##        if (index (quals, "a"))
--- a/src/graphics.h.in	Mon Feb 11 16:42:14 2008 +0100
+++ b/src/graphics.h.in	Tue Feb 12 16:37:56 2008 +0100
@@ -1162,37 +1162,47 @@
   virtual bool is_valid (void) const { return false; }
 
   virtual void close_figure (const octave_value&) const
-    { error ("close_figure: invalid graphics backend"); }
+    { gripe_invalid ("close_figure"); }
 
   virtual void redraw_figure (const graphics_handle&) const
-    { error ("redraw_figure: invalid graphics backend"); }
+    { gripe_invalid ("redraw_figure"); }
 
   virtual void print_figure (const graphics_handle&, const std::string&,
 			     const std::string&, bool,
 			     const std::string& = "") const
-    { error ("print_figure: invalid graphics backend"); }
+    { gripe_invalid ("print_figure"); }
 
   virtual Matrix get_canvas_size (const graphics_handle&) const
     {
-      error ("get_canvas_size: invalid graphics backend");
+      gripe_invalid ("get_canvas_size");
       return Matrix (1, 2, 0.0);
     }
 
   virtual double get_screen_resolution (void) const
     {
-      error ("get_screen_resolution: invalid graphics backend");
-      return -1;
+      gripe_invalid ("get_screen_resolution");
+      return 72.0;
     }
   
   virtual Matrix get_screen_size (void) const
     {
-      error ("get_screen_size: invalid graphics backend");
+      gripe_invalid ("get_screen_size");
       return Matrix (1, 2, 0.0);
     }
 
+  virtual void set_figure_position (const graphics_handle&, const Matrix&) const
+    { gripe_invalid ("set_figure_position"); }
+
 private:
   std::string name;
   int count;
+
+private:
+  void gripe_invalid (const std::string& fname) const
+    {
+      if (! is_valid ())
+	error ("%s: invalid graphics backend", fname.c_str ());
+    }
 };
 
 class graphics_backend
@@ -1260,6 +1270,9 @@
   Matrix get_screen_size (void) const
     { return rep->get_screen_size (); }
 
+  void set_figure_position (const graphics_handle& h, const Matrix& pos) const
+    { rep->set_figure_position (h, pos); }
+
   OCTINTERP_API static graphics_backend default_backend (void);
 
   static void register_backend (const graphics_backend& b)
@@ -2149,6 +2162,9 @@
 
     Matrix get_boundingbox (bool internal = false) const;
 
+    void update_position (void)
+      { backend.set_figure_position (__myhandle__, get_boundingbox ()); }
+
     // See the genprops.awk script for an explanation of the
     // properties declarations.
 
@@ -2184,7 +2200,7 @@
       radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand"
       array_property pointershapecdata , Matrix (16, 16, 0)
       array_property pointershapehotspot , Matrix (1, 2, 0)
-      array_property position , default_figure_position ()
+      array_property position u , default_figure_position ()
       radio_property renderer , "{painters}|zbuffer|opengl|none"
       radio_property renderermode , "{auto}|manual"
       bool_property resize , "on"