Mercurial > hg > octave-avbm
changeset 10289:4b124317dc38
base_properties::set_children: account for hidden children
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 09 Feb 2010 20:58:55 -0500 |
parents | 5e972e2deffe |
children | 1756b3035282 |
files | src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 67 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2010-02-09 John W. Eaton <jwe@octave.org> + * graphics.cc, graphics.h.in + (base_properties::get_hidden_children): New function. + (base_properties::get_children_internal): New function. + (base_properties::get_children): Call get_children_internal to + do the work. + (base_properties::set_children): Incorporate maybe_set_children + function here. Account for hidden children. + (maybe_set_children): Delete. + * c-file-ptr-stream.h (c_file_ptr_buf::buf_close): Rename from close. (c_file_ptr_buf::file_close): Rename from fclose. (c_file_ptr_stream::stream_close): Rename from close.
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -1850,41 +1850,6 @@ } // --------------------------------------------------------------------- -static Matrix -maybe_set_children (const Matrix& kids, const octave_value& val) -{ - const Matrix new_kids = val.matrix_value (); - - bool ok = true; - - if (! error_state) - { - if (kids.numel () == new_kids.numel ()) - { - Matrix t1 = kids; - Matrix t2 = new_kids; - - t1 = t1.sort (); - t2 = t2.sort (); - - if (t1 != t2) - ok = false; - } - else - ok = false; - - if (! ok) - error ("set: new children must be a permutation of existing children"); - } - else - { - ok = false; - error ("set: expecting children to be array of graphics handles"); - } - - return ok ? new_kids : kids; -} - void base_properties::set_from_list (base_graphics_object& obj, property_list& defaults) @@ -2048,7 +2013,36 @@ void base_properties::set_children (const octave_value& val) { - children = maybe_set_children (children, val); + const Matrix new_kids = val.matrix_value (); + + bool ok = true; + + if (! error_state) + { + const Matrix visible_kids = get_children (); + + if (visible_kids.numel () == new_kids.numel ()) + { + Matrix t1 = visible_kids.sort (); + Matrix t2 = new_kids.sort (); + + if (t1 != t2) + ok = false; + } + else + ok = false; + + if (! ok) + error ("set: new children must be a permutation of existing children"); + } + else + { + ok = false; + error ("set: expecting children to be array of graphics handles"); + } + + if (ok) + children = new_kids.stack (get_hidden_children ()); } void @@ -2920,7 +2914,7 @@ } Matrix -base_properties::get_children (void) const +base_properties::get_children_internal (bool return_hidden) const { Matrix retval = children; @@ -2938,13 +2932,33 @@ graphics_handle kid = children (i); if (gh_manager::is_handle_visible (kid)) - retval(k++) = children(i); + { + if (! return_hidden) + retval(k++) = children(i); + } + else + { + if (return_hidden) + retval(k++) = children(i); + } } retval.resize (k, 1); } - return retval;; + return retval; +} + +Matrix +base_properties::get_children (void) const +{ + return get_children_internal (false); +} + +Matrix +base_properties::get_hidden_children (void) const +{ + return get_children_internal (true); } inline Matrix
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -1859,6 +1859,8 @@ Matrix get_all_children (void) const { return children; } + Matrix get_hidden_children (void) const; + void set_children (const octave_value& val); void set_modified (const octave_value& val) { set___modified__ (val); } @@ -1961,6 +1963,9 @@ { insert_property (name, property (&p, true)); } virtual void init (void) { } + +private: + Matrix get_children_internal (bool return_hidden) const; }; class OCTINTERP_API base_graphics_object