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