Skip to content

Commit d2e881b

Browse files
committed
SF: Add tooltip information to table display
The tooltip displays a selection of properties of the data when available The properties can be set in SF_GetTableTooltipProperties The tooltip function attempts automatically to read it as string or number.
1 parent 96c8d42 commit d2e881b

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

Packages/MIES/MIES_Constants.ipf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,7 @@ StrConstant SF_META_TRACE_MODE = "/TraceMode" // number, one of @
21242124
StrConstant SF_META_TRACETOFRONT = "/TraceToFront" // number, boolean, defaults to false (0)
21252125
StrConstant SF_META_DONOTPLOT = "/DoNotPlot" // number, boolean, defaults to false (0)
21262126
StrConstant SF_META_WINDOW_HOOK = "/WindowHook" // string
2127+
StrConstant SF_META_FORMULA = "/Formula" // string
21272128

21282129
/// A color group allows to have matching colors for sweep data with the same channel type/number and sweep.
21292130
/// It is applied before the matching headstage/average colors in #SF_GetTraceColor().

Packages/MIES/MIES_SweepFormula.ipf

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ static Function [WAVE/WAVE formulaResults, STRUCT SF_PlotMetaData plotMetaData]
201201
endif
202202

203203
formulaResults[i][%FORMULAY] = wvYdata
204+
JWN_SetStringInWaveNote(wvYdata, SF_META_FORMULA, yFormula)
204205
endif
205206
endfor
206207

@@ -594,6 +595,7 @@ static Function/S SF_NewSweepFormulaBaseWindow(string templateName, string graph
594595
NewPanel/N=$win/K=1/W=(150, 400, 1000, 700)
595596
elseif(winType == WINTYPE_TABLE)
596597
Edit/N=$win/K=1/W=(150, 400, 1000, 700)
598+
SetWindow $S_name, tooltipHook(sfTableTooltip)=SF_TableTooltipHook
597599
else
598600
FATAL_ERROR("Unsupported window type")
599601
endif
@@ -608,7 +610,7 @@ End
608610
static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string winNameTemplate, string graph, variable winDisplayMode, variable numGraphs)
609611

610612
variable i, guidePos, restoreCursorInfo
611-
string panelName, guideName1, guideName2, win, winTable, winNameTemplateTable
613+
string panelName, guideName1, guideName2, win, winTable, winNameTemplateTable, subWinName
612614

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

@@ -679,6 +681,8 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi
679681
Display/HOST=$win/FG=(customLeft, $guideName1, customRight, $guideName2)/N=$("Graph" + num2str(i))
680682
plotGraphs[i][%GRAPH] = win + "#" + S_name
681683
Edit/HOST=$winTable/FG=(customLeft, $guideName1, customRight, $guideName2)/N=$("Table" + num2str(i))
684+
subWinName = winTable + "#" + S_name
685+
SetWindow $subWinName, tooltipHook(sfTableTooltip)=SF_TableTooltipHook
682686
plotGraphs[i][%TABLE] = winTable + "#" + S_name
683687
endfor
684688
endif
@@ -2384,3 +2388,50 @@ static Function SF_MarkErrorLocationInNotebook(string win)
23842388
offset = str2num(varAssignments[V_row][%OFFSET])
23852389
Notebook $sfWin, selection={(paragraph, 0), (paragraph, offset - 1)}, textRGB=(65535, 0, 0)
23862390
End
2391+
2392+
/// @brief This function returns a list of JSON properties that are intended to be shown
2393+
/// in the tooltip for table display, when present
2394+
/// This allows to separate meta data for the user from internal meta information like plotting hints
2395+
static Function/WAVE SF_GetTableTooltipProperties()
2396+
2397+
Make/FREE/T wv = {SF_META_FORMULA, SF_META_EXPERIMENT, SF_META_DEVICE, SF_META_SWEEPNO, SF_META_CHANNELTYPE, SF_META_CHANNELNUMBER}
2398+
2399+
return wv
2400+
End
2401+
2402+
Function SF_TableTooltipHook(STRUCT WMTooltipHookStruct &s)
2403+
2404+
variable hookResult, val
2405+
string str, prop, key
2406+
2407+
if(WaveExists(s.yWave))
2408+
hookResult = 1
2409+
s.tooltip = ""
2410+
2411+
WAVE/T props = SF_GetTableTooltipProperties()
2412+
for(prop : props)
2413+
key = prop[1, Inf]
2414+
str = JWN_GetStringFromWaveNote(s.yWave, prop)
2415+
if(!IsEmpty(str))
2416+
str = ReplaceString("\r", str, "")
2417+
s.tooltip += "<b>" + key + ": </b>" + str + "<br>"
2418+
continue
2419+
endif
2420+
val = JWN_GetNumberFromWaveNote(s.yWave, prop)
2421+
if(IsNaN(val))
2422+
continue
2423+
endif
2424+
if(!CmpStr(prop, SF_META_CHANNELTYPE))
2425+
str = ChannelTypeToString(val)
2426+
s.tooltip += "<b>" + key + ": </b>" + str + "<br>"
2427+
continue
2428+
endif
2429+
s.tooltip += "<b>" + key + ": </b>" + num2str(val) + "<br>"
2430+
endfor
2431+
s.tooltip = RemoveEnding(s.tooltip, "<br>")
2432+
s.isHtml = 1
2433+
s.duration_ms = 600000
2434+
endif
2435+
2436+
return hookResult
2437+
End

0 commit comments

Comments
 (0)