Skip to content

Commit 90e95b9

Browse files
committed
changes
1 parent 878fb45 commit 90e95b9

File tree

5 files changed

+136
-47
lines changed

5 files changed

+136
-47
lines changed

Packages/MIES/MIES_Constants.ipf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,8 @@ StrConstant SF_OP_TPBASE = "tpbase"
25252525
StrConstant SF_OP_TPFIT = "tpfit"
25262526
///@}
25272527

2528+
StrConstant SF_PROPERTY_TABLE = "Table"
2529+
25282530
/// @name SF operations shorts
25292531
///
25302532
/// @anchor SFOperationsShorts

Packages/MIES/MIES_SweepFormula.ipf

Lines changed: 109 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,73 @@ static Function/S SF_ShrinkLegend(string annotation)
544544
return shrunkAnnotation
545545
End
546546

547+
static Function SF_ClearPlotPanel(string win)
548+
549+
string subWindow
550+
variable wType
551+
552+
TUD_Clear(win, recursive = 1)
553+
554+
WAVE/T allWindows = ListToTextWave(GetAllWindows(win), ";")
555+
556+
for(subWindow : allWindows)
557+
if(IsSubwindow(subWindow))
558+
// in complex hierarchies we might kill more outer subwindows first
559+
// so the inner ones might later not exist anymore
560+
KillWindow/Z $subWindow
561+
endif
562+
endfor
563+
564+
RemoveAllControls(win)
565+
wType = WinType(win)
566+
if(wType == WINTYPE_PANEL || wType == WINTYPE_GRAPH)
567+
RemoveAllDrawLayers(win)
568+
endif
569+
End
570+
571+
/// @brief Creates a new panel for sweepformula display of graph or table and returns the actual window name
572+
///
573+
/// @param[in] templateName base name of new window
574+
/// @param[in] graph name of sweepbrowser/databrowser window
575+
/// @param[in] winType [optional, default WINTYPE_PANEL] specifies window type
576+
/// @returns name of created window
577+
static Function/S SF_NewSweepFormulaBaseWindow(string templateName, string graph, [variable winType])
578+
579+
string win
580+
581+
winType = ParamIsDefault(winType) ? WINTYPE_PANEL : winType
582+
583+
win = templateName
584+
if(WindowExists(win))
585+
SF_ClearPlotPanel(win)
586+
else
587+
if(winType == WINTYPE_GRAPH)
588+
Display/N=$win/K=1/W=(150, 400, 1000, 700)
589+
elseif(winType == WINTYPE_PANEL)
590+
NewPanel/N=$win/K=1/W=(150, 400, 1000, 700)
591+
elseif(winType == WINTYPE_TABLE)
592+
Edit/N=$win/K=1/W=(150, 400, 1000, 700)
593+
else
594+
FATAL_ERROR("Unsupported window type")
595+
endif
596+
win = S_name
597+
598+
SF_CommonWindowSetup(win, graph)
599+
endif
600+
601+
return win
602+
End
603+
547604
static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string winNameTemplate, string graph, variable winDisplayMode, variable numGraphs)
548605

549606
variable i, guidePos, restoreCursorInfo
550-
string panelName, guideName1, guideName2, win
607+
string panelName, guideName1, guideName2, win, winTable, winNameTemplateTable
551608

552609
ASSERT(numGraphs > 0, "Can not prepare plotter window for zero graphs")
553610

554-
Make/FREE/T/N=(numGraphs) plotGraphs
611+
winNameTemplateTable = winNameTemplate + "table"
612+
613+
WAVE/T plotGraphs = GetPlotGraphNames(numGraphs)
555614
Make/FREE/WAVE/N=(numGraphs, 3) infos
556615
SetDimensionLabels(infos, "axes;cursors;annotations", COLS)
557616

@@ -580,41 +639,15 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi
580639

581640
if(winDisplayMode == SF_DM_NORMAL)
582641
for(i = 0; i < numGraphs; i += 1)
583-
win = winNameTemplate + num2istr(i)
584-
585-
if(!WindowExists(win))
586-
Display/N=$win/K=1/W=(150, 400, 1000, 700) as win
587-
win = S_name
588-
endif
589-
590-
SF_CommonWindowSetup(win, graph)
591-
592-
plotGraphs[i] = win
642+
win = winNameTemplate + num2istr(i)
643+
plotGraphs[i][%GRAPH] = SF_NewSweepFormulaBaseWindow(win, graph, winType = WINTYPE_GRAPH)
644+
win = winNameTemplateTable + num2istr(i)
645+
plotGraphs[i][%TABLE] = SF_NewSweepFormulaBaseWindow(win, graph, winType = WINTYPE_TABLE)
593646
endfor
594647
elseif(winDisplayMode == SF_DM_SUBWINDOWS)
595648

596-
win = winNameTemplate
597-
if(WindowExists(win))
598-
TUD_Clear(win, recursive = 1)
599-
600-
WAVE/T allWindows = ListToTextWave(GetAllWindows(win), ";")
601-
602-
for(subWindow : allWindows)
603-
if(IsSubwindow(subWindow))
604-
// in complex hierarchies we might kill more outer subwindows first
605-
// so the inner ones might later not exist anymore
606-
KillWindow/Z $subWindow
607-
endif
608-
endfor
609-
610-
RemoveAllControls(win)
611-
RemoveAllDrawLayers(win)
612-
else
613-
NewPanel/N=$win/K=1/W=(150, 400, 1000, 700)
614-
win = S_name
615-
616-
SF_CommonWindowSetup(win, graph)
617-
endif
649+
win = SF_NewSweepFormulaBaseWindow(winNameTemplate, graph)
650+
winTable = SF_NewSweepFormulaBaseWindow(winNameTemplateTable, graph)
618651

619652
// now we have an open panel without any subwindows
620653

@@ -627,23 +660,32 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi
627660
guideName1 = SF_PLOTTER_GUIDENAME + num2istr(i)
628661
guidePos = i / numGraphs
629662
DefineGuide/W=$win $guideName1={FT, guidePos, FB}
663+
DefineGuide/W=$winTable $guideName1={FT, guidePos, FB}
630664
endfor
631665

632666
DefineGuide/W=$win customLeft={FL, 0.0, FR}
633667
DefineGuide/W=$win customRight={FL, 1.0, FR}
668+
DefineGuide/W=$winTable customLeft={FL, 0.0, FR}
669+
DefineGuide/W=$winTable customRight={FL, 1.0, FR}
634670

635671
// and now the subwindow graphs
636672
for(i = 0; i < numGraphs; i += 1)
637673
guideName1 = SF_PLOTTER_GUIDENAME + num2istr(i)
638674
guideName2 = SF_PLOTTER_GUIDENAME + num2istr(i + 1)
639675
Display/HOST=$win/FG=(customLeft, $guideName1, customRight, $guideName2)/N=$("Graph" + num2str(i))
640-
plotGraphs[i] = winNameTemplate + "#" + S_name
676+
plotGraphs[i][%GRAPH] = win + "#" + S_name
677+
Edit/HOST=$winTable/FG=(customLeft, $guideName1, customRight, $guideName2)/N=$("Table" + num2str(i))
678+
plotGraphs[i][%TABLE] = winTable + "#" + S_name
641679
endfor
642680
endif
643681

644-
for(win : plotGraphs)
682+
for(i = 0; i < numGraphs; i += 1)
683+
win = plotGraphs[i][%GRAPH]
645684
RemoveTracesFromGraph(win)
646685
ModifyGraph/W=$win swapXY=0
686+
687+
win = plotGraphs[i][%TABLE]
688+
RemoveAllColumnsFromTable(win)
647689
endfor
648690

649691
return [plotGraphs, infos]
@@ -788,6 +830,15 @@ static Function/WAVE SF_PrepareResultWaveForPlotting(DFREF dfr, WAVE wvResult, v
788830
return plotWave
789831
End
790832

833+
static Function SF_IsDataForTableDisplay(WAVE wvY)
834+
835+
variable useTable
836+
837+
useTable = JWN_GetNumberFromWaveNote(wvY, SF_PROPERTY_TABLE)
838+
839+
return IsNaN(useTable) ? 0 : !!useTable
840+
End
841+
791842
/// @brief Plot the formula using the data from graph
792843
///
793844
/// @param graph graph to pass to SF_FormulaExecutor
@@ -801,7 +852,8 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
801852
variable winDisplayMode, showLegend, tagCounter, overrideMarker, line, lineGraph, lineGraphFormula
802853
variable xMxN, yMxN, xPoints, yPoints, keepUserSelection, numAnnotations, formulasAreDifferent, postPlotPSX
803854
variable formulaCounter, gdIndex, markerCode, lineCode, lineStyle, traceToFront, isCategoryAxis, xFormulaOffset
804-
string win, wList, winNameTemplate, exWList, wName, annotation, xAxisLabel, yAxisLabel, wvName, info, xAxis
855+
variable showInTable
856+
string win, winTable, wList, winNameTemplate, exWList, wName, annotation, xAxisLabel, yAxisLabel, wvName, info, xAxis
805857
string formulasRemain, moreFormulas, yAndXFormula, xFormula, yFormula, tagText, name, winHook
806858
STRUCT SF_PlotMetaData plotMetaData
807859
STRUCT RGBColor color
@@ -838,8 +890,12 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
838890
formulasRemain = graphCode[j][%GRAPHCODE]
839891
lineGraph = str2num(graphCode[j][%LINE])
840892

841-
win = plotGraphs[j]
842-
wList = AddListItem(win, wList)
893+
win = plotGraphs[j][%GRAPH]
894+
winTable = plotGraphs[j][%TABLE]
895+
if(winDisplayMode == SF_DM_NORMAL)
896+
wList = AddListItem(win, wList)
897+
wList = AddListItem(winTable, wList)
898+
endif
843899

844900
Make/FREE=1/T/N=(MINIMUM_WAVE_SIZE) wAnnotations, formulaArgSetup
845901
Make/FREE=1/WAVE/N=(MINIMUM_WAVE_SIZE) collPlotFormData
@@ -886,6 +942,14 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
886942
WAVE/ZZ previousColorGroups
887943
endif
888944
WAVE/Z colorGroups = SF_GetColorGroups(formulaResults, previousColorGroups)
945+
showInTable = SF_IsDataForTableDisplay(formulaResults)
946+
if(winDisplaymode == SF_DM_NORMAL)
947+
if(showIntable)
948+
KillWindow/Z $win
949+
else
950+
KillWindow/Z $winTable
951+
endif
952+
endif
889953

890954
numData = DimSize(formulaResults, ROWS)
891955
for(k = 0; k < numData; k += 1)
@@ -924,6 +988,12 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
924988

925989
SFH_ASSERT(!(IsTextWave(wvY) && (WaveExists(wvX) && IsTextWave(wvX))), "One wave needs to be numeric for plotting")
926990

991+
if(showIntable)
992+
AppendToTable/W=$winTable wvY.d
993+
dataCnt += 1
994+
continue
995+
endif
996+
927997
if(IsTextWave(wvY))
928998
SFH_ASSERT(WaveExists(wvX), "Cannot plot a single text wave")
929999
ModifyGraph/W=$win swapXY=1
@@ -932,13 +1002,6 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
9321002
WAVE wvX = dummy
9331003
endif
9341004

935-
variable useTable = !!JWN_GetNumberFromWaveNote(wvY, "Table")
936-
937-
if(useTable)
938-
Edit/HOST=$win/FG=(FL, FT, FR, FB) wvY.d
939-
continue
940-
endif
941-
9421005
if(!WaveExists(wvX))
9431006
numTraces = yMxN
9441007
SF_CheckNumTraces(graph, numTraces)

Packages/MIES/MIES_SweepFormula_Operations.ipf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ Function/WAVE SFO_OperationTable(STRUCT SF_ExecutionData &exd)
24312431

24322432
output[] = input[p]
24332433

2434-
JWN_SetNumberInWaveNote(input, "Table", 1)
2434+
JWN_SetNumberInWaveNote(output, SF_PROPERTY_TABLE, 1)
24352435

24362436
return SFH_GetOutputForExecutor(output, exd.graph, SF_OP_TABLE)
24372437
End

Packages/MIES/MIES_Utilities_GUI.ipf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,20 @@ Function RemoveTracesFromGraph(string graph, [string trace, WAVE/Z wv, DFREF dfr
661661
return NaN
662662
End
663663

664+
/// @brief Removes all wave columns from a table
665+
Function RemoveAllColumnsFromTable(string win)
666+
667+
variable i
668+
669+
for(i = 0;; i += 1)
670+
WAVE/Z wv = WaveRefIndexed(win, i, 3)
671+
if(!WaveExists(wv))
672+
break
673+
endif
674+
RemoveFromTable/W=$win wv
675+
endfor
676+
End
677+
664678
/// @brief Add user data "panelVersion" to the panel
665679
Function AddVersionToPanel(string win, variable version)
666680

Packages/MIES/MIES_WaveDataFolderGetters.ipf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9213,3 +9213,13 @@ Function/WAVE GetSFAssertData()
92139213

92149214
return wv
92159215
End
9216+
9217+
/// @brief Used for preparing graph and table window names for the SF plotter
9218+
Function/WAVE GetPlotGraphNames(variable numGraphs)
9219+
9220+
Make/FREE/T/N=(numGraphs, 2) plotGraphs
9221+
SetDimlabel COLS, 0, GRAPH, plotGraphs
9222+
SetDimlabel COLS, 1, TABLE, plotGraphs
9223+
9224+
return plotGraphs
9225+
End

0 commit comments

Comments
 (0)