annotate lisp/calc/calc-graph.el @ 85965:ac6bbbd64b2f

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