annotate scripts/plot/hidden.m @ 7149:5c121a8b40b5

[project @ 2007-11-09 18:15:39 by jwe]
author jwe
date Fri, 09 Nov 2007 18:15:40 +0000
parents
children 73d6b71788c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7149
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2007 Michael Goffioul
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
2 ##
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
4 ##
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
9 ##
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
14 ##
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
18
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
20 ## @deftypefn {Function File} {} hidden (@var{mode})
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {} hidden ()
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
22 ## Manipulation the mesh hidden line removal. Called with no argument
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
23 ## the hidden line removal is toggled. The argument @var{mode} can be either
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
24 ## 'on' or 'off' and the set of the hidden line removal is set accordingly.
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
25 ## @seealso{mesh, meshc, surf}
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
26 ## @end deftypefn
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
27
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
28 ## PKG_ADD: mark_as_command hidden
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
29
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
30 function retval = hidden (mode)
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
31
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
32 if (nargin == 0)
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
33 mode = "swap";
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
34 elseif (nargin == 1);
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
35 if (ischar (mode))
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
36 mode = tolower (mode);
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
37 if (! strcmp (mode, "on") && ! strcmp (mode, "off"))
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
38 error ("hidden: mode expected to be 'on' or 'off'");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
39 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
40 else
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
41 error ("hidden: expecting mode to be a string");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
42 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
43 else
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
44 print_usage ();
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
45 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
46
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
47 for h = get (gca (), "children");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
48 htype = lower (get (h, "type"));
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
49 if (strcmp (htype, "surface"))
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
50 fc = get (h, "facecolor");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
51 if ((! ischar (fc) && is_white (fc))
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
52 || (ischar (fc) && strcmp (fc, "none")))
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
53 switch (mode)
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
54 case "on"
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
55 set (h, "facecolor", "w");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
56 case "off"
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
57 set (h, "facecolor", "none");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
58 case "swap"
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
59 if (ischar (fc))
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
60 set (h, "facecolor", "w");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
61 mode = "on";
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
62 else
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
63 set (h, "facecolor", "none");
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
64 mode = "off";
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
65 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
66 endswitch
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
67 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
68 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
69 endfor
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
70
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
71 if (nargout > 0)
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
72 retval = mode;
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
73 endif
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
74
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
75 endfunction
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
76
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
77 function retval = is_white (color)
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
78 retval = all (color == 1);
5c121a8b40b5 [project @ 2007-11-09 18:15:39 by jwe]
jwe
parents:
diff changeset
79 endfunction