7017
|
1 ## Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
|
2 ## 2006, 2007 John W. Eaton |
3162
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3162
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3162
|
19 |
6895
|
20 ## Undocumented internal function. |
|
21 |
3162
|
22 ## Really decode plot option strings. |
|
23 |
|
24 ## Author: Rick Niles <niles@axp745.gsfc.nasa.gov> |
|
25 ## Adapted-By: jwe |
|
26 ## Maintainer: jwe |
|
27 |
6459
|
28 function [options, valid] = __pltopt1__ (caller, opt, err_on_invalid) |
3162
|
29 |
6264
|
30 options = __default_plot_options__ (); |
6459
|
31 valid = true; |
4841
|
32 |
3162
|
33 more_opts = 1; |
|
34 |
6459
|
35 if (nargin != 2 && nargin != 3) |
6046
|
36 print_usage (); |
3162
|
37 endif |
|
38 |
5443
|
39 if (! ischar (opt)) |
6146
|
40 return; |
3162
|
41 endif |
|
42 |
6395
|
43 have_linestyle = false; |
|
44 have_marker = false; |
|
45 |
6736
|
46 ## If called by __errplot__, extract the linestyle before proceeding. |
|
47 if (strcmp (caller,"__errplot__")) |
|
48 if (strncmp (opt, "#~>", 3)) |
|
49 n = 3; |
|
50 elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2)) |
|
51 n = 2; |
|
52 elseif (strncmp (opt, "~", 1) || strncmp (opt, ">", 1) |
|
53 || strncmp (opt, "#", 1)) |
|
54 n = 1; |
|
55 endif |
|
56 options.linestyle = opt(1:n); |
|
57 opt(1:n) = []; |
|
58 have_linestyle = true; |
|
59 endif |
|
60 |
6264
|
61 while (! isempty (opt)) |
|
62 if (strncmp (opt, "--", 2) || strncmp (opt, "-.", 2)) |
|
63 options.linestyle = opt(1:2); |
6704
|
64 have_linestyle = true; |
6264
|
65 n = 2; |
3162
|
66 else |
6264
|
67 topt = opt(1); |
|
68 n = 1; |
|
69 if (topt == "-" || topt == ":") |
6395
|
70 have_linestyle = true; |
6264
|
71 options.linestyle = topt; |
|
72 elseif (topt == "+" || topt == "o" || topt == "*" |
|
73 || topt == "." || topt == "x" || topt == "s" |
|
74 || topt == "d" || topt == "^" || topt == "v" |
|
75 || topt == ">" || topt == "<" || topt == "p" |
6442
|
76 || topt == "h" || topt == "@") |
6395
|
77 have_marker = true; |
6442
|
78 ## Backward compatibility. Leave undocumented. |
|
79 if (topt == "@") |
|
80 topt = "+"; |
|
81 endif |
6264
|
82 options.marker = topt; |
6444
|
83 ### Numeric color specs for backward compatibility. Leave undocumented. |
|
84 elseif (topt == "k" || topt == "0") |
6264
|
85 options.color = [0, 0, 0]; |
6444
|
86 elseif (topt == "r" || topt == "1") |
6264
|
87 options.color = [1, 0, 0]; |
6444
|
88 elseif (topt == "g" || topt == "2") |
6264
|
89 options.color = [0, 1, 0]; |
6444
|
90 elseif (topt == "b" || topt == "3") |
6264
|
91 options.color = [0, 0, 1]; |
|
92 elseif (topt == "y") |
|
93 options.color = [1, 1, 0]; |
6444
|
94 elseif (topt == "m" || topt == "4") |
6264
|
95 options.color = [1, 0, 1]; |
6444
|
96 elseif (topt == "c" || topt == "5") |
6264
|
97 options.color = [0, 1, 1]; |
6444
|
98 elseif (topt == "w" || topt == "6") |
6264
|
99 options.color = [1, 1, 1]; |
|
100 elseif (isspace (topt)) |
|
101 ## Do nothing. |
|
102 elseif (topt == ";") |
|
103 t = index (opt(2:end), ";"); |
|
104 if (t) |
|
105 options.key = undo_string_escapes (opt(2:t)); |
|
106 n = t+1; |
|
107 else |
6459
|
108 if (err_on_invalid) |
|
109 error ("%s: unfinished key label", caller); |
|
110 else |
|
111 valid = false; |
|
112 options = __default_plot_options__ (); |
|
113 return; |
|
114 endif |
6264
|
115 endif |
3617
|
116 else |
6459
|
117 if (err_on_invalid) |
|
118 error ("%s: unrecognized format character: `%s'", caller, topt); |
|
119 else |
|
120 valid = false; |
|
121 options = __default_plot_options__ (); |
|
122 return; |
|
123 endif |
3162
|
124 endif |
|
125 endif |
6264
|
126 opt(1:n) = []; |
3162
|
127 endwhile |
|
128 |
6395
|
129 if (have_marker && ! have_linestyle) |
6704
|
130 options.linestyle = "none"; |
6395
|
131 endif |
|
132 |
3162
|
133 endfunction |