#pragma rtGlobals=3 // Use modern global access method and strict wave access. // March 6, 2013 // Author: Andrew Achkar, University of Waterloo // Version history: v1 - initial release, known issues: does not deal appropriately with multiple instances of same wave, textbox or other objects appearing on graphs being merged // mergeGraphs(winL,[styleFrom,printCmds]) takes the graphs listed in winL and creates execution code to generate a single graph window containing all traces in the original window list winL // The optional styleFrom string instructs the function which window to copy the "style" settings from. // This excludes all individual trace settings and focuses on the appearance of the axes and the window itself. // If styleFrom is left default, the first graph in winL is used to create appearance code // Set printCmds=1 if you want to output the generated macros in a new notebook Function mergeGraphs(winL,[styleFrom,printCmds]) String winL, styleFrom Variable printCmds If(ParamIsDefault(styleFrom)) styleFrom = StringFromList(0,winL) endif Variable i, numWins = ItemsInList(winL) String disp_cmds = "Window " + UniqueName("Graph",6,0) + "() : Graph \r \tPauseUpdate; Silent 1\t\t// building window...\r" String style_cmds = "Proc " + UniqueName("Graph",6,0) + "Style() : Graph \r \tPauseUpdate; Silent 1\t\t// modifying window...\r" style_cmds += styleOnlyMacro(styleFrom) For(i=0;i0 // The reason for this is that for n>0 all Display commands need to be replaced by AppendToGraph Function /S returnWindowStr(win,n) String win // Name of the window to recreate Variable n // n'th window being merged String line, win_cmd = "", win_rec=WinRecreation(win,0) Variable i, a, b, c, d, e, f for(i=0;i=1 && strsearch(line, "Display",0) != -1 ) line = RemoveByKey("/W",ReplaceString("Display", line , "AppendToGraph"),"=", " ") endif //Boolean variables that track whether line contains certain strings a=strsearch(line, "Window",0) == -1 b=strsearch(line, "ModifyGraph",0) == -1 c=strsearch(line, "ShowInfo",0) == -1 d=strsearch(line, "PauseUpdate",0) == -1 e=strsearch(line, "EndMacro",0) == -1 f=strsearch(line, "fldrSav0",0) != -1 //Change fldrSav0 string created by WinRecreation if(f) line = ReplaceString("fldrSav0", line, "fldrSav" + num2str(n)) endif //Only take commands that involve generating plots If(a && b && c && d && e) win_cmd += line + "\r" endif endfor return win_cmd End // This function returns the TraceInfo for all traces in the window win, seperated by the character ^ // It also adds YWAVE and YWAVEDF to the usual TraceInfo output Function /S getTraceInfoListFromWin(win) String win String traceInfoList="", traceList = TraceNameList(win, ";", 1) Variable i, numTraces = ItemsInList(traceList) For(i=0;i