# HG changeset patch
# User Daniel J Sebald <daniel.sebald@ieee.org>
# Date 1368980417 18000
# Node ID 2e8d4520aa2104b053eb4a084fc10b03cd0e7c7b
# Parent  7f6f0b3f73692cf741ece3fd54ba00e0500224c4
Marginal fix for resetting graphics properties.

* graphics.cc
(root_figure::reset_to_factory_defaults): Set properties to factory_defaults()
except __modified__, uicontextmenu, callbackobject, and currentfigure. Call
reset_to_factory_defaults for children.
(figure::reset_to_factory_defaults): Set properties to factory_defaults()
except __modified__, uicontextmenu, __plot_stream__", __enhanced__,
currentaxes, currentobject, __graphics_toolkit__, and __guidata__. Call
reset_to_factory_defaults for children.
(axes::reset_to_factory_defaults, line::reset_to_factory_defaults,
text::reset_to_factory_defaults, image::reset_to_factory_defaults,
patch::reset_to_factory_defaults, surface::reset_to_factory_defaults,
hggroup::reset_to_factory_defaults): Set properties to factory_defaults()
except __modified__, and uicontextmenu. Call reset_to_factory_defaults for
children.
(uimenu::reset_to_factory_defaults, uicontextmenu::reset_to_factory_defaults,
uicontrol::reset_to_factory_defaults, uipanel::reset_to_factory_defaults,
uitoolbar::reset_to_factory_defaults, uipushtool::reset_to_factory_defaults,
uitoggletool::reset_to_factory_defaults): Set properties to factory_defaults()
except __modified__, uicontextmenu, and __object__. Call
reset_to_factory_defaults for children.
(reset): Add comment about known bugs. Call graphic object's virtual function
reset_to_factory_defaults and set Vdrawnow_requested.
(set): Add comment about known bugs.

* graphics.in.h (base_graphics_object): New virtual function
reset_to_factory_defaults.
(graphics_object): New function reset_to_factory_defaults calling instantiated
virtual function reset_to_factory_defaults from base representation.
(root_figure::reset_to_factory_defaults): New function.
(figure::set): Prefix property name with "figure".
(figure::reset_to_factory_defaults): New function.
(axes::set): Prefix property name with "axes".
(axes::reset_to_factory_defaults, line::reset_to_factory_defaults,
text::reset_to_factory_defaults, image::reset_to_factory_defaults,
patch::reset_to_factory_defaults, surface::reset_to_factory_defaults,
hggroup::reset_to_factory_defaults, uimenu::reset_to_factory_defaults,
uicontextmenu::reset_to_factory_defaults, uicontrol::reset_to_factory_defaults,
uipanel::reset_to_factory_defaults): New function.
(uitoolbar::set): Prefix property name with "uitoolbar".
(uitoolbar::reset_to_factory_defaults, uipushtool::reset_to_factory_defaults,
uitoggletool::reset_to_factory_defaults): New function.

diff --git a/libinterp/interpfcn/graphics.cc b/libinterp/interpfcn/graphics.cc
--- a/libinterp/interpfcn/graphics.cc
+++ b/libinterp/interpfcn/graphics.cc
@@ -1677,6 +1677,46 @@
   mark_modified ();
 }
 
+void
+figure::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__plot_stream__" &&
+          pname != "__enhanced__" &&
+          pname != "currentaxes" &&
+          pname != "currentobject" &&
+          pname != "__graphics_toolkit__" &&
+          pname != "__guidata__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 void
@@ -3157,6 +3197,42 @@
 }
 
 void
+root_figure::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "callbackobject" &&
+          pname != "currentfigure")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
+void
 root_figure::reset_default_properties (void)
 {
   ::reset_default_properties (default_properties);
@@ -5813,6 +5889,40 @@
   return v;
 }
 
+void
+axes::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 octave_value
 axes::get_default (const caseless_str& name) const
 {
@@ -6969,6 +7079,40 @@
   return m;
 }
 
+void
+line::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 Matrix
@@ -7116,6 +7260,40 @@
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
 }
 
+void
+text::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 octave_value
@@ -7125,6 +7303,40 @@
                         cdatamapping_is ("scaled"), 3);
 }
 
+void
+image::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 octave_value
@@ -7137,6 +7349,40 @@
     return convert_cdata (*this, fvc,cdatamapping_is ("scaled"), 2);
 }
 
+void
+patch::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 octave_value
@@ -7231,6 +7477,40 @@
     }
 }
 
+void
+surface::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 void
@@ -7266,6 +7546,40 @@
 static bool updating_hggroup_limits = false;
 
 void
+hggroup::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
+void
 hggroup::update_axis_limits (const std::string& axis_type,
                              const graphics_handle& h)
 {
@@ -7468,6 +7782,80 @@
 
 // ---------------------------------------------------------------------
 
+void
+uimenu::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
+// ---------------------------------------------------------------------
+
+void
+uicontextmenu::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
+// ---------------------------------------------------------------------
+
 octave_value
 uicontrol::properties::get_extent (void) const
 {
@@ -7601,6 +7989,41 @@
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
 }
 
+void
+uicontrol::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
 Matrix
@@ -7737,8 +8160,78 @@
   return convert_font_size (fs, get_fontunits (), "points", parent_height);
 }
 
+void
+uipanel::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 // ---------------------------------------------------------------------
 
+void
+uitoolbar::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
 octave_value
 uitoolbar::get_default (const caseless_str& name) const
 {
@@ -7763,6 +8256,80 @@
 
 // ---------------------------------------------------------------------
 
+void
+uipushtool::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
+// ---------------------------------------------------------------------
+
+void
+uitoggletool::reset_to_factory_defaults (void)
+{
+  property_list::pval_map_type pm = properties::factory_defaults ();
+  property_list::pval_map_const_iterator p;
+  for (p = pm.begin (); p != pm.end (); p++)
+    {
+      caseless_str pname (p->first);
+      if (pname != "__modified__" &&
+          pname != "uicontextmenu" &&
+          pname != "__object__")
+        {
+          // Read-only properties (i.e., 'r' described in genprops.awk)
+          // do not appear within the test structure for valid properties
+          // (i.e., can only get read-only properties, not set them).  There
+          // is no way to check whether a property is read-only so just live
+          // with the error message in the short term.  Furthermore, the
+          // bogus error will stop all remaining "set" operations to fail
+          // unless the error state from before the "set" is restored after
+          // the "set".
+          OCTINTERP_API int error_state_copy = error_state;
+          set (pname, p->second);
+          error_state = error_state_copy;
+        }
+    }
+
+  Matrix kids = xproperties.get_children ();
+  for (octave_idx_type i = 0; i < kids.length (); i++)
+    {
+      graphics_handle hnd = gh_manager::lookup (kids(i));
+      if (hnd.ok ())
+        gh_manager::get_object (hnd).reset_to_factory_defaults ();
+    }
+}
+
+// ---------------------------------------------------------------------
+
 octave_value
 base_graphics_object::get_default (const caseless_str& name) const
 {
@@ -8387,6 +8954,9 @@
 properties of \"position\", \"units\", \"windowstyle\" and\n\
 \"paperunits\" and the default axes properties of \"position\" and \"units\"\n\
 are not reset.\n\
+\n\
+NOTE: Setting and resetting properties has some known issues to be fixed in\n\
+subsequent versions.  No bug report is necessary on this topic.\n\
 @end deftypefn")
 {
   int nargin = args.length ();
@@ -8402,7 +8972,30 @@
         {
           // loop over graphics objects
           for (octave_idx_type n = 0; n < hcv.length (); n++)
-            gh_manager::get_object (hcv(n)).reset_default_properties ();
+            {
+              gh_manager::get_object (hcv(n)).reset_default_properties ();
+
+              // The following step is actually something that probably
+              // shouldn't be done.  Clearing out the user-set properties
+              // (the line previous) seems like all that should be needed,
+              // but property management and hierarchy aren't set up to
+              // accomodate that approach right now.  So just reset all
+              // the properties back to factory settings.
+              //
+              // There is no convenient function for setting the properties
+              // to factory settings because the initialization of the
+              // properties is done inside the constructor member function
+              // definition (see graphics-props.cc).  That could be rewritten
+              // inside the gawk script so that initialization is done with a
+              // function syntax that can be utilized inside the constructor
+              // and here.  However, some thought about global behavior should
+              // be done before modifying the gawk script in order to
+              // accomodate this dubious step.  Instead, here's a roundabout
+              // way of getting the factory settings and then setting every
+              // property one at a time.
+              gh_manager::get_object (hcv(n)).reset_to_factory_defaults ();
+              Vdrawnow_requested = true;
+            }
         }
     }
 
@@ -8442,6 +9035,9 @@
 elements of @var{pv} will be set in all handles in @var{h} independent of\n\
 the dimensions of @var{pv}.\n\
 @end itemize\n\
+\n\
+NOTE: Setting and resetting properties has some known issues to be fixed in\n\
+subsequent versions.  No bug report is necessary on this topic.\n\
 @end deftypefn")
 {
   gh_manager::auto_lock guard;
diff --git a/libinterp/interpfcn/graphics.in.h b/libinterp/interpfcn/graphics.in.h
--- a/libinterp/interpfcn/graphics.in.h
+++ b/libinterp/interpfcn/graphics.in.h
@@ -2770,6 +2770,11 @@
     return octave_value ();
   }
 
+  virtual void reset_to_factory_defaults (void)
+  {
+    error ("base_graphics_object::reset_to_factory_defaults: invalid graphics object");
+  }
+
   virtual std::string values_as_string (void);
 
   virtual octave_scalar_map values_as_struct (void);
@@ -3041,6 +3046,11 @@
     return rep->get_factory_defaults ();
   }
 
+  void reset_to_factory_defaults (void) const
+  {
+    return rep->reset_to_factory_defaults ();
+  }
+
   std::string values_as_string (void) { return rep->values_as_string (); }
 
   octave_map values_as_struct (void) { return rep->values_as_struct (); }
@@ -3278,6 +3288,8 @@
     return factory_properties.as_struct ("factory");
   }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -3470,10 +3482,13 @@
   void set (const caseless_str& name, const octave_value& value)
   {
     if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
+      {
+        // strip "default" and prefix with "figure", then pass to
+        // function that will parse and add the element to the
+        // default_properties map.
+        caseless_str figurename = "figure" + name.substr (7);
+        default_properties.set (figurename, value);
+      }
     else
       xproperties.set (name, value);
   }
@@ -3497,6 +3512,8 @@
     return default_properties.as_struct ("default");
   }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4100,10 +4117,13 @@
   void set (const caseless_str& name, const octave_value& value)
   {
     if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
+      {
+        // strip "default" and prefix with "axes", then pass to
+        // function that will parse and add the element to the
+        // default_properties map.
+        caseless_str axesname = "axes" + name.substr (7);
+        default_properties.set (axesname, value);
+      }
     else
       xproperties.set (name, value);
   }
@@ -4134,6 +4154,8 @@
     return default_properties.as_struct ("default");
   }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4220,6 +4242,8 @@
 
   ~line (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4384,6 +4408,8 @@
 
   ~text (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4509,6 +4535,8 @@
 
   ~image (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4627,6 +4655,8 @@
 
   ~patch (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4780,6 +4810,8 @@
 
   ~surface (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4850,6 +4882,8 @@
 
   ~hggroup (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4914,6 +4948,8 @@
 
   ~uimenu (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -4960,6 +4996,8 @@
 
   ~uicontextmenu (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -5053,6 +5091,8 @@
 
   ~uicontrol (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -5119,6 +5159,8 @@
 
   ~uipanel (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -5175,10 +5217,13 @@
   void set (const caseless_str& name, const octave_value& value)
   {
     if (name.compare ("default", 7))
-      // strip "default", pass rest to function that will
-      // parse the remainder and add the element to the
-      // default_properties map.
-      default_properties.set (name.substr (7), value);
+      {
+        // strip "default" and prefix with "uitoolbar", then pass to
+        // function that will parse and add the element to the
+        // default_properties map.
+        caseless_str uitoolbarname = "uitoolbar" + name.substr (7);
+        default_properties.set (uitoolbarname, value);
+      }
     else
       xproperties.set (name, value);
   }
@@ -5202,6 +5247,8 @@
     return default_properties.as_struct ("default");
   }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -5256,6 +5303,8 @@
 
   ~uipushtool (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
@@ -5309,6 +5358,8 @@
 
   ~uitoggletool (void) { }
 
+  void reset_to_factory_defaults (void);
+
   base_properties& get_properties (void) { return xproperties; }
 
   const base_properties& get_properties (void) const { return xproperties; }
