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