Mercurial > hg > octave-lyh
annotate scripts/plot/private/__patch__.m @ 17535:c12c688a35ed default tip lyh
Fix warnings
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Fri, 27 Sep 2013 17:43:27 +0800 |
parents | 6dbc866379e2 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14109
diff
changeset
|
1 ## Copyright (C) 2007-2012 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"; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
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"; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
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")) |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
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(:); |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
100 elseif (rows (c) != numel (x) && columns (c) == numel (x)) |
13299
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 |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
114 if (ndims (c) == 3 && columns (c) == 1) |
10549 | 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 |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
139 if ((rows (c) == 1 && columns (c) == 1) ... |
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
140 || (rows (c) == 1 && columns (c) == columns (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
|
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; |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
146 elseif (rows (c) == rows (x) && columns (c) == columns (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
|
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"; |
17355
1391dc953ae2
__patch__.m: Fix typo and close bug #34417.
Rik <rik@octave.org>
parents:
17346
diff
changeset
|
151 args{10} = c; |
13954
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 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
212 function args = delfields (args, flds) |
17394
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17364
diff
changeset
|
213 idx = cellfun ("isclass", args, "char"); |
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17364
diff
changeset
|
214 idx(idx) = ismember (args(idx), flds); |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
215 if (rows (idx) == 1) |
17394
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17364
diff
changeset
|
216 idx |= [false, idx(1:end-1)]; |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
217 else |
17394
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17364
diff
changeset
|
218 idx |= [false; idx(1:end-1)]; |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
219 endif |
17394
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17364
diff
changeset
|
220 args(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
|
221 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
|
222 |
22ae6b3411a7
Add isocolor, isonormals 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 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
|
224 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
|
225 ## 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
|
226 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
|
227 nargs = length (args); |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
240 idx = find (strcmpi (args, "facevertexcdata"), 1, "last") + 1; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
241 if (isempty (idx) || idx > nargs) |
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
|
242 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
|
243 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
|
244 fvc = args {idx}; |
6807 | 245 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
246 idx = find (strcmpi (args, "facecolor"), 1, "last") + 1; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
247 if (isempty (idx) || idx > nargs) |
9118
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
248 if (!isempty (fvc)) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
249 fc = "flat"; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
250 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
251 fc = [0, 1, 0]; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
252 endif |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
253 args = {"facecolor", fc, args{:}}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
254 endif |
6807 | 255 |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
256 nc = rows (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
|
257 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
|
258 t1 = isnan (idx); |
13779
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
259 for i = find (any (t1)) |
7c0fcabd1a66
__patch__: fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents:
13778
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 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
|
264 y = reshape (vert(:,2)(idx), size (idx)); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
265 if (columns (vert) > 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
|
266 z = reshape (vert(:,3)(idx), size (idx)); |
6807 | 267 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
|
268 z = []; |
6807 | 269 endif |
6886 | 270 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
271 if (rows (fvc) == nc || rows (fvc) == 1) |
11160
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
272 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
|
273 else |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
274 if (columns (fvc) == 3) |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
275 c = cat (3, reshape (fvc(idx, 1), size (idx)), |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
276 reshape (fvc(idx, 2), size (idx)), |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
277 reshape (fvc(idx, 3), size (idx))); |
14108 | 278 elseif (isempty (fvc)) |
14109
9627d5134a12
__patch__.m: Terminate line with semicolon.
Ben Abbott <bpabbott@mac.com>
parents:
14108
diff
changeset
|
279 c = []; |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
280 else ## if (columnns (fvc) == 1) |
14108 | 281 c = permute (fvc(faces), [2, 1]); |
7020 | 282 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
|
283 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
|
284 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
|
285 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
|
286 |
22ae6b3411a7
Add isocolor, isonormals 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 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
|
288 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
|
289 ## 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
|
290 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
|
291 nargs = length (args); |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
304 idx = find (strcmpi (args, "zdata"), 1, "last") + 1; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
305 if (isempty (idx) || idx > nargs) |
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
|
306 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
|
307 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
|
308 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
|
309 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
310 idx = find (strcmpi (args, "cdata"), 1, "last") + 1; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
311 if (isempty (idx) || idx > nargs) |
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
|
312 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
|
313 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
|
314 c = args {idx}; |
7020 | 315 endif |
11188
4cb1522e4d0f
Use function handle as input to cellfun,
Rik <octave@nomad.inbox5.com>
parents:
11187
diff
changeset
|
316 idx = find (strcmpi (args, "facecolor"), 1, "last") + 1; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
317 if (isempty (idx) || idx > nargs) |
9118
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
318 if (!isempty (c)) |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
319 fc = "flat"; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
320 else |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
321 fc = [0, 1, 0]; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
322 endif |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
323 args = {"facecolor", fc, args{:}}; |
308311b642b2
Explicitly set the default facecolor of patches
David Bateman <dbateman@free.fr>
parents:
9111
diff
changeset
|
324 endif |
7020 | 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 [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
|
327 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
|
328 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
|
329 nc = 1; |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 endif |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14552
diff
changeset
|
336 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
|
337 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
|
338 |
11160
131d56b6d9a3
Set cdata from facevertexcdata and visa versa for patch at all times
David Bateman <dbateman@free.fr>
parents:
10569
diff
changeset
|
339 if (ndims (c) == 3) |
14872
c2dbdeaa25df
maint: use rows() and columns() to clarify m-files.
Rik <octave@nomad.inbox5.com>
parents:
14868
diff
changeset
|
340 fvc = reshape (c, rows (c) * columns (c), size (c, 3)); |
14108 | 341 else |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13256
diff
changeset
|
342 fvc = c(:); |
7020 | 343 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
344 |
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 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
|
346 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
|
347 |
22ae6b3411a7
Add isocolor, isonormals 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 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
|
349 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
|
350 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
|
351 |
22ae6b3411a7
Add isocolor, isonormals 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 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
|
353 update_handle (h, true); |
6807 | 354 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
|
355 |
22ae6b3411a7
Add isocolor, isonormals 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 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
|
357 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
|
358 |
22ae6b3411a7
Add isocolor, isonormals 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 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
|
360 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
|
361 f = get (h); |
10524
1c6ff93c025a
Reimplement the other discrete distribution functions using lookup
David Bateman <dbateman@free.fr>
parents:
9896
diff
changeset
|
362 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
|
363 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
|
364 else |
10569
4f2e46473153
Fix the order of calling setdata and setvertexdata for patches (bug #29549)
David Bateman <dbateman@free.fr>
parents:
10549
diff
changeset
|
365 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
|
366 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
|
367 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
|
368 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
|
369 endfunction |
17346
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14872
diff
changeset
|
370 |