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 |
|
20 ## usage: fmt = __pltopt1__ (caller, opt) |
|
21 ## |
|
22 ## Really decode plot option strings. |
|
23 ## |
|
24 ## See also: __pltopt__ |
|
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; |
|
40 set_errbars = 0; |
|
41 set_key = 0; |
|
42 more_opts = 1; |
|
43 |
|
44 WITH = "w"; |
|
45 LINES = "l"; |
|
46 LINESPOINTS = "linesp"; |
|
47 BOXERRORBARS = "boxer"; |
|
48 BOXES = "boxes"; |
|
49 POINTS = "p"; |
|
50 DOTS = "d"; |
|
51 IMPULSES = "i"; |
|
52 STEPS = "s"; |
|
53 ERRORBARS = "e"; |
|
54 TITLE = "title"; |
|
55 |
|
56 if (nargin != 2) |
|
57 usage ("__pltopt1__ (opt)"); |
|
58 endif |
|
59 |
|
60 if (! isstr (opt)) |
|
61 error ("__pltopt1__: argument must be a string"); |
|
62 endif |
|
63 |
|
64 while (more_opts) |
|
65 |
|
66 ## First get next char. |
|
67 |
|
68 if (max (size (opt)) > 1) |
|
69 # [char, opt] = sscanf (opt, "%c %s", "C"); |
|
70 char = opt(1); |
|
71 opt = opt(2:length(opt)); |
|
72 else |
|
73 char = opt; |
|
74 more_opts = 0; |
|
75 endif |
|
76 |
|
77 ## Now set flags based on char. |
|
78 |
|
79 if (strcmp (char, "-")) |
|
80 set_lines = 1; |
|
81 elseif (strcmp (char, ".")) |
|
82 set_dots = 1; |
|
83 elseif (strcmp (char, "@")) |
|
84 set_points = 1; |
|
85 elseif (strcmp (char, "^")) |
|
86 set_impulses = 1; |
|
87 elseif (strcmp (char, "L")) |
|
88 set_steps = 1; |
|
89 elseif (strcmp (char, "~")) |
|
90 set_errbars = 1; |
|
91 elseif (strcmp (char, "#")) |
|
92 set_boxes = 1; |
|
93 elseif (strcmp (char, "0") || strcmp (char, "1") ... |
|
94 || strcmp (char, "2") || strcmp (char, "3") ... |
|
95 || strcmp (char, "4") || strcmp (char, "5") ... |
|
96 || strcmp (char, "6") || strcmp (char, "7") ... |
|
97 || strcmp (char, "8") || strcmp (char, "9")) |
|
98 if (set_color) |
|
99 set_points = 1; |
|
100 symbol = char; |
|
101 set_symbol = 1; |
|
102 else |
|
103 color = char; |
|
104 set_color = 1; |
|
105 endif |
|
106 elseif (strcmp (char, "r")) |
|
107 set_color = 1; |
|
108 color = "1"; |
|
109 elseif (strcmp (char, "g")) |
|
110 set_color = 1; |
|
111 color = "2"; |
|
112 elseif (strcmp (char, "b")) |
|
113 set_color = 1; |
|
114 color = "3"; |
|
115 elseif (strcmp (char, "m")) |
|
116 set_color = 1; |
|
117 color = "4"; |
|
118 elseif (strcmp (char, "c")) |
|
119 set_color = 1; |
|
120 color = "5"; |
3233
|
121 elseif (strcmp (char, "w") || strcmp (char, "k")) |
3162
|
122 set_color = 1; |
|
123 color = "6"; |
|
124 elseif (strcmp (char, "*")) |
|
125 set_points = 1; |
|
126 set_symbol = 1; |
|
127 symbol = "6"; |
|
128 elseif (strcmp (char, "+")) |
|
129 set_points = 1; |
|
130 set_symbol = 1; |
|
131 symbol = "2"; |
|
132 elseif (strcmp (char, "o")) |
|
133 set_points = 1; |
|
134 set_symbol = 1; |
|
135 symbol = "1"; |
|
136 elseif (strcmp (char, "x")) |
|
137 set_points = 1; |
|
138 set_symbol = 1; |
|
139 symbol = "4"; |
|
140 elseif (strcmp (char, ";")) # title mode. |
|
141 set_key = 1; |
|
142 working = 1; |
|
143 key_title = ""; |
|
144 while (working) |
|
145 if (max (size (opt)) > 1) |
|
146 char = opt(1); |
|
147 opt = opt(2:length(opt)); |
|
148 else |
|
149 char = opt; |
|
150 if (! strcmp (char, ";")) |
|
151 error ("%s: unfinished key label", caller); |
|
152 end |
|
153 more_opts = 0; |
|
154 working = 0; |
|
155 endif |
|
156 if strcmp (char, ";") |
|
157 working = 0; |
|
158 else |
|
159 if (isempty (key_title)) # needs this to avoid empty matrix warning. |
|
160 key_title = char; |
|
161 else |
|
162 key_title = strcat (key_title, char); |
|
163 endif |
|
164 endif |
|
165 endwhile |
|
166 elseif (strcmp (char, " ")) |
|
167 ## whitespace -- do nothing. |
|
168 else |
|
169 error ("%s: unrecognized format character: '%s'", caller, char); |
|
170 endif |
|
171 endwhile |
|
172 |
|
173 ## Now create format string. |
|
174 |
|
175 fmt = WITH; |
|
176 |
|
177 if (set_lines) |
|
178 if (set_points) |
|
179 fmt = strcat (fmt, " ", LINESPOINTS); |
|
180 else |
|
181 fmt = strcat (fmt, " ", LINES); |
|
182 endif |
|
183 elseif (set_boxes) |
|
184 if (set_errbars) |
|
185 fmt = strcat (fmt, " ", BOXERRORBARS); |
|
186 else |
|
187 fmt = strcat (fmt, " ", BOXES); |
|
188 endif |
|
189 elseif (set_points) |
|
190 fmt = strcat (fmt, " ", POINTS); |
|
191 elseif (set_dots) |
|
192 fmt = strcat (fmt, " ", DOTS); |
|
193 elseif (set_impulses) |
|
194 fmt = strcat (fmt, " ", IMPULSES); |
|
195 elseif (set_steps) |
|
196 fmt = strcat (fmt, " ", STEPS); |
|
197 elseif (set_errbars) |
|
198 fmt = strcat (fmt, " ", ERRORBARS); |
|
199 endif |
|
200 |
|
201 if (strcmp (fmt, WITH)) |
|
202 fmt = strcat (fmt, " ", LINES); |
|
203 endif |
|
204 |
|
205 if (set_color) |
|
206 fmt = strcat (fmt, " ", color); |
|
207 if (set_symbol) |
|
208 fmt = strcat (fmt, " ", symbol); |
|
209 endif |
|
210 elseif (set_symbol) |
|
211 fmt = strcat (fmt, " 1 ", symbol); |
|
212 endif |
|
213 |
|
214 if (set_key) |
|
215 fmt = sprintf ("%s %s \"%s\" ", fmt, TITLE, key_title); |
|
216 endif |
|
217 endfunction |