Mercurial > hg > octave-lyh
annotate scripts/plot/private/__patch__.m @ 13954:2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
* plot/private/__patch__.m (__patch__): Predefine h output argument. Support
CDATA specified in RGB format.
(setdata): Removed unused variables.
(setvertexdata): Likewise. Support case where [x|y]data are specified as row
vectors.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Mon, 28 Nov 2011 22:19:45 +0000 |
parents | 425b861ae66f |
children | 5be545210fe3 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 John W. Eaton, Shai Ayal, Kai Habel |
6807 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6807 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6807 | 18 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8190
diff
changeset
|
19 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8190
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{h}, @var{fail}] =} __patch__ (@var{p}, @dots{}) |
6895 | 21 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8190
diff
changeset
|
22 ## @end deftypefn |
6895 | 23 |
24 ## __patch__ (p, x, y, c) | |
25 ## Create patch object from x and y with color c and parent p. | |
6807 | 26 ## Return handle to patch object. |
27 | |
28 ## Author: Kai Habel | |
29 | |
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
|
30 function [h, failed] = __patch__ (p, varargin) |
7191 | 31 |
13954
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
32 h = NaN; |
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
|
33 failed = false; |
6885 | 34 |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
35 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
|
36 |
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
|
37 if (isempty (varargin)) |
13809
425b861ae66f
use compatible defaults for patch function
John W. Eaton <jwe@octave.org>
parents:
13808
diff
changeset
|
38 args = {"xdata", [0; 1; 0], "ydata", [1; 1; 0], "facecolor", [0, 0, 0]}; |
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
|
39 args = setvertexdata (args); |
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
|
40 elseif (isstruct (varargin{1})) |
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
|
41 if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces")) |
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
|
42 args{1} = "faces"; |
9111 | 43 args{2} = getfield(varargin{1}, "faces"); |
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
|
44 args{3} = "vertices"; |
9111 | 45 args{4} = getfield(varargin{1}, "vertices"); |
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
|
46 args{5} = "facevertexcdata"; |
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
|
47 if (isfield (varargin{1}, "facevertexcdata")) |
10549 | 48 args{6} = getfield(varargin{1}, "facevertexcdata"); |
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
|
49 else |
10549 | 50 args{6} = []; |
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
|
51 endif |
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
|
52 args = [args; varargin(2:end)]; |
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
|
53 args = setdata (args); |
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
|
54 else |
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
|
55 failed = true; |
7020 | 56 endif |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
57 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
|
58 if (nargin < 3 || ! is_numeric_arg(2)) |
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
|
59 failed = true; |
7020 | 60 else |
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
|
61 |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
62 if (nargin > 4 && all (is_numeric_arg(1:4))) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
63 x = varargin{1}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
64 y = varargin{2}; |
10549 | 65 z = varargin{3}; |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
66 c = varargin{4}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
67 iarg = 5; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
68 elseif (nargin > 3 && all (is_numeric_arg(1:3))) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
69 x = varargin{1}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
70 y = varargin{2}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
71 iarg = 4; |
13308
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
72 if (rem (nargin - iarg, 2) == 1) |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
73 c = varargin {iarg}; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
74 z = varargin{3}; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
75 iarg = 5; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
76 else |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
77 z = []; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
78 c = varargin{3}; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
79 endif |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
80 elseif (nargin > 2 && all (is_numeric_arg(1:2))) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
81 x = varargin{1}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
82 y = varargin{2}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
83 z = []; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
84 iarg = 3; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
85 if (rem (nargin - iarg, 2) == 1) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
86 c = varargin {iarg}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
87 iarg++; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
88 else |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
89 c = []; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
90 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
|
91 endif |
6885 | 92 |
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
|
93 if (isvector (x)) |
10549 | 94 x = x(:); |
95 y = y(:); | |
96 z = z(:); | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
97 if (isnumeric (c)) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
98 if (isvector (c) && numel (c) == numel (x)) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
99 c = c(:); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
100 elseif (size (c, 1) != numel (x) && size (c, 2) == numel (x)) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
101 c = c.'; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
102 endif |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
103 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
|
104 endif |
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
|
105 args{1} = "xdata"; |
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 args{2} = x; |
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
|
107 args{3} = "ydata"; |
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
|
108 args{4} = y; |
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
|
109 args{5} = "zdata"; |
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
|
110 args{6} = z; |
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
|
111 |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
112 if (isnumeric (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
|
113 |
10549 | 114 if (ndims (c) == 3 && size (c, 2) == 1) |
115 c = permute (c, [1, 3, 2]); | |
116 endif | |
6885 | 117 |
10549 | 118 if (isvector (c) && numel (c) == columns (x)) |
119 if (isnan (c)) | |
120 args{7} = "facecolor"; | |
121 args{8} = [1, 1, 1]; | |
122 args{9} = "cdata"; | |
123 args{10} = c; | |
124 elseif (isnumeric (c)) | |
125 args{7} = "facecolor"; | |
126 args{8} = "flat"; | |
127 args{9} = "cdata"; | |
128 args{10} = c; | |
129 else | |
130 error ("patch: color value not valid"); | |
131 endif | |
13954
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
132 elseif (isvector (c) && numel (c) == 3) |
10549 | 133 args{7} = "facecolor"; |
13808
d5bfaa582eaa
correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents:
13779
diff
changeset
|
134 args{8} = c; |
10549 | 135 args{9} = "cdata"; |
13808
d5bfaa582eaa
correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents:
13779
diff
changeset
|
136 args{10} = []; |
13954
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
137 elseif (ndims (c) == 3 && size (c, 3) == 3) |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
138 ## CDATA is specified as RGB data |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
139 if ((size (c, 1) == 1 && size (c, 2) == 1) ... |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
140 || (size (c, 1) == 1 && size (c, 2) == columns (x))) |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
141 ## Single patch color or per-face color |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
142 args{7} = "facecolor"; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
143 args{8} = "flat"; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
144 args{9} = "cdata"; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
145 args{10} = c; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
146 elseif (size (c, 1) == rows (x) && size (c, 2) == columns (x)) |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
147 ## Per-vertex color |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
148 args{7} = "facecolor"; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
149 args{8} = "interp"; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
150 args{9} = "cdata"; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
151 agrs{10} = c; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
152 else |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
153 error ("patch: color value not valid"); |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
154 endif |
10549 | 155 else |
156 ## Color Vectors | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
157 if (isempty (c)) |
10549 | 158 args{7} = "facecolor"; |
159 args{8} = "interp"; | |
160 args{9} = "cdata"; | |
161 args{10} = []; | |
13308
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
162 elseif (isequal (size (c), size (x)) && isequal (size (c), size (y))) |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
163 args{7} = "facecolor"; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
164 args{8} = "interp"; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
165 args{9} = "cdata"; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
166 args{10} = c; |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
167 else |
13308
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
168 error ("patch: size of x, y, and c must be equal"); |
10549 | 169 endif |
170 endif | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
171 elseif (ischar (c) && rem (nargin - iarg, 2) == 0) |
10549 | 172 ## Assume that any additional argument over an even number is |
173 ## color string. | |
174 args{7} = "facecolor"; | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
175 args{8} = tolower (c); |
10549 | 176 args{9} = "cdata"; |
177 args{10} = []; | |
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
|
178 else |
10549 | 179 args{7} = "facecolor"; |
180 args{8} = [0, 1, 0]; | |
181 args{9} = "cdata"; | |
182 args{10} = []; | |
6925 | 183 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
|
184 |
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
|
185 args = [args, varargin(iarg:end)]; |
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
|
186 args = setvertexdata (args); |
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
|
187 endif |
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
|
188 else |
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
|
189 args = varargin; |
12931
cefd568ea073
Replace function handles with function names in cellfun calls for 15% speedup.
Rik <octave@nomad.inbox5.com>
parents:
11589
diff
changeset
|
190 if (any (strcmpi (args, "faces") | strcmpi (args, "vertices"))) |
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
|
191 args = setdata (args); |
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
|
192 else |
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
|
193 args = setvertexdata (args); |
6885 | 194 endif |
195 endif | |
196 | |
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
|
197 if (!failed) |
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
|
198 h = __go_patch__ (p, args {:}); |
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
|
199 |
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
|
200 ## Setup listener functions |
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
|
201 addlistener (h, "xdata", @update_data); |
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
|
202 addlistener (h, "ydata", @update_data); |
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
|
203 addlistener (h, "zdata", @update_data); |
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
|
204 addlistener (h, "cdata", @update_data); |
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
|
205 |
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
|
206 addlistener (h, "faces", @update_fvc); |
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
|
207 addlistener (h, "vertices", @update_fvc); |
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
|
208 addlistener (h, "facevertexcdata", @update_fvc); |
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
|
209 endif |
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
|
210 endfunction |
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
|
211 |
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
|
212 function args = delfields(args, flds) |
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
|
213 idx = cellfun (@(x) any (strcmpi (x, flds)), args); |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
214 if (rows (idx) == 1) |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
215 idx = idx | [false, idx(1:end-1)]; |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
216 else |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
217 idx = idx | [false; idx(1:end-1)]; |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
218 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
|
219 args (idx) = []; |
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
|
220 endfunction |
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
|
221 |
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
|
222 function args = setdata (args) |
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
|
223 args = delfields (args, {"xdata", "ydata", "zdata", "cdata"}); |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
224 ## Remove the readonly fields as well |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
225 args = delfields (args, {"type", "uicontextmenu"}); |
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
|
226 nargs = length (args); |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
227 idx = find (strcmpi (args, "faces"), 1, "last") + 1; |
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
|
228 if (idx > nargs) |
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
|
229 faces = []; |
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
|
230 else |
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
|
231 faces = args {idx}; |
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
|
232 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
233 idx = find (strcmpi (args, "vertices"), 1, "last") + 1; |
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
|
234 if (idx > nargs) |
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
|
235 vert = []; |
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
|
236 else |
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
|
237 vert = args {idx}; |
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
|
238 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
239 idx = find (strcmpi (args, "facevertexcdata"), 1, "last") + 1; |
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
|
240 if (isempty(idx) || idx > nargs) |
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
|
241 fvc = []; |
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
|
242 else |
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
|
243 fvc = args {idx}; |
6807 | 244 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
245 idx = find (strcmpi (args, "facecolor"), 1, "last") + 1; |
9118
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
246 if (isempty(idx) || idx > nargs) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
247 if (!isempty (fvc)) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
248 fc = "flat"; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
249 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
250 fc = [0, 1, 0]; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
251 endif |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
252 args = {"facecolor", fc, args{:}}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
253 endif |
6807 | 254 |
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
|
255 nc = size (faces, 1); |
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
|
256 idx = faces .'; |
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
|
257 t1 = isnan (idx); |
13779
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
258 for i = find (any (t1)) |
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
259 first_idx_in_column = find (t1(:,i), 1); |
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
260 idx(first_idx_in_column:end,i) = idx(first_idx_in_column-1,i); |
13778
b0b6aa4f7302
__patch__: correctly replace NaN values with last non-NaN value in column
John W. Eaton <jwe@octave.org>
parents:
13698
diff
changeset
|
261 endfor |
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
|
262 x = reshape (vert(:,1)(idx), size (idx)); |
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
|
263 y = reshape (vert(:,2)(idx), size (idx)); |
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
|
264 if (size(vert,2) > 2) |
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
|
265 z = reshape (vert(:,3)(idx), size (idx)); |
6807 | 266 else |
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
|
267 z = []; |
6807 | 268 endif |
6886 | 269 |
11160
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
270 if (size(fvc, 1) == nc || size (fvc, 1) == 1) |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
271 c = reshape (fvc, [1, size(fvc)]); |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
272 else |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
273 if (size(fvc, 2) == 3) |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
274 c = cat(3, reshape (fvc(idx, 1), size(idx)), |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
275 reshape (fvc(idx, 2), size(idx)), |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
276 reshape (fvc(idx, 3), size(idx))); |
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
|
277 else |
11187
0a8e554494c9
__patch__.m: Don't index an empty array; bug introduced by changeset 11175.
Ben Abbott <bpabbott@mac.com>
parents:
11160
diff
changeset
|
278 c = []; |
7020 | 279 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
|
280 endif |
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
|
281 args = {"xdata", x, "ydata", y, "zdata", z, "cdata", c, args{:}}; |
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
|
282 endfunction |
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
|
283 |
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
|
284 function args = setvertexdata (args) |
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
|
285 args = delfields (args, {"vertices", "faces", "facevertexcdata"}); |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
286 ## Remove the readonly fields as well |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
287 args = delfields (args, {"type", "uicontextmenu"}); |
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
|
288 nargs = length (args); |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
289 idx = find (strcmpi (args, "xdata"), 1, "last") + 1; |
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
|
290 if (idx > nargs) |
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
|
291 x = []; |
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
|
292 else |
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
|
293 x = args {idx}; |
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
|
294 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
295 idx = find (strcmpi (args, "ydata"), 1, "last") + 1; |
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
|
296 if (idx > nargs) |
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
|
297 y = []; |
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
|
298 else |
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
|
299 y = args {idx}; |
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
|
300 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
301 idx = find (strcmpi (args, "zdata"), 1, "last") + 1; |
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
|
302 if (isempty(idx) || idx > nargs) |
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
|
303 z = []; |
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
|
304 else |
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
|
305 z = args {idx}; |
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
|
306 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
307 idx = find (strcmpi (args, "cdata"), 1, "last") + 1; |
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
|
308 if (isempty(idx) || idx > nargs) |
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
|
309 c = []; |
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
|
310 else |
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
|
311 c = args {idx}; |
7020 | 312 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
313 idx = find (strcmpi (args, "facecolor"), 1, "last") + 1; |
9118
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
314 if (isempty(idx) || idx > nargs) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
315 if (!isempty (c)) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
316 fc = "flat"; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
317 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
318 fc = [0, 1, 0]; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
319 endif |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
320 args = {"facecolor", fc, args{:}}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
321 endif |
7020 | 322 |
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
|
323 [nr, nc] = size (x); |
13954
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
324 if (nr == 1 && nc > 1) |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
325 nr = nc; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
326 nc = 1; |
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
327 end |
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
|
328 if (!isempty (z)) |
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
|
329 vert = [x(:), y(:), z(:)]; |
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
|
330 else |
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
|
331 vert = [x(:), y(:)]; |
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
|
332 endif |
13954
2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13809
diff
changeset
|
333 faces = reshape (1:numel(x), nr, nc); |
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
|
334 faces = faces'; |
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
|
335 |
11160
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
336 if (ndims (c) == 3) |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
337 fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3)); |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
338 elseif (isvector (c)) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
339 fvc = 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
|
340 else |
13698
276bb0dd9d24
patch: ensure facevertexcdata has correct shape
John W. Eaton <jwe@octave.org>
parents:
13308
diff
changeset
|
341 fvc = c.'(:); |
7020 | 342 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
343 |
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
|
344 args = {"faces", faces, "vertices", vert, "facevertexcdata", fvc, args{:}}; |
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
|
345 endfunction |
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
|
346 |
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
|
347 function update_data (h, d) |
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
|
348 update_handle (h, false); |
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
|
349 endfunction |
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
|
350 |
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
|
351 function update_fvc (h, d) |
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
|
352 update_handle (h, true); |
6807 | 353 endfunction |
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
|
354 |
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
|
355 function update_handle (h, isfv) |
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
|
356 persistent recursive = false; |
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
|
357 |
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
|
358 if (! recursive) |
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
|
359 recursive = true; |
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
|
360 f = get (h); |
10524
1c6ff93c025a
Reimplement the other discrete distribution functions using lookup
David Bateman <dbateman@free.fr>
parents:
9896
diff
changeset
|
361 if (isfv) |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
362 set (h, setdata ([fieldnames(f), struct2cell(f)].'(:)){:}); |
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
|
363 else |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
364 set (h, setvertexdata ([fieldnames(f), struct2cell(f)].'(:)){:}); |
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
|
365 endif |
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
|
366 recursive = false; |
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
|
367 endif |
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
|
368 endfunction |