#pragma rtGlobals=3 // Use modern global access method and strict wave access. #include Function QHAADFCreateLineProfileGraph() String imName = WMTopImageGraph() // Get name of top window with an image; if none alert and abort if(strlen(imName)==0) DoAlert 0,"No image plot found" return 0 endif DoWindow/F QHAADFLineProfileGraph // Create the a Profile Graph Window or bring it to front if it exists (V_Flag=1) if(V_Flag==1) AutoPositionWindow/E/M=1/R=$imName return 0 endif WAVE imWave = $WMGetImageWave(imName) // Reference wave in graph; does not handle multiple images on graph String saveDF = GetDataFolder(1) // Save current DF String waveDF = StringFromList(0,note(imWave),";") // Read the Data Folder associated to the Image from the Image note // Create or Go To the Package Data Folder NewDataFolder/O/S root:Packages NewDataFolder/O/S root:Packages:QHAADF NewDataFolder/O/S root:Packages:QHAADF:LineProfile String/G imageGraphName Variable/G width = 20 Variable/G swidth = width*DimDelta(imWave,0) Variable/G isEditing = 0 Variable/G csrDist = 0 Variable/G isDispCsr = 0 Variable/G profAvg = 0 Variable/G profMax = 0 Variable/G profMin = 0 Make/O profile // Wave that stores the profile WAVE profile = profile Make/O/N=2 xWav // Wave that stores the x positions of the profile line; passed to DrawLine WAVE xWav = xWav Make/O/N=2 yWav // Wave that stores the y positions of the profile line; passed to DrawLine Wave yWav = yWav Make/O/N=8 polyWav //Wave that stores the coordinates for the profile frame; passed to DrawPoly Wave polyWav SetDataFolder saveDF Variable x0 = 40*72/ScreenResolution Variable y0 = 349*72/ScreenResolution Variable x1 = 560*72/ScreenResolution Variable y1 = 569*72/ScreenResolution Display/K=1/W=(x0,y0,x1,y1) profile as "QHAADF Line Profile" DoWindow/C QHAADFLineProfileGraph AutoPositionWindow/E/M=1/R=$imName ControlBar 80 SetVariable profWidthVar, pos={236,8}, size={90,15}, proc=QHAADFSetProfWidthProc SetVariable profWidthVar, title="Width" SetVariable profWidthVar, help={"Width over which to average profile"} SetVariable profWidthVar, limits={0,sqrt(2)*DimDelta(imWave,0)*DimSize(imWave,0),DimDelta(imWave,0)}, value=root:Packages:QHAADF:LineProfile:swidth Button saveProfBut, pos={335,4}, size={87,20}, proc=QHAADFSaveProfProc Button saveProfBut, title="Save Profile" Button saveProfBut, help={"Save Currently displayed profile"} Button remProfBut, pos={426,4}, size={87,20}, proc=QHAADFRemProfProc Button remProfBut, title = "Remove Profile" Button remProfBut, help={"Remove Profile from Image"} Button startPathBut, pos={4,4}, size={110,20}, proc=QHAADFstartPathProc Button startPathBut, title="Start Editing Line" Button startPathBut, help={"Click this button to start editing path"} Button finishPathBut, pos={118,4}, size={110,20}, proc=QHAADFfinishPathProc Button finishPathBut, title="Finish Editing Line" Button finishPathBut, help={"Click this button to finish editing path"} CheckBox csrDisplayCB, pos={4,30}, proc=QHAADFcsrDispCBProc CheckBox csrDisplayCB, title="Display Cursors", variable=isDispCsr CheckBox csrDisplayCB, help={"Check to Display Cursors"} ValDisplay csrDispDelta, pos={118,30}, size={110,20}, value=#"root:Packages:QHAADF:LineProfile:csrDist" ValDisplay csrDispDelta, title="Layer thick: ", format="%.1W1Pm" ValDisplay csrDispDelta, help={"Displays distance measured between cursors A & B on the profile"} ValDisplay dispProfAvg, pos={236,30}, size={80,20}, value=#"root:Packages:QHAADF:LineProfile:profAvg" ValDisplay dispProfAvg, title="Avg: " ValDisplay dispProfAvg, help={"Displays profile mean between cursors A & B"} ValDisplay dispProfMax, pos={335,30}, size={80,20}, value=#"root:Packages:QHAADF:LineProfile:profMax" ValDisplay dispProfMax, title="Max: " ValDisplay dispProfMax, help={"Displays mean of points that are >=95% max between A & B"} ValDisplay dispProfMin, pos={426,30}, size={80,20}, value=#"root:Packages:QHAADF:LineProfile:profMin" ValDisplay dispProfMin, title="Min: " ValDisplay dispProfMin, help={"Displays mean of points that are <=105% min between A & B"} Button newResults, pos={4,52}, size={110,20}, proc=QHAADFnewResProc Button newResults, title="New Results" Button newResults, help={"Click this button to create and show results table"} Button showResults, pos={118,52}, size={110,20}, proc=QHAADFshowResProc Button showResults, title="Show Results" Button showResults, help={"Click this button to show results table"} Button appResults, pos={232,52}, size={110,20}, proc=QHAADFappResProc Button appResults, title="Append to Results" Button appResults, help={"Click this button to append fields to results table"} Button clrResults, pos={346,52}, size={110,20}, proc=QHAADFclrResProc Button clrResults, title="Clear Results" Button clrResults, help={"Click this button to clear results table"} SetWindow QHAADFLineProfileGraph,hook(ILPWinHook)=QHAADFILPWinHook SetWindow $imName,hook(ILPGraphWinHook)=QHAADFILPImWinHook QHAADFInitLineProf() End // Function to remove the profile from the image Function QHAADFRemProfProc(ctrlName) : ButtonControl String ctrlName String imName = WMTopImageGraph() WAVE profile = root:Packages:QHAADF:LineProfile:profile NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing if(isEditing) QHAADFfinishPathProc("finishPathBut") endif Redimension/N=128 profile profile = 0 SetDrawLayer/W=$imName/K ProgFront // Removes the drawing of the profile square on the image by killing the PrgFront Layer (/K Flag) End Function QHAADFfinishPathProc(ctrlName) : ButtonControl String ctrlName String imName = WMTopImageGraph() DrawAction/L=ProgFront/W=$imName getgroup=profLine, commands if(!V_flag) QHAADFToggleEditMode() //Toggles Global Variable isEditing to indicate that the drawing is not being edited anymore return 0 endif QHAADFToggleEditMode() //Toggles Global Variable isEditing to indicate that the drawing is not being edited anymore SetDrawLayer/W=$imName UserFront HideTools/W=$imName/A //DoWindow/F QHAADFLineProfileGraph QHAADFUpdImLineProf() // Updates Profile Graph from new position of Drawing End Function QHAADFstartPathProc(ctrlName) : ButtonControl String ctrlName String imName = WMTopImageGraph() NVAR isDispCsr = root:Packages:QHAADF:LineProfile:isDispCsr NVAR csrDist = root:Packages:QHAADF:LineProfile:csrDist NVAR profAvg = root:Packages:QHAADF:LineProfile:profAvg NVAR profMax = root:Packages:QHAADF:LineProfile:profMax NVAR profMin = root:Packages:QHAADF:LineProfile:profMin QHAADFToggleEditMode() // Toggle Global Variable isEditing to 1 to indicate that the profile is being edited if(isDispCsr) isDispCsr=0 DoUpdate/W=QHAADFLineProfileGraph Cursor/K/W=QHAADFLineProfileGraph A Cursor/K/W=QHAADFLineProfileGraph B csrDist = 0 profAvg = 0 profMax = 0 profMin = 0 QHAADFEraseCsrFrame() endif DrawAction/L=ProgFront/W=$imName getgroup=_all_, commands if(!V_flag) QHAADFInitLineProf() // Initialize line profile in case it has been removed endif DrawAction/L=ProgFront/W=$imName getgroup=profFram, delete SetDrawLayer/W=$imName ProgFront ShowTools/W=$imName/A arrow End Function QHAADFInitLineProf() String imName = WMTopImageGraph() WAVE imWave = $WMGetImageWave(imName) WAVE profile = root:Packages:QHAADF:LineProfile:profile WAVE xWav = root:Packages:QHAADF:LineProfile:xWav WAVE yWav = root:Packages:QHAADF:LineProfile:yWav WAVE polyWav = root:Packages:QHAADF:LineProfile:polyWav NVAR width = root:Packages:QHAADF:LineProfile:width GetAxis/W=$imName/Q bottom xWav[0] = V_min + 0.25*(V_max-V_min) xWav[1] = V_min + 0.75*(V_max-V_min) GetAxis/Q/W=$imName left yWav[0] = V_min + 0.25*(V_max-V_min) yWav[1] = V_min + 0.75*(V_max-V_min) QHAADFCompImLineFrame() // Compute frame showing width from the profile line and the width variables QHAADFDrawImLineProf() // Draw the image line on the profiles QHAADFDoImLineProf() // Extract the profile End Function QHAADFDrawImLineProf() String imName = WMTopImageGraph() WAVE xWav = root:Packages:QHAADF:LineProfile:xWav WAVE yWav = root:Packages:QHAADF:LineProfile:yWav WAVE polyWav = root:Packages:QHAADF:LineProfile:polyWav SetDrawLayer/W=$imName/K ProgFront SetDrawLayer/W=$imName ProgFront SetDrawEnv/W=$imName xcoord=bottom, ycoord=left, fillpat=0, save SetDrawEnv/W=$imName linethick = 1.5, linefgc = (65535,0,0) SetDrawEnv/W=$imName gstart, gname=profLine DrawLine/W=$imName xWav[0],yWav[0],xWav[1],yWav[1] SetDrawEnv/W=$imName gstop SetDrawEnv/W=$imName linethick = 1.5, linefgc = (0,65535,0) SetDrawEnv/W=$imName gstart, gname=profFram DrawPoly/W=$imName polyWav[0],polyWav[1],1,1,{polyWav[0],polyWav[1],polyWav[2],polyWav[3],polyWav[4],polyWav[5],polyWav[6],polyWav[7],polyWav[0],polyWav[1]} SetDrawEnv/W=$imName gstop SetDrawLayer/W=$imName userFront End Function QHAADFDoImLineProf() WAVE imWave = $WMGetImageWave(WMTopImageGraph()) WAVE profile = root:Packages:QHAADF:LineProfile:profile WAVE xWav = root:Packages:QHAADF:LineProfile:xWav WAVE yWav = root:Packages:QHAADF:LineProfile:yWav NVAR width = root:Packages:QHAADF:LineProfile:width Variable d = sqrt((xWav[1]-xWav[0])^2+(yWav[1]-yWav[0])^2) NewDataFolder/O/S qhaadfTmp ImageLineProfile/SC srcWave = imWave, xWave = xWav , yWave = yWav, width = width WAVE W_ImageLineProfile Duplicate/O W_ImageLineProfile, profile SetScale/I x,0,d,WaveUnits(imWave,0) profile KillDataFolder : End Function QHAADFUpdImLineProf() NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing QHAADFUpdLineCoords() // Update the WAVES that contain the position of the Profile Line QHAADFCompImLineFrame() // Compute the new Frame coordinates from updated position // Redraw Line and Frame; Frame is only redrawn if User is not still in Editing mode if(isEditing==0) QHAADFDrawImLineProf() endif // Update the Profile displayed in the QHAADF Line Profile Graph QHAADFDoImLineProf() //Extracts the line profile End Function QHAADFUpdLineCoords() String imName = WMTopImageGraph() WAVE xWav = root:Packages:QHAADF:LineProfile:xWav WAVE yWav = root:Packages:QHAADF:LineProfile:yWav NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing DrawAction/L=ProgFront/W=$imName getgroup=profLine, commands if(!V_flag) return 0 endif String coordList = StringFromList(1,StringFromList(3,S_Recreation,"\r")," ") xWav[0] = str2num(StringFromList(0,coordList,",")) yWav[0] = str2num(StringFromList(1,coordList,",")) xWav[1] = str2num(StringFromList(2,coordList,",")) yWav[1] = str2num(StringFromList(3,coordList,",")) End //************************************************************************************************************************** // // QHAADFCompLineFrame() computes the coordinates of the polygon frame that shows // the width over which the Line Profile is integrated. It takes no input arguments; it relies // on WAVES and GLOBAL VARIABLES that are stored in the following DATAFOLDER: // // :root:Packages:DHAADF:LineProfile // // The following WAVES are used: // // imWave - Reference to the WAVE containing the image that is displayed // xWav - Stores abscissae of the Line drawn for the Profile (Passed to DrawLine) // yWav - Stores ordinates of the Line drawn for the Profile (Passed to DrawLine) // // The following GLOBAL VARIABLES are used: // // width - Stores the value for the width attribute of the ImageLineProfile procedure; it set // in the ProfWidthVar SetVariable of the the QHAADFLineProfile Window // // The output is stored in the following WAVE: // // polyWav - Stores the coordinates of the vertices of the polygon to be drawn; Passed to DrawPoly // // All coordinates are computed with respect to the coordinates of the first point of // the Profile Line (xWav[0],yWav[0]) // //------------------------------------------------------------------------------------------------------------------------------------------- Function QHAADFCompImLineFrame() WAVE imWave = $WMGetImageWave(WMTopImageGraph()) WAVE xWav = root:Packages:QHAADF:LineProfile:xWav WAVE yWav = root:Packages:QHAADF:LineProfile:yWav WAVE polyWav = root:Packages:QHAADF:LineProfile:polyWav NVAR width = root:Packages:QHAADF:LineProfile:width Variable d = sqrt((xWav[1]-xWav[0])^2+(yWav[1]-yWav[0])^2) // Total profile length polyWav[0] = xWav[0]-DimDelta(imWave,0)*width/2*abs(yWav[1]-yWav[0])/d polyWav[1] = yWav[0]+DimDelta(imWave,0)*width/2*abs(xWav[1]-xWav[0])/d polyWav[2] = xWav[0]+DimDelta(imWave,0)*width/2*abs(yWav[1]-yWav[0])/d polyWav[3] = yWav[0]-DimDelta(imWave,0)*width/2*abs(xWav[1]-xWav[0])/d polyWav[4] = xWav[1]+xWav[0]-polyWav[0] polyWav[5] = yWav[1]+yWav[0]-polyWav[1] polyWav[6] = xWav[1]+xWav[0]-polyWav[2] polyWav[7] = yWav[1]+yWav[0]-polyWav[3] End //********************************************************************************************************************** // // QHAADFSetProfWidthProc is a SetVarianble Control Function that sets the width attribute // for calls of the ImageLineProfile procedure and also the width of the frame drawn on the // image that is being processed. The user enters the desired value in the appopriate dimension, // and the function divides it by the image dimension to store the width in pixels, as ImageLineProfile // only accepts a width in pixels. // // The function requires the following input arguments: // // ctrlName - STRING VARIABLE that contains the SetVariable Control Name // varNum - NUM VARIABLE; contains the numeric value of the variable in the SetVariable field // varStr - STR VARIABLE; contains the string value of the variable in the SetVariable field // varName - STR VARIABLE; String containing the name of the Variable in the SetVariable field // // // GLOBAL VARIABLES: // // width - Global Numeric Variable that holds the width (in pixels) that is passed to ImageLineProfile // // WAVE REFERENCES: // // imWave - Reference to the WAVE that holds the displayed image; used to retriev the DimSize //--------------------------------------------------------------------------------------------------------------------------------------- Function QHAADFSetProfWidthProc(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName NVAR width = root:Packages:QHAADF:LineProfile:width WAVE imWave = $WMGetImageWave(WMTopImageGraph()) width = varNum/DimDelta(imWave,0) // Divide by WAVE dimension to store the width in pixels; required for ImageLineProfile QHAADFUpdImLineProf() // Update drawing of the Frame in the Graph that displays the image End //************************************************************************************************************************** // // QHAADFSaveProfProc - ButtonControl Functin for the "Save Profile" button. // Saves a copy of the profile in the folder that holds the image wave. Handles multiple profiles by // incrementing the counter at the end of the profile name. The output is named after the wave the WAVE // that holds the image, with the extension "_prof" and a numeric counter. The profile is a 1D wave that // is scaled from the total length of the line drawn on the image it is extracted from. // // Input Arguments: // // ctrlName - STR VARIABLE; Name of the control // // Variables: // // cdf - STR VARIABLE; stores current DATA FOLDER // waveDF - STR VARIABLE; stores the DATA FOLDER of the WAVE displayed in the Graph // baseName - STR VARIABLE; stores the base name of the output profile wave // outName - STR VARIABLE; name of the output wave (baseName + counter) // // Waves: // // profile - Reference to the profile wave currently displayed in the QHAADF Line Profile Window; // this is the wave that is duplicated into the image folder // //------------------------------------------------------------------------------------------------------------------------------------------- Function QHAADFSaveProfProc(ctrlName) : ButtonControl String ctrlName WAVE imWave = $WMGetImageWave(WMTopImageGraph()) String cdf = GetDataFolder(1) String waveDF = GetWavesDataFolder(imWave, 1 ) String baseName = NameOfWave(imWave)+"_prof" String outName = baseName WAVE profile = root:Packages:QHAADF:LineProfile:profile SetDataFolder waveDF outName += num2str(ItemsInList(WaveList("*_prof*",";","DIMS:1"))) Duplicate profile,$outName SetScale/P x,0,DimDelta(profile,0),WaveUnits(profile,0) $outName SetDataFolder cdf End Function QHAADFILPWinHook(s) STRUCT WMWinHookStruct &s Variable hookResult = 0 NVAR width = root:Packages:QHAADF:LineProfile:width NVAR swidth = root:Packages:QHAADF:LineProfile:swidth NVAR isDispCsr = root:Packages:QHAADF:LineProfile:isDispCsr Variable delta = swidth/width switch(s.eventCode) case 0: QHAADFUpdImLineProf() hookResult = 1 break case 2: QHAADFRemProfProc("remProfBut") hookResult = 1 break case 7: QHAADFUpdCsrDist() if(isDispCsr) QHAADFUpdCsrFrame() endif hookResult = 1 break case 11: //Keyboard Event switch(s.keycode) case 43: swidth+=delta width=swidth/delta QHAADFUpdImLineProf() hookResult = 1 break case 45: swidth-=delta width=swidth/delta QHAADFUpdImLineProf() hookResult = 1 break endswitch break endswitch return hookResult End Function QHAADFILPImWinHook(s) STRUCT WMWinHookStruct &s Variable hookResult = 0 NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing switch(s.eventCode) case 8: if(isEditing) QHAADFUpdImLineProf() endif hookResult = 1 break endswitch return hookResult End Function QHAADFToggleEditMode() NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing isEditing = !isEditing End Function QHAADFcsrDispCBProc(s) : CheckBoxControl STRUCT WMCheckboxAction &s NVAR csrDist = root:Packages:QHAADF:LineProfile:csrDist NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing NVAR profAvg = root:Packages:QHAADF:LineProfile:profAvg NVAR profMax = root:Packages:QHAADF:LineProfile:profMax NVAR profMin = root:Packages:QHAADF:LineProfile:profMin if(isEditing) return 0 endif // Print s.checked GetAxis/Q/W=QHAADFLineProfileGraph bottom Variable x0 = 0.1*(V_max-V_min) Variable x1 = 0.2*(V_max-V_min) GetAxis/Q/W=QHAADFLineProfileGraph left Variable y0 = 0.5*(V_max+V_min) if(s.checked) Cursor/W=QHAADFLineProfileGraph/F/S=2/H=2/L=1 A profile x0,y0 Cursor/W=QHAADFLineProfileGraph/F/S=2/H=2/L=1 B profile x1,y0 QHAADFUpdCsrDist() QHAADFCompCsrFrame() QHAADFDrawCsrFrame() DoUpdate else Cursor/K/W=QHAADFLineProfileGraph A Cursor/K/W=QHAADFLineProfileGraph B csrDist = 0 profAvg = 0 profMax = 0 profMin = 0 QHAADFEraseCsrFrame() DoUpdate endif End Function QHAADFUpdCsrDist() NVAR csrDist = root:Packages:QHAADF:LineProfile:csrDist WAVE profile = root:Packages:QHAADF:LineProfile:profile NVAR profAvg = root:Packages:QHAADF:LineProfile:profAvg NVAR profMax = root:Packages:QHAADF:LineProfile:profMax NVAR profMin = root:Packages:QHAADF:LineProfile:profMin csrDist = abs(hcsr(A)-hcsr(B)) Duplicate/FREE/R=(hcsr(A),hcsr(B)) profile, tmp WaveStats/Q tmp profAvg = V_avg tmp[] = (tmp[p]>=0.95*V_max) ? tmp[p] : NaN WaveTransform zapNaNs tmp profMax = mean(tmp) Duplicate/O/FREE/R=(hcsr(A),hcsr(B)) profile, tmp tmp[] = (tmp[p]<=1.05*V_min) ? tmp[p] : NaN WaveTransform zapNaNs tmp profMin = mean(tmp) DoUpdate /W=QHAADFLineProfileGraph End Function QHAADFDrawCsrFrame() String imName = WMTopImageGraph() WAVE/Z coordCsrLines = root:Packages:QHAADF:LineProfile:coordCsrLines DrawAction/L=ProgFront/W=$imName getgroup=csrLines, delete SetDrawLayer/W=$imName ProgFront SetDrawEnv/W=$imName gstart, gname=csrLines SetDrawEnv/W=$imName xcoord=bottom, ycoord=left, linefgc=(0,0,65535), linethick=2,dash=8 DrawLine/W=$imName coordCsrLines[0][0],coordCsrLines[1][0],coordCsrLines[0][1],coordCsrLines[1][1] SetDrawEnv/W=$imName xcoord=bottom, ycoord=left, linefgc=(0,0,65535), linethick=2,dash=8 DrawLine/W=$imName coordCsrLines[0][2],coordCsrLines[1][2],coordCsrLines[0][3],coordCsrLines[1][3] SetDrawEnv/W=$imName gstop SetDrawLayer/W=$imName UserFront End Function QHAADFEraseCsrFrame() String imName = WMTopImageGraph() DrawAction/L=ProgFront/W=$imName getgroup=csrLines, delete End Function QHAADFUpdCsrFrame() String imName = WMTopImageGraph() QHAADFCompCsrFrame() WAVE coordCsrLines = root:Packages:QHAADF:LineProfile:coordCsrLines DrawAction/L=ProgFront/W=$imName getgroup=csrLines, delete, beginInsert SetDrawLayer/W=$imName ProgFront SetDrawEnv/W=$imName gstart, gname=csrLines SetDrawEnv/W=$imName xcoord=bottom, ycoord=left, linefgc=(0,0,65535), linethick=2,dash=8 DrawLine/W=$imName coordCsrLines[0][0],coordCsrLines[1][0],coordCsrLines[0][1],coordCsrLines[1][1] SetDrawEnv/W=$imName xcoord=bottom, ycoord=left, linefgc=(0,0,65535), linethick=2,dash=8 DrawLine/W=$imName coordCsrLines[0][2],coordCsrLines[1][2],coordCsrLines[0][3],coordCsrLines[1][3] SetDrawEnv/W=$imName gstop SetDrawLayer/W=$imName UserFront DrawAction/L=ProgFront/W=$imName endInsert End Function QHAADFCompCsrFrame() String path2Coords="root:Packages:QHAADF:LineProfile:coordCsrLines" if(WaveExists($path2Coords)) WAVE coordCsrLines = $path2Coords else Make/N=(2,4) $path2Coords WAVE coordCsrLines = $path2Coords endif WAVE xWav = root:Packages:QHAADF:LineProfile:xWav WAVE yWav = root:Packages:QHAADF:LineProfile:yWav WAVE polyWav = root:Packages:QHAADF:LineProfile:polyWav NVAR swidth = root:Packages:QHAADF:LineProfile:swidth NVAR isEditing = root:Packages:QHAADF:LineProfile:isEditing String imName = WMTopImageGraph() if(isEditing) QHAADFfinishPathProc("finishPathBut") endif Variable csrA = hcsr(A,"QHAADFLineProfileGraph") Variable csrB = hcsr(B,"QHAADFLineProfileGraph") // if(numtype(csrA)==2 || numtype(csrB)==2 ) // // DoAlert/T="WARNING" 0, "Please make sure both cursors are on the profile" // return 0 // endif Variable d = sqrt((xWav[1]-xWav[0])^2+(yWav[1]-yWav[0])^2) Make/FREE/N=(3,3) M_transform Make/FREE/N=(3,1) tmp tmp = {polyWav[0],polyWav[1],1} M_transform = {{1,0,0},{0,1,0},{csrA*(xWav[1]-xWav[0])/d,csrA*(yWav[1]-yWav[0])/d,1}} MatrixOP/O tmp = M_transform x tmp coordCsrLines[0][0] = tmp[0] coordCsrLines[1][0] = tmp[1] tmp = {polyWav[2],polyWav[3],1} MatrixOP/O tmp = M_transform x tmp coordCsrLines[0][1] = tmp[0] coordCsrLines[1][1] = tmp[1] tmp = {polyWav[0],polyWav[1],1} M_transform = {{1,0,0},{0,1,0},{csrB*(xWav[1]-xWav[0])/d,csrB*(yWav[1]-yWav[0])/d,1}} MatrixOP/O tmp = M_transform x tmp coordCsrLines[0][2] = tmp[0] coordCsrLines[1][2] = tmp[1] tmp = {polyWav[2],polyWav[3],1} MatrixOP/O tmp = M_transform x tmp coordCsrLines[0][3] = tmp[0] coordCsrLines[1][3] = tmp[1] End Function QHAADFnewResProc(ctrlName) : ButtonControl String ctrlName NVAR csrDist = root:Packages:QHAADF:LineProfile:csrDist NVAR profAvg = root:Packages:QHAADF:LineProfile:profAvg NVAR profMax = root:Packages:QHAADF:LineProfile:profMax NVAR profMin = root:Packages:QHAADF:LineProfile:profMin WAVE imWave = $WMGetImageWave(WMTopImageGraph()) String resName = NameOfWave(imWave)+"_r" String saveDF = GetDataFolder(1) String waveDF = GetWavesDataFolder(imWave,1) SetDataFolder waveDF Make/O/N=(1,4) $resName WAVE resWave = $resName String rowName = "Layer #"+num2str(DimSize(resWave,0)) resWave[0][0] = csrDist resWave[0][1] = profAvg resWave[0][2] = profMax resWave[0][3] = profMin SetDimLabel 1,0, $"Thickness (m)", resWave SetDimLabel 1,1, 'Average', resWave SetDimLabel 1,2, 'Max', resWave SetDimLabel 1,3, 'Min', resWave SetDimLabel 0,0, $rowName, resWave SetDataFolder saveDF QHAADFshowResProc("showResults") End Function QHAADFshowResProc(ctrlName) : ButtonControl String ctrlName String imName = WMTopImageGraph() WAVE imWave = $WMGetImageWave(imName) String resName = NameOfWave(imWave)+"_r" String saveDF = GetDataFolder(1) String waveDF = GetWavesDataFolder(imWave,1) SetDataFolder waveDF WAVE resWave = $resName if(!WaveExists(resWave)) return 0 endif DoWindow/F QHAADFResultsTable if(V_flag) DoWindow/K QHAADFResultsTable endif Edit/K=1 resWave.ld DoWindow/C QHAADFResultsTable AutoPositionWindow/E/M=0/R=$imName SetDataFolder saveDF End Function QHAADFappResProc(ctrlName) : ButtonControl String ctrlName NVAR csrDist = root:Packages:QHAADF:LineProfile:csrDist NVAR profAvg = root:Packages:QHAADF:LineProfile:profAvg NVAR profMax = root:Packages:QHAADF:LineProfile:profMax NVAR profMin = root:Packages:QHAADF:LineProfile:profMin WAVE imWave = $WMGetImageWave(WMTopImageGraph()) String resName = NameOfWave(imWave)+"_r" String saveDF = GetDataFolder(1) String waveDF = GetWavesDataFolder(imWave,1) SetDataFolder waveDF WAVE resWave = $resName if(!WaveExists(resWave)) return 0 endif Variable rowNum = DimSize(resWave,0) Redimension/N=(rowNum+1,4) resWave String rowName = "Layer #"+num2str(rowNum+1) resWave[rowNum][0] = csrDist resWave[rowNum][1] = profAvg resWave[rowNum][2] = profMax resWave[rowNum][3] = profMin SetDimLabel 0,rowNum, $rowName, resWave DoUpdate SetDataFolder saveDF End Function QHAADFclrResProc(ctrlName) : ButtonControl String ctrlName WAVE imWave = $WMGetImageWave(WMTopImageGraph()) String resName = NameOfWave(imWave)+"_r" String saveDF = GetDataFolder(1) String waveDF = GetWavesDataFolder(imWave,1) SetDataFolder waveDF DoWindow/K QHAADFResultsTable KillWaves/Z $resName SetDataFolder saveDF End