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 "PixelExtentInWorldX" 33 r = val.PixelExtentInWorldX; 34 case "PixelExtentInWorldY" 35 r = val.PixelExtentInWorldY; 36 case "ImageExtentInWorldX" 37 r = val.ImageExtentInWorldX; 38 case "ImageExtentInWorldY" 39 r = val.ImageExtentInWorldY; 40 case "XIntrinsicLimits" 41 r = val.XIntrinsicLimits; 42 case "YIntrinsicLimits" 43 r = val.YIntrinsicLimits; 44 otherwise 45 error ("Octave:invalid-indexing", ... 46 strcat ("unknown property '", idx(1).subs, "' for class imref2d")); 47 endswitch 48 if (length (idx) > 1) 49 switch (idx(2).type) 50 case "()" 51 i = idx(2).subs; 52 r = r(i{1}); 53 otherwise 54 error ("Octave:invalid-indexing", ... 55 strcat ("can't index '", idx(1).subs, "' with ", idx(2).type)); 56 endswitch 57 endif 58 endif 59endfunction 60