39 const wxString& aSignalName,
const wxString& aParams )
42 [&](
int aCursorId,
double x )
46 cursor->SetName( aSignalName );
54 wxArrayString items = wxSplit( aParams,
'|' );
56 for(
const wxString& item : items )
58 if( item.StartsWith( wxS(
"rgb" ) ) )
65 else if( item.StartsWith( wxS(
"cursor1" ) ) )
67 wxArrayString parts = wxSplit( item,
':' );
70 if( parts.size() == 3 )
72 parts[0].AfterFirst(
'=' ).ToDouble( &val );
78 else if( item.StartsWith( wxS(
"cursor2" ) ) )
80 wxArrayString parts = wxSplit( item,
':' );
83 if( parts.size() == 3 )
85 parts[0].AfterFirst(
'=' ).ToDouble( &val );
91 else if( item.StartsWith( wxS(
"cursorD" ) ) )
93 wxArrayString parts = wxSplit( item,
':' );
95 if( parts.size() == 3 )
101 else if( item == wxS(
"dottedSecondary" ) )
105 else if( item == wxS(
"hideGrid" ) )
115 wxTextFile file( aPath );
117#define EXPECTING( msg ) \
118 DisplayErrorMessage( this, wxString::Format( _( "Error loading workbook: line %d: %s." ), \
119 file.GetCurrentLine()+1, \
126 wxString firstLine = file.GetFirstLine();
127 wxString pageCountLine;
129 if( firstLine.StartsWith( wxT(
"version " ) ) )
131 if( !firstLine.substr( 8 ).ToLong( &version ) )
139 pageCountLine = file.GetNextLine();
143 pageCountLine = firstLine;
148 if( !pageCountLine.ToLong( &tabCount ) )
150 EXPECTING(
_(
"expecting simulation tab count" ) );
156 std::map<SIM_PLOT_TAB*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
158 for(
long i = 0; i < tabCount; ++i )
160 long simType, tracesCount;
162 if( !file.GetNextLine().ToLong( &simType ) )
164 EXPECTING(
_(
"expecting simulation tab type" ) );
173 wxStringTokenizer tokenizer( command, wxT(
"\r\n" ), wxTOKEN_STRTOK );
187 while( tokenizer.HasMoreTokens() )
189 wxString line = tokenizer.GetNextToken();
191 if( line.StartsWith( wxT(
".kicad adjustpaths" ) ) )
193 else if( line.StartsWith( wxT(
".save all" ) ) )
195 else if( line.StartsWith( wxT(
".probe alli" ) ) )
197 else if( line.StartsWith( wxT(
".probe allp" ) ) )
200 simCommand += line + wxT(
"\n" );
208 if( !file.GetNextLine().ToLong( &tracesCount ) )
217 traceInfo[plotTab] = {};
219 for(
long j = 0; j < tracesCount; ++j )
222 wxString
name, param;
224 if( !file.GetNextLine().ToLong( &traceType ) )
232 name = file.GetNextLine();
242 param = file.GetNextLine();
244 if( param.IsEmpty() )
253 traceInfo[plotTab].emplace_back( std::make_tuple( traceType,
name, param ) );
258 long measurementCount;
260 if( !file.GetNextLine().ToLong( &measurementCount ) )
262 EXPECTING(
_(
"expecting measurement count" ) );
268 for(
int ii = 0; ii < (int) measurementCount; ++ ii )
274 EXPECTING(
_(
"expecting measurement definition" ) );
280 wxString format = file.GetNextLine();
282 if( format.IsEmpty() )
284 EXPECTING(
_(
"expecting measurement format definition" ) );
296 long userDefinedSignalCount;
298 if( file.GetNextLine().ToLong( &userDefinedSignalCount ) )
300 for(
int ii = 0; ii < (int) userDefinedSignalCount; ++ii )
304 for(
const auto& [ plotTab, traceInfoVector ] : traceInfo )
306 for(
const auto& [ traceType, signalName, param ] : traceInfoVector )
308 if( traceType ==
SPT_UNKNOWN && signalName == wxS(
"$LEGEND" ) )
310 wxArrayString coords = wxSplit( param,
' ' );
312 if( coords.size() >= 2 )
317 coords[0].ToLong( &x );
318 coords[1].ToLong( &y );
319 plotTab->SetLegendPosition( wxPoint( (
int) x, (
int) y ) );
322 plotTab->ShowLegend(
true );
327 TRACE* trace = plotTab->GetOrAddTrace( vectorName, (
int) traceType );
329 if( version >= 4 && trace )
334 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)
wxColour GetTraceColour() const
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)