]> Creatis software - CreaPhase.git/blob - octave_packages/m/plot/private/__getlegenddata__.m
update packages
[CreaPhase.git] / octave_packages / m / plot / private / __getlegenddata__.m
1 ## Copyright (C) 2010-2012 David Bateman
2 ##
3 ## This file is part of Octave.
4 ##
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.
9 ##
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.
14 ##
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/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {[@var{hplots}, @var{strings}]} = __getlegenddata__ (@var{h})
21 ## Undocumented internal function.
22 ## @end deftypefn
23
24 function [hplots, text_strings] = __getlegenddata__ (hlegend)
25   hplots = [];
26   text_strings = {};
27   ca = getfield (get (hlegend, "userdata"), "handle");
28   kids = [];
29   for i = 1:numel (ca)
30     kids = [kids; get(ca(i), "children")];
31   endfor
32
33   for i = numel (kids):-1:1
34     typ = get (kids(i), "type");
35     if (strcmp (typ, "line") || strcmp (typ, "surface")
36         || strcmp (typ, "patch") || strcmp (typ, "hggroup"))
37
38       if (strcmp (typ, "hggroup"))
39         hgkids = get (kids(i), "children");
40         for j = 1 : length (hgkids)
41           hgobj = get (hgkids (j));
42           if (isfield (hgobj, "displayname") && ! isempty (hgobj.displayname))
43             hplots = [hplots, hgkids(j)];
44             text_strings = {text_strings{:}, hgobj.displayname};
45             break;
46           endif
47         endfor
48       else
49         if (! isempty (get (kids (i), "displayname")))
50           hplots = [hplots, kids(i)];
51           text_strings = {text_strings{:}, get(kids (i), "displayname")};
52         endif
53       endif
54
55     endif
56   endfor
57
58 endfunction