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; |
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) |
|
64 usage ("__pltopt1__ (opt)"); |
|
65 endif |
|
66 |
|
67 if (! isstr (opt)) |
|
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 |
|
126 elseif (strcmp (char, "r")) |
|
127 set_color = 1; |
|
128 color = "1"; |
|
129 elseif (strcmp (char, "g")) |
|
130 set_color = 1; |
|
131 color = "2"; |
|
132 elseif (strcmp (char, "b")) |
|
133 set_color = 1; |
|
134 color = "3"; |
|
135 elseif (strcmp (char, "m")) |
|
136 set_color = 1; |
|
137 color = "4"; |
|
138 elseif (strcmp (char, "c")) |
|
139 set_color = 1; |
|
140 color = "5"; |
3233
|
141 elseif (strcmp (char, "w") || strcmp (char, "k")) |
3162
|
142 set_color = 1; |
|
143 color = "6"; |
|
144 elseif (strcmp (char, "*")) |
|
145 set_points = 1; |
|
146 set_symbol = 1; |
|
147 symbol = "6"; |
|
148 elseif (strcmp (char, "+")) |
|
149 set_points = 1; |
|
150 set_symbol = 1; |
|
151 symbol = "2"; |
|
152 elseif (strcmp (char, "o")) |
|
153 set_points = 1; |
|
154 set_symbol = 1; |
|
155 symbol = "1"; |
|
156 elseif (strcmp (char, "x")) |
|
157 set_points = 1; |
|
158 set_symbol = 1; |
|
159 symbol = "4"; |
|
160 elseif (strcmp (char, ";")) # title mode. |
|
161 working = 1; |
|
162 while (working) |
|
163 if (max (size (opt)) > 1) |
3426
|
164 char = opt(1); |
|
165 opt = opt(2:length(opt)); |
3162
|
166 else |
3426
|
167 char = opt; |
|
168 if (! strcmp (char, ";")) |
3162
|
169 error ("%s: unfinished key label", caller); |
4006
|
170 endif |
3162
|
171 more_opts = 0; |
|
172 working = 0; |
|
173 endif |
|
174 if strcmp (char, ";") |
|
175 working = 0; |
|
176 else |
3426
|
177 if (isempty (key_title)) # needs this to avoid empty matrix warning. |
3162
|
178 key_title = char; |
3426
|
179 else |
3162
|
180 key_title = strcat (key_title, char); |
3426
|
181 endif |
3162
|
182 endif |
|
183 endwhile |
4260
|
184 key_title = undo_string_escapes (key_title); |
3426
|
185 elseif (strcmp (char, " ")) |
4006
|
186 elseif (isempty(char)) |
3162
|
187 ## whitespace -- do nothing. |
|
188 else |
|
189 error ("%s: unrecognized format character: '%s'", caller, char); |
|
190 endif |
|
191 endwhile |
|
192 |
|
193 ## Now create format string. |
|
194 |
|
195 fmt = WITH; |
|
196 |
|
197 if (set_lines) |
|
198 if (set_points) |
|
199 fmt = strcat (fmt, " ", LINESPOINTS); |
|
200 else |
|
201 fmt = strcat (fmt, " ", LINES); |
|
202 endif |
|
203 elseif (set_boxes) |
4006
|
204 if (set_yerrbars && set_xerrbars) |
|
205 fmt = strcat (fmt, " ", BOXXY); |
|
206 elseif (set_yerrbars ) |
3162
|
207 fmt = strcat (fmt, " ", BOXERRORBARS); |
|
208 else |
|
209 fmt = strcat (fmt, " ", BOXES); |
|
210 endif |
|
211 elseif (set_points) |
|
212 fmt = strcat (fmt, " ", POINTS); |
|
213 elseif (set_dots) |
|
214 fmt = strcat (fmt, " ", DOTS); |
|
215 elseif (set_impulses) |
|
216 fmt = strcat (fmt, " ", IMPULSES); |
|
217 elseif (set_steps) |
|
218 fmt = strcat (fmt, " ", STEPS); |
3717
|
219 elseif (set_yerrbars) |
|
220 if(set_xerrbars) |
|
221 fmt = strcat (fmt, " ", XYERRORBARS); |
|
222 else |
|
223 fmt = strcat (fmt, " ", YERRORBARS); |
|
224 endif |
|
225 elseif (set_xerrbars) |
|
226 fmt = strcat (fmt, " ", XERRORBARS); |
3162
|
227 endif |
|
228 |
|
229 if (strcmp (fmt, WITH)) |
4007
|
230 if (strcmp (caller, "__errplot__")) |
|
231 fmt = strcat (fmt, " ", YERRORBARS); |
|
232 else |
|
233 fmt = strcat (fmt, " ", LINES); |
|
234 endif |
3162
|
235 endif |
|
236 |
|
237 if (set_color) |
|
238 fmt = strcat (fmt, " ", color); |
|
239 if (set_symbol) |
|
240 fmt = strcat (fmt, " ", symbol); |
|
241 endif |
|
242 elseif (set_symbol) |
|
243 fmt = strcat (fmt, " 1 ", symbol); |
|
244 endif |
|
245 |
4841
|
246 fmt = sprintf ("%s %s \"%s\" ", fmt, TITLE, key_title); |
|
247 |
3162
|
248 endfunction |