#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 #pragma IgorVersion = 9.00 #pragma ModuleName = AngDistModule_9 #pragma version = 1.10 // // 2023-05-22 - ver. 1.10: update QdrawOval function Menu "Q Ways", dynamic "---" "Qround Angle Distribution", /Q, BuildRounndCutTBPanel() End // function BuildRounndCutTBPanel() String topGraph=WinName(0,1) String pName = "RoundCutTB" String gName = WinName(0,1) // string ttlabel = "Cut Angle dist :\r" + gName DoWindow/K $pName if (WinType(pName) == 7) DoWindow/F/Z $pName return 0 endif if (ItemsinList(WinList("*", ";", "WIN:1")) == 0) Abort "No graphs available. Create a graph first." endif NewPanel/K=1/FLT=0/N=$pName/W=(0,0,288,200) // ModifyPanel/W=$pName ,noEdit=1 //RenameWindow #, SubWinTBControl SetWindow $pName hook(UpdateHook)=RoundCutUpdateFunc TitleBox tb1,pos={2,20},size={0,0},anchor=LC,title=ttlabel TitleBox tb1 frame=4,labelBack=(65535,60076,49151) if(strlen(topGraph)) AutoPositionWindow/M=0/R=$topGraph $pName endif SetDrawLayer UserBack SetDrawEnv fstyle= 1,textrgb= (65535,16385,16385) DrawText 370,3,"V2.7" SetDrawEnv fsize= 16,fstyle= 1 DrawText 12,65,"X_c:" SetDrawEnv fsize= 16,fstyle= 1 DrawText 78,65,"Y_c:" SetDrawEnv fsize= 16,fstyle= 1 DrawText 144,66,"Radial:" SetDrawEnv fsize= 16,fstyle= 1 DrawText 214,65,"∆r:" SetVariable SubWinX_posi,pos={11.00,69.00},size={55.00,18.00},proc=RoundCutTBControl SetVariable SubWinX_posi,limits={0,1000,1},value=_NUM:451 SetVariable SubWinY_posi,pos={78.00,69.00},size={55.00,18.00},proc=RoundCutTBControl SetVariable SubWinY_posi,limits={0,1000,1},value=_NUM:451 SetVariable Radial_posi,pos={144.00,69.00},size={55.00,18.00},proc=RoundCutTBControl SetVariable Radial_posi,limits={0,1000,1},value=_NUM:15 SetVariable deltaRadia_posi,pos={209.00,69.00},size={55.00,18.00},proc=RoundCutTBControl SetVariable deltaRadia_posi,limits={0,300,0.5},value=_NUM:0 SetVariable ChannelName title="Peak Name",pos={11,124},size={130,24},fColor=(65535,0,26214),value=_STR:"her" Button Drop_ang title="Drop it",pos={220,104},fColor=(52428,34958,1),proc=DropAngdistControl,help={"duplicate current profile named by Peak Name"} Button ResetTG ,pos={220,128},size={45 , 22},proc=ResetImageCenterValues ,title="Reset",fColor=(65535,0,52428),help={"reset the X Y center"} PopupMenu popTraceRGB, win=$pName,pos={143,20},size={150,21}, title="Guide color",Proc=QColorPupTBControl//, bodywidth=50 PopupMenu popTraceRGB, win=$pName,mode=1,popColor= (0,0,0),value= #"\"*COLORPOP*\"", fsize=13 PopupMenu popTraceRGB, win=$pName,help={"Select \"Other...\", then the eye dropper to select color with mouse"} SetWindow kwTopWin,hook(UpdateHook)=RoundCutUpdateFunc fetchImageCenterValues() return 0 end // Function RoundCutUpdateFunc(s) STRUCT WMWinHookStruct &s If (s.eventCode == 0) // FetchLatestSubWinValues() String gName = WinName(0,1) string ttlabel = "Cut Angle dist :\r" + gName TitleBox tb1,title=ttlabel return 1 endif return 0 End // Function ResetImageCenterValues(cba): ButtonControl struct WMButtonAction &cba string ttwinname=cba.userdata if (cba.eventcode==2) fetchImageCenterValues() endif End // function fetchImageCenterValues() String pName = "RoundCutTB" wave xVa_w_graph = QGetImageref() string Str_w_grap = nameofWave(xVa_w_graph) variable Xcent = dimsize($Str_w_grap,0)/2 variable Ycent = dimsize($Str_w_grap,1)/2 variable Radial = Xcent/2 SetVariable SubWinX_posi ,win=$pName ,value=_NUM:Xcent SetVariable SubWinY_posi ,win=$pName ,value=_NUM:Ycent setVariable Radial_posi ,win=$pName ,value=_NUM:Radial return 0 end // //#########--**-- ------------ --**--######### static Function/wave QGetImageref() String gName = getTopGraph() String s=ImageNameList(gName,";") // if(strlen(s)==0) s=traceNameList(gName,";",0) Wave w=TraceNameToWaveRef("",StringFromList(0,s)) endif // if(strlen(s)!=0) Wave w=ImageNameToWaveRef("",StringFromList(0,s)) endif // return w End function QColorPupTBControl(STRUCT WMPopupAction &s) if (s.eventCode != 2) return 0 endif String pName = "RoundCutTB" strswitch(s.ctrlName) case "popTraceRGB": ControlInfo /W=$pName popTraceRGB Make /free wRGB = {V_Red,V_Green,V_Blue} PopupMenu popTraceRGB, win=$pName, popColor=(wRGB[0],wRGB[1],wRGB[2]) break endswitch QdrawOval() return 0 end // Function RoundCutTBControl(s) : SetVariableControl struct WMSetVariableAction &s if (s.eventCode == 1 || s.eventCode == 2) RoundCutTBVarChange(s.ctrlName, s.dval) endif return 0 End // static Function RoundCutTBVarChange(ctrlName, val) String ctrlName Variable val String gName = getTopGraph() String pName = "RoundCutTB" if (!strlen(gName)) return 0 endif StrSwitch(ctrlName) case "SubWinX_posi": QdrawOval() SetVariable SubWinX_posi, win=$pName, value = _NUM:val break case "SubWinY_posi": QdrawOval() SetVariable SubWinY_posi, win=$pName, value = _NUM:val break case "Radial_posi": QdrawOval() SetVariable Radial_posi, win=$pName, value = _NUM:val break case "deltaRadia_posi": QdrawOval() SetVariable deltaRadia_posi, win=$pName, value = _NUM:val break EndSwitch // // fetchLatestSubWinValues() // ?? can not work ?? return 0 end // Function DropAngdistControl(s) : ButtonControl STRUCT WMButtonAction &s if (s.eventCode != 2) return 0 endif String gName = winName(0,1) if (!strlen(gName)) return 0 endif String pName = "RoundCutTB" ControlInfo/W=$pName SubWinX_posi Variable Xc = V_Value ControlInfo/W=$pName SubWinY_posi Variable Yc = V_Value ControlInfo/W=$pName Radial_posi Variable R_d = V_value ControlInfo/W=$pName deltaRadia_posi Variable R_inteval = V_value ControlInfo/W=$pName ChannelName String Pkname = S_value string xVa_w_graph = QGetGraphSname() xVa_w_graph = xVa_w_graph[0, strlen(xVa_w_graph) - 2] String outerAngdistName = "AngProf_" + xVa_w_graph +"_"+Pkname+ "_R" + num2str(R_d) + "_delt" + num2str(R_inteval) outerAngdistName = CleanupName(outerAngdistName, 0) print Xc, Yc, R_d, R_inteval String outerAxes = outerAngdistName + "_rc" print outerAngdistName wave dist_ang wave W_ImageLineProfile StrSwitch(s.ctrlName) // case "Drop_ang": // print current graph name printf "\r//--**-- current graph is: %s", gName matrixOp/O $outerAngdistName = W_ImageLineProfile matrixOp/O $outerAxes = dist_ang display $outerAngdistName vs $outerAxes // string ori_str = WinName(0,1) // only graph // Dowindow/F $ori_str // ensure that break EndSwitch return 0 End //#########--**-- --------- function QdrawOval() variable Xc, Yc, R_d, R_inteval String pName = "RoundCutTB" ControlInfo/W=$pName SubWinX_posi Xc = V_Value ControlInfo/W=$pName SubWinY_posi Yc = V_Value ControlInfo/W=$pName Radial_posi R_d = V_value ControlInfo/W=$pName deltaRadia_posi R_inteval = V_value variable r1 = R_d-R_inteval/2 variable r2 = R_d+R_inteval/2 String topGraph=WinName(0,1) Dowindow/F $topGraph ControlInfo/W=$pName popTraceRGB Make /free wRGB = {V_Red,V_Green,V_Blue} // print V_Red,V_Green,V_Blue ShowTools/A arrow SetDrawLayer/K ProgFront if(R_inteval==0) SetDrawEnv xcoord= bottom,ycoord= left,fillpat= 0 // SetDrawEnv xcoord= abs,ycoord= abs,fillpat= 0 SetDrawEnv dash= 3 SetDrawEnv linefgc= (wRGB[0],wRGB[1],wRGB[2]) DrawOval Xc - R_d,Yc + R_d,Xc + R_d,Yc - R_d else SetDrawEnv xcoord= bottom,ycoord= left,fillpat= 0 // SetDrawEnv xcoord= abs,ycoord= abs,fillpat= 0 SetDrawEnv dash= 0,linethick= 0.50 SetDrawEnv linefgc= (wRGB[0],wRGB[1],wRGB[2]) DrawOval Xc - R_d,Yc + R_d,Xc + R_d,Yc - R_d SetDrawEnv xcoord= bottom,ycoord= left,fillpat= 0 // SetDrawEnv xcoord= abs,ycoord= abs,fillpat= 0 SetDrawEnv dash= 3,linethick= 0.50 SetDrawEnv linefgc= (wRGB[0],wRGB[1],wRGB[2]) DrawOval Xc - r2,Yc + r2,Xc + r2,Yc - r2 SetDrawEnv xcoord= bottom,ycoord= left,fillpat= 0 // SetDrawEnv xcoord= abs,ycoord= abs,fillpat= 0 SetDrawEnv dash= 3,linethick= 0.50 SetDrawEnv linefgc= (wRGB[0],wRGB[1],wRGB[2]) DrawOval Xc - r1,Yc + r1,Xc + r1, Yc - r1 endif HideTools/A string xVa_w_graph = QGetGraphSname() xVa_w_graph = xVa_w_graph[0, strlen(xVa_w_graph) - 2] wave/Z w_image = $xVa_w_graph ImagelineProfile/RAD={Xc, Yc, R_d, R_inteval, pi/180} srcWave=w_image variable nps = numpnts($"W_ImageLineProfile") make/O/n=(nps) dist_ang = 2*pi*x/nps // //// print xVa_w_graph return 0 end // static function /S QGetGraphSname() String gName = getTopGraph() String s=ImageNameList(gName,";") // print s //debug string list = "" if(strlen(s)==0) s = traceNameList(gName,";",1) // StringFromList(items-1 - i,list) // print list //debug endif // print strlen(s) return s End // // static Function/S getTopGraph() String windows = WinList("*", ";", "") String topwindow = StringFromList(0, windows) // print topwindow Variable i = 1 do // try finding a valid graph, even if it is not the top one Variable wtype = WinType(topwindow) if (wtype == 1 || wtype == 3 || wtype == 7) // top window is graph or a type that can contain a graph GetWindow $topwindow, activeSW // for the active sub window (this can also be the top-level, if there are not children, or no child is active) if (strlen(S_value) > 0 && WinType(S_value) == 1) return S_value // this isn't necessarily an immediate child of top window elseif (wtype == 1) return topwindow endif endif topwindow = StringFromList(i, windows) i += 1 while (strlen(topWindow) > 0) return "" // no graph found End //