# HG changeset patch # User Rik # Date 1456265494 28800 # Node ID 030d4d6c2b58e56ef98a38ebc786a4e85ca7342a # Parent 909129eb77c52681efc3e8f3a7997d13c38d3160 Implement figure property "InvertHardCopy" for printing (bug #47230). * graphics.in.h: Change default value of "InvertHardCopy" to "on" to match Matlab. * print.m: Change figure background and top-level axes background colors to white when printing and InvertHardCopy is "on". Restore original colors after print. diff -r 909129eb77c5 -r 030d4d6c2b58 libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Tue Feb 23 15:05:45 2016 -0500 +++ b/libinterp/corefcn/graphics.in.h Tue Feb 23 14:11:34 2016 -0800 @@ -3395,7 +3395,7 @@ string_property filename , "" bool_property graphicssmoothing , "on" bool_property integerhandle S , "on" - bool_property inverthardcopy , "off" + bool_property inverthardcopy , "on" callback_property keypressfcn , Matrix () callback_property keyreleasefcn , Matrix () radio_property menubar , "none|{figure}" diff -r 909129eb77c5 -r 030d4d6c2b58 scripts/plot/util/print.m --- a/scripts/plot/util/print.m Tue Feb 23 15:05:45 2016 -0500 +++ b/scripts/plot/util/print.m Tue Feb 23 14:11:34 2016 -0800 @@ -350,7 +350,7 @@ props(n).h = hobj(n); props(n).name = "units"; props(n).value = {get(hobj(n), "units")}; - set (hobj(n), "units", "data") + set (hobj(n), "units", "data"); endfor ## print() requires axes units = "normalized" @@ -361,7 +361,7 @@ props(m+n).h = hax(n); props(m+n).name = "units"; props(m+n).value = {get(hax(n), "units")}; - set (hax(n), "units", "normalized") + set (hax(n), "units", "normalized"); endfor ## print() requires figure units to be "pixels" @@ -379,14 +379,33 @@ fpos(3:4) = opts.canvas_size; set (opts.figure, "position", fpos); - ## Set figure background to none. - ## This is done both for consistency with Matlab and to eliminate - ## the visible box along the figure's perimeter. - props(m+3).h = opts.figure; - props(m+3).name = "color"; - props(m+3).value{1} = get (props(m+3).h, props(m+3).name); - set (props(m+3).h, "color", "none"); - nfig = m + 3; + ## Implement InvertHardCopy option + do_hardcopy = strcmp (get (opts.figure, "inverthardcopy"), "on"); + + if (do_hardcopy) + ## Set figure background to white. + props(m+3).h = opts.figure; + props(m+3).name = "color"; + props(m+3).value{1} = get (props(m+3).h, props(m+3).name); + set (props(m+3).h, "color", "white"); + nfig = m + 3; + else + nfig = m + 2; + endif + + if (do_hardcopy) + ## Set background to white for all top-level axes objects + hax = findall (opts.figure, "-depth", 1, "type", "axes", + "-not", "tag", "legend"); + m = numel (props); + for n = 1:numel(hax) + props(m+n).h = hax(n); + props(m+n).name = "color"; + props(m+n).value{1} = get(hax(n), "color"); + set (hax(n), "color", "white"); + endfor + nfig += n; + endif if (opts.force_solid != 0) h = findall (opts.figure, "-property", "linestyle");