39                                           const wxString& aSignalName, 
const wxString& aParams )
 
   42            [&]( 
int aCursorId, 
double x )
 
   46                cursor->SetName( aSignalName );
 
   53    wxArrayString items = wxSplit( aParams, 
'|' );
 
   55    for( 
const wxString& item : items )
 
   57        if( item.StartsWith( wxS( 
"rgb" ) ) )
 
   64        else if( item.StartsWith( wxS( 
"cursor1" ) ) )
 
   66            wxArrayString parts = wxSplit( item, 
':' );
 
   69            if( parts.size() == 3 )
 
   71                parts[0].AfterFirst( 
'=' ).ToDouble( &val );
 
   77        else if( item.StartsWith( wxS( 
"cursor2" ) ) )
 
   79            wxArrayString parts = wxSplit( item, 
':' );
 
   82            if( parts.size() == 3 )
 
   84                parts[0].AfterFirst( 
'=' ).ToDouble( &val );
 
   90        else if( item.StartsWith( wxS( 
"cursorD" ) ) )
 
   92            wxArrayString parts = wxSplit( item, 
':' );
 
   94            if( parts.size() == 3 )
 
  100        else if( item == wxS( 
"dottedSecondary" ) )
 
  104        else if( item == wxS( 
"hideGrid" ) )
 
 
  114    wxTextFile file( aPath );
 
  116#define EXPECTING( msg )                                                                          \ 
  117        DisplayErrorMessage( this, wxString::Format( _( "Error loading workbook: line %d: %s." ), \ 
  118                                                     file.GetCurrentLine()+1,                     \ 
  125    wxString firstLine = file.GetFirstLine();
 
  126    wxString pageCountLine;
 
  128    if( firstLine.StartsWith( wxT( 
"version " ) ) )
 
  130        if( !firstLine.substr( 8 ).ToLong( &version ) )
 
  138        pageCountLine = file.GetNextLine();
 
  142        pageCountLine = firstLine;
 
  147    if( !pageCountLine.ToLong( &tabCount ) )
 
  149        EXPECTING( 
_( 
"expecting simulation tab count" ) );
 
  155    std::map<SIM_PLOT_TAB*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
 
  157    for( 
long i = 0; i < tabCount; ++i )
 
  159        long simType, tracesCount;
 
  161        if( !file.GetNextLine().ToLong( &simType ) )
 
  163            EXPECTING( 
_( 
"expecting simulation tab type" ) );
 
  172        wxStringTokenizer tokenizer( command, 
"\r\n", wxTOKEN_STRTOK );
 
  186        while( tokenizer.HasMoreTokens() )
 
  188            wxString line = tokenizer.GetNextToken();
 
  190            if( line.StartsWith( wxT( 
".kicad adjustpaths" ) ) )
 
  192            else if( line.StartsWith( wxT( 
".save all" ) ) )
 
  194            else if( line.StartsWith( wxT( 
".probe alli" ) ) )
 
  196            else if( line.StartsWith( wxT( 
".probe allp" ) ) )
 
  199                simCommand += line + wxT( 
"\n" );
 
  207        if( !file.GetNextLine().ToLong( &tracesCount ) )
 
  216            traceInfo[plotTab] = {};
 
  218        for( 
long j = 0; j < tracesCount; ++j )
 
  221            wxString 
name, param;
 
  223            if( !file.GetNextLine().ToLong( &traceType ) )
 
  231            name = file.GetNextLine();
 
  241            param = file.GetNextLine();
 
  243            if( param.IsEmpty() )
 
  252                traceInfo[plotTab].emplace_back( std::make_tuple( traceType, 
name, param ) );
 
  257            long measurementCount;
 
  259            if( !file.GetNextLine().ToLong( &measurementCount ) )
 
  261                EXPECTING( 
_( 
"expecting measurement count" ) );
 
  267            for( 
int ii = 0; ii < (int) measurementCount; ++ ii )
 
  273                    EXPECTING( 
_( 
"expecting measurement definition" ) );
 
  279                wxString format = file.GetNextLine();
 
  281                if( format.IsEmpty() )
 
  283                    EXPECTING( 
_( 
"expecting measurement format definition" ) );
 
  295    long userDefinedSignalCount;
 
  297    if( file.GetNextLine().ToLong( &userDefinedSignalCount ) )
 
  299        for( 
int ii = 0; ii < (int) userDefinedSignalCount; ++ii )
 
  303    for( 
const auto& [ plotTab, traceInfoVector ] : traceInfo )
 
  305        for( 
const auto& [ traceType, signalName, param ] : traceInfoVector )
 
  307            if( traceType == 
SPT_UNKNOWN && signalName == wxS( 
"$LEGEND" ) )
 
  309                wxArrayString coords = wxSplit( param, 
' ' );
 
  311                if( coords.size() >= 2 )
 
  316                    coords[0].ToLong( &x );
 
  317                    coords[1].ToLong( &y );
 
  318                    plotTab->SetLegendPosition( wxPoint( (
int) x, (
int) y ) );
 
  321                plotTab->ShowLegend( 
true );
 
  326                TRACE*   trace = plotTab->GetOrAddTrace( vectorName, (
int) traceType );
 
  328                if( version >= 4 && trace )
 
  333        plotTab->UpdatePlotColors();
 
  338        m_simulatorFrame->LoadSimulator( simTab->GetSimCommand(), simTab->GetSimOptions() );