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