1740
|
1 // pt-plot.h -*- C++ -*- |
454
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
454
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
454
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_tree_plot_h) |
|
25 #define octave_tree_plot_h 1 |
|
26 |
1297
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
1740
|
31 class ostream; |
|
32 class ostrstream; |
581
|
33 |
524
|
34 class tree_command; |
454
|
35 class tree_plot_command; |
578
|
36 class plot_limits; |
|
37 class plot_range; |
|
38 class subplot_using; |
|
39 class subplot_style; |
|
40 class subplot; |
|
41 class subplot_list; |
454
|
42 |
1745
|
43 #include <string> |
|
44 |
578
|
45 #include <SLList.h> |
|
46 |
872
|
47 #include "dColVector.h" |
|
48 |
|
49 #include "idx-vector.h" |
1740
|
50 #include "pt-cmd.h" |
|
51 #include "pt-exp.h" |
454
|
52 |
|
53 class |
|
54 tree_plot_command : public tree_command |
|
55 { |
593
|
56 public: |
1740
|
57 tree_plot_command (subplot_list *plt = 0, plot_limits *rng = 0, int nd = 0) |
|
58 : tree_command (), ndim (nd), range (rng), plot_list (plt) { } |
454
|
59 |
|
60 ~tree_plot_command (void); |
|
61 |
578
|
62 void eval (void); |
454
|
63 |
593
|
64 void print_code (ostream& os); |
581
|
65 |
593
|
66 private: |
454
|
67 int ndim; |
578
|
68 plot_limits *range; |
|
69 subplot_list *plot_list; |
454
|
70 }; |
|
71 |
|
72 class |
593
|
73 plot_limits : public tree_print_code |
454
|
74 { |
593
|
75 public: |
1740
|
76 plot_limits (plot_range *xlim = 0, plot_range *ylim = 0, |
|
77 plot_range *zlim = 0) |
|
78 : tree_print_code (), x_range (xlim), y_range (ylim), z_range (zlim) { } |
454
|
79 |
578
|
80 ~plot_limits (void); |
454
|
81 |
|
82 void print (int print, ostrstream& plot_buf); |
|
83 |
593
|
84 void print_code (ostream& os); |
|
85 |
|
86 private: |
578
|
87 plot_range *x_range; |
|
88 plot_range *y_range; |
|
89 plot_range *z_range; |
454
|
90 }; |
|
91 |
|
92 class |
593
|
93 plot_range : public tree_print_code |
454
|
94 { |
593
|
95 public: |
1740
|
96 plot_range (tree_expression *l = 0, tree_expression *u = 0) |
|
97 : tree_print_code (), lower (l), upper (u) { } |
454
|
98 |
578
|
99 ~plot_range (void); |
454
|
100 |
|
101 void print (ostrstream& plot_buf); |
|
102 |
593
|
103 void print_code (ostream& os); |
|
104 |
|
105 private: |
491
|
106 tree_expression *lower; |
|
107 tree_expression *upper; |
454
|
108 }; |
|
109 |
|
110 class |
593
|
111 subplot_using : public tree_print_code |
454
|
112 { |
593
|
113 public: |
1622
|
114 subplot_using (void) |
|
115 { |
|
116 qualifier_count = 0; |
|
117 x[0] = x[1] = x[2] = x[3] = 0; |
|
118 scanf_fmt = 0; |
|
119 } |
|
120 |
|
121 subplot_using (tree_expression *fmt) : val (4, -1) |
|
122 { |
|
123 qualifier_count = 0; |
|
124 x[0] = x[1] = x[2] = x[3] = 0; |
|
125 scanf_fmt = fmt; |
|
126 } |
454
|
127 |
578
|
128 ~subplot_using (void); |
454
|
129 |
1622
|
130 subplot_using *set_format (tree_expression *fmt) |
|
131 { |
|
132 scanf_fmt = fmt; |
|
133 return this; |
|
134 } |
454
|
135 |
1622
|
136 subplot_using *add_qualifier (tree_expression *t) |
|
137 { |
|
138 if (qualifier_count < 4) |
|
139 x[qualifier_count] = t; |
|
140 |
|
141 qualifier_count++; |
|
142 |
|
143 return this; |
|
144 } |
454
|
145 |
872
|
146 int eval (int ndim, int n_max); |
|
147 |
|
148 ColumnVector values (int ndim, int n_max = 0); |
|
149 |
454
|
150 int print (int ndim, int n_max, ostrstream& plot_buf); |
|
151 |
593
|
152 void print_code (ostream& os); |
|
153 |
|
154 private: |
454
|
155 int qualifier_count; |
491
|
156 tree_expression *x[4]; |
|
157 tree_expression *scanf_fmt; |
872
|
158 ColumnVector val; |
454
|
159 }; |
|
160 |
|
161 class |
593
|
162 subplot_style : public tree_print_code |
454
|
163 { |
593
|
164 public: |
1622
|
165 subplot_style (void) |
1740
|
166 : tree_print_code (), style (0), linetype (0), pointtype (0) { } |
1622
|
167 |
1755
|
168 subplot_style (const string& s); |
|
169 subplot_style (const string& s, tree_expression *lt); |
|
170 subplot_style (const string& s, tree_expression *lt, tree_expression *pt); |
454
|
171 |
578
|
172 ~subplot_style (void); |
454
|
173 |
|
174 int print (ostrstream& plot_buf); |
|
175 |
872
|
176 int errorbars (void); |
|
177 |
593
|
178 void print_code (ostream& os); |
|
179 |
|
180 private: |
1755
|
181 string style; |
491
|
182 tree_expression *linetype; |
|
183 tree_expression *pointtype; |
454
|
184 }; |
|
185 |
578
|
186 class |
593
|
187 subplot : public tree_print_code |
578
|
188 { |
|
189 public: |
1740
|
190 subplot (tree_expression *data = 0) |
|
191 : tree_print_code (), plot_data (data), using_clause (0), |
|
192 title_clause (0), style_clause (0) { } |
1622
|
193 |
|
194 subplot (subplot_using *u, tree_expression *t, subplot_style *s) |
1740
|
195 : tree_print_code (), plot_data (0), using_clause (u), |
|
196 title_clause (t), style_clause (s) { } |
578
|
197 |
878
|
198 ~subplot (void); |
578
|
199 |
1622
|
200 subplot *set_data (tree_expression *data) |
|
201 { |
|
202 plot_data = data; |
|
203 return this; |
|
204 } |
578
|
205 |
872
|
206 tree_constant extract_plot_data (int ndim, tree_constant& data); |
|
207 |
|
208 int handle_plot_data (int ndim, ostrstream& plot_buf); |
|
209 |
878
|
210 int print (int ndim, ostrstream& plot_buf); |
|
211 |
593
|
212 void print_code (ostream& os); |
|
213 |
578
|
214 private: |
|
215 tree_expression *plot_data; |
999
|
216 subplot_using *using_clause; |
|
217 tree_expression *title_clause; |
|
218 subplot_style *style_clause; |
578
|
219 }; |
|
220 |
|
221 class |
593
|
222 subplot_list : public SLList<subplot *>, public tree_print_code |
578
|
223 { |
1740
|
224 public: |
1227
|
225 subplot_list (void) : SLList<subplot *> (), tree_print_code () { } |
878
|
226 |
1227
|
227 subplot_list (subplot *t) : SLList<subplot *> (), tree_print_code () |
578
|
228 { append (t); } |
|
229 |
1622
|
230 ~subplot_list (void); |
593
|
231 |
|
232 int print (int ndim, ostrstream& plot_buf); |
|
233 |
|
234 void print_code (ostream& os); |
578
|
235 }; |
|
236 |
1755
|
237 extern string save_in_tmp_file (tree_constant& t, int ndim = 2, |
|
238 int parametric = 0); |
524
|
239 |
1745
|
240 extern void mark_for_deletion (const string&); |
524
|
241 |
|
242 extern void cleanup_tmp_files (void); |
|
243 |
|
244 extern void close_plot_stream (void); |
|
245 |
1755
|
246 extern void do_external_plotter_cd (const string& newdir); |
1328
|
247 |
454
|
248 #endif |
|
249 |
|
250 /* |
|
251 ;;; Local Variables: *** |
|
252 ;;; mode: C++ *** |
|
253 ;;; page-delimiter: "^/\\*" *** |
|
254 ;;; End: *** |
|
255 */ |