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