# HG changeset patch # User Pantxo Diribarne # Date 1408803123 -7200 # Node ID 4c59f69fa52c034c9bae58198c8ed08260e41815 # Parent 0976f9fccbbda7f165d472fc9ebdc5f358ac2362 figure: define adopted axes "currentaxes" if none is defined (bug #41573) * graphics.in.h (figure::properties::adopt): declare new custom method * graphics.cc (figure::properties::adopt): when adopting an axes, define it as currentaxes if none is already defined * graphics.cc: add %! test for currentaxes update diff -r 0976f9fccbbd -r 4c59f69fa52c libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Thu Aug 21 16:05:09 2014 -0700 +++ b/libinterp/corefcn/graphics.cc Sat Aug 23 16:12:03 2014 +0200 @@ -3672,6 +3672,37 @@ } } +void +figure::properties::adopt (const graphics_handle& h) +{ + base_properties::adopt (h); + + if (! get_currentaxes ().ok ()) + { + graphics_object go = gh_manager::get_object (h); + + if (go.type () == "axes") + set_currentaxes (h.as_octave_value ()); + } +} + +/* +%!test +%! hf1 = figure ("visible", "off"); +%! ax1 = subplot (1,2,1); +%! ax2 = subplot (1,2,2); +%! hf2 = figure ("visible", "off"); +%! unwind_protect +%! set (ax2, "parent", hf2); +%! assert (get (hf2, "currentaxes"), ax2); +%! assert (get (hf1, "currentaxes"), ax1); +%! set (ax1, "parent", hf2); +%! assert (get (hf2, "currentaxes"), ax2); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect +*/ + void figure::properties::set_visible (const octave_value& val) { diff -r 0976f9fccbbd -r 4c59f69fa52c libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Thu Aug 21 16:05:09 2014 -0700 +++ b/libinterp/corefcn/graphics.in.h Sat Aug 23 16:12:03 2014 +0200 @@ -3306,6 +3306,8 @@ } } + void adopt (const graphics_handle& h); + void set_position (const octave_value& val, bool do_notify_toolkit = true);