Skip to content

Commit 96c8d42

Browse files
committed
SF: Add operation table
operation tags the output wave to hint the plotter that the data should be displayed in a table. The operation does not change the data otherwise. table(expression)
1 parent da2c7ec commit 96c8d42

File tree

6 files changed

+210
-1
lines changed

6 files changed

+210
-1
lines changed

Packages/MIES/MIES_Constants.ipf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,7 @@ StrConstant SF_OP_SELECTIVSCCSWEEPQC = "selivsccsweepqc"
25182518
StrConstant SF_OP_SELECTIVSCCSETQC = "selivsccsetqc"
25192519
StrConstant SF_OP_SELECTRANGE = "selrange"
25202520
StrConstant SF_OP_POWERSPECTRUM = "powerspectrum"
2521+
StrConstant SF_OP_TABLE = "table"
25212522
StrConstant SF_OP_TPSS = "tpss"
25222523
StrConstant SF_OP_TPINST = "tpinst"
25232524
StrConstant SF_OP_TPBASE = "tpbase"

Packages/MIES/MIES_SweepFormula.ipf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Function/WAVE SF_GetNamedOperations()
7474
SF_OP_MERGE, SF_OP_FIT, SF_OP_FITLINE, SF_OP_DATASET, SF_OP_SELECTVIS, SF_OP_SELECTCM, SF_OP_SELECTSTIMSET, \
7575
SF_OP_SELECTIVSCCSWEEPQC, SF_OP_SELECTIVSCCSETQC, SF_OP_SELECTRANGE, SF_OP_SELECTEXP, SF_OP_SELECTDEV, \
7676
SF_OP_SELECTEXPANDSCI, SF_OP_SELECTEXPANDRAC, SF_OP_SELECTSETCYCLECOUNT, SF_OP_SELECTSETSWEEPCOUNT, \
77-
SF_OP_SELECTSCIINDEX, SF_OP_SELECTRACINDEX, SF_OP_ANAFUNCPARAM, SF_OP_CONCAT}
77+
SF_OP_SELECTSCIINDEX, SF_OP_SELECTRACINDEX, SF_OP_ANAFUNCPARAM, SF_OP_CONCAT, SF_OP_TABLE}
7878

7979
return wt
8080
End

Packages/MIES/MIES_SweepFormula_Executor.ipf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ Function/WAVE SFE_FormulaExecutor(STRUCT SF_ExecutionData &exd, [variable srcLoc
511511
case SF_OP_SELECTRANGE:
512512
WAVE out = SFOS_OperationSelectRange(exdop)
513513
break
514+
case SF_OP_TABLE:
515+
WAVE out = SFO_OperationTable(exdop)
516+
break
514517
default:
515518
SFH_FATAL_ERROR("Undefined Operation", jsonId = exdop.jsonId)
516519
endswitch

Packages/MIES/MIES_SweepFormula_Operations.ipf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,3 +2420,18 @@ threadsafe static Function/WAVE SFO_SweepAverageHelper(WAVE/WAVE group)
24202420

24212421
return avgResult[0]
24222422
End
2423+
2424+
Function/WAVE SFO_OperationTable(STRUCT SF_ExecutionData &exd)
2425+
2426+
SFH_CheckArgumentCount(exd, SF_OP_TABLE, 1, maxArgs = 1)
2427+
2428+
WAVE/WAVE input = SF_ResolveDatasetFromJSON(exd, 0)
2429+
2430+
WAVE/WAVE output = SFH_CreateSFRefWave(exd.graph, SF_OP_TABLE, DimSize(input, ROWS))
2431+
2432+
output[] = input[p]
2433+
2434+
JWN_SetNumberInWaveNote(output, SF_PROPERTY_TABLE, 1)
2435+
2436+
return SFH_GetOutputForExecutor(output, exd.graph, SF_OP_TABLE)
2437+
End

Packages/tests/Basic/UTF_SweepFormula.ipf

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,162 @@ static Function TestPlotting()
957957
CHECK_EQUAL_WAVES(wvWin2Y0, wvY5)
958958
End
959959

960+
static Function TestPlottingWithTablesSubWindows()
961+
962+
string win, winBaseTable
963+
964+
string sweepBrowser = CreateFakeSweepBrowser_IGNORE()
965+
DFREF dfr = BSP_GetFolder(sweepBrowser, MIES_BSP_PANEL_FOLDER)
966+
string winBase = MIES_SF#SF_GetFormulaWinNameTemplate(sweepBrowser)
967+
968+
string strSimpleTable = "table(1)"
969+
string strSimpleTableWithTable = "table(1)\rwith\rtable(2)"
970+
string strSimpleTableWithPlot = "table(1)\rwith\r2"
971+
string strSimpleTableVsX = "table(1) vs 2"
972+
string strSimpleTableAndTable = "table(1)\rand\rtable(2)"
973+
string strSimpleTableAndPlot = "table(1)\rand\r2"
974+
string strSimpleTableDataset = "table(dataset(1,2))"
975+
976+
winBaseTable = winBase + "table"
977+
978+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTable)
979+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 1)
980+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table0"), 1)
981+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table1"), 0)
982+
CHECK_EQUAL_VAR(WindowExists(winBase), 0)
983+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 0, 3) // dimlabel column
984+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
985+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 1, 3) // data column
986+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
987+
WAVE/Z wv = WaveRefIndexed(winBaseTable + "#Table0", 2, 3)
988+
CHECK_WAVE(wv, NULL_WAVE)
989+
990+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableWithTable)
991+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 1)
992+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table0"), 1)
993+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table1"), 0)
994+
CHECK_EQUAL_VAR(WindowExists(winBase), 0)
995+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 0, 3) // dimlabel column first table
996+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
997+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 1, 3) // data column first table
998+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
999+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 2, 3) // dimlabel column second table
1000+
CHECK_EQUAL_WAVES(wv, {{2}}, mode = WAVE_DATA)
1001+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 3, 3) // data column second table
1002+
CHECK_EQUAL_WAVES(wv, {{2}}, mode = WAVE_DATA)
1003+
WAVE/Z wv = WaveRefIndexed(winBaseTable + "#Table0", 4, 3)
1004+
CHECK_WAVE(wv, NULL_WAVE)
1005+
1006+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableWithPlot)
1007+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 1)
1008+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table0"), 1)
1009+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table1"), 0)
1010+
CHECK_EQUAL_VAR(WindowExists(winBase), 1)
1011+
CHECK_EQUAL_VAR(WindowExists(winBase + "#Graph0"), 1)
1012+
CHECK_EQUAL_VAR(WindowExists(winBase + "#Graph1"), 0)
1013+
1014+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableVsX)
1015+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 1)
1016+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table0"), 1)
1017+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table1"), 0)
1018+
CHECK_EQUAL_VAR(WindowExists(winBase), 0)
1019+
1020+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableAndTable)
1021+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 1)
1022+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table0"), 1)
1023+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table1"), 1)
1024+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table2"), 0)
1025+
CHECK_EQUAL_VAR(WindowExists(winBase), 0)
1026+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 0, 3) // dimlabel column
1027+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
1028+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 1, 3) // data column
1029+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
1030+
WAVE/Z wv = WaveRefIndexed(winBaseTable + "#Table0", 2, 3)
1031+
CHECK_WAVE(wv, NULL_WAVE)
1032+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table1", 0, 3) // dimlabel column
1033+
CHECK_EQUAL_WAVES(wv, {{2}}, mode = WAVE_DATA)
1034+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table1", 1, 3) // data column
1035+
CHECK_EQUAL_WAVES(wv, {{2}}, mode = WAVE_DATA)
1036+
WAVE/Z wv = WaveRefIndexed(winBaseTable + "#Table1", 2, 3)
1037+
CHECK_WAVE(wv, NULL_WAVE)
1038+
1039+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableAndPlot)
1040+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 1)
1041+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table0"), 1)
1042+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "#Table1"), 0)
1043+
CHECK_EQUAL_VAR(WindowExists(winBase), 1)
1044+
CHECK_EQUAL_VAR(WindowExists(winBase + "#Graph0"), 0)
1045+
CHECK_EQUAL_VAR(WindowExists(winBase + "#Graph1"), 1)
1046+
CHECK_EQUAL_VAR(WindowExists(winBase + "#Graph2"), 0)
1047+
1048+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableDataset)
1049+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 0, 3) // dimlabel column
1050+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
1051+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 1, 3) // data column
1052+
CHECK_EQUAL_WAVES(wv, {{1}}, mode = WAVE_DATA)
1053+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 2, 3) // dimlabel column
1054+
CHECK_EQUAL_WAVES(wv, {{2}}, mode = WAVE_DATA)
1055+
WAVE wv = WaveRefIndexed(winBaseTable + "#Table0", 3, 3) // data column
1056+
CHECK_EQUAL_WAVES(wv, {{2}}, mode = WAVE_DATA)
1057+
WAVE/Z wv = WaveRefIndexed(winBaseTable + "#Table0", 4, 3)
1058+
CHECK_WAVE(wv, NULL_WAVE)
1059+
End
1060+
1061+
static Function TestPlottingWithTablesNormal()
1062+
1063+
string win, winBaseTable
1064+
1065+
string sweepBrowser = CreateFakeSweepBrowser_IGNORE()
1066+
DFREF dfr = BSP_GetFolder(sweepBrowser, MIES_BSP_PANEL_FOLDER)
1067+
string winBase = MIES_SF#SF_GetFormulaWinNameTemplate(sweepBrowser)
1068+
1069+
string strSimpleTable = "table(1)"
1070+
string strSimpleTableWithTable = "table(1)\rwith\rtable(2)"
1071+
string strSimpleTableWithPlot = "table(1)\rwith\r2"
1072+
string strSimpleTableVsX = "table(1) vs 2"
1073+
string strSimpleTableAndTable = "table(1)\rand\rtable(2)"
1074+
string strSimpleTableAndPlot = "table(1)\rand\r2"
1075+
1076+
winBaseTable = winBase + "table"
1077+
1078+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTable, dmMode = SF_DM_NORMAL)
1079+
CHECK_EQUAL_VAR(WindowExists(winBaseTable), 0)
1080+
CHECK_EQUAL_VAR(WindowExists(winBase), 0)
1081+
1082+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "0"), 1)
1083+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "1"), 0)
1084+
CHECK_EQUAL_VAR(WindowExists(winBase + "0"), 0)
1085+
1086+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableWithTable, dmMode = SF_DM_NORMAL)
1087+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "0"), 1)
1088+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "1"), 0)
1089+
CHECK_EQUAL_VAR(WindowExists(winBase + "0"), 0)
1090+
1091+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableWithPlot, dmMode = SF_DM_NORMAL)
1092+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "0"), 1)
1093+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "1"), 0)
1094+
CHECK_EQUAL_VAR(WindowExists(winBase + "0"), 1)
1095+
CHECK_EQUAL_VAR(WindowExists(winBase + "1"), 0)
1096+
1097+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableVsX, dmMode = SF_DM_NORMAL)
1098+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "0"), 1)
1099+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "1"), 0)
1100+
CHECK_EQUAL_VAR(WindowExists(winBase + "1"), 0)
1101+
1102+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableAndTable, dmMode = SF_DM_NORMAL)
1103+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "0"), 1)
1104+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "1"), 1)
1105+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "2"), 0)
1106+
CHECK_EQUAL_VAR(WindowExists(winBase + "0"), 0)
1107+
1108+
MIES_SF#SF_FormulaPlotter(sweepBrowser, strSimpleTableAndPlot, dmMode = SF_DM_NORMAL)
1109+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "0"), 1)
1110+
CHECK_EQUAL_VAR(WindowExists(winBaseTable + "1"), 0)
1111+
CHECK_EQUAL_VAR(WindowExists(winBase + "0"), 0)
1112+
CHECK_EQUAL_VAR(WindowExists(winBase + "1"), 1)
1113+
CHECK_EQUAL_VAR(WindowExists(winBase + "2"), 0)
1114+
End
1115+
9601116
static Function TestSFPreprocessor()
9611117

9621118
string input, output

Packages/tests/Basic/UTF_SweepFormula_Operations.ipf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,3 +3537,37 @@ static Function TestOperationAnaFuncParam()
35373537
idx += 1
35383538
endfor
35393539
End
3540+
3541+
static Function TestOperationTable()
3542+
3543+
string str, win
3544+
variable val
3545+
3546+
win = GetDataBrowserWithData()
3547+
3548+
str = "table()"
3549+
try
3550+
WAVE output = SFE_ExecuteFormula(str, win, useVariables = 0)
3551+
FAIL()
3552+
catch
3553+
PASS()
3554+
endtry
3555+
3556+
str = "table(1,1)"
3557+
try
3558+
WAVE output = SFE_ExecuteFormula(str, win, useVariables = 0)
3559+
FAIL()
3560+
catch
3561+
PASS()
3562+
endtry
3563+
3564+
str = "table(1)"
3565+
WAVE/WAVE output = SFE_ExecuteFormula(str, win, useVariables = 0)
3566+
val = JWN_GetNumberFromWaveNote(output, SF_PROPERTY_TABLE)
3567+
CHECK_EQUAL_VAR(val, 1)
3568+
3569+
str = "table(dataset(1,2))"
3570+
WAVE/WAVE output = SFE_ExecuteFormula(str, win, useVariables = 0)
3571+
val = JWN_GetNumberFromWaveNote(output, SF_PROPERTY_TABLE)
3572+
CHECK_EQUAL_VAR(val, 1)
3573+
End

0 commit comments

Comments
 (0)