#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// //** Multifunctional 2D image Displayer //** Ver. 1.00 //** Latest update: 11/15/2023 //** Author: Lingyuan Kong //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// Function ButtonProc_Showfigind(ctrlName) : ButtonControl String ctrlName d($tpw()) End Function d(name) wave name if (dataFolderExists("root:Packages:NewColortable") == 1) else NewDataFolder root:Packages; NewDataFolder root:Packages:NewColortable endif di(name) PauseUpdate Silent 1 String wn =winname(0,1) modifygraph width=303,height=303;ModifyGraph nticks=0,noLabel=2,axThick=2,standoff=0; ModifyGraph margin(right)=72;ColorScale/C/N=text0/F=0/A=RC/X=-23/Y=0 image=name;ColorScale/C/N=text0 frame=0.00 ColorScale/C/N=text0/A=LC/X=101/Y=0/F=0 frame=0.00,image=$nameofwave(name) Dowindow/F $wn drawAction delete variable lenx = (dimsize(name,0)-1)*dimdelta(name,0) variable leny = (dimsize(name,1)-1)*dimdelta(name,1) Dowindow/F $wn variable x1,x2,lenbar1,lenbar x1 = 0.75*lenx+dimoffset(name,0) lenbar1 = round(0.2*lenx) if(lenbar1 > 10) lenbar = lenbar1+(round(lenbar1/10)-lenbar1/10)*10 else lenbar = lenbar1 endif X2 = 0.75*lenx+lenbar+dimoffset(name,0) SetDrawEnv xcoord= bottom,ycoord= left,linefgc= (65535,65535,65535),linethick= 4.00 DrawLine x1,0.06*leny+dimoffset(name,1),x2,0.06*leny+dimoffset(name,1) string textv =num2str(round(lenbar))+" Å" SetDrawEnv xcoord= bottom,ycoord= left,textrgb= (65535,65535,65535),fstyle= 1,fsize= 20,textxjust= 1,textyjust= 1 DrawText 0.85*lenx+dimoffset(name,0),0.105*leny+dimoffset(name,1),textv Button colorcycling win=$winname(0,1), title="CycleC",proc=ButtonProc_colorcycling_ind,pos={101,0},size={50,12},fSize=10 Button colorplain win=$winname(0,1), title="PlainC",proc=ButtonProc_colorplain_ind,pos={176,0},size={50,12},fSize=10 Button colordiv win=$winname(0,1), title="DivgC",proc=ButtonProc_colordiv_ind,pos={251,0},size={50,12},fSize=10 Button turnoffls3d title="BACK",size={45,12},valueColor=(0,0,0),fColor=(1,65535,33232),pos={370,0},proc=ButtonProc_lsturnoff3d wavestats/Q name variable/G colormin_ind = V_min variable/G colormax_ind = V_max variable/G timesg = 3 variable/G colorinver_ind = 0 variable/G colorindexuser SetVariable setCmin size={100,20},value=colormin_ind,proc=SetVarProc_colornumind,limits={-inf,inf,(V_max-V_min)/50},title="C_Min",pos={208,319} SetVariable setCmax size={100,20},value=colormax_ind,proc=SetVarProc_colornumind,limits={-inf,inf,(V_max-V_min)/50},title="C_Max",pos={208,340} SetVariable setCmaxsigma size={60,20},value=timesg,proc=SetVarProc_coloarrange_ind,limits={-inf,inf,0.2},title="σ",pos={313,319} SetVariable setCinverse size={60,20},value=colorinver_ind,proc=SetVarProc_colorinver_ind,limits={0,1,1},title="IV",pos={313,340} PopupMenu popup0 value="*COLORTABLEPOP*",pos={0,340},proc=PopMenuProc_colormat_ind Button setCauto1 title="A",size={17,12},pos={374,319},proc=ButtonProc_colormatauto1,fSize=10 Button setCauto2 title="∓1",size={22,12},pos={395,319},proc=ButtonProc_colormatauto2,fSize=10 Button setCauto3 title="∓π",size={22,12},pos={395,335},proc=ButtonProc_colormatauto3,fSize=10 Button setCauto4 title="∓V",size={22,12},pos={374,335},proc=ButtonProc_colormatauto4,fSize=10 PopupMenu popup1 value=WaveList("*",";","",root:Packages:NewColortable:),proc=PopMenuProc_colormat_ind2,bodyWidth=130,pos={0,319} SetVariable setvarsetciuind title=" ",value=colorindexuser,proc=SetVarProc_colormatmorevv_ind variable setvarsetciuindlim = itemsInList(WaveList("*", ";", "", root:Packages:NewColortable:))+itemsInList(CtabList())-1 SetVariable setvarsetciuind limits={0,setvarsetciuindlim,1},pos={149,323} tilewindows/WINS=winname(0,1)/R/w=(18,22,100,100)/A=(1,1) //** Error message, no stop but Continuing execution String msg Variable err msg=GetErrMessage(GetRTError(0),3); err=GetRTError(1) //if (err != 0) //Print "Error in Demo: " + msg //Print "Continuing execution" //endif end Function ButtonProc_colormatauto1(ctrlName) : ButtonControl String ctrlName string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {*,*,"+color+","+colorinv execute exe wavestats/Q $tpw() variable/G colormin_ind = V_min variable/G colormax_ind = V_max end Function ButtonProc_colormatauto2(ctrlName) : ButtonControl String ctrlName string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {-1,1,"+color+","+colorinv execute exe variable/G colormin_ind = -1 variable/G colormax_ind = 1 end Function ButtonProc_colormatauto3(ctrlName) : ButtonControl String ctrlName string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {-pi,pi,"+color+","+colorinv execute exe variable/G colormin_ind = -pi variable/G colormax_ind = pi end Function ButtonProc_colormatauto4(ctrlName) : ButtonControl String ctrlName wavestats/Q $tpw() variable vv if(abs(V_max) > abs(V_min)) vv = abs(V_max) else vv = abs(V_min) endif string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {"+num2str(-vv)+","+num2str(vv)+","+color+","+colorinv execute exe variable/G colormin_ind = -vv variable/G colormax_ind = vv end Function ButtonProc_colorcycling_ind(ctrlName) : ButtonControl String ctrlName ModifyGraph noLabel=2 ModifyGraph axThick=0 ModifyImage $tpw() ctab= {-pi,pi,RainbowCycle,0} variable/G colormin_ind = -pi variable/G colormax_ind = pi variable/G colorinver_ind = 1 end Function ButtonProc_colorplain_ind(ctrlName) : ButtonControl String ctrlName ModifyGraph noLabel=0 ModifyGraph axThick=1 ModifyImage $tpw() ctab= {*,*,VioletOrangeYellow,0} wavestats/Q $tpw() variable/G colormin_ind = V_min variable/G colormax_ind = V_max variable/G colorinver_ind = 0 end Function ButtonProc_colordiv_ind(ctrlName) : ButtonControl String ctrlName ModifyGraph noLabel=0 ModifyGraph axThick=1 wavestats/Q $tpw() variable vv if(abs(V_max) > abs(V_min)) vv = abs(V_max) else vv = abs(V_min) endif ModifyImage $tpw() ctab= {-vv,vv,root:RedWhiteBlue256,1} variable/G colormin_ind = -vv variable/G colormax_ind = vv variable/G colorinver_ind = 1 end Function SetVarProc_colornumind(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName variable/G colormin_ind variable/G colormax_ind string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {"+num2str(colormin_ind)+","+num2str(colormax_ind)+","+color+","+colorinv execute exe End Function SetVarProc_coloarrange_ind(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName gethistgram_np() wave W_coef=$"W_coef" string name = tpw() wavestats/Q $name variable sigma = sqrt(2)*W_coef[3] variable lc,lh variable/G timesg if (W_coef[2]-0.5*timesg*sigma >V_min) lc = W_coef[2]-0.5*timesg*sigma else lc =V_min endif if (W_coef[2]+0.5*timesg*sigma < V_max) lh = W_coef[2]+0.5*timesg*sigma else lh =V_max endif string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {"+num2str(lc)+","+num2str(lh)+","+color+","+colorinv execute exe variable/G colormin_ind = lc variable/G colormax_ind = lh string a1 = "fit_Hist_"+tpw() string a2 = "Hist_"+tpw() string a3 = "W_coef" string a4 = "W_sigma" killwaves $a1 $a2 $a3 $a4 End Function SetVarProc_colorinver_ind(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName variable/G colorinver_ind variable/G colormin_ind variable/G colormax_ind string color=stringfromlist(2,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {"+num2str(colormin_ind)+","+num2str(colormax_ind)+","+color+","+num2str(colorinver_ind)+"}" execute exe end Function PopMenuProc_colormat_ind(ctrlName,popNum,popStr) : PopupMenuControl String ctrlName Variable popNum String popStr variable/G colorinver_ind variable/G colormin_ind variable/G colormax_ind string color=popStr string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {"+num2str(colormin_ind)+","+num2str(colormax_ind)+","+color+","+num2str(colorinver_ind)+"}" execute exe variable numnew = itemsInList(WaveList("*", ";", "", root:Packages:NewColortable:)) variable/G colorindexuser = numnew+popNum-1 End Function PopMenuProc_colormat_ind2(ctrlName,popNum,popStr) : PopupMenuControl String ctrlName Variable popNum String popStr variable/G colorinver_ind variable/G colormin_ind variable/G colormax_ind string color="root:Packages:NewColortable:"+popStr string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string exe exe = "ModifyImage $tpw() ctab= {"+num2str(colormin_ind)+","+num2str(colormax_ind)+","+color+","+num2str(colorinver_ind)+"}" execute exe variable/G colorindexuser = popNum-1 //** Error message, no stop but Continuing execution String msg Variable err msg=GetErrMessage(GetRTError(0),3); err=GetRTError(1) //if (err != 0) //Print "Error in Demo: " + msg //Print "Continuing execution" //endif End Function SetVarProc_colormatmorevv_ind(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName colormatmorevv_ind() End Function colormatmorevv_ind() variable/G colorinver_ind variable/G colormin_ind variable/G colormax_ind variable/G colorindexuser variable numnew = itemsInList(WaveList("*", ";", "", root:Packages:NewColortable:)) string colorinv=stringfromlist(3,stringByKey("RECREATION",imageinfo("",tpw(),0)),",") string color string exe if(colorindexuser < numnew) color="root:Packages:NewColortable:"+stringfromList(colorindexuser,WaveList("*", ";", "", root:Packages:NewColortable:)) exe = "ModifyImage $tpw() ctab= {"+num2str(colormin_ind)+","+num2str(colormax_ind)+","+color+","+num2str(colorinver_ind)+"}" execute exe PopupMenu popup1 value=WaveList("*",";","",root:Packages:NewColortable:),proc=PopMenuProc_colormat_ind2,pos={0,319},mode = colorindexuser+1 else color=stringfromList(colorindexuser-numnew,CtabList()) exe = "ModifyImage $tpw() ctab= {"+num2str(colormin_ind)+","+num2str(colormax_ind)+","+color+","+num2str(colorinver_ind)+"}" execute exe PopupMenu popup0 value="*COLORTABLEPOP*",pos={0,340},proc=PopMenuProc_colormat_ind,mode=colorindexuser-numnew+1 endif //** Error message, no stop but Continuing execution String msg Variable err msg=GetErrMessage(GetRTError(0),3); err=GetRTError(1) //if (err != 0) //Print "Error in Demo: " + msg //Print "Continuing execution" //endif End Function di(destw) wave destw string fulllist = WinList("*", ";","WIN:1") //"1 for graph, 2 for table" string name,cmd,wavenamelist variable i,cc String dest=nameofwave(destw) cc=0 for(i=0; i