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 |
6459
|
30 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid) |
3162
|
31 |
6264
|
32 options = __default_plot_options__ (); |
6459
|
33 valid = true; |
4841
|
34 |
3162
|
35 more_opts = 1; |
|
36 |
6459
|
37 if (nargin != 2 && nargin != 3) |
6046
|
38 print_usage (); |
3162
|
39 endif |
|
40 |
5443
|
41 if (! ischar (opt)) |
6146
|
42 return; |
3162
|
43 endif |
|
44 |
6395
|
45 have_linestyle = false; |
|
46 have_marker = false; |
|
47 |
6264
|
48 while (! isempty (opt)) |
|
49 if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2)) |
|
50 options.linestyle = opt(1:2); |
|
51 n = 2; |
3162
|
52 else |
6264
|
53 topt = opt(1); |
|
54 n = 1; |
|
55 if (topt == "-" || topt == ":") |
6395
|
56 have_linestyle = true; |
6264
|
57 options.linestyle = topt; |
|
58 elseif (topt == "+" || topt == "o" || topt == "*" |
|
59 || topt == "." || topt == "x" || topt == "s" |
|
60 || topt == "d" || topt == "^" || topt == "v" |
|
61 || topt == ">" || topt == "<" || topt == "p" |
6442
|
62 || topt == "h" || topt == "@") |
6395
|
63 have_marker = true; |
6442
|
64 ## Backward compatibility. Leave undocumented. |
|
65 if (topt == "@") |
|
66 topt = "+"; |
|
67 endif |
6264
|
68 options.marker = topt; |
6444
|
69 ### Numeric color specs for backward compatibility. Leave undocumented. |
|
70 elseif (topt == "k" || topt == "0") |
6264
|
71 options.color = [0, 0, 0]; |
6444
|
72 elseif (topt == "r" || topt == "1") |
6264
|
73 options.color = [1, 0, 0]; |
6444
|
74 elseif (topt == "g" || topt == "2") |
6264
|
75 options.color = [0, 1, 0]; |
6444
|
76 elseif (topt == "b" || topt == "3") |
6264
|
77 options.color = [0, 0, 1]; |
|
78 elseif (topt == "y") |
|
79 options.color = [1, 1, 0]; |
6444
|
80 elseif (topt == "m" || topt == "4") |
6264
|
81 options.color = [1, 0, 1]; |
6444
|
82 elseif (topt == "c" || topt == "5") |
6264
|
83 options.color = [0, 1, 1]; |
6444
|
84 elseif (topt == "w" || topt == "6") |
6264
|
85 options.color = [1, 1, 1]; |
|
86 elseif (isspace (topt)) |
|
87 ## Do nothing. |
|
88 elseif (topt == ";") |
|
89 t = index (opt(2:end), ";"); |
|
90 if (t) |
|
91 options.key = undo_string_escapes (opt(2:t)); |
|
92 n = t+1; |
|
93 else |
6459
|
94 if (err_on_invalid) |
|
95 error ("%s: unfinished key label", caller); |
|
96 else |
|
97 valid = false; |
|
98 options = __default_plot_options__ (); |
|
99 return; |
|
100 endif |
6264
|
101 endif |
3617
|
102 else |
6459
|
103 if (err_on_invalid) |
|
104 error ("%s: unrecognized format character: `%s'", caller, topt); |
|
105 else |
|
106 valid = false; |
|
107 options = __default_plot_options__ (); |
|
108 return; |
|
109 endif |
3162
|
110 endif |
|
111 endif |
6264
|
112 opt(1:n) = []; |
3162
|
113 endwhile |
|
114 |
6395
|
115 if (have_marker && ! have_linestyle) |
|
116 options.linestyle = ""; |
|
117 endif |
|
118 |
3162
|
119 endfunction |