36 const wxString& aSignalName,
const wxString& aParams )
39 [&](
int aCursorId,
double x )
43 cursor->SetName( aSignalName );
52 wxArrayString items = wxSplit( aParams,
'|' );
54 for(
const wxString& item : items )
56 if( item.StartsWith( wxS(
"rgb" ) ) )
63 else if( item.StartsWith( wxS(
"cursor1" ) ) )
65 wxArrayString parts = wxSplit( item,
':' );
68 if( parts.size() == 3 )
70 parts[0].AfterFirst(
'=' ).ToDouble( &val );
76 else if( item.StartsWith( wxS(
"cursor2" ) ) )
78 wxArrayString parts = wxSplit( item,
':' );
81 if( parts.size() == 3 )
83 parts[0].AfterFirst(
'=' ).ToDouble( &val );
89 else if( item.StartsWith( wxS(
"cursorD" ) ) )
91 wxArrayString parts = wxSplit( item,
':' );
93 if( parts.size() == 3 )
99 else if( item == wxS(
"dottedSecondary" ) )
103 else if( item == wxS(
"hideGrid" ) )
113 wxTextFile file( aPath );
115#define EXPECTING( msg ) \
116 DisplayErrorMessage( this, wxString::Format( _( "Error loading workbook: line %d: %s." ), \
117 file.GetCurrentLine()+1, \
124 wxString firstLine = file.GetFirstLine();
125 wxString pageCountLine;
127 if( firstLine.StartsWith( wxT(
"version " ) ) )
129 if( !firstLine.substr( 8 ).ToLong( &version ) )
137 pageCountLine = file.GetNextLine();
141 pageCountLine = firstLine;
146 if( !pageCountLine.ToLong( &tabCount ) )
148 EXPECTING(
_(
"expecting simulation tab count" ) );
154 std::map<SIM_PLOT_TAB*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
156 for(
long i = 0; i < tabCount; ++i )
158 long simType, tracesCount;
160 if( !file.GetNextLine().ToLong( &simType ) )
162 EXPECTING(
_(
"expecting simulation tab type" ) );
171 wxStringTokenizer tokenizer( command,
"\r\n", wxTOKEN_STRTOK );
185 while( tokenizer.HasMoreTokens() )
187 wxString line = tokenizer.GetNextToken();
189 if( line.StartsWith( wxT(
".kicad adjustpaths" ) ) )
191 else if( line.StartsWith( wxT(
".save all" ) ) )
193 else if( line.StartsWith( wxT(
".probe alli" ) ) )
195 else if( line.StartsWith( wxT(
".probe allp" ) ) )
198 simCommand += line + wxT(
"\n" );
206 if( !file.GetNextLine().ToLong( &tracesCount ) )
215 traceInfo[plotTab] = {};
217 for(
long j = 0; j < tracesCount; ++j )
220 wxString
name, param;
222 if( !file.GetNextLine().ToLong( &traceType ) )
230 name = file.GetNextLine();
240 param = file.GetNextLine();
242 if( param.IsEmpty() )
251 traceInfo[plotTab].emplace_back( std::make_tuple( traceType,
name, param ) );
256 long measurementCount;
258 if( !file.GetNextLine().ToLong( &measurementCount ) )
260 EXPECTING(
_(
"expecting measurement count" ) );
266 for(
int ii = 0; ii < (int) measurementCount; ++ ii )
272 EXPECTING(
_(
"expecting measurement definition" ) );
278 wxString format = file.GetNextLine();
280 if( format.IsEmpty() )
282 EXPECTING(
_(
"expecting measurement format definition" ) );
294 long userDefinedSignalCount;
296 if( file.GetNextLine().ToLong( &userDefinedSignalCount ) )
298 for(
int ii = 0; ii < (int) userDefinedSignalCount; ++ii )
302 for(
const auto& [ plotTab, traceInfoVector ] : traceInfo )
304 for(
const auto& [ traceType, signalName, param ] : traceInfoVector )
306 if( traceType ==
SPT_UNKNOWN && signalName == wxS(
"$LEGEND" ) )
308 wxArrayString coords = wxSplit( param,
' ' );
310 if( coords.size() >= 2 )
315 coords[0].ToLong( &x );
316 coords[1].ToLong( &y );
317 plotTab->SetLegendPosition( wxPoint( (
int) x, (
int) y ) );
320 plotTab->ShowLegend(
true );
325 TRACE* trace = plotTab->GetOrAddTrace( vectorName, (
int) traceType, plotTab->GetDefaultView() );
327 if( version >= 4 && trace )
332 plotTab->UpdatePlotColors();
337 m_simulatorFrame->LoadSimulator( simTab->GetSimCommand(), simTab->GetSimOptions() );