1 ## Copyright (C) 2005-2012 John W. Eaton
3 ## This file is part of Octave.
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {@var{h} =} __line__ (@var{p}, @dots{})
21 ## Undocumented internal function.
24 ## __line__ (p, x, y, z)
25 ## Create line object from x, y, and z with parent p.
26 ## Return handle to line object.
30 function h = __line__ (p, varargin)
36 nvargs = numel (varargin);
38 if (nvargs > 1 && isnumeric (varargin{1}) && isnumeric (varargin{2}))
39 if (nvargs > 2 && isnumeric (varargin{3}))
48 if (num_data_args > 0 && ! size_equal (varargin{1:num_data_args}))
49 error ("line: number of X, Y, and Z points must be equal");
52 if (rem (nvargs - num_data_args, 2) != 0)
53 error ("line: invalid number of PROPERTY / VALUE pairs");
57 if (nvargs > num_data_args)
58 other_args = varargin(num_data_args+1:end);
64 for i = 1:num_data_args
65 tmp = varargin{i}(:,:);
67 nlines = max (1, nlines);
70 nvecpts = numel (tmp);
71 elseif (nvecpts != numel (tmp))
72 error ("line: data size mismatch");
77 nlines = max (columns (tmp), nlines);
82 if (num_data_args == 0)
83 varargin = {[0, 1], [0, 1]};
88 handles = zeros (nlines, 1);
92 if (num_data_args > 1)
93 data(1) = varargin{1};
94 data(2) = varargin{2};
95 if (num_data_args == 3)
96 data(3) = varargin{3};
100 data_args = reshape ({"xdata", "ydata", "zdata"; data{:}}, [1, 6]);
101 mask = reshape ([false(1,3); ismat], [1, 6]);
105 if (! size_equal (tmp)
106 || (nvecpts != 0 && any (nvecpts != cellfun ("size", tmp, 1))))
107 error ("line: data size_mismatch");
110 data_args(mask) = cellfun (@(x) x(:,i), data(ismat),
111 "uniformoutput", false);
113 handles(i) = __go_line__ (p, data_args{:}, other_args{:});