3162
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
|
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 2, or (at your option) |
|
8 ## 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, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
3162
|
19 |
3407
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {} __pltopt1__ (@var{caller}, @var{opt}) |
3162
|
22 ## Really decode plot option strings. |
5642
|
23 ## @seealso{__pltopt__} |
3407
|
24 ## @end deftypefn |
3162
|
25 |
|
26 ## Author: Rick Niles <niles@axp745.gsfc.nasa.gov> |
|
27 ## Adapted-By: jwe |
|
28 ## Maintainer: jwe |
|
29 |
6264
|
30 function options = __pltopt1__ (caller, opt) |
3162
|
31 |
6264
|
32 options = __default_plot_options__ (); |
4841
|
33 |
3162
|
34 more_opts = 1; |
|
35 |
|
36 if (nargin != 2) |
6046
|
37 print_usage (); |
3162
|
38 endif |
|
39 |
5443
|
40 if (! ischar (opt)) |
6146
|
41 return; |
3162
|
42 endif |
|
43 |
6395
|
44 have_linestyle = false; |
|
45 have_marker = false; |
|
46 |
6264
|
47 while (! isempty (opt)) |
|
48 if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2)) |
|
49 options.linestyle = opt(1:2); |
|
50 n = 2; |
3162
|
51 else |
6264
|
52 topt = opt(1); |
|
53 n = 1; |
|
54 if (topt == "-" || topt == ":") |
6395
|
55 have_linestyle = true; |
6264
|
56 options.linestyle = topt; |
|
57 elseif (topt == "+" || topt == "o" || topt == "*" |
|
58 || topt == "." || topt == "x" || topt == "s" |
|
59 || topt == "d" || topt == "^" || topt == "v" |
|
60 || topt == ">" || topt == "<" || topt == "p" |
6442
|
61 || topt == "h" || topt == "@") |
6395
|
62 have_marker = true; |
6442
|
63 ## Backward compatibility. Leave undocumented. |
|
64 if (topt == "@") |
|
65 topt = "+"; |
|
66 endif |
6264
|
67 options.marker = topt; |
|
68 elseif (topt == "k") |
|
69 options.color = [0, 0, 0]; |
|
70 elseif (topt == "r") |
|
71 options.color = [1, 0, 0]; |
|
72 elseif (topt == "g") |
|
73 options.color = [0, 1, 0]; |
|
74 elseif (topt == "b") |
|
75 options.color = [0, 0, 1]; |
|
76 elseif (topt == "y") |
|
77 options.color = [1, 1, 0]; |
|
78 elseif (topt == "m") |
|
79 options.color = [1, 0, 1]; |
|
80 elseif (topt == "c") |
|
81 options.color = [0, 1, 1]; |
|
82 elseif (topt == "w") |
|
83 options.color = [1, 1, 1]; |
|
84 elseif (isspace (topt)) |
|
85 ## Do nothing. |
|
86 elseif (topt == ";") |
|
87 t = index (opt(2:end), ";"); |
|
88 if (t) |
|
89 options.key = undo_string_escapes (opt(2:t)); |
|
90 n = t+1; |
|
91 else |
|
92 error ("%s: unfinished key label", caller); |
|
93 endif |
3617
|
94 else |
6264
|
95 error ("%s: unrecognized format character: `%s'", caller, topt); |
3162
|
96 endif |
|
97 endif |
6264
|
98 opt(1:n) = []; |
3162
|
99 endwhile |
|
100 |
6395
|
101 if (have_marker && ! have_linestyle) |
|
102 options.linestyle = ""; |
|
103 endif |
|
104 |
3162
|
105 endfunction |