@@ -544,14 +544,73 @@ static Function/S SF_ShrinkLegend(string annotation)
544544 return shrunkAnnotation
545545End
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+
547604static 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
789831End
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)
0 commit comments