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 |
|
30 function fmt = __pltopt1__ (caller, opt) |
|
31 |
|
32 set_color = 0; |
|
33 set_symbol = 0; |
|
34 set_lines = 0; |
|
35 set_dots = 0; |
|
36 set_points = 0; |
|
37 set_impulses = 0; |
|
38 set_steps = 0; |
|
39 set_boxes = 0; |
3717
|
40 set_yerrbars = 0; |
|
41 set_xerrbars = 0; |
3617
|
42 set_linestyle = "solid"; |
|
43 |
4841
|
44 key_title = ""; |
|
45 |
3162
|
46 more_opts = 1; |
|
47 |
|
48 WITH = "w"; |
|
49 LINES = "l"; |
|
50 LINESPOINTS = "linesp"; |
|
51 BOXERRORBARS = "boxer"; |
|
52 BOXES = "boxes"; |
4006
|
53 BOXXY = "boxxy"; |
3162
|
54 POINTS = "p"; |
|
55 DOTS = "d"; |
|
56 IMPULSES = "i"; |
|
57 STEPS = "s"; |
3717
|
58 YERRORBARS = "yerr"; |
|
59 XERRORBARS = "xerr"; |
|
60 XYERRORBARS = "xyerr"; |
3162
|
61 TITLE = "title"; |
|
62 |
|
63 if (nargin != 2) |
6046
|
64 print_usage (); |
3162
|
65 endif |
|
66 |
5443
|
67 if (! ischar (opt)) |
3162
|
68 error ("__pltopt1__: argument must be a string"); |
|
69 endif |
|
70 |
|
71 while (more_opts) |
|
72 |
|
73 ## First get next char. |
|
74 |
|
75 if (max (size (opt)) > 1) |
4007
|
76 ## [char, opt] = sscanf (opt, "%c %s", "C"); |
|
77 char = opt(1); |
|
78 opt = opt(2:length(opt)); |
3162
|
79 else |
|
80 char = opt; |
|
81 more_opts = 0; |
|
82 endif |
|
83 |
|
84 ## Now set flags based on char. |
|
85 |
|
86 if (strcmp (char, "-")) |
3617
|
87 if (set_lines) |
|
88 set_linestyle = "dash"; |
|
89 else |
|
90 set_lines = 1; |
|
91 endif |
3162
|
92 elseif (strcmp (char, ".")) |
3617
|
93 if (set_lines) |
|
94 set_linestyle = "dashdot"; |
|
95 else |
|
96 set_dots = 1; |
|
97 endif |
|
98 elseif (strcmp (char, ":")) |
|
99 set_lines = 1; |
|
100 set_linestyle = "dot"; |
3162
|
101 elseif (strcmp (char, "@")) |
|
102 set_points = 1; |
|
103 elseif (strcmp (char, "^")) |
|
104 set_impulses = 1; |
|
105 elseif (strcmp (char, "L")) |
|
106 set_steps = 1; |
|
107 elseif (strcmp (char, "~")) |
3717
|
108 set_yerrbars = 1; |
|
109 elseif (strcmp (char, ">")) |
4007
|
110 set_xerrbars = 1; |
3162
|
111 elseif (strcmp (char, "#")) |
|
112 set_boxes = 1; |
|
113 elseif (strcmp (char, "0") || strcmp (char, "1") ... |
|
114 || strcmp (char, "2") || strcmp (char, "3") ... |
|
115 || strcmp (char, "4") || strcmp (char, "5") ... |
|
116 || strcmp (char, "6") || strcmp (char, "7") ... |
|
117 || strcmp (char, "8") || strcmp (char, "9")) |
|
118 if (set_color) |
3426
|
119 set_points = 1; |
|
120 symbol = char; |
|
121 set_symbol = 1; |
3162
|
122 else |
3426
|
123 color = char; |
|
124 set_color = 1; |
3162
|
125 endif |
5462
|
126 elseif (strcmp (char, "k")) |
|
127 set_color = 1; |
|
128 color = "-1"; |
3162
|
129 elseif (strcmp (char, "r")) |
|
130 set_color = 1; |
|
131 color = "1"; |
|
132 elseif (strcmp (char, "g")) |
|
133 set_color = 1; |
|
134 color = "2"; |
|
135 elseif (strcmp (char, "b")) |
|
136 set_color = 1; |
|
137 color = "3"; |
|
138 elseif (strcmp (char, "m")) |
|
139 set_color = 1; |
|
140 color = "4"; |
|
141 elseif (strcmp (char, "c")) |
|
142 set_color = 1; |
|
143 color = "5"; |
5462
|
144 elseif (strcmp (char, "w")) |
3162
|
145 set_color = 1; |
|
146 color = "6"; |
|
147 elseif (strcmp (char, "*")) |
|
148 set_points = 1; |
|
149 set_symbol = 1; |
6085
|
150 symbol = "3"; |
|
151 elseif (strcmp (char, "+")) |
|
152 set_points = 1; |
|
153 set_symbol = 1; |
|
154 symbol = "1"; |
|
155 elseif (strcmp (char, "o")) |
|
156 set_points = 1; |
|
157 set_symbol = 1; |
3162
|
158 symbol = "6"; |
6085
|
159 elseif (strcmp (char, "x")) |
3162
|
160 set_points = 1; |
|
161 set_symbol = 1; |
|
162 symbol = "2"; |
6085
|
163 elseif (strcmp (char, "s")) |
3162
|
164 set_points = 1; |
|
165 set_symbol = 1; |
|
166 symbol = "4"; |
6085
|
167 elseif (strcmp (char, "d")) |
|
168 set_points = 1; |
|
169 set_symbol = 1; |
|
170 symbol = "12"; |
|
171 elseif (strcmp (char, "v")) |
|
172 set_points = 1; |
|
173 set_symbol = 1; |
|
174 symbol = "10"; |
3162
|
175 elseif (strcmp (char, ";")) # title mode. |
|
176 working = 1; |
|
177 while (working) |
|
178 if (max (size (opt)) > 1) |
3426
|
179 char = opt(1); |
|
180 opt = opt(2:length(opt)); |
3162
|
181 else |
3426
|
182 char = opt; |
|
183 if (! strcmp (char, ";")) |
3162
|
184 error ("%s: unfinished key label", caller); |
4006
|
185 endif |
3162
|
186 more_opts = 0; |
|
187 working = 0; |
|
188 endif |
|
189 if strcmp (char, ";") |
|
190 working = 0; |
|
191 else |
3426
|
192 if (isempty (key_title)) # needs this to avoid empty matrix warning. |
3162
|
193 key_title = char; |
3426
|
194 else |
3162
|
195 key_title = strcat (key_title, char); |
3426
|
196 endif |
3162
|
197 endif |
|
198 endwhile |
4260
|
199 key_title = undo_string_escapes (key_title); |
3426
|
200 elseif (strcmp (char, " ")) |
4006
|
201 elseif (isempty(char)) |
3162
|
202 ## whitespace -- do nothing. |
|
203 else |
|
204 error ("%s: unrecognized format character: '%s'", caller, char); |
|
205 endif |
|
206 endwhile |
|
207 |
|
208 ## Now create format string. |
|
209 |
|
210 fmt = WITH; |
|
211 |
|
212 if (set_lines) |
|
213 if (set_points) |
|
214 fmt = strcat (fmt, " ", LINESPOINTS); |
|
215 else |
|
216 fmt = strcat (fmt, " ", LINES); |
|
217 endif |
|
218 elseif (set_boxes) |
4006
|
219 if (set_yerrbars && set_xerrbars) |
|
220 fmt = strcat (fmt, " ", BOXXY); |
|
221 elseif (set_yerrbars ) |
3162
|
222 fmt = strcat (fmt, " ", BOXERRORBARS); |
|
223 else |
|
224 fmt = strcat (fmt, " ", BOXES); |
|
225 endif |
|
226 elseif (set_points) |
|
227 fmt = strcat (fmt, " ", POINTS); |
|
228 elseif (set_dots) |
|
229 fmt = strcat (fmt, " ", DOTS); |
|
230 elseif (set_impulses) |
|
231 fmt = strcat (fmt, " ", IMPULSES); |
|
232 elseif (set_steps) |
|
233 fmt = strcat (fmt, " ", STEPS); |
3717
|
234 elseif (set_yerrbars) |
5405
|
235 if (set_xerrbars) |
|
236 fmt = strcat (fmt, " ", XYERRORBARS); |
3717
|
237 else |
5405
|
238 fmt = strcat (fmt, " ", YERRORBARS); |
3717
|
239 endif |
|
240 elseif (set_xerrbars) |
|
241 fmt = strcat (fmt, " ", XERRORBARS); |
3162
|
242 endif |
|
243 |
|
244 if (strcmp (fmt, WITH)) |
4007
|
245 if (strcmp (caller, "__errplot__")) |
|
246 fmt = strcat (fmt, " ", YERRORBARS); |
|
247 else |
|
248 fmt = strcat (fmt, " ", LINES); |
|
249 endif |
3162
|
250 endif |
|
251 |
|
252 if (set_color) |
|
253 fmt = strcat (fmt, " ", color); |
|
254 if (set_symbol) |
|
255 fmt = strcat (fmt, " ", symbol); |
|
256 endif |
|
257 elseif (set_symbol) |
|
258 fmt = strcat (fmt, " 1 ", symbol); |
|
259 endif |
|
260 |
4841
|
261 fmt = sprintf ("%s %s \"%s\" ", fmt, TITLE, key_title); |
|
262 |
3162
|
263 endfunction |