Mercurial > hg > octave-nkf
diff src/graphics.cc @ 10722:755fcb5baad3
Add the reset built function
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 23 Jun 2010 11:23:32 +0200 |
parents | 9d4a198614ab |
children | f72a761a784c |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2625,6 +2625,34 @@ property_list root_figure::factory_properties = root_figure::init_factory_properties (); +void +root_figure::reset_default_properties (void) +{ + property_list new_defaults; + + for (property_list::plist_map_const_iterator p = default_properties.begin (); + p != default_properties.end (); p++) + { + const property_list::pval_map_type pval_map = p->second; + std::string prefix = p->first; + + for (property_list::pval_map_const_iterator q = pval_map.begin (); + q != pval_map.end (); + q++) + { + std::string s = q->first; + + if (prefix == "axes" && (s == "position" || s == "units")) + new_defaults.set (prefix + s, q->second); + else if (prefix == "figure" && (s == "position" || s == "units" + || s == "windowstyle" + || s == "paperunits")) + new_defaults.set (prefix + s, q->second); + } + } + default_properties = new_defaults; +} + // --------------------------------------------------------------------- void @@ -2769,6 +2797,34 @@ return retval; } +void +figure::reset_default_properties (void) +{ + property_list new_defaults; + + for (property_list::plist_map_const_iterator p = default_properties.begin (); + p != default_properties.end (); p++) + { + const property_list::pval_map_type pval_map = p->second; + std::string prefix = p->first; + + for (property_list::pval_map_const_iterator q = pval_map.begin (); + q != pval_map.end (); + q++) + { + std::string s = q->first; + + if (prefix == "axes" && (s == "position" || s == "units")) + new_defaults.set (prefix + s, q->second); + else if (prefix == "figure" && (s == "position" || s == "units" + || s == "windowstyle" + || s == "paperunits")) + new_defaults.set (prefix + s, q->second); + } + } + default_properties = new_defaults; +} + // --------------------------------------------------------------------- void @@ -4286,6 +4342,34 @@ unzoom (); } +void +axes::reset_default_properties (void) +{ + property_list new_defaults; + + for (property_list::plist_map_const_iterator p = default_properties.begin (); + p != default_properties.end (); p++) + { + const property_list::pval_map_type pval_map = p->second; + std::string prefix = p->first; + + for (property_list::pval_map_const_iterator q = pval_map.begin (); + q != pval_map.end (); + q++) + { + std::string s = q->first; + + if (prefix == "axes" && (s == "position" || s == "units")) + new_defaults.set (prefix + s, q->second); + else if (prefix == "figure" && (s == "position" || s == "units" + || s == "windowstyle" + || s == "paperunits")) + new_defaults.set (prefix + s, q->second); + } + } + default_properties = new_defaults; +} + // --------------------------------------------------------------------- Matrix @@ -5032,6 +5116,35 @@ return retval; } +DEFUN (reset, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\ +Removes any defaults set for the handle @var{h}. The default figure\n\ +properties \"position\", \"units\", \"windowstyle\" and\n\ +\"paperunits\" and the default axes properties \"position\" and \"units\"\n\ +are not reset.\n\ +@end deftypefn") +{ + int nargin = args.length (); + + if (nargin != 1) + print_usage (); + else + { + // get vector of graphics handles + ColumnVector hcv (args(0).vector_value ()); + + if (! error_state) + { + // loop over graphics objects + for (octave_idx_type n = 0; n < hcv.length (); n++) + gh_manager::get_object (hcv(n)).reset_default_properties (); + } + } + + return octave_value (); +} + DEFUN (set, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\