36 const wxString& aSignalName,
const wxString& aParams )
39 [&](
int aCursorId,
double x )
43 cursor->SetName( aSignalName );
50 wxArrayString items = wxSplit( aParams,
'|' );
52 for(
const wxString& item : items )
54 if( item.StartsWith( wxS(
"rgb" ) ) )
61 else if( item.StartsWith( wxS(
"cursor1" ) ) )
63 wxArrayString parts = wxSplit( item,
':' );
66 if( parts.size() == 3 )
68 parts[0].AfterFirst(
'=' ).ToDouble( &val );
74 else if( item.StartsWith( wxS(
"cursor2" ) ) )
76 wxArrayString parts = wxSplit( item,
':' );
79 if( parts.size() == 3 )
81 parts[0].AfterFirst(
'=' ).ToDouble( &val );
87 else if( item.StartsWith( wxS(
"cursorD" ) ) )
89 wxArrayString parts = wxSplit( item,
':' );
91 if( parts.size() == 3 )
97 else if( item == wxS(
"dottedSecondary" ) )
101 else if( item == wxS(
"hideGrid" ) )
111 wxTextFile file( aPath );
113#define EXPECTING( msg ) \
114 DisplayErrorMessage( this, wxString::Format( _( "Error loading workbook: line %d: %s." ), \
115 file.GetCurrentLine()+1, \
122 wxString firstLine = file.GetFirstLine();
123 wxString pageCountLine;
125 if( firstLine.StartsWith( wxT(
"version " ) ) )
127 if( !firstLine.substr( 8 ).ToLong( &version ) )
135 pageCountLine = file.GetNextLine();
139 pageCountLine = firstLine;
144 if( !pageCountLine.ToLong( &tabCount ) )
146 EXPECTING(
_(
"expecting simulation tab count" ) );
152 std::map<SIM_PLOT_TAB*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
154 for(
long i = 0; i < tabCount; ++i )
156 long simType, tracesCount;
158 if( !file.GetNextLine().ToLong( &simType ) )
160 EXPECTING(
_(
"expecting simulation tab type" ) );
169 wxStringTokenizer tokenizer( command,
"\r\n", wxTOKEN_STRTOK );
183 while( tokenizer.HasMoreTokens() )
185 wxString line = tokenizer.GetNextToken();
187 if( line.StartsWith( wxT(
".kicad adjustpaths" ) ) )
189 else if( line.StartsWith( wxT(
".save all" ) ) )
191 else if( line.StartsWith( wxT(
".probe alli" ) ) )
193 else if( line.StartsWith( wxT(
".probe allp" ) ) )
196 simCommand += line + wxT(
"\n" );
204 if( !file.GetNextLine().ToLong( &tracesCount ) )
213 traceInfo[plotTab] = {};
215 for(
long j = 0; j < tracesCount; ++j )
218 wxString
name, param;
220 if( !file.GetNextLine().ToLong( &traceType ) )
228 name = file.GetNextLine();
238 param = file.GetNextLine();
240 if( param.IsEmpty() )
249 traceInfo[plotTab].emplace_back( std::make_tuple( traceType,
name, param ) );
254 long measurementCount;
256 if( !file.GetNextLine().ToLong( &measurementCount ) )
258 EXPECTING(
_(
"expecting measurement count" ) );
264 for(
int ii = 0; ii < (int) measurementCount; ++ ii )
270 EXPECTING(
_(
"expecting measurement definition" ) );
276 wxString format = file.GetNextLine();
278 if( format.IsEmpty() )
280 EXPECTING(
_(
"expecting measurement format definition" ) );
292 long userDefinedSignalCount;
294 if( file.GetNextLine().ToLong( &userDefinedSignalCount ) )
296 for(
int ii = 0; ii < (int) userDefinedSignalCount; ++ii )
300 for(
const auto& [ plotTab, traceInfoVector ] : traceInfo )
302 for(
const auto& [ traceType, signalName, param ] : traceInfoVector )
304 if( traceType ==
SPT_UNKNOWN && signalName == wxS(
"$LEGEND" ) )
306 wxArrayString coords = wxSplit( param,
' ' );
308 if( coords.size() >= 2 )
313 coords[0].ToLong( &x );
314 coords[1].ToLong( &y );
315 plotTab->SetLegendPosition( wxPoint( (
int) x, (
int) y ) );
318 plotTab->ShowLegend(
true );
323 TRACE* trace = plotTab->GetOrAddTrace( vectorName, (
int) traceType );
325 if( version >= 4 && trace )
330 plotTab->UpdatePlotColors();
335 m_simulatorFrame->LoadSimulator( simTab->GetSimCommand(), simTab->GetSimOptions() );