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