atchity@TC2.CHEM.IASTATE.EDU (11/20/90)
We recently received an upgrade for Mathematica which introduced at least two bugs associated with the use of 4Sight. I thought there might be others out there who could benefit from my workarounds. Both problems and workarounds are contained in the file 4Sight.view, a revied version of which I've appended to this note. 4Sight.view is normally located in $mathdir/Bin.Iris/Display. Bug 1: This is not really a bug, but mathematica now uses a temporary file when displaying 4Sight graphics which is put by default in /tmp. If the NEWSSERVER on another machine is being used (e.g. you're logged on remotely) the directory /tmp must be mounted on the remote machine. My workaround was to change the variable "file" in 4Sight.view from "/tmp/NeWS.view$$" to a path that is accessible to all our PI's. Bug 2: This is a serious bug that affects the NEWSSERVER on the PI displaying the mathematica 4Sight graphics. The 4Sight windows used for displaying mathematica graphics have a menu for changing some of the display parameters. The menu must not be implemented correctly (I'm no NeWS guru, so I really don't know exactly what is wrong) because any other 4Sight window brought up after the first mathematica window (e.g. wsh) will display the mathematica menu IN ADDITION TO any menu normally associated with that window. Accidentally choosing an option from the superimposed mathematica menu will result in the death of the window. My workaround creates and calls the mathematica menu by name (NewMathMenu) which doesn't seem to be exported to any other window. Here is my version of 4Sight.view (with the original temporary file path). -------------------------------------------------------------------------------- #! /bin/sh -f imagetitle="Mathematica Graphics" nodistort=true # default no-stretching: yes while :; do case $# in 0) break 2 ;; esac case "$1" in -T) shift imagetitle="$1" shift ;; -h) shift # imageheight="$1" shift ;; -w) shift # imagewidth="$1" shift ;; -stretch) nodistort=false shift ;; -*) echo 'Usage: NeWS.view [-T title] [-stretch] [file]' >&2 exit 1 ;; *) break 2 ;; esac done # other defaults # line quality, between 0 and 1; 1 is best (and slowest) linequality=0.5 # # temporary file name: must be accessible to all PI's displaying 4Sight graphics # # save input in file file=/tmp/NeWS.view$$ cat $@ > $file ( cat <<'!' false setautobind % so that redefs work... ! psfix </dev/null cat <<'!' pause % give it a chance to catch some breatch /MathPictureStart { gsave Mtransform % possibly rotate to landscape mode Mlmarg % left_margin Mbmarg % bottom_margin translate % - /Mtmatrix % /Mtmatrix matrix currentmatrix % /Mtmatrix text_matrix def % - Plain % default_font Mfontsize scalefont % default_font (at default point size) setfont % - } bind def % redraw after menu choice /ReDraw {/paintclient win send} def /realLinewidth /setlinewidth load def % save old value /uselinewidth? true def /speclinewidth 0 def /setlinewidth { % redefine uselinewidth? {realLinewidth} {pop speclinewidth realLinewidth} ifelse } def /thinlines { /speclinewidth 0 store /uselinewidth? false store } def /thicklines { /speclinewidth 0.005 store /uselinewidth? false store } def /defaultlines { /uselinewidth? true store } def % define line quality /linequality { /curlinequality exch store } def /defaultlinequality { Mlinequality linequality } def % stretching /defaultstretch { /Mnodistort Defnodistort store Mnodistort {nostretchmsg} {stretchmsg} ifelse /searchkey getMenu send % wrong message displayed ? {Mnodistort {stretchmsg} {nostretchmsg} ifelse {stretchhandler} /changeitem getMenu send} if } def /stretchmsg (stretch to fill window) def /nostretchmsg (preserve aspect ratio) def /stretchhandler { % toggle flag and message /Mnodistort currentkey nostretchmsg eq store currentindex Mnodistort {stretchmsg} {nostretchmsg} ifelse {stretchhandler} /changeitem self send ReDraw } def % switch meshes on and off /MSetetra /Metetra load def % save value /MStetra /Mtetra load def % save value /Mshowmesh? true def /Mswtetra { % switch according to flag Mshowmesh? {MSetetra} {MStetra} ifelse } def /defaultmesh { % restore defaults /Metetra {MSetetra pause} store /Mtetra {MStetra pause} store meshmsg /searchkey getMenu send % wrong message displayed ? {nomeshmsg {meshhandler} /changeitem getMenu send} if } def /meshmsg (draw mesh lines) def /nomeshmsg (no mesh lines) def /meshhandler { % toggle flag and message /Mshowmesh? currentkey meshmsg eq store /Metetra {Mswtetra pause} store /Mtetra {Mswtetra pause} store currentindex Mshowmesh? {nomeshmsg} {meshmsg} ifelse {meshhandler} /changeitem self send ReDraw } def % filling on and off /RealFill /fill load def /fill {RealFill} def % create new entry to be changed later /defaultFill { dofill fillmsg /searchkey getMenu send % wrong message displayed ? {nofillmsg {fillhandler} /changeitem getMenu send} if } def /dofill { /fill {RealFill pause} store } def /nofill { /fill {newpath} store % must destroy path! } def /fillmsg (fill polygons) def /nofillmsg (do not fill polygons) def /fillhandler { % toggle flag and message currentkey fillmsg eq {dofill nofillmsg} {nofill fillmsg} ifelse % leaves msg on stack currentindex exch {fillhandler} /changeitem self send % set this msg ReDraw } def /AllDefaults { defaultlines defaultlinequality defaultstretch defaultmesh defaultFill } def ! cat << ! /PSPaint { 1 fillcanvas % menu driven repaint does not work without clippath pathbbox % lx ly hx hy exch % lx ly hy hx 4 -1 roll % ly hy hx lx sub % ly hy hx-lx 3 1 roll % hx-lx ly hy exch % hx-lx hy ly sub % hx-lx hy-ly /Mheight exch def % total page height /Mwidth exch def % total page width .1 72 mul % left, right, top, and bottom margin dup dup dup % bmarg tmarg rmarg lmarg /Mlmarg exch def % left margin /Mrmarg exch def % right margin /Mtmarg exch def % top margin /Mbmarg exch def % bottom margin 0 setgray curlinequality setlinequality % allow menu driven changes pause filename (r) file cvx exec } def %defaults from shell variables /Mlinequality $linequality def % reset nodistort from psfix /Defnodistort $nodistort def % no-stretching flag /filename ($file) def /stretchdefmsg Defnodistort {stretchmsg} {nostretchmsg} ifelse def /meshdefmsg nomeshmsg def /filldefmsg nofillmsg def /curlinequality Mlinequality def % timeout? statusdict begin 90 setjobtimeout end pause % our window % values that need to be known outside the window context /getMenu {{/ClientMenu load} win send} def /makewin { /NewMathWindow DefaultWindow dictbegin /PaintClient {PSPaint} def /FrameLabel ($imagetitle) def /IconLabel ($imagetitle) def dictend classbegin /LineMenu [ (default) {defaultlines ReDraw} (thin) {thinlines ReDraw} (thick) {thicklines ReDraw} ] /new DefaultMenu send def /QualityMenu [ (default) {defaultlinequality ReDraw} (fast) {0 linequality ReDraw} (accurate) {1 linequality ReDraw} ] /new DefaultMenu send def % main menu /ClientMenu [ (Reset to Defaults) {AllDefaults ReDraw} (Line width =>) LineMenu (Line quality =>) QualityMenu stretchdefmsg {stretchhandler} meshdefmsg {meshhandler} filldefmsg {fillhandler} %(redraw) {ReDraw} % for debugging ] /new DefaultMenu send def classend def /win framebuffer /new NewMathWindow send def /reshapefromuser win send {AllDefaults} win send % set it up /map win send } def makewin % remove file on destruction of window {/SaveDestroy /DestroyFrame load def /DestroyFrame { (rm ) filename append forkunix SaveDestroy } def } win send ! ) | sed -e 's/^bind //' -e 's/ bind / /' -e 's/ bind$//' | psh -------------------------------------------------------------------------------- Greg Atchity address: atchity@tc2.chem.iastate.edu