Mercurial > hg > octave-lojdl
changeset 10722:755fcb5baad3
Add the reset built function
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 23 Jun 2010 11:23:32 +0200 |
parents | 998d7ba68009 |
children | e5a80597792b |
files | src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 146 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2010-06-23 David Bateman <dbateman@free.fr> + + * graphics.cc (void root_figure::reset_default_properties (void), + void figure::reset_default_properties (void), + void figure::reset_default_properties (void), + Freset): New functions. + * graphics.h.in (void graphics_object:reset_default_properies (void), + virtual void base_graphics_object:reset_default_properies (void)): + New functions. + (void root_figure::reset_default_properties (void), + void figure::reset_default_properties (void), + void figure::reset_default_properties (void)): Declarations. + 2010-06-21 Rik <octave@nomad.inbox5.com> * DLD-FUNCTIONS/dlmread.cc: Fix spreadsheet style range option.
--- 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\
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -2223,6 +2223,17 @@ virtual void remove_all_listeners (void); + virtual void reset_default_properties (void) + { + if (valid_object ()) + { + std::string msg = (type () + "::reset_default_properties"); + gripe_not_implemented (msg.c_str ()); + } + else + error ("base_graphics_object::default: invalid graphics object"); + } + protected: // A reference count. int count; @@ -2409,6 +2420,9 @@ listener_mode mode = POSTSET) { rep->delete_property_listener (nm, v, mode); } + void reset_default_properties (void) + { rep->reset_default_properties (); } + private: base_graphics_object *rep; }; @@ -2548,6 +2562,8 @@ bool valid_object (void) const { return true; } + void reset_default_properties (void); + private: property_list default_properties; @@ -2752,6 +2768,8 @@ bool valid_object (void) const { return true; } + void reset_default_properties (void); + private: property_list default_properties; }; @@ -3199,6 +3217,8 @@ bool valid_object (void) const { return true; } + void reset_default_properties (void); + private: property_list default_properties; };