1## Copyright (C) 2018 Martin Janda <janda.martin1@gmail.com>
2##
3## This program is free software: you can redistribute it and/or modify it
4## under the terms of the GNU General Public License as published by
5## the Free Software Foundation, either version 3 of the License, or
6## (at your option) any later version.
7##
8## This program is distributed in the hope that it will be useful, but
9## WITHOUT ANY WARRANTY; without even the implied warranty of
10## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11## GNU General Public License for more details.
12##
13## You should have received a copy of the GNU General Public License
14## along with this program.  If not, see
15## <https://www.gnu.org/licenses/>.
16
17## -*- texinfo -*-
18## @deftypefn {} {@var{r} =} subref (@var{val}, @var{idx})
19##
20## @seealso{}
21## @end deftypefn
22
23function r = subsref (val, idx)
24  if (strcmp (idx(1).type, "."))
25    switch (idx(1).subs)
26      case "ImageSize"
27        r = val.ImageSize;
28      case "XWorldLimits"
29        r = val.XWorldLimits;
30      case "YWorldLimits"
31        r = val.YWorldLimits;
32      case "ZWorldLimits"
33        r = val.ZWorldLimits;
34      case "PixelExtentInWorldX"
35        r = val.PixelExtentInWorldX;
36      case "PixelExtentInWorldY"
37        r = val.PixelExtentInWorldY;
38      case "PixelExtentInWorldZ"
39        r = val.PixelExtentInWorldZ;
40      case "ImageExtentInWorldX"
41        r = val.ImageExtentInWorldX;
42      case "ImageExtentInWorldY"
43        r = val.ImageExtentInWorldY;
44      case "ImageExtentInWorldZ"
45        r = val.ImageExtentInWorldZ;
46      case "XIntrinsicLimits"
47        r = val.XIntrinsicLimits;
48      case "YIntrinsicLimits"
49        r = val.YIntrinsicLimits;
50      case "ZIntrinsicLimits"
51        r = val.ZIntrinsicLimits;
52      otherwise
53        error ("Octave:invalid-indexing", ...
54        strcat ("unknown property '", idx(1).subs, "' for class imref3d"));
55    endswitch
56    if (length (idx) > 1)
57      switch (idx(2).type)
58        case "()"
59          i = idx(2).subs;
60          r = r(i{1});
61        otherwise
62          error ("Octave:invalid-indexing", ...
63          strcat ("can't index '", idx(1).subs, "' with ", idx(2).type));
64      endswitch
65    endif
66  endif
67endfunction
68