From e147c3ee7424093ccb4c85245fc3b46304a95899 Mon Sep 17 00:00:00 2001 From: Samuel GOUGEON Date: Sat, 23 Mar 2019 15:49:49 +0100 Subject: [PATCH] * Bugs 16011 16299 fixed: colorbar() failed after plot3d2() & graypolarplot() http://bugzilla.scilab.org/16011 http://bugzilla.scilab.org/16299 Change-Id: I713183aaf5808eb600b87bccae4569c1f95aa2a4 --- scilab/CHANGES.md | 2 ++ scilab/modules/graphics/macros/colorbar.sci | 35 ++++++++++++++------ .../graphics/tests/nonreg_tests/bug_16011.tst | 25 ++++++++++++++ .../modules/graphics/tests/unit_tests/colorbar.tst | 6 ++++ 4 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 scilab/modules/graphics/tests/nonreg_tests/bug_16011.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 7f88751..3edf8db 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -218,6 +218,7 @@ Bug Fixes * [#16003](http://bugzilla.scilab.org/show_bug.cgi?id=16003): Zoom with mouse scroll wheel was broken on simple surfaces. * [#16005](http://bugzilla.scilab.org/show_bug.cgi?id=16005): The `intdec` example was biased and not robust when changing sampling frequencies. * [#16007](http://bugzilla.scilab.org/show_bug.cgi?id=16007): Non-integer index in sparse makes Scilab crash. +* [#16011](http://bugzilla.scilab.org/show_bug.cgi?id=16011): `colorbar(umin, umax)` did not work after `plot3d2`. * [#16012](http://bugzilla.scilab.org/show_bug.cgi?id=16012): `[struct() struct()]` crashed Scilab. * [#16013](http://bugzilla.scilab.org/show_bug.cgi?id=16013): Load previously saved environment with "File/Load environment" menu failed. * [#16014](http://bugzilla.scilab.org/show_bug.cgi?id=16014): after `x.a=1; x(:)=[]` x.a was an empty list. @@ -258,3 +259,4 @@ Bug Fixes * [#16272](http://bugzilla.scilab.org/show_bug.cgi?id=16272): `spzeros(0,n)` and `spzeros(n,0)` were different from `sparse(0,0)`. * [#16275](http://bugzilla.scilab.org/show_bug.cgi?id=16275): `fsolve(x0, fun, tol)` no longer took `tol` into account. * [#16293](http://bugzilla.scilab.org/show_bug.cgi?id=16293): Some demos run in step-by-step console mode(4) did not focus user's attention to the console to proceed. +* [#16299](http://bugzilla.scilab.org/show_bug.cgi?id=16299): After `graypolarplot()`, `colorbar()` displayed an empty ungraduated color bar. diff --git a/scilab/modules/graphics/macros/colorbar.sci b/scilab/modules/graphics/macros/colorbar.sci index a932179..1ea4b2d 100644 --- a/scilab/modules/graphics/macros/colorbar.sci +++ b/scilab/modules/graphics/macros/colorbar.sci @@ -109,19 +109,30 @@ function colorbar(umin, umax, colminmax, fmt) // Default umin, umax, colminmax if Type=="Fec" u = h.data(:,3); + elseif Type=="Plot3d" u = h.data.z + elseif Type=="Fac3d" u = h.data.z; - c = h.data.color; - colorsAreZ = ~isvector(c) - //if colorsAreZ - // // c = U*a+b - // c2 = c-mean(c); - // u2 = u-mean(u); - // k = u~=0; - // colorsAreZ = colorsAreZ & stdev(c(k)./u(k))==0 // Improvement to explore - //end + colorsAreZ = %f; + if or(fieldnames(h.data)=="color") + c = h.data.color; + colorsAreZ = ~isvector(c) + if or(h.color_flag==[2 3 4]) & h.cdata_mapping == "direct" + u = h.data.color + if colminmax == -1 + colminmax = [min(u) max(u)] + end + end + //if colorsAreZ + // // c = U*a+b + // c2 = c-mean(c); + // u2 = u-mean(u); + // k = u~=0; + // colorsAreZ = colorsAreZ & stdev(c(k)./u(k))==0 // Improvement to explore + //end + end if colorsAreZ select h.color_flag case 0 @@ -157,7 +168,8 @@ function colorbar(umin, umax, colminmax, fmt) if ~isdef("umin","l") | type(umin)==0 | umin==[] then if u~=[] if colminmax~=[] & (length(colminmax)>1 | colminmax~=-1) - if Type=="Matplot" + if Type=="Matplot" | .. + Type=="Fac3d" & or(h.color_flag==[2 3 4]) & h.cdata_mapping == "direct" umin = colminmax(1) else if argn(2)<2 @@ -196,7 +208,8 @@ function colorbar(umin, umax, colminmax, fmt) if ~isdef("umax","l") | type(umax)==0 | umax==[] then if u~=[] if colminmax~=[] & colminmax~=-1 - if Type=="Matplot" + if Type=="Matplot" | .. + Type=="Fac3d" & or(h.color_flag==[2 3 4]) & h.cdata_mapping == "direct" umax = colminmax(2) else if argn(2)<2 diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_16011.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_16011.tst new file mode 100644 index 0000000..8901fab --- /dev/null +++ b/scilab/modules/graphics/tests/nonreg_tests/bug_16011.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2019 - Samuel GOUGEON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- TEST WITH GRAPHIC --> +// <-- NO CHECK REF --> + +// <-- Non-regression test for bug 16011 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/16011 +// +// <-- Short Description --> +// colorbar(umin, umax) failed after plot3d2() + +u = linspace(-%pi/2,%pi/2,40); +v = linspace(0,2*%pi,20); +X = cos(u)'*cos(v); +Y = cos(u)'*sin(v); +Z = sin(u)'*ones(v); +plot3d2(X,Y,Z) +assert_checktrue(execstr("colorbar(min(Z), max(Z))", "errcatch")==0); diff --git a/scilab/modules/graphics/tests/unit_tests/colorbar.tst b/scilab/modules/graphics/tests/unit_tests/colorbar.tst index 8422ebe..67e0998 100644 --- a/scilab/modules/graphics/tests/unit_tests/colorbar.tst +++ b/scilab/modules/graphics/tests/unit_tests/colorbar.tst @@ -147,6 +147,12 @@ z = plotSphere(); colorbar(,,[2.97 5]/6); // ticks on [9, 0.2] // colors in [orange, yellow] must match figure #10 ones +// 3.4) after graypolarplot() +clf reset +graypolarplot +colorbar +// Values from 30 to 137. Direct colors = full color map = dark red to white. + // 4) Plot3d // ====== function plotSample() -- 1.7.9.5