Mercurial > octave
changeset 33178:4ec97d8770ff
patch: Ensure geometry defining properties are processed first (bug #65421)
* scripts/plot/draw/private/__patch__.m: Add block to shift any geometry
defininig properties to front of input argument list, otherwise preserving
order.
* scripts/plot/draw/patch.m: Add BIST verifying that the same geometry is
created with CData occurring before Faces.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Thu, 07 Mar 2024 16:12:15 -0500 |
parents | 9431666518fe |
children | ed176bb5f7e6 a959fc381fee |
files | scripts/plot/draw/patch.m scripts/plot/draw/private/__patch__.m |
diffstat | 2 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/draw/patch.m Fri Mar 08 02:28:37 2024 +0100 +++ b/scripts/plot/draw/patch.m Thu Mar 07 16:12:15 2024 -0500 @@ -303,6 +303,24 @@ %! close (hf); %! end_unwind_protect +%!test <*65421> +%! hf = figure ("visible", "off"); +%! unwind_protect +%! h1 = patch ("Vertices",[0, 0; 0, 1; 1, 0;1, 1], ... +%! "Faces", [1, 2, 3; 2, 3, 4], "CData", 1); +%! h2 = patch ("Vertices",[0, 0; 0, 1; 1, 0;1, 1], "CData", 1, ... +%! "Faces", [1, 2, 3; 2, 3, 4]); +%! h1_data = get (h1); +%! h2_data = get (h2); +%! assert ({h1_data.xdata, h1_data.ydata}, ... +%! {[0, 0; 0, 1; 1, 1], [0, 1; 1, 0; 0, 1]}); +%! assert ({h1_data.xdata, h1_data.ydata}, {h2_data.xdata, h2_data.ydata}); +%! assert (h1_data.faces, [1, 2, 3; 4, 5, 6]); +%! assert (h1_data.faces, h2_data.faces); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + ## Test input validation %!error <invalid color specification C> patch (1, 1, 'x') %!error <invalid TrueColor data C> patch (1, 1, rand (1,2,3))
--- a/scripts/plot/draw/private/__patch__.m Fri Mar 08 02:28:37 2024 +0100 +++ b/scripts/plot/draw/private/__patch__.m Thu Mar 07 16:12:15 2024 -0500 @@ -176,6 +176,16 @@ args = varargin; endif + ## All args now Property/Value pairs. + ## Ensure geometry properties come before other properties (see bug #65421). + geom_props = {"xdata", "ydata", "zdata", "faces", "vertices"}; + geom_args = or (cellfun (@strcmpi, {args(1:2:end)}, geom_props, ... + "UniformOutput", false){:}); + neworder = zeros (size (args)); + neworder(1:2:end) = [find(geom_args), find(! geom_args)] * 2 - 1; + neworder(2:2:end) = neworder(1:2:end) + 1; + args = args(neworder); + if (isempty (p)) p = gca (); endif