#!/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: tkGnuplotXY_upto3mathExpressions.tk ## ## WHERE in $FEDIR_TKGUIS/PLOTtools/tkGnuplotXY_upto3mathExpressions ## ## 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: A 'quick' xy-axis math expressions plot utility using 'gnuplot' ## to plot up to 3 math expressions on one graph. ## ## Oriented toward plots of many (tens or hundreds of) data points ## -- via connecting lines rather than data point markers. ## ## (But data point markers can be an option --- instead of ## or in addition to the lines connecting data points.) ## _____________________________________________________________ ## ## This Tk script presents a GUI to prompt for up to 3 ## math expressions. ## ## The GUI also allows for specifying a title for the plot, ## x-axis and y-axis titles, x and y axis limits, [x and y axis ## tic-mark intervals (someday?),] plot lines/points/both, ## some colors (of plot lines and plot background), ## output type (PNG, GIF, JPG, PS, SVG) and image size in pixels. ## ##+######################### ## TYPICAL OPERATIONAL STEPS: ## ## After specifying the math expressions in entry fields 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). ## ##+################# ## THE GUI WIDGETS: ## ## The options available to the user are indicated by ## the following 'sketch' of the GUI: ## ## FRAMEnames ## VVVVVVVVVV ## ------------------------------------------------------------------------------------------ ## Gnuplot of up to 3 math expressions: ## [window title] ## ------------------------------------------------------------------------------------------ ## ## .fRbuttons {Exit} {Help} {RePlot} {Color of {Color of {Color of Load Expression: O 1 O 2 O 3 ## Lines} background} axes} ## ## [.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 ## -------------] ## ## .fRexpr1 |---------------A Expression1: _________________________________________________________ ## | | ## .fRexpr2 | [ This | Expression2: _________________________________________________________ ## | listbox | ## .fRexpr3 | contains | Expression3: _________________________________________________________ ## | math | ## .fRtitle | expressions ] | Plot title: __________________________________________________________ ## | | ## .fRxaxis | | XaxisMin:______ XaxisMax:_______ XticLabelsAngle: ___ _____X-axis label______ ## | | ## .fRyaxis | | YaxisMin:______ YaxisMax:_______ YticLabelsAngle: ___ _____Y-axis label______ ## | | ## .fRlinetypes | | Expr1LineType(1-29): __ Expr2LineType(1-29): __ Expr3LineType(1-29): __ ## | | ## .fRplotopts | | PlotType: O Line O Point O Both LineWidth(1-6): 1 ## | | ## .fRoutopts | | ImageOutType: O GIF O PNG O JPG O PS O SVG {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 ## ## - 7 button widgets ## - 19 label widgets ## - 17 entry widgets (3 more could be added to specify tic-mark interval) ## - 11 radiobutton widgets in 3 groups ## - 1 listbox widget with 2 scrollbars ## - 0 checkbutton widgets ## - 0 scale widgets ## ##+#################################################################### ## CALLED BY: This Tk script can be called by the command name ## ## $FEDIR/tkGUIs/PlotTools/tkGnuplotXY_upto3mathExpressions.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): ## up to 3 math expressions, ## plot title, xy axis-labels, xy axis min-max, ## xy-tic-labels-angle, line-types, ## (xy tic-mark intervals, someday?), ## 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. 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': 'fRleft', 'fRright' ## In frame 'fRright': ## 'fRexpr1', 'fRexpr2', 'fRexpr3', 'fRtitle', 'fRxaxis', 'fRyaxis', ## 'fRlinetypes', 'fRplotopts', '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: ## - 'fRexpr1' contains 1 label & 1 entry widget. ## - 'fRexpr2' contains 1 label & 1 entry widget. ## - 'fRexpr3' contains 1 label & 1 entry widget. ## - 'fRtitle' contains 1 label & 1 entry widget. ## - 'fRxaxis' contains several label & entry widgets. ## - 'fRyaxis' contains several label & entry widgets. ## - 'fRlinetypes' contains 3 pairs of label & entry widgets. ## - 'fRplotopts' contains several radiobuttons and a label & entry widget pair. ## - '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.) ## (Could (re)set contents of axis limits in entry widgets.) ## ## 'display_test_img' - called by 'TestImg' button ## ## 'edit_inputs' - called by 'replot' proc ## ## 'getset_color' - called by 'LineColor' 'BkgdColor' 'AxisColor' buttons ## 'update_color_botton' - called by 'getset_color' proc and 3 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 2015oct08 Started this script based on ## some code from several other ## FE 'tkGooies' scripts. ## Updated by: Blaise Montandon 2015oct12 Added a label to show number of ## lines in the listbox. Added ## '-width' parm to some labels, ## to get some X,Y entry fields ## lined up vertically. ## Updated by: Blaise Montandon 2015oct14 Added 'ClearTitle' button and ## renamed 'Clear' button to 'ClearExpr'. ## Added code to 'replot' proc to set ## PlotTITLE to ENTRYexpr1 if PlotTITLE ## is blank. ##+####################################################################### ##+####################################################################### ## Set WINDOW TITLES and POSITION. ##+####################################################################### wm title . "tkGnuplotXY - of up to 3 math expressions" wm iconname . "tkGnuplotExpr" # 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" 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 set RELIEF_label_lo "flat" set RELIEF_label_hi "groove" ## relief must be: flat, groove, raised, ridge, solid, or sunken ## 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 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 # set RELIEF_chkbutt_hi "groove" # set RELIEF_chkbutt_lo "flat" ## LISTBOX geom settings: set BDwidthPx_listbox 2 set initListboxWidthChars 25 set initListboxHeightChars 8 ## SCALE geom parameters: # set BDwidthPx_scale 2 # set initScaleLengthPx 300 # set scaleWidthPx 10 ##+###################################################### ## Set a MIN-SIZE of the window (roughly). ## ## Set approx MIN WIDTH according to widgets across 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 Color of "] 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 '.fRexpr1' frame ## 1 char high for the '.fRexpr2' frame ## 1 char high for the '.fRexpr3' frame ## 1 char high for the '.fRtitle' frame ## 1 char high for the '.fRxaxis' frame ## 1 char high for the '.fRyaxis' frame ## 1 char high for the '.fRlinetypes' frame ## 1 char high for the '.fRplotopts' 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 11x4 pixels for frame/widget borders of the 11 frames. set charHeightPx [font metrics fontTEMP_fixedwidth -linespace] set minWinHeightPx [expr {64 + ( 12 * $charHeightPx )} ] ## FOR TESTING: # puts "minWinWidthPx = $minWinWidthPx" # puts "minWinHeightPx = $minWinHeightPx" wm minsize . $minWinWidthPx $minWinHeightPx ## We allow the window to be resizable and we pack the canvas with ## '-fill both' so that the canvas can be enlarged by enlarging the ## window. ## 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. 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(buttonCOLORAXIS) "Color of Axes" set aRtext(labelLOADEXPR) " Load Expression:" set aRtext(radbuttLOADEXPR1) "1" set aRtext(radbuttLOADEXPR2) "2" set aRtext(radbuttLOADEXPR3) "3" set aRtext(buttonCLEAREXPR) "ClearExpr" set aRtext(buttonCLEARTITLE) "ClearTitle" set aRtext(buttonAUTOSCALE) "Autoscale" ## For widgets in 'fRexpr1' frame: set aRtext(labelEXPR1) "Expression1:" ## For widgets in 'fRexpr2' frame: set aRtext(labelEXPR2) "Expression2:" ## For widgets in 'fRexpr3' frame: set aRtext(labelEXPR3) "Expression3:" ## For widgets in 'fRtitle' frame: set aRtext(labelPLOTTITLE) "Plot title:" ## 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 'fRlinetypes' frame: set aRtext(labelLINETYPE1) "Expr1 LineType(1-29):" set aRtext(labelLINETYPE2) " Expr2 LineType(1-29):" set aRtext(labelLINETYPE3) " Expr3 LineType(1-29):" ## For widgets in 'fRplotopts' frame: set aRtext(labelPLOTTYPE) "Plot type:" set aRtext(radbuttLINES) "Lines" set aRtext(radbuttPOINTS) "Points" set aRtext(radbuttLINESPOINTS) "Both" set aRtext(labelLINEWIDTH) " Line Width (1-6):" ## 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: ## - 'fRexpr1' contains 1 label & 1 entry widget. ## - 'fRexpr2' contains 1 label & 1 entry widget. ## - 'fRexpr3' contains 1 label & 1 entry widget. ## - 'fRtitle' contains 1 label & 1 entry widget. ## - 'fRxaxis' contains several label & entry widgets. ## - 'fRyaxis' contains several label & entry widgets. ## - 'fRlinetypes' contains 3 pairs of label & entry widgets. ## - 'fRplotopts' contains radiobuttons and one pair of label & entry widgets. ## - 'fRoutopts' contains radiobutton 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 -relief raised -bd 2 frame .fRbottom.fRright.fRexpr1 -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRexpr2 -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRexpr3 -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRtitle -relief $RELIEF_frame -bd $BDwidthPx_frame # frame .fRbottom.fRright.fRtitle -relief raised -bd 2 frame .fRbottom.fRright.fRxaxis -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRyaxis -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRlinetypes -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRplotopts -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRbottom.fRright.fRoutopts -relief $RELIEF_frame -bd $BDwidthPx_frame 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.fRexpr1 \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRexpr2 \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRexpr3 \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRtitle \ -side top \ -anchor nw \ -fill x \ -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.fRlinetypes \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRbottom.fRright.fRplotopts \ -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. ##+############################################################### ##+############################################################### ##+####################################################### ## 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_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_color "bkgd"} button .fRbuttons.buttAXIScolor \ -text "$aRtext(buttonCOLORAXIS)" \ -font fontTEMP_SMALL_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {getset_color "axis"} ## If the axis (or points) color option is de-activated: # -command {popup_msgVarWithScroll .topHelp "This Axes color option is not implemented yet." +10+300} ## DEFINE a LABEL and 3 RADIOBUTTONS for 'LoadExpressionNum' indicator : ## (1 or 2 or 3) label .fRbuttons.labelLOADEXPR \ -text "$aRtext(labelLOADEXPR)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo radiobutton .fRbuttons.radbuttLOADEXPR1 \ -text "$aRtext(radbuttLOADEXPR1)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARloadExprNum \ -value "1" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbuttons.radbuttLOADEXPR2 \ -text "$aRtext(radbuttLOADEXPR2)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARloadExprNum \ -value "2" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbuttons.radbuttLOADEXPR3 \ -text "$aRtext(radbuttLOADEXPR3)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARloadExprNum \ -value "3" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi 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.buttCLEARTITLE \ -text "$aRtext(buttonCLEARTITLE)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {set PlotTITLE ""} 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 \ .fRbuttons.buttAXIScolor \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbuttons.labelLOADEXPR \ .fRbuttons.radbuttLOADEXPR1 \ .fRbuttons.radbuttLOADEXPR2 \ .fRbuttons.radbuttLOADEXPR3 \ .fRbuttons.buttCLEAREXPR \ .fRbuttons.buttCLEARTITLE \ .fRbuttons.buttAUTOSCALE \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbuttons.labNUMFUNCS \ -side right \ -anchor e \ -fill none \ -expand 0 ##+######################################################## ## 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 are to be added here: .fRbottom.fRleft.listbox insert end "## Some exponential curves:" .fRbottom.fRleft.listbox insert end "exp(-x/10.0)*sin(x) # an oscillating, decaying exponential curve" .fRbottom.fRleft.listbox insert end "exp(-x/10.0) # a decaying exponential curve - upper-bound of curve above" .fRbottom.fRleft.listbox insert end "-exp(-x/10.0) # an increasing exponential curve - lower-bound of curve above" .fRbottom.fRleft.listbox insert end "## Some polynomial curves:" .fRbottom.fRleft.listbox insert end "x*x*x - 5*x*x + x + 20 # a cubic plynomial" .fRbottom.fRleft.listbox insert end "(1.0 * x**3) - (5.0 * x**2) + (1.0 * x) + 20 # the same cubic written with integer exponents, explicit coefficients, and parentheses" .fRbottom.fRleft.listbox insert end "## Some bounded sinusoidal curves:" .fRbottom.fRleft.listbox insert end "1.0*sin(1.0*x+0.0) + 1.0*cos(1.0*x+0.0) # a linear combination of sin and cos" .fRbottom.fRleft.listbox insert end "0.5*cos(x) + 1.25 # a cosine function" .fRbottom.fRleft.listbox insert end "-cos(x)/(1 + 0.1*x**2) # cosine modified by a distribution function" .fRbottom.fRleft.listbox insert end "## Some trigonometric curves:" .fRbottom.fRleft.listbox insert end "1.0*tan(x) # an unbounded trig function" .fRbottom.fRleft.listbox insert end "## Some distribution curves:" .fRbottom.fRleft.listbox insert end "exp(-x**2) # Gaussian distribution function" .fRbottom.fRleft.listbox insert end "1/(1+x**2) # Lorentzian distribution function" .fRbottom.fRleft.listbox insert end "## Some hyperbolic sin/cosn curves:" .fRbottom.fRleft.listbox insert end "1/cosh(x) + 2 # reciprocal of hyperbolic cosine function" ##+############################################################## ## 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 ##+######################################################## ## IN THE '.fRbottom.fRright.fRexpr1' frame -- ## DEFINE 1 pair of LABEL, ENTRY WIDGETs. THEN PACK EM. ##+######################################################## label .fRbottom.fRright.fRexpr1.lab \ -text "$aRtext(labelEXPR1)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label entry .fRbottom.fRright.fRexpr1.ent \ -textvariable ENTRYexpr1 \ -width $initExpressionWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK widgets in frame '.fRbottom.fRright.fRexpr1' ## --- individually, for expansion control. pack .fRbottom.fRright.fRexpr1.lab \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRexpr1.ent \ -side left \ -anchor w \ -fill x \ -expand 1 ##+######################################################## ## IN THE '.fRbottom.fRright.fRexpr2' frame -- ## DEFINE 1 pair of LABEL, ENTRY WIDGETs. THEN PACK EM. ##+######################################################## label .fRbottom.fRright.fRexpr2.lab \ -text "$aRtext(labelEXPR2)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label entry .fRbottom.fRright.fRexpr2.ent \ -textvariable ENTRYexpr2 \ -width $initExpressionWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK widgets in frame '.fRbottom.fRright.fRexpr2' ## --- individually, for expansion control. pack .fRbottom.fRright.fRexpr2.lab \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRexpr2.ent \ -side left \ -anchor w \ -fill x \ -expand 1 ##+######################################################## ## IN THE '.fRbottom.fRright.fRexpr3' frame -- ## DEFINE 1 pair of LABEL, ENTRY WIDGETs. THEN PACK EM. ##+######################################################## label .fRbottom.fRright.fRexpr3.lab \ -text "$aRtext(labelEXPR3)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label entry .fRbottom.fRright.fRexpr3.ent \ -textvariable ENTRYexpr3 \ -width $initExpressionWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK widgets in frame '.fRbottom.fRright.fRexpr3' ## --- individually, for expansion control. pack .fRbottom.fRright.fRexpr3.lab \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRexpr3.ent \ -side left \ -anchor w \ -fill x \ -expand 1 ##+######################################################## ## 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 widgets in frame '.fRtitle' ## --- individually, for expansion control. 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 ##+######################################################## ## 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. ##+########################################### entry .fRbottom.fRright.fRxaxis.entXTITLE \ -textvariable XaxisTITLE \ -width $initTitleWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+##################################################### ## PACK the widgets in frame '.fRbottom.fRright.fRxaxis' ## --- individually, for ease of experimentation with ## x-expansion of the right-most (title) entry widget. ##+##################################################### pack .fRbottom.fRright.fRxaxis.labXmin \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRxaxis.entXmin \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRxaxis.labXmax \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRxaxis.entXmax \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRxaxis.labXTICLABELangle \ -side left \ -anchor w \ -fill none \ -expand 0 pack .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 ##+####################################################### ## 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. ##+####################################################### entry .fRbottom.fRright.fRyaxis.entYTITLE \ -textvariable YaxisTITLE \ -width $initTitleWidthChars \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+###################################################### ## PACK the widgets in frame '.fRbottom.fRright.fRyaxis' ## --- individually, for ease of experimentation with ## x-expansion of the right-most (title) entry widget. ##+###################################################### pack .fRbottom.fRright.fRyaxis.labYmin \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRyaxis.entYmin \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRyaxis.labYmax \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRyaxis.entYmax \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRyaxis.labYTICLABELangle \ -side left \ -anchor w \ -fill none \ -expand 0 pack .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 ##+####################################################### ## IN THE '.fRbottom.fRright.fRlinetypes' frame -- ## DEFINE 3 pairs of LABEL & ENTRY WIDGETS for line-types. ## THEN PACK the widgets. ##+####################################################### label .fRbottom.fRright.fRlinetypes.labLINETYPE1 \ -text "$aRtext(labelLINETYPE1)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRlinetypes.entLINETYPE1 \ -textvariable LineType1 \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRlinetypes.labLINETYPE2 \ -text "$aRtext(labelLINETYPE2)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRlinetypes.entLINETYPE2 \ -textvariable LineType2 \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry label .fRbottom.fRright.fRlinetypes.labLINETYPE3 \ -text "$aRtext(labelLINETYPE3)" \ -font fontTEMP_varwidth \ -padx $PADXpx_label \ -pady $PADYpx_label \ -justify left \ -anchor w entry .fRbottom.fRright.fRlinetypes.entLINETYPE3 \ -textvariable LineType3 \ -width 3 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ##+######################################################### ## PACK the widgets in frame '.fRbottom.fRright.fRlinetypes' ## --- individually, for possible experimentation with ## x-expansion of the entry widgets. ##+######################################################### pack .fRbottom.fRright.fRlinetypes.labLINETYPE1 \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRlinetypes.entLINETYPE1 \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRlinetypes.labLINETYPE2 \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRlinetypes.entLINETYPE2 \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRlinetypes.labLINETYPE3 \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRlinetypes.entLINETYPE3 \ -side left \ -anchor w \ -fill none \ -expand 0 ##+####################################################### ## IN THE '.fRbottom.fRright.fRplotopts' frame -- ## DEFINE a LABEL WIDGET with several RADIOBUTTON widgets ## (for Lines, Points, or Both) and ## 1 pairs of LABEL & ENTRY WIDGET (for line-width). ## THEN PACK THEM. ##+####################################################### ## DEFINE a LABEL and RADIOBUTTONS for PLOT TYPE : ## (lines or points or both) label .fRbottom.fRright.fRplotopts.labelPLOTTYPE \ -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.fRplotopts.radbuttLINES \ -text "$aRtext(radbuttLINES)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "lines" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRplotopts.radbuttPOINTS \ -text "$aRtext(radbuttPOINTS)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "points" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi radiobutton .fRbottom.fRright.fRplotopts.radbuttLINESPOINTS \ -text "$aRtext(radbuttLINESPOINTS)" \ -font fontTEMP_varwidth \ -anchor w \ -variable RADVARplottype \ -value "linespoints" \ -selectcolor "$radiobuttBKGD" \ -padx $PADXpx_radbutt \ -pady $PADYpx_radbutt \ -bd $BDwidthPx_radbutt \ -relief $RELIEF_radbutt_hi label .fRbottom.fRright.fRplotopts.labelLINEWIDTH \ -text "$aRtext(labelLINEWIDTH)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -padx $PADXpx_label \ -pady $PADYpx_label \ -bd $BDwidthPx_label \ -relief $RELIEF_label_lo entry .fRbottom.fRright.fRplotopts.entLINEWIDTH \ -textvariable lineWIDTH \ -width 1 \ -font fontTEMP_fixedwidth \ -bg $entryBKGD \ -relief sunken \ -bd $BDwidthPx_entry ## PACK all the widgets in frame '.fRbottom.fRright.fRplotopts'. pack .fRbottom.fRright.fRplotopts.labelPLOTTYPE \ .fRbottom.fRright.fRplotopts.radbuttLINES \ .fRbottom.fRright.fRplotopts.radbuttPOINTS \ .fRbottom.fRright.fRplotopts.radbuttLINESPOINTS \ -side left \ -anchor center \ -fill none \ -expand 0 pack .fRbottom.fRright.fRplotopts.labelLINEWIDTH \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbottom.fRright.fRplotopts.entLINEWIDTH \ -side left \ -anchor w \ -fill none \ -expand 0 ##+####################################################### ## 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 Xpixels \ -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 Ypixels \ -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 '.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} ##+################################################################## ##+################################################################## ## DEFINE PROCEDURES: ## ## 'listboxSelectionTOexprField' - called by button1-release binding ## on the listbox ## ## 'clear_expr' - called by 'Clear' button ## ## 'replot' - called by 'Plot' button ## (Writes gnuplot script and executes it.) ## (Could (re)set contents of axis limits in entry widgets.) ## ## 'display_test_img' - called by 'Test' button ## ## 'edit_inputs' - called by 'replot' proc ## ## 'getset_color' - called by 'LineColor' 'AxisColor' 'BkgdColor' buttons ## 'update_color_button' - called by 'getset_color' proc and 3 times in the ## 'Additional GUI Initialization' section. ## ## 'popup_msgVarWithScroll' - called by 'Help' button to show HELPtext var. ## ##+################################################################## ##+################################################################## ##+######################################################################### ## proc 'listboxSelectionTOexprField' ##+######################################################################### ## PURPOSE: Calls on a 'load_parameters_frame_XXX' proc ## depending on the model-types listbox line selected. ## ## CALLED BY: button1-release on the model-types listbox ## ## See the listbox insert statements above (where the listbox widget was ## defined) for the model-type ID strings that were loaded in the listbox. ##+######################################################################### proc listboxSelectionTOexprField {} { global ENTRYexpr1 ENTRYexpr2 ENTRYexpr3 RADVARloadExprNum 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 appropriate math-expression entry field of the GUI. ##################################################################################### if {"$RADVARloadExprNum" == "1"} {set ENTRYexpr1 "$HOLDexpr"} if {"$RADVARloadExprNum" == "2"} {set ENTRYexpr2 "$HOLDexpr"} if {"$RADVARloadExprNum" == "3"} {set ENTRYexpr3 "$HOLDexpr"} } ## END OF PROC 'listboxSelectionTOexprField' ##+##################################################################### ## proc 'clear_expr' ##+##################################################################### ## PURPOSE: Clear an expression field indicated by the setting ## of the LoadExpression radiobuttons. ## ## CALLED BY: .fRbuttons.buttCLEAR ##+##################################################################### proc clear_expr {} { global RADVARloadExprNum ENTRYexpr1 ENTRYexpr2 ENTRYexpr3 if {"$RADVARloadExprNum" == "1"} {set ENTRYexpr1 ""} if {"$RADVARloadExprNum" == "2"} {set ENTRYexpr2 ""} if {"$RADVARloadExprNum" == "3"} {set ENTRYexpr3 ""} } ## END OF PROC 'clear_expr' ##+##################################################################### ## proc 'set_autoscale' ##+##################################################################### ## PURPOSE: Set Xmin,Xmax,Ymin,Ymax input fields to asterisks to ## cause plot to autoscale. ## ## CALLED BY: .fRbuttons.buttAUTOSCALE ##+##################################################################### proc set_autoscale {} { global Xmin Xmax Ymin Ymax set Xmin "*" set Xmax "*" set Ymin "*" set Ymax "*" } ## END OF PROC 'set_autoscale' ##+#################################################################### ## PROC: 'replot' ##+#################################################################### ## PURPOSE: ## Builds a 'gnuplot' script using the parameters from the ## GUI and the data filename specified. ## ## 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: button .fRbuttons.buttPLOT ##+#################################################################### proc replot {} { global OUTscript IMGFILEprefix global PlotTITLE XaxisTITLE YaxisTITLE global ENTRYexpr1 ENTRYexpr2 ENTRYexpr3 global Xmin Xmax Ymin Ymax global XTICLABELangle YTICLABELangle global LineType1 LineType2 LineType3 global RADVARplottype lineWIDTH global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global Xpixels Ypixels global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global COLORAXISr COLORAXISg COLORAXISb COLORAXIShex global EDITcode ## If PlotTITLE is empty, load it with ENTRYexpr1 --- ## to help the user remember what is in the plot image. ## (If the user does not want a title, the image can be edited to ## 'white-out' the title.) ## The user can then add-to/change the title and do a re-plot. if {"$PlotTITLE" == ""} {set PlotTITLE "$ENTRYexpr1"} ## 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" ## 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 $Xpixels , $Ypixels \ nocrop noenhanced butt $xCOLORBKGDhex $xCOLORAXIShex $xCOLORAXIShex" set IMGfile "${IMGFILEprefix}.gif" set IMGviewer "$GIFviewer" } if {"$RADVARoutimg" == "png"} { puts $SHout "set terminal png size $Xpixels , $Ypixels \ nocrop noenhanced butt $xCOLORBKGDhex $xCOLORAXIShex $xCOLORAXIShex" set IMGfile "${IMGFILEprefix}.png" set IMGviewer "$PNGviewer" } if {"$RADVARoutimg" == "jpg"} { puts $SHout "set terminal jpeg size $Xpixels , $Ypixels \ 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 $Xpixels , $Ypixels 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'" } ################################### ## 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'" ##################################### ## Set axis labels. puts $SHout "set xlabel '$XaxisTITLE'" puts $SHout "set ylabel '$YaxisTITLE'" ##################################### ## Set axis limits. puts $SHout "set xrange \[ $Xmin : $Xmax \]" puts $SHout "set yrange \[ $Ymin : $Ymax \]" ##################################### ## Set x-axis tic marks. puts $SHout "set xtics rotate by $XTICLABELangle" ## No mid-x-tickmarks puts $SHout "set nomxtics" ## Example of setting x-tic-marks manually: # set xtics 0, 5 , 100 ##################################### ## Set y-axis tic marks. puts $SHout "set ytics rotate by $YTICLABELangle" ## No mid-y-tickmarks puts $SHout "set nomytics" ## Example of setting y-tic-marks manually: # set ytics 0, 5 , 100 #################################### ## Force vertical axis thru x=0. puts $SHout "set xzeroaxis" ################################### ## Force horizontal axis thru y=0. puts $SHout "set yzeroaxis" ################################### ## Set a PLOTTYPE var to be used in the plot command. if {"$RADVARplottype" == "lines"} { set PLOTTYPE "with lines linewidth $lineWIDTH linecolor rgb '$COLORLINEhex'" } if {"$RADVARplottype" == "points"} { set PLOTTYPE "with points" } if {"$RADVARplottype" == "linespoints"} { set PLOTTYPE "with linespoints linewidth $lineWIDTH linecolor rgb '$COLORLINEhex'" } ############################################## ## Request PLOT LEGEND a.k.a. 'key' --- or not. ## Options: ## set nokey ## set key top right ## set key bottom right ## set key top left ## set key bottom left puts $SHout "set nokey" ################################# ## Set functions f(x), g(x), h(x). if {"$ENTRYexpr1" != ""} {puts $SHout "f(x) = $ENTRYexpr1"} if {"$ENTRYexpr2" != ""} {puts $SHout "g(x) = $ENTRYexpr2"} if {"$ENTRYexpr3" != ""} {puts $SHout "h(x) = $ENTRYexpr3"} ###################### ## The PLOT COMMAND(s): ## if {"$ENTRYexpr2" == ""} { ## If the 2nd expression entry field is empty, just plot f(x). puts $SHout "plot \[$Xmin:$Xmax\] f(x) $PLOTTYPE linetype $LineType1" } elseif {"$ENTRYexpr3" == ""} { ## If the 3rd expression entry field is empty (and the 2nd is not), plot f(x) and g(x). puts $SHout "plot \[$Xmin:$Xmax\] f(x) $PLOTTYPE linetype $LineType1 \\" puts $SHout ", g(x) $PLOTTYPE linetype $LineType2" } else { ## If we got here, all 3 expression entry fields are non-empty, so plot all 3. puts $SHout "plot \[$Xmin:$Xmax\] f(x) $PLOTTYPE linetype $LineType1 \\" puts $SHout ", g(x) $PLOTTYPE linetype $LineType2 \\" puts $SHout ", h(x) $PLOTTYPE linetype $LineType3" } ################################### ## COULD ADD A LABEL anywhere on the plot, ## if we added some entry fields on the GUI for the into: ## # 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 'replot' ##+#################################################################### ## 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 IMGFILEprefix global RADVARoutimg GIFviewer PNGviewer JPGviewer PSviewer SVGviewer global Xpixels Ypixels ## 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" ## Set output (terminal) type and ## set a filename for the output image file. if {"$RADVARoutimg" == "gif"} { puts $SHout "set terminal gif size $Xpixels , $Ypixels" set IMGfile "${IMGFILEprefix}.gif" set IMGviewer "$GIFviewer" } if {"$RADVARoutimg" == "png"} { puts $SHout "set terminal png size $Xpixels , $Ypixels" set IMGfile "${IMGFILEprefix}.png" set IMGviewer "$PNGviewer" } if {"$RADVARoutimg" == "jpg"} { puts $SHout "set terminal jpeg size $Xpixels , $Ypixels" 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 $Xpixels , $Ypixels" puts $SHout "set terminal svg size $Xpixels , $Ypixels 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'" } 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: 'edit_inputs' ##+##################################################################### ## PURPOSE: ## ## CALLED BY: proc 'replot' ##+##################################################################### proc edit_inputs {} { global ENTRYexpr2 ENTRYexpr3 global Xmin Xmax Ymin Ymax global Xpixels Ypixels lineWIDTH ## 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" ######################################################################### ## Check that ENTRYexpr2 is nonblank if ENTRYexpr3 is nonblank. ######################################################################### set ENTRYexpr2 [string trim $ENTRYexpr2] set ENTRYexpr3 [string trim $ENTRYexpr3] if {"$ENTRYexpr2" == "" && "$ENTRYexpr3" != ""} { popup_msgVarWithScroll .topErr "Expression2 is blank, but Expr3 is not. Move 3 to 2." $ERRMSGloc set EDITcode 1 return } ####################################################### ## Remove trailing and leading blanks (if any) from the ## user entries in the 'entry' widgets. ####################################################### set Xmin [string trim $Xmin] set Ymin [string trim $Ymin] set Xmax [string trim $Xmax] set Ymax [string trim $Ymax] set Xpixels [string trim $Xpixels] set Ypixels [string trim $Ypixels] set lineWIDTH [string trim $lineWIDTH] ######################################################################### ## 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 } } ########################################################## ## Check that Xpixels, Ypixels, lineWIDTH are integers. ########################################################## if {![string is integer -strict "$Xpixels"]} { popup_msgVarWithScroll .topErr "Xpixels is NOT NUMERIC." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$Ypixels"]} { popup_msgVarWithScroll .topErr "Ypixels is NOT NUMERIC." $ERRMSGloc set EDITcode 1 return } if {![string is integer -strict "$lineWIDTH"]} { popup_msgVarWithScroll .topErr "Line WIDTH is NOT NUMERIC." $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' ## ## Arguments: none ## ## CALLED BY: .fRbuttons.buttLINEcolor button ##+##################################################################### proc getset_color {colorID} { global COLORLINEr COLORLINEg COLORLINEb COLORLINEhex global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex global COLORAXISr COLORAXISg COLORAXISb COLORAXIShex global ColorSelectorScript 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 } 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 } 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 the ## 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 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 # 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" } } else { ## Seems to be an invalid colorID. return } } ## END OF PROC 'update_color_button' ##+######################################################################## ## 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 the DIRECTORY variable to be used to specify ## a starting location to look for INPUT data files. ##+##################################################### # set DIRin "/tmp" # set DIRin "$env(HOME)" set DIRin "$DIRthisScript" ##+##################################################### ## 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 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 COLORAXISr 0 set COLORAXISg 0 set COLORAXISb 0 set COLORAXIShex [format "#%02X%02X%02X" $COLORAXISr $COLORAXISg $COLORAXISb ] update_color_button "axis" set COLORBKGDr 255 set COLORBKGDg 255 set COLORBKGDb 255 set COLORBKGDhex [format "#%02X%02X%02X" $COLORBKGDr $COLORBKGDg $COLORBKGDb ] update_color_button "bkgd" ##+################################################### ## Set the initial settings for various radiobuttons ## and entry fields at the bottom of the GUI. ##+################################################### set RADVARloadExprNum 1 # set RADVARloadExprNum 2 # set RADVARloadExprNum 3 set RADVARplottype "lines" # set RADVARplottype "points" # set RADVARplottype "linespoints" set lineWIDTH 1 # set lineWIDTH 2 set RADVARoutimg "gif" # set RADVARoutimg "png" # set RADVARoutimg "jpg" # set RADVARoutimg "ps" # set RADVARoutimg "psbw" # set RADVARoutimg "svg" # set Xpixels "800" # set Ypixels "600" # set Xpixels "640" # set Ypixels "480" set Xpixels "600" set Ypixels "400" # set Xpixels "320" # set Ypixels "240" .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 text file viewer. ##+################################################## # 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 XTICLABELangle "0" # set XTICLABELangle "-45" set YTICLABELangle "0" # set YTICLABELangle "10" set LineType1 "1" set LineType2 "2" set LineType3 "3" set PlotTITLE " PLOT TITLE goes here." set XaxisTITLE " X-axis TITLE goes here." set YaxisTITLE " Y-axis TITLE goes here." if {1} { set ENTRYexpr1 "sin(x)" set ENTRYexpr2 "" set ENTRYexpr3 "" } if {0} { set ENTRYexpr1 "sin(x)" set ENTRYexpr2 "cos(x)" set ENTRYexpr3 "csc(x)" } if {0} { set ENTRYexpr1 "sin(x)" set ENTRYexpr2 "cos(x)" set ENTRYexpr3 "tan(x)" } if {0} { set ENTRYexpr1 "sin(x)" set ENTRYexpr2 "exp(x)" set ENTRYexpr3 "log(x)" } ##+######################################################## ## 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 X-Y plots of up to 3 math expressions on one graph ** 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 expressions (coefficients, new terms, new function calls, etc.) and re-plot. This utility is oriented toward plots of many (tens or hundreds of) data points -- via connecting lines rather than data point markers. But data point markers can be an option --- instead of (or in addition to) the lines connecting data points. ******* The GUI: This Tk script presents a GUI to prompt for 1, 2, or 3 math expressions. To facilitate entry of functions, 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 corresponding function will be put in one of the 3 expression entry fields of the GUI. Which entry field is the target is determined by the 3 radiobuttons at the top-right of the GUI. Check that the radiobuttons are set appropriately before clicking on a line of the listbox. --- The user can choose a function similar to one he/she would like to plot. Once the selected expression is in an expression entry field, the user can alter the function before clicking on the 'RePlot' button. The GUI also provides entry fields for specifying - a title for the plot, - x-axis and y-axis titles, - x and y axis limits (min and max) - output image size, in pixels (x and y). If you leave the min,max entry fields defaulted to asterisk (*), 'gnuplot' will automatically determine axis limits and tic mark spacings. I may add entry fields for - x and y axis tic-mark intervals (someday?). In the meantime, 'gnuplot' will determine the tic-mark spacing, even if you specify 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. The GUI also provides 3 radiobuttons for specifying whether to plot with lines, points, or both. Since the usual choice is 'lines', that is the intial setting when the GUI first starts up. ************ OUTPUT TYPES: (gnuplot 'terminal types') The GUI provides 5 radiobuttons for specifying - output image file type (GIF, PNG, JPG, PS, PSbw, SVG, or WXT) or what 'gnuplot' calls the 'terminal type'. The GIF, PNG, and JPG options cause 'gnuplot' to put the output plot image in a '.gif' or '.png' or '.jpg' file. The PS and PSbw options create a '.ps' Postscript file --- color or black-and-white. The SVG (Scalable Vector Graphics) option creates a '.svg' file, which is a rather large text XML file. An SVG file can be displayed by the Inkscape SVG editor program or by most web browsers. The WXT option does not create a file, but puts the plot output in a 'wxt' terminal. The 'wxt' terminal uses the wxWidgets library, which is where the 'wx' comes from. The actual drawing is done via Cairo, a 2D graphics library, and Pango, a library for laying out and rendering text. The 'wxt' terminal may offer the ability to get some high-quality output, because it may offer better quality lines and text (perhaps due to better anti-aliasing). However, the 'wxt' terminal does not write to an image file. The output is put in a terminal window. To get an image file, the user can use a screen-capture utility (such as 'gnome-screenshot' on Linux) to get the image in a PNG file. Then an image editor (such as 'mtpaint' on Linux) can be used to crop and resize the image file, if necessary. And a command like 'pngcrush -brute' can be used to minimize the size of the final PNG file. *********** TEST IMAGES: A 'TestImg' button runs 'gnuplot' in a 'test' mode that displays example line-types, rotated text, and other plot options that are available with each of the gnuplot output ('terminal') types. *************** COLOR FOR PLOTS: The GUI has 3 buttons to allow you to provide colors for the plot --- in particular, colors for the lines, and a color for the plot background. The line color is defaulted to red and the background is 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'. Note: The background color (and axis-color?) option works with GIF and PNG 'terminal' output, but does not seem to work with JPEG, nor with SVG and WXT. ************************* TYPICAL OPERATIONAL STEPS: The GUI is filled with defaults when it first starts up. The user can simply click the 'RePlot' button to immediatly get a plot image to pop up. If the user does not want to take the default expression ... After specifying one, two, or three expressions to plot, if the user takes the defaults for the other options on the GUI, the user can click on the 'RePlot' button to cause the plot to be rendered and displayed. The user can then change the plot title, x-and-y axis labels, x-and-y axis min-max, (xy tic-mark intervals, someday?) --- and click the 'RePlot' button again. The GUI has a 'LineType(1-29)' entry field, for the three possible expressions, by which you can choose from 29 different 'gnuplot' line types. You can see the types with the 'TestImg' button. The GUI also has an 'XticLabelsAngle' entry field in which you can specify an angle (such as zero or -45) which is used to set the angle at which x-tic-mark labels are drawn. The GUI also has an 'YticLabelsAngle' entry field, although it may be less likely to be used than the x-angle option. Note that once you have selected math expression(s), you can repeatedly edit the expression entry fields and click 'RePlot' after each edit to see the effects of your editing. ************* CLEAR BUTTONS: The 'ClearExpr' button can be used to quickly clear an expression out of any of the 3 expression entry fields. When you click the 'ClearExpr' button, the entry field indicated by the setting of the 3 LoadExpression radiobuttons is the field that is cleared. Often the user may want to use (part of) a math expression in the PlotTITLE entry field. To save the user some keyboarding, the user can click 'ClearTitle' to immediately clear the PlotTITLE entry field. When the user clicks the 'RePlot' button and the PlotTITLE entry field is blank, the expression in the first expression field is put in the PlotTITLE entry field. This can help the user remember what is in the plot image, when looking at the plot image later. Of course, the user can then add-to/change the title and do a re-plot. Note that in the unlikely case that the user does not want a plot title, the image can be edited to 'white-out' the title. ************** 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 --- $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: 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, JPEG, SVG and WXT output types. For linetypes 1 through 29, 'gnuplot' gives different colored SOLID lines in GIF, PNG, JPEG, SVG, and WXT 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. An alternative is to do lines-and-points plots, and use the different point-symbol styles to help the color-challenged identify the different plot lines. *********************************** ADDITIONAL IMAGE PROCESSING OPTIONS: You can take an image capture of the WXT terminal --- or 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 --- 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 a Postscript output --- getting a PNG, 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. (I did not want to take up more GUI space with a 'TimeStamp' checkbutton on the GUI --- but that could be a future enhancement.) ************************ '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: This utility currently allows for plotting the (up to 3) curves on the same scale with just one Y-axis and with one Y-axis label --- on the left side of the plot. In the future, a 'key' (legend) option could be implemented --- say via a widget on the GUI --- to ask 'gnuplot' to put a legend on the GUI and locate it appropriately. ('gnuplot' allows the 'key' to be placed at various places on the plot, such as 'top right', 'bottom right', 'top left', and 'bottom left' --- or at a specific coordinates location on the plot. An entry field on the GUI would allow the user to pass any 'gnuplot' 'key' command to 'gnuplot' --- including 'off', to request no legend.) Also, entry fields could be added to the GUI to allow the user to specify a spacing for x-tic-marks and for y-tic-marks. Someday? --- Furthermore, I may try to get more appealing plots --- with color gradient backgrounds and with 'shadow curves' and with 'ribbon curves' --- by using some of the 'gnuplot tricks' of Zoltan Voros 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 "