64 |
(let ((calc-graph-no-auto-view t)) |
(let ((calc-graph-no-auto-view t)) |
65 |
(calc-graph-delete t) |
(calc-graph-delete t) |
66 |
(calc-graph-add many) |
(calc-graph-add many) |
67 |
(calc-graph-plot nil)) |
(calc-graph-plot nil))) |
|
) |
|
68 |
|
|
69 |
(defun calc-graph-fast-3d (many) |
(defun calc-graph-fast-3d (many) |
70 |
(interactive "P") |
(interactive "P") |
71 |
(let ((calc-graph-no-auto-view t)) |
(let ((calc-graph-no-auto-view t)) |
72 |
(calc-graph-delete t) |
(calc-graph-delete t) |
73 |
(calc-graph-add-3d many) |
(calc-graph-add-3d many) |
74 |
(calc-graph-plot nil)) |
(calc-graph-plot nil))) |
|
) |
|
75 |
|
|
76 |
(defun calc-graph-delete (all) |
(defun calc-graph-delete (all) |
77 |
(interactive "P") |
(interactive "P") |
86 |
(setq calc-graph-var-cache nil) |
(setq calc-graph-var-cache nil) |
87 |
(delete-region (point) (point-max))) |
(delete-region (point) (point-max))) |
88 |
(delete-region (point) (1- (point-max))))))) |
(delete-region (point) (1- (point-max))))))) |
89 |
(calc-graph-view-commands)) |
(calc-graph-view-commands))) |
|
) |
|
90 |
|
|
91 |
(defun calc-graph-find-plot (&optional before all) |
(defun calc-graph-find-plot (&optional before all) |
92 |
(goto-char (point-min)) |
(goto-char (point-min)) |
102 |
(beginning-of-line))) |
(beginning-of-line))) |
103 |
(or before |
(or before |
104 |
(re-search-forward ",[ \t]+"))) |
(re-search-forward ",[ \t]+"))) |
105 |
t)) |
t))) |
|
) |
|
106 |
|
|
107 |
(defun calc-graph-add (many) |
(defun calc-graph-add (many) |
108 |
(interactive "P") |
(interactive "P") |
135 |
(calc-graph-add-curve (calc-graph-lookup (nth 1 pair)) |
(calc-graph-add-curve (calc-graph-lookup (nth 1 pair)) |
136 |
(calc-graph-lookup (nth 2 pair))) |
(calc-graph-lookup (nth 2 pair))) |
137 |
(setq many (1- many)))))) |
(setq many (1- many)))))) |
138 |
(calc-graph-view-commands)) |
(calc-graph-view-commands))) |
|
) |
|
139 |
|
|
140 |
(defun calc-graph-add-3d (many) |
(defun calc-graph-add-3d (many) |
141 |
(interactive "P") |
(interactive "P") |
173 |
(calc-graph-lookup (nth 2 curve)) |
(calc-graph-lookup (nth 2 curve)) |
174 |
(calc-graph-lookup (nth 3 curve))) |
(calc-graph-lookup (nth 3 curve))) |
175 |
(setq many (1- many)))))) |
(setq many (1- many)))))) |
176 |
(calc-graph-view-commands)) |
(calc-graph-view-commands))) |
|
) |
|
177 |
|
|
178 |
(defun calc-graph-add-curve (xdata ydata &optional zdata) |
(defun calc-graph-add-curve (xdata ydata &optional zdata) |
179 |
(let ((num (calc-graph-count-curves)) |
(let ((num (calc-graph-count-curves)) |
208 |
0) |
0) |
209 |
(or (and (Math-num-integerp pstyle) (math-trunc pstyle)) |
(or (and (Math-num-integerp pstyle) (math-trunc pstyle)) |
210 |
(if (eq (car-safe (calc-var-value (nth 2 ydata))) 'vec) |
(if (eq (car-safe (calc-var-value (nth 2 ydata))) 'vec) |
211 |
0 -1))))) |
0 -1)))))) |
|
) |
|
212 |
|
|
213 |
(defun calc-graph-lookup (thing) |
(defun calc-graph-lookup (thing) |
214 |
(if (and (eq (car-safe thing) 'var) |
(if (and (eq (car-safe thing) 'var) |
225 |
found (cons thing var) |
found (cons thing var) |
226 |
calc-graph-var-cache (cons found calc-graph-var-cache)) |
calc-graph-var-cache (cons found calc-graph-var-cache)) |
227 |
(set (nth 2 var) thing))) |
(set (nth 2 var) thing))) |
228 |
(cdr found))) |
(cdr found)))) |
|
) |
|
229 |
|
|
230 |
(defun calc-graph-juggle (arg) |
(defun calc-graph-juggle (arg) |
231 |
(interactive "p") |
(interactive "p") |
238 |
(while (< arg 0) |
(while (< arg 0) |
239 |
(setq arg (+ arg num)))))) |
(setq arg (+ arg num)))))) |
240 |
(while (>= (setq arg (1- arg)) 0) |
(while (>= (setq arg (1- arg)) 0) |
241 |
(calc-graph-do-juggle))) |
(calc-graph-do-juggle)))) |
|
) |
|
242 |
|
|
243 |
(defun calc-graph-count-curves () |
(defun calc-graph-count-curves () |
244 |
(save-excursion |
(save-excursion |
249 |
(while (search-forward "," nil t) |
(while (search-forward "," nil t) |
250 |
(setq num (1+ num))) |
(setq num (1+ num))) |
251 |
num) |
num) |
252 |
0)) |
0))) |
|
) |
|
253 |
|
|
254 |
(defun calc-graph-do-juggle () |
(defun calc-graph-do-juggle () |
255 |
(let (base) |
(let (base) |
261 |
(let ((str (buffer-substring (+ (point) 2) (1- (point-max))))) |
(let ((str (buffer-substring (+ (point) 2) (1- (point-max))))) |
262 |
(delete-region (point) (1- (point-max))) |
(delete-region (point) (1- (point-max))) |
263 |
(goto-char (+ base 5)) |
(goto-char (+ base 5)) |
264 |
(insert str ", ")))))) |
(insert str ", "))))))) |
|
) |
|
265 |
|
|
266 |
(defun calc-graph-print (flag) |
(defun calc-graph-print (flag) |
267 |
(interactive "P") |
(interactive "P") |
268 |
(calc-graph-plot flag t) |
(calc-graph-plot flag t)) |
|
) |
|
269 |
|
|
270 |
(defun calc-graph-plot (flag &optional printing) |
(defun calc-graph-plot (flag &optional printing) |
271 |
(interactive "P") |
(interactive "P") |
510 |
calc-gnuplot-print-output))) |
calc-gnuplot-print-output))) |
511 |
(if (symbolp command) |
(if (symbolp command) |
512 |
(funcall command output) |
(funcall command output) |
513 |
(eval command))))))))) |
(eval command)))))))))) |
|
) |
|
514 |
|
|
515 |
(defun calc-graph-compute-2d () |
(defun calc-graph-compute-2d () |
516 |
(if (setq yvec (eq (car-safe yvalue) 'vec)) |
(if (setq yvec (eq (car-safe yvalue) 'vec)) |
547 |
(if (and (not (setq xvec (eq (car-safe xvalue) 'vec))) |
(if (and (not (setq xvec (eq (car-safe xvalue) 'vec))) |
548 |
refine (cdr (cdr ycache))) |
refine (cdr (cdr ycache))) |
549 |
(calc-graph-refine-2d) |
(calc-graph-refine-2d) |
550 |
(calc-graph-recompute-2d))) |
(calc-graph-recompute-2d)))) |
|
) |
|
551 |
|
|
552 |
(defun calc-graph-refine-2d () |
(defun calc-graph-refine-2d () |
553 |
(setq keep-file nil |
(setq keep-file nil |
578 |
(cdr ycacheptr))) |
(cdr ycacheptr))) |
579 |
(setq ycacheptr (cdr (cdr ycacheptr)))) |
(setq ycacheptr (cdr (cdr ycacheptr)))) |
580 |
(setq yp ycache |
(setq yp ycache |
581 |
numsteps 1000000) |
numsteps 1000000)) |
|
) |
|
582 |
|
|
583 |
(defun calc-graph-recompute-2d () |
(defun calc-graph-recompute-2d () |
584 |
(setq ycacheptr ycache) |
(setq ycacheptr ycache) |
630 |
yvec t |
yvec t |
631 |
yp (cons 'vec (nreverse yvector)) |
yp (cons 'vec (nreverse yvector)) |
632 |
numsteps (1- (length xp))) |
numsteps (1- (length xp))) |
633 |
(setq numsteps 1000000)) |
(setq numsteps 1000000))) |
|
) |
|
634 |
|
|
635 |
(defun calc-graph-compute-3d () |
(defun calc-graph-compute-3d () |
636 |
(if (setq yvec (eq (car-safe yvalue) 'vec)) |
(if (setq yvec (eq (car-safe yvalue) 'vec)) |
744 |
var-DUMMY2 (car y3step) |
var-DUMMY2 (car y3step) |
745 |
zp (cons (math-evaluate-expr yvalue) zp)))) |
zp (cons (math-evaluate-expr yvalue) zp)))) |
746 |
(setq zp (nreverse zp) |
(setq zp (nreverse zp) |
747 |
numsteps (1- (* numsteps (1+ numsteps3))))) |
numsteps (1- (* numsteps (1+ numsteps3)))))) |
|
) |
|
748 |
|
|
749 |
(defun calc-graph-format-data () |
(defun calc-graph-format-data () |
750 |
(while (<= (setq stepcount (1+ stepcount)) numsteps) |
(while (<= (setq stepcount (1+ stepcount)) numsteps) |
831 |
(or blank |
(or blank |
832 |
(progn |
(progn |
833 |
(insert "\n") |
(insert "\n") |
834 |
(setq blank t))))) |
(setq blank t)))))) |
|
) |
|
835 |
|
|
836 |
(defun calc-temp-file-name (num) |
(defun calc-temp-file-name (num) |
837 |
(while (<= (length calc-graph-file-cache) (1+ num)) |
(while (<= (length calc-graph-file-cache) (1+ num)) |
843 |
(if (<= num 0) |
(if (<= num 0) |
844 |
(char-to-string (- ?A num)) |
(char-to-string (- ?A num)) |
845 |
(int-to-string num)))) |
(int-to-string num)))) |
846 |
nil)))) |
nil))))) |
|
) |
|
847 |
|
|
848 |
(defun calc-graph-delete-temps () |
(defun calc-graph-delete-temps () |
849 |
(while calc-graph-file-cache |
(while calc-graph-file-cache |
852 |
(condition-case err |
(condition-case err |
853 |
(delete-file (car (car calc-graph-file-cache))) |
(delete-file (car (car calc-graph-file-cache))) |
854 |
(error nil))) |
(error nil))) |
855 |
(setq calc-graph-file-cache (cdr calc-graph-file-cache))) |
(setq calc-graph-file-cache (cdr calc-graph-file-cache)))) |
|
) |
|
856 |
|
|
857 |
(defun calc-graph-kill-hook () |
(defun calc-graph-kill-hook () |
858 |
(calc-graph-delete-temps) |
(calc-graph-delete-temps) |
859 |
(if calc-graph-prev-kill-hook |
(if calc-graph-prev-kill-hook |
860 |
(funcall calc-graph-prev-kill-hook)) |
(funcall calc-graph-prev-kill-hook))) |
|
) |
|
861 |
|
|
862 |
(defun calc-graph-show-tty (output) |
(defun calc-graph-show-tty (output) |
863 |
"Default calc-gnuplot-plot-command for \"tty\" output mode. |
"Default calc-gnuplot-plot-command for \"tty\" output mode. |
864 |
This is useful for tek40xx and other graphics-terminal types." |
This is useful for tek40xx and other graphics-terminal types." |
865 |
(call-process-region 1 1 shell-file-name |
(call-process-region 1 1 shell-file-name |
866 |
nil calc-gnuplot-buffer nil |
nil calc-gnuplot-buffer nil |
867 |
"-c" (format "cat %s >/dev/tty; rm %s" output output)) |
"-c" (format "cat %s >/dev/tty; rm %s" output output))) |
|
) |
|
868 |
|
|
869 |
(defun calc-graph-show-dumb (&optional output) |
(defun calc-graph-show-dumb (&optional output) |
870 |
"Default calc-gnuplot-plot-command for Pinard's \"dumb\" terminal type. |
"Default calc-gnuplot-plot-command for Pinard's \"dumb\" terminal type. |
912 |
(if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch) |
(if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch) |
913 |
" or `M-# M-#'" "")) |
" or `M-# M-#'" "")) |
914 |
(recursive-edit) |
(recursive-edit) |
915 |
(bury-buffer "*Gnuplot Trail*")) |
(bury-buffer "*Gnuplot Trail*"))) |
|
) |
|
916 |
|
|
917 |
(defun calc-graph-clear () |
(defun calc-graph-clear () |
918 |
(interactive) |
(interactive) |
923 |
(if (equal calc-graph-last-output "STDOUT") |
(if (equal calc-graph-last-output "STDOUT") |
924 |
"" |
"" |
925 |
(prin1-to-string calc-graph-last-output))) |
(prin1-to-string calc-graph-last-output))) |
926 |
(calc-gnuplot-command "clear"))) |
(calc-gnuplot-command "clear")))) |
|
) |
|
927 |
|
|
928 |
(defun calc-graph-title-x (title) |
(defun calc-graph-title-x (title) |
929 |
(interactive "sX axis title: ") |
(interactive "sX axis title: ") |
930 |
(calc-graph-set-command "xlabel" (if (not (equal title "")) |
(calc-graph-set-command "xlabel" (if (not (equal title "")) |
931 |
(prin1-to-string title))) |
(prin1-to-string title)))) |
|
) |
|
932 |
|
|
933 |
(defun calc-graph-title-y (title) |
(defun calc-graph-title-y (title) |
934 |
(interactive "sY axis title: ") |
(interactive "sY axis title: ") |
935 |
(calc-graph-set-command "ylabel" (if (not (equal title "")) |
(calc-graph-set-command "ylabel" (if (not (equal title "")) |
936 |
(prin1-to-string title))) |
(prin1-to-string title)))) |
|
) |
|
937 |
|
|
938 |
(defun calc-graph-title-z (title) |
(defun calc-graph-title-z (title) |
939 |
(interactive "sZ axis title: ") |
(interactive "sZ axis title: ") |
940 |
(calc-graph-set-command "zlabel" (if (not (equal title "")) |
(calc-graph-set-command "zlabel" (if (not (equal title "")) |
941 |
(prin1-to-string title))) |
(prin1-to-string title)))) |
|
) |
|
942 |
|
|
943 |
(defun calc-graph-range-x (range) |
(defun calc-graph-range-x (range) |
944 |
(interactive "sX axis range: ") |
(interactive "sX axis range: ") |
945 |
(calc-graph-set-range "xrange" range) |
(calc-graph-set-range "xrange" range)) |
|
) |
|
946 |
|
|
947 |
(defun calc-graph-range-y (range) |
(defun calc-graph-range-y (range) |
948 |
(interactive "sY axis range: ") |
(interactive "sY axis range: ") |
949 |
(calc-graph-set-range "yrange" range) |
(calc-graph-set-range "yrange" range)) |
|
) |
|
950 |
|
|
951 |
(defun calc-graph-range-z (range) |
(defun calc-graph-range-z (range) |
952 |
(interactive "sZ axis range: ") |
(interactive "sZ axis range: ") |
953 |
(calc-graph-set-range "zrange" range) |
(calc-graph-set-range "zrange" range)) |
|
) |
|
954 |
|
|
955 |
(defun calc-graph-set-range (cmd range) |
(defun calc-graph-set-range (cmd range) |
956 |
(if (equal range "$") |
(if (equal range "$") |
974 |
(string-match " " range))) |
(string-match " " range))) |
975 |
(aset range (match-beginning 0) ?\:)) |
(aset range (match-beginning 0) ?\:)) |
976 |
(calc-graph-set-command cmd (if (not (equal range "")) |
(calc-graph-set-command cmd (if (not (equal range "")) |
977 |
(concat "[" range "]"))) |
(concat "[" range "]")))) |
|
) |
|
978 |
|
|
979 |
(defun calc-graph-log-x (flag) |
(defun calc-graph-log-x (flag) |
980 |
(interactive "P") |
(interactive "P") |
981 |
(calc-graph-set-log flag 0 0) |
(calc-graph-set-log flag 0 0)) |
|
) |
|
982 |
|
|
983 |
(defun calc-graph-log-y (flag) |
(defun calc-graph-log-y (flag) |
984 |
(interactive "P") |
(interactive "P") |
985 |
(calc-graph-set-log 0 flag 0) |
(calc-graph-set-log 0 flag 0)) |
|
) |
|
986 |
|
|
987 |
(defun calc-graph-log-z (flag) |
(defun calc-graph-log-z (flag) |
988 |
(interactive "P") |
(interactive "P") |
989 |
(calc-graph-set-log 0 0 flag) |
(calc-graph-set-log 0 0 flag)) |
|
) |
|
990 |
|
|
991 |
(defun calc-graph-set-log (xflag yflag zflag) |
(defun calc-graph-set-log (xflag yflag zflag) |
992 |
(let* ((old (or (calc-graph-find-command "logscale") "")) |
(let* ((old (or (calc-graph-find-command "logscale") "")) |
1006 |
(if (eq zflag 0) zold |
(if (eq zflag 0) zold |
1007 |
(> (prefix-numeric-value zflag) 0)) |
(> (prefix-numeric-value zflag) 0)) |
1008 |
(not zold)) "z" ""))) |
(not zold)) "z" ""))) |
1009 |
(calc-graph-set-command "logscale" (if (not (equal str "")) str))) |
(calc-graph-set-command "logscale" (if (not (equal str "")) str)))) |
|
) |
|
1010 |
|
|
1011 |
(defun calc-graph-line-style (style) |
(defun calc-graph-line-style (style) |
1012 |
(interactive "P") |
(interactive "P") |
1013 |
(calc-graph-set-styles (and style (prefix-numeric-value style)) t) |
(calc-graph-set-styles (and style (prefix-numeric-value style)) t)) |
|
) |
|
1014 |
|
|
1015 |
(defun calc-graph-point-style (style) |
(defun calc-graph-point-style (style) |
1016 |
(interactive "P") |
(interactive "P") |
1017 |
(calc-graph-set-styles t (and style (prefix-numeric-value style))) |
(calc-graph-set-styles t (and style (prefix-numeric-value style)))) |
|
) |
|
1018 |
|
|
1019 |
(defun calc-graph-set-styles (lines points) |
(defun calc-graph-set-styles (lines points) |
1020 |
(calc-graph-init) |
(calc-graph-init) |
1067 |
" " (int-to-string pstyle)) |
" " (int-to-string pstyle)) |
1068 |
(if (and lstyle (> lstyle 0)) |
(if (and lstyle (> lstyle 0)) |
1069 |
(insert " " (int-to-string lstyle)))))) |
(insert " " (int-to-string lstyle)))))) |
1070 |
(calc-graph-view-commands) |
(calc-graph-view-commands)) |
|
) |
|
1071 |
|
|
1072 |
(defun calc-graph-zero-x (flag) |
(defun calc-graph-zero-x (flag) |
1073 |
(interactive "P") |
(interactive "P") |
1075 |
(and (if flag |
(and (if flag |
1076 |
(<= (prefix-numeric-value flag) 0) |
(<= (prefix-numeric-value flag) 0) |
1077 |
(not (calc-graph-find-command "noxzeroaxis"))) |
(not (calc-graph-find-command "noxzeroaxis"))) |
1078 |
" ")) |
" "))) |
|
) |
|
1079 |
|
|
1080 |
(defun calc-graph-zero-y (flag) |
(defun calc-graph-zero-y (flag) |
1081 |
(interactive "P") |
(interactive "P") |
1083 |
(and (if flag |
(and (if flag |
1084 |
(<= (prefix-numeric-value flag) 0) |
(<= (prefix-numeric-value flag) 0) |
1085 |
(not (calc-graph-find-command "noyzeroaxis"))) |
(not (calc-graph-find-command "noyzeroaxis"))) |
1086 |
" ")) |
" "))) |
|
) |
|
1087 |
|
|
1088 |
(defun calc-graph-name (name) |
(defun calc-graph-name (name) |
1089 |
(interactive "sTitle for current curve: ") |
(interactive "sTitle for current curve: ") |
1103 |
(delete-region (point) end)) |
(delete-region (point) end)) |
1104 |
(goto-char end)) |
(goto-char end)) |
1105 |
(insert " title " (prin1-to-string name)))) |
(insert " title " (prin1-to-string name)))) |
1106 |
(calc-graph-view-commands) |
(calc-graph-view-commands)) |
|
) |
|
1107 |
|
|
1108 |
(defun calc-graph-hide (flag) |
(defun calc-graph-hide (flag) |
1109 |
(interactive "P") |
(interactive "P") |
1117 |
(if (or (null flag) (<= (prefix-numeric-value flag) 0)) |
(if (or (null flag) (<= (prefix-numeric-value flag) 0)) |
1118 |
(delete-char 1)) |
(delete-char 1)) |
1119 |
(if (or (null flag) (> (prefix-numeric-value flag) 0)) |
(if (or (null flag) (> (prefix-numeric-value flag) 0)) |
1120 |
(insert "*"))))) |
(insert "*")))))) |
|
) |
|
1121 |
|
|
1122 |
(defun calc-graph-header (title) |
(defun calc-graph-header (title) |
1123 |
(interactive "sTitle for entire graph: ") |
(interactive "sTitle for entire graph: ") |
1124 |
(calc-graph-set-command "title" (if (not (equal title "")) |
(calc-graph-set-command "title" (if (not (equal title "")) |
1125 |
(prin1-to-string title))) |
(prin1-to-string title)))) |
|
) |
|
1126 |
|
|
1127 |
(defun calc-graph-border (flag) |
(defun calc-graph-border (flag) |
1128 |
(interactive "P") |
(interactive "P") |
1130 |
(and (if flag |
(and (if flag |
1131 |
(<= (prefix-numeric-value flag) 0) |
(<= (prefix-numeric-value flag) 0) |
1132 |
(not (calc-graph-find-command "noborder"))) |
(not (calc-graph-find-command "noborder"))) |
1133 |
" ")) |
" "))) |
|
) |
|
1134 |
|
|
1135 |
(defun calc-graph-grid (flag) |
(defun calc-graph-grid (flag) |
1136 |
(interactive "P") |
(interactive "P") |
1137 |
(calc-graph-set-command "grid" (and (if flag |
(calc-graph-set-command "grid" (and (if flag |
1138 |
(> (prefix-numeric-value flag) 0) |
(> (prefix-numeric-value flag) 0) |
1139 |
(not (calc-graph-find-command "grid"))) |
(not (calc-graph-find-command "grid"))) |
1140 |
" ")) |
" "))) |
|
) |
|
1141 |
|
|
1142 |
(defun calc-graph-key (flag) |
(defun calc-graph-key (flag) |
1143 |
(interactive "P") |
(interactive "P") |
1144 |
(calc-graph-set-command "key" (and (if flag |
(calc-graph-set-command "key" (and (if flag |
1145 |
(> (prefix-numeric-value flag) 0) |
(> (prefix-numeric-value flag) 0) |
1146 |
(not (calc-graph-find-command "key"))) |
(not (calc-graph-find-command "key"))) |
1147 |
" ")) |
" "))) |
|
) |
|
1148 |
|
|
1149 |
(defun calc-graph-num-points (res flag) |
(defun calc-graph-num-points (res flag) |
1150 |
(interactive "sNumber of data points: \nP") |
(interactive "sNumber of data points: \nP") |
1158 |
(message "Default 3D resolution is %d." |
(message "Default 3D resolution is %d." |
1159 |
calc-graph-default-resolution-3d) |
calc-graph-default-resolution-3d) |
1160 |
(setq calc-graph-default-resolution-3d (string-to-int res)))) |
(setq calc-graph-default-resolution-3d (string-to-int res)))) |
1161 |
(calc-graph-set-command "samples" (if (not (equal res "")) res))) |
(calc-graph-set-command "samples" (if (not (equal res "")) res)))) |
|
) |
|
1162 |
|
|
1163 |
(defun calc-graph-device (name flag) |
(defun calc-graph-device (name flag) |
1164 |
(interactive "sDevice name: \nP") |
(interactive "sDevice name: \nP") |
1177 |
calc-gnuplot-print-device) |
calc-gnuplot-print-device) |
1178 |
(setq calc-gnuplot-print-device name))) |
(setq calc-gnuplot-print-device name))) |
1179 |
(calc-graph-set-command "terminal" (if (not (equal name "")) |
(calc-graph-set-command "terminal" (if (not (equal name "")) |
1180 |
name)))) |
name))))) |
|
) |
|
1181 |
|
|
1182 |
(defun calc-graph-output (name flag) |
(defun calc-graph-output (name flag) |
1183 |
(interactive "FOutput file name: \np") |
(interactive "FOutput file name: \np") |
1201 |
calc-gnuplot-print-output) |
calc-gnuplot-print-output) |
1202 |
(setq calc-gnuplot-print-output name))) |
(setq calc-gnuplot-print-output name))) |
1203 |
(calc-graph-set-command "output" (if (not (equal name "")) |
(calc-graph-set-command "output" (if (not (equal name "")) |
1204 |
(prin1-to-string name)))) |
(prin1-to-string name))))) |
|
) |
|
1205 |
|
|
1206 |
(defun calc-graph-display (name) |
(defun calc-graph-display (name) |
1207 |
(interactive "sX display name: ") |
(interactive "sX display name: ") |
1210 |
(or calc-gnuplot-display "<none>")) |
(or calc-gnuplot-display "<none>")) |
1211 |
(setq calc-gnuplot-display name) |
(setq calc-gnuplot-display name) |
1212 |
(if (calc-gnuplot-alive) |
(if (calc-gnuplot-alive) |
1213 |
(calc-gnuplot-command "exit"))) |
(calc-gnuplot-command "exit")))) |
|
) |
|
1214 |
|
|
1215 |
(defun calc-graph-geometry (name) |
(defun calc-graph-geometry (name) |
1216 |
(interactive "sX geometry spec (or \"default\"): ") |
(interactive "sX geometry spec (or \"default\"): ") |
1219 |
(or calc-gnuplot-geometry "default")) |
(or calc-gnuplot-geometry "default")) |
1220 |
(setq calc-gnuplot-geometry (and (not (equal name "default")) name)) |
(setq calc-gnuplot-geometry (and (not (equal name "default")) name)) |
1221 |
(if (calc-gnuplot-alive) |
(if (calc-gnuplot-alive) |
1222 |
(calc-gnuplot-command "exit"))) |
(calc-gnuplot-command "exit")))) |
|
) |
|
1223 |
|
|
1224 |
(defun calc-graph-find-command (cmd) |
(defun calc-graph-find-command (cmd) |
1225 |
(calc-graph-init) |
(calc-graph-init) |
1227 |
(set-buffer calc-gnuplot-input) |
(set-buffer calc-gnuplot-input) |
1228 |
(goto-char (point-min)) |
(goto-char (point-min)) |
1229 |
(if (re-search-forward (concat "^set[ \t]+" cmd "[ \t]*\\(.*\\)$") nil t) |
(if (re-search-forward (concat "^set[ \t]+" cmd "[ \t]*\\(.*\\)$") nil t) |
1230 |
(buffer-substring (match-beginning 1) (match-end 1)))) |
(buffer-substring (match-beginning 1) (match-end 1))))) |
|
) |
|
1231 |
|
|
1232 |
(defun calc-graph-set-command (cmd &rest args) |
(defun calc-graph-set-command (cmd &rest args) |
1233 |
(calc-graph-init) |
(calc-graph-init) |
1250 |
(or (bolp) |
(or (bolp) |
1251 |
(insert "\n")) |
(insert "\n")) |
1252 |
(insert "set " (mapconcat 'identity (cons cmd args) " ") "\n")))) |
(insert "set " (mapconcat 'identity (cons cmd args) " ") "\n")))) |
1253 |
(calc-graph-view-commands) |
(calc-graph-view-commands)) |
|
) |
|
1254 |
|
|
1255 |
(defun calc-graph-command (cmd) |
(defun calc-graph-command (cmd) |
1256 |
(interactive "sGNUPLOT command: ") |
(interactive "sGNUPLOT command: ") |
1259 |
(calc-graph-view-trail) |
(calc-graph-view-trail) |
1260 |
(calc-gnuplot-command cmd) |
(calc-gnuplot-command cmd) |
1261 |
(accept-process-output) |
(accept-process-output) |
1262 |
(calc-graph-view-trail)) |
(calc-graph-view-trail))) |
|
) |
|
1263 |
|
|
1264 |
(defun calc-graph-kill (&optional no-view) |
(defun calc-graph-kill (&optional no-view) |
1265 |
(interactive) |
(interactive) |
1272 |
(sit-for 1) |
(sit-for 1) |
1273 |
(if (process-status calc-gnuplot-process) |
(if (process-status calc-gnuplot-process) |
1274 |
(delete-process calc-gnuplot-process)) |
(delete-process calc-gnuplot-process)) |
1275 |
(setq calc-gnuplot-process nil))) |
(setq calc-gnuplot-process nil)))) |
|
) |
|
1276 |
|
|
1277 |
(defun calc-graph-quit () |
(defun calc-graph-quit () |
1278 |
(interactive) |
(interactive) |
1280 |
(calc-graph-view-commands t)) |
(calc-graph-view-commands t)) |
1281 |
(if (get-buffer-window calc-gnuplot-buffer) |
(if (get-buffer-window calc-gnuplot-buffer) |
1282 |
(calc-graph-view-trail t)) |
(calc-graph-view-trail t)) |
1283 |
(calc-graph-kill t) |
(calc-graph-kill t)) |
|
) |
|
1284 |
|
|
1285 |
(defun calc-graph-view-commands (&optional no-need) |
(defun calc-graph-view-commands (&optional no-need) |
1286 |
(interactive "p") |
(interactive "p") |
1287 |
(or calc-graph-no-auto-view (calc-graph-init-buffers)) |
(or calc-graph-no-auto-view (calc-graph-init-buffers)) |
1288 |
(calc-graph-view calc-gnuplot-input calc-gnuplot-buffer (null no-need)) |
(calc-graph-view calc-gnuplot-input calc-gnuplot-buffer (null no-need))) |
|
) |
|
1289 |
|
|
1290 |
(defun calc-graph-view-trail (&optional no-need) |
(defun calc-graph-view-trail (&optional no-need) |
1291 |
(interactive "p") |
(interactive "p") |
1292 |
(or calc-graph-no-auto-view (calc-graph-init-buffers)) |
(or calc-graph-no-auto-view (calc-graph-init-buffers)) |
1293 |
(calc-graph-view calc-gnuplot-buffer calc-gnuplot-input (null no-need)) |
(calc-graph-view calc-gnuplot-buffer calc-gnuplot-input (null no-need))) |
|
) |
|
1294 |
|
|
1295 |
(defun calc-graph-view (buf other-buf need) |
(defun calc-graph-view (buf other-buf need) |
1296 |
(let (win) |
(let (win) |
1325 |
(vertical-motion (- 6 (window-height win))) |
(vertical-motion (- 6 (window-height win))) |
1326 |
(set-window-start win (point)) |
(set-window-start win (point)) |
1327 |
(goto-char (point-max))))) |
(goto-char (point-max))))) |
1328 |
(or calc-graph-no-auto-view (sit-for 0))) |
(or calc-graph-no-auto-view (sit-for 0)))) |
|
) |
|
1329 |
(setq calc-graph-no-auto-view nil) |
(setq calc-graph-no-auto-view nil) |
1330 |
|
|
1331 |
(defun calc-gnuplot-check-for-errors () |
(defun calc-gnuplot-check-for-errors () |
1337 |
(re-search-forward "^[ \t]+\\^$" nil t) |
(re-search-forward "^[ \t]+\\^$" nil t) |
1338 |
(goto-char (point-max)) |
(goto-char (point-max)) |
1339 |
(setq calc-gnuplot-last-error-pos (point-max)))) |
(setq calc-gnuplot-last-error-pos (point-max)))) |
1340 |
(calc-graph-view-trail)) |
(calc-graph-view-trail))) |
|
) |
|
1341 |
|
|
1342 |
(defun calc-gnuplot-command (&rest args) |
(defun calc-gnuplot-command (&rest args) |
1343 |
(calc-graph-init) |
(calc-graph-init) |
1358 |
calc-gnuplot-process)) |
calc-gnuplot-process)) |
1359 |
(calc-gnuplot-check-for-errors) |
(calc-gnuplot-check-for-errors) |
1360 |
(if (get-buffer-window calc-gnuplot-buffer) |
(if (get-buffer-window calc-gnuplot-buffer) |
1361 |
(calc-graph-view-trail)))) |
(calc-graph-view-trail))))) |
|
) |
|
1362 |
(setq calc-graph-no-wait nil) |
(setq calc-graph-no-wait nil) |
1363 |
|
|
1364 |
(defun calc-graph-init-buffers () |
(defun calc-graph-init-buffers () |
1367 |
(setq calc-gnuplot-buffer (get-buffer-create "*Gnuplot Trail*"))) |
(setq calc-gnuplot-buffer (get-buffer-create "*Gnuplot Trail*"))) |
1368 |
(or (and calc-gnuplot-input |
(or (and calc-gnuplot-input |
1369 |
(buffer-name calc-gnuplot-input)) |
(buffer-name calc-gnuplot-input)) |
1370 |
(setq calc-gnuplot-input (get-buffer-create "*Gnuplot Commands*"))) |
(setq calc-gnuplot-input (get-buffer-create "*Gnuplot Commands*")))) |
|
) |
|
1371 |
|
|
1372 |
(defun calc-graph-init () |
(defun calc-graph-init () |
1373 |
(or (calc-gnuplot-alive) |
(or (calc-gnuplot-alive) |
1429 |
(eq (char-after (1- (point-max))) ?\n) |
(eq (char-after (1- (point-max))) ?\n) |
1430 |
(progn |
(progn |
1431 |
(goto-char (point-max)) |
(goto-char (point-max)) |
1432 |
(insert "\n"))))) |
(insert "\n")))))) |
|
) |
|
1433 |
|
|
1434 |
|
;;; calc-graph.el ends here |