#pragma rtGlobals=3 // Use modern global access method and strict wave access.\ #include //#include menu "Graph" "GraphControl",/q, GraphControlInit() end menu "Layout" "LayoutControl",/q, LayoutControl() end menu "AllTracesPopup" "GraphControl",/q,GraphControlInit() end menu "TracePopup" "GraphControl",/q,GraphControlInit() end //---------------Layout control Window LayoutControl() : Panel PauseUpdate; Silent 1 // building window... NewPanel /W=(36,65,365,400) ShowTools/A SetVariable Left_LC,pos={10.00,22.00},size={80.00,18.00},proc=Left_Right_LC,title="Left" SetVariable Left_LC,value= _NUM:125 SetVariable Top_LC,pos={10.00,42.00},size={80.00,18.00},proc=Left_Right_LC,title="Top" SetVariable Top_LC,value= _NUM:10 Button SetFrame_LC,pos={275.00,63.00},size={40.00,24.00},proc=SetFrame_LC,title="frame" Button SetFrame_LC,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) Button SetFrame_LC,valueColor=(34952,34952,34952) Button MoveLeft_LC,pos={190.00,96.00},size={30.00,30.00},proc=MoveGraphs,title="\\W546" Button MoveLeft_LC,fSize=9 Button MoveRight_LC,pos={270.00,96.00},size={30.00,30.00},proc=MoveGraphs,title="\\W549" Button MoveRight_LC,fSize=9 Button MoveTop_LC,pos={230.00,66.00},size={30.00,30.00},proc=MoveGraphs,title="\\W517" Button MoveTop_LC,fSize=9 Button MoveBottom_LC,pos={230.00,126.00},size={30.00,30.00},proc=MoveGraphs,title="\\W523" Button MoveBottom_LC,fSize=9 GroupBox LayoutGB_LC,pos={100.00,6.00},size={65.00,60.00},title="position " SetVariable PLOT_TOP,pos={38.00,89.00},size={70.00,18.00},proc=LC_PLOTSIZE,title="Top" SetVariable PLOT_TOP,valueBackColor=(56576,56576,56576) SetVariable PLOT_TOP,limits={-1,1000,10},value= _NUM:0 SetVariable PLOT_BOTTOM,pos={18.00,131.00},size={90.00,18.00},proc=LC_PLOTSIZE,title="Bottom" SetVariable PLOT_BOTTOM,valueBackColor=(56576,56576,56576) SetVariable PLOT_BOTTOM,limits={-1,1000,10},value= _NUM:0 SetVariable PLOT_LEFT,pos={9.00,110.00},size={45.00,18.00},proc=LC_PLOTSIZE SetVariable PLOT_LEFT,valueBackColor=(56576,56576,56576) SetVariable PLOT_LEFT,limits={-1,1000,10},value= _NUM:0 SetVariable PLOT_Right,pos={106.00,110.00},size={45.00,18.00},proc=LC_PLOTSIZE SetVariable PLOT_Right,valueBackColor=(56576,56576,56576) SetVariable PLOT_Right,limits={-1,1000,10},value= _NUM:0 TitleBox PLOT_LEFTtitle,pos={9.00,96.00},size={20.00,15.00},title="Left",frame=0 TitleBox PLOT_RIGHTtitle,pos={120.00,96.00},size={28.00,15.00},title="Right" TitleBox PLOT_RIGHTtitle,frame=0 SetVariable PLOT_SIZEH,pos={170.00,22.00},size={95.00,18.00},proc=LC_PLOTSIZE,title="Width" SetVariable PLOT_SIZEH,limits={-1,1000,10},value= _NUM:0 SetVariable PLOT_SIZEV,pos={170.00,42.00},size={95.00,18.00},proc=LC_PLOTSIZE,title="Height" SetVariable PLOT_SIZEV,limits={-1,1000,10},value= _NUM:0 GroupBox PLOT_GBmargins,pos={2.00,70.00},size={163.00,88.00},title="Plot Area" GroupBox PLOT_GBmargins,fSize=12 TitleBox LT_LC,pos={104.00,24.00},size={47.00,15.00},title="(100,100)" TitleBox LT_LC,labelBack=(65535,65535,65535),fSize=12,frame=0 TitleBox RB_LC,pos={166.00,64.00},size={47.00,15.00},title="(100,100)" TitleBox RB_LC,labelBack=(65535,65535,65535),fSize=12,frame=0 SetVariable MOVE_NUM,pos={223.00,102.00},size={45.00,18.00},title=" " SetVariable MOVE_NUM,valueBackColor=(56576,56576,56576) SetVariable MOVE_NUM,limits={1,1000,1},value= _NUM:5 Button AlignLeft_LC,pos={190.00,162.00},size={60.00,24.00},proc=AlignGraphs,title="\\Z12align\\Z09\\W546" Button AlignLeft_LC,fSize=9 Button AlignTop_LC1,pos={255.00,162.00},size={60.00,24.00},proc=AlignGraphs,title="\\Z12align\\Z09\\W517" Button AlignTop_LC1,fSize=9 Button BringFront_LC,pos={275.00,17.00},size={40.00,24.00},proc=BringFront,title="front" Button BringFront_LC,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) Button PLOT_Layout,pos={275.00,40.00},size={40.00,24.00},proc=GraphControlLayout,title="Layout" Button PLOT_Layout,fSize=10,fColor=(61166,61166,61166) Button SetGrid_LC,pos={105.00,162.00},size={60.00,24.00},proc=SetGrid,title="set grid" Button SetGrid_LC,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) SetVariable Grid_LC,pos={3.00,164.00},size={100.00,18.00},proc=LC_PLOTSIZE,title="grid size" SetVariable Grid_LC,limits={0,100,1},value= _NUM:5 Button LCcopy,pos={102.00,41.00},size={40.00,22.00},proc=copy_LC,title="copy" Button LCcopy,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) Button LC_showG_on_L,pos={28.00,228.00},size={40.00,22.00},proc=LC_G_on_L,title="show" Button LC_showG_on_L,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) TitleBox LC_G_on_L,pos={10.00,210.00},size={101.00,15.00},title="Graphs: on Layouts" TitleBox LC_G_on_L,fSize=12,frame=0 Button LC_hideG_on_L1,pos={68.00,228.00},size={40.00,22.00},proc=LC_G_on_L,title="hide" Button LC_hideG_on_L1,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) TitleBox LC_G_noton_L,pos={130.00,210.00},size={79.00,15.00},title="not on Layouts" TitleBox LC_G_noton_L,fSize=12,frame=0 Button LC_shG_not_on_L,pos={128.00,228.00},size={40.00,22.00},proc=LC_G_on_L,title="show" Button LC_shG_not_on_L,labelBack=(65535,65535,65535) Button LC_shG_not_on_L,fColor=(65535,65535,65535) Button LC_hiG_not_on_L2,pos={168.00,228.00},size={40.00,22.00},proc=LC_G_on_L,title="hide" Button LC_hiG_not_on_L2,labelBack=(65535,65535,65535) Button LC_hiG_not_on_L2,fColor=(65535,65535,65535) Button LC_showPlotsFromDF,pos={28.00,258.00},size={180.00,22.00},proc=LC_plotsfromDF,title="Graphs from selected datafolder" Button LC_showPlotsFromDF,labelBack=(65535,65535,65535) Button LC_showPlotsFromDF,fColor=(65535,65535,65535) CheckBox LC_subDF,pos={212.00,262.00},size={104.00,15.00},title="check subfolders" CheckBox LC_subDF,value= 1 Button LC_Kill_DF,pos={28.00,288.00},size={180.00,22.00},proc=LC_deleteDF_plots,title="Delete datafolder and graphs" Button LC_Kill_DF,labelBack=(65535,65535,65535),fColor=(65535,65535,65535) GroupBox Manage_Windows,pos={2.00,190.00},size={320.00,127.00},title="Manage Windows" GroupBox Manage_Windows,fSize=12 SetWindow kwTopWin,hook(newLayoutControl)=LayoutControlPanelHook EndMacro //events that happen when graphcontrol panel is activated or resized function LayoutControlPanelHook(s) STRUCT WMWinHookStruct &s if ((s.eventcode==0))//&&(strlen(winname(0,1+2+4+16+128+4096))))//activate if(strlen(winname(0,4))>0) SetWindow $winname(0,4) hook(newLayoutControl)=LayoutControlHook endif endif end //the layout is now lnked to layoutcontrol panel function LayoutControlHook(s) STRUCT WMWinHookStruct &s dowindow LayoutControl if (v_flag) if ((s.eventcode==5)||(s.eventcode==11)) execute /p /q "Measure_LC(\"\")" endif if (s.eventcode!=4) // print s.eventcode endif endif End //set the position of active graphs Function Left_Right_LC(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName if(strlen(winname(0,4))>0) string info=layoutinfo("","layout") string selected=stringbykey("SELECTED",info,":") //print selected variable i for(i=0;i3) SetVariable Left_LC win=layoutcontrol,value= _NUM:str2num(S_recreation[startpos+1,strsearch(S_recreation,",",startpos)-1]) SetVariable Top_LC win=layoutcontrol,value= _NUM:str2num(S_recreation[strsearch(S_recreation,",",startpos)+1,endpos-1]) endif End Function SetGrid(ctrlName) : ButtonControl String ctrlName string S_recreation="" drawaction /w=$winname(0,4) commands if(strlen(S_recreation)>0) string items=S_recreation,item,text,command drawaction /w=$winname(0,4) delete variable line,locx,locy,locR,locB controlinfo/w=layoutcontrol Grid_LC variable gridsize=v_value dowindow/f $winname(0,4) //doupdate for(line=0;line0) sscanf item, " "+command+" %f,%f,%f,%f", locx,locy,locR,locB locx=round(locx/gridsize)*gridsize locy=round(locy/gridsize)*gridsize locR=round(locR/gridsize)*gridsize locB=round(locB/gridsize)*gridsize sprintf item, command+"/w=%s %g,%g,%g,%g",winname(0,4), locx,locy,locR,locB endif if (stringmatch(item,"*SetDrawEnv*")) item=replacestring("SetDrawEnv",item,"SetDrawEnv/w="+winname(0,4))//+",save, ") endif item=replacestring("//",item,"") item=replacestring("\r",item,"") execute/p/q item endif // print item endfor endif //execute S_recreation End //measure the location of active graphs Function Measure_LC(ctrlName) : ButtonControl String ctrlName if(strlen(winname(0,4))>0) string info=layoutinfo("","layout") string selected=stringbykey("SELECTED",info,":") if(itemsinlist(selected,",")>0) variable posLeft=str2num(stringbykey("left",layoutinfo("",stringfromlist(0,selected,",")))) variable posTop=str2num(stringbykey("top",layoutinfo("",stringfromlist(0,selected,",")))) if (strlen(winlist(stringfromlist(0,selected,","),";","win:1"))>0)//graph exists getwindow $stringfromlist(0,selected,",") gsize variable left=v_left,right=v_right,top=v_top,bottom=v_bottom getwindow $stringfromlist(0,selected,",") psize left+=v_left;right-=v_right;top+=v_top;bottom-=v_bottom SetVariable PLOT_TOP, win=LayoutControl,value= _NUM:round(top) SetVariable PLOT_LEFT, win=LayoutControl,value= _NUM:round(left) TitleBox LT_LC , win=LayoutControl,title="("+num2str((posLeft))+","+num2str((postop))+")" TitleBox RB_LC , win=LayoutControl,title="("+num2str(round(posLeft+v_right-v_left))+","+num2str(round(postop+v_bottom-v_top))+")" SetVariable PLOT_RIGHT, win=LayoutControl,value= _NUM:round(right) SetVariable PLOT_BOTTOM, win=LayoutControl,value= _NUM:round(bottom) SetVariable PLOT_SIZEH, win=LayoutControl,value= _NUM:round(v_right-v_left) SetVariable PLOT_SIZEV, win=LayoutControl,value= _NUM:round(v_bottom-v_top) endif else TitleBox LT_LC , win=LayoutControl,title="(,)" TitleBox RB_LC , win=LayoutControl,title="(,)" endif endif End //moves selected graphs by a number Function MoveGraphs(ctrlName) : ButtonControl String ctrlName variable moveleft=0,movetop=0 controlinfo/w=LayoutControl Move_num if(stringmatch(ctrlName,"*left*")) moveleft=-v_value endif if(stringmatch(ctrlName,"*right*")) moveleft=v_value endif if(stringmatch(ctrlName,"*top*")) movetop=-v_value endif if(stringmatch(ctrlName,"*bottom*")) movetop=v_value endif if(stringmatch(ctrlName,"*100*")) moveleft*=10 movetop*=10 endif if(strlen(winname(0,4))>0) string info=layoutinfo("","layout") string selected=stringbykey("SELECTED",info,":") variable i for(i=0;i0) string info=layoutinfo("","layout") string selected=stringbykey("SELECTED",info,":") if(strlen(selected)>0) variable i,mostleftpos=inf,mosttoppos=inf for(i=0;i0) string info=layoutinfo("","layout") string selected=stringbykey("SELECTED",info,":") variable i for(i=0;i0) ModifyLayout trans=1,frame=0 dowindow /F $winname(0,4) dowindow /F LayoutControl endif End //brings the graph to front Function BringFront(ctrlName) : ButtonControl String ctrlName if(strlen(winname(0,4))>0) string info=layoutinfo("","layout") string selected=stringbykey("SELECTED",info,":") variable i for(i=0;i0) if(delete) killwindow /z $graphname else dowindow/f $graphname endif endif endfor if(deep) string Folders=stringbykey("FOLDERS",DataFolderDir(1),":") for (subDF=0;subDF0)&& (tnum0) variable del=strsearch(ERR,"(",strlen(ERR),1) ERR=replacestring(ERR[0,del],ERR,"") ERR=removeending(ERR) del=strsearch(ERR,",",0) string PERR=ERR[0,del-1],NERR=ERR[del+1,strlen(ERR)-1] if(strlen(PERR)>0) appendtotable $PERR endif if(strlen(NERR)>0) appendtotable $NERR endif //print ERR[0,del-1] //print stringfromlist(0,EBdata("ywave",ERR),",") endif // st=replacestring("wave",st,"ywave",0,1) // // // else // CheckBox ERROR_SHADE value= 0,win=graphcontrol // del=strsearch(st,"X",0) // if(del==-1) // del=strsearch(st,"Y",0) // endif // st=replacestring(st[0,del-1],st,"") // // if (stringmatch(st,"XY*")) // st=replacestring(",wave",st,";xwave",0,1) // st=replacestring(",wave",st,";ywave",0,1) // else // if (stringmatch(st,"Y*")) // st=replacestring(",wave",st,";ywave",0,1) // else // st=replacestring(",wave",st,";xwave",0,1) // endif // endif // endif // // yp=stringfromlist(0,EBdata("ywave",st),",") // yn=stringfromlist(1,EBdata("ywave",st),",") end function/s fixDOTwaves(wavestr) string wavestr string dfstr,wavest variable findwavestart if(stringmatch(wavestr,"*.*")) findwavestart=strsearch(wavestr,":",strlen(wavestr)-1,1) dfstr=wavestr[0,findwavestart] wavest=wavestr[findwavestart+1,strlen(wavestr)-1] return dfstr+"'"+wavest+"'" else return wavestr endif end //opens a dialog to replace the selected wave function replacewavedialog(tracename,y0x1) string tracename variable y0x1 string DF=getdatafolder(1) setdatafolder root:DFselect: svar wavesel,savedDF if(strlen(wavesel)) if(y0x1==0) replacewave trace=$(tracename),$fixDOTwaves(wavesel) print "replacewave trace="+(tracename)+","+fixDOTwaves(wavesel) else replacewave/X trace=$(tracename),$fixDOTwaves(wavesel) print "replacewave/X trace="+(tracename)+","+fixDOTwaves(wavesel) endif endif updatetracelist(0) setdatafolder DF end //the graphs are now lnked to graphcontrol panel function GraphControlHook(s) STRUCT WMWinHookStruct &s dowindow GraphControl if (v_flag) controlinfo/w=GraphControl PLOT_LINK if(strlen(S_userdata)) if (s.eventcode==6) updateplotparams() endif if ((s.eventcode==0)||(s.eventcode==2)||(s.eventcode==8))//||(s.eventcode==15)||(s.eventcode==16)) //0-activate;2-kill;8-change;hide-15;unhide-16 execute/p/q "updatetracelist("+num2str(s.eventcode)+")" execute/p/q "updatetracecontrols(-1)" endif endif endif End //events that happen when graphcontrol panel is activated or resized function GraphControlPanelHook(s) STRUCT WMWinHookStruct &s controlinfo/w=GraphControl PLOT_LINK if(strlen(S_userdata)) if ((s.eventcode==0)&&(strlen(winname(0,1+2+4+16+128+4096))))//activate if (WinType(winname(0,1+2+4+16+128+4096) )==1) getwindow $winname(0,1) hook(newgraphcontrol) updatetracelist(0) //print S_value if(strlen(S_value)==0) execute "updatetracecontrols(-1)" endif endif endif endif if ((s.eventcode==6))//resize getwindow GraphControl wsize if(V_bottom-V_top<200) MoveWindow /w=GraphControl V_left,V_top,V_right,V_top+200 getwindow GraphControl wsize endif getwindow GraphControl wsizeDC ListBox PLOTLIST size={V_right-V_left-5,V_bottom-V_top-180} endif //endif End //finds the user selected trace function gettracenumber(number) variable number //if -1 searches for the first selected row variable tnum,found string DF=getdatafolder(1) setdatafolder root:graphcontrol: wave listselect if(number==-1) found=0 for (tnum=0;tnum=0) //trace selected tracename=stringfromlist(number,TraceNameList("", ";", 1 )) info =traceinfo("",tracename,0) //print info UpdateControl("popupmenu", "TRACE_MODE","mode",numberbykey("mode(x)",info,"=")+1,"","GraphControl" , "") UpdateControl("popupmenu", "TRACE_FILLTYPEplus","mode",numberbykey("hbFill(x)",info,"=")+1,"","GraphControl" , "") UpdateControl("popupmenu", "TRACE_FILLTYPEneg","mode",numberbykey("hBarNegFill(x)",info,"=")+1,"","GraphControl" , "") UpdateControl("popupmenu", "TRACE_LINE","mode",numberbykey("lstyle(x)",info,"=")+1,"","GraphControl" , "") UpdateControl("popupmenu", "TRACE_MARKER","mode",numberbykey("marker(x)",info,"=")+1,"","GraphControl" , "") UpdateControl("popupmenu", "TRACE_MARKERCOLSTROKE","popcolor",nan,stringbykey("mrkStrokeRGB(x)",info,"="),"GraphControl" , "") UpdateControl("popupmenu", "TRACE_COLFILLplus","popcolor",nan,stringbykey("plusRGB(x)",info,"="),"GraphControl" , "") UpdateControl("popupmenu", "TRACE_COLFILLneg","popcolor",nan,stringbykey("negRGB(x)",info,"="),"GraphControl" , "") UpdateControl("SetVariable", "TRACE_LINESIZE","value",numberbykey("lsize(x)",info,"="),"","GraphControl" , "_NUM:") UpdateControl("SetVariable", "TRACE_MARKERSIZE","value",numberbykey("msize(x)",info,"="),"","GraphControl" , "_NUM:") UpdateControl("SetVariable", "TRACE_MARKERTHICK","value",numberbykey("mrkThick(x)",info,"="),"","GraphControl" , "_NUM:") variable alpha=1 string colRGB=stringbykey("rgb(x)",info,"=") if( itemsinlist(stringbykey("rgb(x)",info,"="),",")==4) colRGB=removeending (removelistitem(3,colRGB,","))+")" alpha=str2num(stringfromlist(3,stringbykey("rgb(x)",info,"="),","))/((2^16)) endif UpdateControl("popupmenu", "TRACE_COL","popcolor",nan,colRGB,"GraphControl" , "") UpdateControl("SetVariable", "TRACE_TRANS","value",alpha,"","GraphControl" , "_NUM:") UpdateControl("CheckBox", "TRACE_MARKERSTROKE","value",numberbykey("useMrkStrokeRGB(x)",info,"="),"","GraphControl","") UpdateControl("CheckBox", "TRACE_MARKEROPAQUE","value",numberbykey("opaque(x)",info,"="),"","GraphControl","") UpdateControl("CheckBox", "TRACE_FILLCOLORplus","value",numberbykey("usePlusRGB(x)",info,"="),"","GraphControl","") UpdateControl("CheckBox", "TRACE_FILLCOLORneg","value",numberbykey("usenegRGB(x)",info,"="),"","GraphControl","") readEB(info,stringfromlist(number,TraceNameList("", ";", 1 )),1) controlinfo/w=GraphControl TRACE_MODE if((V_value!=6)&&(V_value!=8)) disablelist+=ControlNameList("GraphControl", ";", "*fill*") else //disablelist+=ControlNameList("GraphControl", ";", "trace_trans*") endif if((V_value<4)||(V_value>5)) disablelist+=ControlNameList("GraphControl", ";", "*MARKER*") endif UpdateControl("popupmenu", "PLOT_AXIS_LEFT","mode",whichlistitem(stringbykey("YAXIS",info,":"),getaxistype(0))+1,"","GraphControl" , "") UpdateControl("popupmenu", "PLOT_AXIS_BOTTOM","mode",whichlistitem(stringbykey("XAXIS",info,":"),getaxistype(1))+1,"","GraphControl" , "") updateplotparams() else //no trace selected controlinfo/w=graphcontrol PLOT_AXIS_LEFT if(v_value>0)//there are axes if(stringmatch(s_value,stringfromlist(0,getaxistype(0)))==0) popupmenu PLOT_AXIS_LEFT mode=1,win= graphcontrol endif controlinfo/w=graphcontrol PLOT_AXIS_BOTTOM if(stringmatch(s_value,stringfromlist(0,getaxistype(1)))==0) popupmenu PLOT_AXIS_BOTTOM mode=1,win= graphcontrol endif UpdateControl("popupmenu", "PLOT_AXIS_LEFT","mode",1,"","GraphControl" , "") UpdateControl("popupmenu", "PLOT_AXIS_BOTTOM","mode",1,"","GraphControl" , "") endif endif for(i=0;i-1) controlinfo /w=GraphControl $stringfromlist(i,enablelist) if(dis!=v_disable) modifycontrollist stringfromlist(i,enablelist) disable=dis,win=GraphControl endif endfor endif setdatafolder DF end //update of the axis and plot controls function updateplotparams() string DF=getdatafolder(1) setdatafolder root:graphcontrol: svar axisleft,axisbottom variable updatelabel=0,vmin,vmax string labelname if(strlen(winname(0,1))>0 ) getwindow $winname(0,1) gsize variable left=v_left,right=v_right,top=v_top,bottom=v_bottom getwindow $winname(0,1) psize left+=v_left;right-=v_right;top+=v_top;bottom-=v_bottom UpdateControl("SetVariable", "PLOT_LEFT","value",round(left),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_RIGHT","value",round(right),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_TOP","value",round(top),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_BOTTOM","value",round(bottom),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_SIZEH","value",round(v_right-v_left),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_SIZEV","value",round(v_bottom-v_top),"","GraphControl","_NUM:") controlinfo/w=GraphControl PLOT_AXIS_BOTTOM getaxis/w=$winname(0,1)/q $S_value labelname=S_value updatelabel+=((stringmatch(s_value,AxisLabel(winname(0,1),labelname))==0)) UpdateControl("SetVariable", "PLOT_BOTTOM_MIN","value",(V_min),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_BOTTOM_MIN","width",round(strlen(num2str(V_min))*4+27),"","GraphControl","") UpdateControl("SetVariable", "PLOT_BOTTOM_MAX","value",(V_max),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_BOTTOM_MAX","width",round(strlen(num2str(V_max))*4+27),"","GraphControl","") UpdateControl("SetVariable", "PLOT_BOTTOM_LABEL","value",nan,"\""+AxisLabel(winname(0,1),labelname)+"\"","GraphControl","_str:") UpdateControl("checkbox", "PLOT_BOTTOM_MODE_LINEAR","value",numberbykey("log(x)",axisinfo("",s_value),"=")==0,"","GraphControl","") UpdateControl("checkbox", "PLOT_BOTTOM_MODE_LOG","value",numberbykey("log(x)",axisinfo("",s_value),"=")==1,"","GraphControl","") UpdateControl("checkbox", "PLOT_BOTTOM_MODE_LOG2","value",numberbykey("log(x)",axisinfo("",s_value),"=")==2,"","GraphControl","") if(stringmatch(axisbottom,AxisLabel(winname(0,1),labelname))==0) axisbottom=AxisLabel(winname(0,1),labelname) endif CheckBox TRANS_HIDE_BOTTOM ,win=GraphControl,value=((numberbykey("nticks(x)",axisinfo("",s_value),"=")+numberbykey("axThick(x)",axisinfo("",s_value),"="))==0) controlinfo/w=GraphControl PLOT_AXIS_LEFT getaxis/w=$winname(0,1)/q $S_value labelname=S_value updatelabel+=((stringmatch(s_value,AxisLabel(winname(0,1),labelname))==0)) UpdateControl("SetVariable", "PLOT_LEFT_MIN","value",(V_min),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_LEFT_MIN","width",round(strlen(num2str(V_min))*4+27),"","GraphControl","") UpdateControl("SetVariable", "PLOT_LEFT_MAX","value",(V_max),"","GraphControl","_NUM:") UpdateControl("SetVariable", "PLOT_LEFT_MAX","width",round(strlen(num2str(V_max))*4+27),"","GraphControl","") UpdateControl("SetVariable", "PLOT_LEFT_LABEL","value",nan,"\""+AxisLabel(winname(0,1),labelname)+"\"","GraphControl","_str:") UpdateControl("checkbox", "PLOT_LEFT_MODE_LINEAR","value",numberbykey("log(x)",axisinfo("",s_value),"=")==0,"","GraphControl","") UpdateControl("checkbox", "PLOT_LEFT_MODE_LOG","value",numberbykey("log(x)",axisinfo("",s_value),"=")==1,"","GraphControl","") UpdateControl("checkbox", "PLOT_LEFT_MODE_LOG2","value",numberbykey("log(x)",axisinfo("",s_value),"=")==2,"","GraphControl","") CheckBox TRANS_HIDE_LEFT ,win=GraphControl,value=((numberbykey("nticks(x)",axisinfo("",s_value),"=")+numberbykey("axThick(x)",axisinfo("",s_value),"="))==0) if(stringmatch(axisleft,AxisLabel(winname(0,1),labelname))==0) axisleft=AxisLabel(winname(0,1),labelname) endif endif setdatafolder DF end //determines if controls needs updating- used to prevent flicker function UpdateControl(ctrl,name,keyword,var,str,win ,modstr) string ctrl,name,keyword,str,win,modstr variable var dowindow GraphControl if(v_flag) if((stringmatch(keyword,"width"))) controlinfo/w=$win $name if(v_width!=var) execute ctrl+" "+name+",size={"+modstr+num2str(var)+","+num2str(v_height)+"},win="+win endif else if(numtype(var)==0) //numeric controlinfo/w=$win $name if(v_value!=var) execute ctrl+" "+name+","+keyword+"="+modstr+num2str(var)+",win="+win endif else if(strlen(str)) //string controlinfo/w=$win $name if(stringmatch(replacestring("\"",str,""),s_value)==0) execute ctrl+" "+name+","+keyword+"="+modstr+""+str+",win="+win endif endif endif endif endif end //--------------------error bars functions----------------------// function/s EBdata(type,help) string type,help help=stringbykey(type,help,"=",";") help=replacestring("(",help,"") help=replacestring(")",help,"") return help end //update error bars according to selected trace function readEB(info,tracename,docapbar) string info,tracename variable docapbar string DF=getdatafolder(1) setdatafolder root:graphcontrol: svar disablelist setdatafolder DF string st,yp="",yn="",xp="",xn="",help="" st=stringbykey("ERRORBARS",info,":",";") st=replacestring("ERRORBARS",st,"") if(docapbar) if(numtype(numberbykey("/T",st,"="))==0) UpdateControl("SetVariable", "ERROR_CAPH","value",numberbykey("/T",st,"="),"","GraphControl","_Num:") endif if(numtype(numberbykey("/Y",st,"="))==0) UpdateControl("SetVariable", "ERROR_CAPW","value",numberbykey("/Y",st,"="),"","GraphControl","_Num:") endif if(numtype(numberbykey("/L",st,"="))==0) UpdateControl("SetVariable", "ERROR_BAR","value",numberbykey("/L",st,"="),"","GraphControl","_Num:") endif endif variable alpha=1 string EBcolor=stringfromlist(2,st,",")+","+stringfromlist(3,st,",")+","+stringfromlist(4,st,",") if((stringmatch(stringfromlist(4,st,","),"*)*")==0)&&(stringmatch(st,"*SHADE*")>0)) EBcolor+=")"//","+stringfromlist(5,st,",") alpha=str2num(removeending(stringfromlist(5,st,",")))/(2^16) endif if((stringmatch(st,"*SHADE*")==0)) disablelist+= "TRACE_TRANS_SHADE;TRACE_SHADE_EB;" endif SetVariable TRACE_TRANS_SHADE win=graphcontrol,value= _NUM:alpha st=replacestring(tracename+" ",st,"") if(stringmatch(st,"*shade*")) CheckBox ERROR_SHADE value= 1,win=graphcontrol variable del=strsearch(st,"wave",0) st=replacestring(st[0,del-1],st,"") st=replacestring("wave",st,"ywave",0,1) disablelist+="ERROR_CAPW;" disablelist+="ERROR_CAPH;" disablelist+="ERROR_BAR;" UpdateControl("popupmenu", "TRACE_SHADE_EB","popColor",nan,EBcolor,"GraphControl" , "") else CheckBox ERROR_SHADE value= 0,win=graphcontrol del=strsearch(st,"X",0) if(del==-1) del=strsearch(st,"Y",0) endif st=replacestring(st[0,del-1],st,"") if (stringmatch(st,"XY*")) st=replacestring(",wave",st,";xwave",0,1) st=replacestring(",wave",st,";ywave",0,1) else if (stringmatch(st,"Y*")) st=replacestring(",wave",st,";ywave",0,1) else st=replacestring(",wave",st,";xwave",0,1) endif endif endif yp=stringfromlist(0,EBdata("ywave",st),",") yn=stringfromlist(1,EBdata("ywave",st),",") //print st,yp,yn CheckBox ERROR_YP_CHECK value=(strlen(yp)>0),win=graphcontrol CheckBox ERROR_YN_CHECK value=(strlen(yn)>0),win=graphcontrol xp=stringfromlist(0,EBdata("xwave",st),",") xn=stringfromlist(1,EBdata("xwave",st),",") UpdateControl("SetVariable", "ERROR_YP","value",nan,"\""+yp+"\"","GraphControl","_STR:") UpdateControl("SetVariable", "ERROR_YN","value",nan,"\""+yn+"\"","GraphControl","_STR:") UpdateControl("SetVariable", "ERROR_XP","value",nan,"\""+xp+"\"","GraphControl","_STR:") UpdateControl("SetVariable", "ERROR_XN","value",nan,"\""+xn+"\"","GraphControl","_STR:") UpdateControl("CheckBox", "ERROR_XP_CHECK","value",0,"","GraphControl","") UpdateControl("CheckBox", "ERROR_XN_CHECK","value",1,"","GraphControl","") //if(strlen(stringbykey("XWAVE",info,":",";"))==0) disablelist+="ERROR_XP;" disablelist+="ERROR_XN;" disablelist+="ERROR_XP_CHECK;" disablelist+="ERROR_XN_CHECK;" disablelist+="ERROR_X;" //endif setdatafolder DF end //reads the error bar information to controls function writeEB(controlname,docapbar) string controlname variable docapbar setdatafolder root:DFselect: svar wavesel,savedDF setdatafolder root:graphcontrol: wave listselect variable tnum,tracesnum=1 setdatafolder savedDF if(strlen(controlname)) SetVariable $replacestring("_CHECK",controlname,"") win=graphcontrol,value= _STR:wavesel endif string st="",yp="",yn="",xp="",xn="",xwaves="",ywaves="",cap="",bar="",shade="" controlinfo/w=graphcontrol ERROR_YP yp=s_value controlinfo/w=graphcontrol ERROR_YN yn=s_value if(stringmatch(controlname,"error_yp_check")) yn=yp endif controlinfo/w=graphcontrol ERROR_SHADE if ((v_value)&&((strlen(yp)||(strlen(yn)))))//shade controlinfo/w=graphcontrol TRACE_TRANS_SHADE variable alpha=v_value controlinfo/w=graphcontrol TRACE_SHADE_EB if((alpha<1)&&(itemsinlist(s_value,",")<=3)) s_value= removeending(addlistitem(num2str(alpha*(2^16)),removeending(s_value),",",3))+")" endif shade=" shade = {0,0,"+s_value+",(0,0,0,0)} " st=" wave=( "+yp+","+yn+")" else controlinfo/w=graphcontrol ERROR_XP xp=s_value controlinfo/w=graphcontrol ERROR_XN xn=s_value controlinfo/w=graphcontrol ERROR_CAPH cap="/T="+num2str(v_value) controlinfo/w=graphcontrol ERROR_CAPW cap+="/Y="+num2str(v_value) controlinfo/w=graphcontrol ERROR_BAR bar="/L="+num2str(v_value) if((strlen(xp)||(strlen(xn)))&&(V_disable==0)) st="X" xwaves=", wave=( "+xp+","+xn+")" endif if(strlen(yp)||(strlen(yn))) st+="Y" ywaves=", wave=( "+yp+","+yn+")" endif st+=xwaves+ywaves if(strlen(st)==0) st="OFF" endif endif for (tnum=0;tnum=0;tnum-=1) location+=1 if(strlen(laxisname)==0) laxisname=stringbykey("YAXIS",tracecopyrecreation[tnum],":") endif if (stringmatch(laxisname,"*right*")) laxis="/R="+laxisname else laxis="/L="+laxisname endif if(strlen(baxisname)==0) baxisname=stringbykey("XAXIS",tracecopyrecreation[tnum],":") endif if (stringmatch(baxisname,"*top*")) baxis="/T="+baxisname else baxis="/B="+baxisname endif if(strlen(stringbykey("XWAVE",tracecopyrecreation[tnum],":"))) execute "appendtograph "+laxis+baxis+" "+ tracecopyY[tnum]+" vs "+(stringbykey("XWAVEDF",tracecopyrecreation[tnum],":"))+(stringbykey("XWAVE",tracecopyrecreation[tnum],":")) else execute "appendtograph "+laxis+baxis +" "+ tracecopyY[tnum] endif doupdate string newtracename=stringfromlist(itemsinlist(TraceNameList("", ";", 1 ))-1,TraceNameList("", ";", 1 )) updatetracelist(0) recreation=tracecopyrecreation[tnum] //print newtracename //print recreation recreation=replacestring("RECREATION:",recreation[strsearch(recreation,"RECREATION",0),strlen(recreation)-1],"") for(i=0;i=0) if( (stringmatch(ctrlName,"*link") )||(stringmatch(ctrlName,"*shade*"))) execute /p/q "writeEB(\"\",0)" execute /p/q "updatetracecontrols(-1)" else string DF=getdatafolder(1) setdatafolder root:graphcontrol: controlinfo/w=graphcontrol $replacestring("_CHECK",ctrlName,"") string DFnew="" if (strsearch(s_value,":",1)) DFnew=s_value[0,strsearch(s_value,":",1)] endif DFnew= GetWavesDataFolder(WaveRefIndexed("", gettracenumber(-1),1),1) setdatafolder DF DFdialog(DFnew,"writeEB(\""+ctrlName+"\",1)",1,numpnts(WaveRefIndexed("", gettracenumber(-1),1)),1,0) endif endif end //updates error bars Function ERR_VISUAL(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName writeEB("",0) End //copies the plot and axis information Function PLOTINFOCOPY(ctrlName) : ButtonControl String ctrlName string DF=getdatafolder(1) setdatafolder root:graphcontrol: make/o/n=6 plotval make/t/o/n=(0,3) axesval variable i for (i=0;i=0)//axis exists execute stringbykey("SETAXISCMD", axesval[i][1],":") string info=axesval[i][1] string recreation=replacestring("RECREATION:",info[strsearch(info,"RECREATION",0),strlen(info)-1],"") for (items=0;items= 0 ) start = strsearch(info, "\"", start)+1 Variable theEnd= strsearch(info, "\"", start)-1 axisLabelST= info[start,theEnd] endif if (SuppressEscaping) start = 0 do start = strsearch(axisLabelST, "\\\\", start) // search for double backslash if (start >= 0) string newLabel = axisLabelST[0,start-1] newLabel += axisLabelST[start+1, strlen(axisLabelST)-1] axisLabelST = newLabel else break endif while(1) endif return axisLabelST End //user selection on tracelist listbox Function TRACELIST(LB_Struct) : ListBoxControl STRUCT WMListboxAction &LB_Struct Variable row=LB_Struct.row Variable col=LB_Struct.col Variable event=LB_Struct.eventcode string DF=getdatafolder(1) setdatafolder root:graphcontrol: wave listcolselect,listselect wave/t listcol ,listtext,listtitle wave/wave ywaveref,xwaveref variable i,tnum,found variable/g selectedrow //wave selectrows if ((event==1)&&(row>=-1))//mouse down, used for reorder ,replace waves if(row<0)//header if(LB_Struct.eventMod==17)//right mouse click string listdata="\\M1" for(i=0;i0) listcolselect[V_flag-1]=1-listcolselect[V_flag-1] execute/p/q "updatetracelist(0)" endif else //left mouse click listselect=floor(listselect/2)*2+1-mod(listselect,2) endif elseif (row=0) if(stringmatch(listtitle[col],"Pos")) //print row,dimsize(listselect,0) if(row1) DFname[0][0]="\\W547" //can go up endif variable numDF=CountObjects("", 4 ) variable numwave=CountObjects("", 1 ) variable wnum string waveref for(wnum=0;wnum0))//go up one level DFselect[][]=0 if(itemsinlist(getdatafolder(1),":")>1) setdatafolder :: endif wavesinDF() endif if((col==0)&&(row>0)&&(event>0)) DFselect[][1]=0 DFselect[row][0]=floor(DFselect[row][0]/2)*2 DFselect[row][1]=1 endif if((event==2)&&(DFselect[row][col]==80)) setdatafolder DFname[row][1] DFselect[row][1]=0 wavesinDF() endif if((event==3)&&(DFselect[row][0]>0))//double click setdatafolder DFname[row][1] DFselect[0][1]=0 wavesinDF() endif if(row0)),DFname[row][1] ) endif endif return 0 End //can ok button be visible, based on user selection function DFselectok(ok,trace) variable ok string trace variable i Button DFOK,win=DataFolderDialog, disable=2 for(i=0;i