comparison libinterp/corefcn/graphics.cc @ 19078:4c59f69fa52c

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
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sat, 23 Aug 2014 16:12:03 +0200
parents da7d9e4bda8c
children 1288a2f27769
comparison
equal deleted inserted replaced
19075:0976f9fccbbd 19078:4c59f69fa52c
3669 } 3669 }
3670 3670
3671 currentaxes = new_currentaxes; 3671 currentaxes = new_currentaxes;
3672 } 3672 }
3673 } 3673 }
3674
3675 void
3676 figure::properties::adopt (const graphics_handle& h)
3677 {
3678 base_properties::adopt (h);
3679
3680 if (! get_currentaxes ().ok ())
3681 {
3682 graphics_object go = gh_manager::get_object (h);
3683
3684 if (go.type () == "axes")
3685 set_currentaxes (h.as_octave_value ());
3686 }
3687 }
3688
3689 /*
3690 %!test
3691 %! hf1 = figure ("visible", "off");
3692 %! ax1 = subplot (1,2,1);
3693 %! ax2 = subplot (1,2,2);
3694 %! hf2 = figure ("visible", "off");
3695 %! unwind_protect
3696 %! set (ax2, "parent", hf2);
3697 %! assert (get (hf2, "currentaxes"), ax2);
3698 %! assert (get (hf1, "currentaxes"), ax1);
3699 %! set (ax1, "parent", hf2);
3700 %! assert (get (hf2, "currentaxes"), ax2);
3701 %! unwind_protect_cleanup
3702 %! close (hf);
3703 %! end_unwind_protect
3704 */
3674 3705
3675 void 3706 void
3676 figure::properties::set_visible (const octave_value& val) 3707 figure::properties::set_visible (const octave_value& val)
3677 { 3708 {
3678 std::string s = val.string_value (); 3709 std::string s = val.string_value ();