Do not allow constants to be bound by lambda expressions
[maxima.git] / plotting / mgnuplot.in
blobc01eefaa5409e843ed74db1e77de62f184fd4b14
1 #!/bin/sh
2 # comment \
3 exec @WISH@ "$0" "$@"
5 # Set path to gnuplot on windows, if required
6 if { $tcl_platform(platform) eq "windows"} {
7 # If gnuplot isn't in the path, then guess location and add to path
8 if { [auto_execok gnuplot] eq "" } {
9 # Path to mgnuplot executable
10 set mypath [file dirname $argv0]
11 # gnuplot.exe location relative to mgnuplot.exe in windows installer
12 set gnuplotpath [file normalize "${mypath}/../../../../gnuplot/bin"]
13 set ::env(PATH) "$::env(PATH);$gnuplotpath"
17 #set gnuPlotstream [open {| gnuplot /d19/staff/wfs/tmp/jo } w]
18 set gnuPlotstream [open {| gnuplot } r+]
21 proc sendgnu com {
22 global gnuPlotstream
23 puts stdout $com ; flush stdout
24 puts $gnuPlotstream $com ; flush $gnuPlotstream
27 set ii 0
28 while {$ii < $argc} {
29 switch -exact "X[lindex $argv $ii]" {
30 X-parametric3d {
31 sendgnu "set parametric\n"
32 sendgnu "set data style lines\n"
33 sendgnu "set hidden\n"
34 set ii [expr {$ii + 1}]
35 sendgnu "splot '[lindex $argv $ii]'\n" }
36 X-plot2d {
37 set ii [expr {$ii + 1}]
38 sendgnu "set data style lines"
39 sendgnu "plot '[lindex $argv $ii]'\n"
41 X-title {
42 set ii [expr {$ii + 1}]
43 sendgnu "set title '[lindex $argv $ii]'\n" }
46 set ii [expr {$ii +1}]
49 set xrot 60
50 set zrot 30
53 text .text
54 .text configure -height 4 -width 40
56 proc getoptions {} {
57 # unlink gnu-optionsxx
58 set tmp gnu-optionsxx
59 file delete -force $tmp
60 sendgnu "save '$tmp'\n"
61 # 50 ms delay in loop is arbitrary, was "exec sleep 0"
62 while {[file exists $tmp] <= 0} {after 50}
63 set at [.fra.options nearest 0]
64 set f [ open gnu-optionsxx ]
65 .fra.options delete 0 end
66 while { [gets $f line] >= 0 } {
67 .fra.options insert end [lrange $line 0 end ]}
68 .fra.options yview $at
71 frame .fra -bd 2
72 label .fra.label -text "Current Set Options"
73 scrollbar .fra.scroll -command ".fra.options yview"
74 listbox .fra.options -yscrollcommand ".fra.scroll set" -relief sunken -bd 2
75 pack .fra.label
76 pack .fra.options -side left
77 pack .fra.scroll -side right -fill y
78 bind .fra.options <Double-1> "set selected_option \[lindex \[selection get\] 0\]"
79 frame .option_edit
81 proc msg a {global $a
82 sendgnu [format "%s\n\nreplot\n" [expr $$a]] ;
83 set $a ""
84 getoptions}
86 proc mkOption_edit {a b} {
87 global $b
88 label $a.label -text "Edit: "
89 entry $a.entry -width 20 -relief sunken -bd 2 -textvariable $b
90 bind $a.entry <Return> "msg $b"
91 pack $a.label $a.entry -side left -padx 1m -pady 2m
94 mkOption_edit .option_edit selected_option
97 getoptions
99 button .exit -text "Exit" -command {
100 sendgnu "exit\n"
101 destroy .
104 button .save -text "save gnuplot.out" -command {
105 sendgnu "save 'gnuplot.out'\n"
108 scale .rotxscale -label "xrotation" \
109 -orient horizontal -length 200 -from 0 -to 180 \
110 -command gnuPlotsetview -tickinterval 60
111 scale .rotzscale -label "zrotation" \
112 -orient horizontal -length 200 -from 0 -to 360 \
113 -command gnuPlotsetview -tickinterval 120
115 set initted 0
116 .rotxscale set $xrot
117 .rotzscale set $zrot
119 proc gnuPlotsetview value {
120 global initted
121 if { $initted < 2 } { set initted [expr {$initted + 1}]} \
122 else \
123 {sendgnu [format "set view %d,%d\nreplot\n" [.rotxscale get] [.rotzscale get]]}}
125 pack .exit .rotxscale .rotzscale .fra .option_edit .save