#pragma rtGlobals=3 // Use modern global access method and strict wave access. #include Function ModifyFuzzy(s) //hook function to update the fuzzy plot STRUCT WMWinHookStruct &s if(s.eventcode==8) dowindow/f Fuzzypanel //only when the panel is present if(v_flag) UpdateFuzzy(s.winName) endif endif End Function /wave Col2Wave(ColSt)//extract color from (r,g,b) format to n=3 wave string ColSt make/o/n=3 ColWave ColSt=ReplaceString("(",ColSt,"r=") ColSt=ReplaceString(",",ColSt,";g=",0,1) ColSt=ReplaceString(",",ColSt,";b=",0,1) ColSt=ReplaceString(")",ColSt,";") ColWave[0]=NumberbyKey("r",ColSt,"=") ColWave[1]=NumberbyKey("g",ColSt,"=") ColWave[2]=NumberbyKey("b",ColSt,"=") return ColWave End Function UpdateFuzzy(name)//draws the lines that make the blur, on userBack layer string name string FuzzyTraces=getuserdata(name,"","Fuzzy"),CurrentTrace variable numFuzzy,pnts,size variable FuzzySize,FuzzyStyle make/o/n=3 FuzzyCol,OrigCol //gather parameters-saved in userdata of the plot window duplicate/o Col2Wave(getuserdata(name,"","Col")),FuzzyCol FuzzySize=str2num(getuserdata(name,"","Size")) FuzzyStyle=str2num(getuserdata(name,"","Style")) //draw setdrawlayer /w=$name userBack DrawAction /w=$name delete SetDrawEnv /w=$name xcoord= bottom,ycoord= left,save //find the traces to blur numFuzzy=0 do if (waveexists(WaveRefIndexed(name,numFuzzy,1))) Duplicate/o WaveRefIndexed(name,numFuzzy,1), tempFuzzyy else break endif CurrentTrace=nameofwave(WaveRefIndexed(name,numFuzzy,1)) numFuzzy+=1 if(StringMatch(FuzzyTraces,"*"+ CurrentTrace+";*")) duplicate/o Col2Wave(StringByKey("rgb(x)",traceinfo(name,CurrentTrace,0),"=")),OrigCol if(strlen(StringByKey("xwave",traceinfo(name,CurrentTrace,0)))>0) Duplicate/o $StringByKey("xwavedf",traceinfo(name,CurrentTrace,0))+StringByKey("xwave",traceinfo(name,CurrentTrace,0)), tempFuzzyx else make/o/n=(numpnts(tempFuzzyy)) tempFuzzyx=p endif for(pnts=0;pnts0;size-=1) //the size of the blur duplicate/o FuzzyCol,ColWave ColWave=abs((OrigCol-FuzzyCol)/FuzzySize*(FuzzySize-size)+FuzzyCol) SetDrawEnv /w=$name linethick= size,linefgc=(ColWave[0],ColWave[1],ColWave[2]),dash= FuzzyStyle, xcoord= bottom,ycoord= left DrawLine /w=$name tempFuzzyx[pnts], tempFuzzyy[pnts], tempFuzzyx[pnts+1], tempFuzzyy[pnts+1] endfor endfor endif while(1) killwaves/z tempFuzzyy,tempFuzzyx,FuzzyCol,OrigCol,ColWave//cleanup End Function SetFuzzy()//fuzzy selected trace GetLastUserMenuInfo string CurrentTrace=S_traceName string FuzzyTraces=getuserdata(S_graphName,"","Fuzzy") if (StringMatch(FuzzyTraces,"*"+CurrentTrace+"*")) //trace is fuzzy, unfuzzy it FuzzyTraces=ReplaceString(CurrentTrace+";",FuzzyTraces,"") else FuzzyTraces+=CurrentTrace+";" endif setwindow $S_graphName userdata(Fuzzy)=FuzzyTraces UpdateFuzzyParams() End Function FuzzyNone(ctrlName) : ButtonControl//remove fuzzy from all traces String ctrlName setwindow $winname(0,1),userdata(Fuzzy)="" UpdateFuzzy(winname(0,1)) End Function UpdateFuzzyParams() //read the params from fuzzypanel dowindow/f Fuzzypanel //only when the panel is present if(v_flag) controlinfo/w=Fuzzypanel SetFuzzySize setwindow $winname(0,1),userdata(Size)=num2str(V_Value) controlinfo/w=Fuzzypanel BackPopup setwindow $winname(0,1),userdata(Col)=S_Value controlinfo/w=Fuzzypanel LineStylepopup setwindow $winname(0,1),userdata(Style)=num2str(V_Value-1) setwindow $winname(0,1) hook(fuzzy)=ModifyFuzzy endif End Function FuzzyAll(ctrlName) : ButtonControl//make all traces fuzzy String ctrlName setwindow $winname(0,1),userdata(Fuzzy)=TracenameList(winname(0,1),";",1) UpdateFuzzyParams() UpdateFuzzy(winname(0,1)) End Function MakeFuzzyPanel()//the main panel dowindow/f FuzzyPanel if(v_flag==0) newpanel/k=1/n=FuzzyPanel/w=(200,200,280,340)/FLT=1 PopupMenu BackPopup,pos={14,59},size={50,21} PopupMenu BackPopup,mode=1,popColor= (0,0,0),value= #"\"*COLORPOP*\"" SetVariable SetFuzzySize,pos={10,24},size={60,16},title="Size" SetVariable SetFuzzySize,limits={1,10,1},value= _NUM:3,noedit= 1 GroupBox FuzzyGB,pos={4,4},size={70,128},title="Fuzzy Lines" TitleBox BackgroundTitle,pos={10,43},size={58,13},title="Background",frame=0 PopupMenu LineStylepopup bodyWidth=50,value="*LINESTYLEPOP*",pos={14,79} Button FuzzAll,pos={10,105},size={25,20},proc=FuzzyAll,title="All" Button FuzzNone,pos={35,105},size={35,20},proc=FuzzyNone,title="None" SetActiveSubwindow _endfloat_ endif End //menu items Menu "TracePopup" "Fuzzy Line",/q ,SetFuzzy() End Menu "Graph" "Fuzzy Line",/q ,MakeFuzzyPanel() End