#!/usr/bin/wish ## ##+####################################################################### ## NOTE: ## If the 'wish' interpreter is in a different directory, such as ## /usr/local/bin, you can make a soft-link from 'wish' there to ## /usr/bin/wish, as root, with a command like ## ln -s /usr/bin/local/wish /usr/bin/wish ##+####################################################################### ## Tk SCRIPT NAME: tkGnuplot3DsurfaceOr2DContour_fromExprFxy.tk ## ## WHERE: in $FEDIR_TKGUIS/PLOTtools/tkGnuplot3DsurfaceOr2DContour_fromExprFxy ## ## where $FEDIR_TKGUIS = $FEDIR/tkGUIs ## ## where $FEDIR is the installation ## directory of the FE subsystem that ## contains this script. ## ## Typically FEDIR is $HOME/apps/tkGooies_linux ## after the 'tkGooies' self-extracting install script is run. ##+###################################################################### ## PURPOSE: This is an f(x,y) math-expression 'quick-plot' utility using ## 'gnuplot' to plot one of several types of plots from the ## user-specified expression: ## - a 3D surface on one graph with x,y,z axes, or ## - a 2D contour-lines plot with x,y axes, or ## - a 2D 'heat map' plot with x,y axes, or ## - a combined 3D-surface and 2D-contour-lines plot ## - a combined 2D-contour-lines and 2D-heat-map plot ## _____________________________________________________________ ## ## This Tk script presents a GUI to prompt for the math expression ## --- and provides a listbox of examples to choose from. ## ## The GUI also allows for specifying a title for the plot, ## x,y,z-axis titles, x,y,z axis limits, two 3D-view-angles, ## some surface 'hatching' options, some contour-lines options, ## some heat-map/palette color options --- ## as well as output type (PNG, GIF, JPG, PSc, PSbw, SVG, XWT) and ## image size in pixels. ## ##+######################### ## TYPICAL OPERATIONAL STEPS: ## ## After specifying the math expression in an entry field of the GUI, ## if the user takes the defaults for the other options on the GUI, ## the user can click on a 'RePlot' button to cause the plot to be ## rendered and displayed. ## ## The user can click on the 'Help' button for a description ## of this utility (help which can be much more extensive than ## this description). See the 'HELPtext' variable which is set ## at the bottom of this Tk script. ## ##+################# ## THE GUI WIDGETS: ## ## The options available to the user are indicated by ## the following 'sketch' of the GUI: ## ## FRAMEnames ## VVVVVVVVVV ## ------------------------------------------------------------------------------------------ ## Gnuplot - 3D-SURFACE and/or 2D-CONTOUR plot of a math expression, f(x,y) ## [window title] ## ------------------------------------------------------------------------------------------ ## ## .fRbuttons {Exit} {Help} {RePlot} {Color of {Color of {Clear} {Autoscale} ## Lines} background} ## ## [.fRbottom FRAME contains the '.fRleft' and 'fRright' FRAMES] ## ## [ '.fRleft' FRAME [ '.fRright FRAME' ## is below ] is below and to the right ] ## [FRAMES below ## are in .fRright ## -------------] ## ## .fRexpr |---------------A Expression: sin(2.0*pi*x+0.5)*cos(1.0*pi*y+1.2)___________________________________ ## | | ## .fRtitle | | Plot title: __________Plot TITLE goes here________________________________________ ## | | ## .fRplottype | | O 3D-Surface O 2D-Contour-lines O 2D-HeatMap O Surface-and-ContourLines O ContourLines-and-HeatMap ## | | ## .fRxaxis | [ This | XaxisMin: *_____ XaxisMax: *______ XticLabelsAngle: 0__ ___X-axis label goes here____ ## | listbox | ## .fRyaxis | contains | YaxisMin: *_____ YaxisMax: *______ YticLabelsAngle: 0__ ___Y-axis label goes here____ ## | f(x,y) math | ## .fRzaxis | expressions ] | ZaxisMin: *_____ ZaxisMax: *______ ZticLabelsAngle: 0__ ___Z-axis label goes here____ ## | | ## .fRsurfopts | | SurfaceGridSamples .. Xdirection: 30__ Ydirection: 30__ X ShadeSurface? SurfaceHatchType(1-7): 3_ ## | | ## .fRsurfview | | 3D View angles .. Polar(1-180): 45_ Azimuthal(0-360): 45_ {OverheadView} {ObliqueView} ## | | ## .fRcntropts | | ContourLevels: 10_ ContourGridSamples(x-and-y): 150_ ContourLineWidth: 1.5_ ## | | ## .fRheatopts | | HeatColors: {Low Color} {Low-Mid Color} {High-Mid Color} {High Color} ## | | ## .fRkeyopts | | NumberFormatInKey: %.1f__ Examples: %8.2f %.1f KeyLocation: at 0,0 top left____________ ## | | ## .fRoutopts | | ImageOutType: O GIF O PNG O JPG O PSc OPSbw O SVG O WXT {TestImg} Xpixels: 800__ Ypixels: 600__ ## | | ## .fRmsg |<------------->V [ .......... Messages go here ......................................................] ## ## ------------------------------------------------------------------- ## ## In the above sketch of the GUI: ## ## SQUARE BRACKETS indicate a comment (not to be placed on the GUI). ## BRACES indicate a Tk 'button' widget. ## UNDERSCORES indicate a Tk 'entry' widget. ## A COLON indicates that the text before the colon is on a 'label' widget. ## CAPITAL-O indicates a Tk 'radiobutton' widget. ## CAPITAL-X indicates a Tk 'checkbutton' widget (if any). ## Vertical bars (and horizontal hyphens) outline a 'listbox' widget. ## Less-than and greater-than signs indicate the left and right ends of a horizontal 'scrollbar'. ## Capital-V and Capital-A letters indicate the bottom and top ends of a vertical 'scrollbar'. ## ##+############## ## GUI components: ## ## From the GUI 'sketch' above, it is seen that the GUI consists of ## about ## ## - 14 button widgets ## - 26 label widgets ## - 26 entry widgets ## - 12 radiobutton widgets in 2 groups ## - 1 listbox widget with 2 scrollbars ## - 1 checkbutton widget ## - 0 scale widgets ## - 0 canvas widgets ## ##+#################################################################### ## CALLED BY: This Tk script can be called by the command name ## ## $FEDIR/tkGUIs/PlotTools/tkGnuplot3DsurfaceOr2Dcontour_fromExprFxy/ ## tkGnuplot3DsurfaceOr2Dcontour_fromExprFxy.tk ## ## where $FEDIR is the installation ## directory of the FE subsystem that ## contains this script. ## ## This script can be accessed via a drawer in a 'PLOTtools' ## toolchest (menu) in the FE 'tkGooies' toolchest system. ## ##+#################################################################### ## ## INPUTS (via entry fields on the GUI): ## an f(x,y) math expression, ## plot title, xyz axis-labels, xyz axis min-max, xyz-tic-labels-angle, ## surface parms, contour-line parms, heatmap/palette parms, ## image dimensions (in pixels). ## ## OUTPUT: An image file, displayed by an image-display program ## specified at the bottom of this Tk Script. ## ## The image file is put in a directory specified at the ## bottom of this Tk script. Example: /tmp ## ## An image capture of the Tk GUI and/or the output plot image ## with a screen capture tool is a possiblity. ## Example tool: 'gnome-screenshot' ## ##+#################################################################### ## STRUCTURE OF THIS CODE: ## ## 0) Set general window parms (win-name, win-position, win-color-scheme, ## fonts-for-widgets, widget-geom-parms, text-array-for-labels-etc, ## win-size-control). ## ## 1a) Define ALL frames (and sub-frames, if any). ## 1b) Pack the frames. ## ## 2) Define & pack all widgets in the frames, frame by frame. ## After all the widgets for a frame are defined, pack them in the frame. ## ## 3) Define keyboard and/or mouse/touchpad/touch-sensitive-screen 'event' ## BINDINGS, if needed. ## 4) Define PROCS, if needed. ## 5) Additional GUI INITIALIZATION (typically with one or more of ## the procs), if needed. ## ## In more detail: ## ## 0a) Define ALL frames: ## TopLevel: 'fRbuttons', 'fRbottom' ## In frame 'fRbottom'- 2 frames: 'fRleft', 'fRright' ## In frame 'fRright': ## 'fRexpr', 'fRtitle', 'fRplottype', 'fRxaxis', 'fRyaxis', 'fRzaxis', ## 'fRsurfopts', 'fRsurfview', 'fRcntropts', 'fRheatopts', ## 'fRkeyopts', 'fRoutopts', 'fRmsg' ## ## 0b) Pack frames with pack-parms to get proper behavior of widgets ## during window expansion. Example: Allow math-expression and title ## input fields to x-expand. ## ## 1) Define & pack all widgets in the frames -- basically going through ## frames & their interiors in top-to-bottom, left-to-right order: ## - '.fRbuttons' contains several buttons -- 'Exit','Help','Plot',... ## - '.fRbottom.fRleft' contains a listbox and its 2 scrollbars ## '.fRbottom.fRright' contains the following sub-frames: ## - 'fRexpr' contains 1 label & 1 entry widget. ## - 'fRtitle' contains 1 label & 1 entry widget. ## - 'fRplottype' contains 1 label & several radiobutton widgets. ## - 'fRxaxis' contains several label & entry widgets. ## - 'fRyaxis' contains several label & entry widgets. ## - 'fRzaxis' contains several label & entry widgets. ## - 'fRsurfopts' contains several label & entry widgets. ## - 'fRsurfview' contains several label & entry widgets. ## - 'fRcntropts' contains several label & entry widgets. ## - 'fRheatopts' contains label & button widgets. ## - 'fRkeyopts' contains several label & entry widgets. ## - 'fRoutopts' contains a label and several radiobutton widgets, and ## 2 label & entry widget pairs. ## - 'fRmsg' contains a label (or message or text) widget. ## ## 2) Define BINDINGS: (For details, see BINDINGS code section far below.) ## ## - a button-release binding on the listbox ## ## 3) Define PROCS: (See PROCS code section.) ## ## 'listboxSelectionTOexprField' - called by a button-release binding on the listbox ## ## 'clear_expr' - called by 'ClearExpr' button ## ## 'set_autoscale' - called by 'Autoscale' button ## ## 'replot' - called by 'RePlot' button ## (Writes gnuplot script and executes it.) ## ## 'plot_surface' - called by 'replot' proc ## 'plot_contour' - called by 'replot' proc ## 'plot_heatmap' - called by 'replot' proc ## 'plot_surface-contour' - called by 'replot' proc ## 'plot_contour-heatmap' - called by 'replot' proc ## ## 'display_test_img' - called by 'Test' button ## ## 'edit_inputs' - called by 'replot' proc ## ## 'getset_color' - called by 'LineColor', 'BkgdColor', and ## 5 heatmap/palette-color buttons ## ## 'update_color_botton' - called by the 'getset_color' proc and 5 times in ## the 'Additional GUI Initialization' section. ## ## 'popup_msgVarWithScroll' - called by 'Help' button to show HELPtext var. ## ## See the PROCS code section far below. ## ## 4) Additional GUI initialization, if needed. ## May use some procs such as the 'update_*_color_button' procs. ## ##+###################################################################### ## DEVELOPED/REVISED WITH: ## (Tcl 8.5)-(Tk 8.5) for first version in 2015, on Linux (Ubuntu 9.10). ## ## $ wish ## % puts "$tcl_version $tk_version" showed 8.5 8.5 on Ubuntu 9.10. ##+####################################################################### ## MAINTENANCE HISTORY: ## Started by: Blaise Montandon 2015oct10 Started this script based on ## some code from several other ## FE 'tkGooies' scripts. ## Updated by: Blaise Montandon 2015oct14 Consolidated some color procs. ##+####################################################################### ##+####################################################################### ## Set WINDOW TITLES and POSITION. ##+####################################################################### wm title . "tkGnuplot - 3D surface and/or 2D contour - of a math expression, f(x,y)" wm iconname . "tkGnuplot F(x,y)" # wm geometry . +15+30 wm geometry . +15-30 ##+###################################################### ## Set the COLOR SCHEME for the window and its widgets --- ## such as entry field background color. ##+###################################################### ## Some initial colors for several color-choosing buttons ## on the GUI are set at the bottom of this script, ## in the 'Additional GUI Initialization' section. ##+###################################################### # tk_setPalette "#e0e0e0" tk_setPalette "#c0c0c0" set entryBKGD "#f0f0f0" set listboxBKGD "#f0f0f0" set radiobuttBKGD "#f0f0f0" set checkbuttBKGD "#f0f0f0" ##+######################################################## ## Set (temp) FONT NAMES. ## ## Use a VARIABLE-WIDTH font for text on label and ## button widgets. ## ## Use a FIXED-WIDTH font for text in the entry fields ## --- or in a listbox widget or in a text widget. ##+######################################################## font create fontTEMP_varwidth \ -family {comic sans ms} \ -size -14 \ -weight bold \ -slant roman font create fontTEMP_SMALL_varwidth \ -family {comic sans ms} \ -size -10 \ -weight bold \ -slant roman ## Some other possible (similar) variable width fonts: ## Arial ## Bitstream Vera Sans ## DejaVu Sans ## Droid Sans ## FreeSans ## Liberation Sans ## Nimbus Sans L ## Trebuchet MS ## Verdana font create fontTEMP_fixedwidth \ -family {liberation mono} \ -size -14 \ -weight bold \ -slant roman font create fontTEMP_SMALL_fixedwidth \ -family {liberation mono} \ -size -10 \ -weight bold \ -slant roman ## Some other possible fixed width fonts (esp. on Linux): ## Andale Mono ## Bitstream Vera Sans Mono ## Courier 10 Pitch ## DejaVu Sans Mono ## Droid Sans Mono ## FreeMono ## Nimbus Mono L ## TlwgMono ##+########################################################### ## SET GEOM VARS FOR THE VARIOUS WIDGET DEFINITIONS. ## (e.g. padding and borderwidth for Buttons) ##+########################################################### ## BUTTON widget geom settings: set PADXpx_button 0 set PADYpx_button 0 set BDwidthPx_button 2 ## LABEL widget geom settings: set PADXpx_label 0 set PADYpx_label 0 set BDwidthPx_label 2 ## relief must be: flat, groove, raised, ridge, solid, or sunken set RELIEF_label_lo "flat" set RELIEF_label_hi "groove" ## ENTRY widget geom settings: set BDwidthPx_entry 2 set initExpressionWidthChars 30 set initTitleWidthChars 25 ## RADIOBUTTON geom parameters: set PADXpx_radbutt 0 set PADYpx_radbutt 0 set BDwidthPx_radbutt 2 ## relief must be: flat, groove, raised, ridge, solid, or sunken set RELIEF_radbutt_hi "ridge" set RELIEF_radbutt_lo "flat" ## CHECKBUTTON geom parameters: set PADXpx_chkbutt 0 set PADYpx_chkbutt 0 set BDwidthPx_chkbutt 2 ## relief must be: flat, groove, raised, ridge, solid, or sunken set RELIEF_chkbutt_hi "ridge" set RELIEF_chkbutt_lo "flat" ## LISTBOX geom settings: set BDwidthPx_listbox 2 set initListboxWidthChars 25 set initListboxHeightChars 8 ## SCALE geom parameters: (Not used, yet. Commented.) # set BDwidthPx_scale 2 # set initScaleLengthPx 300 # set scaleWidthPx 10 ##+###################################################### ## Set a MIN-SIZE of the window (roughly). ## ## Set approx MIN WIDTH according to the ## listbox width and the width of the '.fRbuttons' frame. ## ## Set approx MIN HEIGHT according to the height of the ## vertical 'stack' of frames. ##+###################################################### set buttonsWidthPx [font measure fontTEMP_varwidth \ "Exit Help RePlot Color of Color of Clear Autoscale "] set charWidthPx [font measure fontTEMP_varwidth "e"] set listboxWidthPx [expr {$charWidthPx * $initListboxWidthChars}] ## Add some pixels to account for right-left-size of window-manager ## decoration (about 6 pixels) and frame/widget borders for ## at least 4 buttons (4x4 pixels/widget). set minWinWidthPx [expr {$listboxWidthPx + $buttonsWidthPx + 22}] ## Get the approx MIN HEIGHT based on ## 2 chars high for the '.fRbuttons' frame ## 1 char high for the '.fRexpr' frame ## 1 char high for the '.fRtitle' frame ## 1 char high for the '.fRplottype' frame ## 1 char high for the '.fRxaxis' frame ## 1 char high for the '.fRyaxis' frame ## 1 char high for the '.fRzaxis' frame ## 1 char high for the '.fRsurfopts' frame ## 1 char high for the '.fRsurfview' frame ## 1 char high for the '.fRcntropts' frame ## 1 char high for the '.fRheatopts' frame ## 1 char high for the '.fRkeyopts' frame ## 1 char high for the '.fRoutopts' frame ## 1 char high for the '.fRmsg' frame ## ## and add about 20 pixels for top-bottom window decoration -- ## and about 14x4 pixels for frame/widget borders of the 14 frames. set charHeightPx [font metrics fontTEMP_fixedwidth -linespace] set minWinHeightPx [expr {76 + ( 15 * $charHeightPx )} ] ## FOR TESTING: # puts "minWinWidthPx = $minWinWidthPx" # puts "minWinHeightPx = $minWinHeightPx" wm minsize . $minWinWidthPx $minWinHeightPx ## If you want to make the window un-resizable, ## you can use the following statement. # wm resizable . 0 0 ## We can make the window un-resizable in the y direction, ## but allow it to be resizable in the x direction. ## (Does not work for all window managers? ## Does not seem to work 'completely as desired' for mine. ## The 'MaximizeWindow' button on the top window border always ## maximizes the window to full screensize. ## See an alternative attempt using 'wm maxsize .', ## at the very bottom of this script.) wm resizable . 1 0 ##+#################################################################### ## Set a TEXT-ARRAY to hold text for buttons & labels on the GUI. ## NOTE: This can aid INTERNATIONALIZATION. This array can ## be set according to a nation/region parameter. ##+#################################################################### ## if { "$VARlocale" == "en"} ## For widgets in 'fRbuttons' frame: set aRtext(buttonEXIT) "Exit" set aRtext(buttonHELP) "Help" set aRtext(buttonPLOT) "RePlot" set aRtext(buttonCOLORLINE) "Color of Lines" set aRtext(buttonCOLORBKGD) "Color of Background" set aRtext(buttonCLEAREXPR) "ClearExpr" set aRtext(buttonEXPR2TITLE) "ExprToTitle" set aRtext(buttonAUTOSCALE) "Autoscale" ## For widgets in 'fRexpr' frame: set aRtext(labelEXPR) "Expression:" ## For widgets in 'fRtitle' frame: set aRtext(labelPLOTTITLE) "Plot title:" ## For widgets in 'fRplottype' frame: set aRtext(labelPLOTTYPE) "PlotType:" set aRtext(radbuttSURF) "3Dsurface" set aRtext(radbuttCONT) "2Dcontour" set aRtext(radbuttHEAT) "2Dheatmap" set aRtext(radbuttSURFCONT) "SurfaceAndContour" set aRtext(radbuttCONTHEAT) "ContourAndHeatmap" ## For widgets in 'fRxaxis' frame: set aRtext(labelXMIN) "Xmin:" set aRtext(labelXMAX) " Xmax:" set aRtext(labelXTICLABELangle) " XticLabelsAngle:" ## For widgets in 'fRyaxis' frame: set aRtext(labelYMIN) "Ymin:" set aRtext(labelYMAX) " Ymax:" set aRtext(labelYTICLABELangle) " YticLabelsAngle:" ## For widgets in 'fRzaxis' frame: set aRtext(labelZMIN) "Zmin:" set aRtext(labelZMAX) " Zmax:" set aRtext(labelZTICLABELangle) " ZticLabelsAngle:" ## For widgets in 'fRsurfopts' frame: set aRtext(labelSURFsamplesXY) "SurfaceGridSamples - XandY directions:" set aRtext(chkbuttSHADED) "ShadeSurface?" set aRtext(labelHATCHTYPE) " SurfaceHatchType(1-7):" ## For widgets in 'fRsurfview' frame: set aRtext(labelPOLAR) "3D View angles .. Polar(1-180):" set aRtext(labelAZIMUTHAL) "Azimuthal(0-360):" set aRtext(buttonOVERHEAD) "OverheadView" set aRtext(buttonOBLIQUE) "ObliqueView" ## For widgets in 'fRcntropts' frame: set aRtext(labelLEVELS) "ContourLevels:" set aRtext(labelCONTsamplesXY) " ContourGridSamples-XandY:" set aRtext(labelLINEWIDTH) " ContourLineWidth:" ## For widgets in 'fRheatopts' frame: set aRtext(labelHEATCOLORS) "Heat/Palette Colors&Locations(0-99):" set aRtext(buttonLOWCOLOR) "Low" set aRtext(buttonLOWMIDCOLOR) "LoMid" set aRtext(buttonMIDCOLOR) "Mid" set aRtext(buttonHIGHMIDCOLOR) "HiMid" set aRtext(buttonHIGHCOLOR) "High" set aRtext(buttonSHOPALETTE) "ShoPalette" ## For widgets in 'fRkeyopts' frame: set aRtext(labelNUMFORMAT) "NumberFormatInKey:" set aRtext(labelNUMFMTEXAMPLES) "Examples: %8.2f %.1f" set aRtext(labelKEYLOC) " KeyLocation:" ## For widgets in 'fRoutopts' frame: set aRtext(labelOUTTYPE) "Image file type:" set aRtext(radbuttGIF) "GIF" set aRtext(radbuttPNG) "PNG" set aRtext(radbuttJPG) "JPG" set aRtext(radbuttPS) "PSc" set aRtext(radbuttPSbw) "PSbw" set aRtext(radbuttSVG) "SVG" set aRtext(radbuttWXT) "WXT" set aRtext(buttonTESTimg) "TestImg" set aRtext(labelXPIXELS) " Xpixels:" set aRtext(labelYPIXELS) " Ypixels:" ## END OF if { "$VARlocale" == "en"} ##+################################################################### ##+################################################################### ## DEFINE *ALL* THE FRAMES -- (top to bottom): ## ## - '.fRbuttons' contains button widgets -- 'Exit', 'Help', ## 'RePlot', some color-selector-buttons, ... ## ## - '.fRbottom.fRleft' contains a listbox and its 2 scrollbars ## ## - '.fRbottom.fRright' contains the following sub-frames: ## - 'fRexpr' contains 1 label & 1 entry widget. ## - 'fRtitle' contains 1 label & 1 entry widget. ## - 'fRplottypes' contains several radiobutton widgets. ## - 'fRxaxis' contains several label & entry widgets. ## - 'fRyaxis' contains several label & entry widgets. ## - 'fRzaxis' contains several label & entry widgets. ## - 'fRsurfopts' contains several label & entry widgets. ## - 'fRsurfview' contains several label & entry widgets. ## - 'fRcntropts' contains weveral label & entry widgets. ## - 'fRheatopts' contains several button widgets. ## - 'fRkeyopts' contains several label & entry widgets. ## - 'fRoutopts' contains a label and several radiobutton widgets ## and 2 pairs of label & entry widgets. ## - 'fRmsg' contains a label (or text) widget. ##+################################################################### ## FOR TESTING change 0 to 1: ## (Example1: To see appearance of frames when borders are drawn.) ## (Example2: To see sizes of frames for various '-fill' options.) ## (Example3: To see how frames expand as window is resized.) if {0} { set RELIEF_frame raised set BDwidthPx_frame 2 } else { set RELIEF_frame flat set BDwidthPx_frame 0 } frame .fRbuttons -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRleft -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRexpr -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRtitle -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRplottypes -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRxaxis -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRyaxis -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRzaxis -relief $RELIEF_frame -bd $BDwidthPx_frame # frame .fRbottom.fRright.fRsurfopts -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRsurfopts -relief raised -bd 2 frame .fRbottom.fRright.fRsurfview -relief $RELIEF_frame -bd $BDwidthPx_frame # frame .fRbottom.fRright.fRcntropts -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRcntropts -relief raised -bd 2 frame .fRbottom.fRright.fRheatopts -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRkeyopts -relief $RELIEF_frame -bd $BDwidthPx_frame # frame .fRbottom.fRright.fRoutopts -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRoutopts -relief raised -bd 2 frame .fRbottom.fRright.fRmsg -relief $RELIEF_frame -bd $BDwidthPx_frame ##+####################################################### ## PACK *ALL* the FRAMES. ##+####################################################### ## PACK THE FRAMES IN SEPARATELY, in order to ## experiment with different behaviors in window expansion. ##+####################################################### pack .fRbuttons \ -side top \ -anchor nw \ -fill x \ -expand 0 ##+##################### pack .fRbottom \ -side top \ -anchor nw \ -fill x \ -expand 1 pack .fRbottom.fRleft \ -side left \ -anchor nw \ -fill both \ -expand 0 pack .fRbottom.fRright \ -side left \ -anchor nw \ -fill x \ -expand 1 ##+##################### pack .fRbottom.fRright.fRexpr \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRtitle \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRplottypes \ -side top \ -anchor nw \ -fill none \ -expand 0 pack .fRbottom.fRright.fRxaxis \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRyaxis \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRzaxis \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRsurfopts \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRsurfview \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRcntropts \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRheatopts \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRkeyopts \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRoutopts \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRmsg \ -side top \ -anchor nw \ -fill x \ -expand 0 ##+################################################################ ## The frames are defined and packed. ##+################################################################ ##+############################################################### ## START DEFINING & PACKING WIDGETS WITHIN THEIR FRAMES. ##+############################################################### ##+############################################################### ##+####################################################### ## BUTTONS FRAME: ## IN THE '.fRbuttons' frame -- DEFINE ~6 BUTTON WIDGETs. ## THEN PACK EM. ##+####################################################### button .fRbuttons.buttEXIT \ -text "$aRtext(buttonEXIT)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command exit button .fRbuttons.buttHELP \ -text "$aRtext(buttonHELP)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {popup_msgVarWithScroll .topHelp "$HELPtext" +10+10} button .fRbuttons.buttPLOT \ -text "$aRtext(buttonPLOT)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command replot button .fRbuttons.buttLINEcolor \ -text "$aRtext(buttonCOLORLINE)" \ -font fontTEMP_SMALL_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_line_color "line"} button .fRbuttons.buttBKGDcolor \ -text "$aRtext(buttonCOLORBKGD)" \ -font fontTEMP_SMALL_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_bkgd_color "bkgd"} button .fRbuttons.buttCLEAREXPR \ -text "$aRtext(buttonCLEAREXPR)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command clear_expr button .fRbuttons.buttEXPR2TITLE \ -text "$aRtext(buttonEXPR2TITLE)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {set PlotTITLE "$ENTRYexpr"} button .fRbuttons.buttAUTOSCALE \ -text "$aRtext(buttonAUTOSCALE)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command set_autoscale ## This label is set in the 'Additional GUI Initialization' ## section, after the number of funcs in the listbox has been set. label .fRbuttons.labNUMFUNCS \ -text "" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label ##+######################################################## ## PACK the widgets of frame '.fRbuttons'. ##+######################################################## pack .fRbuttons.buttEXIT \ .fRbuttons.buttHELP \ .fRbuttons.buttPLOT \ .fRbuttons.buttLINEcolor \ .fRbuttons.buttBKGDcolor \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbuttons.buttCLEAREXPR \ .fRbuttons.buttEXPR2TITLE \ .fRbuttons.buttAUTOSCALE \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbuttons.labNUMFUNCS \ -side right \ -anchor e \ -fill none \ -expand 0 ##+######################################################## ## LISTBOX FRAME: ## IN THE '.fRbottom.fRleft' frame -- ## DEFINE A LISTBOX WIDGET with 2 scrollbars. THEN PACK EM. ##+######################################################## listbox .fRbottom.fRleft.listbox \ -width $initListboxWidthChars \ -height $initListboxHeightChars \ -font fontTEMP_fixedwidth \ -relief raised \ -borderwidth $BDwidthPx_listbox \ -state normal \ -yscrollcommand ".fRbottom.fRleft.scrbary set" \ -xscrollcommand ".fRbottom.fRleft.scrbarx set" scrollbar .fRbottom.fRleft.scrbary \ -orient vertical \ -command ".fRbottom.fRleft.listbox yview" scrollbar .fRbottom.fRleft.scrbarx \ -orient horizontal \ -command ".fRbottom.fRleft.listbox xview" ##+########################################################## ## INSERT MATH-EXPRESSION LISTBOX ENTRIES that hold ## a math-expression (in gnuplot-friendly format) ## --- followed, optionally, by a separator character (#) ## that may be followed by an arbitrary amount of ## descriptive info. ## ## We can have inactive 'commented' entries in the listbox: ## By putting a '#' at the beginning of a line, we signal ## that that line is just some text --- such as a heading for ## the next group of math-expressions. ##+########################################################################## ## Make sure the listbox is empty. .fRbottom.fRleft.listbox delete 0 end ## New MATH-EXPRESSIONS. f(x,y), are to be added here: .fRbottom.fRleft.listbox insert end {## Some POLYNOMIAL f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {(2.0*(x*x)) + (2.0*(y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {(1.0*x*x) - (1.0*y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {(2.0-(x*x+y*y))*(2.0-(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {10.0 - (1.0*x*x) - (3.0*y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {(0.5*x*x*x) - (0.5*y*y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {x*(0.5-x) * (0.5-(y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some SIN-COS f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {sin(2.0*pi*x)*cos(2.0*pi*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {cos(1.5*pi*x)*cos(1.5*pi*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {(x*x+y*y) * cos(1.0*pi*x)*cos(1.0*pi*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {cos(2.0*pi*x)*cos(2.0*pi*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {cos(2.0*pi * x) * sin(2.0*pi * y) # Description can go here.} .fRbottom.fRleft.listbox insert end {x * y * cos( 2.0 * (x * x) + 2.0 * (y * y) ) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some SQUARE ROOT f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {-sqrt(2.0*(x*x) + 2.0*(y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {0.5*cos(8.0*sqrt(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {sin(2.0*pi*sqrt((x*x) + (y*y))) # Description can go here.} .fRbottom.fRleft.listbox insert end {0.5*cos(8.0*sqrt(x*x+y*y))*cos(8.0*sqrt(x*x+y*y)) * exp(-1.5*sqrt(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {sin(sqrt(30*2.0*pi*(x*x + y*y + 0.001))) / sqrt(30*2.0*pi*(x*x + y*y + 0.001)) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some LINEAR f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {(-1.0 * x) * (1.0 * y) # Description can go here.} .fRbottom.fRleft.listbox insert end {-1.0*x - 1.0*y + 1.0 # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some EXPONENTIAL f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {-2.0*(x + y) * exp(-6.*(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.0*sin(pi*(x + y))*sin(pi*(x + y)) * exp(-3.*(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {6.0*(x*x+y*y) * exp(-2.0*(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {(6.0*(x*x-y*y)) * exp(-6.*(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {(2.0 - (0.1*x*x + 19.0*y*y*y)) * exp(-2.5*(x*x + y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {0.5*x*y*y*exp(0.5*(x + y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some INVERSE POLYNOMIAL f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {4.0 / (1.0 + x*x*x*x + y*y*y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some MIXED POLYNOMIAL/TRIG/EXPONENTIAL/LINEAR/RATIONAL f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {0.5*y*y + 1 - cos(pi*x) # Description can go here.} .fRbottom.fRleft.listbox insert end {0.5*exp(-1.0*x) * sin(pi*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.5*x*x*x * sin(1.5*2.0*pi*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.0*cos(2.0*2.0*pi*x*y) / (1.0 + 9.0*y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.0*cos(2.0*pi*(x+y)) / (1.0 + 8.0*(x-y)*(x-y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.0*sin(1.0*2.0*pi*y*y) + (2.5 / (1.0 + 6.0*x*x + 6.0*y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.0*cos(pi*x)*cos(pi*(x+y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {1.0*y*cos(pi*x)*cos(pi*(x*x+y*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some ABSOLUTE-VALUE f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {sqrt(abs(x)*abs(y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some MAX/CEIL/FLOOR f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {0.45*max(x,y) # Description can go here.} .fRbottom.fRleft.listbox insert end {-ceil(5.5*max(0.5*x,0.5*y)) # Description can go here.} .fRbottom.fRleft.listbox insert end {-0.2*ceil(2.*x)*ceil(2.*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {0.1*floor(2.*x)*floor(2.*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {-0.2*ceil(max(2.*x+.1,2.*y+.1)) # Description can go here.} .fRbottom.fRleft.listbox insert end {-x*x*ceil(y) # Description can go here.} .fRbottom.fRleft.listbox insert end {-0.2*x*x*ceil(3.0*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {-ceil(0.5*x)*ceil(0.5*y)/(1+x*x+y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {-0.5*ceil(2.5*x*x)*ceil(2.5*y*y) # Description can go here.} .fRbottom.fRleft.listbox insert end {## Some CONSTANT f(x,y) expressions:} .fRbottom.fRleft.listbox insert end {0.0 # Description can go here.} .fRbottom.fRleft.listbox insert end {1000.0 # Description can go here.} ##+############################################################## ## Get the number of math-expressions loaded into the listbox --- ## to show users how many are in the listbox, maybe out of sight. ##+############################################################## set numLinesInListbox [.fRbottom.fRleft.listbox index end] .fRbuttons.labNUMFUNCS configure -text "Lines in listbox: $numLinesInListbox" ##+#################################### ## Pack the listbox and its scrollbars. ##+#################################### ## We pack the listbox AFTER ## the scrollbars, to get the scrollbars ## positioned properly --- BEFORE ## the listbox FILLS the pack area. ##+#################################### pack .fRbottom.fRleft.scrbary \ -side right \ -anchor e \ -fill y \ -expand 0 pack .fRbottom.fRleft.scrbarx \ -side bottom \ -anchor s \ -fill x \ -expand 0 pack .fRbottom.fRleft.listbox \ -side top \ -anchor nw \ -fill both \ -expand 1 ##+######################################################## ## EXPR FRAME: ## IN THE '.fRbottom.fRright.fRexpr' frame -- ## DEFINE 1 pair of LABEL, ENTRY WIDGETs. THEN PACK EM. ##+######################################################## label .fRbottom.fRright.fRexpr.lab \ -text "$aRtext(labelEXPR)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label entry .fRbottom.fRright.fRexpr.ent \ -textvariable ENTRYexpr \ -width $initExpressionWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK all widgets in frame '.fRbottom.fRright.fRexpr' ## --- individually, to allow the entry widget to expand. pack .fRbottom.fRright.fRexpr.lab \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRexpr.ent \ -side left \ -anchor w \ -fill x \ -expand 1 ##+######################################################## ## TITLE FRAME: ## IN THE '.fRbottom.fRright.fRtitle' frame -- ## DEFINE 1 pair of LABEL, ENTRY WIDGETs. THEN PACK EM. ##+######################################################## label .fRbottom.fRright.fRtitle.lab \ -text "$aRtext(labelPLOTTITLE)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label entry .fRbottom.fRright.fRtitle.ent \ -textvariable PlotTITLE \ -width $initTitleWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK all widgets in frame '.fRbottom.fRright.fRtitle' ## --- individually, to allow the entry widget to expand. pack .fRbottom.fRright.fRtitle.lab \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRtitle.ent \ -side left \ -anchor w \ -fill x \ -expand 1 ##+####################################################### ## PLOTTYPES FRAME: ## IN THE '.fRbottom.fRright.fRplottypes' frame -- ## DEFINE 5 RADIOBUTTON WIDGETS. THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRplottypes.labelPLOTTYPES \ -text "$aRtext(labelPLOTTYPE)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo radiobutton .fRbottom.fRright.fRplottypes.radbuttSURF \ -text "$aRtext(radbuttSURF)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "surf" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRplottypes.radbuttCONT \ -text "$aRtext(radbuttCONT)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "cont" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRplottypes.radbuttHEAT \ -text "$aRtext(radbuttHEAT)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "heat" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRplottypes.radbuttSURFCONT \ -text "$aRtext(radbuttSURFCONT)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "surfcont" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRplottypes.radbuttCONTHEAT \ -text "$aRtext(radbuttCONTHEAT)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "contheat" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi ## PACK all the widgets in the '.fRbottom.fRright.fRplottypes' frame. pack .fRbottom.fRright.fRplottypes.labelPLOTTYPES \ .fRbottom.fRright.fRplottypes.radbuttSURF \ .fRbottom.fRright.fRplottypes.radbuttCONT \ .fRbottom.fRright.fRplottypes.radbuttHEAT \ .fRbottom.fRright.fRplottypes.radbuttSURFCONT \ .fRbottom.fRright.fRplottypes.radbuttCONTHEAT \ -side left \ -anchor w \ -fill none \ -expand 0 ##+######################################################## ## XAXIS FRAME: ## IN THE '.fRbottom.fRright.fRxaxis' frame -- ## DEFINE several LABEL & ENTRY WIDGETS for x-axis. ## AND PACK the widgets. ##+######################################################## ## Rather than adding another frame-level to keep ## entry fields lined up nicely, we try using a common ## width for the min, max, angle labels for the entry fields. ## (This might result in some clipping of the labels ## for certain font choices.) set minWIDTHchars 4 set maxWIDTHchars 6 set angleWIDTHchars 13 label .fRbottom.fRright.fRxaxis.labXmin \ -text "$aRtext(labelXMIN)" \ -font fontTEMP_varwidth \ -width $minWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRxaxis.entXmin \ -textvariable Xmin \ -width 7 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRxaxis.labXmax \ -text "$aRtext(labelXMAX)" \ -font fontTEMP_varwidth \ -width $maxWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRxaxis.entXmax \ -textvariable Xmax \ -width 7 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRxaxis.labXTICLABELangle \ -text "$aRtext(labelXTICLABELangle)" \ -font fontTEMP_varwidth \ -width $angleWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRxaxis.entXTICLABELangle \ -textvariable XTICLABELangle \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+########################################### ## Define an ENTRY widget for the x-axis title. ## We will allow this widget to x-expand. ##+########################################### entry .fRbottom.fRright.fRxaxis.entXTITLE \ -textvariable XaxisTITLE \ -width $initTitleWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+######################################################### ## PACK all the widgets in frame '.fRbottom.fRright.fRxaxis'. ##+######################################################### pack .fRbottom.fRright.fRxaxis.labXmin \ .fRbottom.fRright.fRxaxis.entXmin \ .fRbottom.fRright.fRxaxis.labXmax \ .fRbottom.fRright.fRxaxis.entXmax \ .fRbottom.fRright.fRxaxis.labXTICLABELangle \ .fRbottom.fRright.fRxaxis.entXTICLABELangle \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRxaxis.entXTITLE \ -side left \ -anchor w \ -fill x \ -expand 1 ##+####################################################### ## YAXIS FRAME: ## IN THE '.fRbottom.fRright.fRyaxis' frame -- ## DEFINE several LABEL & ENTRY WIDGETS for the y-axis. ## THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRyaxis.labYmin \ -text "$aRtext(labelYMIN)" \ -font fontTEMP_varwidth \ -width $minWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRyaxis.entYmin \ -textvariable Ymin \ -width 7 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRyaxis.labYmax \ -text "$aRtext(labelYMAX)" \ -font fontTEMP_varwidth \ -width $maxWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRyaxis.entYmax \ -textvariable Ymax \ -width 7 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRyaxis.labYTICLABELangle \ -text "$aRtext(labelYTICLABELangle)" \ -font fontTEMP_varwidth \ -width $angleWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRyaxis.entYTICLABELangle \ -textvariable YTICLABELangle \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+####################################################### ## For the y axis title, DEFINE 1 ENTRY WIDGET. ## We will allow this widget to x-expand. ##+####################################################### entry .fRbottom.fRright.fRyaxis.entYTITLE \ -textvariable YaxisTITLE \ -width $initTitleWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+######################################################### ## PACK all the widgets in frame '.fRbottom.fRright.fRyaxis'. ##+######################################################### pack .fRbottom.fRright.fRyaxis.labYmin \ .fRbottom.fRright.fRyaxis.entYmin \ .fRbottom.fRright.fRyaxis.labYmax \ .fRbottom.fRright.fRyaxis.entYmax \ .fRbottom.fRright.fRyaxis.labYTICLABELangle \ .fRbottom.fRright.fRyaxis.entYTICLABELangle \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRyaxis.entYTITLE \ -side left \ -anchor w \ -fill x \ -expand 1 ##+####################################################### ## ZAXIS FRAME: ## IN THE '.fRbottom.fRright.fRzaxis' frame -- ## DEFINE several LABEL & ENTRY WIDGETS for the z-axis. ## THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRzaxis.labZmin \ -text "$aRtext(labelZMIN)" \ -font fontTEMP_varwidth \ -width $minWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRzaxis.entZmin \ -textvariable Zmin \ -width 7 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRzaxis.labZmax \ -text "$aRtext(labelZMAX)" \ -font fontTEMP_varwidth \ -width $maxWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRzaxis.entZmax \ -textvariable Zmax \ -width 7 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRzaxis.labZTICLABELangle \ -text "$aRtext(labelZTICLABELangle)" \ -font fontTEMP_varwidth \ -width $angleWIDTHchars \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRzaxis.entZTICLABELangle \ -textvariable ZTICLABELangle \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+####################################################### ## For the z axis title, DEFINE 1 ENTRY WIDGET. ## We will allow this widget to x-expand. ##+####################################################### entry .fRbottom.fRright.fRzaxis.entZTITLE \ -textvariable ZaxisTITLE \ -width $initTitleWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+######################################################### ## PACK all the widgets in frame '.fRbottom.fRright.fRzaxis'. ##+######################################################### pack .fRbottom.fRright.fRzaxis.labZmin \ .fRbottom.fRright.fRzaxis.entZmin \ .fRbottom.fRright.fRzaxis.labZmax \ .fRbottom.fRright.fRzaxis.entZmax \ .fRbottom.fRright.fRzaxis.labZTICLABELangle \ .fRbottom.fRright.fRzaxis.entZTICLABELangle \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRzaxis.entZTITLE \ -side left \ -anchor w \ -fill x \ -expand 1 ##+####################################################### ## SURFOPTS FRAME: ## IN THE '.fRbottom.fRright.fRsurfopts' frame -- ## DEFINE several pairs of LABEL & ENTRY WIDGETs. ## THEN PACK THEM. ##+####################################################### label .fRbottom.fRright.fRsurfopts.labelSURFsamplesXY \ -text "$aRtext(labelSURFsamplesXY)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo entry .fRbottom.fRright.fRsurfopts.entXSAMPLES \ -textvariable ENTRYsurfaceSamplesX \ -width 4 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry entry .fRbottom.fRright.fRsurfopts.entYSAMPLES \ -textvariable ENTRYsurfaceSamplesY \ -width 4 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+######################################################## ## Make a checkbutton to indicate a shaded-surface plot ## is desired instead of a surface-hatched-lines plot. ## ## When this checkbutton is turned on, the HATCHTYPE entry ## field could be disabled, to indicate that hatching ## will not be done if shaded-mode is chosen. ##+######################################################## checkbutton .fRbottom.fRright.fRsurfopts.chkbuttSHADED \ -variable ShadedSurface_0or1 \ -text "$aRtext(chkbuttSHADED)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -selectcolor "$checkbuttBKGD" \ -bd $BDwidthPx_chkbutt \ -relief $RELIEF_chkbutt_hi label .fRbottom.fRright.fRsurfopts.labelHATCHTYPE \ -text "$aRtext(labelHATCHTYPE)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo entry .fRbottom.fRright.fRsurfopts.entHATCHTYPE \ -textvariable ENTRYhatchtype \ -width 1 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+########################################################### ## PACK all the widgets in frame '.fRbottom.fRright.fRsurfopts'. ##+########################################################### pack .fRbottom.fRright.fRsurfopts.labelSURFsamplesXY \ .fRbottom.fRright.fRsurfopts.entXSAMPLES \ .fRbottom.fRright.fRsurfopts.entYSAMPLES \ .fRbottom.fRright.fRsurfopts.chkbuttSHADED \ .fRbottom.fRright.fRsurfopts.labelHATCHTYPE \ .fRbottom.fRright.fRsurfopts.entHATCHTYPE \ -side left \ -anchor w \ -fill none \ -expand 0 ##+####################################################### ## SURFVIEW FRAME: ## IN THE '.fRbottom.fRright.fRsurfview' frame -- ## DEFINE several pairs of LABEL & ENTRY WIDGETS. ## THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRsurfview.labPOLAR \ -text "$aRtext(labelPOLAR)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRsurfview.entPOLAR \ -textvariable ENTRYpolarAngle \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRsurfview.labAZIMUTHAL \ -text "$aRtext(labelAZIMUTHAL)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRsurfview.entAZIMUTHAL \ -textvariable ENTRYazimuthalAngle \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry button .fRbottom.fRright.fRsurfview.buttOVERHEAD \ -text "$aRtext(buttonOVERHEAD)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command set_overhead_view_angles button .fRbottom.fRright.fRsurfview.buttOBLIQUE \ -text "$aRtext(buttonOBLIQUE)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command set_oblique_view_angles ##+############################################################ ## PACK all the widgets in frame '.fRbottom.fRright.fRsurfview'. ##+############################################################ pack .fRbottom.fRright.fRsurfview.labPOLAR \ .fRbottom.fRright.fRsurfview.entPOLAR \ .fRbottom.fRright.fRsurfview.labAZIMUTHAL \ .fRbottom.fRright.fRsurfview.entAZIMUTHAL \ .fRbottom.fRright.fRsurfview.buttOVERHEAD \ .fRbottom.fRright.fRsurfview.buttOBLIQUE \ -side left \ -anchor w \ -fill none \ -expand 0 ##+####################################################### ## CNTROPTS FRAME: ## IN THE '.fRbottom.fRright.fRcntropts' frame -- ## DEFINE several pairs of LABEL & ENTRY WIDGETS. ## THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRcntropts.labLEVELS \ -text "$aRtext(labelLEVELS)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRcntropts.entLEVELS \ -textvariable ENTRYcontourLevels \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRcntropts.labCONTsamplesXY \ -text "$aRtext(labelCONTsamplesXY)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRcntropts.entCONTsamplesX \ -textvariable ENTRYcontourSamplesX \ -width 4 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry entry .fRbottom.fRright.fRcntropts.entCONTsamplesY \ -textvariable ENTRYcontourSamplesY \ -width 4 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRcntropts.labLINEWIDTH \ -text "$aRtext(labelLINEWIDTH)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRcntropts.entLINEWIDTH \ -textvariable ENTRYcontourLineWidth \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+############################################################ ## PACK all the widgets in frame '.fRbottom.fRright.fRcntropts'. ##+############################################################ pack .fRbottom.fRright.fRcntropts.labLEVELS \ .fRbottom.fRright.fRcntropts.entLEVELS \ .fRbottom.fRright.fRcntropts.labCONTsamplesXY \ .fRbottom.fRright.fRcntropts.entCONTsamplesX \ .fRbottom.fRright.fRcntropts.entCONTsamplesY \ .fRbottom.fRright.fRcntropts.labLINEWIDTH \ .fRbottom.fRright.fRcntropts.entLINEWIDTH \ -side left \ -anchor w \ -fill none \ -expand 0 ##+####################################################### ## HEATOPTS (palette) FRAME: ## IN THE '.fRbottom.fRright.fRheatopts' frame -- ## DEFINE several pairs of LABEL & ENTRY WIDGETS. ## THEN PACK the widgets. ##+####################################################### set buttWIDTHchars 5 label .fRbottom.fRright.fRheatopts.labHEATCOLORS \ -text "$aRtext(labelHEATCOLORS)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w button .fRbottom.fRright.fRheatopts.buttLOWCOLOR \ -text "$aRtext(buttonLOWCOLOR)" \ -font fontTEMP_varwidth \ -width $buttWIDTHchars \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_color "low"} entry .fRbottom.fRright.fRheatopts.entLOWCOLORLOC \ -textvariable ENTRYcolorLocLOW \ -width 2 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry button .fRbottom.fRright.fRheatopts.buttLOWMIDCOLOR \ -text "$aRtext(buttonLOWMIDCOLOR)" \ -font fontTEMP_varwidth \ -width $buttWIDTHchars \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_color "lowmid"} entry .fRbottom.fRright.fRheatopts.entLOWMIDCOLORLOC \ -textvariable ENTRYcolorLocLOWMID \ -width 2 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry button .fRbottom.fRright.fRheatopts.buttMIDCOLOR \ -text "$aRtext(buttonMIDCOLOR)" \ -font fontTEMP_varwidth \ -width $buttWIDTHchars \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_color "mid"} entry .fRbottom.fRright.fRheatopts.entMIDCOLORLOC \ -textvariable ENTRYcolorLocMID \ -width 2 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry button .fRbottom.fRright.fRheatopts.buttHIGHMIDCOLOR \ -text "$aRtext(buttonHIGHMIDCOLOR)" \ -font fontTEMP_varwidth \ -width $buttWIDTHchars \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_color "highmid"} entry .fRbottom.fRright.fRheatopts.entHIGHMIDCOLORLOC \ -textvariable ENTRYcolorLocHIGHMID \ -width 2 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry button .fRbottom.fRright.fRheatopts.buttHIGHCOLOR \ -text "$aRtext(buttonHIGHCOLOR)" \ -font fontTEMP_varwidth \ -width $buttWIDTHchars \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_color "high"} entry .fRbottom.fRright.fRheatopts.entHIGHCOLORLOC \ -textvariable ENTRYcolorLocHIGH \ -width 2 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry button .fRbottom.fRright.fRheatopts.buttSHOPALETTE \ -text "$aRtext(buttonSHOPALETTE)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command show_palette_gradient ##+############################################################ ## PACK all the widgets in frame '.fRbottom.fRright.fRheatopts'. ##+############################################################ pack .fRbottom.fRright.fRheatopts.labHEATCOLORS \ .fRbottom.fRright.fRheatopts.buttLOWCOLOR \ .fRbottom.fRright.fRheatopts.entLOWCOLORLOC \ .fRbottom.fRright.fRheatopts.buttLOWMIDCOLOR \ .fRbottom.fRright.fRheatopts.entLOWMIDCOLORLOC \ .fRbottom.fRright.fRheatopts.buttMIDCOLOR \ .fRbottom.fRright.fRheatopts.entMIDCOLORLOC \ .fRbottom.fRright.fRheatopts.buttHIGHMIDCOLOR \ .fRbottom.fRright.fRheatopts.entHIGHMIDCOLORLOC \ .fRbottom.fRright.fRheatopts.buttHIGHCOLOR \ .fRbottom.fRright.fRheatopts.entHIGHCOLORLOC \ -side left \ -anchor w \ -fill y \ -expand 0 pack .fRbottom.fRright.fRheatopts.buttSHOPALETTE \ -side right \ -anchor e \ -fill y \ -expand 0 ##+####################################################### ## KEYOPTS FRAME: ## IN THE '.fRbottom.fRright.fRkeyopts' frame -- ## DEFINE several pairs of LABEL & ENTRY WIDGETS. ## THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRkeyopts.labNUMFORMAT \ -text "$aRtext(labelNUMFORMAT)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRkeyopts.entNUMFORMAT \ -textvariable ENTRYkeyNumFormat \ -width 6 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRkeyopts.labNUMFMTEXAMPLES \ -text "$aRtext(labelNUMFMTEXAMPLES)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w label .fRbottom.fRright.fRkeyopts.labKEYLOC \ -text "$aRtext(labelKEYLOC)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRkeyopts.entKEYLOC \ -textvariable ENTRYkeyLocation \ -width 20 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK all the widgets in frame '.fRbottom.fRright.fRkeyopts'. pack .fRbottom.fRright.fRkeyopts.labNUMFORMAT \ .fRbottom.fRright.fRkeyopts.entNUMFORMAT \ .fRbottom.fRright.fRkeyopts.labNUMFMTEXAMPLES \ .fRbottom.fRright.fRkeyopts.labKEYLOC \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRkeyopts.entKEYLOC \ -side left \ -anchor w \ -fill x \ -expand 1 ##+####################################################### ## OUTOPTS FRAME: ## IN THE '.fRbottom.fRright.fRoutopts' frame -- ## DEFINE a LABEL WIDGET with several RADIOBUTTON widgets ## (for GIF, PNG, JPEG, PS, SVG) and ## 2 pairs of LABEL & ENTRY WIDGET (for x,y pixels). ## THEN PACK THEM. ##+####################################################### ## DEFINE a LABEL and RADIOBUTTONS for IMAGE OUTPUT TYPE : ## (gif or png or jpg or ps or svg) label .fRbottom.fRright.fRoutopts.labelOUTTYPE \ -text "$aRtext(labelOUTTYPE)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo radiobutton .fRbottom.fRright.fRoutopts.radbuttGIF \ -text "$aRtext(radbuttGIF)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "gif" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRoutopts.radbuttPNG \ -text "$aRtext(radbuttPNG)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "png" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRoutopts.radbuttJPG \ -text "$aRtext(radbuttJPG)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "jpg" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRoutopts.radbuttPS \ -text "$aRtext(radbuttPS)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "ps" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRoutopts.radbuttPSbw \ -text "$aRtext(radbuttPSbw)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "psbw" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRoutopts.radbuttSVG \ -text "$aRtext(radbuttSVG)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "svg" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRoutopts.radbuttWXT \ -text "$aRtext(radbuttWXT)" \ -font fontTEMP_SMALL_varwidth \ -anchor w \ -variable RADVARoutimg \ -value "wxt" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi button .fRbottom.fRright.fRoutopts.buttTESTimg \ -text "$aRtext(buttonTESTimg)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command display_test_img label .fRbottom.fRright.fRoutopts.labelXPIXELS \ -text "$aRtext(labelXPIXELS)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo entry .fRbottom.fRright.fRoutopts.entXPIXELS \ -textvariable ENTRYxpixels \ -width 5 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRoutopts.labelYPIXELS \ -text "$aRtext(labelYPIXELS)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo entry .fRbottom.fRright.fRoutopts.entYPIXELS \ -textvariable ENTRYypixels \ -width 5 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK all the widgets in frame '.fRbottom.fRright.fRoutopts'. pack .fRbottom.fRright.fRoutopts.labelOUTTYPE \ .fRbottom.fRright.fRoutopts.radbuttGIF \ .fRbottom.fRright.fRoutopts.radbuttPNG \ .fRbottom.fRright.fRoutopts.radbuttJPG \ .fRbottom.fRright.fRoutopts.radbuttPS \ .fRbottom.fRright.fRoutopts.radbuttPSbw \ .fRbottom.fRright.fRoutopts.radbuttSVG \ .fRbottom.fRright.fRoutopts.radbuttWXT \ .fRbottom.fRright.fRoutopts.buttTESTimg \ -side left \ -anchor center \ -fill none \ -expand 0 pack .fRbottom.fRright.fRoutopts.labelXPIXELS \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRoutopts.entXPIXELS \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRoutopts.labelYPIXELS \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRoutopts.entYPIXELS \ -side left \ -anchor w \ -fill none \ -expand 0 ##+####################################################### ## IN THE '.fRbottom.fRrightfRmsg' frame -- ## DEFINE a LABEL (or TEXT) widget. THEN PACK IT. ##+####################################################### label .fRbottom.fRright.fRmsg.labelMSG \ -font fontTEMP_fixedwidth \ -bg "#33ff33" \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_hi ## PACK the widgets in frame '.fRbottom.fRright.fRmsg'. pack .fRbottom.fRright.fRmsg.labelMSG \ -side left \ -anchor w \ -fill x \ -expand 1 ##+################################################################# ##+ Frames and their widgets are defined and packed. ##+################################################################# ##+################################################################# ## END OF MAIN GUI BUILDING SECTION. ##+################################################################# ##+################################################################# ##+################################################################## ##+################################################################## ## DEFINE BINDINGS -- for mouse/keboard actions: ##+################################################################## ##+################################################################## bind .fRbottom.fRleft.listbox {listboxSelectionTOexprField} ## We could add a button1-release binding on the 'ShadedSurface?' checkbutton, ## to disable the HatchType entry field if shaded-surface is chosen, ## and enable the HatchType entry field if shaded-surface is off. ##+################################################################## ##+################################################################## ## DEFINE PROCEDURES: ## ## 'listboxSelectionTOexprField' - called by button1-release binding ## on the listbox ## ## 'clear_expr' - called by 'ClearExpr' button ## ## 'set_autoscale' - called by 'Autoscale' button ## ## 'replot' - called by 'RePlot' button, to build and ## execute a 'gnuplot' script. The following ## 'plot_*' procs build the script appropriate ## to the selected plot-type. ## ## 'plot_surface' - called by 'replot' proc ## 'plot_contour' - called by 'replot' proc ## 'plot_heatmap' - called by 'replot' proc ## 'plot_surface-contour' - called by 'replot' proc ## 'plot_contour-heatmap' - called by 'replot' proc ## ## 'edit_inputs' - called by 'plot_*' procs ## ## 'display_test_img' - called by 'TestImg' button ## 'show_palette_gradient' - called by 'ShoPalette' button ## ## 'getset_color' - called by 'LineColor', 'BkgdColor', and ## 5 heatmap/palette-color buttons ## ## 'update_color_button' - called by 'getset_color' proc and 5 times in ## the 'Additional GUI Initialization' section. ## ## 'set_overhead_view_angles' - called by an 'OverheadView' button ## 'set_oblique_view_angles' - called by an 'ObliqueView' button ## ## 'popup_msgVarWithScroll' - called by 'Help' button to show HELPtext var. ## ##+################################################################## ##+################################################################## ##+######################################################################### ## proc 'listboxSelectionTOexprField' ##+######################################################################### ## PURPOSE: Loads the ENTRYexpr variable ## depending on the math-expression listbox line selected. ## ## CALLED BY: button1-release on the listbox ## ## See the listbox ' insert ' statements (where the listbox widget was ## defined) for the math expression strings that were loaded in the listbox. ##+######################################################################### proc listboxSelectionTOexprField {} { global ENTRYexpr set sel_index [ .fRbottom.fRleft.listbox curselection ] if { $sel_index != "" } { set ExprLine [ .fRbottom.fRleft.listbox get $sel_index ] set TEMPlist [split $ExprLine #] set HOLDexpr [lindex $TEMPlist 0] set HOLDexpr [string trim $HOLDexpr] } else {return} ## FOR TESTING: # puts "proc 'listboxSelectionTOexprField' > HOLDexpr: $HOLDexpr" if {"$HOLDexpr" == ""} {return} ##################################################################################### ## Load the math-expression entry field of the GUI. ##################################################################################### set ENTRYexpr "$HOLDexpr" } ## END OF PROC 'listboxSelectionTOexprField' ##+##################################################################### ## proc 'clear_expr' ##+##################################################################### ## PURPOSE: Clear the math expression field. ## ## CALLED BY: .fRbuttons.buttCLEAR ##+##################################################################### proc clear_expr {} { global ENTRYexpr set ENTRYexpr "" } ## END OF PROC 'clear_expr' ##+##################################################################### ## proc 'set_autoscale' ##+##################################################################### ## PURPOSE: Set Xmin,Xmax,Ymin,Ymax,Zmin,Zmax input fields to asterisks ## --- to cause a plot to autoscale. ## ## CALLED BY: .fRbuttons.buttAUTOSCALE ##+##################################################################### proc set_autoscale {} { global Xmin Xmax Ymin Ymax Zmin Zmax set Xmin "*" set Xmax "*" set Ymin "*" set Ymax "*" set Zmin "*" set Zmax "*" } ## END OF PROC 'set_autoscale' ##+#################################################################### ## PROC: 'replot' ##+#################################################################### ## PURPOSE: ## Calls on a 'plot_*' proc to builds a 'gnuplot' script. ## Chooses the proc according to the current setting of the ## plot-type radiobuttons variable, RADVARplottype. ## ## CALLED BY: button .fRbuttons.buttPLOT ##+#################################################################### proc replot {} { global RADVARplottype if {"$RADVARplottype" == "surf"} {plot_surface} if {"$RADVARplottype" == "cont"} {plot_contour} if {"$RADVARplottype" == "heat"} {plot_heatmap} if {"$RADVARplottype" == "surfcont"} {plot_surface-contour} if {"$RADVARplottype" == "contheat"} {plot_contour-heatmap} } ## END OF proc 'replot' ##+#################################################################### ## PROC: 'set_output_vars' ##+#################################################################### ## PURPOSE: Uses the 'RADVARoutimg' variable to set variables ## IMGfile and IMGviewer and to put a 'set terminal' ## and a 'set output' command in the OUTscript. ## ## CALLED BY: the 'plot_surface', 'plot_contour', 'plot_heatmap', ## 'plot_surface-contour', and 'plot_contour-heatmap' procs ##+################################################################### proc set_output_vars {} { ## 'In' variables: global RADVARoutimg IMGFILEprefix SHout ## OUTscript var not needed? global COLORBKGDhex COLORAXIShex global ENTRYxpixels ENTRYypixels global GIFviewer PNGviewer JPGviewer PSviewer SVGviewer ## 'Out' variables: global IMGfile IMGviewer ## Set output (terminal) type and ## set a filename for the output image file. ## ## Common options for all bitmap terminals: ## set terminal XXX [size {int:x}, {int:y} ] [ {no]crop ] ## [font [ {str:name} [ {int:size} ] ] ## | [ "{str:path} [, (int:size} ]" ] ] ## [ [no]enhanced ] [ rounded | butt ] ## [ (color0) (color1) (color2) ... ] ## NOTE: ## 'The first color (color0) will be used for the background, ## the second color for the border, the third for the axes (when ## using 'set zeroaxis', for instance). All remaining colors are ## used for consecutive line types. The format for the color ## specification consists of a hex string preceded by the ## letter x, for example xFF0000 for red, and so on." ## ## 'enhanced' mode is to handle special text, such as subscripts, ## superscripts, and font changes. ## ## Reference: pages 342-344 of book "Gnuplot in Action" set xCOLORBKGDhex [string replace "$COLORBKGDhex" 0 0 "x"] set xCOLORAXIShex [string replace "$COLORAXIShex" 0 0 "x"] if {"$RADVARoutimg" == "gif"} { puts $SHout "set terminal gif size $ENTRYxpixels , $ENTRYypixels \ nocrop noenhanced butt $xCOLORBKGDhex $xCOLORAXIShex $xCOLORAXIShex" set IMGfile "${IMGFILEprefix}.gif" set IMGviewer "$GIFviewer" } if {"$RADVARoutimg" == "png"} { puts $SHout "set terminal png size $ENTRYxpixels , $ENTRYypixels \ nocrop noenhanced butt $xCOLORBKGDhex $xCOLORAXIShex $xCOLORAXIShex" set IMGfile "${IMGFILEprefix}.png" set IMGviewer "$PNGviewer" } if {"$RADVARoutimg" == "jpg"} { puts $SHout "set terminal jpeg size $ENTRYxpixels , $ENTRYypixels \ nocrop noenhanced butt $xCOLORBKGDhex $xCOLORAXIShex $xCOLORAXIShex" set IMGfile "${IMGFILEprefix}.jpg" set IMGviewer "$JPGviewer" } ########################################## ## Common options for Postscript terminal: ## set terminal postscript [landscape | portrait | eps ] ## [ color | mono ] [ blacktext | colortext ] ## [ simplex | duplex | defaultplex ] ## [ size {flt:x}[in|cm], {flt:y}[in,cm] ] ## [font [ {str:name} [ {int:size} ] ] ## [ [no]enhanced ] [ rounded | butt ] ## [ solid | dashed ] ## [ linewidth | lw {flt:factor} ] ## [ dashlength | dl {flt:factor} ] if {"$RADVARoutimg" == "ps"} { puts $SHout "set terminal postscript landscape color colortext simplex \ noenhanced butt dashed size 8.0in, 6.0in" set IMGfile "${IMGFILEprefix}.ps" set IMGviewer "$PSviewer" } if {"$RADVARoutimg" == "psbw"} { puts $SHout "set terminal postscript landscape mono blacktext simplex \ noenhanced butt dashed size 8.0in, 6.0in" set IMGfile "${IMGFILEprefix}.ps" set IMGviewer "$PSviewer" } ########################################## ## Common options for SVG (scalable vector graphics) terminal: ## set terminal svg [ size {int:x},{int:y} [ fixed | dynamic ] ] ## [font "{str:name} [, {int:size} ]" ] ## [fontfile "{str:filename}" ] ## [ [no]enhanced ] [ rounded | butt ] ## [ linewidth {flt:factor} ] if {"$RADVARoutimg" == "svg"} { puts $SHout "set terminal svg size $ENTRYxpixels , $ENTRYypixels dynamic \ noenhanced butt" set IMGfile "${IMGFILEprefix}.svg" set IMGviewer "$SVGviewer" } if {"$RADVARoutimg" == "wxt"} { puts $SHout "set terminal wxt persist title \"WXT terminal window\"" set IMGfile "" set IMGviewer "" } if {"$IMGfile" != ""} { puts $SHout "set output '$IMGfile'" } } ## END OF proc 'set_output_vars' ##+#################################################################### ## PROC: 'plot_surface' ##+#################################################################### ## PURPOSE: ## Builds a 'gnuplot' script to do a 3D surface plot, ## using the math expression and parameters from the GUI. ## ## Then executes that gnuplot-script and shows the resulting image ## file in an image viewer (set at the bottom of this Tk script) ## --- or, at least, tells the name of the output image file, in ## a message area of the GUI. ## ## Arguments: passed in Tcl-Tk global variables. ## ## CALLED BY: the 'replot' proc ###################################################################### proc plot_surface {} { global OUTscript SHout IMGFILEprefix global ENTRYexpr PlotTITLE XaxisTITLE YaxisTITLE ZaxisTITLE global Xmin Xmax Ymin Ymax Zmin Zmax global XTICLABELangle YTICLABELangle ZTICLABELangle global ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY global ShadedSurface_0or1 ENTRYhatchtype HATCHlineWIDTH global ENTRYpolarAngle ENTRYazimuthalAngle ## Not needed for 3D surface plot: (?) # global ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY ENTRYcontourLineWidth global ENTRYkeyNumFormat ENTRYkeyLocation global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global IMGfile IMGviewer global ENTRYxpixels ENTRYypixels global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global EDITcode ## Call a proc to check for invalid inputs, esp. in entry fields. edit_inputs if {$EDITcode > 0} {return} ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ## Set a working directory for gnuplot. ## gnuplot may put 'extra' files here. puts $SHout "! cd /tmp" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################### ## Set plot title. puts $SHout "set title '$PlotTITLE'" ############################################# ## Set TIMESTAMP (at bottom-left of plot): ## Y=yyyy b=mmm d=dd a=day-of-week HMS=hours-mins-secs puts $SHout "set timestamp '%Y %b %d %a %H:%M:%S'" ################################################ ## Issue commands to setup for a 3D SURFACE PLOT: ##################################### ## Set xyz axis labels. puts $SHout "set xlabel '$XaxisTITLE'" puts $SHout "set ylabel '$YaxisTITLE'" puts $SHout "set zlabel '$ZaxisTITLE'" ##################################### ## Set xyz axis limits. puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" puts $SHout "set zrange \[ $Zmin : $Zmax \]" ##################################### ## Set xyz axis tic marks. puts $SHout "set xtics rotate by $XTICLABELangle" puts $SHout "set ytics rotate by $YTICLABELangle" puts $SHout "set ztics rotate by $ZTICLABELangle" ## No mid-xyz-tickmarks puts $SHout "set nomxtics" puts $SHout "set nomytics" puts $SHout "set nomztics" ## Example of setting xyz-tic-marks manually: # set xtics 0, 5 , 100 # set ytics 0, 5 , 100 # set ztics 0, 5 , 100 #################################### ## Force vertical axis thru x=0. ## Not applicable for 3D surface plot? # puts $SHout "set xzeroaxis" ################################### ## Force horizontal axis thru y=0. ## Not applicable for 3D surface plot? # puts $SHout "set yzeroaxis" ######################################## ## Set sample frequency for the surface. puts $SHout "set isosamples $ENTRYsurfaceSamplesX , $ENTRYsurfaceSamplesY" ######################################################## ## Prepare for either a shaded or a hatched surface plot. if {$ShadedSurface_0or1 == 1} { puts $SHout "unset surface" puts $SHout "set xyplane 0.0" ## 'pm3d' = palette-mapped 3-dimensional puts $SHout "set pm3d" } else { puts $SHout "set surface" ## We could put a checkbutton on the GUI to allow for ## showing all lines, even hidden ones, although the ## plot will usually be very messy and not to be used. ## For now, we always call 'hidden3d'. puts $SHout "set hidden3d trianglepattern $ENTRYhatchtype" } ## END OF if {$ShadedSurface_0or1 == 1} ############################################## ## Request PLOT LEGEND a.k.a. 'key' --- or not. ## Some Options: ## set key off ## set key top right ## set key bottom right ## set key top left ## set key bottom left ## set key at 0 , 0 ## ## Default key settings are: ## on right top vertical Right noreverse noinvert autotitle ## samplen 4 spacing 1.25 title '' nobox ## ## If the user does not want the key, ## the user can try 'off' in the KeyLocation entry ## field in the GUI. Or 'top left' or 'bottom left' ## or 'at 0,0' or 'inside' or 'lmargin' or whatever. puts $SHout "set key $ENTRYkeyLocation" ## Define format for numerics placed in the key for each contour line. ## Not needed for this surface plot? puts $SHout "set clabel '$ENTRYkeyNumFormat'" ########################## ## Set the 3D view angles. ## '1.0 , 1.0' are scaling factors for the overall plot and the height. ## NOTE: The 3 commas are needed. puts $SHout "set view $ENTRYpolarAngle , $ENTRYazimuthalAngle , 1.0 , 1.0" ################################# ## Set function f(x,y). puts $SHout "f(x,y) = $ENTRYexpr" ############################################################## ## Set a local tempLINETYPE var to be used in the plot command. set tempLINETYPE "with lines linewidth $HATCHlineWIDTH linecolor rgb '$COLORLINEhex'" ########################################## ## ISSUE the 'splot' command. ## NOTE: Plot xyz ranges were set above. ## Is the linetype stuff needed??? puts $SHout "splot f(x,y) $tempLINETYPE" ######################################### ## COULD ADD A LABEL anywhere on the plot, ## via an added entry field or two on the GUI: ## # set label 'A plot note can go here.' at 1000,-2 center ## ## If your x-axis went from 0 to 2000, then '1000,-2 center' would locate the ## label below the x-axis (because of '-2') and just about centered in the ## x-direction on the plot (because of '1000' and 'center'). ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'plot_surface' ##+#################################################################### ## PROC: 'plot_contour' ##+#################################################################### ## PURPOSE: ## Builds a 'gnuplot' script to do a 2D contour-lines plot, ## using the math expression and parameters from the GUI. ## ## Then executes that gnuplot-script and shows the resulting image ## file in an image viewer (set at the bottom of this Tk script) ## --- or, at least, tells the name of the output image file, in ## a message area of the GUI. ## ## Arguments: passed in Tcl-Tk global variables. ## ## CALLED BY: the 'replot' proc ###################################################################### proc plot_contour {} { global OUTscript SHout IMGFILEprefix global ENTRYexpr PlotTITLE XaxisTITLE YaxisTITLE ZaxisTITLE global Xmin Xmax Ymin Ymax Zmin Zmax global XTICLABELangle YTICLABELangle ZTICLABELangle global ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY ## Not needed for contour plot: (?) # global ShadedSurface_0or1 ENTRYhatchtype HATCHlineWIDTH ## Useful for flexibility in viewing? global ENTRYpolarAngle ENTRYazimuthalAngle ## Needed for contour plot: global ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY ENTRYcontourLineWidth global ENTRYkeyNumFormat ENTRYkeyLocation global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global IMGfile IMGviewer global ENTRYxpixels ENTRYypixels global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global EDITcode ## Call a proc to check for invalid inputs, esp. in entry fields. edit_inputs if {$EDITcode > 0} {return} ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ## Set a working directory for gnuplot. ## gnuplot may put 'extra' files here. puts $SHout "! cd /tmp" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################### ## Set plot title. puts $SHout "set title '$PlotTITLE'" ############################################# ## Set TIMESTAMP (at bottom-left of plot): ## Y=yyyy b=mmm d=dd a=day-of-week HMS=hours-mins-secs puts $SHout "set timestamp '%Y %b %d %a %H:%M:%S'" ################################################ ## Issue commands to setup for a 2D CONTOUR PLOT. ##################################### ## Set xy axis labels. puts $SHout "set xlabel '$XaxisTITLE'" puts $SHout "set ylabel '$YaxisTITLE'" ##################################### ## Set xy axis limits. puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" ##################################### ## Set xy-axis tic marks. puts $SHout "set xtics rotate by $XTICLABELangle" puts $SHout "set ytics rotate by $YTICLABELangle" ## No mid-xy-tickmarks puts $SHout "set nomxtics" puts $SHout "set nomytics" ## Example of setting xy-tic-marks manually: # set xtics 0, 5 , 100 # set ytics 0, 5 , 100 #################################### ## Force vertical axis thru x=0. ## Useful? puts $SHout "set xzeroaxis" ################################### ## Force horizontal axis thru y=0. ## Useful? puts $SHout "set yzeroaxis" ############################################## ## Request PLOT LEGEND a.k.a. 'key' --- or not. ## Some Options: ## set key off ## set key top right ## set key bottom right ## set key top left ## set key bottom left ## set key at 0 , 0 ## ## Default key settings are: ## on right top vertical Right noreverse noinvert autotitle ## samplen 4 spacing 1.25 title '' nobox ## ## If the user does not want the key, ## the user can try 'off' in the KeyLocation entry ## field in the GUI. Or 'top left' or 'bottom left' ## or 'at 0,0' or 'inside' or 'lmargin' or whatever. puts $SHout "set key $ENTRYkeyLocation" ## Control the format of the numbers in the key ## for the contour-lines. puts $SHout "set clabel '$ENTRYkeyNumFormat'" ############################################## ## Set sampling frequency for the contour plot. ## Use what we use for surface plots??? # puts $SHout "set isosamples $ENTRYsurfaceSamplesX , $ENTRYsurfaceSamplesY" ## OR USE ENTRYcontourSamplesX and Y ?? puts $SHout "set isosamples $ENTRYcontourSamplesX , $ENTRYcontourSamplesY" ## Some commands specific to doing a 2D contour-lines plot: puts $SHout "set contour base" puts $SHout "set cntrparam levels auto $ENTRYcontourLevels" puts $SHout "unset surface" puts $SHout "unset ztics" ############################################################# ## Instead of the following, we let the user control the view. ## puts $SHout "set view 0,0" ########################## ## Set the 3D view angles. ## '1.0 , 1.0' are scaling factors for the overall plot and the height. ## NOTE: The 3 commas are needed. puts $SHout "set view $ENTRYpolarAngle , $ENTRYazimuthalAngle , 1.0 , 1.0" ######################## ## Set function f(x,y). puts $SHout "f(x,y) = $ENTRYexpr" ############################################################## ## Set a local tempLINETYPE var to be used in the plot command. set tempLINETYPE "with lines linewidth $ENTRYcontourLineWidth linecolor rgb '$COLORLINEhex'" ############################################################## ## ISSUE the 'splot' command. ## The line parameters really needed here??? puts $SHout "splot f(x,y) $tempLINETYPE" ######################################### ## COULD ADD A LABEL anywhere on the plot, ## via another entry field or two on the GUI: ## # set label 'A plot note can go here.' at 1000,-2 center ## ## If your x-axis went from 0 to 2000, then '1000,-2 center' would locate the ## label below the x-axis (because of '-2') and just about centered in the ## x-direction on the plot (because of '1000' and 'center'). ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'plot_contour' ##+#################################################################### ## PROC: 'plot_heatmap' ##+#################################################################### ## PURPOSE: ## Builds a 'gnuplot' script to do a 2D 'heatmap' plot, ## using the math expression and parameters from the GUI. ## ## Then executes that gnuplot-script and shows the resulting image ## file in an image viewer (set at the bottom of this Tk script) ## --- or, at least, tells the name of the output image file, in ## a message area of the GUI. ## ## Arguments: passed in Tcl-Tk global variables. ## ## CALLED BY: the 'replot' proc ###################################################################### proc plot_heatmap {} { global OUTscript SHout IMGFILEprefix global ENTRYexpr PlotTITLE XaxisTITLE YaxisTITLE ZaxisTITLE global Xmin Xmax Ymin Ymax Zmin Zmax global XTICLABELangle YTICLABELangle ZTICLABELangle ## Not needed for this heatmap plot: (?) global ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY ## Not needed for this heatmap plot: # global ShadedSurface_0or1 ENTRYhatchtype HATCHlineWIDTH global ENTRYpolarAngle ENTRYazimuthalAngle ## Not needed for this heatmap plot: (?) global ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY ENTRYcontourLineWidth global ENTRYkeyNumFormat ENTRYkeyLocation global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global IMGfile IMGviewer global ENTRYxpixels ENTRYypixels global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global ENTRYcolorLocLOW ENTRYcolorLocLOWMID ENTRYcolorLocMID \ ENTRYcolorLocHIGHMID ENTRYcolorLocHIGH global heatCOLORLOWhex heatCOLORLOWMIDhex heatCOLORMIDhex \ heatCOLORHIGHMIDhex heatCOLORHIGHhex global EDITcode ## Call a proc to check for invalid inputs, esp. in entry fields. edit_inputs if {$EDITcode > 0} {return} ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ## Set a working directory for gnuplot. ## gnuplot may put 'extra' files here. puts $SHout "! cd /tmp" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################### ## Set plot title. puts $SHout "set title '$PlotTITLE'" ############################################# ## Set TIMESTAMP (at bottom-left of plot): ## Y=yyyy b=mmm d=dd a=day-of-week HMS=hours-mins-secs puts $SHout "set timestamp '%Y %b %d %a %H:%M:%S'" ############################################# ## Issue commands to setup for a HEATMAP PLOT. ##################################### ## Set xy axis labels. puts $SHout "set xlabel '$XaxisTITLE'" puts $SHout "set ylabel '$YaxisTITLE'" ##################################### ## Set xy axis limits. puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" ##################################### ## Set xy-axis tic marks. puts $SHout "set xtics rotate by $XTICLABELangle" puts $SHout "set ytics rotate by $YTICLABELangle" ## No mid-xy-tickmarks puts $SHout "set nomxtics" puts $SHout "set nomytics" ## Example of setting xy-tic-marks manually: # set xtics 0, 5 , 100 # set ytics 0, 5 , 100 #################################### ## Force vertical axis thru x=0. ## Not useful on a heatmap? puts $SHout "set xzeroaxis" ################################### ## Force horizontal axis thru y=0. ## Not useful on a heatmap? puts $SHout "set yzeroaxis" #################################################### ## Does a heatmap have its own (colored/shaded) key? ## Maybe we do not need to request a key for this ## type of plot, but we will let the user decide. ############################################## ## Request PLOT LEGEND a.k.a. 'key' --- or not. ## Some Options: ## set key off ## set key top right ## set key bottom right ## set key top left ## set key bottom left ## set key at 0 , 0 ## ## Default key settings are: ## on right top vertical Right noreverse noinvert autotitle ## samplen 4 spacing 1.25 title '' nobox ## ## If the user does not want the key, ## the user can try 'off' in the KeyLocation entry ## field in the GUI. Or 'top left' or 'bottom left' ## or 'at 0,0' or 'inside' or 'lmargin' or whatever. puts $SHout "set key $ENTRYkeyLocation" ## Define format for numerics placed in the key for each contour line. ## Not needed for a heatmap plot? # puts $SHout "set clabel '$ENTRYkeyNumFormat'" ######################################################## ## Issue some commands very specific to doing a heatmap. ## The line 'unset surface' is required to tell splot not to draw ## the surface itself, which would put a distracting grid of lines ## on top of our image plot. puts $SHout "unset surface" ## The 'view map' line sets the view so that we are facing the x-y plane. ## puts $SHout "set view map" ## This is too restrictive. Let the GUI parms determine the view. ########################## ## Set the 3D view angles. ## '1.0 , 1.0' are scaling factors for the overall plot and the height. ## NOTE: The 3 commas are needed. puts $SHout "set view $ENTRYpolarAngle , $ENTRYazimuthalAngle , 1.0 , 1.0" ## This set pm3d line has the additional clause 'at b', which ## means at bottom. This says to draw the data color map on the ## x-y plane rather than on the surface itself. puts $SHout "set pm3d at b" ################################# ## Set a palette for the heatmap. puts $SHout "set palette model RGB defined \ ($ENTRYcolorLocLOW '$heatCOLORLOWhex' , \ $ENTRYcolorLocLOWMID '$heatCOLORLOWMIDhex' , \ $ENTRYcolorLocMID '$heatCOLORMIDhex' , \ $ENTRYcolorLocHIGHMID '$heatCOLORHIGHMIDhex' , \ $ENTRYcolorLocHIGH '$heatCOLORHIGHhex')" ################################# ## Set function f(x,y). puts $SHout "f(x,y) = $ENTRYexpr" ############################################## ## ISSUE the 'splot' command to do the heatmap: puts $SHout "splot f(x,y)" ######################################### ## COULD ADD A LABEL anywhere on the plot ## via an added entry field or two on the GUI: ## # set label 'A plot note can go here.' at 1000,-2 center ## ## If your x-axis went from 0 to 2000, then '1000,-2 center' would locate the ## label below the x-axis (because of '-2') and just about centered in the ## x-direction on the plot (because of '1000' and 'center'). ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'plot_heatmap' ##+#################################################################### ## PROC: 'plot_surface-contour' ##+#################################################################### ## PURPOSE: ## Builds a 'gnuplot' script to do a 3D-surface-and-2D-contour plot, ## using the math expression and parameters from the GUI. ## ## Then executes that gnuplot-script and shows the resulting image ## file in an image viewer (set at the bottom of this Tk script) ## --- or, at least, tells the name of the output image file, in ## a message area of the GUI. ## ## Arguments: passed in Tcl-Tk global variables. ## ## CALLED BY: the 'replot' proc ###################################################################### proc plot_surface-contour {} { global OUTscript SHout IMGFILEprefix global ENTRYexpr PlotTITLE XaxisTITLE YaxisTITLE ZaxisTITLE global Xmin Xmax Ymin Ymax Zmin Zmax global XTICLABELangle YTICLABELangle ZTICLABELangle global ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY global ShadedSurface_0or1 ENTRYhatchtype HATCHlineWIDTH global ENTRYpolarAngle ENTRYazimuthalAngle global ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY ENTRYcontourLineWidth global ENTRYkeyNumFormat ENTRYkeyLocation global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global IMGfile IMGviewer global ENTRYxpixels ENTRYypixels global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global EDITcode ## Call a proc to check for invalid inputs, esp. in entry fields. edit_inputs if {$EDITcode > 0} {return} ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################### ## Set plot title. puts $SHout "set title '$PlotTITLE'" ############################################# ## Set TIMESTAMP (at bottom-left of plot): ## Y=yyyy b=mmm d=dd a=day-of-week HMS=hours-mins-secs puts $SHout "set timestamp '%Y %b %d %a %H:%M:%S'" ################################################ ## Issue commands to setup for a 3D SURFACE PLOT ## with a 2D contour-lines plot on the 'base': ##################################### ## Set xyz xis labels. puts $SHout "set xlabel '$XaxisTITLE'" puts $SHout "set ylabel '$YaxisTITLE'" puts $SHout "set zlabel '$ZaxisTITLE'" ##################################### ## Set xyz axis limits. puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" puts $SHout "set zrange \[ $Zmin : $Zmax \]" ##################################### ## Set xyz axis tic marks. puts $SHout "set xtics rotate by $XTICLABELangle" puts $SHout "set ytics rotate by $YTICLABELangle" puts $SHout "set ztics rotate by $ZTICLABELangle" ## No mid-xyz-tickmarks puts $SHout "set nomxtics" puts $SHout "set nomytics" puts $SHout "set nomztics" ## Example of setting xyz-tic-marks manually: # set xtics 0, 5 , 100 # set ytics 0, 5 , 100 # set ztics 0, 5 , 100 #################################### ## Force vertical axis thru x=0. ## Not applicable for 3D surface plot? ## But maybe useful on the 2D contours plot on the 'base'? # puts $SHout "set xzeroaxis" ################################### ## Force horizontal axis thru y=0. ## Not applicable for 3D surface plot? ## But maybe useful on the 2D contours plot on the 'base'? # puts $SHout "set yzeroaxis" ######################################## ## Set sample frequency for the surface. puts $SHout "set isosamples $ENTRYsurfaceSamplesX , $ENTRYsurfaceSamplesY" ######################################################## ## Prepare for either a shaded or a hatched surface plot. if {$ShadedSurface_0or1 == 1} { puts $SHout "unset surface" puts $SHout "set xyplane 0.5" # puts $SHout "set xyplane 1.0" ## 'pm3d' = palette-mapped 3-dimensional puts $SHout "set pm3d" } else { puts $SHout "set surface" ## We could put a checkbutton on the GUI to allow for ## showing all lines, even hidden ones, although the ## plot will usually be very messy and not to be used. ## For now, we always call 'hidden3d'. puts $SHout "set hidden3d trianglepattern $ENTRYhatchtype" } ## END OF if {$ShadedSurface_0or1 == 1} ############################################## ## Request PLOT LEGEND a.k.a. 'key' --- or not. ## Some Options: ## set key off ## set key top right ## set key bottom right ## set key top left ## set key bottom left ## set key at 0 , 0 ## ## Default key settings are: ## on right top vertical Right noreverse noinvert autotitle ## samplen 4 spacing 1.25 title '' nobox ## ## If the user does not want the key, ## the user can try 'off' in the KeyLocation entry ## field in the GUI. Or 'top left' or 'bottom left' ## or 'at 0,0' or 'inside' or 'lmargin' or whatever. puts $SHout "set key $ENTRYkeyLocation" ########################## ## Set the 3D view angles. ## '1.0 , 1.0' are scaling factors for the overall plot and the height. ## NOTE: The 3 commas are needed. puts $SHout "set view $ENTRYpolarAngle , $ENTRYazimuthalAngle , 1.0 , 1.0" ############################################################# ## Issue some commands for the 2D CONTOUR-LINES on the 'base'. puts $SHout "set contour base" puts $SHout "set cntrparam levels $ENTRYcontourLevels" ## Do we need to use ENTRYcontourSamplesX and Y with 'samples'? puts $SHout "set samples $ENTRYcontourSamplesX , $ENTRYcontourSamplesY" ## If we ask for a key for the contour lines, ## define format for numerics placed in the key for each contour line. puts $SHout "set clabel '$ENTRYkeyNumFormat'" ################################# ## Set function f(x,y). puts $SHout "f(x,y) = $ENTRYexpr" ########################################## ## ISSUE the 'splot' command. ## NOTE: Plot xyz ranges were set above. ## How is the linetype stuff used??? ## For hatched surface? For contour-lines? puts $SHout "splot f(x,y) with lines linewidth $HATCHlineWIDTH \ linecolor rgb '$COLORLINEhex'" ## How do we use ENTRYcontourLineWidth? In place of HATCHlineWIDTH? ######################################### ## COULD ADD A LABEL anywhere on the plot, ## via an added entry field or two on the GUI: ## # set label 'A plot note can go here.' at 1000,-2 center ## ## If your x-axis went from 0 to 2000, then '1000,-2 center' would locate the ## label below the x-axis (because of '-2') and just about centered in the ## x-direction on the plot (because of '1000' and 'center'). ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'plot_surface-contour' ##+#################################################################### ## PROC: 'plot_contour-heatmap' ##+#################################################################### ## PURPOSE: ## Builds a 'gnuplot' script to do a 2D-contour-and-2D-heatmap plot, ## using the math expression and parameters from the GUI. ## ## Then executes that gnuplot-script and shows the resulting image ## file in an image viewer (set at the bottom of this Tk script) ## --- or, at least, tells the name of the output image file, in ## a message area of the GUI. ## ## Arguments: passed in Tcl-Tk global variables. ## ## REFERENCE: http://www.phyast.pitt.edu/~zov1/gnuplot/html/???? ## by Zoltán Vörös circa 2009 ## "Color Shaded Contour Plot of f(x,y) = sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)" ## ## CALLED BY: the 'replot' proc ###################################################################### proc plot_contour-heatmap {} { global OUTscript SHout IMGFILEprefix global ENTRYexpr PlotTITLE XaxisTITLE YaxisTITLE ZaxisTITLE global Xmin Xmax Ymin Ymax Zmin Zmax global XTICLABELangle YTICLABELangle ZTICLABELangle global ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY ## Not needed for 2D contour-lines-and-heatmap plot? # global ShadedSurface_0or1 ENTRYhatchtype HATCHlineWIDTH ## Needed for viewing options? global ENTRYpolarAngle ENTRYazimuthalAngle global ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY \ ENTRYcontourLineWidth global ENTRYkeyNumFormat ENTRYkeyLocation global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global IMGfile IMGviewer global ENTRYxpixels ENTRYypixels global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global heatCOLORLOWhex heatCOLORLOWMIDhex heatCOLORMIDhex \ heatCOLORHIGHMIDhex heatCOLORHIGHhex global ENTRYcolorLocLOW ENTRYcolorLocLOWMID ENTRYcolorLocMID \ ENTRYcolorLocHIGHMID ENTRYcolorLocHIGH global EDITcode ## Call a proc to check for invalid inputs, esp. in entry fields. edit_inputs if {$EDITcode > 0} {return} ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ## Set a working directory for gnuplot. ## gnuplot may put 'extra' files here. puts $SHout "! cd /tmp" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################### ## Set plot title. puts $SHout "set title '$PlotTITLE'" ############################################# ## Set TIMESTAMP (at bottom-left of plot): ## Y=yyyy b=mmm d=dd a=day-of-week HMS=hours-mins-secs puts $SHout "set timestamp '%Y %b %d %a %H:%M:%S'" ################################################################## ## Issue commands to setup for a 2D CONTOUR-LINES-and-HEATMAP PLOT: ##################################### ## Set xy axis labels. puts $SHout "set xlabel '$XaxisTITLE'" puts $SHout "set ylabel '$YaxisTITLE'" ##################################### ## Set xy axis limits. puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" ##################################### ## Set xy axis tic marks. puts $SHout "set xtics rotate by $XTICLABELangle" puts $SHout "set ytics rotate by $YTICLABELangle" ## No mid-xyz-tickmarks puts $SHout "set nomxtics" puts $SHout "set nomytics" ## Example of setting xyz-tic-marks manually: # set xtics 0, 5 , 100 # set ytics 0, 5 , 100 #################################### ## Force vertical axis thru x=0. ## Force horizontal axis thru y=0. ## Not nice over the heatmap? ## # puts $SHout "set xzeroaxis" # puts $SHout "set yzeroaxis" #################################### ## Set some rather thin outer margins. ## The units are in char widths and heights ## using the current terminal's default font. puts $SHout "set bmargin 3" puts $SHout "set tmargin 3" puts $SHout "set lmargin 3" puts $SHout "set rmargin 3" ######################################## ## Set sample frequency. ## USE 'isosamples' even though we do 'plot' below, not 'splot'?? puts $SHout "set isosamples $ENTRYsurfaceSamplesX , $ENTRYsurfaceSamplesY" ## OR use 'samples'?? OR both?? We use both, for now. puts $SHout "set samples $ENTRYcontourSamplesX , $ENTRYcontourSamplesY" ############################################## ## Make filenames for 2 gnuplot 'table' files. ## (See the Zoltan reference above.) set CONTOURfile "${IMGFILEprefix}_contour.dat" set HEATMAPfile "${IMGFILEprefix}_heatmap.dat" ############################################################## ## Set function f(x,y) --- from which to make 2 'table' files. puts $SHout "f(x,y) = $ENTRYexpr" ################################# ## Make the heatmap 'table' file. puts $SHout "set table '$HEATMAPfile'" puts $SHout "splot f(x,y)" puts $SHout "unset table" ################################# ## Make the contour 'table' file. puts $SHout "set contour base" ## Do we need to determine these from Zmin, Zmax?? when they are not asterisks. ## or other computed values?? puts $SHout "set cntrparam level incremental -3, 0.5, 3" # puts $SHout "set cntrparam level incremental $Zmin , 0.5 , $Zmax" puts $SHout "unset surface" puts $SHout "set table '$CONTOURfile'" puts $SHout "splot f(x,y)" puts $SHout "unset table" ##################################### ## Prepare for the 'plot' statement. puts $SHout "reset" puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" ############################################## ## Request PLOT LEGEND a.k.a. 'key' --- or not. ## Some Options: ## set key off ## set key top right ## set key bottom right ## set key top left ## set key bottom left ## set key at 0 , 0 ## ## Default key settings are: ## on right top vertical Right noreverse noinvert autotitle ## samplen 4 spacing 1.25 title '' nobox ## ## If the user does not want the key, ## the user can try 'off' in the KeyLocation entry ## field in the GUI. Or 'top left' or 'bottom left' ## or 'at 0,0' or 'inside' or 'lmargin' or whatever. puts $SHout "set key $ENTRYkeyLocation" ################################################## ## Define the palette of with the GUI vars. ################################################## puts $SHout "set palette model RGB defined \ ($ENTRYcolorLocLOW '$heatCOLORLOWhex' , \ $ENTRYcolorLocLOWMID '$heatCOLORLOWMIDhex' , \ $ENTRYcolorLocMID '$heatCOLORMIDhex' , \ $ENTRYcolorLocHIGHMID '$heatCOLORHIGHMIDhex' , \ $ENTRYcolorLocHIGH '$heatCOLORHIGHhex')" ########################## ## Set the 3D view angles. ## (Would be nice if we could let the user determine the view ## via GUI parms. But the following statement seems to work ## with 'splot', but not with 'plot'.) ## '1.0 , 1.0' are scaling factors for the overall plot and the height. ## NOTE: The 3 commas are needed. # puts $SHout "set view $ENTRYpolarAngle , $ENTRYazimuthalAngle , 1.0 , 1.0" ############################################ ## ISSUE the 'plot' command --- not 'splot'. ## From Zoltan: puts $SHout "plot '$HEATMAPfile' with image, '$CONTOURfile' \ with lines linetype -1 linewidth $ENTRYcontourLineWidth" ## Zoltan used: w l lt -1 lw 1.5 ######################################### ## COULD ADD A LABEL anywhere on the plot, ## via an added entry field or two on the GUI: ## # set label 'A plot note can go here.' at 1000,-2 center ## ## If your x-axis went from 0 to 2000, then '1000,-2 center' would locate the ## label below the x-axis (because of '-2') and just about centered in the ## x-direction on the plot (because of '1000' and 'center'). ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'plot_contour-heatmap' ##+#################################################################### ## PROC: 'display_test_img' ##+##################################################################### ## PURPOSE: Displays a gnuplot test image for the chosen ## terminal (image) type. ## ## CALLED BY: .fRoutopts.buttTESTimg ##+##################################################################### proc display_test_img {} { global OUTscript SHout IMGFILEprefix global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global ENTRYxpixels ENTRYypixels global IMGfile IMGviewer ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ## Set a working directory for gnuplot. ## gnuplot may put 'extra' files here. puts $SHout "! cd /tmp" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################################### ## ISSUE the command to get the terminal test image. ################################################### puts $SHout "test" ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'display_test_img' ##+#################################################################### ## PROC: 'show_palette_gradient' ##+##################################################################### ## PURPOSE: Displays a test image for the current palette. ## ## CALLED BY: .fRoutopts.buttTESTimg ##+##################################################################### proc show_palette_gradient {} { global OUTscript SHout IMGFILEprefix global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global ENTRYxpixels ENTRYypixels global ENTRYcolorLocLOW ENTRYcolorLocLOWMID ENTRYcolorLocMID \ ENTRYcolorLocHIGHMID ENTRYcolorLocHIGH global heatCOLORLOWhex heatCOLORLOWMIDhex heatCOLORMIDhex \ heatCOLORHIGHMIDhex heatCOLORHIGHhex global IMGfile IMGviewer ## Prepare to make a NEW output gnuplot script. # catch {exec rm "$OUTscript"} catch {file delete "$OUTscript"} ## Open the output file and get its file handle. set SHout [open "$OUTscript" w] ##################################################### ## START writing the gnuplot script. ##################################################### ## Set the first line. puts $SHout "#!/usr/bin/gnuplot" ## Set a working directory for gnuplot. ## gnuplot may put 'extra' files here. puts $SHout "! cd /tmp" ################################################ ## According to RADVARoutimg, put 'set terminal' ## and 'set output' commands in OUTscript and ## set the variables IMGfile and IMGviewer. ################################################ set_output_vars ################################################## ## Define the palette of with the GUI vars. ################################################## puts $SHout "set palette model RGB defined \ ($ENTRYcolorLocLOW '$heatCOLORLOWhex' , \ $ENTRYcolorLocLOWMID '$heatCOLORLOWMIDhex' , \ $ENTRYcolorLocMID '$heatCOLORMIDhex' , \ $ENTRYcolorLocHIGHMID '$heatCOLORHIGHMIDhex' , \ $ENTRYcolorLocHIGH '$heatCOLORHIGHhex')" ################################################## ## ISSUE the command to get the test palette image. ################################################## puts $SHout "test palette" ## The 'show palette gradient' command gives text output ## like the following: ## 0. gray=0.0000, (r,g,b)=(0.0000,0.0000,1.0000), #0000ff = 0 0 255 ## 1. gray=0.2525, (r,g,b)=(0.3922,0.3922,1.0000), #6464ff = 100 100 255 ## 2. gray=0.2525, (r,g,b)=(0.0000,1.0000,0.0000), #00ff00 = 0 255 0 ## 3. gray=0.6061, (r,g,b)=(0.7843,0.3922,0.1961), #c86432 = 200 100 50 ## 4. gray=1.0000, (r,g,b)=(1.0000,1.0000,1.0000), #ffffff = 255 255 255 ##################################### ## Set command to view the image plot. ## The exclamation point tells gnuplot to pass the command to ## a shell (a command interpreter for the operating system). if {"$IMGfile" != ""} { puts $SHout "! $IMGviewer $IMGfile &" } ################################## ## Close the gnuplot script file. close $SHout ################################################# ## Put an 'outputs-location' message in the tkGUI, ## BEFORE executing the plot. if {"$IMGfile" != ""} { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to $IMGfile." } else { .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Gnuplot script is written to $OUTscript --- image to terminal window." } update ################################################### ## Execute the gnuplot script. ## (May add some error code checking later.) catch {exec chmod 755 "$OUTscript"} catch {exec "$OUTscript"} } ## END of proc 'show_palette_gradient' ##+#################################################################### ## PROC: 'edit_inputs' ##+##################################################################### ## PURPOSE: Check input fields of the GUI. ## ## CALLED BY: proc 'replot' ##+##################################################################### proc edit_inputs {} { global RADVARplottype global Xmin Xmax Ymin Ymax Zmin Zmax global XTICLABELangle YTICLABELangle ZTICLABELangle global ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY ENTRYhatchtype global ENTRYpolarAngle ENTRYazimuthalAngle global ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY \ ENTRYcontourLineWidth global ENTRYcolorLocLOW ENTRYcolorLocLOWMID ENTRYcolorLocMID \ ENTRYcolorLocHIGHMID ENTRYcolorLocHIGH global ENTRYkeyNumFormat ENTRYkeyLocation global ENTRYxpixels ENTRYypixels ## We could do without this EDITcode variable, by using ## a code with the 'return' statement. But using this ## code variable is a little more self-documenting. global EDITcode set EDITcode 0 set ERRMSGloc "+10+10" ####################################################### ## Remove trailing and leading blanks (if any) from the ## user entries in the 'entry' widgets. ####################################################### set Xmin [string trim $Xmin] set Xmax [string trim $Xmax] set Ymin [string trim $Ymin] set Ymax [string trim $Ymax] set Zmin [string trim $Zmin] set Zmax [string trim $Zmax] set XTICLABELangle [string trim $XTICLABELangle] set YTICLABELangle [string trim $YTICLABELangle] set ZTICLABELangle [string trim $ZTICLABELangle] set ENTRYsurfaceSamplesX [string trim $ENTRYsurfaceSamplesX] set ENTRYsurfaceSamplesY [string trim $ENTRYsurfaceSamplesY] set ENTRYhatchtype [string trim $ENTRYhatchtype] set ENTRYpolarAngle [string trim $ENTRYpolarAngle] set ENTRYazimuthalAngle [string trim $ENTRYazimuthalAngle] set ENTRYcontourLevels [string trim $ENTRYcontourLevels] set ENTRYcontourSamplesX [string trim $ENTRYcontourSamplesX] set ENTRYcontourSamplesY [string trim $ENTRYcontourSamplesY] set ENTRYcontourLineWidth [string trim $ENTRYcontourLineWidth] set ENTRYkeyNumFormat [string trim $ENTRYkeyNumFormat] set ENTRYkeyLocation [string trim $ENTRYkeyLocation] set ENTRYxpixels [string trim $ENTRYxpixels] set ENTRYypixels [string trim $ENTRYypixels] ######################################################################### ## Check that Xmin,Xmax,Ymin,Ymax are NOT blank. ######################################################################### set MUSTBEmsg "Must be '*' or a 'real' number." if {"$Xmin" == ""} { popup_msgVarWithScroll .topErr "Xmin is blank. $MUSTBEmsg" $ERRMSGloc set EDITcode 1 return } if {"$Xmax" == ""} { popup_msgVarWithScroll .topErr "Xmax is blank. $MUSTBEmsg" $ERRMSGloc set EDITcode 1 return } if {"$Ymin" == ""} { popup_msgVarWithScroll .topErr "Ymin is blank. $MUSTBEmsg" $ERRMSGloc set EDITcode 1 return } if {"$Ymax" == ""} { popup_msgVarWithScroll .topErr "Ymax is blank. $MUSTBEmsg" $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that Xmin,Xmax,Ymin,Ymax are asterisk-only (*) ## OR 'real' numbers. ######################################################################### ## Implemented using 'string is double'. Some sample test results: ## % string is double "-100.00" ## 1 ## % string is double "abc" ## 0 ## % string is double "-2.5e-3" ## 1 ## % string is double "-2.5E-3" ## 1 ## % string is double "-2.5D-3" ## 0 ######################################################################### set NUMERICmsg "does not appear to be numeric. Use chars '0123456789-.eE'." if {"$Xmin" != "*"} { if {![string is double "$Xmin"]} { popup_msgVarWithScroll .topErr "Xmin $NUMERICmsg" +10+10 set EDITcode 1 return } } if {"$Xmax" != "*"} { if {![string is double "$Xmax"]} { popup_msgVarWithScroll .topErr "Xmax $NUMERICmsg" $ERRMSGloc set EDITcode 1 return } } if {"$Ymin" != "*"} { if {![string is double "$Ymin"]} { popup_msgVarWithScroll .topErr "Ymin $NUMERICmsg" $ERRMSGloc set EDITcode 1 return } } if {"$Ymax" != "*"} { if {![string is double "$Ymax"]} { popup_msgVarWithScroll .topErr "Ymax $NUMERICmsg" $ERRMSGloc set EDITcode 1 return } } if {"$Zmin" != "*"} { if {![string is double "$Zmin"]} { popup_msgVarWithScroll .topErr "Zmin $NUMERICmsg" $ERRMSGloc set EDITcode 1 return } } if {"$Zmax" != "*"} { if {![string is double "$Zmax"]} { popup_msgVarWithScroll .topErr "Zmax $NUMERICmsg" $ERRMSGloc set EDITcode 1 return } } ######################################################################### ## Check that surface plotting parameters ## ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY ENTRYhatchtype ## ENTRYpolarAngle ENTRYazimuthalAngle ## are not blank. ######################################################################## if {"$ENTRYsurfaceSamplesX" == ""} { popup_msgVarWithScroll .topErr "ENTRY Surface Samples X is blank. Should be an integer" $ERRMSGloc set EDITcode 1 return } if {"$ENTRYsurfaceSamplesY" == ""} { popup_msgVarWithScroll .topErr "ENTRY Surface Samples Y is blank. Should be an integer" $ERRMSGloc set EDITcode 1 return } if {"$ENTRYhatchtype" == ""} { popup_msgVarWithScroll .topErr "ENTRY HatchType is blank. Should be integer, 1 to 7." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYpolarAngle" == ""} { popup_msgVarWithScroll .topErr "ENTRY Polar Angle is blank. Should be 0 to 180." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYazimuthalAngle" == ""} { popup_msgVarWithScroll .topErr "ENTRY Azimuthal Angle is blank. Should be 0 to 180." $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that surface plotting parameters ## ENTRYsurfaceSamplesX ENTRYsurfaceSamplesY ENTRYhatchtype ## ENTRYpolarAngle ENTRYazimuthalAngle ## are numeric. ######################################################################## if {![string is integer -strict "$ENTRYsurfaceSamplesX"]} { popup_msgVarWithScroll .topErr "ENTRY Surface Samples X is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYsurfaceSamplesY"]} { popup_msgVarWithScroll .topErr "ENTRY Surface Samples Y is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYhatchtype"]} { popup_msgVarWithScroll .topErr "ENTRY HatchType is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if { $ENTRYhatchtype < 1 || $ENTRYhatchtype > 7 } { popup_msgVarWithScroll .topErr "ENTRY HatchType is NOT between 1 and 7." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYpolarAngle"]} { popup_msgVarWithScroll .topErr "ENTRY Polar Angle is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if { $ENTRYpolarAngle < 0 || $ENTRYpolarAngle > 180 } { popup_msgVarWithScroll .topErr "ENTRY Polar Angle is NOT between 0 and 180." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYazimuthalAngle"]} { popup_msgVarWithScroll .topErr "ENTRY Azimuthal Angle is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if { $ENTRYazimuthalAngle < 0 || $ENTRYazimuthalAngle > 360 } { popup_msgVarWithScroll .topErr "ENTRY Azimuthal Angle is NOT between 0 and 360." $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that contour plotting parameters ## ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY ENTRYcontourLineWidth ## are not blank. ######################################################################## if {"$ENTRYcontourLevels" == ""} { popup_msgVarWithScroll .topErr "ENTRY Contour Levels is blank. Should be integer." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcontourSamplesX" == ""} { popup_msgVarWithScroll .topErr "ENTRY Contour Samples X is blank. Should be integer." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcontourSamplesY" == ""} { popup_msgVarWithScroll .topErr "ENTRY Contour Samples Y is blank. Should be integer." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcontourLineWidth" == ""} { popup_msgVarWithScroll .topErr "ENTRY Contour Line Width is blank. Should be numeric." $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that contour plotting parameters ## ENTRYcontourLevels ENTRYcontourSamplesX ENTRYcontourSamplesY ENTRYcontourLineWidth ## are numeric. ######################################################################## if {![string is integer -strict "$ENTRYcontourLevels"]} { popup_msgVarWithScroll .topErr "ENTRY Contour Levels is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYcontourSamplesX"]} { popup_msgVarWithScroll .topErr "ENTRY Contour Samples X is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYcontourSamplesY"]} { popup_msgVarWithScroll .topErr "ENTRY Contour Samples Y is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is double "$ENTRYcontourLineWidth"]} { popup_msgVarWithScroll .topErr "ENTRY Contour Line Width is NOT NUMERIC." $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that heat/palette 'color locations' in the palette ## ENTRYcolorLocLOW ENTRYcolorLocLOWMID ENTRYcolorLocMID ## ENTRYcolorLocHIGHMID ENTRYcolorLocHIGH ## are not blank. ######################################################################## if {"$ENTRYcolorLocLOW" == ""} { popup_msgVarWithScroll .topErr "ENTRY Color Location LOW is blank. Should be numeric." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcolorLocLOWMID" == ""} { popup_msgVarWithScroll .topErr "ENTRY Color Location LOWMID is blank. Should be numeric." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcolorLocMID" == ""} { popup_msgVarWithScroll .topErr "ENTRY Color Location MID is blank. Should be numeric." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcolorLocHIGHMID" == ""} { popup_msgVarWithScroll .topErr "ENTRY Color Location HIGHMID is blank. Should be numeric." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYcolorLocHIGH" == ""} { popup_msgVarWithScroll .topErr "ENTRY Color Location HIGH is blank. Should be numeric." $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that heat/palette 'color locations' in the palette ## ENTRYcolorLocLOW ENTRYcolorLocLOWMID ENTRYcolorLocMID ## ENTRYcolorLocHIGHMID ENTRYcolorLocHIGH ## are numeric (integer). ######################################################################## if {![string is integer -strict "$ENTRYcolorLocLOW"]} { popup_msgVarWithScroll .topErr "ENTRY Color Location LOW is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYcolorLocLOWMID"]} { popup_msgVarWithScroll .topErr "ENTRY Color Location LOWMID is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYcolorLocMID"]} { popup_msgVarWithScroll .topErr "ENTRY Color Location MID is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYcolorLocHIGHMID"]} { popup_msgVarWithScroll .topErr "ENTRY Color Location HIGHMID is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYcolorLocHIGH"]} { popup_msgVarWithScroll .topErr "ENTRY Color Location HIGH is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } ######################################################################### ## Check that key (legend) making parameters ## ENTRYkeyNumFormat ENTRYkeyLocation ## are not blank. ######################################################################## if {"$ENTRYkeyNumFormat" == ""} { popup_msgVarWithScroll .topErr "ENTRY Key Number Format is blank. Should be like '%.1f'." $ERRMSGloc set EDITcode 1 return } if {"$ENTRYkeyLocation" == ""} { popup_msgVarWithScroll .topErr "ENTRY Key Location is blank. Should be like 'at 0,0 top left'." $ERRMSGloc set EDITcode 1 return } ########################################################## ## Check that ENTRYxpixels, ENTRYypixels are integers. ########################################################## if {![string is integer -strict "$ENTRYxpixels"]} { popup_msgVarWithScroll .topErr "Xpixels is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$ENTRYypixels"]} { popup_msgVarWithScroll .topErr "Ypixels is NOT INTEGER." $ERRMSGloc set EDITcode 1 return } } ## END of proc 'edit_inputs' ##+#################################################################### ## PROC: 'getset_color' ##+##################################################################### ## PURPOSE: ## ## This procedure is invoked to get an RGB triplet ## via 3 RGB slider bars on the FE Color Selector GUI. ## ## Uses that RGB value to set the color in variables determined ## by the 'colorID' string passed to this proc. ## ID Examples: 'line', 'bkgd', 'axis' ## 'low', 'lowmid', 'mid', 'highmid', 'high' ## ## Arguments: none ## ## CALLED BY: the color buttons on the GUI ##+##################################################################### proc getset_color {colorID} { global ColorSelectorScript global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global COLORAXISr COLORAXISg COLORAXISb COLORAXIShex global heatCOLORLOWr heatCOLORLOWg heatCOLORLOWb heatCOLORLOWhex global heatCOLORLOWMIDr heatCOLORLOWMIDg heatCOLORLOWMIDb heatCOLORLOWMIDhex global heatCOLORMIDr heatCOLORMIDg heatCOLORMIDb heatCOLORMIDhex global heatCOLORHIGHMIDr heatCOLORHIGHMIDg heatCOLORHIGHMIDb heatCOLORHIGHMIDhex global heatCOLORHIGHr heatCOLORHIGHg heatCOLORHIGHb heatCOLORHIGHhex if {"$colorID" == "line"} { set tempCOLORr $COLORLINEr set tempCOLORg $COLORLINEg set tempCOLORb $COLORLINEb set tempCOLORhex $COLORLINEhex } elseif {"$colorID" == "bkgd"} { set tempCOLORr $COLORBKGDr set tempCOLORg $COLORBKGDg set tempCOLORb $COLORBKGDb set tempCOLORhex $COLORBKGDhex } elseif {"$colorID" == "axis"} { set tempCOLORr $COLORAXISr set tempCOLORg $COLORAXISg set tempCOLORb $COLORAXISb set tempCOLORhex $COLORAXIShex } elseif {"$colorID" == "low"} { set tempCOLORr $heatCOLORLOWr set tempCOLORg $heatCOLORLOWg set tempCOLORb $heatCOLORLOWb set tempCOLORhex $heatCOLORLOWhex } elseif {"$colorID" == "lowmid"} { set tempCOLORr $heatCOLORLOWMIDr set tempCOLORg $heatCOLORLOWMIDg set tempCOLORb $heatCOLORLOWMIDb set tempCOLORhex $heatCOLORLOWMIDhex } elseif {"$colorID" == "mid"} { set tempCOLORr $heatCOLORMIDr set tempCOLORg $heatCOLORMIDg set tempCOLORb $heatCOLORMIDb set tempCOLORhex $heatCOLORMIDhex } elseif {"$colorID" == "highmid"} { set tempCOLORr $heatCOLORHIGHMIDr set tempCOLORg $heatCOLORHIGHMIDg set tempCOLORb $heatCOLORHIGHMIDb set tempCOLORhex $heatCOLORHIGHMIDhex } elseif {"$colorID" == "high"} { set tempCOLORr $heatCOLORHIGHr set tempCOLORg $heatCOLORHIGHg set tempCOLORb $heatCOLORHIGHb set tempCOLORhex $heatCOLORHIGHhex } else { ## Seems to be an invalid colorID. return } ## FOR TESTING: # puts "tempCOLORr: $tempCOLORr" # puts "tempCOLORg: $tempCOLORb" # puts "tempCOLORb: $tempCOLORb" set TEMPrgb [ exec $ColorSelectorScript $tempCOLORr $tempCOLORg $tempCOLORb] ## FOR TESTING: # puts "TEMPrgb: $TEMPrgb" if { "$TEMPrgb" == "" } { return } scan $TEMPrgb "%s %s %s %s" r255 g255 b255 hexRGB if {"$colorID" == "line"} { set COLORLINEhex "#$hexRGB" set COLORLINEr $r255 set COLORLINEg $g255 set COLORLINEb $b255 } elseif {"$colorID" == "bkgd"} { set COLORBKGDhex "#$hexRGB" set COLORBKGDr $r255 set COLORBKGDg $g255 set COLORBKGDb $b255 } elseif {"$colorID" == "axis"} { set COLORAXIShex "#$hexRGB" set COLORAXISr $r255 set COLORAXISg $g255 set COLORAXISb $b255 } elseif {"$colorID" == "low"} { set heatCOLORLOWhex "#$hexRGB" set heatCOLORLOWr $r255 set heatCOLORLOWg $g255 set heatCOLORLOWb $b255 } elseif {"$colorID" == "lowmid"} { set heatCOLORLOWMIDhex "#$hexRGB" set heatCOLORLOWMIDr $r255 set heatCOLORLOWMIDg $g255 set heatCOLORLOWMIDb $b255 } elseif {"$colorID" == "mid"} { set heatCOLORMIDhex "#$hexRGB" set heatCOLORMIDr $r255 set heatCOLORMIDg $g255 set heatCOLORMIDb $b255 } elseif {"$colorID" == "highmid"} { set heatCOLORHIGHMIDhex "#$hexRGB" set heatCOLORHIGHMIDr $r255 set heatCOLORHIGHMIDg $g255 set heatCOLORHIGHMIDb $b255 } elseif {"$colorID" == "high"} { set heatCOLORHIGHhex "#$hexRGB" set heatCOLORHIGHr $r255 set heatCOLORHIGHg $g255 set heatCOLORHIGHb $b255 } else { return } ## Set color of the indicated color button. update_color_button $colorID } ## END OF PROC 'getset_color' ##+##################################################################### ## PROC 'update_color_button' ##+##################################################################### ## PURPOSE: ## This procedure is invoked to set the background color of a ## color button, indicated by the 'colorID' string, ## to its currently set 'colorID' color --- and sets ## foreground color, for text on the button, to a suitable black or ## white color, so that the label text is readable. ## ## Arguments: global color vars ## ## CALLED BY: in 2 places: ## in proc 'getset_color' ## and in several calls in the 'Additional-GUI-Initialization' ## section at the bottom of this script. ##+##################################################################### proc update_color_button {colorID} { global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global COLORAXISr COLORAXISg COLORAXISb COLORAXIShex global heatCOLORLOWr heatCOLORLOWg heatCOLORLOWb heatCOLORLOWhex global heatCOLORLOWMIDr heatCOLORLOWMIDg heatCOLORLOWMIDb heatCOLORLOWMIDhex global heatCOLORMIDr heatCOLORMIDg heatCOLORMIDb heatCOLORMIDhex global heatCOLORHIGHMIDr heatCOLORHIGHMIDg heatCOLORHIGHMIDb heatCOLORHIGHMIDhex global heatCOLORHIGHr heatCOLORHIGHg heatCOLORHIGHb heatCOLORHIGHhex # set colorBREAK 300 set colorBREAK 250 if {"$colorID" == "line"} { .fRbuttons.buttLINEcolor configure -bg $COLORLINEhex set sumCOLOR1 [expr {$COLORLINEr + $COLORLINEg + $COLORLINEb}] if {$sumCOLOR1 > $colorBREAK} { .fRbuttons.buttLINEcolor configure -fg "#000000" } else { .fRbuttons.buttLINEcolor configure -fg "#ffffff" } } elseif {"$colorID" == "bkgd"} { .fRbuttons.buttBKGDcolor configure -bg $COLORBKGDhex set sumCOLOR1 [expr {$COLORBKGDr + $COLORBKGDg + $COLORBKGDb}] if {$sumCOLOR1 > $colorBREAK} { .fRbuttons.buttBKGDcolor configure -fg "#000000" } else { .fRbuttons.buttBKGDcolor configure -fg "#ffffff" } } elseif {"$colorID" == "axis"} { .fRbuttons.buttAXIScolor configure -bg $COLORAXIShex set sumCOLOR1 [expr {$COLORAXISr + $COLORAXISg + $COLORAXISb}] if {$sumCOLOR1 > $colorBREAK} { .fRbuttons.buttAXIScolor configure -fg "#000000" } else { .fRbuttons.buttAXIScolor configure -fg "#ffffff" } } elseif {"$colorID" == "low"} { .fRbottom.fRright.fRheatopts.buttLOWCOLOR configure -bg $heatCOLORLOWhex set sumCOLOR1 [expr {$heatCOLORLOWr + $heatCOLORLOWg + $heatCOLORLOWb}] if {$sumCOLOR1 > $colorBREAK} { .fRbottom.fRright.fRheatopts.buttLOWCOLOR configure -fg "#000000" } else { .fRbottom.fRright.fRheatopts.buttLOWCOLOR configure -fg "#ffffff" } } elseif {"$colorID" == "lowmid"} { .fRbottom.fRright.fRheatopts.buttLOWMIDCOLOR configure -bg $heatCOLORLOWMIDhex set sumCOLOR1 [expr {$heatCOLORLOWMIDr + $heatCOLORLOWMIDg + $heatCOLORLOWMIDb}] if {$sumCOLOR1 > $colorBREAK} { .fRbottom.fRright.fRheatopts.buttLOWMIDCOLOR configure -fg "#000000" } else { .fRbottom.fRright.fRheatopts.buttLOWMIDCOLOR configure -fg "#ffffff" } } elseif {"$colorID" == "mid"} { .fRbottom.fRright.fRheatopts.buttMIDCOLOR configure -bg $heatCOLORMIDhex set sumCOLOR1 [expr {$heatCOLORMIDr + $heatCOLORMIDg + $heatCOLORMIDb}] if {$sumCOLOR1 > $colorBREAK} { .fRbottom.fRright.fRheatopts.buttMIDCOLOR configure -fg "#000000" } else { .fRbottom.fRright.fRheatopts.buttMIDCOLOR configure -fg "#ffffff" } } elseif {"$colorID" == "highmid"} { .fRbottom.fRright.fRheatopts.buttHIGHMIDCOLOR configure -bg $heatCOLORHIGHMIDhex set sumCOLOR1 [expr {$heatCOLORHIGHMIDr + $heatCOLORHIGHMIDg + $heatCOLORHIGHMIDb}] if {$sumCOLOR1 > $colorBREAK} { .fRbottom.fRright.fRheatopts.buttHIGHMIDCOLOR configure -fg "#000000" } else { .fRbottom.fRright.fRheatopts.buttHIGHMIDCOLOR configure -fg "#ffffff" } } elseif {"$colorID" == "high"} { .fRbottom.fRright.fRheatopts.buttHIGHCOLOR configure -bg $heatCOLORHIGHhex set sumCOLOR1 [expr {$heatCOLORHIGHr + $heatCOLORHIGHg + $heatCOLORHIGHb}] if {$sumCOLOR1 > $colorBREAK} { .fRbottom.fRright.fRheatopts.buttHIGHCOLOR configure -fg "#000000" } else { .fRbottom.fRright.fRheatopts.buttHIGHCOLOR configure -fg "#ffffff" } } else { ## Seems to be an invalid colorID. return } } ## END OF PROC 'update_color_button' ##+#################################################################### ## PROC: 'set_overhead_view_angles' ##+#################################################################### ## PURPOSE: Resets view angles quickly for an 'overhead' view. ## ## CALLED BY: button 'OverheadView' ##+#################################################################### proc set_overhead_view_angles {} { global ENTRYpolarAngle ENTRYazimuthalAngle set ENTRYpolarAngle 0 set ENTRYazimuthalAngle 0 } ## END OF PROC 'set_overhead_view_angles' ##+#################################################################### ## PROC: 'set_oblique_view_angles' ##+#################################################################### ## PURPOSE: Resets view angles quickly for an 'oblique' view. ## ## CALLED BY: button 'ObliqueView' ##+#################################################################### proc set_oblique_view_angles {} { global ENTRYpolarAngle ENTRYazimuthalAngle set ENTRYpolarAngle 45 set ENTRYazimuthalAngle 45 } ## END OF PROC 'set_oblique_view_angles' ##+######################################################################## ## PROC 'popup_msgVarWithScroll' ##+######################################################################## ## PURPOSE: Report help or error conditions to the user. ## ## We do not use focus,grab,tkwait in this proc, ## because we use it to show help when the GUI is idle, ## and we may want the user to be able to keep the Help ## window open while doing some other things with the GUI ## such as putting a filename in the filename entry field ## or clicking on a radiobutton. ## ## For a similar proc with focus-grab-tkwait added, ## see the proc 'popup_msgVarWithScroll_wait' in a ## 3DterrainGeneratorExaminer Tk script. ## ## REFERENCE: page 602 of 'Practical Programming in Tcl and Tk', ## 4th edition, by Welch, Jones, Hobbs. ## ## ARGUMENTS: A toplevel frame name (such as .fRhelp or .fRerrmsg) ## and a variable holding text (many lines, if needed). ## ## CALLED BY: 'help' button ##+######################################################################## ## To have more control over the formatting of the message (esp. ## words per line), we use this 'toplevel-text' method, ## rather than the 'tk_dialog' method -- like on page 574 of the book ## by Hattie Schroeder & Mike Doyel,'Interactive Web Applications ## with Tcl/Tk', Appendix A "ED, the Tcl Code Editor". ##+######################################################################## proc popup_msgVarWithScroll { toplevName VARtext ULloc} { ## global fontTEMP_varwidth #; Not needed. 'wish' makes this global. ## global env # bell # bell ################################################# ## Set VARwidth & VARheight from $VARtext. ################################################# ## To get VARheight, ## split at '\n' (newlines) and count 'lines'. ################################################# set VARlist [ split $VARtext "\n" ] ## For testing: # puts "VARlist: $VARlist" set VARheight [ llength $VARlist ] ## For testing: # puts "VARheight: $VARheight" ################################################# ## To get VARwidth, ## loop through the 'lines' getting length ## of each; save max. ################################################# set VARwidth 0 ############################################# ## LOOK AT EACH LINE IN THE LIST. ############################################# foreach line $VARlist { ############################################# ## Get the length of the line. ############################################# set LINEwidth [ string length $line ] if { $LINEwidth > $VARwidth } { set VARwidth $LINEwidth } } ## END OF foreach line $VARlist ## For testing: # puts "VARwidth: $VARwidth" ############################################################### ## NOTE: VARwidth works for a fixed-width font used for the ## text widget ... BUT the programmer may need to be ## careful that the contents of VARtext are all ## countable characters by the 'string length' command. ############################################################### ##################################### ## SETUP 'TOP LEVEL' HELP WINDOW. ##################################### catch {destroy $toplevName} toplevel $toplevName # wm geometry $toplevName 600x400+100+50 # wm geometry $toplevName +100+50 wm geometry $toplevName $ULloc wm title $toplevName "Note" # wm title $toplevName "Note to $env(USER)" wm iconname $toplevName "Note" ##################################### ## In the frame '$toplevName' - ## DEFINE THE TEXT WIDGET and ## its two scrollbars --- and ## DEFINE an OK BUTTON widget. ##################################### if {$VARheight > 10} { text $toplevName.text \ -wrap none \ -font fontTEMP_varwidth \ -width $VARwidth \ -height $VARheight \ -bg "#f0f0f0" \ -relief raised \ -bd 2 \ -yscrollcommand "$toplevName.scrolly set" \ -xscrollcommand "$toplevName.scrollx set" scrollbar $toplevName.scrolly \ -orient vertical \ -command "$toplevName.text yview" scrollbar $toplevName.scrollx \ -orient horizontal \ -command "$toplevName.text xview" } else { text $toplevName.text \ -wrap none \ -font fontTEMP_varwidth \ -width $VARwidth \ -height $VARheight \ -bg "#f0f0f0" \ -relief raised \ -bd 2 } button $toplevName.butt \ -text "OK" \ -font fontTEMP_varwidth \ -command "destroy $toplevName" ############################################### ## PACK *ALL* the widgets in frame '$toplevName'. ############################################### ## Pack the bottom button BEFORE the ## bottom x-scrollbar widget, pack $toplevName.butt \ -side bottom \ -anchor center \ -fill none \ -expand 0 if {$VARheight > 10} { ## Pack the scrollbars BEFORE the text widget, ## so that the text does not monopolize the space. pack $toplevName.scrolly \ -side right \ -anchor center \ -fill y \ -expand 0 ## DO NOT USE '-expand 1' HERE on the Y-scrollbar. ## THAT ALLOWS Y-SCROLLBAR TO EXPAND AND PUTS ## BLANK SPACE BETWEEN Y-SCROLLBAR & THE TEXT AREA. pack $toplevName.scrollx \ -side bottom \ -anchor center \ -fill x \ -expand 0 ## DO NOT USE '-expand 1' HERE on the X-scrollbar. ## THAT KEEPS THE TEXT AREA FROM EXPANDING. pack $toplevName.text \ -side top \ -anchor center \ -fill both \ -expand 1 } else { pack $toplevName.text \ -side top \ -anchor center \ -fill both \ -expand 1 } ##################################### ## LOAD MSG INTO TEXT WIDGET. ##################################### ## $toplevName.text delete 1.0 end $toplevName.text insert end $VARtext $toplevName.text configure -state disabled } ## END OF PROC 'popup_msgVarWithScroll' ##+######################## ## END of PROC definitions. ##+######################## ##+##################################################### ##+##################################################### ## ADDITIONAL GUI INITIALIZATION SECTION: ##+##################################################### ##+##################################################### ##+##################################################### ## Set the DIRECTORY variable to be used to specify ## the location of OUTPUT image files --- and the last ## gnuplot script used to make an image file. ##+##################################################### # set DIRout "$env(HOME)" set DIRout "/tmp" ##+##################################################### ## Set the full-name of the RGB COLOR-SELECTOR Tk script ## that is used in several procs above. ##+##################################################### ## FOR TESTING: # puts "argv0: $argv0" set DIRthisScript "[file dirname $argv0]" ## For ease of testing in a Linux/Unix terminal and located at the ## directory containing this Tk script. Set the full directory name. if {"$DIRthisScript" == "."} { set DIRthisScript "[pwd]" } set DIRupOne "[file dirname "$DIRthisScript"]" set DIRupTwo "[file dirname "$DIRupOne"]" set ColorSelectorScript "$DIRupTwo/SELECTORtools/tkRGBselector/sho_colorvals_via_sliders3rgb.tk" ## An alternative: Put the RGB color-selector Tk script in the ## same directory as this Tk script and uncomment the following. # set ColorSelectorScript "$DIRthisScript/sho_colorvals_via_sliders3rgb.tk" ##+##################################################### ## Set a filename for the OUTPUT GNUPLOT SCRIPT(s). ##+##################################################### set userID "$env(USER)" set OUTscript "$DIRout/${userID}_gnuplot.sh" ##+##################################################### ## Set a file 'prefix' for the OUTPUT IMAGE FILE(s). ##+##################################################### set IMGFILEprefix "$DIRout/${userID}_temp" ##+######################################## ## Set the initial plot-color-button colors. ##+######################################## set COLORLINEr 255 set COLORLINEg 0 set COLORLINEb 0 set COLORLINEhex [format "#%02X%02X%02X" $COLORLINEr $COLORLINEg $COLORLINEb ] update_color_button "line" set COLORBKGDr 255 set COLORBKGDg 255 set COLORBKGDb 255 set COLORBKGDhex [format "#%02X%02X%02X" $COLORBKGDr $COLORBKGDg $COLORBKGDb ] update_color_button "bkgd" ## Color for plot border and some axes. ## We hard-code this to black, for now --- ## rather than using another color button on the GUI. set COLORAXISr 0 set COLORAXISg 0 set COLORAXISb 0 set COLORAXIShex [format "#%02X%02X%02X" $COLORAXISr $COLORAXISg $COLORAXISb ] # update_color_button "axis" ## If we ever put a color-button on the GUI for 'axis' color-vars, ## we could activate this proc, to color the button. ##+################################################ ## Set the initial HEAT/PALETTE-color-button colors. ##+################################################ ## Blue (for the deep sea) set heatCOLORLOWr 0 set heatCOLORLOWg 0 set heatCOLORLOWb 255 set heatCOLORLOWhex [format "#%02X%02X%02X" $heatCOLORLOWr $heatCOLORLOWg $heatCOLORLOWb ] update_color_button "low" ## LightBlue (for the shallow sea) set heatCOLORLOWMIDr 100 set heatCOLORLOWMIDg 100 set heatCOLORLOWMIDb 255 set heatCOLORLOWMIDhex [format "#%02X%02X%02X" $heatCOLORLOWMIDr $heatCOLORLOWMIDg $heatCOLORLOWMIDb ] update_color_button "lowmid" ## Green (for the lowlands) set heatCOLORMIDr 0 set heatCOLORMIDg 255 set heatCOLORMIDb 0 set heatCOLORMIDhex [format "#%02X%02X%02X" $heatCOLORMIDr $heatCOLORMIDg $heatCOLORMIDb ] update_color_button "mid" ## Brown (for higher lands) set heatCOLORHIGHMIDr 200 set heatCOLORHIGHMIDg 100 set heatCOLORHIGHMIDb 50 set heatCOLORHIGHMIDhex [format "#%02X%02X%02X" $heatCOLORHIGHMIDr $heatCOLORHIGHMIDg $heatCOLORHIGHMIDb ] update_color_button "highmid" ## White (for snowy mountaintops) set heatCOLORHIGHr 255 set heatCOLORHIGHg 255 set heatCOLORHIGHb 255 set heatCOLORHIGHhex [format "#%02X%02X%02X" $heatCOLORHIGHr $heatCOLORHIGHg $heatCOLORHIGHb ] update_color_button "high" ##+########################################################## ## Set the initial HEAT/PALETTE-colors' (relative) LOCATIONS. ## On a scale of 0 to 99. ## (We can have two the same value, to indicate an abrupt ## color stop-and-start.) ##+########################################################## set ENTRYcolorLocLOW 0 set ENTRYcolorLocLOWMID 25 set ENTRYcolorLocMID 25 set ENTRYcolorLocHIGHMID 60 set ENTRYcolorLocHIGH 99 ##+########################################### ## Set some initial 'surface-hatching' options. ##+########################################### ## 30,30 gives coarse hatched-surface and shaded-surface plots. # set ENTRYsurfaceSamplesX "30" # set ENTRYsurfaceSamplesY "30" set ENTRYsurfaceSamplesX "100" set ENTRYsurfaceSamplesY "100" ## Initialize for a shaded-surface plot. # set ShadedSurface_0or1 1 ## Initialize for a hatched-line plot. set ShadedSurface_0or1 0 ## See page 3xx of 'Gnuplot in Action'. # set ENTRYhatchtype 1 ;# lines parallel to x-axis # set ENTRYhatchtype 2 ;# lines parallel to y-axis # set ENTRYhatchtype 4 ;# diagonal lines, from southwest to northeast set ENTRYhatchtype 3 ;# 1+2 # set ENTRYhatchtype 7 ;# 1+2+4 ## We may put an entry widget on the GUI for this, someday? ## For now, we hard code this parameter. # set HATCHlineWIDTH 1 # set HATCHlineWIDTH 2 # set HATCHlineWIDTH 1.5 set HATCHlineWIDTH 1.2 ##+########################################### ## Set some initial 'viewing' options. ##+########################################### set ENTRYpolarAngle 45 set ENTRYazimuthalAngle 45 ##+########################################### ## Set some initial 'key' options. ##+########################################### # set ENTRYkeyNumFormat "%8.2f" set ENTRYkeyNumFormat "%.1f" # set ENTRYkeyLocation "at 0,0 top left" set ENTRYkeyLocation "top right" # set ENTRYkeyLocation "off" ##+########################################### ## Set some initial 'contour' options. ##+########################################### set ENTRYcontourLevels "10" set ENTRYcontourSamplesX "150" set ENTRYcontourSamplesY "150" set ENTRYcontourLineWidth "1.2" ##+################################################### ## Set the initial settings for plottype radiobuttons. ##+################################################### set RADVARplottype "surf" # set RADVARplottype "cont" # set RADVARplottype "heat" # set RADVARplottype "surfcont" # set RADVARplottype "contheat" ##+################################################### ## Set the initial settings for output radiobuttons ## and entry fields on the GUI. ##+################################################### set RADVARoutimg "gif" # set RADVARoutimg "png" # set RADVARoutimg "jpg" # set RADVARoutimg "ps" # set RADVARoutimg "psbw" # set RADVARoutimg "svg" # set RADVARoutimg "wxt" # set ENTRYxpixels "800" # set ENTRYypixels "600" # set ENTRYxpixels "640" # set ENTRYypixels "480" set ENTRYxpixels "600" set ENTRYypixels "600" .fRbottom.fRright.fRmsg.labelMSG configure -text \ "You can take the initial defaults and simply click on 'Replot'." # "Messages may appear here." ##+################################################## ## Set the image viewers for various image file types. ##+################################################## # set GIFviewer "firefox" # set GIFviewer "seamonkey" # set GIFviewer "/usr/bin/display" # set GIFviewer "/usr/bin/eom" set GIFviewer "/usr/bin/eog" # set PNGviewer "firefox" # set PNGviewer "seamonkey" # set PNGviewer "/usr/bin/display" # set PNGviewer "/usr/bin/eom" set PNGviewer "/usr/bin/eog" # set JPGviewer "firefox" # set JPGviewer "seamonkey" # set JPGviewer "/usr/bin/display" # set JPGviewer "/usr/bin/eom" set JPGviewer "/usr/bin/eog" # set PSviewer "/usr/bin/xpdf" set PSviewer "/usr/bin/evince" # set SVGviewer "firefox" # set SVGviewer "seamonkey" set SVGviewer "/usr/bin/inkscape" ##+################################################## ## Set a text file viewer. ## (In case we ever decide to use one.) ##+################################################## # set TXTFILEviewer "/usr/bin/kedit" # set TXTFILEviewer "/usr/bin/gedit" # set TXTFILEviewer "../../TextTools/tkXpg/xpg" # set TXTFILEviewer "../../shofil.tk" set TXTFILEviewer "$env(HOME)/apps/feXpg/scripts/xpg" ##+########################################### ## Set sample entry field values for testing ## --- and for final release. ##+########################################## set Xmin "*" set Xmax "*" set Ymin "*" set Ymax "*" set Zmin "*" set Zmax "*" set XTICLABELangle "0" # set XTICLABELangle "-45" set YTICLABELangle "0" # set YTICLABELangle "10" set ZTICLABELangle "0" # set ZTICLABELangle "10" set PlotTITLE " PLOT TITLE goes here." set XaxisTITLE " X-axis TITLE goes here." set YaxisTITLE " Y-axis TITLE goes here." set ZaxisTITLE " Z-axis TITLE goes here." if {1} { set ENTRYexpr "sin(x)*cos(y)" set PlotTITLE " PLOT of f(x,y) = sin(x)*cos(y)" set XaxisTITLE " X" set YaxisTITLE " Y" set ZaxisTITLE " Z" .fRbottom.fRright.fRmsg.labelMSG configure -text \ "Click on 'RePlot' to get a plot with the current parameter settings." } if {0} { set ENTRYexpr "sin(x+y)" set PlotTITLE " PLOT of f(x,y) = sin(x+y)" set XaxisTITLE " X" set YaxisTITLE " Y" set ZaxisTITLE " Z" } if {0} { set ENTRYexpr "exp(-(x**2 + y**2))" set PlotTITLE " PLOT of f(x,y) = exp(-(x**2 + y**2))" set XaxisTITLE " X" set YaxisTITLE " Y" set ZaxisTITLE "" } ##+######################################################## ## Set the 'HELPtext' var. ## (Some of the variables set above are used in this text.) ##+######################################################## set HELPtext "\ \ \ ** HELP for this tkGUI FrontEnd for 'gnuplot' - to do 3D-surface and/or 2D-contour-line plots of math expressions of the form f(x,y) ** This is an f(x,y) math-expression 'quick-plot' utility using 'gnuplot' to plot one of several types of plots from the user-specified expression: 1) a 3D surface on one graph with x,y,z axes, or 2) a 2D contour-lines plot with x,y axes, or 3) a 2D 'heat map' plot with x,y axes, or 4) a combined 3D-surface and 2D-contour-lines plot, or 5) a combined 2D-contour-lines and 2D-heat-map plot. This Tk script is meant to be a 'quick' xy-axis math-expression plot utility --- using 'gnuplot' to evaluate user-specified expressions, and allowing the user to easily modify the expression (coefficients, new terms or factors, add/change gnuplot-built-in-function calls, etc.) and re-plot. ####### The GUI: This Tk script presents a GUI to prompt for a math expressions of the form f(x,y) --- that is, an expression involving the 2 independent variables x and y. To facilitate entry of an expression, many sample functions are available via a listbox on the GUI. The user can click (and release) on a line of the listbox and the selected function will be put into the expression entry field of the GUI. The user can choose a function similar to one he/she would like to plot. Once the selected expression is in the expression entry field, the user can alter the function before clicking on the 'RePlot' button. ************************ PLOT APPEARANCE OPTIONS: When the GUI first comes up, the user can simply take all the defaults and click the 'RePlot' button to see a sample plot. In additon to providing an entry field for the math expression, the GUI provides entry fields for specifying - a title for the plot, - x-axis and y-axis and z-axis titles, - x and y and z axis limits (min and max) - output image size, in pixels (x and y). (It may be typical to paste the math expression from the expression entry field into the plot-title field, to assemble a suitable plot title.) The GUI provides 5 radiobuttons for selecting one of the five types of plots (listed above). Since a typical first choice is a '3D surface plot', that is the intial radiobutton setting when the GUI first starts up. If you leave the x,y,z min,max entry fields defaulted to asterisk (*), 'gnuplot' will automatically determine axis limits and tic mark spacings. I may add entry fields for - x-y-z axis tic-mark intervals (someday?). In the meantime, 'gnuplot' will determine the tic-mark spacing, even when you enter numeric min,max limits for the axes, rather than letting 'gnuplot' determine min,max limits. If the tic marks look 'funky', you can experiment with the min,max values to get more pleasant tic marks. ************** OUTPUT OPTIONS: The GUI provides 5 radiobuttons for specifying - output image type (GIF, PNG, JPG, PSc, PSbw, SVG, WXT) where 'PSc' denotes Postscript Color' and 'PSbw' denotes 'Postscript Black-and-White'. SVG is 'Scalable Vector Graphics', an XML file. WXT presents the plot in a terminal, rather than putting the plot in a file. The graphics are done with the 'wxWidgets' graphics library. A 'TestImg' button runs 'gnuplot' in a 'test' mode that displays example line-types and text-orientations and other plot capabilities available with each of these gnuplot output ('terminal') types. ************* COLOR OPTIONS: The GUI has various color buttons to allow you to provide colors for the various types of plots --- for example, a color for the plot background (defaulted to white). Clicking on a color button brings up an RGB color selector Tk GUI to allow for quickly seeing and specifying a color with 3 RGB 'sliders'. ************************* TYPICAL OPERATIONAL STEPS: After specifying an f(x,y) math expression to plot, if the user takes the defaults for the other options on the GUI, the user can simply click on the 'RePlot' button to cause the plot to be rendered and displayed. The user can then change the plot title, x-y-z axis labels, x-y-z axis min-max, (x-y-z tic-mark intervals, someday?) --- and click the 'RePlot' button again. Note that once you have selected a math expression, you can repeatedly edit the expression entry field --- for example, changing the values of coefficients --- and click 'RePlot' after each edit, to see the effects of your editing. ************** OUTPUT DISPLAY: An output image file is displayed --- by an image-display program that is specified at the bottom of this Tk Script via variables named GIFviewer, PNGviewer, JPGviewer, PSviewer, and SVGviewer. The current settings are: GIFviewer: $GIFviewer PNGviewer: $PNGviewer JPGviewer: $JPGviewer PSviewer: $PSviewer SVGviewer: $SVGviewer For example, on Linux, the 'Eye of Gnome' (or 'Eye of MATE') viewer program can be used for GIF, PNG, and JPG files. The image file is put in a directory specified at the bottom of this Tk script. The file will be created with the suffix '.gif' or '.png' or '.jpg' or '.ps' or '.svg'. The prefix of the image filename is set at the bottom of the script in the variable 'IMGFILEprefix' --- which is currently set to $IMGFILEprefix The 'gnuplot' script is also put in a file specified at the bottom of this script via the variable 'OUTscript' --- which is currently set to $OUTscript You can edit this Tk script and change the output directory (DIRout) for the image and script files --- and change the middle-names of these files if you wish. (The userid is currently used in these 2 filenames to avoid overwriting someone else's output if you are working in a shared computing environment.) You can, of course, move these files to another directory if you want to save them. ******************* 'ENHANCED' PLOTTING with the 'gnuplot' script: This Tk GUI is not intended to try to allow for using the hundreds of command options of the 'gnuplot' program. However, if you find that a plot is almost what you want, and you could get what you want by using a few more commands or parameters of 'gnuplot', then you can edit the 'gnuplot' script file --- $OUTscript --- to make changes to the script and execute it again. In fact, if your plot does not popup soon after clicking on the 'RePlot' button, the script may have failed due to a syntax error. In that case, you can go to the directory containing the script and execute it to look for error messages from the script. Then you can edit the script, try to fix the error, and execute it again. ************ DASHED LINES: Although dashed lines are not very useful in doing 3D surface plots, they can be helpful in distinguishing lines of a contour plot. Unfortunately, it appears that 'gnuplot' 4.2 and thereabout can give dashed lines (for linetypes 1 through 29) in Postscript output, but NOT with GIF, PNG, and JPEG output types. For linetypes 1 through 29, 'gnuplot' gives different colored SOLID lines in GIF, PNG, and JPEG output. This is rather unfortunate when you try to make plots for the color-challenged. (About 10 to 15% of the population is color-blind to some extent.) It appears that if you want dashed plot lines, you may have to use Postscript output. *********************************** ADDITIONAL IMAGE PROCESSING OPTIONS: You can do an image capture of the Tk GUI --- with or without an output plot image beside it. For example, on Linux, a screen capture tool such as the 'gnome-screenshot' or 'mate-screenshot' program can be used. If necessary, an image editor (like 'mtpaint' on Linux) can be used to crop the window capture image. The image could also be down-sized in the editor --- say, to make a smaller image suitable for use in a web page or an email. Furthermore, if you want dashed-line plots in a GIF or PNG or JPEG file, you could do a screen capture of Postscript output when it is viewed in a Postscript viewer (such as 'evince' on Linux). The screen capture typically gives a PNG (or GIF or JPEG) file. Then edit that file (crop or resize it) with an image editor. Speaking of using an image editor: I put a time-stamp in the lower-left of the plots. An image editor can be used to crop that time-stamp off of the image or paint over it with the background color of the plot. ************************ 'gnuplot' MATH OPERATORS: VVVVVVVVVVVVVVVV BINARY OPERATORS: ---------------- Operator Example ArgumentType Description --------- ---------- ----------------- --------------- + a+b any numerical addition - a-b any numerical subtraction * a*b any numerical multiplication / a/b any numerical division ** a**b any numerical exponentiation % a%b int modulo == a==b any numerical numerical equality != a!=b any numerical numerical inequality < a a>b any numerical greater than >= a>=b any numerical greater than or equal to & a&b int bitwise AND ^ a^b int bitwise XOR | a|b int bitwise OR && a&&b int logical AND || a||b int logical OR . a.b string string concatenation eq a eq b string string equality ne a ne b string string inequality VVVVVVVVVVVVVVV UNARY OPERATORS: --------------- Operator Example ArgumentType Description --------- ---------- ------------ --------------- - -a any numerical unary minus + +a any numerical unary plus ! !a int logical NOT ! a! int factorial ~ ~a int one's complement VVVVVVVVVVVVVVVV TERNARY OPERATOR: ---------------- a ? b : c evaluates its first argument (which must evaluate to an integer) . If true (nonzero), the second argument is evaluated and returned; otherwise, the third argument is evaluated and returned. VVVVVVVVVVVVVVVVVVVVVVV TRIGONOMETRIC FUNCTIONS: ----------------------- Function Description --------- ----------------------- sin(x), cos(x), tan(x) Trigonometric functions asin(x), acos(x), atan(x) Inverse trigonometric functions atan2(y,x) Evaluates to atan(y/x), but uses the signs of both arguments to determine the resulting quadrant. Arguments must no be complex. VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV EXPONENTIAL, LOGARITHM, SQUAREROOT FUNCTIONS: -------------------------------------------- Function Description ----------- ----------------------- sqrt(x) Square root function exp(x) Exponential function log(x) Natural logarithm (base e) log10(x) Common logarithm (base 10) VVVVVVVVVVVVVVVVVVVVVVVVVVVV SOME COMMONLY USED FUNCTIONS: ---------------------------- Function Description --------- ------------------------------------- abs(x) Absolute value for real or complex x. int(x) Integer part of x, truncated to zero. ceil(x) Smallest integer not less than x (as floating-point value). floor(x) Largest integer not greater than x (as floating-point value). sgn(x) Sign function (-1 if x < 0; 0 if x = 0 ; 1 if x > 0). rand(0) Returns the next pseudo random number (between 0 and 1), using the current values of both seeds. rand(-1) Resets both seeds to a standard value. rand(x) For x>0, sets both seeds to a value based on the value of x. rand({x,y}) For x,y>0, sets the first seed to x and the other seed to y. norm(x) Normal Gaussian) distribution function. norm(x) = 0.5*(1+erf(x/sqrt(2))) VVVVVVVVVVVVVVVVVVVV HYPERBOLIC FUNCTIONS: -------------------- Function Description --------------------------- ----------------------- sinh(x), cosh(x), tanh(x) Hyperbolic functions asinh(x), acosh(x), atanh(x) Inverse hyperbolic functions VVVVVVVVVVVVVVVV BESSEL FUNCTIONS: ---------------- Function Description --------- -------------------------------------------- besj0(x) Bessel function of the first kind of order 0 besy0(x) Bessel function of the second kind of order 0 besj1(x) Bessel function of the first kind of order 1 besy1(x) Bessel function of the second kind of order 1 See 'gnuplot' reference manuals, reference books, and the web for other functions. **************************** ENHANCEMENTS OF THIS UTILITY: I have not tested this script extensively. No doubt, if I use it some more, I will find a few things to change, add, or fix. I do intend to change or add example functions in the listbox, someday. Entry fields could be added to the GUI to allow the user to specify a spacing for x-y-z tic-marks on the axes. Someday? --- Furthermore, I may try to get more appealing plots --- such as color gradient backgrounds --- by using some of the 'gnuplot tricks' of Zoltan Voros, as seen at http://www.phyast.pitt.edu/~zov1/gnuplot/html/gradient.html and http://www.phyast.pitt.edu/~zov1/gnuplot/html/shadowcurve.html and http://www.phyast.pitt.edu/~zov1/gnuplot/html/ribbon.html " ## An alternative ATTEMPT, to FIX the y-height ## of the window, after all widgets are packed: ## ('wm resizeable . 1 0' above did not work as desired.) if {0} { update set winHeightPx [winfo height .] set screenWidthPx [winfo screenwidth .] # set screenWidthPx [winfo vrootwidth .] ## This 'wm maxsize .' DOES NOT SEEM TO WORK ## 'completely as desired' with my window manager. ## The 'MaximizeWindow' button on the top window border always ## maximizes the window to full screensize. wm maxsize . $screenWidthPx $winHeightPx ## FOR TESTING: puts "winHeightPx: $winHeightPx" puts "screenWidthPx: $screenWidthPx" puts "[wm maxsize .]" puts "[wm geometry .]" }