Skip to content

Commit 8c00e84

Browse files
committed
SF: Add tests for full plotting specification plotter support
The test defines a testop() that creates a specific full plotting specification. Then the operation is positioned in the outer SF code connected with AND and WITH before and after to the surrounding code. Also meta data transfer from the dataset and data wave is checked through SF_META_YAXISLABEL and SF_META_LEGEND_LINE_PREFIX
1 parent 72002d8 commit 8c00e84

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed

Packages/tests/Basic/UTF_SweepFormula.ipf

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,3 +2692,175 @@ static Function TestSourceLocationContent([WAVE/WAVE wv])
26922692
Redimension/N=(size, -1) srcLocs
26932693
CHECK_EQUAL_WAVES(srcLocs, wSrcLocs, mode = WAVE_DATA)
26942694
End
2695+
2696+
Function/WAVE TestFullPlottingOp(STRUCT SF_ExecutionData &exd)
2697+
2698+
string opShort = SF_OP_TESTOP
2699+
string formula
2700+
2701+
formula = "var = 1"
2702+
2703+
WAVE/WAVE varStorage = GetSFVarStorage(exd.graph)
2704+
Duplicate/FREE varStorage, varBackup
2705+
SFE_ExecuteVariableAssignments(exd.graph, formula, allowEmptyCode = 1)
2706+
2707+
WAVE/WAVE plotAND = GetFullPlottingAND(exd.graph, opShort, 2)
2708+
// build the following construct for the full plot specification, $var is created independently in the code above beforehand
2709+
// $var vs 2
2710+
// with
2711+
// 3 vs 4
2712+
// and
2713+
// 5 vs 6
2714+
// with
2715+
// 7 vs 8
2716+
2717+
WAVE/WAVE plotWITH = GetFullPlottingWITH(2)
2718+
formula = "$var"
2719+
WAVE/WAVE wvY = SFH_ExecuteFormulaInternal(exd.graph, formula)
2720+
JWN_SetStringInWaveNote(wvY[0], SF_META_LEGEND_LINE_PREFIX, "legend")
2721+
JWN_SetStringInWaveNote(wvY, SF_META_YAXISLABEL, "yaxislabel")
2722+
plotWITH[0][%FORMULAY] = wvY
2723+
formula = "2"
2724+
WAVE/WAVE wvX = SFH_ExecuteFormulaInternal(exd.graph, formula)
2725+
plotWITH[0][%FORMULAX] = wvX
2726+
2727+
formula = "3"
2728+
WAVE/WAVE wvY = SFH_ExecuteFormulaInternal(exd.graph, formula)
2729+
plotWITH[1][%FORMULAY] = wvY
2730+
formula = "4"
2731+
WAVE/WAVE wvX = SFH_ExecuteFormulaInternal(exd.graph, formula)
2732+
plotWITH[1][%FORMULAX] = wvX
2733+
2734+
plotAND[0] = plotWITH
2735+
2736+
WAVE/WAVE plotWITH = GetFullPlottingWITH(2)
2737+
formula = "5"
2738+
WAVE/WAVE wvY = SFH_ExecuteFormulaInternal(exd.graph, formula)
2739+
plotWITH[0][%FORMULAY] = wvY
2740+
formula = "6"
2741+
WAVE/WAVE wvX = SFH_ExecuteFormulaInternal(exd.graph, formula)
2742+
plotWITH[0][%FORMULAX] = wvX
2743+
2744+
formula = "7"
2745+
WAVE/WAVE wvY = SFH_ExecuteFormulaInternal(exd.graph, formula)
2746+
plotWITH[1][%FORMULAY] = wvY
2747+
formula = "8"
2748+
WAVE/WAVE wvX = SFH_ExecuteFormulaInternal(exd.graph, formula)
2749+
plotWITH[1][%FORMULAX] = wvX
2750+
2751+
plotAND[1] = plotWITH
2752+
2753+
Duplicate/O varBackup, varStorage
2754+
2755+
return SFH_GetOutputForExecutor(plotAND, exd.graph, opShort)
2756+
End
2757+
2758+
static Function TestFullPlottingSpecificationCheckTrace(string win, variable traceIndex, variable yRef, variable xRef)
2759+
2760+
string traces = TraceNameList(win, ";", 0x1)
2761+
WAVE wvY = TraceNameToWaveRef(win, StringFromList(traceIndex, traces))
2762+
WAVE wvX = XWaveRefFromTrace(win, StringFromList(traceIndex, traces))
2763+
Make/FREE/D wvRef = {{yRef}}
2764+
CHECK_EQUAL_WAVES(wvY, wvRef, mode = WAVE_DATA)
2765+
wvRef[] = xRef
2766+
CHECK_EQUAL_WAVES(wvX, wvRef, mode = WAVE_DATA)
2767+
End
2768+
2769+
static Function TestFullPlottingSpecification()
2770+
2771+
string win, traces, lbl, annoText
2772+
string graph, winResultBase
2773+
2774+
graph = CreateFakeSweepBrowser_IGNORE()
2775+
DFREF dfr = BSP_GetFolder(graph, MIES_BSP_PANEL_FOLDER)
2776+
winResultBase = BSP_GetFormulaGraph(graph)
2777+
2778+
SVAR funcName = $GetSFTestopName(graph)
2779+
funcName = "TestFullPlottingOp"
2780+
2781+
MIES_SF#SF_FormulaPlotter(graph, "testop()")
2782+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "0"
2783+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2784+
traces = TraceNameList(win, ";", 0x1)
2785+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2786+
TestFullPlottingSpecificationCheckTrace(win, 0, 1, 2)
2787+
TestFullPlottingSpecificationCheckTrace(win, 1, 3, 4)
2788+
lbl = AxisLabel(win, "left")
2789+
CHECK_EQUAL_STR(lbl, "yaxislabel")
2790+
annoText = StringByKey("TEXT", AnnotationInfo(win, SF_ANNOTATION_NAME))
2791+
CHECK_GT_VAR(strsearch(annoText, " legend", 0), 0)
2792+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "1"
2793+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2794+
traces = TraceNameList(win, ";", 0x1)
2795+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2796+
TestFullPlottingSpecificationCheckTrace(win, 0, 5, 6)
2797+
TestFullPlottingSpecificationCheckTrace(win, 1, 7, 8)
2798+
2799+
MIES_SF#SF_FormulaPlotter(graph, "9 vs 9\rand\rtestop()")
2800+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "0"
2801+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2802+
traces = TraceNameList(win, ";", 0x1)
2803+
CHECK_EQUAL_VAR(ItemsInList(traces), 1)
2804+
TestFullPlottingSpecificationCheckTrace(win, 0, 9, 9)
2805+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "1"
2806+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2807+
traces = TraceNameList(win, ";", 0x1)
2808+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2809+
TestFullPlottingSpecificationCheckTrace(win, 0, 1, 2)
2810+
TestFullPlottingSpecificationCheckTrace(win, 1, 3, 4)
2811+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "2"
2812+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2813+
traces = TraceNameList(win, ";", 0x1)
2814+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2815+
TestFullPlottingSpecificationCheckTrace(win, 0, 5, 6)
2816+
TestFullPlottingSpecificationCheckTrace(win, 1, 7, 8)
2817+
2818+
MIES_SF#SF_FormulaPlotter(graph, "9 vs 9\rwith\rtestop()")
2819+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "0"
2820+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2821+
traces = TraceNameList(win, ";", 0x1)
2822+
CHECK_EQUAL_VAR(ItemsInList(traces), 3)
2823+
TestFullPlottingSpecificationCheckTrace(win, 0, 9, 9)
2824+
TestFullPlottingSpecificationCheckTrace(win, 1, 1, 2)
2825+
TestFullPlottingSpecificationCheckTrace(win, 2, 3, 4)
2826+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "1"
2827+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2828+
traces = TraceNameList(win, ";", 0x1)
2829+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2830+
TestFullPlottingSpecificationCheckTrace(win, 0, 5, 6)
2831+
TestFullPlottingSpecificationCheckTrace(win, 1, 7, 8)
2832+
2833+
MIES_SF#SF_FormulaPlotter(graph, "testop()\rand\r9 vs 9")
2834+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "0"
2835+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2836+
traces = TraceNameList(win, ";", 0x1)
2837+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2838+
TestFullPlottingSpecificationCheckTrace(win, 0, 1, 2)
2839+
TestFullPlottingSpecificationCheckTrace(win, 1, 3, 4)
2840+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "1"
2841+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2842+
traces = TraceNameList(win, ";", 0x1)
2843+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2844+
TestFullPlottingSpecificationCheckTrace(win, 0, 5, 6)
2845+
TestFullPlottingSpecificationCheckTrace(win, 1, 7, 8)
2846+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "2"
2847+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2848+
traces = TraceNameList(win, ";", 0x1)
2849+
CHECK_EQUAL_VAR(ItemsInList(traces), 1)
2850+
TestFullPlottingSpecificationCheckTrace(win, 0, 9, 9)
2851+
2852+
MIES_SF#SF_FormulaPlotter(graph, "testop()\rwith\r9 vs 9")
2853+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "0"
2854+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2855+
traces = TraceNameList(win, ";", 0x1)
2856+
CHECK_EQUAL_VAR(ItemsInList(traces), 2)
2857+
TestFullPlottingSpecificationCheckTrace(win, 0, 1, 2)
2858+
TestFullPlottingSpecificationCheckTrace(win, 1, 3, 4)
2859+
win = winResultBase + "_" + SF_WINNAME_SUFFIX_GRAPH + "#" + SF_WINNAME_SUFFIX_GRAPH + "1"
2860+
REQUIRE_EQUAL_VAR(WindowExists(win), 1)
2861+
traces = TraceNameList(win, ";", 0x1)
2862+
CHECK_EQUAL_VAR(ItemsInList(traces), 3)
2863+
TestFullPlottingSpecificationCheckTrace(win, 0, 5, 6)
2864+
TestFullPlottingSpecificationCheckTrace(win, 1, 7, 8)
2865+
TestFullPlottingSpecificationCheckTrace(win, 2, 9, 9)
2866+
End

0 commit comments

Comments
 (0)