diff src/graphics.cc @ 6432:5bec61ae1576

[project @ 2007-03-23 02:19:10 by jwe]
author jwe
date Fri, 23 Mar 2007 02:19:11 +0000
parents 0cc5ca7b1e91
children 84f2d0253aea
line wrap: on
line diff
--- a/src/graphics.cc	Thu Mar 22 18:20:32 2007 +0000
+++ b/src/graphics.cc	Fri Mar 23 02:19:11 2007 +0000
@@ -396,6 +396,11 @@
 
   virtual ~base_graphics_object (void) { }
 
+  virtual void mark_modified (void)
+  {
+    error ("base_graphics_object::mark_modified: invalid graphics object");
+  }
+
   virtual void override_defaults (base_graphics_object&)
   {
     error ("base_graphics_object::override_defaults: invalid graphics object");
@@ -518,6 +523,8 @@
       delete rep;
   }
 
+  void mark_modified (void) { rep->mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     rep->override_defaults (obj);
@@ -1001,12 +1008,20 @@
   base_properties (const std::string& t = "unknown",
 		   const graphics_handle& mh = octave_NaN,
 		   const graphics_handle& p = octave_NaN)
-    : type (t), __myhandle__ (mh), parent (p), children () { }
+    : type (t), __modified__ (true), __myhandle__ (mh), parent (p),
+      children () { }
 
   virtual ~base_properties (void) { }
 
   virtual std::string graphics_object_name (void) const = 0;
 
+  void mark_modified (void)
+  {
+    __modified__ = true;
+    graphics_object parent_obj = gh_manager::get_object (parent);
+    parent_obj.mark_modified ();
+  }
+
   void override_defaults (base_graphics_object& obj)
   {
     graphics_object parent_obj = gh_manager::get_object (parent);
@@ -1119,6 +1134,7 @@
 
 protected:
   std::string type;
+  bool __modified__;
   graphics_handle __myhandle__;
   graphics_handle parent;
   Matrix children;
@@ -1212,6 +1228,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Now override with our defaults.  If the default_properties
@@ -1333,8 +1351,15 @@
 
     void set (const property_name& name, const octave_value& val)
     {
+      bool modified = true;
+
       if (name.compare ("children"))
 	children = maybe_set_children (children, val);
+      else if (name.compare ("__modified__"))
+	{
+	  __modified__ = val.bool_value ();
+	  modified = false;
+	}
       else if (name.compare ("__plot_stream__"))
 	__plot_stream__ = val;
       else if (name.compare ("nextplot"))
@@ -1367,7 +1392,13 @@
       else if (name.compare ("paperorientation"))
 	paperorientation = val;
       else
-	warning ("set: invalid property `%s'", name.c_str ());
+	{
+	  modified = false;
+	  warning ("set: invalid property `%s'", name.c_str ());
+	}
+
+      if (modified)
+	mark_modified ();
     }
 
     octave_value get (void) const
@@ -1377,6 +1408,7 @@
       m.assign ("type", type);
       m.assign ("parent", parent);
       m.assign ("children", children);
+      m.assign ("__modified__", __modified__);
       m.assign ("__plot_stream__", __plot_stream__);
       m.assign ("nextplot", nextplot);
       m.assign ("closerequestfcn", closerequestfcn);
@@ -1398,6 +1430,8 @@
 	retval = parent;
       else if (name.compare ("children"))
 	retval = children;
+      else if (name.compare ("__modified__"))
+	retval = __modified__;
       else if (name.compare ("__plot_stream__"))
 	retval = __plot_stream__;
       else if (name.compare ("nextplot"))
@@ -1443,7 +1477,7 @@
       property_list::pval_map_type m;
 
       m["nextplot"] = "replace";
-      //      m["closerequestfcn"] = make_fcn_handle ("closereq");
+      // m["closerequestfcn"] = make_fcn_handle ("closereq");
       m["colormap"] = colormap_property ();
       m["visible"] = "on";
       m["paperorientation"] = "portrait";
@@ -1480,6 +1514,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { properties.mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (root figure) to override first (properties knows how
@@ -1638,10 +1674,17 @@
 
     void set (const property_name& name, const octave_value& val)
     {
+      bool modified = true;
+
       if (name.compare ("parent"))
 	set_parent (val);
       else if (name.compare ("children"))
 	children = maybe_set_children (children, val);
+      else if (name.compare ("__modified__"))
+	{
+	  __modified__ = val.bool_value ();
+	  modified = false;
+	}
       else if (name.compare ("position"))
 	position = val;
       else if (name.compare ("title"))
@@ -1801,7 +1844,13 @@
       else if (name.compare ("outerposition"))
 	outerposition = val;
       else
-	warning ("set: invalid property `%s'", name.c_str ());
+	{
+	  modified = false;
+	  warning ("set: invalid property `%s'", name.c_str ());
+	}
+
+      if (modified)
+	mark_modified ();
     }
 
     void set_defaults (base_graphics_object& obj, const std::string& mode)
@@ -1895,6 +1944,7 @@
       m.assign ("type", type);
       m.assign ("parent", parent);
       m.assign ("children", children);
+      m.assign ("__modified__", __modified__);
       m.assign ("position", position);
       m.assign ("title", title);
       m.assign ("box", box);
@@ -1953,6 +2003,8 @@
 	retval = parent;
       else if (name.compare ("children"))
 	retval = children;
+      else if (name.compare ("__modified__"))
+	retval = __modified__;
       else if (name.compare ("position"))
 	retval = position;
       else if (name.compare ("title"))
@@ -2229,6 +2281,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { properties.mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (figure) to override first (properties knows how
@@ -2357,10 +2411,17 @@
 
     void set (const property_name& name, const octave_value& val)
     {
+      bool modified = true;
+
       if (name.compare ("parent"))
 	set_parent (val);
       else if (name.compare ("children"))
 	children = maybe_set_children (children, val);
+      else if (name.compare ("__modified__"))
+	{
+	  __modified__ = val.bool_value ();
+	  modified = false;
+	}
       else if (name.compare ("xdata"))
 	xdata = val;
       else if (name.compare ("ydata"))
@@ -2388,7 +2449,13 @@
       else if (name.compare ("keylabel"))
 	keylabel = val;
       else
-	warning ("set: invalid property `%s'", name.c_str ());
+	{
+	  modified = false;
+	  warning ("set: invalid property `%s'", name.c_str ());
+	}
+
+      if (modified)
+	mark_modified ();
     }
 
     octave_value get (void) const
@@ -2398,6 +2465,7 @@
       m.assign ("type", type);
       m.assign ("parent", parent);
       m.assign ("children", children);
+      m.assign ("__modified__", __modified__);
       m.assign ("xdata", xdata);
       m.assign ("ydata", ydata);
       m.assign ("zdata", zdata);
@@ -2425,6 +2493,8 @@
 	retval = parent;
       else if (name.compare ("children"))
 	retval = children;
+      else if (name.compare ("__modified__"))
+	retval = __modified__;
       else if (name.compare ("xdata"))
 	retval = xdata;
       else if (name.compare ("ydata"))
@@ -2511,6 +2581,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { properties.mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (figure) to override first (properties knows how
@@ -2571,10 +2643,17 @@
 
     void set (const property_name& name, const octave_value& val)
     {
+      bool modified = true;
+
       if (name.compare ("parent"))
 	set_parent (val);
       else if (name.compare ("children"))
 	children = maybe_set_children (children, val);
+      else if (name.compare ("__modified__"))
+	{
+	  __modified__ = val.bool_value ();
+	  modified = false;
+	}
       else if (name.compare ("string"))
 	string = val;
       else if (name.compare ("units"))
@@ -2584,7 +2663,13 @@
       else if (name.compare ("horizontalalignment"))
 	horizontalalignment = val;
       else
-	warning ("set: invalid property `%s'", name.c_str ());
+	{
+	  modified = false;
+	  warning ("set: invalid property `%s'", name.c_str ());
+	}
+
+      if (modified)
+	mark_modified ();
     }
 
     octave_value get (void) const
@@ -2594,6 +2679,7 @@
       m.assign ("type", type);
       m.assign ("parent", parent);
       m.assign ("children", children);
+      m.assign ("__modified__", __modified__);
       m.assign ("string", string);
       m.assign ("units", units);
       m.assign ("position", position);
@@ -2612,6 +2698,8 @@
 	retval = parent;
       else if (name.compare ("children"))
 	retval = children;
+      else if (name.compare ("__modified__"))
+	retval = __modified__;
       else if (name.compare ("string"))
 	retval = string;
       else if (name.compare ("units"))
@@ -2662,6 +2750,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { properties.mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (figure) to override first (properties knows how
@@ -2721,10 +2811,17 @@
 
     void set (const property_name& name, const octave_value& val)
     {
+      bool modified = true;
+
       if (name.compare ("parent"))
 	set_parent (val);
       else if (name.compare ("children"))
 	children = maybe_set_children (children, val);
+      else if (name.compare ("__modified__"))
+	{
+	  __modified__ = val.bool_value ();
+	  modified = false;
+	}
       else if (name.compare ("cdata"))
 	cdata = val;
       else if (name.compare ("xdata"))
@@ -2732,7 +2829,13 @@
       else if (name.compare ("ydata"))
 	ydata = val;
       else
-	warning ("set: invalid property `%s'", name.c_str ());
+	{
+	  modified = false;
+	  warning ("set: invalid property `%s'", name.c_str ());
+	}
+
+      if (modified)
+	mark_modified ();
     }
 
     octave_value get (void) const
@@ -2742,6 +2845,7 @@
       m.assign ("type", type);
       m.assign ("parent", parent);
       m.assign ("children", children);
+      m.assign ("__modified__", __modified__);
       m.assign ("cdata", cdata);
       m.assign ("xdata", xdata);
       m.assign ("ydata", ydata);
@@ -2759,6 +2863,8 @@
 	retval = parent;
       else if (name.compare ("children"))
 	retval = children;
+      else if (name.compare ("__modified__"))
+	retval = __modified__;
       else if (name.compare ("cdata"))
 	retval = cdata;
       else if (name.compare ("xdata"))
@@ -2805,6 +2911,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { properties.mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (figure) to override first (properties knows how
@@ -2865,10 +2973,17 @@
 
     void set (const property_name& name, const octave_value& val)
     {
+      bool modified = true;
+
       if (name.compare ("parent"))
 	set_parent (val);
       else if (name.compare ("children"))
 	children = maybe_set_children (children, val);
+      else if (name.compare ("__modified__"))
+	{
+	  __modified__ = val.bool_value ();
+	  modified = false;
+	}
       else if (name.compare ("xdata"))
 	xdata = val;
       else if (name.compare ("ydata"))
@@ -2878,7 +2993,13 @@
       else if (name.compare ("keylabel"))
 	keylabel = val;
       else
-	warning ("set: invalid property `%s'", name.c_str ());
+	{
+	  modified = false;
+	  warning ("set: invalid property `%s'", name.c_str ());
+	}
+
+      if (modified)
+	mark_modified ();
     }
 
     octave_value get (void) const
@@ -2888,6 +3009,7 @@
       m.assign ("type", type);
       m.assign ("parent", parent);
       m.assign ("children", children);
+      m.assign ("__modified__", __modified__);
       m.assign ("xdata", xdata);
       m.assign ("ydata", ydata);
       m.assign ("zdata", zdata);
@@ -2906,6 +3028,8 @@
 	retval = parent;
       else if (name.compare ("children"))
 	retval = children;
+      else if (name.compare ("__modified__"))
+	retval = __modified__;
       else if (name.compare ("xdata"))
 	retval = xdata;
       else if (name.compare ("ydata"))
@@ -2956,6 +3080,8 @@
 
   std::string type (void) const { return properties.graphics_object_name (); }
 
+  void mark_modified (void) { properties.mark_modified (); }
+
   void override_defaults (base_graphics_object& obj)
   {
     // Allow parent (figure) to override first (properties knows how