Mercurial > hg > octave-lyh
annotate scripts/plot/private/__patch__.m @ 13808:d5bfaa582eaa
correctly handle RGB color spec for patch object
* __patch__.m: Set facecolor from RGB color spec
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 03 Nov 2011 16:14:28 -0400 |
parents | 7c0fcabd1a66 |
children | 425b861ae66f |
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 |
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
|
32 failed = false; |
6885 | 33 |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
34 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
|
35 |
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
|
36 if (isempty (varargin)) |
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 args = {"xdata", [0; 1; 1], "ydata", [0; 0; 1], "facecolor", "blue"}; |
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
|
38 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
|
39 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
|
40 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
|
41 args{1} = "faces"; |
9111 | 42 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
|
43 args{3} = "vertices"; |
9111 | 44 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
|
45 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
|
46 if (isfield (varargin{1}, "facevertexcdata")) |
10549 | 47 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
|
48 else |
10549 | 49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 failed = true; |
7020 | 55 endif |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
56 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
|
57 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
|
58 failed = true; |
7020 | 59 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
|
60 |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
61 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
|
62 x = varargin{1}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
63 y = varargin{2}; |
10549 | 64 z = varargin{3}; |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
65 c = varargin{4}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
66 iarg = 5; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
67 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
|
68 x = varargin{1}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
69 y = varargin{2}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
70 iarg = 4; |
13308
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
71 if (rem (nargin - iarg, 2) == 1) |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
72 c = varargin {iarg}; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
73 z = varargin{3}; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
74 iarg = 5; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
75 else |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
76 z = []; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
77 c = varargin{3}; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
78 endif |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
79 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
|
80 x = varargin{1}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
81 y = varargin{2}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
82 z = []; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
83 iarg = 3; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
84 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
|
85 c = varargin {iarg}; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
86 iarg++; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
87 else |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
88 c = []; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
89 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
|
90 endif |
6885 | 91 |
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
|
92 if (isvector (x)) |
10549 | 93 x = x(:); |
94 y = y(:); | |
95 z = z(:); | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
96 if (isnumeric (c)) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
97 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
|
98 c = c(:); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
99 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
|
100 c = c.'; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
101 endif |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
111 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
|
112 |
10549 | 113 if (ndims (c) == 3 && size (c, 2) == 1) |
114 c = permute (c, [1, 3, 2]); | |
115 endif | |
6885 | 116 |
10549 | 117 if (isvector (c) && numel (c) == columns (x)) |
118 if (isnan (c)) | |
119 args{7} = "facecolor"; | |
120 args{8} = [1, 1, 1]; | |
121 args{9} = "cdata"; | |
122 args{10} = c; | |
123 elseif (isnumeric (c)) | |
124 args{7} = "facecolor"; | |
125 args{8} = "flat"; | |
126 args{9} = "cdata"; | |
127 args{10} = c; | |
128 else | |
129 error ("patch: color value not valid"); | |
130 endif | |
131 elseif (size (c, ndims (c)) == 3) | |
132 args{7} = "facecolor"; | |
13808
d5bfaa582eaa
correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents:
13779
diff
changeset
|
133 args{8} = c; |
10549 | 134 args{9} = "cdata"; |
13808
d5bfaa582eaa
correctly handle RGB color spec for patch object
John W. Eaton <jwe@octave.org>
parents:
13779
diff
changeset
|
135 args{10} = []; |
10549 | 136 else |
137 ## Color Vectors | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
138 if (isempty (c)) |
10549 | 139 args{7} = "facecolor"; |
140 args{8} = "interp"; | |
141 args{9} = "cdata"; | |
142 args{10} = []; | |
13308
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
143 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
|
144 args{7} = "facecolor"; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
145 args{8} = "interp"; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
146 args{9} = "cdata"; |
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
147 args{10} = c; |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
148 else |
13308
9a83ec29aec9
Fix regression introduced by e9f6a6edec42.
Ben Abbott <bpabbott@mac.com>
parents:
13299
diff
changeset
|
149 error ("patch: size of x, y, and c must be equal"); |
10549 | 150 endif |
151 endif | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
152 elseif (ischar (c) && rem (nargin - iarg, 2) == 0) |
10549 | 153 ## Assume that any additional argument over an even number is |
154 ## color string. | |
155 args{7} = "facecolor"; | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
156 args{8} = tolower (c); |
10549 | 157 args{9} = "cdata"; |
158 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
|
159 else |
10549 | 160 args{7} = "facecolor"; |
161 args{8} = [0, 1, 0]; | |
162 args{9} = "cdata"; | |
163 args{10} = []; | |
6925 | 164 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
|
165 |
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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 args = setvertexdata (args); |
6885 | 175 endif |
176 endif | |
177 | |
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 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
|
179 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
|
180 |
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 ## 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 |
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 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 |
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 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
|
194 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
|
195 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
|
196 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
|
197 else |
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 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
|
202 |
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 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
|
204 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
|
205 ## 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
|
206 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
|
207 nargs = length (args); |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 fvc = args {idx}; |
6807 | 225 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
226 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
|
227 if (isempty(idx) || idx > nargs) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
228 if (!isempty (fvc)) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
229 fc = "flat"; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
230 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
231 fc = [0, 1, 0]; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
232 endif |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
233 args = {"facecolor", fc, args{:}}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
234 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
235 fc = args {idx}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
236 endif |
6807 | 237 |
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
|
238 nr = size (faces, 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
|
239 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
|
240 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
|
241 t1 = isnan (idx); |
13779
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
242 for i = find (any (t1)) |
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 z = reshape (vert(:,3)(idx), size (idx)); |
6807 | 250 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
|
251 z = []; |
6807 | 252 endif |
6886 | 253 |
11160
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
254 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
|
255 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
|
256 else |
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 c = []; |
7020 | 263 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
|
264 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
|
265 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
|
266 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
|
267 |
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
|
268 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
|
269 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
|
270 ## 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
|
271 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
|
272 nargs = length (args); |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
285 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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
291 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
|
292 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
|
293 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
|
294 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
|
295 c = args {idx}; |
7020 | 296 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
297 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
|
298 if (isempty(idx) || idx > nargs) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
299 if (!isempty (c)) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
300 fc = "flat"; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
301 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
302 fc = [0, 1, 0]; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
303 endif |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
304 args = {"facecolor", fc, args{:}}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
305 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
306 fc = args {idx}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
307 endif |
7020 | 308 |
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
|
309 [nr, nc] = size (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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 faces = reshape (1:numel(x), rows (x), columns (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
|
316 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
|
317 |
11160
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
318 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
|
319 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
|
320 elseif (isvector (c)) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
321 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
|
322 else |
13698
276bb0dd9d24
patch: ensure facevertexcdata has correct shape
John W. Eaton <jwe@octave.org>
parents:
13308
diff
changeset
|
323 fvc = c.'(:); |
7020 | 324 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
325 |
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
|
326 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
|
327 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
|
328 |
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 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
|
330 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
|
331 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
|
332 |
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
|
333 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
|
334 update_handle (h, true); |
6807 | 335 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
|
336 |
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
|
337 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
|
338 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
|
339 |
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 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
|
341 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
|
342 f = get (h); |
10524
1c6ff93c025a
Reimplement the other discrete distribution functions using lookup
David Bateman <dbateman@free.fr>
parents:
9896
diff
changeset
|
343 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
|
344 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
|
345 else |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 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
|
350 endfunction |