#pragma rtGlobals= 2 #pragma version = 2.13 DefaultFont "Helvetica" #include "Utility_JZT", version>=2.51 Menu "Analysis" Submenu "Packages" "Laser data files",Execute/P "INSERTINCLUDE \"LaserLoad\"";Execute/P "COMPILEPROCEDURES ";Execute/P "LaserLoadInitPackage()" help = {"Load everything for reading spec files."} SubMenu "Inelastic" "Inelastic(" "data collection",Execute/P "INSERTINCLUDE \"Inelastic_General\",version>=2.51";Execute/P "COMPILEPROCEDURES ";Execute/P "InitInelasticIgorFile(2)";Execute/P "COMPILEPROCEDURES " help = {"Utility functions and menu for inelastic experiments."} "read dump files",Execute/P "INSERTINCLUDE \"LoadDumps\"";Execute/P "COMPILEPROCEDURES " help = {"Dumps for inelastic experiments."} " utility",Execute/P "INSERTINCLUDE \"inelasticUtility\"";Execute/P "COMPILEPROCEDURES ";Execute/P "inelasticInitPackage()";Execute/P "COMPILEPROCEDURES " help = {"Utility functions and menu for inelastic experiments."} End SubMenu "µ beam, Sector 34" // "start microPanel",Execute/P "INSERTINCLUDE \"microGeometry\", version>=2.3";Execute/P "COMPILEPROCEDURES ";Execute/P "Init_microGeo();MakeMicroPanel(-1)" // "start microPanel",Execute/P "INSERTINCLUDE \"microGeometry\", version>=2.3";Execute/P "INSERTINCLUDE \"LatticeSym\", version>=1.0";Execute/P "COMPILEPROCEDURES ";Execute/P "Init_microGeo();InitLatticeSymPackage();MakeMicroPanel(-1)" "ÐÐ> start microPanel",Execute/P "INSERTINCLUDE \"microGeometry\", version>=2.49";Execute/P "INSERTINCLUDE \"LatticeSym\", version>=3.32";Execute/P "COMPILEPROCEDURES ";Execute/P "Init_microGeo();InitLatticeSymPackage();MakeMicroPanel(-1)" help = {"starting point for the generic micro beam analysis"} "Indexing & Peak Searching",Execute/P "INSERTINCLUDE \"Indexing\", version>=2.23";Execute/P "COMPILEPROCEDURES ";Execute/P "InitIndexingPackage()" help = {"Find and Fit Peaks in an image, and then Index the peaks"} "Energy-Wire Scans",Execute/P "INSERTINCLUDE \"EnergyWireScans\", version>=0.989";Execute/P "COMPILEPROCEDURES " help = {"Processes Energy-Wire scans into Depth-Q plots"} "Index Lots of Images",Execute/P "INSERTINCLUDE \"IndexLots\", version>=2.07";Execute/P "COMPILEPROCEDURES " help = {"index a large group of images, like from a wire-scan"} "3d-Grains with Gizmo",Execute/P "INSERTINCLUDE \"GizmoGrains\", version>=1.3";Execute/P "COMPILEPROCEDURES ";Execute/P "initGrainGizmo()" help = {"Processes 3D array of matricies into a viewable volume"} "3d-Array of Orientation Mats",Execute/P "INSERTINCLUDE \"ArrayOf3dOrients\", version>=2.24";Execute/P "COMPILEPROCEDURES " help = {"Processes 3D array of matricies into viewable of rotataion angles, dislocation tensors, GND, etc."} "tilts from one spot",Execute/P "INSERTINCLUDE \"ProcessSpotTilts\", version>=1.2";Execute/P "COMPILEPROCEDURES " "Pole Figure",Execute/P "INSERTINCLUDE \"PoleFigure\"";Execute/P "COMPILEPROCEDURES " help = {"Loads Pole figure Macros"} "Details of Depth Resolved Wire Scans",Execute/P "INSERTINCLUDE \"DepthResolvedQuery\"";Execute/P "COMPILEPROCEDURES " help = {"used to analyze a depth resolved wire scan, mostly for debugging"} "K-B Mirror analysis",Execute/P "INSERTINCLUDE \"KB_mirrors 3.0\", version>=3.0";Execute/P "COMPILEPROCEDURES ";Execute/P "KB_mirror_InitPackage()" help = {"Load procedures for analyzing K-B mirrors"} "micro-mono Calibration",Execute/P "INSERTINCLUDE \"monoCalibrate\", version>=1.4";Execute/P "COMPILEPROCEDURES ";Execute/P "monoCalibrateInitPackage()" "single slit diffraction",Execute/P "INSERTINCLUDE \"SingleSlit\", version>=1.0";Execute/P "COMPILEPROCEDURES " End SubMenu "EPICS" "EPICS(" "Load Scan Record", Execute/P "INSERTINCLUDE \"LoadEPICSscans\"" ; Execute/P "COMPILEPROCEDURES " help = {"Load procedures for Loading the dump of a scan record using TkGrab, does not need EPICS support"} "PV I\O", Execute/P "INSERTINCLUDE \"epics\"" ; Execute/P "COMPILEPROCEDURES ";Execute/P "epicsInitPackage()" help = {"Load procedures for talking to PVs via EPICS (only useful at APS)"} " & old Beam Procedures",Execute/P "INSERTINCLUDE \"BeamProcedures\"";Execute/P "COMPILEPROCEDURES " help = {"Epics related items. (only useful at APS)"} End SubMenu "X-ray" "Stereographic Projections",Execute/P "INSERTINCLUDE \"StereographicProjection\", version>=2.4";Execute/P "COMPILEPROCEDURES ";Execute/P "InitStereoGraphicPackage()" End "hex stacking faults in GaN",Execute/P "INSERTINCLUDE \"StackingFaults\"";Execute/P "COMPILEPROCEDURES ";Execute/P "initStackingFaults()" help = {"look at scattering from stacking faults in GaN"} "SCD neutron Analysis",Execute/P "INSERTINCLUDE \"SCDpackage\", version>=2.2";Execute/P "COMPILEPROCEDURES ";Execute/P "SCDinitPackage(1)" help = {"Adds functions for processing SCD neutron data"} "Undulator Gap", Execute/P "INSERTINCLUDE \"undulator\"" ; Execute/P "COMPILEPROCEDURES ";Execute/P "undulatorInitPackage()" help = {"Load procedures reading and looking at WinView images"} "Procedure Browser", Execute/P "INSERTINCLUDE " ; Execute/P "COMPILEPROCEDURES " "-" End End Menu "Data" Submenu "Packages" "-" "Laser data files",Execute/P "INSERTINCLUDE \"LaserLoad\"";Execute/P "COMPILEPROCEDURES ";Execute/P "LaserLoadInitPackage()" help = {"Load everything for reading spec files."} SubMenu "Inelastic" "data collection",Execute/P "INSERTINCLUDE \"Inelastic_General\",version>=2.51";Execute/P "COMPILEPROCEDURES ";Execute/P "InitInelasticIgorFile(2)";Execute/P "COMPILEPROCEDURES " help = {"Utility functions and menu for inelastic experiments."} "read dump files",Execute/P "INSERTINCLUDE \"LoadDumps\"";Execute/P "COMPILEPROCEDURES " help = {"Dumps for inelastic experiments."} End "EPICS Load Scan Record", Execute/P "INSERTINCLUDE \"LoadEPICSscans\"" ; Execute/P "COMPILEPROCEDURES " help = {"Load procedures for Loading the dump of a scan record using TkGrab, does not need EPICS support"} "3d-Grains with Gizmo",Execute/P "INSERTINCLUDE \"GizmoGrains\", version>=1.3";Execute/P "COMPILEPROCEDURES ";Execute/P "initGrainGizmo()" help = {"Load procedures looking at 3-d grain structures"} End End Menu "Load Waves" Submenu "Packages" "-" "Laser data files",Execute/P "INSERTINCLUDE \"LaserLoad\"";Execute/P "COMPILEPROCEDURES ";Execute/P "LaserLoadInitPackage()" help = {"Load everything for reading spec files."} SubMenu "Inelastic" "data collection",Execute/P "INSERTINCLUDE \"Inelastic_General\",version>=2.51";Execute/P "COMPILEPROCEDURES ";Execute/P "InitInelasticIgorFile(2)";Execute/P "COMPILEPROCEDURES " help = {"Utility functions and menu for inelastic experiments."} "read dump files",Execute/P "INSERTINCLUDE \"LoadDumps\"";Execute/P "COMPILEPROCEDURES " help = {"Dumps for inelastic experiments."} End "EPICS Load Scan Record", Execute/P "INSERTINCLUDE \"LoadEPICSscans\"" ; Execute/P "COMPILEPROCEDURES " help = {"Load procedures for Loading the dump of a scan record using TkGrab, does not need EPICS support"} End End Menu "File" "Dymoize top Graph", DymoGraph() help = {"Make duplicate graph suitable for Dymo printing"} "2nd version of Igor",Igor2() help = {"start up a second version of Igor"} End //Menu "Macros" // "Find a Wave", FindaWave_("") //End Menu "Misc" "StopAllTimers",StopAllTimers() End Function StopAllTimers() Variable i String str="" for(i=0;i<=9;i+=1) str += SelectString(stopMSTimer(i),"",num2istr(i)+" ") endfor if (strlen(str)) printf "timers %s were running\r",str endif End Proc JonsStyle_() : GraphStyle JonsStyle("") EndMacro // Function JonsStyle(gName) String gName if (NumberByKey("IGORVERS",IgorInfo(0))>=5.01) // ModifyGraph gfRelSize=4 ModifyGraph/W=$gName gfMult=130 else ModifyGraph/W=$gName gfSize=18 endif ModifyGraph/Z/W=$gName tick=2, minor=1, standoff=0 ModifyGraph/W=$gName lowTrip=0.001 if (strlen(AxisInfo(gName, "top"))<1) ModifyGraph/W=$gName/Z mirror(bottom)=1 endif if (strlen(AxisInfo(gName, "right"))<1) ModifyGraph/W=$gName/Z mirror(left)=1 endif // find the top wave on graph, and try to label the axes String wList = ImageNameList(gName,";") // first assum an image if (strlen(wList)) Wave w=ImageNameToWaveRef(gName,StringFromList(0,wList) ) else // next try a line plot wList = TraceNameList(gName,";",1) Wave w=TraceNameToWaveRef(gName,StringFromList(0,wList)) endif if (WaveExists(w)) String wnote=note(w) String left = StringByKey("GraphAxisLabelVert", wnote ,"=" ) String bot = StringByKey("GraphAxisLabelHoriz", wnote ,"=" ) String infoStr=ImageInfo(gName,NameOfWave(w),0) if (strlen(infoStr)<1) infoStr = TraceInfo(gName,NameOfWave(w),0) endif String leftName = StringByKey("YAXIS",infoStr) String botName = StringByKey("XAXIS",infoStr) Variable setHoriz = strlen(AxisLabelFromGraph(gName,w,botName))==0 // do not re-set if alreay labeled Variable setVert = strlen(AxisLabelFromGraph(gName,w,leftName))==0 if (strlen(left) && setVert && strlen(leftName)) Label $leftName left endif if (strlen(bot) && setHoriz && strlen(botName)) Label $botName bot endif endif End //Proc JonsStyle_() : GraphStyle // PauseUpdate; Silent 1 | modifying window... // // Modify/Z rgb=(0,0,0) // if (NumberByKey("IGORVERS",IgorInfo(0))>=5.01) //// ModifyGraph gfRelSize=4 // ModifyGraph gfMult=130 // else // Modify gfSize=18 // endif // Modify/Z tick=2, minor=1, standoff=0 // ModifyGraph lowTrip=0.001 // if (strlen(AxisInfo("", "top"))<1) // Modify/Z mirror(bottom)=1 // endif // if (strlen(AxisInfo("", "right"))<1) // Modify/Z mirror(left)=1 // endif //EndMacro // Modified from a script by Peter Ulrich // posted to on Nov 19, 2004 Function Igor2() // Good readings: http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG4 String exit=" & \" > /dev/null 2>&1 &\"" String launcher="\"/System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp \"" String com="do shell script "+launcher + " & quoted form of POSIX path of (path to me)" + exit ExecuteScriptText com End Function FindaWave_(searchString) String searchString if (strlen(searchString)<1) searchString="*" Prompt searchString,"search string" DoPrompt "choose one", searchString endif String result Prompt result,"choose a wave",popup, WaveList(searchString, ";", "") DoPrompt "choose one", result print result EndMacro Function/S Seconds2String(seconds) // convert seconds into a time string Variable seconds Variable minutes=0, hours=0 seconds = abs(seconds) String str = "" if (seconds>90) // change to hms for long times hours = trunc(seconds/3600.) seconds = mod(seconds,3600.) minutes = trunc(seconds/60.) seconds = round(mod(seconds,60.)) if (hours>0) str += " "+num2istr(hours)+" hour" endif if (hours>1) str += "s" endif if (minutes>0) str += " "+num2istr(minutes)+" minute" endif if (minutes>1) str += "s" endif if (seconds>0) str += " "+num2istr(seconds)+" seconds" endif else if (seconds>2) seconds = round(seconds) else seconds = round(seconds*10)/10 endif str = num2str(seconds)+ " seconds" endif return str End Function SpeakSeconds(seconds) // speak the execution time, note that 1 second = 60.15 ticks Variable seconds seconds = abs(seconds) String str = "Time taken was "+Seconds2String(seconds)+"." if ((seconds/60)>=3) // always print if it took more than 3 minutes print str endif String funcName="SpeechAvail" if (exists("SpeechAvail")!=3) // if built in funciton does not exist funcName="SpeechAvailProtoTypeFunc" endif FUNCREF SpeechAvailProtoTypeFunc refSpeechAvail = $funcName funcName="Speak" if (exists("Speak")!=3) // if built in funciton does not exist funcName="SpeakProtoTypeFunc" endif FUNCREF SpeakProtoTypeFunc refSpeak = $funcName if (refSpeechAvail()) Variable i = strsearch(str, "minute", 0) if (i>1) str[i,i+5]="minut" endif refSpeak(str) else print str endif EndMacro Function SpeakNumber(name,x) // speak the execution time, note that 1 second = 60.15 ticks String name Variable x String funcName="SpeechAvail" if (exists("SpeechAvail")!=3) // if built in funciton does not exist funcName="SpeechAvailProtoTypeFunc" endif FUNCREF SpeechAvailProtoTypeFunc refSpeechAvail = $funcName funcName="Speak" if (exists("Speak")!=3) // if built in funciton does not exist funcName="SpeakProtoTypeFunc" endif FUNCREF SpeakProtoTypeFunc refSpeak = $funcName if (refSpeechAvail()) refSpeak(name+" equals "+num2str(x)) return 1 endif print name+" = "+num2str(x) EndMacro //Function SpeakNumber(name,x) // speak the execution time, note that 1 second = 60.15 ticks // String name="x" // Variable x // if (exists("SpeechAvail")==3) // if (SpeechAvail()) // Speak(name+" equals "+num2str(x)) // return 1 // endif // endif // print name+" = "+num2str(x) //EndMacro Function SpeechAvailProtoTypeFunc() return 0 End Function SpeakProtoTypeFunc(str) String str End // ============================================================================ // // ============================== Start of Dymo Printing ============================= // Constant dymoWidth=266, dymoHeight=159 // printable size of Dymo (points) for "30256 Shipping Labels" Function DymoGraph() // make a new graph just like the top graph, but formatted for Dymo printing String win=WinName(0,1,1) // name of window to dymoize if (strlen(win)<1) DoAlert 0,"no graphs displayed" return 1 endif GetWindow $win gsize // area of graph that gets printed if (abs(V_right-V_left-dymoWidth)>1 || abs(V_bottom-V_top-dymoHeight)>1) // graph is wrong size, change it String rec=WinRecreation("",0) Variable i1,i2,j,left,top i1 = strsearch(rec, "Display ",0)+strlen("Display ") i2 = strsearch(rec, "\r",i1)-1 j = strsearch(rec, "/W=(",i1)+4 left = str2num(StringFromList(0,rec[j,Inf],",")) top = str2num(StringFromList(1,rec[j,Inf],",")) if (strsearch(rec[i1,i2], "/K=",0)<0) // no '/K=' in rec, so put in '/K=1' rec[i1,i1]="/K=1/" else // '/K=n' exists, change it to '/K=1' j = strsearch(rec, "/K=",i1)+3 rec[j,j]="1" endif i1 = strsearch(rec,"gfMult=",0) // remove a possiible "gfMult=nnn" (this makes the fonts too big) if (i1>0) i2 = strsearch(rec,"\r",i1,0)-1 i1 = strsearch(rec,"\r",i1,1)+1 i1 = strsearch(rec,"ModifyGraph ",i1,0)+strlen("ModifyGraph ") rec[i1,i2] = ReplaceNumberByKey("gfMult",rec[i1,i2],100,"=",",") endif i1 = strsearch(rec,"gfSize=",0) // remove a possiible "gfSize=nn" (this makes the fonts too big) if (i1>0) i2 = strsearch(rec,"\r",i1,0)-1 i1 = strsearch(rec,"\r",i1,1)+1 i1 = strsearch(rec,"ModifyGraph ",i1,0)+strlen("ModifyGraph ") rec[i1,i2] = ReplaceNumberByKey("gfSize",rec[i1,i2],0,"=",",") endif Execute rec MoveWindow left, top, left+dymoWidth, top+dymoHeight Button PrintDymoButton,pos={1,2},size={30,16},proc=PrintDymoProc,title="Print",fSize=9 Button PrintDymoButton,help={"This will print the graph to the Dymo LabelWriter 400"} DoWindow /T $WinName(0,1,1), "Print to Dymo" Textbox/C/N=stamp0/F=0/A=RB/X=0.2/Y=-2/E=2 "\\Z04\\{\"%s %s\",date(), time()}" PathInfo home // creates String s_path TextBox/C/N=stamp1/F=0/A=LB/X=0.2/Y=-2/E=2 "\\Z04"+S_path+IgorInfo(1)+":"+win HideInfo HideTools/A DoUpdate endif End Function PrintDymoProc(ctrlName) : ButtonControl String ctrlName String cmd, win=WinName(0,1,1) PrintSettings/W=$win getPrinterList if (WhichListItem("LabelWriter_400",S_value)<0) DoAlert 0, "the labelwriter 400 is not available on this computer" return 1 elseif (!stringmatch(ctrlName,"PrintDymoButton")) return 1 elseif (strlen(win)<1) // is the window there return 1 endif GetWindow $win gsize // paper size minus the margins from graph Variable width=V_right-V_left, height=V_bottom-V_top if (abs(width-dymoHeight)<1 && abs(height-dymoWidth)<1) DoAlert 0, "The graph is set for Dymo, but you need to rotate from Protrait to Landscape" return 1 elseif (abs(width-dymoWidth)>1 || abs(height-dymoHeight)>1) DoAlert 0, "the graph size is not set for Dymo labels" return 1 endif // PrintSettings/W=$win getPageDimensions // String pageDimensions=S_value PrintSettings/W=$win getPageSettings // get printer setting for later restoration String pageSettings=S_value PrintSettings/W=$win orientation=1,scale=100,setPrinter="LabelWriter_400",margins={0,0,0,0} // change to Dymo LabelWriter 400, landscape mode PrintSettings/W=$win getPrinter if (strsearch(S_value,"LabelWriter_400",0,2)<0) // double check the printer name DoAlert 0, "Printer not set to 'LabelWriter_400'" return 1 endif PrintSettings getPageDimensions String paper = StringByKey("PAPER",S_value) height = str2num(StringFromList(3,paper,","))-str2num(StringFromList(1,paper,",")) width = str2num(StringFromList(2,paper,","))-str2num(StringFromList(0,paper,",")) if ( abs(width-287) || abs(height-165) ) String str sprintf str, "Printer set to LabelWriter_400, but printable area is (h=%g\" x w=%g\").\r Set to 'LabelWriter 400' with '30256 Shipping'"height/72,width/72 print str DoAlert 0, str return 1 endif Variable leftMargin=16 sprintf cmd,"PrintGraphs %s(%d, 0, %g,%g)\r",win,leftMargin,dymoWidth+leftMargin, dymoHeight Execute cmd // restore settings sprintf cmd, "PrintSettings/W=%s orientation=%s,scale=%s,setPrinter=\"\",margins={%s}",win,StringByKey("ORIENTATION",pageSettings),StringByKey("SCALE",pageSettings),StringByKey("MARGINS",pageSettings) Execute cmd DoWindow /K $win End //Function PrintDymoProc(ctrlName) : ButtonControl // String ctrlName // String cmd, win=WinName(0,1,1) // PrintSettings/W=$win getPrinterList // if (WhichListItem("LabelWriter_400",S_value)<0) // DoAlert 0, "the labelwriter 400 is not available" // return 1 // elseif (!stringmatch(ctrlName,"PrintDymoButton")) // return 1 // elseif (strlen(win)<1) // is the window there // return 1 // endif // // GetWindow $win gsize // paper size minus the margins // Variable width=V_right-V_left, height=V_bottom-V_top // if (abs(width-dymoHeight)<1 && abs(height-dymoWidth)<1) // DoAlert 0, "The graph is set for Dymo, but you need to rotate from Protrait to Landscape" // return 1 // elseif (abs(width-dymoWidth)>1 || abs(height-dymoHeight)>1) // String str // sprintf str, "printer not set to Dymo labels, printable area is (h=%.3f\" x w=%.3f\"),\ruse Dymo 400 with '30256 Shipping Labels'"(height)/72,(width)/72 // DoAlert 0, str // return 1 // endif // // PrintSettings/W=$win getPageDimensions // String pageDimensions=S_value // PrintSettings/W=$win getPageSettings // String pageSettings=S_value // // PrintSettings/W=$win orientation=1,scale=100,setPrinter="LabelWriter_400",margins={0,0,0,0} // change to Dymo LabelWriter 400, landscape mode // PrintSettings/W=$win orientation=1,scale=100,setPrinter="LabelWriter_400",margins={0,0,0,0},getPrinter // change to Dymo LabelWriter 400, landscape mode // if (strsearch(S_value,"LabelWriter_400",0,2)<0) // double check the printer name // DoAlert 0, "Printer not set to 'LabelWriter_400'" // return 1 // else // Variable leftMargin=16 // sprintf cmd,"PrintGraphs %s(%d, 0, %g,%g)\r",win,leftMargin,dymoWidth+leftMargin, dymoHeight // Execute cmd // endif // // // restore settings // sprintf cmd, "PrintSettings/W=%s orientation=%s,scale=%s,setPrinter=\"\",margins={%s}",win,StringByKey("ORIENTATION",pageSettings),StringByKey("SCALE",pageSettings),StringByKey("MARGINS",pageSettings) // Execute cmd // DoWindow /K $win //End //Function DymoGraph() // make a new graph just like the top graph, but formatted for Dymo printing // String win=WinName(0,1,1) // name of window to dymoize // if (strlen(win)<1) // DoAlert 0,"no graphs displayed" // return 1 // endif // GetWindow $win logicalprintablesize // paper size minus the margins // isWindowSetForDymo(win) //// if (abs(V_right-V_left-dymoWidth)>1 || abs(V_bottom-V_top-dymoHeight)>1) //// String str //// sprintf str, "printer not set to Dymo labels, printable area is (h=%.3f\" x w=%.3f\"),\ruse Dymo 400 with '30256 Shipping Labels'"(V_bottom-V_top)/72,(V_right-V_left)/72 //// DoAlert 0, str //// endif // GetWindow $win gsize // area of graph that gets printed // if (abs(V_right-V_left-dymoWidth)>1 || abs(V_bottom-V_top-dymoHeight)>1) // graph is wrong size, change it // String rec=WinRecreation("",0) // Variable i1,i2,j,left,top // i1 = strsearch(rec, "Display ",0)+strlen("Display ") // i2 = strsearch(rec, "\r",i1)-1 // j = strsearch(rec, "/W=(",i1)+4 // left = str2num(StringFromList(0,rec[j,Inf],",")) // top = str2num(StringFromList(1,rec[j,Inf],",")) // if (strsearch(rec[i1,i2], "/K=",0)<0) // no '/K=' in rec, so put in '/K=1' // rec[i1,i1]="/K=1/" // else // '/K=n' exists, change it to '/K=1' // j = strsearch(rec, "/K=",i1)+3 // rec[j,j]="1" // endif // i1 = strsearch(rec,"gfMult=",0) // remove a possiible "gfMult=nnn" (this makes the fonts too big) // if (i1>0) // i2 = strsearch(rec,"\r",i1,0)-1 // i1 = strsearch(rec,"\r",i1,1)+1 // i1 = strsearch(rec,"ModifyGraph ",i1,0)+strlen("ModifyGraph ") // rec[i1,i2] = ReplaceNumberByKey("gfMult",rec[i1,i2],100,"=",",") // endif // i1 = strsearch(rec,"gfSize=",0) // remove a possiible "gfSize=nn" (this makes the fonts too big) // if (i1>0) // i2 = strsearch(rec,"\r",i1,0)-1 // i1 = strsearch(rec,"\r",i1,1)+1 // i1 = strsearch(rec,"ModifyGraph ",i1,0)+strlen("ModifyGraph ") // rec[i1,i2] = ReplaceNumberByKey("gfSize",rec[i1,i2],0,"=",",") // endif // Execute rec // MoveWindow left, top, left+dymoWidth, top+dymoHeight // Button PrintDymoButton,pos={1,2},size={30,16},proc=PrintDymoProc,title="Print",fSize=9 // Button PrintDymoButton,help={"This will print the graph to the Dymo LabelWriter 400"} // DoWindow /T $WinName(0,1,1), "Print to Dymo" // HideInfo // HideTools/A // DoUpdate // endif //End //Function PrintDymoProc(ctrlName) : ButtonControl // String ctrlName // if (stringmatch(ctrlName,"PrintDymoButton")) // String cmd, win=WinName(0,1,1) // GetWindow $win logicalprintablesize // paper size minus the margins // if (abs(V_right-V_left-dymoWidth)>1 || abs(V_bottom-V_top-dymoHeight)>1) // sprintf cmd, "printer not set to Dymo labels, printable area is (h=%.3f\" x w=%.3f\"),\ruse Dymo 400 with '30256 Shipping Labels'"(V_bottom-V_top)/72,(V_right-V_left)/72 // DoAlert 0, cmd // return 1 // endif // sprintf cmd,"PrintGraphs %s(0, 0, %g,%g)\r",win,dymoWidth, dymoHeight // Execute cmd // DoWindow /K $win // endif //End //Static Function isWindowSetForDymo(win) // String win // if (strlen(win)<1) // return 1 // endif // PrintSettings getPrinterList // if (WhichListItem("LabelWriter_400",S_value)<0) // DoAlert 0, "the labelwriter 400 is not available" // return 1 // endif // GetWindow $win logicalprintablesize // paper size minus the margins // Variable width=V_right-V_left, height=V_bottom-V_top // if (abs(width-dymoHeight)<1 && abs(height-dymoWidth)<1) // DoAlert 0, "The graph is set for Dymo, but you need to rotate from Protrait to Landscape" // return 1 // elseif (abs(width-dymoWidth)>1 || abs(height-dymoHeight)>1) // String str // sprintf str, "printer not set to Dymo labels, printable area is (h=%.3f\" x w=%.3f\"),\ruse Dymo 400 with '30256 Shipping Labels'"(height)/72,(width)/72 // DoAlert 0, str // return 1 // endif // return 0 //End // =============================== End of Dymo Printing ============================= // // ============================================================================ // // ============================================================================ // // ============================== Start of Wave Printing ============================= // Function printWave(w) // print a wave (vector or matrix) to history Wave w if (!WaveExists(w)) DoAlert 0, "in 'printWave', wave does not exist" return 1 endif if (DimSize(w, 1)<=1) // for vectors printvec(w) elseif (DimSize(w, 2)==0) // for 2-d matrix if (DimSize(w,0)<=1 || DimSize(w,1)<=1) printvec(w) else return printmat(w) endif else print "cannot yet handle dimensions 3 or 4" endif return 0 End Static Function printvec(w) // print a vector to screen Wave w printf "%s = %s\r", NameOfWave(w),vec2str(w) End //Static Function printvec(w) // print a vector to screen // Wave w // String name=NameOfWave(w) // Wave/T tw=$GetWavesDataFolder(w,2) // Wave/C cw=$GetWavesDataFolder(w,2) // Variable waveIsComplex = WaveType(w) %& 0x01 // Variable numeric = (WaveType(w)!=0) // Variable i=0, n, maxPrint=20 // n = numpnts(w) // maxPrint = min(n,maxPrint) // printf "%s = {", name // do // if (waveIsComplex) // a complex wave // printf "(%g, %g)", real(cw[i]),imag(cw[i]) // endif // if (numeric %& (!waveIsComplex)) // a simple number wave // printf "%g", w[i] // endif // if (!numeric) // a text wave // printf "\"%s\"", tw[i] // endif // if (i<(n-1)) // printf ", " // endif // i += 1 // while (imaxPrint) // printf "...}\ronly printed %d of %d values\r",maxPrint,n // else // printf "}\r" // endif //End Static Function printmat(m) Wave m if (DimSize(m, 1)==0 || DimSize(m,2)!=0) // for 2-d matrix only DoAlert 0, "Can only print 2-d matricies with printmat" return 1 endif String name=NameOfWave(m) Wave/C mc=$GetWavesDataFolder(m,2) if (DimSize(m, 0)==2 && DimSize(m, 1)==2) if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1] endif elseif (DimSize(m, 0)>=3 && DimSize(m, 1)==2) if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1] print name+"[2][0] =",mc[2][0],"; ",name+"[2][1] =",mc[2][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1] print name+"[2][0] =",m[2][0],"; ",name+"[2][1] =",m[2][1] endif elseif (DimSize(m, 0)==2 && DimSize(m, 1)>=3) if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1],"; ",name+"[0][2] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1],"; ",name+"[1][2] =",mc[1][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1],"; ",name+"[0][2] =",m[0][2] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1],"; ",name+"[1][2] =",m[1][2] endif else if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1],"; ",name+"[0][2] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1],"; ",name+"[1][2] =",mc[1][1] print name+"[2][0] =",mc[2][0],"; ",name+"[2][1] =",mc[2][1],"; ",name+"[2][2] =",mc[2][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1],"; ",name+"[0][2] =",m[0][2] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1],"; ",name+"[1][2] =",m[1][2] print name+"[2][0] =",m[2][0],"; ",name+"[2][1] =",m[2][1],"; ",name+"[2][2] =",m[2][2] endif endif if (DimSize(m,0)>3 || DimSize(m,1)>3) printf "Only printed part of the (%d x %d) matrix\r",DimSize(m,0),DimSize(m,1) endif return 0 End // // //Function/T vec2str(w) // convert vector to s string suitable for printing, does not include name // Wave w // Wave/T tw=$GetWavesDataFolder(w,2) // Wave/C cw=$GetWavesDataFolder(w,2) // Variable waveIsComplex = WaveType(w) %& 0x01 // Variable numeric = (WaveType(w)!=0) // Variable i=0, n, maxPrint=20 // n = numpnts(w) // maxPrint = min(n,maxPrint) // String str, out="{" // // do // if (waveIsComplex) // a complex wave // sprintf str,"(%g, %g)", real(cw[i]),imag(cw[i]) // elseif (numeric %& (!waveIsComplex)) // a simple number wave // sprintf str,"%g", w[i] // elseif (!numeric) // a text wave // sprintf str,"\"%s\"", tw[i] // endif // out += str // if (i<(n-1)) // sprintf str,", " // out += str // endif // i += 1 // while (imaxPrint) // sprintf str,"...}\ronly printed %d of %d values\r",maxPrint,n // out += str // else // out += "}" // endif // return out //End Function/T vec2str(w,[places]) // convert vector to s string suitable for printing, does not include name Wave w // 1d wave to print Variable places // number of places, for default, use negative or NaN Wave/T tw=$GetWavesDataFolder(w,2) Wave/C cw=$GetWavesDataFolder(w,2) Variable waveIsComplex = WaveType(w) %& 0x01 Variable numeric = (WaveType(w)!=0) if (ParamIsDefault(places)) places = -1 endif String fmt if (waveIsComplex) places = places>=0 ? min(20,places) : 5 // default to 5 for unacceptable values sprintf fmt,"(%%.%dg, %%.%dg)",places,places elseif (numeric) places = places>=0 ? min(20,places) : 5 // default to 5 for unacceptable values sprintf fmt,"%%.%dg",places elseif (places>0) // must be string, and a maximum length given sprintf fmt, "\"%d%%s\"",places else // string with no preferred length fmt = "\"%%s\"" endif Variable i=0, n, maxPrint=20 n = numpnts(w) maxPrint = min(n,maxPrint) String str, out="{" do if (waveIsComplex) // a complex wave sprintf str,fmt, real(cw[i]),imag(cw[i]) elseif (numeric && (!waveIsComplex)) // a simple number wave sprintf str,fmt, w[i] elseif (!numeric) // a text wave sprintf str,"\"%s\"", tw[i] endif out += str if (i<(n-1)) sprintf str,", " out += str endif i += 1 while (imaxPrint) sprintf str,"...}\ronly printed %d of %d values\r",maxPrint,n out += str else out += "}" endif return out End // =============================== End of Wave Printing ============================== // // ============================================================================ //