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, wxT(
"\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();
The SIMULATOR_FRAME holds the main user-interface for running simulations.
@ OPTION_SAVE_ALL_CURRENTS
@ OPTION_SAVE_ALL_VOLTAGES
@ OPTION_SAVE_ALL_DISSIPATIONS
@ OPTION_ADJUST_INCLUDE_PATHS
wxAuiNotebook * m_plotNotebook
SIM_TAB * NewSimTab(const wxString &aSimCommand)
Create a new simulation tab for a given simulation type.
bool loadLegacyWorkbook(const wxString &aPath)
wxString vectorNameFromSignalName(SIM_PLOT_TAB *aPlotTab, const wxString &aSignalName, int *aTraceType)
Get the simulator output vector name for a given signal name and type.
SIM_TAB * GetCurrentSimTab() const
Return the currently opened plot panel (or NULL if there is none).
std::map< int, wxString > m_userDefinedSignals
SIMULATOR_FRAME * m_simulatorFrame
void parseTraceParams(SIM_PLOT_TAB *aPlotTab, TRACE *aTrace, const wxString &aSignalName, const wxString &aParams)
SPICE_VALUE_FORMAT m_cursorFormats[3][2]
bool LoadSimulator(const wxString &aSimCommand, unsigned aSimOptions)
Check and load the current netlist into the simulator.
mpWindow * GetPlotWin() const
void ShowGrid(bool aEnable)
std::vector< std::pair< wxString, wxString > > & Measurements()
void UpdateTraceStyle(TRACE *trace)
Update plot colors.
void SetDottedSecondary(bool aEnable)
Draw secondary signal traces (current or phase) with dotted lines.
void SetLastSchTextSimCommand(const wxString &aCmd)
void SetSimOptions(int aOptions)
void SetTraceColour(const wxColour &aColour)
void SetCursor(int aCursorId, CURSOR *aCursor)
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
This file is part of the common library.
wxString UnescapeString(const wxString &aSource)