Correctly write phase/gain signals to workbook.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18205
This commit is contained in:
Jeff Young 2024-06-14 15:40:17 +01:00
parent 5a3bad51d0
commit 300313ce73
1 changed files with 13 additions and 3 deletions

View File

@ -2171,10 +2171,20 @@ bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath )
auto findSignalName =
[&]( const wxString& aVectorName ) -> wxString
{
wxString vectorName;
wxString suffix;
if( aVectorName.EndsWith( _( " (phase)" ) ) )
suffix = _( " (phase)" );
else if( aVectorName.EndsWith( _( " (gain)" ) ) )
suffix = _( " (gain)" );
vectorName = aVectorName.Left( aVectorName.Length() - suffix.Length() );
for( const auto& [ id, signal ] : m_userDefinedSignals )
{
if( aVectorName == vectorNameFromSignalId( id ) )
return signal;
if( vectorName == vectorNameFromSignalId( id ) )
return signal + suffix;
}
return aVectorName;
@ -2184,7 +2194,7 @@ bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath )
{
nlohmann::json trace_js = nlohmann::json(
{ { "trace_type", (int) trace->GetType() },
{ "signal", findSignalName( trace->GetName() ) },
{ "signal", findSignalName( trace->GetDisplayName() ) },
{ "color", COLOR4D( trace->GetTraceColour() ).ToCSSString() } } );
if( CURSOR* cursor = trace->GetCursor( 1 ) )