diff --git a/Packages/MIES/MIES_GuiUtilities.ipf b/Packages/MIES/MIES_GuiUtilities.ipf index cab833cefc..4de124f789 100644 --- a/Packages/MIES/MIES_GuiUtilities.ipf +++ b/Packages/MIES/MIES_GuiUtilities.ipf @@ -1864,13 +1864,15 @@ End /// @brief Recursively build a list of windows, including all child /// windows, starting with wName. /// -/// @param wName parent window name to start with, if wName is empty then all graphs, tables, layouts, notebooks and panels +/// @param wName parent window name to start with, if wName is empty then all graphs, tables, layouts, notebooks, panels and gizmo /// with subwindows (possible for graphs and panels) are returned /// @return A string containing names of windows. This list is a semicolon separated list. It will include the window /// wName, if wName was not empty, and all of its children and children of children, etc. Function/S GetAllWindows(string wName) string windowList = "" + + ASSERT(!IsNull(wName), "Can not work with null string") [windowList] = GetAllWindowsImpl(wName) return windowList @@ -1889,6 +1891,9 @@ static Function [string windowList] GetAllWindowsImpl(string wName) [windowList] = GetAllWindowsImpl(win) endfor else + if(!WindowExists(wName)) + return [windowList] + endif windowList = AddListItem(wName, windowList, ";", Inf) if(!WindowTypeCanHaveChildren(wName)) diff --git a/Packages/MIES/MIES_Structures.ipf b/Packages/MIES/MIES_Structures.ipf index 4adfd750fc..df7e277756 100644 --- a/Packages/MIES/MIES_Structures.ipf +++ b/Packages/MIES/MIES_Structures.ipf @@ -630,15 +630,6 @@ Structure CheckParametersStruct string setName // name of the stimulus set EndStructure -/// @brief Helper struct for data gathered by SF formula plotter in SF_GatherFormulaResults -Structure SF_PlotMetaData - string dataType // from SF_META_DATATYPE constant - string opStack // from SF_META_OPSTACK constant - string argSetupStack // from SF_META_ARGSETUPSTACK constant - string xAxisLabel // from SF_META_XAXISLABEL constant - string yAxisLabel // from SF_META_YAXISLABEL constant -EndStructure - /// @brief ReadOut Structure for ASYNC Structure ASYNC_ReadOutStruct DFREF dfr // dfr with output data diff --git a/Packages/MIES/MIES_SweepFormula.ipf b/Packages/MIES/MIES_SweepFormula.ipf index a6a59e5cbd..49637a0a47 100644 --- a/Packages/MIES/MIES_SweepFormula.ipf +++ b/Packages/MIES/MIES_SweepFormula.ipf @@ -164,7 +164,7 @@ Function SF_FormulaWaveScaleTransfer(WAVE source, WAVE dest, variable dimSource, endswitch End -static Function [WAVE/WAVE formulaResults, STRUCT SF_PlotMetaData plotMetaData] SF_GatherFormulaResults(string xFormula, string yFormula, string graph, variable lineNr, variable offset) +static Function [WAVE/WAVE formulaResults, WAVE/T plotMetaData] SF_GatherFormulaResults(string xFormula, string yFormula, string graph, variable lineNr, variable offset) variable i, numResultsY, numResultsX variable useXLabel, addDataUnitsInAnnotation @@ -234,11 +234,13 @@ static Function [WAVE/WAVE formulaResults, STRUCT SF_PlotMetaData plotMetaData] dataUnits = SelectString(addDataUnitsInAnnotation && !IsEmpty(dataUnitCheck), "", SF_FormatUnit(dataUnitCheck)) endif - plotMetaData.dataType = JWN_GetStringFromWaveNote(wvYRef, SF_META_DATATYPE) - plotMetaData.opStack = JWN_GetStringFromWaveNote(wvYRef, SF_META_OPSTACK) - plotMetaData.argSetupStack = JWN_GetStringFromWaveNote(wvYRef, SF_META_ARGSETUPSTACK) - plotMetaData.xAxisLabel = SelectString(useXLabel, SF_XLABEL_USER, JWN_GetStringFromWaveNote(wvYRef, SF_META_XAXISLABEL)) - plotMetaData.yAxisLabel = JWN_GetStringFromWaveNote(wvYRef, SF_META_YAXISLABEL) + dataUnits + WAVE/T plotMetaData = GetSFPlotMetaData() + + plotMetaData[%DATATYPE] = JWN_GetStringFromWaveNote(wvYRef, SF_META_DATATYPE) + plotMetaData[%OPSTACK] = JWN_GetStringFromWaveNote(wvYRef, SF_META_OPSTACK) + plotMetaData[%ARGSETUPSTACK] = JWN_GetStringFromWaveNote(wvYRef, SF_META_ARGSETUPSTACK) + plotMetaData[%XAXISLABEL] = SelectString(useXLabel, SF_XLABEL_USER, JWN_GetStringFromWaveNote(wvYRef, SF_META_XAXISLABEL)) + plotMetaData[%YAXISLABEL] = JWN_GetStringFromWaveNote(wvYRef, SF_META_YAXISLABEL) + dataUnits return [formulaResults, plotMetaData] End @@ -266,15 +268,15 @@ static Function/S SF_GetAnnotationPrefix(string dataType) endswitch End -static Function/S SF_GetTraceAnnotationText(STRUCT SF_PlotMetaData &plotMetaData, WAVE data) +static Function/S SF_GetTraceAnnotationText(WAVE/T plotMetaData, WAVE data) variable channelNumber, channelType, sweepNo, isAveraged string channelId, prefix, legendPrefix string traceAnnotation, annotationPrefix - prefix = RemoveEnding(ReplaceString(";", plotMetaData.opStack, " "), " ") + prefix = RemoveEnding(ReplaceString(";", plotMetaData[%OPSTACK], " "), " ") - strswitch(plotMetaData.dataType) + strswitch(plotMetaData[%DATATYPE]) case SF_DATATYPE_EPOCHS: // fallthrough case SF_DATATYPE_SWEEP: // fallthrough case SF_DATATYPE_LABNOTEBOOK: // fallthrough @@ -287,7 +289,7 @@ static Function/S SF_GetTraceAnnotationText(STRUCT SF_PlotMetaData &plotMetaData legendPrefix = " " + legendPrefix + " " endif - sprintf annotationPrefix, "%s%s", SF_GetAnnotationPrefix(plotMetaData.dataType), legendPrefix + sprintf annotationPrefix, "%s%s", SF_GetAnnotationPrefix(plotMetaData[%DATATYPE]), legendPrefix if(IsValidSweepNumber(sweepNo)) channelNumber = JWN_GetNumberFromWaveNote(data, SF_META_CHANNELNUMBER) @@ -299,7 +301,7 @@ static Function/S SF_GetTraceAnnotationText(STRUCT SF_PlotMetaData &plotMetaData endif break default: - if(WhichListItem(SF_OP_DATA, plotMetaData.opStack) == -1) + if(WhichListItem(SF_OP_DATA, plotMetaData[%OPSTACK]) == -1) sprintf traceAnnotation, "%s", prefix else channelNumber = JWN_GetNumberFromWaveNote(data, SF_META_CHANNELNUMBER) @@ -327,7 +329,7 @@ static Function/S SF_GetTraceAnnotationText(STRUCT SF_PlotMetaData &plotMetaData return traceAnnotation End -static Function/S SF_GetMetaDataAnnotationText(STRUCT SF_PlotMetaData &plotMetaData, WAVE data, string traceName) +static Function/S SF_GetMetaDataAnnotationText(WAVE/T plotMetaData, WAVE data, string traceName) return "\\s(" + traceName + ") " + SF_GetTraceAnnotationText(plotMetaData, data) + "\r" End @@ -492,7 +494,7 @@ End /// /// @retval traces generated trace names /// @retval traceCnt total count of all traces (input *and* output) -static Function [WAVE/T traces, variable traceCnt] SF_CreateTraceNames(variable numTraces, variable dataNum, STRUCT SF_PlotMetaData &plotMetaData, WAVE data) +static Function [WAVE/T traces, variable traceCnt] SF_CreateTraceNames(variable numTraces, variable dataNum, WAVE/T plotMetaData, WAVE data) string traceAnnotation @@ -829,8 +831,6 @@ End static Function SF_KillWindowAndParentsIfEmpty(string win) - string subWindows - KillWindow/Z $win for(;;) win = RemoveEnding(win, "#" + LastStringFromList(win, sep = "#")) @@ -855,7 +855,7 @@ static Function SF_KillEmptyDataWindows(WAVE/T plotGraphs) endfor End -/// @brief Tiles the subwindows in the panels acording to existing data, requires SF_DM_SUBWINDOWS mode +/// @brief Tiles the subwindows in the panels according to existing data, requires SF_DM_SUBWINDOWS mode static Function SF_TileExistingData(WAVE/T plotGraphs) variable numSubWins, numData, guidePos, subWindowIndex, posIndex, col, numCols @@ -939,6 +939,76 @@ static Function SF_IsDataForTableDisplay(WAVE wvY) return IsNaN(useTable) ? 0 : !!useTable End +/// @brief Evaluates the formulas and returns results for all successfully evaluated ones +/// Data structure wave tree, rows are filled: +/// WREF indexing over all graphs +/// WREF indexing over all formula results with two columns +/// col %DATA: formularesults +/// col %META: plot meta data +/// +/// Formula results are in the format as returned by SF_GatherFormulaResults() from GetFormulaGatherWave() +/// with indexing over the results of a single formula and two columns +/// col %FORMULAX +/// col %FORMULAY +/// +/// @param graph graph name of SB/DB +/// @param formula formula to plot +/// @param lineVars number of lines in the SF notebook with variable assignments in front of the formula +/// +/// @returns dataInGraphs waveref wave with the structure as explained above +/// @returns err set to 1 if there was an evaluation error, 0 otherwise +static Function [WAVE/WAVE dataInGraphs, variable err] SF_PlotterGetDataFromFormulas(string graph, string formula, variable lineVars) + + variable i, numDataInGraph, numGraphs + string formulasRemain, moreFormulas, xFormula, yFormula, yAndXFormula + variable line, lineGraph, lineGraphFormula, xFormulaOffset + + err = 0 + + WAVE/T graphCode = SF_SplitCodeToGraphs(formula) + numGraphs = DimSize(graphCode, ROWS) + + Make/FREE/WAVE/N=(numGraphs) dataInGraphs + for(i = 0; i < numGraphs; i += 1) + + formulasRemain = graphCode[i][%GRAPHCODE] + lineGraph = str2num(graphCode[i][%LINE]) + + WAVE/WAVE dataInGraph = GetSFDataInGraph() + numDataInGraph = 0 + do + SplitString/E=SF_SWEEPFORMULA_WITH_REGEXP formulasRemain, yAndXFormula, moreFormulas + if(!V_flag) + break + endif + line = lineVars + lineGraph + lineGraphFormula + lineGraphFormula = SF_GetLineNumberOfRemainingCode(formulasRemain, moreFormulas) + formulasRemain = moreFormulas + + [xFormula, yFormula, xFormulaOffset] = SF_SplitGraphsToFormula(yAndXFormula) + SFH_ASSERT(!IsEmpty(yFormula), "Could not determine y [vs x] formula pair.") + + WAVE/Z/WAVE formulaResults = $"" + WAVE/Z/T plotMetaData = $"" + try + [formulaResults, plotMetaData] = SF_GatherFormulaResults(xFormula, yFormula, graph, line, xFormulaOffset) + catch + err = 1 + continue + endtry + EnsureLargeEnoughWave(dataInGraph, indexShouldExist = numDataInGraph) + dataInGraph[numDataInGraph][%DATA] = formulaResults + dataInGraph[numDataInGraph][%META] = plotMetaData + + numDataInGraph += 1 + while(1) + Redimension/N=(numDataInGraph, -1) dataInGraph + dataInGraphs[i] = dataInGraph + endfor + + return [dataInGraphs, err] +End + /// @brief Plot the formula using the data from graph /// /// @param graph graph to pass to SF_FormulaExecutor @@ -949,27 +1019,25 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode string trace, customLegend variable i, j, k, l, numTraces, splitTraces, splitY, splitX, numGraphs, numWins, numData, dataCnt, traceCnt - variable winDisplayMode, showLegend, tagCounter, overrideMarker, line, lineGraph, lineGraphFormula + variable winDisplayMode, showLegend, tagCounter, overrideMarker variable xMxN, yMxN, xPoints, yPoints, keepUserSelection, numAnnotations, formulasAreDifferent, postPlotPSX - variable formulaCounter, gdIndex, markerCode, lineCode, lineStyle, traceToFront, isCategoryAxis, xFormulaOffset - variable showInTable, numTableFormulas, formulaAddedOncePerDataset + variable formulaCounter, gdIndex, markerCode, lineCode, lineStyle, traceToFront, isCategoryAxis + variable showInTable, numTableFormulas, formulaAddedOncePerDataset, cntDataInGraph, numDataInGraph, evalErr string win, winTable, wList, winNameTemplate, exWList, wName, annotation, xAxisLabel, yAxisLabel, wvName, info, xAxis - string formulasRemain, moreFormulas, yAndXFormula, xFormula, yFormula, tagText, name, winHook - STRUCT SF_PlotMetaData plotMetaData - STRUCT RGBColor color + string tagText, name, winHook + STRUCT RGBColor color winDisplayMode = ParamIsDefault(dmMode) ? SF_DM_SUBWINDOWS : dmMode lineVars = ParamIsDefault(lineVars) ? NaN : lineVars ASSERT(winDisplaymode == SF_DM_NORMAL || winDisplaymode == SF_DM_SUBWINDOWS, "Invalid display mode.") - DFREF dfr = SF_GetBrowserDF(graph) - - WAVE/T graphCode = SF_SplitCodeToGraphs(formula) - - SVAR lastCode = $GetLastSweepFormulaCode(dfr) + DFREF dfr = SF_GetBrowserDF(graph) + SVAR lastCode = $GetLastSweepFormulaCode(dfr) keepUserSelection = !cmpstr(lastCode, formula) - numGraphs = DimSize(graphCode, ROWS) + [WAVE/WAVE evalFormulas, evalErr] = SF_PlotterGetDataFromFormulas(graph, formula, lineVars) + + numGraphs = DimSize(evalFormulas, ROWS) wList = "" winNameTemplate = SF_GetFormulaWinNameTemplate(graph) @@ -977,6 +1045,18 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode for(j = 0; j < numGraphs; j += 1) + win = plotGraphs[j][%GRAPH] + winTable = plotGraphs[j][%TABLE] + if(winDisplayMode == SF_DM_NORMAL) + wList = AddListItem(win, wList) + wList = AddListItem(winTable, wList) + endif + + WAVE/WAVE graphFormulas = evalFormulas[j] + if(!DimSize(graphFormulas, ROWS)) + continue + endif + traceCnt = 0 numAnnotations = 0 postPlotPSX = 0 @@ -988,49 +1068,28 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode Make/FREE/T/N=0 xAxisLabels, yAxisLabels - formulasRemain = graphCode[j][%GRAPHCODE] - lineGraph = str2num(graphCode[j][%LINE]) - - win = plotGraphs[j][%GRAPH] - winTable = plotGraphs[j][%TABLE] - if(winDisplayMode == SF_DM_NORMAL) - wList = AddListItem(win, wList) - wList = AddListItem(winTable, wList) - endif - Make/FREE=1/T/N=(MINIMUM_WAVE_SIZE) wAnnotations, formulaArgSetup, tableFormulas Make/FREE=1/WAVE/N=(MINIMUM_WAVE_SIZE) collPlotFormData - do + numDataInGraph = DimSize(graphFormulas, ROWS) + for(cntDataInGraph = 0; cntDataInGraph < numDataInGraph; cntDataInGraph += 1) + + WAVE/Z/WAVE formulaResults = graphFormulas[cntDataInGraph][%DATA] + if(!WaveExists(formulaResults)) + ASSERT(evalErr, "Got null wave as one result for formula, but evaluation returned no error") + continue + endif + WAVE/T plotMetaData = graphFormulas[cntDataInGraph][%META] WAVE/WAVE plotFormData = SF_CreatePlotFormulaDataWave() gdIndex = 0 annotation = "" formulaAddedOncePerDataset = 0 - SplitString/E=SF_SWEEPFORMULA_WITH_REGEXP formulasRemain, yAndXFormula, moreFormulas - if(!V_flag) - break - endif - line = lineVars + lineGraph + lineGraphFormula - lineGraphFormula = SF_GetLineNumberOfRemainingCode(formulasRemain, moreFormulas) - formulasRemain = moreFormulas + SF_GatherAxisLabels(formulaResults, plotMetaData[%XAXISLABEL], "FORMULAX", xAxisLabels) + SF_GatherAxisLabels(formulaResults, plotMetaData[%YAXISLABEL], "FORMULAY", yAxisLabels) - [xFormula, yFormula, xFormulaOffset] = SF_SplitGraphsToFormula(yAndXFormula) - SFH_ASSERT(!IsEmpty(yFormula), "Could not determine y [vs x] formula pair.") - - WAVE/Z/WAVE formulaResults = $"" - try - [formulaResults, plotMetaData] = SF_GatherFormulaResults(xFormula, yFormula, graph, line, xFormulaOffset) - catch - SF_KillEmptyDataWindows(plotGraphs) - Abort - endtry - - SF_GatherAxisLabels(formulaResults, plotMetaData.xAxisLabel, "FORMULAX", xAxisLabels) - SF_GatherAxisLabels(formulaResults, plotMetaData.yAxisLabel, "FORMULAY", yAxisLabels) - - if(!cmpstr(plotMetaData.dataType, SF_DATATYPE_PSX)) + if(!CmpStr(plotMetaData[%DATATYPE], SF_DATATYPE_PSX)) PSX_Plot(win, graph, formulaResults, plotMetaData) postPlotPSX = 1 continue @@ -1060,9 +1119,9 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode SFH_ASSERT(!(IsTextWave(wvResultY) && WaveDims(wvResultY) > 1), "Plotter got 2d+ text wave as y data.") - [color] = SF_GetTraceColor(graph, plotMetaData.opStack, wvResultY, colorGroups) + [color] = SF_GetTraceColor(graph, plotMetaData[%OPSTACK], wvResultY, colorGroups) - if(!WaveExists(wvResultX) && !IsEmpty(plotMetaData.xAxisLabel)) + if(!WaveExists(wvResultX) && !IsEmpty(plotMetaData[%XAXISLABEL])) WAVE/Z wvResultX = JWN_GetNumericWaveFromWaveNote(wvResultY, SF_META_XVALUES) if(!WaveExists(wvResultX)) @@ -1231,7 +1290,7 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode EnsureLargeEnoughWave(wAnnotations, indexShouldExist = numAnnotations) wAnnotations[numAnnotations] = annotation EnsureLargeEnoughWave(formulaArgSetup, indexShouldExist = numAnnotations) - formulaArgSetup[numAnnotations] = plotMetaData.argSetupStack + formulaArgSetup[numAnnotations] = plotMetaData[%ARGSETUPSTACK] numAnnotations += 1 endif @@ -1241,7 +1300,7 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode Redimension/N=(gdIndex, -1) tracesInGraph, dataInGraph collPlotFormData[formulaCounter] = plotFormData formulaCounter += 1 - while(1) + endfor if(numTableFormulas) Redimension/N=(numTableFormulas) tableFormulas @@ -1442,6 +1501,10 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode endif endfor endif + + if(evalErr) + Abort + endif End static Function SF_DeriveTraceDisplayMode(WAVE/Z wvX, WAVE wvY) diff --git a/Packages/MIES/MIES_SweepFormula_PSX.ipf b/Packages/MIES/MIES_SweepFormula_PSX.ipf index b569b76824..6d60a408a4 100644 --- a/Packages/MIES/MIES_SweepFormula_PSX.ipf +++ b/Packages/MIES/MIES_SweepFormula_PSX.ipf @@ -3869,7 +3869,7 @@ End /// /// This is only called for the very first `psx` operation output, subsequent /// `psx` operation outputs are just added as additional combos. -static Function PSX_CreatePSXGraphAndSubwindows(string win, string graph, STRUCT SF_PlotMetaData &plotMetaData) +static Function PSX_CreatePSXGraphAndSubwindows(string win, string graph, WAVE/T plotMetaData) string mainWin, extSubWin, extSingleGraph, extAllGraph @@ -3894,7 +3894,7 @@ static Function PSX_CreatePSXGraphAndSubwindows(string win, string graph, STRUCT WAVE sweepDataOffFilt = GetPSXSweepDataOffFiltWaveFromDFR(comboDFR) WAVE sweepDataOffFiltDeconv = GetPSXSweepDataOffFiltDeconvWaveFromDFR(comboDFR) - [STRUCT RGBColor color] = SF_GetTraceColor(graph, plotMetaData.opStack, sweepData, $"") + [STRUCT RGBColor color] = SF_GetTraceColor(graph, plotMetaData[%OPSTACK], sweepData, $"") AppendToGraph/W=$win/C=(color.red, color.green, color.blue)/L=leftOffFilt sweepDataOffFilt AppendToGraph/W=$win/L=leftOffFilt peakYAtFilt vs peakX @@ -4487,7 +4487,7 @@ static Function PSX_GetNumberOfCombinations(WAVE/WAVE results) End /// @brief High-level function responsible for `psx` data and plot management -Function PSX_Plot(string win, string graph, WAVE/Z/WAVE results, STRUCT SF_PlotMetaData &plotMetaData) +Function PSX_Plot(string win, string graph, WAVE/Z/WAVE results, WAVE/T plotMetaData) variable numCombos, i, offset, firstOp, numFailures diff --git a/Packages/MIES/MIES_Utilities_WaveHandling.ipf b/Packages/MIES/MIES_Utilities_WaveHandling.ipf index cf659d4cd0..4f170cb990 100644 --- a/Packages/MIES/MIES_Utilities_WaveHandling.ipf +++ b/Packages/MIES/MIES_Utilities_WaveHandling.ipf @@ -1517,7 +1517,7 @@ Function ConcatenateWavesWithNoteIndex(WAVE/Z dest, WAVE/Z src) End /// @brief Returns true (1) if a wave has dimlabels in a given dimension -/// In the utmost cases if waves have dimension labels then already the first index has a label. +/// In most cases if waves have dimension labels then already the first index has a label. /// /// @param wv wave, can also be null wave /// @param dim dimension to check @@ -1535,6 +1535,7 @@ Function HasDimLabels(WAVE/Z wv, variable dim, [variable deep]) deep = ParamIsDefault(deep) ? 1 : deep ASSERT(IsInteger(deep) && deep > 0, "deep must be integer and greater than zero") ASSERT(IsInteger(dim) && dim >= ROWS && dim < MAX_DIMENSION_COUNT, "dim must be a valid dimension") + deep = min(deep, DimSize(wv, dim)) for(i = 0; i < deep; i += 1) if(!IsEmpty(GetDimLabel(wv, dim, i))) diff --git a/Packages/MIES/MIES_WaveDataFolderGetters.ipf b/Packages/MIES/MIES_WaveDataFolderGetters.ipf index 46348659e3..fb861b451c 100644 --- a/Packages/MIES/MIES_WaveDataFolderGetters.ipf +++ b/Packages/MIES/MIES_WaveDataFolderGetters.ipf @@ -9228,3 +9228,25 @@ Function/WAVE GetPlotGraphNames(variable numGraphs) return plotGraphs End + +/// @brief Wave storing sf plot meta information per formularesult, filled in SF_GatherFormulaResults +Function/WAVE GetSFPlotMetaData() + + Make/FREE/T/N=(5) wv + SetDimensionLabels(wv, "DATATYPE;OPSTACK;ARGSETUPSTACK;XAXISLABEL;YAXISLABEL;", ROWS) + + return wv +End + +/// @brief Returns a free wave that stores the data per graph that is split by "AND" in the formula +/// Rows: Entry per graph +/// Column 0: waveref to formula results (from GetFormulaGatherWave()) +/// Column 1: waveref to meta data for plot +Function/WAVE GetSFDataInGraph() + + Make/FREE/WAVE/N=(MINIMUM_WAVE_SIZE, 2) dataInGraph + SetDimLabel COLS, 0, DATA, dataInGraph + SetDimLabel COLS, 1, META, dataInGraph + + return dataInGraph +End diff --git a/Packages/tests/Basic/UTF_GuiUtilities.ipf b/Packages/tests/Basic/UTF_GuiUtilities.ipf index 3abb2e40da..e11c887772 100644 --- a/Packages/tests/Basic/UTF_GuiUtilities.ipf +++ b/Packages/tests/Basic/UTF_GuiUtilities.ipf @@ -458,3 +458,53 @@ static Function TestScrollListboxIntoView() End /// @} + +/// GetAllWindows +/// @{ + +Function TestGetAllWindows() + + string wList, nullArg, win, subWin + variable exist + + try + GetAllWindows(nullArg) + FAIL() + catch + ClearRTError() + PASS() + endtry + + wList = GetAllWindows("This window does not exist") + CHECK_EMPTY_STR(wList) + + Display + win = S_name + wList = GetAllWindows("") + exist = WhichListItem(win, wList) + CHECK_GE_VAR(exist, 0) + + NewPanel + win = S_name + DisPlay/HOST=# + subWin = win + "#" + S_name + wList = GetAllWindows("") + exist = WhichListItem(win, wList) + CHECK_GE_VAR(exist, 0) + exist = WhichListItem(subWin, wList) + CHECK_GE_VAR(exist, 0) + + wList = GetAllWindows(win) + exist = WhichListItem(win, wList) + CHECK_GE_VAR(exist, 0) + exist = WhichListItem(subWin, wList) + CHECK_GE_VAR(exist, 0) + + wList = GetAllWindows(subWin) + exist = WhichListItem(win, wList) + CHECK_EQUAL_VAR(exist, -1) + exist = WhichListItem(subWin, wList) + CHECK_GE_VAR(exist, 0) +End + +/// @}