# HG changeset patch # User Rik # Date 1393523807 28800 # Node ID 9c8321ea6f585749685b0cacab396b2d87104883 # Parent c936beeda029ef4c7a8b70ce8437c0b0eed813b2 copyobj.m: Arrange original and copied plot side-by-side in demos. * copyobj.m: Arrange original and copied plot side-by-side in demos. Workaround bug where set (h, 'position', ...) is not respected in FLTK by multiple calls to drawnow(). diff -r c936beeda029 -r 9c8321ea6f58 scripts/plot/util/copyobj.m --- a/scripts/plot/util/copyobj.m Tue Feb 25 16:58:42 2014 +0100 +++ b/scripts/plot/util/copyobj.m Thu Feb 27 09:56:47 2014 -0800 @@ -72,9 +72,11 @@ endfunction +## Absurd number of drawnow() function calls in demos is due to problem +## with FLTK backend which is not respecting the set ('position') call. + %!demo -%! hdl = figure (1234); -%! clf; +%! hobj = figure ('name', 'Original', 'numbertitle', 'off'); %! hold on; %! x = 1:10; %! y = x.^2; @@ -84,11 +86,20 @@ %! set (hg, 'marker', '^', 'markerfacecolor', rand (1,3)); %! plot (x, y2, 'ok-'); %! legend ('errorbar', 'line'); -%! hnew = copyobj (hdl); +%! drawnow (); +%! pos = get (hobj, 'position'); +%! scrn = get (0, 'screensize'); +%! set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); +%! drawnow (); +%! hnew = copyobj (hobj); +%! drawnow (); +%! set (hnew, 'name', 'Copyobj'); +%! drawnow (); +%! set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); +%! drawnow (); %!demo -%! hdl = figure (1234); -%! clf; +%! hobj = figure ('name', 'Original', 'numbertitle', 'off'); %! subplot (2,2,1); %! hold on; %! contourf (rand (10, 10)); @@ -104,7 +115,17 @@ %! imagesc (rand (30, 30)); %! text (15, 15, 'Rotated text', ... %! 'HorizontAlalignment', 'Center', 'Rotation', 30); -%! hnew = copyobj (hdl); +%! drawnow (); +%! pos = get (hobj, 'position'); +%! scrn = get (0, 'screensize'); +%! set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); +%! drawnow (); +%! hnew = copyobj (hobj); +%! drawnow (); +%! set (hnew, 'name', 'Copyobj'); +%! drawnow (); +%! set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); +%! drawnow (); %!testif HAVE_MAGICK %! toolkit = graphics_toolkit ();