/[emacs]/emacs/lisp/calc/calc-graph.el
ViewVC logotype

Diff of /emacs/lisp/calc/calc-graph.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5.2.4 by miles, Mon Oct 25 04:22:24 2004 UTC revision 1.5.2.5 by miles, Wed Dec 8 23:31:43 2004 UTC
# Line 66  Line 66 
66  (defvar calc-graph-data-cache-limit 10)  (defvar calc-graph-data-cache-limit 10)
67  (defvar calc-graph-no-auto-view nil)  (defvar calc-graph-no-auto-view nil)
68  (defvar calc-graph-no-wait nil)  (defvar calc-graph-no-wait nil)
69    (defvar calc-gnuplot-trail-mark)
70    
71  (defun calc-graph-fast (many)  (defun calc-graph-fast (many)
72    (interactive "P")    (interactive "P")
# Line 224  Line 225 
225        thing        thing
226      (let ((found (assoc thing calc-graph-var-cache)))      (let ((found (assoc thing calc-graph-var-cache)))
227        (or found        (or found
228            (progn            (let ((varname (concat "PlotData"
229              (setq varname (concat "PlotData"                                   (int-to-string
230                                    (int-to-string                                    (1+ (length calc-graph-var-cache))))))
231                                     (1+ (length calc-graph-var-cache))))              (setq var (list 'var (intern varname)
                   var (list 'var (intern varname)  
232                              (intern (concat "var-" varname)))                              (intern (concat "var-" varname)))
233                    found (cons thing var)                    found (cons thing var)
234                    calc-graph-var-cache (cons found calc-graph-var-cache))                    calc-graph-var-cache (cons found calc-graph-var-cache))
# Line 275  Line 275 
275    (interactive "P")    (interactive "P")
276    (calc-graph-plot flag t))    (calc-graph-plot flag t))
277    
278    (defvar var-DUMMY)
279    (defvar var-DUMMY2)
280    (defvar var-PlotRejects)
281    
282    ;; The following variables are local to calc-graph-plot, but are
283    ;; used in the functions calc-graph-compute-2d, calc-graph-refine-2d,
284    ;; calc-graph-recompute-2d, calc-graph-compute-3d and
285    ;; calc-graph-format-data, which are called by calc-graph-plot.
286    (defvar calc-graph-yvalue)
287    (defvar calc-graph-yvec)
288    (defvar calc-graph-numsteps)
289    (defvar calc-graph-numsteps3)
290    (defvar calc-graph-xvalue)
291    (defvar calc-graph-xvec)
292    (defvar calc-graph-xname)
293    (defvar calc-graph-yname)
294    (defvar calc-graph-xstep)
295    (defvar calc-graph-ycache)
296    (defvar calc-graph-ycacheptr)
297    (defvar calc-graph-refine)
298    (defvar calc-graph-keep-file)
299    (defvar calc-graph-xval)
300    (defvar calc-graph-xlow)
301    (defvar calc-graph-xhigh)
302    (defvar calc-graph-yval)
303    (defvar calc-graph-yp)
304    (defvar calc-graph-xp)
305    (defvar calc-graph-zp)
306    (defvar calc-graph-yvector)
307    (defvar calc-graph-resolution)
308    (defvar calc-graph-y3value)
309    (defvar calc-graph-y3name)
310    (defvar calc-graph-y3step)
311    (defvar calc-graph-zval)
312    (defvar calc-graph-stepcount)
313    (defvar calc-graph-is-splot)
314    (defvar calc-graph-surprise-splot)
315    (defvar calc-graph-blank)
316    (defvar calc-graph-non-blank)
317    (defvar calc-graph-curve-num)
318    
319  (defun calc-graph-plot (flag &optional printing)  (defun calc-graph-plot (flag &optional printing)
320    (interactive "P")    (interactive "P")
321    (calc-slow-wrapper    (calc-slow-wrapper
# Line 282  Line 323 
323           (tempbuf (get-buffer-create "*Gnuplot Temp-2*"))           (tempbuf (get-buffer-create "*Gnuplot Temp-2*"))
324           (tempbuftop 1)           (tempbuftop 1)
325           (tempoutfile nil)           (tempoutfile nil)
326           (curve-num 0)           (calc-graph-curve-num 0)
327           (refine (and flag (> (prefix-numeric-value flag) 0)))           (calc-graph-refine (and flag (> (prefix-numeric-value flag) 0)))
328           (recompute (and flag (< (prefix-numeric-value flag) 0)))           (recompute (and flag (< (prefix-numeric-value flag) 0)))
329           (surprise-splot nil)           (calc-graph-surprise-splot nil)
330           (tty-output nil)           (tty-output nil)
331           cache-env is-splot device output resolution precision samples-pos)           cache-env calc-graph-is-splot device output calc-graph-resolution precision samples-pos)
332       (or (boundp 'calc-graph-prev-kill-hook)       (add-hook 'kill-emacs-hook 'calc-graph-kill-hook)
          (setq calc-graph-prev-kill-hook nil)  
          (add-hook 'kill-emacs-hook 'calc-graph-kill-hook))  
333       (save-excursion       (save-excursion
334         (calc-graph-init)         (calc-graph-init)
335         (set-buffer tempbuf)         (set-buffer tempbuf)
336         (erase-buffer)         (erase-buffer)
337         (set-buffer calc-gnuplot-input)         (set-buffer calc-gnuplot-input)
338         (goto-char (point-min))         (goto-char (point-min))
339         (setq is-splot (re-search-forward "^splot[ \t]" nil t))         (setq calc-graph-is-splot (re-search-forward "^splot[ \t]" nil t))
340         (let ((str (buffer-string))         (let ((str (buffer-string))
341               (ver calc-gnuplot-version))               (ver calc-gnuplot-version))
342           (set-buffer (get-buffer-create "*Gnuplot Temp*"))           (set-buffer (get-buffer-create "*Gnuplot Temp*"))
# Line 313  Line 352 
352                       "set nogrid\nset nokey\nset nopolar\n"))                       "set nogrid\nset nokey\nset nopolar\n"))
353           (if (>= ver 3)           (if (>= ver 3)
354               (insert "set surface\nset nocontour\n"               (insert "set surface\nset nocontour\n"
355                       "set " (if is-splot "" "no") "parametric\n"                       "set " (if calc-graph-is-splot "" "no") "parametric\n"
356                       "set notime\nset border\nset ztics\nset zeroaxis\n"                       "set notime\nset border\nset ztics\nset zeroaxis\n"
357                       "set view 60,30,1,1\nset offsets 0,0,0,0\n"))                       "set view 60,30,1,1\nset offsets 0,0,0,0\n"))
358           (setq samples-pos (point))           (setq samples-pos (point))
359           (insert "\n\n" str))           (insert "\n\n" str))
360         (goto-char (point-min))         (goto-char (point-min))
361         (if is-splot         (if calc-graph-is-splot
362             (if refine             (if calc-graph-refine
363                 (error "This option works only for 2d plots")                 (error "This option works only for 2d plots")
364               (setq recompute t)))               (setq recompute t)))
365         (let ((calc-gnuplot-input (current-buffer))         (let ((calc-gnuplot-input (current-buffer))
# Line 366  Line 405 
405                                       (if (equal output "STDOUT")                                       (if (equal output "STDOUT")
406                                           ""                                           ""
407                                         (prin1-to-string output)))))                                         (prin1-to-string output)))))
408           (setq resolution (calc-graph-find-command "samples"))           (setq calc-graph-resolution (calc-graph-find-command "samples"))
409           (if resolution           (if calc-graph-resolution
410               (setq resolution (string-to-int resolution))               (setq calc-graph-resolution (string-to-int calc-graph-resolution))
411             (setq resolution (if is-splot             (setq calc-graph-resolution (if calc-graph-is-splot
412                                  calc-graph-default-resolution-3d                                  calc-graph-default-resolution-3d
413                                calc-graph-default-resolution)))                                calc-graph-default-resolution)))
414           (setq precision (calc-graph-find-command "precision"))           (setq precision (calc-graph-find-command "precision"))
# Line 381  Line 420 
420           (calc-graph-set-command "samples")           (calc-graph-set-command "samples")
421           (calc-graph-set-command "precision"))           (calc-graph-set-command "precision"))
422         (goto-char samples-pos)         (goto-char samples-pos)
423         (insert "set samples " (int-to-string (max (if is-splot 20 200)         (insert "set samples " (int-to-string (max (if calc-graph-is-splot 20 200)
424                                                    (+ 5 resolution))) "\n")                                                    (+ 5 calc-graph-resolution))) "\n")
425         (while (re-search-forward "{\\*[^}]+}[^,\n]*" nil t)         (while (re-search-forward "{\\*[^}]+}[^,\n]*" nil t)
426           (delete-region (match-beginning 0) (match-end 0))           (delete-region (match-beginning 0) (match-end 0))
427           (if (looking-at ",")           (if (looking-at ",")
# Line 398  Line 437 
437                                 calc-simplify-mode                                 calc-simplify-mode
438                                 calc-infinite-mode                                 calc-infinite-mode
439                                 calc-word-size                                 calc-word-size
440                                 precision is-splot))                                 precision calc-graph-is-splot))
441           (if (and (not recompute)           (if (and (not recompute)
442                    (equal (cdr (car calc-graph-data-cache)) cache-env))                    (equal (cdr (car calc-graph-data-cache)) cache-env))
443               (while (> (length calc-graph-data-cache)               (while (> (length calc-graph-data-cache)
# Line 408  Line 447 
447             (setq calc-graph-data-cache (list (cons nil cache-env)))))             (setq calc-graph-data-cache (list (cons nil cache-env)))))
448         (calc-graph-find-plot t t)         (calc-graph-find-plot t t)
449         (while (re-search-forward         (while (re-search-forward
450                 (if is-splot                 (if calc-graph-is-splot
451                     "{\\([^{}:\n]+\\):\\([^{}:\n]+\\):\\([^{}:\n]+\\)}"                     "{\\([^{}:\n]+\\):\\([^{}:\n]+\\):\\([^{}:\n]+\\)}"
452                   "{\\([^{}:\n]+\\)\\(:\\)\\([^{}:\n]+\\)}")                   "{\\([^{}:\n]+\\)\\(:\\)\\([^{}:\n]+\\)}")
453                 nil t)                 nil t)
454           (setq curve-num (1+ curve-num))           (setq calc-graph-curve-num (1+ calc-graph-curve-num))
455           (let* ((xname (buffer-substring (match-beginning 1) (match-end 1)))           (let* ((calc-graph-xname (buffer-substring (match-beginning 1) (match-end 1)))
456                  (xvar (intern (concat "var-" xname)))                  (xvar (intern (concat "var-" calc-graph-xname)))
457                  (xvalue (math-evaluate-expr (calc-var-value xvar)))                  (calc-graph-xvalue (math-evaluate-expr (calc-var-value xvar)))
458                  (y3name (and is-splot                  (calc-graph-y3name (and calc-graph-is-splot
459                               (buffer-substring (match-beginning 2)                               (buffer-substring (match-beginning 2)
460                                                 (match-end 2))))                                                 (match-end 2))))
461                  (y3var (and is-splot (intern (concat "var-" y3name))))                  (y3var (and calc-graph-is-splot (intern (concat "var-" calc-graph-y3name))))
462                  (y3value (and is-splot (calc-var-value y3var)))                  (calc-graph-y3value (and calc-graph-is-splot (calc-var-value y3var)))
463                  (yname (buffer-substring (match-beginning 3) (match-end 3)))                  (calc-graph-yname (buffer-substring (match-beginning 3) (match-end 3)))
464                  (yvar (intern (concat "var-" yname)))                  (yvar (intern (concat "var-" calc-graph-yname)))
465                  (yvalue (calc-var-value yvar))                  (calc-graph-yvalue (calc-var-value yvar))
466                  filename)                  filename)
467             (delete-region (match-beginning 0) (match-end 0))             (delete-region (match-beginning 0) (match-end 0))
468             (setq filename (calc-temp-file-name curve-num))             (setq filename (calc-temp-file-name calc-graph-curve-num))
469             (save-excursion             (save-excursion
470               (set-buffer calcbuf)               (set-buffer calcbuf)
471               (let (tempbuftop               (let (tempbuftop
472                     (xp xvalue)                     (calc-graph-xp calc-graph-xvalue)
473                     (yp yvalue)                     (calc-graph-yp calc-graph-yvalue)
474                     (zp nil)                     (calc-graph-zp nil)
475                     (xlow nil) (xhigh nil) (y3low nil) (y3high nil)                     (calc-graph-xlow nil) (calc-graph-xhigh nil) (y3low nil) (y3high nil)
476                     xvec xval xstep var-DUMMY                     calc-graph-xvec calc-graph-xval calc-graph-xstep var-DUMMY
477                     y3vec y3val y3step var-DUMMY2 (zval nil)                     y3val calc-graph-y3step var-DUMMY2 (calc-graph-zval nil)
478                     yvec yval ycache ycacheptr yvector                     calc-graph-yvec calc-graph-yval calc-graph-ycache calc-graph-ycacheptr calc-graph-yvector
479                     numsteps numsteps3                     calc-graph-numsteps calc-graph-numsteps3
480                     (keep-file (and (not is-splot) (file-exists-p filename)))                     (calc-graph-keep-file (and (not calc-graph-is-splot) (file-exists-p filename)))
481                     (stepcount 0)                     (calc-graph-stepcount 0)
482                     (calc-symbolic-mode nil)                     (calc-symbolic-mode nil)
483                     (calc-prefer-frac nil)                     (calc-prefer-frac nil)
484                     (calc-internal-prec (max 3 precision))                     (calc-internal-prec (max 3 precision))
485                     (calc-simplify-mode (and (not (memq calc-simplify-mode                     (calc-simplify-mode (and (not (memq calc-simplify-mode
486                                                         '(none num)))                                                         '(none num)))
487                                              calc-simplify-mode))                                              calc-simplify-mode))
488                     (blank t)                     (calc-graph-blank t)
489                     (non-blank nil)                     (calc-graph-non-blank nil)
490                     (math-working-step 0)                     (math-working-step 0)
491                     (math-working-step-2 nil))                     (math-working-step-2 nil))
492                 (save-excursion                 (save-excursion
493                   (if is-splot                   (if calc-graph-is-splot
494                       (calc-graph-compute-3d)                       (calc-graph-compute-3d)
495                     (calc-graph-compute-2d))                     (calc-graph-compute-2d))
496                   (set-buffer tempbuf)                   (set-buffer tempbuf)
497                   (goto-char (point-max))                   (goto-char (point-max))
498                   (insert "\n" xname)                   (insert "\n" calc-graph-xname)
499                   (if is-splot                   (if calc-graph-is-splot
500                       (insert ":" y3name))                       (insert ":" calc-graph-y3name))
501                   (insert ":" yname "\n\n")                   (insert ":" calc-graph-yname "\n\n")
502                   (setq tempbuftop (point))                   (setq tempbuftop (point))
503                   (let ((calc-group-digits nil)                   (let ((calc-group-digits nil)
504                         (calc-leading-zeros nil)                         (calc-leading-zeros nil)
505                         (calc-number-radix 10)                         (calc-number-radix 10)
506                         (entry (and (not is-splot)                         (entry (and (not calc-graph-is-splot)
507                                     (list xp yp xhigh numsteps))))                                     (list calc-graph-xp calc-graph-yp calc-graph-xhigh calc-graph-numsteps))))
508                     (or (equal entry                     (or (equal entry
509                                (nth 1 (nth (1+ curve-num)                                (nth 1 (nth (1+ calc-graph-curve-num)
510                                            calc-graph-file-cache)))                                            calc-graph-file-cache)))
511                         (setq keep-file nil))                         (setq calc-graph-keep-file nil))
512                     (setcar (cdr (nth (1+ curve-num) calc-graph-file-cache))                     (setcar (cdr (nth (1+ calc-graph-curve-num) calc-graph-file-cache))
513                             entry)                             entry)
514                     (or keep-file                     (or calc-graph-keep-file
515                         (calc-graph-format-data)))                         (calc-graph-format-data)))
516                   (or keep-file                   (or calc-graph-keep-file
517                       (progn                       (progn
518                         (or non-blank                         (or calc-graph-non-blank
519                             (error "No valid data points for %s:%s"                             (error "No valid data points for %s:%s"
520                                    xname yname))                                    calc-graph-xname calc-graph-yname))
521                         (write-region tempbuftop (point-max) filename                         (write-region tempbuftop (point-max) filename
522                                       nil 'quiet))))))                                       nil 'quiet))))))
523             (insert (prin1-to-string filename))))             (insert (prin1-to-string filename))))
524         (if surprise-splot         (if calc-graph-surprise-splot
525             (setcdr cache-env nil))             (setcdr cache-env nil))
526         (if (= curve-num 0)         (if (= calc-graph-curve-num 0)
527             (progn             (progn
528               (calc-gnuplot-command "clear")               (calc-gnuplot-command "clear")
529               (calc-clear-command-flag 'clear-message)               (calc-clear-command-flag 'clear-message)
530               (message "No data to plot!"))               (message "No data to plot!"))
531           (setq calc-graph-data-cache-limit (max curve-num           (setq calc-graph-data-cache-limit (max calc-graph-curve-num
532                                                  calc-graph-data-cache-limit)                                                  calc-graph-data-cache-limit)
533                 filename (calc-temp-file-name 0))                 filename (calc-temp-file-name 0))
534           (write-region (point-min) (point-max) filename nil 'quiet)           (write-region (point-min) (point-max) filename nil 'quiet)
# Line 517  Line 556 
556                     (eval command))))))))))                     (eval command))))))))))
557    
558  (defun calc-graph-compute-2d ()  (defun calc-graph-compute-2d ()
559    (if (setq yvec (eq (car-safe yvalue) 'vec))    (if (setq calc-graph-yvec (eq (car-safe calc-graph-yvalue) 'vec))
560        (if (= (setq numsteps (1- (length yvalue))) 0)        (if (= (setq calc-graph-numsteps (1- (length calc-graph-yvalue))) 0)
561            (error "Can't plot an empty vector")            (error "Can't plot an empty vector")
562          (if (setq xvec (eq (car-safe xvalue) 'vec))          (if (setq calc-graph-xvec (eq (car-safe calc-graph-xvalue) 'vec))
563              (or (= (1- (length xvalue)) numsteps)              (or (= (1- (length calc-graph-xvalue)) calc-graph-numsteps)
564                  (error "%s and %s have different lengths" xname yname))                  (error "%s and %s have different lengths" calc-graph-xname calc-graph-yname))
565            (if (and (eq (car-safe xvalue) 'intv)            (if (and (eq (car-safe calc-graph-xvalue) 'intv)
566                     (math-constp xvalue))                     (math-constp calc-graph-xvalue))
567                (setq xstep (math-div (math-sub (nth 3 xvalue)                (setq calc-graph-xstep (math-div (math-sub (nth 3 calc-graph-xvalue)
568                                                (nth 2 xvalue))                                                (nth 2 calc-graph-xvalue))
569                                      (1- numsteps))                                      (1- calc-graph-numsteps))
570                      xvalue (nth 2 xvalue))                      calc-graph-xvalue (nth 2 calc-graph-xvalue))
571              (if (math-realp xvalue)              (if (math-realp calc-graph-xvalue)
572                  (setq xstep 1)                  (setq calc-graph-xstep 1)
573                (error "%s is not a suitable basis for %s" xname yname)))))                (error "%s is not a suitable basis for %s" calc-graph-xname calc-graph-yname)))))
574      (or (math-realp yvalue)      (or (math-realp calc-graph-yvalue)
575          (let ((arglist nil))          (let ((arglist nil))
576            (setq yvalue (math-evaluate-expr yvalue))            (setq calc-graph-yvalue (math-evaluate-expr calc-graph-yvalue))
577            (calc-default-formula-arglist yvalue)            (calc-default-formula-arglist calc-graph-yvalue)
578            (or arglist            (or arglist
579                (error "%s does not contain any unassigned variables" yname))                (error "%s does not contain any unassigned variables" calc-graph-yname))
580            (and (cdr arglist)            (and (cdr arglist)
581                 (error "%s contains more than one variable: %s"                 (error "%s contains more than one variable: %s"
582                        yname arglist))                        calc-graph-yname arglist))
583            (setq yvalue (math-expr-subst yvalue            (setq calc-graph-yvalue (math-expr-subst calc-graph-yvalue
584                                          (math-build-var-name (car arglist))                                          (math-build-var-name (car arglist))
585                                          '(var DUMMY var-DUMMY)))))                                          '(var DUMMY var-DUMMY)))))
586      (setq ycache (assoc yvalue calc-graph-data-cache))      (setq calc-graph-ycache (assoc calc-graph-yvalue calc-graph-data-cache))
587      (delq ycache calc-graph-data-cache)      (delq calc-graph-ycache calc-graph-data-cache)
588      (nconc calc-graph-data-cache      (nconc calc-graph-data-cache
589             (list (or ycache (setq ycache (list yvalue)))))             (list (or calc-graph-ycache (setq calc-graph-ycache (list calc-graph-yvalue)))))
590      (if (and (not (setq xvec (eq (car-safe xvalue) 'vec)))      (if (and (not (setq calc-graph-xvec (eq (car-safe calc-graph-xvalue) 'vec)))
591               refine (cdr (cdr ycache)))               calc-graph-refine (cdr (cdr calc-graph-ycache)))
592          (calc-graph-refine-2d)          (calc-graph-refine-2d)
593        (calc-graph-recompute-2d))))        (calc-graph-recompute-2d))))
594    
595  (defun calc-graph-refine-2d ()  (defun calc-graph-refine-2d ()
596    (setq keep-file nil    (setq calc-graph-keep-file nil
597          ycacheptr (cdr ycache))          calc-graph-ycacheptr (cdr calc-graph-ycache))
598    (if (and (setq xval (calc-graph-find-command "xrange"))    (if (and (setq calc-graph-xval (calc-graph-find-command "xrange"))
599             (string-match "\\`\\[\\([0-9.eE+-]*\\):\\([0-9.eE+-]*\\)\\]\\'"             (string-match "\\`\\[\\([0-9.eE+-]*\\):\\([0-9.eE+-]*\\)\\]\\'"
600                           xval))                           calc-graph-xval))
601        (let ((b2 (match-beginning 2))        (let ((b2 (match-beginning 2))
602              (e2 (match-end 2)))              (e2 (match-end 2)))
603          (setq xlow (math-read-number (substring xval          (setq calc-graph-xlow (math-read-number (substring calc-graph-xval
604                                                  (match-beginning 1)                                                  (match-beginning 1)
605                                                  (match-end 1)))                                                  (match-end 1)))
606                xhigh (math-read-number (substring xval b2 e2))))                calc-graph-xhigh (math-read-number (substring calc-graph-xval b2 e2))))
607      (if xlow      (if calc-graph-xlow
608          (while (and (cdr ycacheptr)          (while (and (cdr calc-graph-ycacheptr)
609                      (Math-lessp (car (nth 1 ycacheptr)) xlow))                      (Math-lessp (car (nth 1 calc-graph-ycacheptr)) calc-graph-xlow))
610            (setq ycacheptr (cdr ycacheptr)))))            (setq calc-graph-ycacheptr (cdr calc-graph-ycacheptr)))))
611    (setq math-working-step-2 (1- (length ycacheptr)))    (setq math-working-step-2 (1- (length calc-graph-ycacheptr)))
612    (while (and (cdr ycacheptr)    (while (and (cdr calc-graph-ycacheptr)
613                (or (not xhigh)                (or (not calc-graph-xhigh)
614                    (Math-lessp (car (car ycacheptr)) xhigh)))                    (Math-lessp (car (car calc-graph-ycacheptr)) calc-graph-xhigh)))
615      (setq var-DUMMY (math-div (math-add (car (car ycacheptr))      (setq var-DUMMY (math-div (math-add (car (car calc-graph-ycacheptr))
616                                          (car (nth 1 ycacheptr)))                                          (car (nth 1 calc-graph-ycacheptr)))
617                                2)                                2)
618            math-working-step (1+ math-working-step)            math-working-step (1+ math-working-step)
619            yval (math-evaluate-expr yvalue))            calc-graph-yval (math-evaluate-expr calc-graph-yvalue))
620      (setcdr ycacheptr (cons (cons var-DUMMY yval)      (setcdr calc-graph-ycacheptr (cons (cons var-DUMMY calc-graph-yval)
621                              (cdr ycacheptr)))                              (cdr calc-graph-ycacheptr)))
622      (setq ycacheptr (cdr (cdr ycacheptr))))      (setq calc-graph-ycacheptr (cdr (cdr calc-graph-ycacheptr))))
623    (setq yp ycache    (setq calc-graph-yp calc-graph-ycache
624          numsteps 1000000))          calc-graph-numsteps 1000000))
625    
626  (defun calc-graph-recompute-2d ()  (defun calc-graph-recompute-2d ()
627    (setq ycacheptr ycache)    (setq calc-graph-ycacheptr calc-graph-ycache)
628    (if xvec    (if calc-graph-xvec
629        (setq numsteps (1- (length xvalue))        (setq calc-graph-numsteps (1- (length calc-graph-xvalue))
630              yvector nil)              calc-graph-yvector nil)
631      (if (and (eq (car-safe xvalue) 'intv)      (if (and (eq (car-safe calc-graph-xvalue) 'intv)
632               (math-constp xvalue))               (math-constp calc-graph-xvalue))
633          (setq numsteps resolution          (setq calc-graph-numsteps calc-graph-resolution
634                yp nil                calc-graph-yp nil
635                xlow (nth 2 xvalue)                calc-graph-xlow (nth 2 calc-graph-xvalue)
636                xhigh (nth 3 xvalue)                calc-graph-xhigh (nth 3 calc-graph-xvalue)
637                xstep (math-div (math-sub xhigh xlow)                calc-graph-xstep (math-div (math-sub calc-graph-xhigh calc-graph-xlow)
638                                (1- numsteps))                                (1- calc-graph-numsteps))
639                xvalue (nth 2 xvalue))                calc-graph-xvalue (nth 2 calc-graph-xvalue))
640        (error "%s is not a suitable basis for %s"        (error "%s is not a suitable basis for %s"
641               xname yname)))               calc-graph-xname calc-graph-yname)))
642    (setq math-working-step-2 numsteps)    (setq math-working-step-2 calc-graph-numsteps)
643    (while (>= (setq numsteps (1- numsteps)) 0)    (while (>= (setq calc-graph-numsteps (1- calc-graph-numsteps)) 0)
644      (setq math-working-step (1+ math-working-step))      (setq math-working-step (1+ math-working-step))
645      (if xvec      (if calc-graph-xvec
646          (progn          (progn
647            (setq xp (cdr xp)            (setq calc-graph-xp (cdr calc-graph-xp)
648                  xval (car xp))                  calc-graph-xval (car calc-graph-xp))
649            (and (not (eq ycacheptr ycache))            (and (not (eq calc-graph-ycacheptr calc-graph-ycache))
650                 (consp (car ycacheptr))                 (consp (car calc-graph-ycacheptr))
651                 (not (Math-lessp (car (car ycacheptr)) xval))                 (not (Math-lessp (car (car calc-graph-ycacheptr)) calc-graph-xval))
652                 (setq ycacheptr ycache)))                 (setq calc-graph-ycacheptr calc-graph-ycache)))
653        (if (= numsteps 0)        (if (= calc-graph-numsteps 0)
654            (setq xval xhigh)   ; avoid cumulative roundoff            (setq calc-graph-xval calc-graph-xhigh)   ; avoid cumulative roundoff
655          (setq xval xvalue          (setq calc-graph-xval calc-graph-xvalue
656                xvalue (math-add xvalue xstep))))                calc-graph-xvalue (math-add calc-graph-xvalue calc-graph-xstep))))
657      (while (and (cdr ycacheptr)      (while (and (cdr calc-graph-ycacheptr)
658                  (Math-lessp (car (nth 1 ycacheptr)) xval))                  (Math-lessp (car (nth 1 calc-graph-ycacheptr)) calc-graph-xval))
659        (setq ycacheptr (cdr ycacheptr)))        (setq calc-graph-ycacheptr (cdr calc-graph-ycacheptr)))
660      (or (and (cdr ycacheptr)      (or (and (cdr calc-graph-ycacheptr)
661               (Math-equal (car (nth 1 ycacheptr)) xval))               (Math-equal (car (nth 1 calc-graph-ycacheptr)) calc-graph-xval))
662          (progn          (progn
663            (setq keep-file nil            (setq calc-graph-keep-file nil
664                  var-DUMMY xval)                  var-DUMMY calc-graph-xval)
665            (setcdr ycacheptr (cons (cons xval (math-evaluate-expr yvalue))            (setcdr calc-graph-ycacheptr (cons (cons calc-graph-xval (math-evaluate-expr calc-graph-yvalue))
666                                    (cdr ycacheptr)))))                                    (cdr calc-graph-ycacheptr)))))
667      (setq ycacheptr (cdr ycacheptr))      (setq calc-graph-ycacheptr (cdr calc-graph-ycacheptr))
668      (if xvec      (if calc-graph-xvec
669          (setq yvector (cons (cdr (car ycacheptr)) yvector))          (setq calc-graph-yvector (cons (cdr (car calc-graph-ycacheptr)) calc-graph-yvector))
670        (or yp (setq yp ycacheptr))))        (or calc-graph-yp (setq calc-graph-yp calc-graph-ycacheptr))))
671    (if xvec    (if calc-graph-xvec
672        (setq xp xvalue        (setq calc-graph-xp calc-graph-xvalue
673              yvec t              calc-graph-yvec t
674              yp (cons 'vec (nreverse yvector))              calc-graph-yp (cons 'vec (nreverse calc-graph-yvector))
675              numsteps (1- (length xp)))              calc-graph-numsteps (1- (length calc-graph-xp)))
676      (setq numsteps 1000000)))      (setq calc-graph-numsteps 1000000)))
677    
678  (defun calc-graph-compute-3d ()  (defun calc-graph-compute-3d ()
679    (if (setq yvec (eq (car-safe yvalue) 'vec))    (if (setq calc-graph-yvec (eq (car-safe calc-graph-yvalue) 'vec))
680        (if (math-matrixp yvalue)        (if (math-matrixp calc-graph-yvalue)
681            (progn            (progn
682              (setq numsteps (1- (length yvalue))              (setq calc-graph-numsteps (1- (length calc-graph-yvalue))
683                    numsteps3 (1- (length (nth 1 yvalue))))                    calc-graph-numsteps3 (1- (length (nth 1 calc-graph-yvalue))))
684              (if (eq (car-safe xvalue) 'vec)              (if (eq (car-safe calc-graph-xvalue) 'vec)
685                  (or (= (1- (length xvalue)) numsteps)                  (or (= (1- (length calc-graph-xvalue)) calc-graph-numsteps)
686                      (error "%s has wrong length" xname))                      (error "%s has wrong length" calc-graph-xname))
687                (if (and (eq (car-safe xvalue) 'intv)                (if (and (eq (car-safe calc-graph-xvalue) 'intv)
688                         (math-constp xvalue))                         (math-constp calc-graph-xvalue))
689                    (setq xvalue (calcFunc-index numsteps                    (setq calc-graph-xvalue (calcFunc-index calc-graph-numsteps
690                                                 (nth 2 xvalue)                                                 (nth 2 calc-graph-xvalue)
691                                                 (math-div                                                 (math-div
692                                                  (math-sub (nth 3 xvalue)                                                  (math-sub (nth 3 calc-graph-xvalue)
693                                                            (nth 2 xvalue))                                                            (nth 2 calc-graph-xvalue))
694                                                  (1- numsteps))))                                                  (1- calc-graph-numsteps))))
695                  (if (math-realp xvalue)                  (if (math-realp calc-graph-xvalue)
696                      (setq xvalue (calcFunc-index numsteps xvalue 1))                      (setq calc-graph-xvalue (calcFunc-index calc-graph-numsteps calc-graph-xvalue 1))
697                    (error "%s is not a suitable basis for %s" xname yname))))                    (error "%s is not a suitable basis for %s" calc-graph-xname calc-graph-yname))))
698              (if (eq (car-safe y3value) 'vec)              (if (eq (car-safe calc-graph-y3value) 'vec)
699                  (or (= (1- (length y3value)) numsteps3)                  (or (= (1- (length calc-graph-y3value)) calc-graph-numsteps3)
700                      (error "%s has wrong length" y3name))                      (error "%s has wrong length" calc-graph-y3name))
701                (if (and (eq (car-safe y3value) 'intv)                (if (and (eq (car-safe calc-graph-y3value) 'intv)
702                         (math-constp y3value))                         (math-constp calc-graph-y3value))
703                    (setq y3value (calcFunc-index numsteps3                    (setq calc-graph-y3value (calcFunc-index calc-graph-numsteps3
704                                                  (nth 2 y3value)                                                  (nth 2 calc-graph-y3value)
705                                                  (math-div                                                  (math-div
706                                                   (math-sub (nth 3 y3value)                                                   (math-sub (nth 3 calc-graph-y3value)
707                                                             (nth 2 y3value))                                                             (nth 2 calc-graph-y3value))
708                                                   (1- numsteps3))))                                                   (1- calc-graph-numsteps3))))
709                  (if (math-realp y3value)                  (if (math-realp calc-graph-y3value)
710                      (setq y3value (calcFunc-index numsteps3 y3value 1))                      (setq calc-graph-y3value (calcFunc-index calc-graph-numsteps3 calc-graph-y3value 1))
711                    (error "%s is not a suitable basis for %s" y3name yname))))                    (error "%s is not a suitable basis for %s" calc-graph-y3name calc-graph-yname))))
712              (setq xp nil              (setq calc-graph-xp nil
713                    yp nil                    calc-graph-yp nil
714                    zp nil                    calc-graph-zp nil
715                    xvec t)                    calc-graph-xvec t)
716              (while (setq xvalue (cdr xvalue) yvalue (cdr yvalue))              (while (setq calc-graph-xvalue (cdr calc-graph-xvalue) calc-graph-yvalue (cdr calc-graph-yvalue))
717                (setq xp (nconc xp (make-list (1+ numsteps3) (car xvalue)))                (setq calc-graph-xp (nconc calc-graph-xp (make-list (1+ calc-graph-numsteps3) (car calc-graph-xvalue)))
718                      yp (nconc yp (cons 0 (copy-sequence (cdr y3value))))                      calc-graph-yp (nconc calc-graph-yp (cons 0 (copy-sequence (cdr calc-graph-y3value))))
719                      zp (nconc zp (cons '(skip)                      calc-graph-zp (nconc calc-graph-zp (cons '(skip)
720                                         (copy-sequence (cdr (car yvalue)))))))                                         (copy-sequence (cdr (car calc-graph-yvalue)))))))
721              (setq numsteps (1- (* numsteps (1+ numsteps3)))))              (setq calc-graph-numsteps (1- (* calc-graph-numsteps
722          (if (= (setq numsteps (1- (length yvalue))) 0)                                               (1+ calc-graph-numsteps3)))))
723            (if (= (setq calc-graph-numsteps (1- (length calc-graph-yvalue))) 0)
724              (error "Can't plot an empty vector"))              (error "Can't plot an empty vector"))
725          (or (and (eq (car-safe xvalue) 'vec)          (or (and (eq (car-safe calc-graph-xvalue) 'vec)
726                   (= (1- (length xvalue)) numsteps))                   (= (1- (length calc-graph-xvalue)) calc-graph-numsteps))
727              (error "%s is not a suitable basis for %s" xname yname))              (error "%s is not a suitable basis for %s" calc-graph-xname calc-graph-yname))
728          (or (and (eq (car-safe y3value) 'vec)          (or (and (eq (car-safe calc-graph-y3value) 'vec)
729                   (= (1- (length y3value)) numsteps))                   (= (1- (length calc-graph-y3value)) calc-graph-numsteps))
730              (error "%s is not a suitable basis for %s" y3name yname))              (error "%s is not a suitable basis for %s" calc-graph-y3name calc-graph-yname))
731          (setq xp xvalue          (setq calc-graph-xp calc-graph-xvalue
732                yp y3value                calc-graph-yp calc-graph-y3value
733                zp yvalue                calc-graph-zp calc-graph-yvalue
734                xvec t))                calc-graph-xvec t))
735      (or (math-realp yvalue)      (or (math-realp calc-graph-yvalue)
736          (let ((arglist nil))          (let ((arglist nil))
737            (setq yvalue (math-evaluate-expr yvalue))            (setq calc-graph-yvalue (math-evaluate-expr calc-graph-yvalue))
738            (calc-default-formula-arglist yvalue)            (calc-default-formula-arglist calc-graph-yvalue)
739            (setq arglist (sort arglist 'string-lessp))            (setq arglist (sort arglist 'string-lessp))
740            (or (cdr arglist)            (or (cdr arglist)
741                (error "%s does not contain enough unassigned variables" yname))                (error "%s does not contain enough unassigned variables" calc-graph-yname))
742            (and (cdr (cdr arglist))            (and (cdr (cdr arglist))
743                 (error "%s contains too many variables: %s" yname arglist))                 (error "%s contains too many variables: %s" calc-graph-yname arglist))
744            (setq yvalue (math-multi-subst yvalue            (setq calc-graph-yvalue (math-multi-subst calc-graph-yvalue
745                                           (mapcar 'math-build-var-name                                           (mapcar 'math-build-var-name
746                                                   arglist)                                                   arglist)
747                                           '((var DUMMY var-DUMMY)                                           '((var DUMMY var-DUMMY)
748                                             (var DUMMY2 var-DUMMY2))))))                                             (var DUMMY2 var-DUMMY2))))))
749      (if (setq xvec (eq (car-safe xvalue) 'vec))      (if (setq calc-graph-xvec (eq (car-safe calc-graph-xvalue) 'vec))
750          (setq numsteps (1- (length xvalue)))          (setq calc-graph-numsteps (1- (length calc-graph-xvalue)))
751        (if (and (eq (car-safe xvalue) 'intv)        (if (and (eq (car-safe calc-graph-xvalue) 'intv)
752                 (math-constp xvalue))                 (math-constp calc-graph-xvalue))
753            (setq numsteps resolution            (setq calc-graph-numsteps calc-graph-resolution
754                  xvalue (calcFunc-index numsteps                  calc-graph-xvalue (calcFunc-index calc-graph-numsteps
755                                         (nth 2 xvalue)                                         (nth 2 calc-graph-xvalue)
756                                         (math-div (math-sub (nth 3 xvalue)                                         (math-div (math-sub (nth 3 calc-graph-xvalue)
757                                                             (nth 2 xvalue))                                                             (nth 2 calc-graph-xvalue))
758                                                   (1- numsteps))))                                                   (1- calc-graph-numsteps))))
759          (error "%s is not a suitable basis for %s"          (error "%s is not a suitable basis for %s"
760                 xname yname)))                 calc-graph-xname calc-graph-yname)))
761      (if (setq y3vec (eq (car-safe y3value) 'vec))      (if (eq (car-safe calc-graph-y3value) 'vec)
762          (setq numsteps3 (1- (length y3value)))          (setq calc-graph-numsteps3 (1- (length calc-graph-y3value)))
763        (if (and (eq (car-safe y3value) 'intv)        (if (and (eq (car-safe calc-graph-y3value) 'intv)
764                 (math-constp y3value))                 (math-constp calc-graph-y3value))
765            (setq numsteps3 resolution            (setq calc-graph-numsteps3 calc-graph-resolution
766                  y3value (calcFunc-index numsteps3                  calc-graph-y3value (calcFunc-index calc-graph-numsteps3
767                                          (nth 2 y3value)                                          (nth 2 calc-graph-y3value)
768                                          (math-div (math-sub (nth 3 y3value)                                          (math-div (math-sub (nth 3 calc-graph-y3value)
769                                                              (nth 2 y3value))                                                              (nth 2 calc-graph-y3value))
770                                                    (1- numsteps3))))                                                    (1- calc-graph-numsteps3))))
771          (error "%s is not a suitable basis for %s"          (error "%s is not a suitable basis for %s"
772                 y3name yname)))                 calc-graph-y3name calc-graph-yname)))
773      (setq xp nil      (setq calc-graph-xp nil
774            yp nil            calc-graph-yp nil
775            zp nil            calc-graph-zp nil
776            xvec t)            calc-graph-xvec t)
777      (setq math-working-step 0)      (setq math-working-step 0)
778      (while (setq xvalue (cdr xvalue))      (while (setq calc-graph-xvalue (cdr calc-graph-xvalue))
779        (setq xp (nconc xp (make-list (1+ numsteps3) (car xvalue)))        (setq calc-graph-xp (nconc calc-graph-xp (make-list (1+ calc-graph-numsteps3) (car calc-graph-xvalue)))
780              yp (nconc yp (cons 0 (copy-sequence (cdr y3value))))              calc-graph-yp (nconc calc-graph-yp (cons 0 (copy-sequence (cdr calc-graph-y3value))))
781              zp (cons '(skip) zp)              calc-graph-zp (cons '(skip) calc-graph-zp)
782              y3step y3value              calc-graph-y3step calc-graph-y3value
783              var-DUMMY (car xvalue)              var-DUMMY (car calc-graph-xvalue)
784              math-working-step-2 0              math-working-step-2 0
785              math-working-step (1+ math-working-step))              math-working-step (1+ math-working-step))
786        (while (setq y3step (cdr y3step))        (while (setq calc-graph-y3step (cdr calc-graph-y3step))
787          (setq math-working-step-2 (1+ math-working-step-2)          (setq math-working-step-2 (1+ math-working-step-2)
788                var-DUMMY2 (car y3step)                var-DUMMY2 (car calc-graph-y3step)
789                zp (cons (math-evaluate-expr yvalue) zp))))                calc-graph-zp (cons (math-evaluate-expr calc-graph-yvalue) calc-graph-zp))))
790      (setq zp (nreverse zp)      (setq calc-graph-zp (nreverse calc-graph-zp)
791            numsteps (1- (* numsteps (1+ numsteps3))))))            calc-graph-numsteps (1- (* calc-graph-numsteps (1+ calc-graph-numsteps3))))))
792    
793  (defun calc-graph-format-data ()  (defun calc-graph-format-data ()
794    (while (<= (setq stepcount (1+ stepcount)) numsteps)    (while (<= (setq calc-graph-stepcount (1+ calc-graph-stepcount)) calc-graph-numsteps)
795      (if xvec      (if calc-graph-xvec
796          (setq xp (cdr xp)          (setq calc-graph-xp (cdr calc-graph-xp)
797                xval (car xp)                calc-graph-xval (car calc-graph-xp)
798                yp (cdr yp)                calc-graph-yp (cdr calc-graph-yp)
799                yval (car yp)                calc-graph-yval (car calc-graph-yp)
800                zp (cdr zp)                calc-graph-zp (cdr calc-graph-zp)
801                zval (car zp))                calc-graph-zval (car calc-graph-zp))
802        (if yvec        (if calc-graph-yvec
803            (setq xval xvalue            (setq calc-graph-xval calc-graph-xvalue
804                  xvalue (math-add xvalue xstep)                  calc-graph-xvalue (math-add calc-graph-xvalue calc-graph-xstep)
805                  yp (cdr yp)                  calc-graph-yp (cdr calc-graph-yp)
806                  yval (car yp))                  calc-graph-yval (car calc-graph-yp))
807          (setq xval (car (car yp))          (setq calc-graph-xval (car (car calc-graph-yp))
808                yval (cdr (car yp))                calc-graph-yval (cdr (car calc-graph-yp))
809                yp (cdr yp))                calc-graph-yp (cdr calc-graph-yp))
810          (if (or (not yp)          (if (or (not calc-graph-yp)
811                  (and xhigh (equal xval xhigh)))                  (and calc-graph-xhigh (equal calc-graph-xval calc-graph-xhigh)))
812              (setq numsteps 0))))              (setq calc-graph-numsteps 0))))
813      (if is-splot      (if calc-graph-is-splot
814          (if (and (eq (car-safe zval) 'calcFunc-xyz)          (if (and (eq (car-safe calc-graph-zval) 'calcFunc-xyz)
815                   (= (length zval) 4))                   (= (length calc-graph-zval) 4))
816              (setq xval (nth 1 zval)              (setq calc-graph-xval (nth 1 calc-graph-zval)
817                    yval (nth 2 zval)                    calc-graph-yval (nth 2 calc-graph-zval)
818                    zval (nth 3 zval)))                    calc-graph-zval (nth 3 calc-graph-zval)))
819        (if (and (eq (car-safe yval) 'calcFunc-xyz)        (if (and (eq (car-safe calc-graph-yval) 'calcFunc-xyz)
820                 (= (length yval) 4))                 (= (length calc-graph-yval) 4))
821            (progn            (progn
822              (or surprise-splot              (or calc-graph-surprise-splot
823                  (save-excursion                  (save-excursion
824                    (set-buffer (get-buffer-create "*Gnuplot Temp*"))                    (set-buffer (get-buffer-create "*Gnuplot Temp*"))
825                    (save-excursion                    (save-excursion
826                      (goto-char (point-max))                      (goto-char (point-max))
827                      (re-search-backward "^plot[ \t]")                      (re-search-backward "^plot[ \t]")
828                      (insert "set parametric\ns")                      (insert "set parametric\ns")
829                      (setq surprise-splot t))))                      (setq calc-graph-surprise-splot t))))
830              (setq xval (nth 1 yval)              (setq calc-graph-xval (nth 1 calc-graph-yval)
831                    zval (nth 3 yval)                    calc-graph-zval (nth 3 calc-graph-yval)
832                    yval (nth 2 yval)))                    calc-graph-yval (nth 2 calc-graph-yval)))
833          (if (and (eq (car-safe yval) 'calcFunc-xy)          (if (and (eq (car-safe calc-graph-yval) 'calcFunc-xy)
834                   (= (length yval) 3))                   (= (length calc-graph-yval) 3))
835              (setq xval (nth 1 yval)              (setq calc-graph-xval (nth 1 calc-graph-yval)
836                    yval (nth 2 yval)))))                    calc-graph-yval (nth 2 calc-graph-yval)))))
837      (if (and (Math-realp xval)      (if (and (Math-realp calc-graph-xval)
838               (Math-realp yval)               (Math-realp calc-graph-yval)
839               (or (not zval) (Math-realp zval)))               (or (not calc-graph-zval) (Math-realp calc-graph-zval)))
840          (progn          (progn
841            (setq blank nil            (setq calc-graph-blank nil
842                  non-blank t)                  calc-graph-non-blank t)
843            (if (Math-integerp xval)            (if (Math-integerp calc-graph-xval)
844                (insert (math-format-number xval))                (insert (math-format-number calc-graph-xval))
845              (if (eq (car xval) 'frac)              (if (eq (car calc-graph-xval) 'frac)
846                  (setq xval (math-float xval)))                  (setq calc-graph-xval (math-float calc-graph-xval)))
847              (insert (math-format-number (nth 1 xval))              (insert (math-format-number (nth 1 calc-graph-xval))
848                      "e" (int-to-string (nth 2 xval))))                      "e" (int-to-string (nth 2 calc-graph-xval))))
849            (insert " ")            (insert " ")
850            (if (Math-integerp yval)            (if (Math-integerp calc-graph-yval)
851                (insert (math-format-number yval))                (insert (math-format-number calc-graph-yval))
852              (if (eq (car yval) 'frac)              (if (eq (car calc-graph-yval) 'frac)
853                  (setq yval (math-float yval)))                  (setq calc-graph-yval (math-float calc-graph-yval)))
854              (insert (math-format-number (nth 1 yval))              (insert (math-format-number (nth 1 calc-graph-yval))
855                      "e" (int-to-string (nth 2 yval))))                      "e" (int-to-string (nth 2 calc-graph-yval))))
856            (if zval            (if calc-graph-zval
857                (progn                (progn
858                  (insert " ")                  (insert " ")
859                  (if (Math-integerp zval)                  (if (Math-integerp calc-graph-zval)
860                      (insert (math-format-number zval))                      (insert (math-format-number calc-graph-zval))
861                    (if (eq (car zval) 'frac)                    (if (eq (car calc-graph-zval) 'frac)
862                        (setq zval (math-float zval)))                        (setq calc-graph-zval (math-float calc-graph-zval)))
863                    (insert (math-format-number (nth 1 zval))                    (insert (math-format-number (nth 1 calc-graph-zval))
864                            "e" (int-to-string (nth 2 zval))))))                            "e" (int-to-string (nth 2 calc-graph-zval))))))
865            (insert "\n"))            (insert "\n"))
866        (and (not (equal zval '(skip)))        (and (not (equal calc-graph-zval '(skip)))
            (boundp 'var-PlotRejects)  
867             (eq (car-safe var-PlotRejects) 'vec)             (eq (car-safe var-PlotRejects) 'vec)
868             (nconc var-PlotRejects             (nconc var-PlotRejects
869                    (list (list 'vec                    (list (list 'vec
870                                curve-num                                calc-graph-curve-num
871                                stepcount                                calc-graph-stepcount
872                                xval yval)))                                calc-graph-xval calc-graph-yval)))
873             (calc-refresh-evaltos 'var-PlotRejects))             (calc-refresh-evaltos 'var-PlotRejects))
874        (or blank        (or calc-graph-blank
875            (progn            (progn
876              (insert "\n")              (insert "\n")
877              (setq blank t))))))              (setq calc-graph-blank t))))))
878    
879  (defun calc-temp-file-name (num)  (defun calc-temp-file-name (num)
880    (while (<= (length calc-graph-file-cache) (1+ num))    (while (<= (length calc-graph-file-cache) (1+ num))
# Line 859  Line 898 
898      (setq calc-graph-file-cache (cdr calc-graph-file-cache))))      (setq calc-graph-file-cache (cdr calc-graph-file-cache))))
899    
900  (defun calc-graph-kill-hook ()  (defun calc-graph-kill-hook ()
901    (calc-graph-delete-temps)    (calc-graph-delete-temps))
   (if calc-graph-prev-kill-hook  
       (funcall calc-graph-prev-kill-hook)))  
902    
903  (defun calc-graph-show-tty (output)  (defun calc-graph-show-tty (output)
904    "Default calc-gnuplot-plot-command for \"tty\" output mode.    "Default calc-gnuplot-plot-command for \"tty\" output mode.
# Line 870  This is useful for tek40xx and other gra Line 907  This is useful for tek40xx and other gra
907                         nil calc-gnuplot-buffer nil                         nil calc-gnuplot-buffer nil
908                         "-c" (format "cat %s >/dev/tty; rm %s" output output)))                         "-c" (format "cat %s >/dev/tty; rm %s" output output)))
909    
910    (defvar calc-dumb-map nil
911      "The keymap for the \"dumb\" terminal plot.")
912    
913  (defun calc-graph-show-dumb (&optional output)  (defun calc-graph-show-dumb (&optional output)
914    "Default calc-gnuplot-plot-command for Pinard's \"dumb\" terminal type.    "Default calc-gnuplot-plot-command for Pinard's \"dumb\" terminal type.
915  This \"dumb\" driver will be present in Gnuplot 3.0."  This \"dumb\" driver will be present in Gnuplot 3.0."
# Line 882  This \"dumb\" driver will be present in Line 922  This \"dumb\" driver will be present in
922          (sleep-for 1))          (sleep-for 1))
923      (goto-char (point-max))      (goto-char (point-max))
924      (re-search-backward "\f\\|^[ \t]+\\^$\\|G N U P L O T")      (re-search-backward "\f\\|^[ \t]+\\^$\\|G N U P L O T")
     (setq found-pt (point))  
925      (if (looking-at "\f")      (if (looking-at "\f")
926          (progn          (progn
927            (forward-char 1)            (forward-char 1)
# Line 898  This \"dumb\" driver will be present in Line 937  This \"dumb\" driver will be present in
937        (end-of-line)        (end-of-line)
938        (backward-char 1)        (backward-char 1)
939        (recenter '(4)))        (recenter '(4)))
940      (or (boundp 'calc-dumb-map)      (or calc-dumb-map
941          (progn          (progn
942            (setq calc-dumb-map (make-sparse-keymap))            (setq calc-dumb-map (make-sparse-keymap))
943            (define-key calc-dumb-map "\n" 'scroll-up)            (define-key calc-dumb-map "\n" 'scroll-up)
# Line 1097  This \"dumb\" driver will be present in Line 1136  This \"dumb\" driver will be present in
1136      (or (calc-graph-find-plot nil nil)      (or (calc-graph-find-plot nil nil)
1137          (error "No data points have been set!"))          (error "No data points have been set!"))
1138      (let ((base (point))      (let ((base (point))
1139            start)            start
1140              end)
1141        (re-search-forward "[,\n]\\|[ \t]+with")        (re-search-forward "[,\n]\\|[ \t]+with")
1142        (setq end (match-beginning 0))        (setq end (match-beginning 0))
1143        (goto-char base)        (goto-char base)

Legend:
Removed from v.1.5.2.4  
changed lines
  Added in v.1.5.2.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26