annotate scripts/plot/draw/private/__contour__.m @ 21567:3d25f9f4a62b

maint: Eliminate Britishicisms in the code. * oct-stream.cc, __magick_read__.cc, Array.h, flag.m, lines.m, prism.m, __contour__.m: Use 'optimize' and 'color' rather than British spellings.
author Rik <rik@octave.org>
date Wed, 30 Mar 2016 21:35:51 -0700
parents 89fa0694aa2e
children ffad2baa90f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19593
diff changeset
1 ## Copyright (C) 2007-2015 David Bateman
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
2 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
4 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
9 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
14 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
18
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8441
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20735
diff changeset
20 ## @deftypefn {} {[@var{c}, @var{hg}] =} __contour__ (@dots{})
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
21 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8441
diff changeset
22 ## @end deftypefn
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
23
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
24 function [c, hg] = __contour__ (varargin)
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7191
diff changeset
25 ax = varargin{1};
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
26 zlevel = varargin{2};
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
27 filled = "off";
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
28
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
29 linespec.color = "auto";
7317
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7208
diff changeset
30 linespec.linestyle = "-";
20203
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 opts = {};
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 i = 3;
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
33 while (i <= length (varargin))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 if (ischar (varargin{i}) || iscellstr (varargin{i}))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
35 arg = varargin{i};
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
36 if (i < length (varargin))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
37 if (strcmpi (arg, "fill"))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
38 filled = varargin{i+1};
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
39 varargin(i:i+1) = [];
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
40 continue;
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
41 elseif (strcmpi (arg, "linecolor"))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
42 linespec.color = varargin{i+1};
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
43 varargin(i:i+1) = [];
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
44 continue;
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
45 endif
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
46 endif
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
47
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
48 [lspec, valid] = __pltopt__ ("__contour__", arg, false);
7317
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7208
diff changeset
49 if (valid)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
50 varargin(i) = [];
20203
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
51 if (! isempty (lspec.color))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
52 linespec.color = lspec.color;
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
53 endif
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
54 if (! isempty (lspec.linestyle))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
55 linespec.linestyle = lspec.linestyle;
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
56 endif
20203
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
57 else # unrecognized option, pass unmodified in opts cell array
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
58 if (i < length (varargin))
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
59 opts(end+(1:2)) = varargin(i:i+1);
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
60 varargin(i:i+1) = [];
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
61 else
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
62 error ("__contour__: Uneven number of PROP/VAL pairs");
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
63 endif
7317
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7208
diff changeset
64 endif
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7208
diff changeset
65
20203
70e8801a56f7 Correctly parse linestyle specification for contour plots.
Rik <rik@octave.org>
parents: 19833
diff changeset
66 else # skip numeric arguments
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20203
diff changeset
67 i += 1;
7462
dfcaf7ed48e3 Allow linewidth to be specified for contours
David Bateman
parents: 7317
diff changeset
68 endif
dfcaf7ed48e3 Allow linewidth to be specified for contours
David Bateman
parents: 7317
diff changeset
69 endwhile
dfcaf7ed48e3 Allow linewidth to be specified for contours
David Bateman
parents: 7317
diff changeset
70
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
71 if (length (varargin) < 5)
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
72 z1 = varargin{3};
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
73 x1 = 1 : columns (z1);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
74 y1 = 1 : rows (z1);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
75 else
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
76 x1 = varargin{3};
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
77 y1 = varargin{4};
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
78 z1 = varargin{5};
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
79 endif
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
80 if (! ismatrix (z1) || ! ismatrix (x1) || ! ismatrix (y1))
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
81 error ("__contour__: X, Y, and Z must be matrices");
10634
60542efcfa2c Check input arguments for size and type (bug #29861).
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
82 endif
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
83 if (length (varargin) == 4 || length (varargin) == 6)
16911
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
84 vn = varargin{end};
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
85 vnauto = false;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
86 else
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
87 vn = 10;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
88 vnauto = true;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
89 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
90
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8289
diff changeset
91 if (isscalar (vn))
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
92 ## FIXME: The levels should be determined similarly to {x,y,z}ticks
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
93 ## so that they aren't set at extremely odd values.
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
94 lvl = linspace (min (z1(! isinf (z1))), max (z1(! isinf (z1))), vn + 2);
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
95 ## Strip off max outlier, min must stay for contourf hole algorithm.
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
96 lvl = lvl(1:end-1);
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8289
diff changeset
97 else
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
98 lvl = sort (vn);
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8289
diff changeset
99 endif
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8289
diff changeset
100
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
101 if (strcmpi (filled, "on"))
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
102 if (isvector (x1) || isvector (y1))
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
103 [x1, y1] = meshgrid (x1, y1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
104 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
105 [nr, nc] = size (z1);
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
106 x0 = prepad (x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
107 x0 = postpad (x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
108 x0 = [x0(1, :); x0; x0(1, :)];
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
109 y0 = prepad (y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
110 y0 = postpad (y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1));
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
111 y0 = [y0(:, 1), y0, y0(:, 1)];
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
112 z0 = -Inf (nr+2, nc+2);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
113 z0(2:nr+1, 2:nc+1) = z1;
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8289
diff changeset
114 [c, lev] = contourc (x0, y0, z0, lvl);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
115 else
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8289
diff changeset
116 [c, lev] = contourc (x1, y1, z1, lvl);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
117 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
118
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
119 hg = hggroup ();
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
120 opts = __add_datasource__ ("__countour__", hg, {"x", "y", "z"}, opts{:});
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
121
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
122 addproperty ("xdata", hg, "data", x1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
123 addproperty ("ydata", hg, "data", y1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
124 addproperty ("zdata", hg, "data", z1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
125 addproperty ("contourmatrix", hg, "data", c);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
126
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
127 addlistener (hg, "xdata", @update_data);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
128 addlistener (hg, "ydata", @update_data);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
129 addlistener (hg, "zdata", @update_data);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
130 addlistener (hg, "contourmatrix", @update_data);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
131
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
132 addproperty ("fill", hg, "radio", "on|{off}", filled);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
133
17167
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
134 ## The properties zlevel and zlevelmode don't exist in matlab, but allow the
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
135 ## use of contourgroups with the contour3, meshc, and surfc functions.
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
136 if (isnumeric (zlevel))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
137 addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", "manual");
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
138 addproperty ("zlevel", hg, "data", zlevel);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
139 else
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
140 addproperty ("zlevelmode", hg, "radio", "{none}|auto|manual", zlevel);
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
141 addproperty ("zlevel", hg, "data", 0.);
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
142 endif
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
143
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
144 lvlstep = sum (diff (lvl)) / (length (lvl) - 1);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
145
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
146 addproperty ("levellist", hg, "data", lev);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
147 addproperty ("levelstep", hg, "double", lvlstep);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
148 if (vnauto)
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
149 addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
150 addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
151 elseif (isscalar (vn))
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
152 addproperty ("levellistmode", hg, "radio", "{auto}|manual", "auto");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
153 addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "manual");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
154 else
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
155 addproperty ("levellistmode", hg, "radio", "{auto}|manual", "manual");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
156 addproperty ("levelstepmode", hg, "radio", "{auto}|manual", "auto");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
157 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
158
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
159 addproperty ("labelspacing", hg, "double", 144);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
160 addproperty ("textlist", hg, "data", lev);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
161 addproperty ("textlistmode", hg, "radio", "{auto}|manual", "auto");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
162 addproperty ("textstep", hg, "double", lvlstep);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
163 addproperty ("textstepmode", hg, "radio", "{auto}|manual", "auto");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
164 addproperty ("showtext", hg, "radio", "on|{off}", "off");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
165
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
166 addproperty ("linecolor", hg, "color", linespec.color, "{auto}|none");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
167 addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
168 addproperty ("linewidth", hg, "linelinewidth", 0.5);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
169
17527
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17525
diff changeset
170 ## Matlab property, although Octave does not implement it.
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17525
diff changeset
171 addproperty ("hittestarea", hg, "radio", "on|{off}", "off");
76614e624818 Add "HitTestArea" property to certain hggroups for Matlab compatibility
Rik <rik@octave.org>
parents: 17525
diff changeset
172
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
173 addlistener (hg, "fill", {@update_data, "fill"});
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
174
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
175 addlistener (hg, "zlevelmode", @update_zlevel);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
176 addlistener (hg, "zlevel", @update_zlevel);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
177
16911
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
178 addlistener (hg, "levellist", {@update_data, "levellist"});
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
179 addlistener (hg, "levelstep", {@update_data, "levelstep"});
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
180 addlistener (hg, "levellistmode", @update_data);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
181 addlistener (hg, "levelstepmode", @update_data);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
182
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
183 addlistener (hg, "labelspacing", @update_text);
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
184 addlistener (hg, "textlist", {@update_text, "textlist"});
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
185 addlistener (hg, "textlistmode", @update_text);
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
186 addlistener (hg, "textstep", {@update_text, "textstep"});
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
187 addlistener (hg, "textstepmode", @update_text);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
188 addlistener (hg, "showtext", @update_text);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
189
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
190 addlistener (hg, "linecolor", @update_line);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
191 addlistener (hg, "linestyle", @update_line);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
192 addlistener (hg, "linewidth", @update_line);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
193
17167
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
194 ## Set axis before adding patches so that each new patch does not trigger
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
195 ## new axis calculation. No need if mode is already "manual".
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
196 if (all (strcmp (get (gca (), {"xlimmode", "ylimmode"}), "auto")))
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
197 axis ([min(x1(:)) max(x1(:)) min(y1(:)) max(y1(:))]);
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
198 endif
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
199
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
200 add_patch_children (hg);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
201
17167
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
202 if (! isempty (opts))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
203 set (hg, opts{:});
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
204 endif
17167
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
205
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
206 endfunction
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
207
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
208 function add_patch_children (hg)
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
209 c = get (hg, "contourmatrix");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
210 lev = get (hg, "levellist");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
211 fill = get (hg, "fill");
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
212 zlev = get (hg, "zlevel");
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
213 zmode = get (hg, "zlevelmode");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
214 lc = get (hg, "linecolor");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
215 lw = get (hg, "linewidth");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
216 ls = get (hg, "linestyle");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
217 filled = get (hg, "fill");
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
218 ca = gca ();
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
219
17411
f58ad514372c __contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents: 17338
diff changeset
220 ## Turn off automatic updating of clim while adding patches
f58ad514372c __contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents: 17338
diff changeset
221 climmode = get (ca, "climmode");
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
222 set (ca, "climmode", "manual");
17411
f58ad514372c __contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents: 17338
diff changeset
223
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
224 if (strcmp (lc, "auto"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
225 lc = "flat";
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
226 endif
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
227
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
228 if (strcmp (filled, "on"))
10354
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
229
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
230 lvl_eps = get_lvl_eps (lev);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
231
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
232 ## Decode contourc output format.
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
233 i = 1;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
234 ncont = 0;
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
235 while (i < columns (c))
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20203
diff changeset
236 ncont += 1;
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
237 cont_lev(ncont) = c(1, i);
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
238 cont_len(ncont) = c(2, i);
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
239 cont_idx(ncont) = i+1;
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
240 ii = i + (1:cont_len(ncont));
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
241 cont_area(ncont) = polyarea (c(1, ii), c(2, ii));
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
242 i += cont_len(ncont) + 1;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
243 endwhile
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
244
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
245 ## Handle for each level the case where we have (a) hole(s) in a patch.
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
246 ## Those are to be filled with the color of level below or with the
21567
3d25f9f4a62b maint: Eliminate Britishicisms in the code.
Rik <rik@octave.org>
parents: 21385
diff changeset
247 ## background color.
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
248 for k = 1:numel (lev)
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
249 lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
250 len = numel (lvl_idx);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
251 if (len > 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
252 mark = false (size (lvl_idx));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
253 a = 1;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
254 while (a < len)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
255 ## take 1st patch
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
256 pa_idx = lvl_idx(a);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
257 ## get pointer to contour start, and contour length
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
258 curr_ct_idx = cont_idx(pa_idx);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
259 curr_ct_len = cont_len(pa_idx);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
260 ## get contour
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
261 curr_ct = c(:, curr_ct_idx:curr_ct_idx+curr_ct_len-1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
262 b_vec = (a+1):len;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
263 next_ct_pt_vec = c(:, cont_idx(lvl_idx(b_vec)));
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
264 in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:),
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
265 curr_ct(1, :), curr_ct(2, :));
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
266 mark(b_vec(in)) = ! mark(b_vec(in));
20735
418ae0cb752f Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents: 20203
diff changeset
267 a += 1;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
268 endwhile
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
269 if (numel (mark) > 0)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
270 ## All marked contours describe a hole in a larger contour of
21567
3d25f9f4a62b maint: Eliminate Britishicisms in the code.
Rik <rik@octave.org>
parents: 21385
diff changeset
271 ## the same level and must be filled with color of level below.
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
272 ma_idx = lvl_idx(mark);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
273 if (k > 1)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
274 ## Find color of level below.
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
275 tmp = find (abs (cont_lev - lev(k - 1)) < lvl_eps);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
276 lvl_bel_idx = tmp(1);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
277 ## Set color of patches found.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
278 cont_lev(ma_idx) = cont_lev(lvl_bel_idx);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
279 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
280 ## Set lowest level contour to NaN.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
281 cont_lev(ma_idx) = NaN;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
282 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
283 endif
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
284 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
285 endfor
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
286
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
287 ## The algorithm can create patches with the size of the plotting
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
288 ## area, we would like to draw only the patch with the highest level.
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
289 del_idx = [];
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
290 max_idx = find (cont_area == max (cont_area));
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
291 if (numel (max_idx) > 1)
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
292 ## delete double entries
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
293 del_idx = max_idx(1:end-1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
294 cont_area(del_idx) = cont_lev(del_idx) = [];
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
295 cont_len(del_idx) = cont_idx(del_idx) = [];
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
296 endif
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
297
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
298 ## Now we have everything together and can start plotting the patches
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
299 ## beginning with largest area.
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
300 [~, svec] = sort (cont_area);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
301 len = ncont - numel (del_idx);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
302 h = [];
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
303 for n = len:-1:1
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
304 idx = svec(n);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
305 ctmp = c(:, cont_idx(idx):cont_idx(idx) + cont_len(idx) - 1);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
306 if (all (ctmp(:,1) == ctmp(:,end)))
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
307 ## patch() doesn't need/want closed contour. It will do it itself.
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
308 ctmp(:,end) = [];
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
309 endif
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
310 if (isnan (cont_lev(idx)))
13156
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
311 fc = get (ca, "color");
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
312 if (strcmp (fc, "none"))
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
313 fc = get (ancestor (ca, "figure"), "color");
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
314 endif
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
315 else
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
316 fc = "flat";
da71f676e449 Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents: 12648
diff changeset
317 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
318 h = [h; __go_patch__(ca, "xdata", ctmp(1, :)(:), "ydata", ctmp(2, :)(:),
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
319 "vertices", ctmp.', "faces", 1:(cont_len(idx)-1),
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
320 "facevertexcdata", cont_lev(idx), "facecolor", fc,
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
321 "cdata", cont_lev(idx), "edgecolor", lc,
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
322 "linestyle", ls, "linewidth", lw,
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
323 "parent", hg)];
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
324 endfor
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
325
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
326 if (min (lev) == max (lev))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
327 set (ca, "clim", [min(lev)-1, max(lev)+1], "layer", "top");
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
328 else
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
329 set (ca, "clim", [min(lev), max(lev)], "layer", "top");
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
330 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
331 else
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
332 ## Decode contourc output format.
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
333 h = [];
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
334 i = 1;
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
335 while (i < length (c))
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
336 clev = c(1,i);
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
337 clen = c(2,i);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
338
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
339 if (all (c(:,i+1) == c(:,i+clen)))
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
340 p = c(:, i+1:i+clen-1).';
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
341 else
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
342 p = [c(:, i+1:i+clen), NaN(2, 1)].';
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
343 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
344
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
345 switch (zmode)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
346 case "none"
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
347 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2),
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
348 "zdata", [],
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
349 "vertices", p, "faces", 1:rows (p),
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
350 "facevertexcdata", clev, "facecolor", "none",
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
351 "cdata", clev, "edgecolor", lc,
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
352 "linestyle", ls, "linewidth", lw,
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
353 "parent", hg)];
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
354 case "auto"
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
355 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2),
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
356 "zdata", clev * ones (rows (p),1),
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
357 "vertices", [p, clev * ones(rows(p),1)],
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
358 "faces", 1:rows(p),
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
359 "facevertexcdata", clev, "facecolor", "none",
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
360 "cdata", clev, "edgecolor", lc,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
361 "linestyle", ls, "linewidth", lw,
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
362 "parent", hg)];
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
363 otherwise
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
364 h = [h; __go_patch__(ca, "xdata", p(:,1), "ydata", p(:,2),
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
365 "zdata", zlev * ones (rows (p), 1),
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
366 "vertices", [p, zlev * ones(rows(p),1)],
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
367 "faces", 1:rows (p),
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
368 "facevertexcdata", clev, "facecolor", "none",
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
369 "cdata", clev, "edgecolor", lc,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11163
diff changeset
370 "linestyle", ls, "linewidth", lw,
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
371 "parent", hg)];
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
372 endswitch
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
373 i += clen + 1;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
374 endwhile
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
375 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
376
17411
f58ad514372c __contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents: 17338
diff changeset
377 set (ca, "climmode", climmode);
f58ad514372c __contour__.m: Turn off auto clim adjustment while patches are being added.
Rik <rik@octave.org>
parents: 17338
diff changeset
378
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
379 endfunction
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
380
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
381 function update_zlevel (h, ~)
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
382 z = get (h, "zlevel");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
383 zmode = get (h, "zlevelmode");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
384 kids = get (h, "children");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
385
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
386 switch (zmode)
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
387 case "none"
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
388 set (kids, "zdata", []);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
389 case "auto"
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
390 for i = 1 : length (kids)
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
391 set (kids(i), "zdata", get (kids(i), "cdata") .*
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
392 ones (size (get (kids(i), "xdata"))));
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
393 endfor
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
394 otherwise
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
395 for i = 1 : length (kids)
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
396 set (kids(i), "zdata", z .* ones (size (get (kids(i), "xdata"))));
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
397 endfor
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
398 endswitch
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
399 endfunction
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
400
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
401 function update_line (h, ~)
9554
bda3513e7ba9 Fix test for setting of datasource properties. Add the edgecolor property to contours
David Bateman <dbateman@free.fr>
parents: 8920
diff changeset
402 lc = get (h, "linecolor");
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
403 if (strcmp (lc, "auto"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
404 lc = "flat";
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
405 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
406 set (findobj (h, "type", "patch"), "edgecolor", lc,
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
407 "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"));
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
408 endfunction
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
409
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
410 function update_data (h, ~, prop = "")
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
411 persistent recursive = false;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
412
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
413 if (! recursive)
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
414 recursive = true;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
415
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
416 delete (get (h, "children"));
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
417
16933
e39f00a32dc7 maint: Use parentheses around condition for switch(),while(),if() statements.
Rik <rik@octave.org>
parents: 16911
diff changeset
418 switch (prop)
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17167
diff changeset
419 case "levellist"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
420 set (h, "levellistmode", "manual");
17174
c3c1ebfaa7dc maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents: 17167
diff changeset
421 case "levelstep"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
422 set (h, "levelstepmode", "manual");
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
423 case "fill"
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
424 ## Switching from filled ('k' linespec) to unfilled, reset linecolor
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
425 if (strcmp (get (h, "fill"), "off"))
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
426 set (h, "linecolor", "auto");
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
427 else
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
428 set (h, "linecolor", "black");
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
429 endif
16911
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
430 endswitch
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
431
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
432 if (strcmp (get (h, "levellistmode"), "manual")
16911
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
433 && ! strcmp (prop, "levelstep"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
434 lvl = get (h, "levellist");
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
435 elseif (strcmp (get (h, "levelstepmode"), "manual"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
436 z = get (h, "zdata");
16911
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
437 lvs = get (h, "levelstep");
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
438 lvl(1) = ceil (min (z(:)) / lvs) * lvs;
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
439 lvl(2) = floor (max (z(:)) / lvs) * lvs;
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
440 if (lvl(1) >= lvl(2))
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
441 lvl = median (z(:));
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
442 else
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
443 lvl = lvl(1) : lvs : lvl(2);
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
444 endif
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
445 set (h, "levellist", lvl);
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
446 set (h, "levellistmode", "auto");
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
447 else
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
448 z = get (h, "zdata");
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
449 ## FIXME: The levels should be determined similarly to {x,y,z}ticks
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
450 ## so that they aren't set at extremely odd values.
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
451 lvl = linspace (min (z(! isinf (z))), max (z(! isinf (z))), 10 + 2);
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
452 ## Strip off max outlier, min must stay for contourf hole algorithm.
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
453 lvl = lvl(1:end-1);
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
454 endif
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
455
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
456 if (strcmp (get (h, "fill"), "on"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
457 X = get (h, "xdata");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
458 Y = get (h, "ydata");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
459 Z = get (h, "zdata");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
460 if (isvector (X) || isvector (Y))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
461 [X, Y] = meshgrid (X, Y);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
462 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
463 [nr, nc] = size (Z);
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
464 X0 = prepad (X, nc+1, 2 * X(1, 1) - X(1, 2), 2);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
465 X0 = postpad (X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
466 X0 = [X0(1, :); X0; X0(1, :)];
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
467 Y0 = prepad (Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
468 Y0 = postpad (Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1));
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
469 Y0 = [Y0(:, 1), Y0, Y0(:, 1)];
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
470 Z0 = -Inf (nr+2, nc+2);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
471 Z0(2:nr+1, 2:nc+1) = Z;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
472 [c, lev] = contourc (X0, Y0, Z0, lvl);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
473 else
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
474 [c, lev] = contourc (get (h, "xdata"), get (h, "ydata"),
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
475 get (h, "zdata"), lvl);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
476 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
477 set (h, "contourmatrix", c);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
478
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
479 if (strcmp (get (h, "levellistmode"), "manual"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
480 ## Do nothing
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
481 elseif (strcmp (get (h, "levelstepmode"), "manual"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
482 set (h, "levellist", lev);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
483 else
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
484 set (h, "levellist", lev);
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
485 lvlstep = sum (diff (lvl)) / (length (lvl) - 1);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
486 set (h, "levelstep", lvlstep);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
487 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
488
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
489 add_patch_children (h);
17474
6edc451629a6 __contour__.m: Ignore dummy input in all listener functions.
Rik <rik@octave.org>
parents: 17466
diff changeset
490 update_text (h);
16911
5ea6a6d2b83f Fix contour() listeners.
Ben Abbott <bpabbott@mac.com>
parents: 15450
diff changeset
491 recursive = false;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
492 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
493
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
494 endfunction
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
495
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
496 function update_text (h, ~, prop = "")
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
497 persistent recursive = false;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
498
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
499 if (! recursive)
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
500 recursive = true;
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
501
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
502 delete (findobj (h, "type", "text"));
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
503
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
504 switch (prop)
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
505 case "textlist"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
506 set (h, "textlistmode", "manual");
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
507 case "textstep"
21385
89fa0694aa2e Fix check-missing-semicolon QA target (bug #47277).
Rik <rik@octave.org>
parents: 20852
diff changeset
508 set (h, "textstepmode", "manual");
17525
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
509 endswitch
76a6d7de4cbc Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents: 17474
diff changeset
510
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
511 if (strcmp (get (h, "textlistmode"), "manual"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
512 lvl = get (h, "textlist");
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
513 elseif (strcmp (get (h, "textstepmode"), "manual"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
514 lev = get (h, "levellist");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
515
10354
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
516 lvl_eps = get_lvl_eps (lev);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
517
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
518 stp = get (h, "textstep");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
519 t = [0, floor(cumsum(diff (lev)) / (abs(stp) - lvl_eps))];
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
520 lvl = lev([true, t(1:end-1) != t(2:end)]);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
521 set (h, "textlist", lvl);
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
522 else
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
523 lvl = get (h, "levellist");
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
524 set (h, "textlist", lvl, "textstep", get (h, "levelstep"));
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
525 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
526
17466
a5c6591d01e6 __contour__.m: Overhaul function.
Rik <rik@octave.org>
parents: 17411
diff changeset
527 if (strcmp (get (h, "showtext"), "on"))
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
528 switch (get (h, "zlevelmode"))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
529 case "manual"
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
530 __clabel__ (get (h, "contourmatrix"), lvl, h,
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
531 get (h, "labelspacing"), get (h, "zlevel"));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
532 case "auto"
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
533 __clabel__ (get (h, "contourmatrix"), lvl, h,
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
534 get (h, "labelspacing"), "auto");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
535 otherwise
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
536 __clabel__ (get (h, "contourmatrix"), lvl, h,
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10354
diff changeset
537 get (h, "labelspacing"), []);
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
538 endswitch
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
539 endif
11198
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11175
diff changeset
540
9f080d23396f Fix multi-parented legends with the gnuplot backend (fixes #30461 and #31522)
David Bateman <dbateman@free.fr>
parents: 11175
diff changeset
541 recursive = false;
8289
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
542 endif
ac7f334d9652 Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents: 8190
diff changeset
543 endfunction
10354
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
544
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
545 function lvl_eps = get_lvl_eps (lev)
17167
0a761f218d8d Fix contour plot axis to x-y data range, not axis ("tight").
Rik <rik@octave.org>
parents: 16933
diff changeset
546 ## FIXME: is this the right thing to do for this tolerance? Should
10354
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
547 ## it be an absolute or relative tolerance, or switch from one to the
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
548 ## other depending on the value of lev?
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
549 if (isscalar (lev))
12648
c6378cec77af Fix unfilled contourf when lvl = [0,0] (bug #33177).
Marco Caliari marco.caliari@univr.it
parents: 11587
diff changeset
550 lvl_eps = abs (lev) * sqrt (eps) + sqrt (eps);
10354
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
551 else
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
552 tmp = min (abs (diff (lev)));
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
553 if (tmp < 10*eps)
10354
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
554 lvl_eps = sqrt (eps);
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
555 else
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
556 lvl_eps = tmp / 1000.0;
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
557 endif
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
558 endif
f074aa6b2c80 __contour__: don't fail if zlevel is a vector with all the same values
John W. Eaton <jwe@octave.org>
parents: 10156
diff changeset
559 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17174
diff changeset
560