changelog shortlog tags changeset files revisions annotate raw

scripts/plot/hidden.m

changeset 10289: 4b124317dc38
parent:eb63fbe60fab
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (38 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 2007, 2008, 2009 Michael Goffioul
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} {} hidden (@var{mode})
21## @deftypefnx {Function File} {} hidden ()
22## Manipulation the mesh hidden line removal. Called with no argument
23## the hidden line removal is toggled. The argument @var{mode} can be either
24## 'on' or 'off' and the set of the hidden line removal is set accordingly.
25## @seealso{mesh, meshc, surf}
26## @end deftypefn
27
28function retval = hidden (mode)
29
30 if (nargin == 0)
31 mode = "swap";
32 elseif (nargin == 1);
33 if (ischar (mode))
34 mode = tolower (mode);
35 if (! strcmp (mode, "on") && ! strcmp (mode, "off"))
36 error ("hidden: mode expected to be 'on' or 'off'");
37 endif
38 else
39 error ("hidden: expecting mode to be a string");
40 endif
41 else
42 print_usage ();
43 endif
44
45 for h = get (gca (), "children");
46 htype = lower (get (h, "type"));
47 if (strcmp (htype, "surface"))
48 fc = get (h, "facecolor");
49 if ((! ischar (fc) && is_white (fc))
50 || (ischar (fc) && strcmpi (fc, "none")))
51 switch (mode)
52 case "on"
53 set (h, "facecolor", "w");
54 case "off"
55 set (h, "facecolor", "none");
56 case "swap"
57 if (ischar (fc))
58 set (h, "facecolor", "w");
59 mode = "on";
60 else
61 set (h, "facecolor", "none");
62 mode = "off";
63 endif
64 endswitch
65 endif
66 endif
67 endfor
68
69 if (nargout > 0)
70 retval = mode;
71 endif
72
73endfunction
74
75function retval = is_white (color)
76 retval = all (color == 1);
77endfunction