Mercurial > emacs
annotate lisp/calc/calc-graph.el @ 60495:8e1bab51992b
(face-id): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 08 Mar 2005 02:55:39 +0000 |
parents | 39d1282c0854 |
children | d727bdc30df2 95879cc1ed20 |
rev | line source |
---|---|
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1 ;;; calc-graph.el --- graph output functions for Calc |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
40998
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
4 |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 ;; Author: David Gillespie <daveg@synaptics.com> |
58478
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
6 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
40785 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is distributed in the hope that it will be useful, | |
11 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
12 ;; accepts responsibility to anyone for the consequences of using it | |
13 ;; or for whether it serves any particular purpose or works at all, | |
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
15 ;; License for full details. | |
16 | |
17 ;; Everyone is granted permission to copy, modify and redistribute | |
18 ;; GNU Emacs, but only under the conditions described in the | |
19 ;; GNU Emacs General Public License. A copy of this license is | |
20 ;; supposed to have been given to you along with GNU Emacs so you | |
21 ;; can know your rights and responsibilities. It should be in a | |
22 ;; file named COPYING. Among other things, the copyright notice | |
23 ;; and this notice must be preserved on all copies. | |
24 | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
25 ;;; Commentary: |
40785 | 26 |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
27 ;;; Code: |
40785 | 28 |
29 ;; This file is autoloaded from calc-ext.el. | |
58657
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
30 |
40785 | 31 (require 'calc-ext) |
32 (require 'calc-macs) | |
33 | |
34 ;;; Graphics | |
35 | |
58657
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
36 (defvar calc-gnuplot-name "gnuplot" |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
37 "*Name of GNUPLOT program, for calc-graph features.") |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
38 |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
39 (defvar calc-gnuplot-plot-command nil |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
40 "*Name of command for displaying GNUPLOT output; %s = file name to print.") |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
41 |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
42 (defvar calc-gnuplot-print-command "lp %s" |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
43 "*Name of command for printing GNUPLOT output; %s = file name to print.") |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
44 |
43606
54abc38794d9
(calc-gnuplot-tempfile): Don't expand against
Colin Walters <walters@gnu.org>
parents:
41271
diff
changeset
|
45 (defvar calc-gnuplot-tempfile "calc") |
40785 | 46 |
58478
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
47 (defvar calc-gnuplot-default-device) |
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
48 (defvar calc-gnuplot-default-output) |
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
49 (defvar calc-gnuplot-print-device) |
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
50 (defvar calc-gnuplot-print-output) |
40785 | 51 (defvar calc-gnuplot-keep-outfile nil) |
52 (defvar calc-gnuplot-version nil) | |
53 | |
54 (defvar calc-gnuplot-display (getenv "DISPLAY")) | |
58478
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
55 (defvar calc-gnuplot-geometry) |
40785 | 56 |
58478
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
57 (defvar calc-graph-default-resolution) |
0a85050b3bb4
(calc-gnuplot-default-device, calc-gnuplot-default-output)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58188
diff
changeset
|
58 (defvar calc-graph-default-resolution-3d) |
40785 | 59 (defvar calc-graph-default-precision 5) |
60 | |
61 (defvar calc-gnuplot-buffer nil) | |
62 (defvar calc-gnuplot-input nil) | |
63 | |
64 (defvar calc-gnuplot-last-error-pos 1) | |
65 (defvar calc-graph-last-device nil) | |
66 (defvar calc-graph-last-output nil) | |
67 (defvar calc-graph-file-cache nil) | |
68 (defvar calc-graph-var-cache nil) | |
69 (defvar calc-graph-data-cache nil) | |
70 (defvar calc-graph-data-cache-limit 10) | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
71 (defvar calc-graph-no-auto-view nil) |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
72 (defvar calc-graph-no-wait nil) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
73 (defvar calc-gnuplot-trail-mark) |
40785 | 74 |
75 (defun calc-graph-fast (many) | |
76 (interactive "P") | |
77 (let ((calc-graph-no-auto-view t)) | |
78 (calc-graph-delete t) | |
79 (calc-graph-add many) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
80 (calc-graph-plot nil))) |
40785 | 81 |
82 (defun calc-graph-fast-3d (many) | |
83 (interactive "P") | |
84 (let ((calc-graph-no-auto-view t)) | |
85 (calc-graph-delete t) | |
86 (calc-graph-add-3d many) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
87 (calc-graph-plot nil))) |
40785 | 88 |
89 (defun calc-graph-delete (all) | |
90 (interactive "P") | |
91 (calc-wrapper | |
92 (calc-graph-init) | |
93 (save-excursion | |
94 (set-buffer calc-gnuplot-input) | |
95 (and (calc-graph-find-plot t all) | |
96 (progn | |
97 (if (looking-at "s?plot") | |
98 (progn | |
99 (setq calc-graph-var-cache nil) | |
100 (delete-region (point) (point-max))) | |
101 (delete-region (point) (1- (point-max))))))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
102 (calc-graph-view-commands))) |
40785 | 103 |
104 (defun calc-graph-find-plot (&optional before all) | |
105 (goto-char (point-min)) | |
106 (and (re-search-forward "^s?plot[ \t]+" nil t) | |
107 (let ((beg (point))) | |
108 (goto-char (point-max)) | |
109 (if (or all | |
110 (not (search-backward "," nil t)) | |
111 (< (point) beg)) | |
112 (progn | |
113 (goto-char beg) | |
114 (if before | |
115 (beginning-of-line))) | |
116 (or before | |
117 (re-search-forward ",[ \t]+"))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
118 t))) |
40785 | 119 |
120 (defun calc-graph-add (many) | |
121 (interactive "P") | |
122 (calc-wrapper | |
123 (calc-graph-init) | |
124 (cond ((null many) | |
125 (calc-graph-add-curve (calc-graph-lookup (calc-top-n 2)) | |
126 (calc-graph-lookup (calc-top-n 1)))) | |
127 ((or (consp many) (eq many 0)) | |
128 (let ((xdata (calc-graph-lookup (calc-top-n 2))) | |
129 (ylist (calc-top-n 1))) | |
130 (or (eq (car-safe ylist) 'vec) | |
131 (error "Y argument must be a vector")) | |
132 (while (setq ylist (cdr ylist)) | |
133 (calc-graph-add-curve xdata (calc-graph-lookup (car ylist)))))) | |
134 ((> (setq many (prefix-numeric-value many)) 0) | |
135 (let ((xdata (calc-graph-lookup (calc-top-n (1+ many))))) | |
136 (while (> many 0) | |
137 (calc-graph-add-curve xdata | |
138 (calc-graph-lookup (calc-top-n many))) | |
139 (setq many (1- many))))) | |
140 (t | |
141 (let (pair) | |
142 (setq many (- many)) | |
143 (while (> many 0) | |
144 (setq pair (calc-top-n many)) | |
145 (or (and (eq (car-safe pair) 'vec) | |
146 (= (length pair) 3)) | |
147 (error "Argument must be an [x,y] vector")) | |
148 (calc-graph-add-curve (calc-graph-lookup (nth 1 pair)) | |
149 (calc-graph-lookup (nth 2 pair))) | |
150 (setq many (1- many)))))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
151 (calc-graph-view-commands))) |
40785 | 152 |
153 (defun calc-graph-add-3d (many) | |
154 (interactive "P") | |
155 (calc-wrapper | |
156 (calc-graph-init) | |
157 (cond ((null many) | |
158 (calc-graph-add-curve (calc-graph-lookup (calc-top-n 3)) | |
159 (calc-graph-lookup (calc-top-n 2)) | |
160 (calc-graph-lookup (calc-top-n 1)))) | |
161 ((or (consp many) (eq many 0)) | |
162 (let ((xdata (calc-graph-lookup (calc-top-n 3))) | |
163 (ydata (calc-graph-lookup (calc-top-n 2))) | |
164 (zlist (calc-top-n 1))) | |
165 (or (eq (car-safe zlist) 'vec) | |
166 (error "Z argument must be a vector")) | |
167 (while (setq zlist (cdr zlist)) | |
168 (calc-graph-add-curve xdata ydata | |
169 (calc-graph-lookup (car zlist)))))) | |
170 ((> (setq many (prefix-numeric-value many)) 0) | |
171 (let ((xdata (calc-graph-lookup (calc-top-n (+ many 2)))) | |
172 (ydata (calc-graph-lookup (calc-top-n (+ many 1))))) | |
173 (while (> many 0) | |
174 (calc-graph-add-curve xdata ydata | |
175 (calc-graph-lookup (calc-top-n many))) | |
176 (setq many (1- many))))) | |
177 (t | |
178 (let (curve) | |
179 (setq many (- many)) | |
180 (while (> many 0) | |
181 (setq curve (calc-top-n many)) | |
182 (or (and (eq (car-safe curve) 'vec) | |
183 (= (length curve) 4)) | |
184 (error "Argument must be an [x,y,z] vector")) | |
185 (calc-graph-add-curve (calc-graph-lookup (nth 1 curve)) | |
186 (calc-graph-lookup (nth 2 curve)) | |
187 (calc-graph-lookup (nth 3 curve))) | |
188 (setq many (1- many)))))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
189 (calc-graph-view-commands))) |
40785 | 190 |
191 (defun calc-graph-add-curve (xdata ydata &optional zdata) | |
192 (let ((num (calc-graph-count-curves)) | |
193 (pstyle (calc-var-value 'var-PointStyles)) | |
194 (lstyle (calc-var-value 'var-LineStyles))) | |
195 (save-excursion | |
196 (set-buffer calc-gnuplot-input) | |
197 (goto-char (point-min)) | |
198 (if (re-search-forward (if zdata "^plot[ \t]" "^splot[ \t]") | |
199 nil t) | |
200 (error "Can't mix 2d and 3d curves on one graph")) | |
201 (if (re-search-forward "^s?plot[ \t]" nil t) | |
202 (progn | |
203 (end-of-line) | |
204 (insert ", ")) | |
205 (goto-char (point-max)) | |
206 (or (eq (preceding-char) ?\n) | |
207 (insert "\n")) | |
208 (insert (if zdata "splot" "plot") " \n") | |
209 (forward-char -1)) | |
210 (insert "{" (symbol-name (nth 1 xdata)) | |
211 ":" (symbol-name (nth 1 ydata))) | |
212 (if zdata | |
213 (insert ":" (symbol-name (nth 1 zdata)))) | |
214 (insert "} " | |
215 "title \"" (symbol-name (nth 1 ydata)) "\" " | |
216 "with dots") | |
217 (setq pstyle (and (eq (car-safe pstyle) 'vec) (nth (1+ num) pstyle))) | |
57183
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
218 (setq lstyle (and (eq (car-safe lstyle) 'vec) (nth (1+ num) lstyle)))) |
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
219 (calc-graph-set-styles |
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
220 (or (and (Math-num-integerp lstyle) (math-trunc lstyle)) |
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
221 0) |
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
222 (or (and (Math-num-integerp pstyle) (math-trunc pstyle)) |
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
223 (if (eq (car-safe (calc-var-value (nth 2 ydata))) 'vec) |
1b540cda70aa
(calc-graph-add-curve): Moved the call to `calc-graph-set-styles' so
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
224 0 -1))))) |
40785 | 225 |
226 (defun calc-graph-lookup (thing) | |
227 (if (and (eq (car-safe thing) 'var) | |
228 (calc-var-value (nth 2 thing))) | |
229 thing | |
230 (let ((found (assoc thing calc-graph-var-cache))) | |
231 (or found | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
232 (let ((varname (concat "PlotData" |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
233 (int-to-string |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
234 (1+ (length calc-graph-var-cache)))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
235 (setq var (list 'var (intern varname) |
40785 | 236 (intern (concat "var-" varname))) |
237 found (cons thing var) | |
238 calc-graph-var-cache (cons found calc-graph-var-cache)) | |
239 (set (nth 2 var) thing))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
240 (cdr found)))) |
40785 | 241 |
242 (defun calc-graph-juggle (arg) | |
243 (interactive "p") | |
244 (calc-graph-init) | |
245 (save-excursion | |
246 (set-buffer calc-gnuplot-input) | |
247 (if (< arg 0) | |
248 (let ((num (calc-graph-count-curves))) | |
249 (if (> num 0) | |
250 (while (< arg 0) | |
251 (setq arg (+ arg num)))))) | |
252 (while (>= (setq arg (1- arg)) 0) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
253 (calc-graph-do-juggle)))) |
40785 | 254 |
255 (defun calc-graph-count-curves () | |
256 (save-excursion | |
257 (set-buffer calc-gnuplot-input) | |
258 (if (re-search-forward "^s?plot[ \t]" nil t) | |
259 (let ((num 1)) | |
260 (goto-char (point-min)) | |
261 (while (search-forward "," nil t) | |
262 (setq num (1+ num))) | |
263 num) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
264 0))) |
40785 | 265 |
266 (defun calc-graph-do-juggle () | |
267 (let (base) | |
268 (and (calc-graph-find-plot t t) | |
269 (progn | |
270 (setq base (point)) | |
271 (calc-graph-find-plot t nil) | |
272 (or (eq base (point)) | |
273 (let ((str (buffer-substring (+ (point) 2) (1- (point-max))))) | |
274 (delete-region (point) (1- (point-max))) | |
275 (goto-char (+ base 5)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
276 (insert str ", "))))))) |
40785 | 277 |
278 (defun calc-graph-print (flag) | |
279 (interactive "P") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
280 (calc-graph-plot flag t)) |
40785 | 281 |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
282 (defvar var-DUMMY) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
283 (defvar var-DUMMY2) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
284 (defvar var-PlotRejects) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
285 |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
286 ;; The following variables are local to calc-graph-plot, but are |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
287 ;; used in the functions calc-graph-compute-2d, calc-graph-refine-2d, |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
288 ;; calc-graph-recompute-2d, calc-graph-compute-3d and |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
289 ;; calc-graph-format-data, which are called by calc-graph-plot. |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
290 (defvar calc-graph-yvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
291 (defvar calc-graph-yvec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
292 (defvar calc-graph-numsteps) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
293 (defvar calc-graph-numsteps3) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
294 (defvar calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
295 (defvar calc-graph-xvec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
296 (defvar calc-graph-xname) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
297 (defvar calc-graph-yname) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
298 (defvar calc-graph-xstep) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
299 (defvar calc-graph-ycache) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
300 (defvar calc-graph-ycacheptr) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
301 (defvar calc-graph-refine) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
302 (defvar calc-graph-keep-file) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
303 (defvar calc-graph-xval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
304 (defvar calc-graph-xlow) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
305 (defvar calc-graph-xhigh) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
306 (defvar calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
307 (defvar calc-graph-yp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
308 (defvar calc-graph-xp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
309 (defvar calc-graph-zp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
310 (defvar calc-graph-yvector) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
311 (defvar calc-graph-resolution) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
312 (defvar calc-graph-y3value) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
313 (defvar calc-graph-y3name) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
314 (defvar calc-graph-y3step) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
315 (defvar calc-graph-zval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
316 (defvar calc-graph-stepcount) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
317 (defvar calc-graph-is-splot) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
318 (defvar calc-graph-surprise-splot) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
319 (defvar calc-graph-blank) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
320 (defvar calc-graph-non-blank) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
321 (defvar calc-graph-curve-num) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
322 |
40785 | 323 (defun calc-graph-plot (flag &optional printing) |
324 (interactive "P") | |
325 (calc-slow-wrapper | |
326 (let ((calcbuf (current-buffer)) | |
327 (tempbuf (get-buffer-create "*Gnuplot Temp-2*")) | |
328 (tempbuftop 1) | |
329 (tempoutfile nil) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
330 (calc-graph-curve-num 0) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
331 (calc-graph-refine (and flag (> (prefix-numeric-value flag) 0))) |
40785 | 332 (recompute (and flag (< (prefix-numeric-value flag) 0))) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
333 (calc-graph-surprise-splot nil) |
40785 | 334 (tty-output nil) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
335 cache-env calc-graph-is-splot device output calc-graph-resolution precision samples-pos) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
336 (add-hook 'kill-emacs-hook 'calc-graph-kill-hook) |
40785 | 337 (save-excursion |
338 (calc-graph-init) | |
339 (set-buffer tempbuf) | |
340 (erase-buffer) | |
341 (set-buffer calc-gnuplot-input) | |
342 (goto-char (point-min)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
343 (setq calc-graph-is-splot (re-search-forward "^splot[ \t]" nil t)) |
40785 | 344 (let ((str (buffer-string)) |
345 (ver calc-gnuplot-version)) | |
346 (set-buffer (get-buffer-create "*Gnuplot Temp*")) | |
347 (erase-buffer) | |
348 (insert "# (Note: This is a temporary copy---do not edit!)\n") | |
349 (if (>= ver 2) | |
350 (insert "set noarrow\nset nolabel\n" | |
351 "set autoscale xy\nset nologscale xy\n" | |
352 "set xlabel\nset ylabel\nset title\n" | |
353 "set noclip points\nset clip one\nset clip two\n" | |
354 "set format \"%g\"\nset tics\nset xtics\nset ytics\n" | |
355 "set data style linespoints\n" | |
356 "set nogrid\nset nokey\nset nopolar\n")) | |
357 (if (>= ver 3) | |
358 (insert "set surface\nset nocontour\n" | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
359 "set " (if calc-graph-is-splot "" "no") "parametric\n" |
40785 | 360 "set notime\nset border\nset ztics\nset zeroaxis\n" |
361 "set view 60,30,1,1\nset offsets 0,0,0,0\n")) | |
362 (setq samples-pos (point)) | |
363 (insert "\n\n" str)) | |
364 (goto-char (point-min)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
365 (if calc-graph-is-splot |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
366 (if calc-graph-refine |
40785 | 367 (error "This option works only for 2d plots") |
368 (setq recompute t))) | |
369 (let ((calc-gnuplot-input (current-buffer)) | |
370 (calc-graph-no-auto-view t)) | |
371 (if printing | |
372 (setq device calc-gnuplot-print-device | |
373 output calc-gnuplot-print-output) | |
374 (setq device (calc-graph-find-command "terminal") | |
375 output (calc-graph-find-command "output")) | |
376 (or device | |
377 (setq device calc-gnuplot-default-device)) | |
378 (if output | |
379 (setq output (car (read-from-string output))) | |
380 (setq output calc-gnuplot-default-output))) | |
381 (if (or (equal device "") (equal device "default")) | |
382 (setq device (if printing | |
383 "postscript" | |
384 (if (or (eq window-system 'x) (getenv "DISPLAY")) | |
385 "x11" | |
386 (if (>= calc-gnuplot-version 3) | |
387 "dumb" "postscript"))))) | |
388 (if (equal device "dumb") | |
389 (setq device (format "dumb %d %d" | |
40998
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
390 (1- (frame-width)) (1- (frame-height))))) |
40785 | 391 (if (equal device "big") |
392 (setq device (format "dumb %d %d" | |
40998
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
393 (* 4 (- (frame-width) 3)) |
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
394 (* 4 (- (frame-height) 3))))) |
40785 | 395 (if (stringp output) |
396 (if (or (equal output "auto") | |
397 (and (equal output "tty") (setq tty-output t))) | |
398 (setq tempoutfile (calc-temp-file-name -1) | |
399 output tempoutfile)) | |
400 (setq output (eval output))) | |
401 (or (equal device calc-graph-last-device) | |
402 (progn | |
403 (setq calc-graph-last-device device) | |
404 (calc-gnuplot-command "set terminal" device))) | |
405 (or (equal output calc-graph-last-output) | |
406 (progn | |
407 (setq calc-graph-last-output output) | |
408 (calc-gnuplot-command "set output" | |
409 (if (equal output "STDOUT") | |
410 "" | |
411 (prin1-to-string output))))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
412 (setq calc-graph-resolution (calc-graph-find-command "samples")) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
413 (if calc-graph-resolution |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
414 (setq calc-graph-resolution (string-to-int calc-graph-resolution)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
415 (setq calc-graph-resolution (if calc-graph-is-splot |
40785 | 416 calc-graph-default-resolution-3d |
417 calc-graph-default-resolution))) | |
418 (setq precision (calc-graph-find-command "precision")) | |
419 (if precision | |
420 (setq precision (string-to-int precision)) | |
421 (setq precision calc-graph-default-precision)) | |
422 (calc-graph-set-command "terminal") | |
423 (calc-graph-set-command "output") | |
424 (calc-graph-set-command "samples") | |
425 (calc-graph-set-command "precision")) | |
426 (goto-char samples-pos) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
427 (insert "set samples " (int-to-string (max (if calc-graph-is-splot 20 200) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
428 (+ 5 calc-graph-resolution))) "\n") |
40785 | 429 (while (re-search-forward "{\\*[^}]+}[^,\n]*" nil t) |
430 (delete-region (match-beginning 0) (match-end 0)) | |
431 (if (looking-at ",") | |
432 (delete-char 1) | |
49840
e4b97a8e48e6
(calc-graph-plot): Fix character constant.
Juanma Barranquero <lekktu@gmail.com>
parents:
49598
diff
changeset
|
433 (while (memq (preceding-char) '(?\s ?\t)) |
40785 | 434 (forward-char -1)) |
435 (if (eq (preceding-char) ?\,) | |
436 (delete-backward-char 1)))) | |
437 (save-excursion | |
438 (set-buffer calcbuf) | |
439 (setq cache-env (list calc-angle-mode | |
440 calc-complex-mode | |
441 calc-simplify-mode | |
442 calc-infinite-mode | |
443 calc-word-size | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
444 precision calc-graph-is-splot)) |
40785 | 445 (if (and (not recompute) |
446 (equal (cdr (car calc-graph-data-cache)) cache-env)) | |
447 (while (> (length calc-graph-data-cache) | |
448 calc-graph-data-cache-limit) | |
449 (setcdr calc-graph-data-cache | |
450 (cdr (cdr calc-graph-data-cache)))) | |
451 (setq calc-graph-data-cache (list (cons nil cache-env))))) | |
452 (calc-graph-find-plot t t) | |
453 (while (re-search-forward | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
454 (if calc-graph-is-splot |
40785 | 455 "{\\([^{}:\n]+\\):\\([^{}:\n]+\\):\\([^{}:\n]+\\)}" |
456 "{\\([^{}:\n]+\\)\\(:\\)\\([^{}:\n]+\\)}") | |
457 nil t) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
458 (setq calc-graph-curve-num (1+ calc-graph-curve-num)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
459 (let* ((calc-graph-xname (buffer-substring (match-beginning 1) (match-end 1))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
460 (xvar (intern (concat "var-" calc-graph-xname))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
461 (calc-graph-xvalue (math-evaluate-expr (calc-var-value xvar))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
462 (calc-graph-y3name (and calc-graph-is-splot |
40785 | 463 (buffer-substring (match-beginning 2) |
464 (match-end 2)))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
465 (y3var (and calc-graph-is-splot (intern (concat "var-" calc-graph-y3name)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
466 (calc-graph-y3value (and calc-graph-is-splot (calc-var-value y3var))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
467 (calc-graph-yname (buffer-substring (match-beginning 3) (match-end 3))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
468 (yvar (intern (concat "var-" calc-graph-yname))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
469 (calc-graph-yvalue (calc-var-value yvar)) |
40785 | 470 filename) |
471 (delete-region (match-beginning 0) (match-end 0)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
472 (setq filename (calc-temp-file-name calc-graph-curve-num)) |
40785 | 473 (save-excursion |
474 (set-buffer calcbuf) | |
475 (let (tempbuftop | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
476 (calc-graph-xp calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
477 (calc-graph-yp calc-graph-yvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
478 (calc-graph-zp nil) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
479 (calc-graph-xlow nil) (calc-graph-xhigh nil) (y3low nil) (y3high nil) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
480 calc-graph-xvec calc-graph-xval calc-graph-xstep var-DUMMY |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
481 y3val calc-graph-y3step var-DUMMY2 (calc-graph-zval nil) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
482 calc-graph-yvec calc-graph-yval calc-graph-ycache calc-graph-ycacheptr calc-graph-yvector |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
483 calc-graph-numsteps calc-graph-numsteps3 |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
484 (calc-graph-keep-file (and (not calc-graph-is-splot) (file-exists-p filename))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
485 (calc-graph-stepcount 0) |
40785 | 486 (calc-symbolic-mode nil) |
487 (calc-prefer-frac nil) | |
488 (calc-internal-prec (max 3 precision)) | |
489 (calc-simplify-mode (and (not (memq calc-simplify-mode | |
490 '(none num))) | |
491 calc-simplify-mode)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
492 (calc-graph-blank t) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
493 (calc-graph-non-blank nil) |
40785 | 494 (math-working-step 0) |
495 (math-working-step-2 nil)) | |
496 (save-excursion | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
497 (if calc-graph-is-splot |
40785 | 498 (calc-graph-compute-3d) |
499 (calc-graph-compute-2d)) | |
500 (set-buffer tempbuf) | |
501 (goto-char (point-max)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
502 (insert "\n" calc-graph-xname) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
503 (if calc-graph-is-splot |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
504 (insert ":" calc-graph-y3name)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
505 (insert ":" calc-graph-yname "\n\n") |
40785 | 506 (setq tempbuftop (point)) |
507 (let ((calc-group-digits nil) | |
508 (calc-leading-zeros nil) | |
509 (calc-number-radix 10) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
510 (entry (and (not calc-graph-is-splot) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
511 (list calc-graph-xp calc-graph-yp calc-graph-xhigh calc-graph-numsteps)))) |
40785 | 512 (or (equal entry |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
513 (nth 1 (nth (1+ calc-graph-curve-num) |
40785 | 514 calc-graph-file-cache))) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
515 (setq calc-graph-keep-file nil)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
516 (setcar (cdr (nth (1+ calc-graph-curve-num) calc-graph-file-cache)) |
40785 | 517 entry) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
518 (or calc-graph-keep-file |
40785 | 519 (calc-graph-format-data))) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
520 (or calc-graph-keep-file |
40785 | 521 (progn |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
522 (or calc-graph-non-blank |
40785 | 523 (error "No valid data points for %s:%s" |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
524 calc-graph-xname calc-graph-yname)) |
40785 | 525 (write-region tempbuftop (point-max) filename |
526 nil 'quiet)))))) | |
527 (insert (prin1-to-string filename)))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
528 (if calc-graph-surprise-splot |
40785 | 529 (setcdr cache-env nil)) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
530 (if (= calc-graph-curve-num 0) |
40785 | 531 (progn |
532 (calc-gnuplot-command "clear") | |
533 (calc-clear-command-flag 'clear-message) | |
534 (message "No data to plot!")) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
535 (setq calc-graph-data-cache-limit (max calc-graph-curve-num |
40785 | 536 calc-graph-data-cache-limit) |
537 filename (calc-temp-file-name 0)) | |
538 (write-region (point-min) (point-max) filename nil 'quiet) | |
539 (calc-gnuplot-command "load" (prin1-to-string filename)) | |
540 (or (equal output "STDOUT") | |
541 calc-gnuplot-keep-outfile | |
542 (progn ; need to close the output file before printing/plotting | |
543 (setq calc-graph-last-output "STDOUT") | |
544 (calc-gnuplot-command "set output"))) | |
545 (let ((command (if printing | |
546 calc-gnuplot-print-command | |
547 (or calc-gnuplot-plot-command | |
548 (and (string-match "^dumb" device) | |
549 'calc-graph-show-dumb) | |
550 (and tty-output | |
551 'calc-graph-show-tty))))) | |
552 (if command | |
553 (if (stringp command) | |
554 (calc-gnuplot-command | |
555 "!" (format command | |
556 (or tempoutfile | |
557 calc-gnuplot-print-output))) | |
558 (if (symbolp command) | |
559 (funcall command output) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
560 (eval command)))))))))) |
40785 | 561 |
562 (defun calc-graph-compute-2d () | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
563 (if (setq calc-graph-yvec (eq (car-safe calc-graph-yvalue) 'vec)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
564 (if (= (setq calc-graph-numsteps (1- (length calc-graph-yvalue))) 0) |
40785 | 565 (error "Can't plot an empty vector") |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
566 (if (setq calc-graph-xvec (eq (car-safe calc-graph-xvalue) 'vec)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
567 (or (= (1- (length calc-graph-xvalue)) calc-graph-numsteps) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
568 (error "%s and %s have different lengths" calc-graph-xname calc-graph-yname)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
569 (if (and (eq (car-safe calc-graph-xvalue) 'intv) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
570 (math-constp calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
571 (setq calc-graph-xstep (math-div (math-sub (nth 3 calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
572 (nth 2 calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
573 (1- calc-graph-numsteps)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
574 calc-graph-xvalue (nth 2 calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
575 (if (math-realp calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
576 (setq calc-graph-xstep 1) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
577 (error "%s is not a suitable basis for %s" calc-graph-xname calc-graph-yname))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
578 (or (math-realp calc-graph-yvalue) |
40785 | 579 (let ((arglist nil)) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
580 (setq calc-graph-yvalue (math-evaluate-expr calc-graph-yvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
581 (calc-default-formula-arglist calc-graph-yvalue) |
40785 | 582 (or arglist |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
583 (error "%s does not contain any unassigned variables" calc-graph-yname)) |
40785 | 584 (and (cdr arglist) |
585 (error "%s contains more than one variable: %s" | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
586 calc-graph-yname arglist)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
587 (setq calc-graph-yvalue (math-expr-subst calc-graph-yvalue |
40785 | 588 (math-build-var-name (car arglist)) |
589 '(var DUMMY var-DUMMY))))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
590 (setq calc-graph-ycache (assoc calc-graph-yvalue calc-graph-data-cache)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
591 (delq calc-graph-ycache calc-graph-data-cache) |
40785 | 592 (nconc calc-graph-data-cache |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
593 (list (or calc-graph-ycache (setq calc-graph-ycache (list calc-graph-yvalue))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
594 (if (and (not (setq calc-graph-xvec (eq (car-safe calc-graph-xvalue) 'vec))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
595 calc-graph-refine (cdr (cdr calc-graph-ycache))) |
40785 | 596 (calc-graph-refine-2d) |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
597 (calc-graph-recompute-2d)))) |
40785 | 598 |
599 (defun calc-graph-refine-2d () | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
600 (setq calc-graph-keep-file nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
601 calc-graph-ycacheptr (cdr calc-graph-ycache)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
602 (if (and (setq calc-graph-xval (calc-graph-find-command "xrange")) |
40785 | 603 (string-match "\\`\\[\\([0-9.eE+-]*\\):\\([0-9.eE+-]*\\)\\]\\'" |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
604 calc-graph-xval)) |
40785 | 605 (let ((b2 (match-beginning 2)) |
606 (e2 (match-end 2))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
607 (setq calc-graph-xlow (math-read-number (substring calc-graph-xval |
40785 | 608 (match-beginning 1) |
609 (match-end 1))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
610 calc-graph-xhigh (math-read-number (substring calc-graph-xval b2 e2)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
611 (if calc-graph-xlow |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
612 (while (and (cdr calc-graph-ycacheptr) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
613 (Math-lessp (car (nth 1 calc-graph-ycacheptr)) calc-graph-xlow)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
614 (setq calc-graph-ycacheptr (cdr calc-graph-ycacheptr))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
615 (setq math-working-step-2 (1- (length calc-graph-ycacheptr))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
616 (while (and (cdr calc-graph-ycacheptr) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
617 (or (not calc-graph-xhigh) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
618 (Math-lessp (car (car calc-graph-ycacheptr)) calc-graph-xhigh))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
619 (setq var-DUMMY (math-div (math-add (car (car calc-graph-ycacheptr)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
620 (car (nth 1 calc-graph-ycacheptr))) |
40785 | 621 2) |
622 math-working-step (1+ math-working-step) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
623 calc-graph-yval (math-evaluate-expr calc-graph-yvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
624 (setcdr calc-graph-ycacheptr (cons (cons var-DUMMY calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
625 (cdr calc-graph-ycacheptr))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
626 (setq calc-graph-ycacheptr (cdr (cdr calc-graph-ycacheptr)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
627 (setq calc-graph-yp calc-graph-ycache |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
628 calc-graph-numsteps 1000000)) |
40785 | 629 |
630 (defun calc-graph-recompute-2d () | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
631 (setq calc-graph-ycacheptr calc-graph-ycache) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
632 (if calc-graph-xvec |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
633 (setq calc-graph-numsteps (1- (length calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
634 calc-graph-yvector nil) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
635 (if (and (eq (car-safe calc-graph-xvalue) 'intv) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
636 (math-constp calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
637 (setq calc-graph-numsteps calc-graph-resolution |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
638 calc-graph-yp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
639 calc-graph-xlow (nth 2 calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
640 calc-graph-xhigh (nth 3 calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
641 calc-graph-xstep (math-div (math-sub calc-graph-xhigh calc-graph-xlow) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
642 (1- calc-graph-numsteps)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
643 calc-graph-xvalue (nth 2 calc-graph-xvalue)) |
40785 | 644 (error "%s is not a suitable basis for %s" |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
645 calc-graph-xname calc-graph-yname))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
646 (setq math-working-step-2 calc-graph-numsteps) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
647 (while (>= (setq calc-graph-numsteps (1- calc-graph-numsteps)) 0) |
40785 | 648 (setq math-working-step (1+ math-working-step)) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
649 (if calc-graph-xvec |
40785 | 650 (progn |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
651 (setq calc-graph-xp (cdr calc-graph-xp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
652 calc-graph-xval (car calc-graph-xp)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
653 (and (not (eq calc-graph-ycacheptr calc-graph-ycache)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
654 (consp (car calc-graph-ycacheptr)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
655 (not (Math-lessp (car (car calc-graph-ycacheptr)) calc-graph-xval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
656 (setq calc-graph-ycacheptr calc-graph-ycache))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
657 (if (= calc-graph-numsteps 0) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
658 (setq calc-graph-xval calc-graph-xhigh) ; avoid cumulative roundoff |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
659 (setq calc-graph-xval calc-graph-xvalue |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
660 calc-graph-xvalue (math-add calc-graph-xvalue calc-graph-xstep)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
661 (while (and (cdr calc-graph-ycacheptr) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
662 (Math-lessp (car (nth 1 calc-graph-ycacheptr)) calc-graph-xval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
663 (setq calc-graph-ycacheptr (cdr calc-graph-ycacheptr))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
664 (or (and (cdr calc-graph-ycacheptr) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
665 (Math-equal (car (nth 1 calc-graph-ycacheptr)) calc-graph-xval)) |
40785 | 666 (progn |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
667 (setq calc-graph-keep-file nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
668 var-DUMMY calc-graph-xval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
669 (setcdr calc-graph-ycacheptr (cons (cons calc-graph-xval (math-evaluate-expr calc-graph-yvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
670 (cdr calc-graph-ycacheptr))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
671 (setq calc-graph-ycacheptr (cdr calc-graph-ycacheptr)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
672 (if calc-graph-xvec |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
673 (setq calc-graph-yvector (cons (cdr (car calc-graph-ycacheptr)) calc-graph-yvector)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
674 (or calc-graph-yp (setq calc-graph-yp calc-graph-ycacheptr)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
675 (if calc-graph-xvec |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
676 (setq calc-graph-xp calc-graph-xvalue |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
677 calc-graph-yvec t |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
678 calc-graph-yp (cons 'vec (nreverse calc-graph-yvector)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
679 calc-graph-numsteps (1- (length calc-graph-xp))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
680 (setq calc-graph-numsteps 1000000))) |
40785 | 681 |
682 (defun calc-graph-compute-3d () | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
683 (if (setq calc-graph-yvec (eq (car-safe calc-graph-yvalue) 'vec)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
684 (if (math-matrixp calc-graph-yvalue) |
40785 | 685 (progn |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
686 (setq calc-graph-numsteps (1- (length calc-graph-yvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
687 calc-graph-numsteps3 (1- (length (nth 1 calc-graph-yvalue)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
688 (if (eq (car-safe calc-graph-xvalue) 'vec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
689 (or (= (1- (length calc-graph-xvalue)) calc-graph-numsteps) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
690 (error "%s has wrong length" calc-graph-xname)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
691 (if (and (eq (car-safe calc-graph-xvalue) 'intv) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
692 (math-constp calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
693 (setq calc-graph-xvalue (calcFunc-index calc-graph-numsteps |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
694 (nth 2 calc-graph-xvalue) |
40785 | 695 (math-div |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
696 (math-sub (nth 3 calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
697 (nth 2 calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
698 (1- calc-graph-numsteps)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
699 (if (math-realp calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
700 (setq calc-graph-xvalue (calcFunc-index calc-graph-numsteps calc-graph-xvalue 1)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
701 (error "%s is not a suitable basis for %s" calc-graph-xname calc-graph-yname)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
702 (if (eq (car-safe calc-graph-y3value) 'vec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
703 (or (= (1- (length calc-graph-y3value)) calc-graph-numsteps3) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
704 (error "%s has wrong length" calc-graph-y3name)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
705 (if (and (eq (car-safe calc-graph-y3value) 'intv) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
706 (math-constp calc-graph-y3value)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
707 (setq calc-graph-y3value (calcFunc-index calc-graph-numsteps3 |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
708 (nth 2 calc-graph-y3value) |
40785 | 709 (math-div |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
710 (math-sub (nth 3 calc-graph-y3value) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
711 (nth 2 calc-graph-y3value)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
712 (1- calc-graph-numsteps3)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
713 (if (math-realp calc-graph-y3value) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
714 (setq calc-graph-y3value (calcFunc-index calc-graph-numsteps3 calc-graph-y3value 1)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
715 (error "%s is not a suitable basis for %s" calc-graph-y3name calc-graph-yname)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
716 (setq calc-graph-xp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
717 calc-graph-yp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
718 calc-graph-zp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
719 calc-graph-xvec t) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
720 (while (setq calc-graph-xvalue (cdr calc-graph-xvalue) calc-graph-yvalue (cdr calc-graph-yvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
721 (setq calc-graph-xp (nconc calc-graph-xp (make-list (1+ calc-graph-numsteps3) (car calc-graph-xvalue))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
722 calc-graph-yp (nconc calc-graph-yp (cons 0 (copy-sequence (cdr calc-graph-y3value)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
723 calc-graph-zp (nconc calc-graph-zp (cons '(skip) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
724 (copy-sequence (cdr (car calc-graph-yvalue))))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
725 (setq calc-graph-numsteps (1- (* calc-graph-numsteps |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
726 (1+ calc-graph-numsteps3))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
727 (if (= (setq calc-graph-numsteps (1- (length calc-graph-yvalue))) 0) |
40785 | 728 (error "Can't plot an empty vector")) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
729 (or (and (eq (car-safe calc-graph-xvalue) 'vec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
730 (= (1- (length calc-graph-xvalue)) calc-graph-numsteps)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
731 (error "%s is not a suitable basis for %s" calc-graph-xname calc-graph-yname)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
732 (or (and (eq (car-safe calc-graph-y3value) 'vec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
733 (= (1- (length calc-graph-y3value)) calc-graph-numsteps)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
734 (error "%s is not a suitable basis for %s" calc-graph-y3name calc-graph-yname)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
735 (setq calc-graph-xp calc-graph-xvalue |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
736 calc-graph-yp calc-graph-y3value |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
737 calc-graph-zp calc-graph-yvalue |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
738 calc-graph-xvec t)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
739 (or (math-realp calc-graph-yvalue) |
40785 | 740 (let ((arglist nil)) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
741 (setq calc-graph-yvalue (math-evaluate-expr calc-graph-yvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
742 (calc-default-formula-arglist calc-graph-yvalue) |
40785 | 743 (setq arglist (sort arglist 'string-lessp)) |
744 (or (cdr arglist) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
745 (error "%s does not contain enough unassigned variables" calc-graph-yname)) |
40785 | 746 (and (cdr (cdr arglist)) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
747 (error "%s contains too many variables: %s" calc-graph-yname arglist)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
748 (setq calc-graph-yvalue (math-multi-subst calc-graph-yvalue |
40785 | 749 (mapcar 'math-build-var-name |
750 arglist) | |
751 '((var DUMMY var-DUMMY) | |
752 (var DUMMY2 var-DUMMY2)))))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
753 (if (setq calc-graph-xvec (eq (car-safe calc-graph-xvalue) 'vec)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
754 (setq calc-graph-numsteps (1- (length calc-graph-xvalue))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
755 (if (and (eq (car-safe calc-graph-xvalue) 'intv) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
756 (math-constp calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
757 (setq calc-graph-numsteps calc-graph-resolution |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
758 calc-graph-xvalue (calcFunc-index calc-graph-numsteps |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
759 (nth 2 calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
760 (math-div (math-sub (nth 3 calc-graph-xvalue) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
761 (nth 2 calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
762 (1- calc-graph-numsteps)))) |
40785 | 763 (error "%s is not a suitable basis for %s" |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
764 calc-graph-xname calc-graph-yname))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
765 (if (eq (car-safe calc-graph-y3value) 'vec) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
766 (setq calc-graph-numsteps3 (1- (length calc-graph-y3value))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
767 (if (and (eq (car-safe calc-graph-y3value) 'intv) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
768 (math-constp calc-graph-y3value)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
769 (setq calc-graph-numsteps3 calc-graph-resolution |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
770 calc-graph-y3value (calcFunc-index calc-graph-numsteps3 |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
771 (nth 2 calc-graph-y3value) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
772 (math-div (math-sub (nth 3 calc-graph-y3value) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
773 (nth 2 calc-graph-y3value)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
774 (1- calc-graph-numsteps3)))) |
40785 | 775 (error "%s is not a suitable basis for %s" |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
776 calc-graph-y3name calc-graph-yname))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
777 (setq calc-graph-xp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
778 calc-graph-yp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
779 calc-graph-zp nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
780 calc-graph-xvec t) |
40785 | 781 (setq math-working-step 0) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
782 (while (setq calc-graph-xvalue (cdr calc-graph-xvalue)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
783 (setq calc-graph-xp (nconc calc-graph-xp (make-list (1+ calc-graph-numsteps3) (car calc-graph-xvalue))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
784 calc-graph-yp (nconc calc-graph-yp (cons 0 (copy-sequence (cdr calc-graph-y3value)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
785 calc-graph-zp (cons '(skip) calc-graph-zp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
786 calc-graph-y3step calc-graph-y3value |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
787 var-DUMMY (car calc-graph-xvalue) |
40785 | 788 math-working-step-2 0 |
789 math-working-step (1+ math-working-step)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
790 (while (setq calc-graph-y3step (cdr calc-graph-y3step)) |
40785 | 791 (setq math-working-step-2 (1+ math-working-step-2) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
792 var-DUMMY2 (car calc-graph-y3step) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
793 calc-graph-zp (cons (math-evaluate-expr calc-graph-yvalue) calc-graph-zp)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
794 (setq calc-graph-zp (nreverse calc-graph-zp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
795 calc-graph-numsteps (1- (* calc-graph-numsteps (1+ calc-graph-numsteps3)))))) |
40785 | 796 |
797 (defun calc-graph-format-data () | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
798 (while (<= (setq calc-graph-stepcount (1+ calc-graph-stepcount)) calc-graph-numsteps) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
799 (if calc-graph-xvec |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
800 (setq calc-graph-xp (cdr calc-graph-xp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
801 calc-graph-xval (car calc-graph-xp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
802 calc-graph-yp (cdr calc-graph-yp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
803 calc-graph-yval (car calc-graph-yp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
804 calc-graph-zp (cdr calc-graph-zp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
805 calc-graph-zval (car calc-graph-zp)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
806 (if calc-graph-yvec |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
807 (setq calc-graph-xval calc-graph-xvalue |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
808 calc-graph-xvalue (math-add calc-graph-xvalue calc-graph-xstep) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
809 calc-graph-yp (cdr calc-graph-yp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
810 calc-graph-yval (car calc-graph-yp)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
811 (setq calc-graph-xval (car (car calc-graph-yp)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
812 calc-graph-yval (cdr (car calc-graph-yp)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
813 calc-graph-yp (cdr calc-graph-yp)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
814 (if (or (not calc-graph-yp) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
815 (and calc-graph-xhigh (equal calc-graph-xval calc-graph-xhigh))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
816 (setq calc-graph-numsteps 0)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
817 (if calc-graph-is-splot |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
818 (if (and (eq (car-safe calc-graph-zval) 'calcFunc-xyz) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
819 (= (length calc-graph-zval) 4)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
820 (setq calc-graph-xval (nth 1 calc-graph-zval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
821 calc-graph-yval (nth 2 calc-graph-zval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
822 calc-graph-zval (nth 3 calc-graph-zval))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
823 (if (and (eq (car-safe calc-graph-yval) 'calcFunc-xyz) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
824 (= (length calc-graph-yval) 4)) |
40785 | 825 (progn |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
826 (or calc-graph-surprise-splot |
40785 | 827 (save-excursion |
828 (set-buffer (get-buffer-create "*Gnuplot Temp*")) | |
829 (save-excursion | |
830 (goto-char (point-max)) | |
831 (re-search-backward "^plot[ \t]") | |
832 (insert "set parametric\ns") | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
833 (setq calc-graph-surprise-splot t)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
834 (setq calc-graph-xval (nth 1 calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
835 calc-graph-zval (nth 3 calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
836 calc-graph-yval (nth 2 calc-graph-yval))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
837 (if (and (eq (car-safe calc-graph-yval) 'calcFunc-xy) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
838 (= (length calc-graph-yval) 3)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
839 (setq calc-graph-xval (nth 1 calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
840 calc-graph-yval (nth 2 calc-graph-yval))))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
841 (if (and (Math-realp calc-graph-xval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
842 (Math-realp calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
843 (or (not calc-graph-zval) (Math-realp calc-graph-zval))) |
40785 | 844 (progn |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
845 (setq calc-graph-blank nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
846 calc-graph-non-blank t) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
847 (if (Math-integerp calc-graph-xval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
848 (insert (math-format-number calc-graph-xval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
849 (if (eq (car calc-graph-xval) 'frac) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
850 (setq calc-graph-xval (math-float calc-graph-xval))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
851 (insert (math-format-number (nth 1 calc-graph-xval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
852 "e" (int-to-string (nth 2 calc-graph-xval)))) |
40785 | 853 (insert " ") |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
854 (if (Math-integerp calc-graph-yval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
855 (insert (math-format-number calc-graph-yval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
856 (if (eq (car calc-graph-yval) 'frac) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
857 (setq calc-graph-yval (math-float calc-graph-yval))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
858 (insert (math-format-number (nth 1 calc-graph-yval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
859 "e" (int-to-string (nth 2 calc-graph-yval)))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
860 (if calc-graph-zval |
40785 | 861 (progn |
862 (insert " ") | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
863 (if (Math-integerp calc-graph-zval) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
864 (insert (math-format-number calc-graph-zval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
865 (if (eq (car calc-graph-zval) 'frac) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
866 (setq calc-graph-zval (math-float calc-graph-zval))) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
867 (insert (math-format-number (nth 1 calc-graph-zval)) |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
868 "e" (int-to-string (nth 2 calc-graph-zval)))))) |
40785 | 869 (insert "\n")) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
870 (and (not (equal calc-graph-zval '(skip))) |
40785 | 871 (eq (car-safe var-PlotRejects) 'vec) |
872 (nconc var-PlotRejects | |
873 (list (list 'vec | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
874 calc-graph-curve-num |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
875 calc-graph-stepcount |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
876 calc-graph-xval calc-graph-yval))) |
40785 | 877 (calc-refresh-evaltos 'var-PlotRejects)) |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
878 (or calc-graph-blank |
40785 | 879 (progn |
880 (insert "\n") | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
881 (setq calc-graph-blank t)))))) |
40785 | 882 |
883 (defun calc-temp-file-name (num) | |
884 (while (<= (length calc-graph-file-cache) (1+ num)) | |
885 (setq calc-graph-file-cache (nconc calc-graph-file-cache (list nil)))) | |
886 (car (or (nth (1+ num) calc-graph-file-cache) | |
887 (setcar (nthcdr (1+ num) calc-graph-file-cache) | |
43606
54abc38794d9
(calc-gnuplot-tempfile): Don't expand against
Colin Walters <walters@gnu.org>
parents:
41271
diff
changeset
|
888 (list (make-temp-file |
40785 | 889 (concat calc-gnuplot-tempfile |
890 (if (<= num 0) | |
891 (char-to-string (- ?A num)) | |
892 (int-to-string num)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
893 nil))))) |
40785 | 894 |
895 (defun calc-graph-delete-temps () | |
896 (while calc-graph-file-cache | |
897 (and (car calc-graph-file-cache) | |
898 (file-exists-p (car (car calc-graph-file-cache))) | |
899 (condition-case err | |
900 (delete-file (car (car calc-graph-file-cache))) | |
901 (error nil))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
902 (setq calc-graph-file-cache (cdr calc-graph-file-cache)))) |
40785 | 903 |
904 (defun calc-graph-kill-hook () | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
905 (calc-graph-delete-temps)) |
40785 | 906 |
907 (defun calc-graph-show-tty (output) | |
908 "Default calc-gnuplot-plot-command for \"tty\" output mode. | |
909 This is useful for tek40xx and other graphics-terminal types." | |
910 (call-process-region 1 1 shell-file-name | |
911 nil calc-gnuplot-buffer nil | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
912 "-c" (format "cat %s >/dev/tty; rm %s" output output))) |
40785 | 913 |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
914 (defvar calc-dumb-map nil |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
915 "The keymap for the \"dumb\" terminal plot.") |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
916 |
40785 | 917 (defun calc-graph-show-dumb (&optional output) |
918 "Default calc-gnuplot-plot-command for Pinard's \"dumb\" terminal type. | |
919 This \"dumb\" driver will be present in Gnuplot 3.0." | |
920 (interactive) | |
921 (save-window-excursion | |
922 (switch-to-buffer calc-gnuplot-buffer) | |
923 (delete-other-windows) | |
924 (goto-char calc-gnuplot-trail-mark) | |
925 (or (search-forward "\f" nil t) | |
926 (sleep-for 1)) | |
927 (goto-char (point-max)) | |
928 (re-search-backward "\f\\|^[ \t]+\\^$\\|G N U P L O T") | |
929 (if (looking-at "\f") | |
930 (progn | |
931 (forward-char 1) | |
932 (if (eolp) (forward-line 1)) | |
933 (or (calc-graph-find-command "time") | |
934 (calc-graph-find-command "title") | |
935 (calc-graph-find-command "ylabel") | |
936 (let ((pt (point))) | |
937 (insert-before-markers (format "(%s)" (current-time-string))) | |
938 (goto-char pt))) | |
939 (set-window-start (selected-window) (point)) | |
940 (goto-char (point-max))) | |
941 (end-of-line) | |
942 (backward-char 1) | |
943 (recenter '(4))) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
944 (or calc-dumb-map |
40785 | 945 (progn |
946 (setq calc-dumb-map (make-sparse-keymap)) | |
947 (define-key calc-dumb-map "\n" 'scroll-up) | |
948 (define-key calc-dumb-map " " 'scroll-up) | |
949 (define-key calc-dumb-map "\177" 'scroll-down) | |
950 (define-key calc-dumb-map "<" 'scroll-left) | |
951 (define-key calc-dumb-map ">" 'scroll-right) | |
952 (define-key calc-dumb-map "{" 'scroll-down) | |
953 (define-key calc-dumb-map "}" 'scroll-up) | |
954 (define-key calc-dumb-map "q" 'exit-recursive-edit) | |
955 (define-key calc-dumb-map "\C-c\C-c" 'exit-recursive-edit))) | |
956 (use-local-map calc-dumb-map) | |
957 (setq truncate-lines t) | |
59231
39d1282c0854
(calc-graph-show-dumb): Mention C-cC-c as the way to return to Calc.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58657
diff
changeset
|
958 (message "Type `q' or `C-c C-c' to return to Calc") |
40785 | 959 (recursive-edit) |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
960 (bury-buffer "*Gnuplot Trail*"))) |
40785 | 961 |
962 (defun calc-graph-clear () | |
963 (interactive) | |
964 (if calc-graph-last-device | |
965 (if (or (equal calc-graph-last-device "x11") | |
966 (equal calc-graph-last-device "X11")) | |
967 (calc-gnuplot-command "set output" | |
968 (if (equal calc-graph-last-output "STDOUT") | |
969 "" | |
970 (prin1-to-string calc-graph-last-output))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
971 (calc-gnuplot-command "clear")))) |
40785 | 972 |
973 (defun calc-graph-title-x (title) | |
974 (interactive "sX axis title: ") | |
975 (calc-graph-set-command "xlabel" (if (not (equal title "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
976 (prin1-to-string title)))) |
40785 | 977 |
978 (defun calc-graph-title-y (title) | |
979 (interactive "sY axis title: ") | |
980 (calc-graph-set-command "ylabel" (if (not (equal title "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
981 (prin1-to-string title)))) |
40785 | 982 |
983 (defun calc-graph-title-z (title) | |
984 (interactive "sZ axis title: ") | |
985 (calc-graph-set-command "zlabel" (if (not (equal title "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
986 (prin1-to-string title)))) |
40785 | 987 |
988 (defun calc-graph-range-x (range) | |
989 (interactive "sX axis range: ") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
990 (calc-graph-set-range "xrange" range)) |
40785 | 991 |
992 (defun calc-graph-range-y (range) | |
993 (interactive "sY axis range: ") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
994 (calc-graph-set-range "yrange" range)) |
40785 | 995 |
996 (defun calc-graph-range-z (range) | |
997 (interactive "sZ axis range: ") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
998 (calc-graph-set-range "zrange" range)) |
40785 | 999 |
1000 (defun calc-graph-set-range (cmd range) | |
1001 (if (equal range "$") | |
1002 (calc-wrapper | |
1003 (let ((val (calc-top-n 1))) | |
1004 (if (and (eq (car-safe val) 'intv) (math-constp val)) | |
1005 (setq range (concat | |
1006 (math-format-number (math-float (nth 2 val))) ":" | |
1007 (math-format-number (math-float (nth 3 val))))) | |
1008 (if (and (eq (car-safe val) 'vec) | |
1009 (= (length val) 3)) | |
1010 (setq range (concat | |
1011 (math-format-number (math-float (nth 1 val))) ":" | |
1012 (math-format-number (math-float (nth 2 val))))) | |
1013 (error "Range specification must be an interval or 2-vector"))) | |
1014 (calc-pop-stack 1)))) | |
1015 (if (string-match "\\[.+\\]" range) | |
1016 (setq range (substring range 1 -1))) | |
1017 (if (and (not (string-match ":" range)) | |
1018 (or (string-match "," range) | |
1019 (string-match " " range))) | |
1020 (aset range (match-beginning 0) ?\:)) | |
1021 (calc-graph-set-command cmd (if (not (equal range "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1022 (concat "[" range "]")))) |
40785 | 1023 |
1024 (defun calc-graph-log-x (flag) | |
1025 (interactive "P") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1026 (calc-graph-set-log flag 0 0)) |
40785 | 1027 |
1028 (defun calc-graph-log-y (flag) | |
1029 (interactive "P") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1030 (calc-graph-set-log 0 flag 0)) |
40785 | 1031 |
1032 (defun calc-graph-log-z (flag) | |
1033 (interactive "P") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1034 (calc-graph-set-log 0 0 flag)) |
40785 | 1035 |
1036 (defun calc-graph-set-log (xflag yflag zflag) | |
1037 (let* ((old (or (calc-graph-find-command "logscale") "")) | |
1038 (xold (string-match "x" old)) | |
1039 (yold (string-match "y" old)) | |
1040 (zold (string-match "z" old)) | |
1041 str) | |
1042 (setq str (concat (if (if xflag | |
1043 (if (eq xflag 0) xold | |
1044 (> (prefix-numeric-value xflag) 0)) | |
1045 (not xold)) "x" "") | |
1046 (if (if yflag | |
1047 (if (eq yflag 0) yold | |
1048 (> (prefix-numeric-value yflag) 0)) | |
1049 (not yold)) "y" "") | |
1050 (if (if zflag | |
1051 (if (eq zflag 0) zold | |
1052 (> (prefix-numeric-value zflag) 0)) | |
1053 (not zold)) "z" ""))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1054 (calc-graph-set-command "logscale" (if (not (equal str "")) str)))) |
40785 | 1055 |
1056 (defun calc-graph-line-style (style) | |
1057 (interactive "P") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1058 (calc-graph-set-styles (and style (prefix-numeric-value style)) t)) |
40785 | 1059 |
1060 (defun calc-graph-point-style (style) | |
1061 (interactive "P") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1062 (calc-graph-set-styles t (and style (prefix-numeric-value style)))) |
40785 | 1063 |
1064 (defun calc-graph-set-styles (lines points) | |
1065 (calc-graph-init) | |
1066 (save-excursion | |
1067 (set-buffer calc-gnuplot-input) | |
1068 (or (calc-graph-find-plot nil nil) | |
1069 (error "No data points have been set!")) | |
1070 (let ((base (point)) | |
1071 (mode nil) (lstyle nil) (pstyle nil) | |
1072 start end lenbl penbl) | |
1073 (re-search-forward "[,\n]") | |
1074 (forward-char -1) | |
1075 (setq end (point) start end) | |
1076 (goto-char base) | |
1077 (if (looking-at "[^,\n]*[^,\n \t]\\([ \t]+with\\)") | |
1078 (progn | |
1079 (setq start (match-beginning 1)) | |
1080 (goto-char (match-end 0)) | |
1081 (if (looking-at "[ \t]+\\([a-z]+\\)") | |
1082 (setq mode (buffer-substring (match-beginning 1) | |
1083 (match-end 1)))) | |
1084 (if (looking-at "[ \ta-z]+\\([0-9]+\\)") | |
1085 (setq lstyle (string-to-int | |
1086 (buffer-substring (match-beginning 1) | |
1087 (match-end 1))))) | |
1088 (if (looking-at "[ \ta-z]+[0-9]+[ \t]+\\([0-9]+\\)") | |
1089 (setq pstyle (string-to-int | |
1090 (buffer-substring (match-beginning 1) | |
1091 (match-end 1))))))) | |
1092 (setq lenbl (or (equal mode "lines") (equal mode "linespoints")) | |
1093 penbl (or (equal mode "points") (equal mode "linespoints"))) | |
1094 (if lines | |
1095 (or (eq lines t) | |
1096 (setq lstyle lines | |
1097 lenbl (>= lines 0))) | |
1098 (setq lenbl (not lenbl))) | |
1099 (if points | |
1100 (or (eq points t) | |
1101 (setq pstyle points | |
1102 penbl (>= points 0))) | |
1103 (setq penbl (not penbl))) | |
1104 (delete-region start end) | |
1105 (goto-char start) | |
1106 (insert " with " | |
1107 (if lenbl | |
1108 (if penbl "linespoints" "lines") | |
1109 (if penbl "points" "dots"))) | |
1110 (if (and pstyle (> pstyle 0)) | |
1111 (insert " " (if (and lstyle (> lstyle 0)) (int-to-string lstyle) "1") | |
1112 " " (int-to-string pstyle)) | |
1113 (if (and lstyle (> lstyle 0)) | |
1114 (insert " " (int-to-string lstyle)))))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1115 (calc-graph-view-commands)) |
40785 | 1116 |
1117 (defun calc-graph-zero-x (flag) | |
1118 (interactive "P") | |
1119 (calc-graph-set-command "noxzeroaxis" | |
1120 (and (if flag | |
1121 (<= (prefix-numeric-value flag) 0) | |
1122 (not (calc-graph-find-command "noxzeroaxis"))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1123 " "))) |
40785 | 1124 |
1125 (defun calc-graph-zero-y (flag) | |
1126 (interactive "P") | |
1127 (calc-graph-set-command "noyzeroaxis" | |
1128 (and (if flag | |
1129 (<= (prefix-numeric-value flag) 0) | |
1130 (not (calc-graph-find-command "noyzeroaxis"))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1131 " "))) |
40785 | 1132 |
1133 (defun calc-graph-name (name) | |
1134 (interactive "sTitle for current curve: ") | |
1135 (calc-graph-init) | |
1136 (save-excursion | |
1137 (set-buffer calc-gnuplot-input) | |
1138 (or (calc-graph-find-plot nil nil) | |
1139 (error "No data points have been set!")) | |
1140 (let ((base (point)) | |
58188
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
1141 start |
9e6aba37e9aa
(calc-dumb-map): Declared it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57631
diff
changeset
|
1142 end) |
40785 | 1143 (re-search-forward "[,\n]\\|[ \t]+with") |
1144 (setq end (match-beginning 0)) | |
1145 (goto-char base) | |
1146 (if (looking-at "[^,\n]*[^,\n \t]\\([ \t]+title\\)") | |
1147 (progn | |
1148 (goto-char (match-beginning 1)) | |
1149 (delete-region (point) end)) | |
1150 (goto-char end)) | |
1151 (insert " title " (prin1-to-string name)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1152 (calc-graph-view-commands)) |
40785 | 1153 |
1154 (defun calc-graph-hide (flag) | |
1155 (interactive "P") | |
1156 (calc-graph-init) | |
1157 (and (calc-graph-find-plot nil nil) | |
1158 (progn | |
1159 (or (looking-at "{") | |
1160 (error "Can't hide this curve (wrong format)")) | |
1161 (forward-char 1) | |
1162 (if (looking-at "*") | |
1163 (if (or (null flag) (<= (prefix-numeric-value flag) 0)) | |
1164 (delete-char 1)) | |
1165 (if (or (null flag) (> (prefix-numeric-value flag) 0)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1166 (insert "*")))))) |
40785 | 1167 |
1168 (defun calc-graph-header (title) | |
1169 (interactive "sTitle for entire graph: ") | |
1170 (calc-graph-set-command "title" (if (not (equal title "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1171 (prin1-to-string title)))) |
40785 | 1172 |
1173 (defun calc-graph-border (flag) | |
1174 (interactive "P") | |
1175 (calc-graph-set-command "noborder" | |
1176 (and (if flag | |
1177 (<= (prefix-numeric-value flag) 0) | |
1178 (not (calc-graph-find-command "noborder"))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1179 " "))) |
40785 | 1180 |
1181 (defun calc-graph-grid (flag) | |
1182 (interactive "P") | |
1183 (calc-graph-set-command "grid" (and (if flag | |
1184 (> (prefix-numeric-value flag) 0) | |
1185 (not (calc-graph-find-command "grid"))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1186 " "))) |
40785 | 1187 |
1188 (defun calc-graph-key (flag) | |
1189 (interactive "P") | |
1190 (calc-graph-set-command "key" (and (if flag | |
1191 (> (prefix-numeric-value flag) 0) | |
1192 (not (calc-graph-find-command "key"))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1193 " "))) |
40785 | 1194 |
1195 (defun calc-graph-num-points (res flag) | |
1196 (interactive "sNumber of data points: \nP") | |
1197 (if flag | |
1198 (if (> (prefix-numeric-value flag) 0) | |
1199 (if (equal res "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1200 (message "Default resolution is %d" |
40785 | 1201 calc-graph-default-resolution) |
1202 (setq calc-graph-default-resolution (string-to-int res))) | |
1203 (if (equal res "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1204 (message "Default 3D resolution is %d" |
40785 | 1205 calc-graph-default-resolution-3d) |
1206 (setq calc-graph-default-resolution-3d (string-to-int res)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1207 (calc-graph-set-command "samples" (if (not (equal res "")) res)))) |
40785 | 1208 |
1209 (defun calc-graph-device (name flag) | |
1210 (interactive "sDevice name: \nP") | |
1211 (if (equal name "?") | |
1212 (progn | |
1213 (calc-gnuplot-command "set terminal") | |
1214 (calc-graph-view-trail)) | |
1215 (if flag | |
1216 (if (> (prefix-numeric-value flag) 0) | |
1217 (if (equal name "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1218 (message "Default GNUPLOT device is \"%s\"" |
40785 | 1219 calc-gnuplot-default-device) |
1220 (setq calc-gnuplot-default-device name)) | |
1221 (if (equal name "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1222 (message "GNUPLOT device for Print command is \"%s\"" |
40785 | 1223 calc-gnuplot-print-device) |
1224 (setq calc-gnuplot-print-device name))) | |
1225 (calc-graph-set-command "terminal" (if (not (equal name "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1226 name))))) |
40785 | 1227 |
1228 (defun calc-graph-output (name flag) | |
1229 (interactive "FOutput file name: \np") | |
1230 (cond ((string-match "\\<[aA][uU][tT][oO]$" name) | |
1231 (setq name "auto")) | |
1232 ((string-match "\\<[tT][tT][yY]$" name) | |
1233 (setq name "tty")) | |
1234 ((string-match "\\<[sS][tT][dD][oO][uU][tT]$" name) | |
1235 (setq name "STDOUT")) | |
1236 ((equal (file-name-nondirectory name) "") | |
1237 (setq name "")) | |
1238 (t (setq name (expand-file-name name)))) | |
1239 (if flag | |
1240 (if (> (prefix-numeric-value flag) 0) | |
1241 (if (equal name "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1242 (message "Default GNUPLOT output file is \"%s\"" |
40785 | 1243 calc-gnuplot-default-output) |
1244 (setq calc-gnuplot-default-output name)) | |
1245 (if (equal name "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1246 (message "GNUPLOT output file for Print command is \"%s\"" |
40785 | 1247 calc-gnuplot-print-output) |
1248 (setq calc-gnuplot-print-output name))) | |
1249 (calc-graph-set-command "output" (if (not (equal name "")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1250 (prin1-to-string name))))) |
40785 | 1251 |
1252 (defun calc-graph-display (name) | |
1253 (interactive "sX display name: ") | |
1254 (if (equal name "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1255 (message "Current X display is \"%s\"" |
40785 | 1256 (or calc-gnuplot-display "<none>")) |
1257 (setq calc-gnuplot-display name) | |
1258 (if (calc-gnuplot-alive) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1259 (calc-gnuplot-command "exit")))) |
40785 | 1260 |
1261 (defun calc-graph-geometry (name) | |
1262 (interactive "sX geometry spec (or \"default\"): ") | |
1263 (if (equal name "") | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1264 (message "Current X geometry is \"%s\"" |
40785 | 1265 (or calc-gnuplot-geometry "default")) |
1266 (setq calc-gnuplot-geometry (and (not (equal name "default")) name)) | |
1267 (if (calc-gnuplot-alive) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1268 (calc-gnuplot-command "exit")))) |
40785 | 1269 |
1270 (defun calc-graph-find-command (cmd) | |
1271 (calc-graph-init) | |
1272 (save-excursion | |
1273 (set-buffer calc-gnuplot-input) | |
1274 (goto-char (point-min)) | |
1275 (if (re-search-forward (concat "^set[ \t]+" cmd "[ \t]*\\(.*\\)$") nil t) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1276 (buffer-substring (match-beginning 1) (match-end 1))))) |
40785 | 1277 |
1278 (defun calc-graph-set-command (cmd &rest args) | |
1279 (calc-graph-init) | |
1280 (save-excursion | |
1281 (set-buffer calc-gnuplot-input) | |
1282 (goto-char (point-min)) | |
1283 (if (re-search-forward (concat "^set[ \t]+" cmd "[ \t\n]") nil t) | |
1284 (progn | |
1285 (forward-char -1) | |
1286 (end-of-line) | |
1287 (let ((end (point))) | |
1288 (beginning-of-line) | |
1289 (delete-region (point) (1+ end)))) | |
1290 (if (calc-graph-find-plot t t) | |
1291 (if (eq (preceding-char) ?\n) | |
1292 (forward-char -1)) | |
1293 (goto-char (1- (point-max))))) | |
1294 (if (and args (car args)) | |
1295 (progn | |
1296 (or (bolp) | |
1297 (insert "\n")) | |
1298 (insert "set " (mapconcat 'identity (cons cmd args) " ") "\n")))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1299 (calc-graph-view-commands)) |
40785 | 1300 |
1301 (defun calc-graph-command (cmd) | |
1302 (interactive "sGNUPLOT command: ") | |
1303 (calc-wrapper | |
1304 (calc-graph-init) | |
1305 (calc-graph-view-trail) | |
1306 (calc-gnuplot-command cmd) | |
1307 (accept-process-output) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1308 (calc-graph-view-trail))) |
40785 | 1309 |
1310 (defun calc-graph-kill (&optional no-view) | |
1311 (interactive) | |
1312 (calc-graph-delete-temps) | |
1313 (if (calc-gnuplot-alive) | |
1314 (calc-wrapper | |
1315 (or no-view (calc-graph-view-trail)) | |
1316 (let ((calc-graph-no-wait t)) | |
1317 (calc-gnuplot-command "exit")) | |
1318 (sit-for 1) | |
1319 (if (process-status calc-gnuplot-process) | |
1320 (delete-process calc-gnuplot-process)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1321 (setq calc-gnuplot-process nil)))) |
40785 | 1322 |
1323 (defun calc-graph-quit () | |
1324 (interactive) | |
1325 (if (get-buffer-window calc-gnuplot-input) | |
1326 (calc-graph-view-commands t)) | |
1327 (if (get-buffer-window calc-gnuplot-buffer) | |
1328 (calc-graph-view-trail t)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1329 (calc-graph-kill t)) |
40785 | 1330 |
1331 (defun calc-graph-view-commands (&optional no-need) | |
1332 (interactive "p") | |
1333 (or calc-graph-no-auto-view (calc-graph-init-buffers)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1334 (calc-graph-view calc-gnuplot-input calc-gnuplot-buffer (null no-need))) |
40785 | 1335 |
1336 (defun calc-graph-view-trail (&optional no-need) | |
1337 (interactive "p") | |
1338 (or calc-graph-no-auto-view (calc-graph-init-buffers)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1339 (calc-graph-view calc-gnuplot-buffer calc-gnuplot-input (null no-need))) |
40785 | 1340 |
1341 (defun calc-graph-view (buf other-buf need) | |
1342 (let (win) | |
1343 (or calc-graph-no-auto-view | |
1344 (if (setq win (get-buffer-window buf)) | |
1345 (or need | |
1346 (and (eq buf calc-gnuplot-buffer) | |
1347 (save-excursion | |
1348 (set-buffer buf) | |
1349 (not (pos-visible-in-window-p (point-max) win)))) | |
1350 (progn | |
1351 (bury-buffer buf) | |
1352 (bury-buffer other-buf) | |
1353 (let ((curwin (selected-window))) | |
1354 (select-window win) | |
1355 (switch-to-buffer nil) | |
1356 (select-window curwin)))) | |
1357 (if (setq win (get-buffer-window other-buf)) | |
1358 (set-window-buffer win buf) | |
1359 (if (eq major-mode 'calc-mode) | |
1360 (if (or need | |
40998
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
1361 (< (window-height) (1- (frame-height)))) |
40785 | 1362 (display-buffer buf)) |
1363 (switch-to-buffer buf))))) | |
1364 (save-excursion | |
1365 (set-buffer buf) | |
1366 (if (and (eq buf calc-gnuplot-buffer) | |
1367 (setq win (get-buffer-window buf)) | |
1368 (not (pos-visible-in-window-p (point-max) win))) | |
1369 (progn | |
1370 (goto-char (point-max)) | |
1371 (vertical-motion (- 6 (window-height win))) | |
1372 (set-window-start win (point)) | |
1373 (goto-char (point-max))))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1374 (or calc-graph-no-auto-view (sit-for 0)))) |
40785 | 1375 |
1376 (defun calc-gnuplot-check-for-errors () | |
1377 (if (save-excursion | |
1378 (prog2 | |
1379 (progn | |
1380 (set-buffer calc-gnuplot-buffer) | |
1381 (goto-char calc-gnuplot-last-error-pos)) | |
1382 (re-search-forward "^[ \t]+\\^$" nil t) | |
1383 (goto-char (point-max)) | |
1384 (setq calc-gnuplot-last-error-pos (point-max)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1385 (calc-graph-view-trail))) |
40785 | 1386 |
1387 (defun calc-gnuplot-command (&rest args) | |
1388 (calc-graph-init) | |
1389 (let ((cmd (concat (mapconcat 'identity args " ") "\n"))) | |
1390 (accept-process-output) | |
1391 (save-excursion | |
1392 (set-buffer calc-gnuplot-buffer) | |
1393 (calc-gnuplot-check-for-errors) | |
1394 (goto-char (point-max)) | |
1395 (setq calc-gnuplot-trail-mark (point)) | |
1396 (or (>= calc-gnuplot-version 3) | |
1397 (insert cmd)) | |
1398 (set-marker (process-mark calc-gnuplot-process) (point)) | |
1399 (process-send-string calc-gnuplot-process cmd) | |
1400 (if (get-buffer-window calc-gnuplot-buffer) | |
1401 (calc-graph-view-trail)) | |
1402 (accept-process-output (and (not calc-graph-no-wait) | |
1403 calc-gnuplot-process)) | |
1404 (calc-gnuplot-check-for-errors) | |
1405 (if (get-buffer-window calc-gnuplot-buffer) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1406 (calc-graph-view-trail))))) |
40785 | 1407 |
1408 (defun calc-graph-init-buffers () | |
1409 (or (and calc-gnuplot-buffer | |
1410 (buffer-name calc-gnuplot-buffer)) | |
1411 (setq calc-gnuplot-buffer (get-buffer-create "*Gnuplot Trail*"))) | |
1412 (or (and calc-gnuplot-input | |
1413 (buffer-name calc-gnuplot-input)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1414 (setq calc-gnuplot-input (get-buffer-create "*Gnuplot Commands*")))) |
40785 | 1415 |
1416 (defun calc-graph-init () | |
1417 (or (calc-gnuplot-alive) | |
1418 (let ((process-connection-type t) | |
1419 origin) | |
1420 (if calc-gnuplot-process | |
1421 (progn | |
1422 (delete-process calc-gnuplot-process) | |
1423 (setq calc-gnuplot-process nil))) | |
1424 (calc-graph-init-buffers) | |
1425 (save-excursion | |
1426 (set-buffer calc-gnuplot-buffer) | |
1427 (insert "\nStarting gnuplot...\n") | |
1428 (setq origin (point))) | |
1429 (setq calc-graph-last-device nil) | |
1430 (setq calc-graph-last-output nil) | |
1431 (condition-case err | |
1432 (let ((args (append (and calc-gnuplot-display | |
1433 (not (equal calc-gnuplot-display | |
1434 (getenv "DISPLAY"))) | |
1435 (list "-display" | |
1436 calc-gnuplot-display)) | |
1437 (and calc-gnuplot-geometry | |
1438 (list "-geometry" | |
1439 calc-gnuplot-geometry))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
1440 (setq calc-gnuplot-process |
40785 | 1441 (apply 'start-process |
1442 "gnuplot" | |
1443 calc-gnuplot-buffer | |
1444 calc-gnuplot-name | |
1445 args)) | |
57631
3581e2403cc7
(calc-graph-init): Use `set-process-query-on-exit-flag'
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57593
diff
changeset
|
1446 (set-process-query-on-exit-flag calc-gnuplot-process nil)) |
40785 | 1447 (file-error |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1448 (error "Sorry, can't find \"%s\" on your system" |
40785 | 1449 calc-gnuplot-name))) |
1450 (save-excursion | |
1451 (set-buffer calc-gnuplot-buffer) | |
1452 (while (and (not (save-excursion | |
1453 (goto-char origin) | |
1454 (search-forward "gnuplot> " nil t))) | |
1455 (memq (process-status calc-gnuplot-process) '(run stop))) | |
1456 (accept-process-output calc-gnuplot-process)) | |
1457 (or (memq (process-status calc-gnuplot-process) '(run stop)) | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1458 (error "Unable to start GNUPLOT process")) |
40785 | 1459 (if (save-excursion |
1460 (goto-char origin) | |
1461 (re-search-forward | |
1462 "G N U P L O T.*\n.*version \\([0-9]+\\)\\." nil t)) | |
1463 (setq calc-gnuplot-version (string-to-int (buffer-substring | |
1464 (match-beginning 1) | |
1465 (match-end 1)))) | |
1466 (setq calc-gnuplot-version 1)) | |
1467 (goto-char (point-max))))) | |
1468 (save-excursion | |
1469 (set-buffer calc-gnuplot-input) | |
1470 (if (= (buffer-size) 0) | |
1471 (insert "# Commands for running gnuplot\n\n\n") | |
1472 (or calc-graph-no-auto-view | |
1473 (eq (char-after (1- (point-max))) ?\n) | |
1474 (progn | |
1475 (goto-char (point-max)) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1476 (insert "\n")))))) |
40785 | 1477 |
58657
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
1478 (provide 'calc-graph) |
05cfe246ec8d
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58478
diff
changeset
|
1479 |
52401 | 1480 ;;; arch-tag: e4b06a52-c386-4d54-a2bb-7c0a0ef533c2 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
1481 ;;; calc-graph.el ends here |