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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
3162
|
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 |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
3162
|
18 |
6895
|
19 ## Undocumented internal function. |
|
20 |
3162
|
21 ## Really decode plot option strings. |
|
22 |
|
23 ## Author: Rick Niles <niles@axp745.gsfc.nasa.gov> |
|
24 ## Adapted-By: jwe |
|
25 ## Maintainer: jwe |
|
26 |
6459
|
27 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid) |
3162
|
28 |
6264
|
29 options = __default_plot_options__ (); |
6459
|
30 valid = true; |
4841
|
31 |
3162
|
32 more_opts = 1; |
|
33 |
6459
|
34 if (nargin != 2 && nargin != 3) |
6046
|
35 print_usage (); |
3162
|
36 endif |
|
37 |
5443
|
38 if (! ischar (opt)) |
6146
|
39 return; |
3162
|
40 endif |
|
41 |
6395
|
42 have_linestyle = false; |
|
43 have_marker = false; |
|
44 |
6736
|
45 ## If called by __errplot__, extract the linestyle before proceeding. |
|
46 if (strcmp (caller,"__errplot__")) |
|
47 if (strncmp (opt, "#~>", 3)) |
|
48 n = 3; |
|
49 elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2)) |
|
50 n = 2; |
|
51 elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1) |
|
52 || strncmp (opt, "#", 1)) |
|
53 n = 1; |
|
54 endif |
|
55 options.linestyle = opt(1:n); |
|
56 opt(1:n) = []; |
|
57 have_linestyle = true; |
|
58 endif |
|
59 |
6264
|
60 while (! isempty (opt)) |
|
61 if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2)) |
|
62 options.linestyle = opt(1:2); |
6704
|
63 have_linestyle = true; |
6264
|
64 n = 2; |
3162
|
65 else |
6264
|
66 topt = opt(1); |
|
67 n = 1; |
|
68 if (topt == "-" || topt == ":") |
6395
|
69 have_linestyle = true; |
6264
|
70 options.linestyle = topt; |
|
71 elseif (topt == "+" || topt == "o" || topt == "*" |
|
72 || topt == "." || topt == "x" || topt == "s" |
|
73 || topt == "d" || topt == "^" || topt == "v" |
|
74 || topt == ">" || topt == "<" || topt == "p" |
6442
|
75 || topt == "h" || topt == "@") |
6395
|
76 have_marker = true; |
6442
|
77 ## Backward compatibility. Leave undocumented. |
|
78 if (topt == "@") |
|
79 topt = "+"; |
|
80 endif |
6264
|
81 options.marker = topt; |
6444
|
82 ### Numeric color specs for backward compatibility. Leave undocumented. |
|
83 elseif (topt == "k" || topt == "0") |
6264
|
84 options.color = [0, 0, 0]; |
6444
|
85 elseif (topt == "r" || topt == "1") |
6264
|
86 options.color = [1, 0, 0]; |
6444
|
87 elseif (topt == "g" || topt == "2") |
6264
|
88 options.color = [0, 1, 0]; |
6444
|
89 elseif (topt == "b" || topt == "3") |
6264
|
90 options.color = [0, 0, 1]; |
|
91 elseif (topt == "y") |
|
92 options.color = [1, 1, 0]; |
6444
|
93 elseif (topt == "m" || topt == "4") |
6264
|
94 options.color = [1, 0, 1]; |
6444
|
95 elseif (topt == "c" || topt == "5") |
6264
|
96 options.color = [0, 1, 1]; |
6444
|
97 elseif (topt == "w" || topt == "6") |
6264
|
98 options.color = [1, 1, 1]; |
|
99 elseif (isspace (topt)) |
|
100 ## Do nothing. |
|
101 elseif (topt == ";") |
|
102 t = index (opt(2:end), ";"); |
|
103 if (t) |
|
104 options.key = undo_string_escapes (opt(2:t)); |
|
105 n = t+1; |
|
106 else |
6459
|
107 if (err_on_invalid) |
|
108 error ("%s: unfinished key label", caller); |
|
109 else |
|
110 valid = false; |
|
111 options = __default_plot_options__ (); |
|
112 return; |
|
113 endif |
6264
|
114 endif |
3617
|
115 else |
6459
|
116 if (err_on_invalid) |
|
117 error ("%s: unrecognized format character: `%s'", caller, topt); |
|
118 else |
|
119 valid = false; |
|
120 options = __default_plot_options__ (); |
|
121 return; |
|
122 endif |
3162
|
123 endif |
|
124 endif |
6264
|
125 opt(1:n) = []; |
3162
|
126 endwhile |
|
127 |
6395
|
128 if (have_marker && ! have_linestyle) |
6704
|
129 options.linestyle = "none"; |
6395
|
130 endif |
|
131 |
3162
|
132 endfunction |