changeset 7386:22815fa9c368

[project @ 2008-01-15 21:28:43 by jwe]
author jwe
date Tue, 15 Jan 2008 21:28:43 +0000
parents 8b7b4f58199f
children b429b21abdd4
files src/ChangeLog src/graphics.h.in
diffstat 2 files changed, 88 insertions(+), 305 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Jan 15 20:49:10 2008 +0000
+++ b/src/ChangeLog	Tue Jan 15 21:28:43 2008 +0000
@@ -8,6 +8,21 @@
 
 2008-01-15  Michael Goffioul  <michael.goffioul@gmail.com>
 
+	* graphics.h.in (base_properties::remove_child,
+	base_properties::adopt, base_properties::update_axis_limits):
+	Make virtual.
+	(base_graphics_object::mark_modified,
+	base_graphics_object::override-defaults,
+	base_graphics_object::set_from_list, base_graphics_object::set,
+	base_graphics_object::get, base_graphics_object::get_parent,
+	base_graphics_object::remove_child, base_graphics_object::adopt,
+	base_graphics_object::reparent, base_graphics_object::defaults,
+	base_graphics_object::type): Add default implementation.
+	(class root_figure, class figure, class axes, class line,
+	class text, class image, class patch, class surface):
+	Remove overloaded virtual methods whose implementation is
+	identical to the default one.
+
 	* genprops.awk: Handle 'h' modifier for hidden properties.
 	Replace "get(void)" method with "get(bool all = false)" to allow
 	access to hidden properties.
--- a/src/graphics.h.in	Tue Jan 15 20:49:10 2008 +0000
+++ b/src/graphics.h.in	Tue Jan 15 21:28:43 2008 +0000
@@ -1051,9 +1051,9 @@
   
   std::string get_visible (void) const { return visible.current_value (); }
 
-  void remove_child (const graphics_handle& h);
-
-  void adopt (const graphics_handle& h)
+  virtual void remove_child (const graphics_handle& h);
+
+  virtual void adopt (const graphics_handle& h)
   {
     octave_idx_type n = children.numel ();
     children.resize (1, n+1);
@@ -1188,7 +1188,7 @@
   // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent
   // axes object.
 
-  void update_axis_limits (const std::string& axis_type) const;
+  virtual void update_axis_limits (const std::string& axis_type) const;
 
   virtual void delete_children (void);
 
@@ -1291,22 +1291,34 @@
 
   virtual void mark_modified (void)
   {
-    error ("base_graphics_object::mark_modified: invalid graphics object");
+    if (valid_object ())
+      get_properties ().mark_modified ();
+    else
+      error ("base_graphics_object::mark_modified: invalid graphics object");
   }
 
-  virtual void override_defaults (base_graphics_object&)
+  virtual void override_defaults (base_graphics_object& obj)
   {
-    error ("base_graphics_object::override_defaults: invalid graphics object");
+    if (valid_object ())
+      get_properties ().override_defaults (obj);
+    else
+      error ("base_graphics_object::override_defaults: invalid graphics object");
   }
 
-  virtual void set_from_list (property_list&)
+  virtual void set_from_list (property_list& plist)
   {
-    error ("base_graphics_object::set_from_list: invalid graphics object");
+    if (valid_object ())
+      get_properties ().set_from_list (*this, plist);
+    else
+      error ("base_graphics_object::set_from_list: invalid graphics object");
   }
 
-  virtual void set (const caseless_str&, const octave_value&)
+  virtual void set (const caseless_str& pname, const octave_value& pval)
   {
-    error ("base_graphics_object::set: invalid graphics object");
+    if (valid_object ())
+      get_properties ().set (pname, pval);
+    else
+      error ("base_graphics_object::set: invalid graphics object");
   }
 
   virtual void set_defaults (const std::string&)
@@ -1316,14 +1328,24 @@
 
   virtual octave_value get (bool all = false) const
   {
-    error ("base_graphics_object::get: invalid graphics object");
-    return octave_value ();
+    if (valid_object ())
+      return get_properties ().get (all);
+    else
+      {
+        error ("base_graphics_object::get: invalid graphics object");
+        return octave_value ();
+      }
   }
 
-  virtual octave_value get (const caseless_str&) const
+  virtual octave_value get (const caseless_str& pname) const
   {
-    error ("base_graphics_object::get: invalid graphics object");
-    return octave_value ();
+    if (valid_object ())
+      return get_properties ().get (pname);
+    else
+      {
+        error ("base_graphics_object::get: invalid graphics object");
+        return octave_value ();
+      }
   }
 
   virtual octave_value get_default (const caseless_str&) const;
@@ -1344,28 +1366,48 @@
 
   virtual graphics_handle get_parent (void) const
   {
-    error ("base_graphics_object::get_parent: invalid graphics object");
-    return graphics_handle ();
+    if (valid_object ())
+      return get_properties ().get_parent ();
+    else
+      {
+        error ("base_graphics_object::get_parent: invalid graphics object");
+        return graphics_handle ();
+      }
   }
 
-  virtual void remove_child (const graphics_handle&)
+  virtual void remove_child (const graphics_handle& h)
   {
-    error ("base_graphics_object::remove_child: invalid graphics object");
+    if (valid_object ())
+      get_properties ().remove_child (h);
+    else
+      error ("base_graphics_object::remove_child: invalid graphics object");
   }
 
-  virtual void adopt (const graphics_handle&)
+  virtual void adopt (const graphics_handle& h)
   {
-    error ("base_graphics_object::adopt: invalid graphics object");
+    if (valid_object ())
+      get_properties ().adopt (h);
+    else
+      error ("base_graphics_object::adopt: invalid graphics object");
   }
 
-  virtual void reparent (const graphics_handle&)
+  virtual void reparent (const graphics_handle& np)
   {
-    error ("base_graphics_object::reparent: invalid graphics object");
+    if (valid_object ())
+      get_properties ().reparent (np);
+    else
+      error ("base_graphics_object::reparent: invalid graphics object");
   }
 
   virtual void defaults (void) const
   {
-    error ("base_graphics_object::default: invalid graphics object");
+    if (valid_object ())
+      {
+        std::string msg = (type () + "::defaults");
+        gripe_not_implemented (msg.c_str ());
+      }
+    else
+      error ("base_graphics_object::default: invalid graphics object");
   }
 
   virtual base_properties& get_properties (void)
@@ -1389,7 +1431,11 @@
 
   virtual bool valid_object (void) const { return false; }
 
-  virtual std::string type (void) const { return "unknown"; }
+  virtual std::string type (void) const
+  {
+    return (valid_object () ? get_properties ().graphics_object_name ()
+        : "unknown");
+  }
 
   bool isa (const std::string& go_name) const
   {
@@ -1589,8 +1635,6 @@
 
   ~root_figure (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
   void mark_modified (void) { }
 
   void override_defaults (base_graphics_object& obj)
@@ -1603,11 +1647,6 @@
     obj.set_from_list (default_properties);
   }
 
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
   void set (const caseless_str& name, const octave_value& value)
   {
     if (name.compare ("default", 7))
@@ -1619,11 +1658,6 @@
       xproperties.set (name, value);
   }
 
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
   octave_value get (const caseless_str& name) const
   {
     octave_value retval;
@@ -1668,23 +1702,10 @@
     return factory_properties.as_struct ("factory");
   }
 
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& np) { xproperties.reparent (np); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const
-  {
-    gripe_not_implemented ("root_figure::defaults");
-  }
-
   bool valid_object (void) const { return true; }
 
 private:
@@ -1739,14 +1760,10 @@
 
   ~figure (void)
   {
-    xproperties.delete_children ();
+    xproperties.delete_children (); 
     xproperties.close ();
   }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (root figure) to override first (properties knows how
@@ -1761,11 +1778,6 @@
     obj.set_from_list (default_properties);
   }
 
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
   void set (const caseless_str& name, const octave_value& value)
   {
     if (name.compare ("default", 7))
@@ -1777,11 +1789,6 @@
       xproperties.set (name, value);
   }
 
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
   octave_value get (const caseless_str& name) const
   {
     octave_value retval;
@@ -1801,20 +1808,10 @@
     return default_properties.as_struct ("default");
   }
 
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& np) { xproperties.reparent (np); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("figure::defaults"); }
-
   bool valid_object (void) const { return true; }
 
 private:
@@ -1931,10 +1928,6 @@
 
   ~axes (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (figure) to override first (properties knows how
@@ -1949,11 +1942,6 @@
     obj.set_from_list (default_properties);
   }
 
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
   void set (const caseless_str& name, const octave_value& value)
   {
     if (name.compare ("default", 7))
@@ -1970,11 +1958,6 @@
     xproperties.set_defaults (*this, mode);
   }
 
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
   octave_value get (const caseless_str& name) const
   {
     octave_value retval;
@@ -1995,20 +1978,10 @@
     return default_properties.as_struct ("default");
   }
 
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& np) { xproperties.reparent (np); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("axes::defaults"); }
-
   void update_axis_limits (const std::string& axis_type);
 
   bool valid_object (void) const { return true; }
@@ -2065,51 +2038,10 @@
 
   ~line (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-  }
-
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
-  void set (const caseless_str& name, const octave_value& val)
-  {
-    xproperties.set (name, val);
-  }
-
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    return xproperties.get (name);
-  }
-
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& h) { xproperties.reparent (h); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("line::defaults"); }
-
   bool valid_object (void) const { return true; }
 };
 
@@ -2167,51 +2099,10 @@
 
   ~text (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-  }
-
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
-  void set (const caseless_str& name, const octave_value& val)
-  {
-    xproperties.set (name, val);
-  }
-
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    return xproperties.get (name);
-  }
-
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& h) { xproperties.reparent (h); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("text::defaults"); }
-
   bool valid_object (void) const { return true; }
 };
 
@@ -2250,51 +2141,10 @@
 
   ~image (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-  }
-
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
-  void set (const caseless_str& name, const octave_value& val)
-  {
-    xproperties.set (name, val);
-  }
-
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    return xproperties.get (name);
-  }
-
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& h) { xproperties.reparent (h); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("image::defaults"); }
-
   bool valid_object (void) const { return true; }
 };
 
@@ -2364,51 +2214,10 @@
 
   ~patch (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-  }
-
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
-  void set (const caseless_str& name, const octave_value& val)
-  {
-    xproperties.set (name, val);
-  }
-
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    return xproperties.get (name);
-  }
-
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& h) { xproperties.reparent (h); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("patch::defaults"); }
-
   bool valid_object (void) const { return true; }
 };
 
@@ -2459,51 +2268,10 @@
 
   ~surface (void) { xproperties.delete_children (); }
 
-  std::string type (void) const { return xproperties.graphics_object_name (); }
-
-  void mark_modified (void) { xproperties.mark_modified (); }
-
-  void override_defaults (base_graphics_object& obj)
-  {
-    // Allow parent (figure) to override first (properties knows how
-    // to find the parent object).
-    xproperties.override_defaults (obj);
-  }
-
-  void set_from_list (property_list& plist)
-  {
-    xproperties.set_from_list (*this, plist);
-  }
-
-  void set (const caseless_str& name, const octave_value& val)
-  {
-    xproperties.set (name, val);
-  }
-
-  octave_value get (bool all = false) const
-  {
-    return xproperties.get (all);
-  }
-
-  octave_value get (const caseless_str& name) const
-  {
-    return xproperties.get (name);
-  }
-
-  graphics_handle get_parent (void) const { return xproperties.get_parent (); }
-
-  void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
-
-  void adopt (const graphics_handle& h) { xproperties.adopt (h); }
-
-  void reparent (const graphics_handle& h) { xproperties.reparent (h); }
-
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
 
-  void defaults (void) const { gripe_not_implemented ("surface::defaults"); }
-
   bool valid_object (void) const { return true; }
 };