annotate scripts/plot/draw/private/__patch__.m @ 30634:36d940c58c2e

Improve input validation for patch function (bug #61782) * patch.m: Avoid call to gca() before executing __patch__ as input validation may stop patch from being created leaving empty figure and axes objects. Add BIST tests for input validation. * __patch__.m: Remove second output of function (failed). Detect 3-input case with bad color specification and issue and emit an error. Add comments to clarify code about which input combination is being processed in long if/elseif tree. Call gca() if patch is validated but no axes has been specified. * fill.m: Re-write call to __patch__ to match new function with only one output.
author Rik <rik@octave.org>
date Tue, 11 Jan 2022 12:17:16 -0800
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30379
diff changeset
3 ## Copyright (C) 2007-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
7 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
8 ## This file is part of Octave.
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
14 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
19 ##
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6925
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
25
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20735
diff changeset
27 ## @deftypefn {} {[@var{h}, @var{fail}] =} __patch__ (@var{p}, @dots{})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
28 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8190
diff changeset
29 ## @end deftypefn
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
30
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
31 ## __patch__ (p, x, y, c)
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6886
diff changeset
32 ## Create patch object from x and y with color c and parent p.
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
33 ## Return handle to patch object.
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents:
diff changeset
34
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
35 function h = __patch__ (p, varargin)
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
36
13954
2ebbc6c9961b [Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13809
diff changeset
37 h = NaN;
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
38 nargin = nargin - 1;
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
39
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
40 is_numeric_arg = cellfun (@isnumeric, varargin);
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
41
13115
cd808de114c1 Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents: 12931
diff changeset
42 if (isempty (varargin))
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
43 args = {};
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
44 elseif (is_numeric_arg(1))
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
45 if (nargin < 3 || ! is_numeric_arg(2))
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
46 print_usage ("patch");
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
47 endif
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
48
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
49 if (nargin >= 4 && all (is_numeric_arg(1:4)))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
50 x = varargin{1};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
51 y = varargin{2};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
52 z = varargin{3};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
53 c = varargin{4};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
54 iarg = 5;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
55 elseif (nargin >= 3 && all (is_numeric_arg(1:3)))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
56 x = varargin{1};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
57 y = varargin{2};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
58 if (nargin > 3 && iscolorspec (varargin{4}))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
59 z = varargin{3};
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
60 c = varargin{4};
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
61 iarg = 5;
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
62 else
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
63 z = [];
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
64 c = varargin{3};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
65 iarg = 4;
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
66 endif
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
67 elseif (nargin >= 3 && all (is_numeric_arg(1:2)))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
68 x = varargin{1};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
69 y = varargin{2};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
70 z = [];
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
71 if (iscolorspec (varargin{3}))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
72 c = varargin{3};
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
73 iarg = 4;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
74 elseif (nargin == 3)
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
75 error ("patch: invalid color specification C");
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
76 else
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
77 c = [];
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
78 iarg = 3;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
79 endif
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
80 endif
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
81
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
82 if (isvector (x))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
83 x = x(:);
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
84 y = y(:);
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
85 z = z(:);
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
86 if (isnumeric (c))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
87 if (isvector (c))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
88 if (isequal (size (c), [1, 3]))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
89 ## Do nothing, this is a single RGB color specification
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
90 elseif (numel (c) == numel (x))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
91 c = c(:);
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
92 endif
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
93 elseif (rows (c) != numel (x) && columns (c) == numel (x))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
94 c = c.';
13299
e9f6a6edec42 Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents: 13256
diff changeset
95 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
96 endif
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
97 endif
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
98 args{1} = "xdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
99 args{2} = x;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
100 args{3} = "ydata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
101 args{4} = y;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
102 args{5} = "zdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
103 args{6} = z;
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
104
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
105 if (isnumeric (c) && ! isempty (c))
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
106
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
107 if (ndims (c) == 3 && columns (c) == 1)
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
108 c = permute (c, [1, 3, 2]);
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
109 endif
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
110
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
111 if (isvector (c) && numel (c) == columns (x))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
112 ## One color per face
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
113 if (isnan (c))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
114 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
115 args{8} = [1, 1, 1];
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
116 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
117 args{7} = "facecolor";
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
118 args{8} = "flat";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
119 endif
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
120 args{9} = "cdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
121 args{10} = c;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
122 elseif (isrow (c) && numel (c) == 3)
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
123 ## One RGB color
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
124 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
125 args{8} = c;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
126 args{9} = "cdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
127 args{10} = [];
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
128 elseif (ndims (c) == 3 && size (c, 3) == 3)
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
129 ## CDATA is specified as 3-D RGB data
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
130 if ((rows (c) == 1 && columns (c) == 1) ...
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
131 || (rows (c) == 1 && columns (c) == columns (x)))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
132 ## Single patch color or per-face color
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
133 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
134 args{8} = "flat";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
135 args{9} = "cdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
136 args{10} = c;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
137 elseif (rows (c) == rows (x) && columns (c) == columns (x))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
138 ## Per-vertex color
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
139 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
140 args{8} = "interp";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
141 args{9} = "cdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
142 args{10} = c;
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
143 else
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
144 error ("patch: invalid TrueColor data C");
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
145 endif
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
146 else
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
147 ## Color vectors
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
148 if (isempty (c))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
149 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
150 args{8} = "interp";
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
151 args{9} = "cdata";
13808
d5bfaa582eaa correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents: 13779
diff changeset
152 args{10} = [];
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
153 elseif (size_equal (c, x) && size_equal (c, y))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
154 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
155 args{8} = "interp";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
156 args{9} = "cdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
157 args{10} = c;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
158 else
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
159 error ("patch: size of X, Y, and C must be equal");
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10524
diff changeset
160 endif
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6895
diff changeset
161 endif
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
162 elseif (iscolorspec (c))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
163 ## Color specification is a string
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
164 args{7} = "facecolor";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
165 args{8} = tolower (c);
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
166 args{9} = "cdata";
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
167 args{10} = [];
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
168 elseif (! isempty (c))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
169 error ("patch: invalid color specification C");
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
170 endif
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
171
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
172 args = [args, varargin(iarg:end)];
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
173
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
174 else
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
175 ## "Property"/Value pair input
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
176 args = varargin;
6885
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
177 endif
987a7bf45c99 [project @ 2007-09-10 20:51:09 by jwe]
jwe
parents: 6807
diff changeset
178
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
179 if (isempty (p))
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
180 p = gca ();
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
181 endif
30634
36d940c58c2e Improve input validation for patch function (bug #61782)
Rik <rik@octave.org>
parents: 30564
diff changeset
182 h = __go_patch__ (p, args{:});
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21261
diff changeset
183
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
184 endfunction
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21261
diff changeset
185
21801
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
186 function retval = iscolorspec (arg)
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30186
diff changeset
187
21801
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
188 retval = false;
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
189 if (ischar (arg))
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
190 persistent colors = {"y", "yellow", "r", "red", "m", "magenta", ...
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
191 "c", "cyan", "g", "green", "b", "blue", ...
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
192 "w", "white", "k", "black"};
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
193 if (any (strcmpi (arg, colors)))
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
194 retval = true;
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
195 endif
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
196 endif
30379
363fb10055df maint: Style check m-files ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30186
diff changeset
197
21801
4acfe6a99a9f Improve parsing of input arguments in __patch__.m (bug #48038).
mmuetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
198 endfunction