changeset 18528:9c8321ea6f58

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().
author Rik <rik@octave.org>
date Thu, 27 Feb 2014 09:56:47 -0800
parents c936beeda029
children f958e8cd6348
files scripts/plot/util/copyobj.m
diffstat 1 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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 ();