X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fgeometry-1.5.0%2Fio%2F%40svg%2Fsubsref.m;fp=octave_packages%2Fgeometry-1.5.0%2Fio%2F%40svg%2Fsubsref.m;h=81bbc137bf0d0b8466f7e0fa0a43302f961fb9ee;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/geometry-1.5.0/io/@svg/subsref.m b/octave_packages/geometry-1.5.0/io/@svg/subsref.m new file mode 100644 index 0000000..81bbc13 --- /dev/null +++ b/octave_packages/geometry-1.5.0/io/@svg/subsref.m @@ -0,0 +1,84 @@ +## Copyright (C) 2011 Carnë Draug +## Copyright (c) 2011 Juan Pablo Carbajal +## Improvement based on John W. Eaton's idea. +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . + +## -*- texinfo -*- +## @deftypefn {Function File} {} function_name () +## @end deftypefn + +function varargout = subsref (obj, idx) + + persistent __method__ method4field typeNotImplemented + if isempty(__method__) + + __method__ = struct(); + + __method__.plot = @(o,varargin) plot (o, varargin{:}); + __method__.getpath = @(o,varargin) getpath (o, varargin{:}); + __method__.pathid = @(o,varargin) pathid(o,varargin{:}); + __method__.path2polygon = @(o,varargin) path2polygon (o, varargin{:}); + __method__.normalize = @(o,varargin) normalize (o, varargin{:}); + __method__.height = @(o,varargin) height(o, varargin{:}); + __method__.width = @(o,varargin) width(o,varargin{:}); + + # Error strings + method4field = "Class %s has no field %s. Use %s() for the method."; + typeNotImplemented = "%s no implemented for class %s."; + + end + + if ( !strcmp (class (obj), 'svg') ) + error ("Object must be of the svg class but '%s' was used", class (obj) ); + elseif ( idx(1).type != '.' ) + error ("Invalid index for class %s", class (obj) ); + endif + + method = idx(1).subs; + if ~isfield(__method__, method) + error('Unknown method %s.',method); + else + fhandle = __method__.(method); + end + + if strcmp(method,'normalize') + warning("svg:Devel",["Not returning second output argument of %s" ... + " use method(obj) API to get it"],method); + end + + if numel (idx) == 1 % can't access properties, only methods + + error (method4field, class (obj), method, method); + + end + + if strcmp (idx(2).type, '()') + + args = idx(2).subs; + if isempty(args) + out = fhandle (obj); + else + out = fhandle (obj, args{:}); + end + + varargout{1} = out; + + else + + error (typeNotImplemented,[method idx(2).type], class (obj)); + + end + +endfunction