60#include "fmt/format.h"
70 int res = (int) aFirst | (
int) aSecond;
86 wxCommandEvent*
event =
new wxCommandEvent( EVT_SIM_REPORT );
87 event->SetString( aText );
99 wxCommandEvent*
event =
nullptr;
103 case SIM_IDLE:
event =
new wxCommandEvent( EVT_SIM_FINISHED );
break;
104 case SIM_RUNNING:
event =
new wxCommandEvent( EVT_SIM_STARTED );
break;
105 default: wxFAIL;
return;
170 void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
override;
203 menu.AppendSeparator();
212 std::vector<wxString> signals;
214 wxGridCellCoordsArray cells1 =
m_grid->GetSelectionBlockTopLeft();
215 wxGridCellCoordsArray cells2 =
m_grid->GetSelectionBlockBottomRight();
217 for(
size_t i = 0; i < cells1.Count(); i++ )
221 for(
int j = cells1[i].GetRow(); j < cells2[i].GetRow() + 1; j++ )
223 signals.push_back(
m_grid->GetCellValue( j, cells1[i].GetCol() ) );
228 wxGridCellCoordsArray cells3 =
m_grid->GetSelectedCells();
230 for(
size_t i = 0; i < cells3.Count(); i++ )
233 signals.push_back(
m_grid->GetCellValue( cells3[i].GetRow(), cells3[i].GetCol() ) );
236 if( signals.size() < 1 )
241 for(
const wxString& signal : signals )
246 for(
const wxString& signal : signals )
251 for(
const wxString& signal : signals )
256 for(
const wxString& signal : signals )
261 for(
const wxString& signal : signals )
266 for(
const wxString& signal : signals )
271 for(
const wxString& signal : signals )
276 for(
const wxString& signal : signals )
295 void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
override;
315 menu.AppendSeparator();
331 if( formatDialog.ShowModal() == wxID_OK )
352 void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
override;
378 menu.AppendSeparator();
391 if( formatDialog.ShowModal() == wxID_OK )
399 std::vector<int> measurements;
401 wxGridCellCoordsArray cells1 =
m_grid->GetSelectionBlockTopLeft();
402 wxGridCellCoordsArray cells2 =
m_grid->GetSelectionBlockBottomRight();
404 for(
size_t i = 0; i < cells1.Count(); i++ )
408 for(
int j = cells1[i].GetRow(); j < cells2[i].GetRow() + 1; j++ )
410 measurements.push_back( j );
415 wxGridCellCoordsArray cells3 =
m_grid->GetSelectedCells();
417 for(
size_t i = 0; i < cells3.Count(); i++ )
420 measurements.push_back( cells3[i].GetRow() );
423 if( measurements.size() < 1 )
428 sort( measurements.begin(), measurements.end(), std::greater<>() );
430 for(
int row : measurements )
469 m_SuppressGridEvents( 0 ),
470 m_lastSimPlot(
nullptr ),
473 m_simFinished( false ),
474 m_workbookModified( false )
476 SetKiway(
this, aKiway );
479 wxASSERT( m_schematicFrame );
487 wxASSERT( m_simulator );
492 m_filter->SetHint(
_(
"Filter" ) );
502 wxGridCellAttr* attr =
new wxGridCellAttr;
506 attr =
new wxGridCellAttr;
510 attr =
new wxGridCellAttr;
514 attr =
new wxGridCellAttr;
518 for(
int cursorId = 0; cursorId < 3; ++cursorId )
520 m_cursorFormats[ cursorId ][ 0 ] = { 3, wxS(
"~s" ) };
521 m_cursorFormats[ cursorId ][ 1 ] = { 3, wxS(
"~V" ) };
524 attr =
new wxGridCellAttr;
534 wxCHECK2( settings, );
542 m_simulator->SetReporter( m_reporter );
544 m_circuitModel = std::make_shared<NGSPICE_CIRCUIT_MODEL>( &m_schematicFrame->Schematic(),
this );
563#ifndef wxHAS_NATIVE_TABART
565 m_plotNotebook->SetArtProvider(
new wxAuiSimpleTabArt() );
577 setSubWindowsSashSize();
627 for(
int ii = 0; ii < (int)
m_plotNotebook->GetPageCount(); ++ii )
633 plot->OnLanguageChanged();
635 wxString pageTitle(
m_simulator->TypeToName(
plot->GetType(),
true ) );
636 pageTitle.Prepend( wxString::Format(
_(
"Plot%u - " ), ii+1 ) );
656 tuner->ShowChangedLanguage();
706 if(
project.m_SchematicSettings )
708 bool modified =
project.m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile();
727 if( !
m_simulator->Settings()->GetWorkbookFilename().IsEmpty() )
729 wxFileName filename =
m_simulator->Settings()->GetWorkbookFilename();
730 filename.SetPath(
Prj().GetProjectPath() );
733 m_simulator->Settings()->SetWorkbookFilename(
"" );
749 bool readOnly =
false;
756 if( filename.IsOk() && filename.FileExists() )
759 readOnly = !filename.IsFileWritable();
763 title = wxT(
"*" ) + filename.GetName();
765 title = filename.GetName();
769 title += wxS(
" " ) +
_(
"[Read Only]" );
772 title += wxS(
" " ) +
_(
"[Unsaved]" );
774 title += wxT(
" \u2014 " ) +
_(
"Spice Simulator" );
805 if( aFilter.IsEmpty() )
806 aFilter = wxS(
"*" );
812 for(
const wxString& signal :
m_signals )
818 TRACE* trace = plotPanel ? plotPanel->
GetTrace( vectorName, traceType ) :
nullptr;
825 wxGridCellAttr* attr =
new wxGridCellAttr;
831 wxGridCellAttr* attr =
new wxGridCellAttr;
832 attr->SetRenderer(
new wxGridCellBoolRenderer() );
834 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
841 if( !plotPanel || !trace )
843 wxGridCellAttr* attr =
new wxGridCellAttr;
848 attr =
new wxGridCellAttr;
852 attr =
new wxGridCellAttr;
858 wxGridCellAttr* attr =
new wxGridCellAttr;
859 attr =
new wxGridCellAttr;
862 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
867 attr =
new wxGridCellAttr;
868 attr->SetRenderer(
new wxGridCellBoolRenderer() );
870 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
873 attr =
new wxGridCellAttr;
874 attr->SetRenderer(
new wxGridCellBoolRenderer() );
876 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
892 wxString unconnected = wxString( wxS(
"unconnected-(" ) );
897 unconnected.Replace(
'(',
'_' );
900 [&](
const wxString& aSignalName )
902 if( simType ==
ST_AC )
904 m_signals.push_back( aSignalName +
_(
" (gain)" ) );
905 m_signals.push_back( aSignalName +
_(
" (phase)" ) );
920 if( netname ==
"GND" || netname ==
"0" || netname.StartsWith( unconnected ) )
924 addSignal( wxString::Format( wxS(
"V(%s)" ), netname ) );
934 for(
const std::string&
name : item.model->SpiceGenerator().CurrentNames( item ) )
944 if( item.model->GetPinCount() >= 2 )
946 wxString
name = item.model->SpiceGenerator().ItemName( item );
947 addSignal( wxString::Format( wxS(
"P(%s)" ),
name ) );
953 for(
const wxString& directive :
m_circuitModel->GetDirectives() )
955 wxStringTokenizer tokenizer( directive, wxT(
"\r\n" ), wxTOKEN_STRTOK );
957 while( tokenizer.HasMoreTokens() )
959 wxString line = tokenizer.GetNextToken();
960 wxString directiveParams;
962 if( line.Upper().StartsWith( wxS(
".PROBE" ), &directiveParams ) )
963 addSignal( directiveParams.Trim(
true ).Trim(
false ) );
971 addSignal( signalName );
974 [](
const wxString& lhs,
const wxString& rhs )
977 if( lhs.Upper().StartsWith(
'V' ) && !rhs.Upper().StartsWith(
'V' ) )
979 else if( !lhs.Upper().StartsWith(
'V' ) && rhs.Upper().StartsWith(
'V' ) )
982 return StrNumCmp( lhs, rhs, true ) < 0;
1020 wxString schTextSimCommand =
m_circuitModel->GetSchTextSimCommand();
1033 if( plotWindow->
GetType() == schTextSimType
1034 && schTextSimCommand !=
m_circuitModel->GetLastSchTextSimCommand() )
1036 if(
IsOK(
this,
_(
"Schematic sheet simulation command directive has changed. "
1037 "Do you wish to update the Simulation Command?" ) ) )
1051 std::unique_lock<std::mutex> simulatorLock(
m_simulator->GetMutex(), std::try_to_lock );
1053 if( simulatorLock.owns_lock() )
1055 wxBusyCursor toggle;
1091 wxString pageTitle(
m_simulator->TypeToName( simType,
true ) );
1092 pageTitle.Prepend( wxString::Format(
_(
"Plot%u - " ), (
unsigned int) ++
m_plotNumber ) );
1109 wxPoint pos = aEvent.GetPosition();
1110 wxRect ctrlRect =
m_filter->GetScreenRect();
1111 int buttonWidth = ctrlRect.GetHeight();
1113 if(
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
1114 SetCursor( wxCURSOR_ARROW );
1115 else if(
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
1116 SetCursor( wxCURSOR_ARROW );
1118 SetCursor( wxCURSOR_IBEAM );
1124 return wxString::Format( wxS(
"user%d" ), aUserDefinedSignalId );
1134 std::map<wxString, int> suffixes;
1140 wxUniChar firstChar = aSignalName.Upper()[0];
1142 if( firstChar ==
'V' )
1144 else if( firstChar ==
'I' )
1146 else if( firstChar ==
'P' )
1151 wxString
name = aSignalName;
1153 for(
const auto& [ candidate, type ] : suffixes )
1155 if(
name.EndsWith( candidate ) )
1157 name =
name.Left(
name.Length() - candidate.Length() );
1160 *aTraceType |= type;
1168 if(
name == signal )
1181 int row = aEvent.GetRow();
1182 int col = aEvent.GetCol();
1191 if(
text == wxS(
"1" ) )
1194 plot->DeleteTrace( vectorName, traceType );
1204 TRACE* trace =
plot->GetTrace( vectorName, traceType );
1209 plot->UpdateTraceStyle( trace );
1210 plot->UpdatePlotColors();
1216 for(
int ii = 0; ii <
m_signalsGrid->GetNumberRows(); ++ii )
1222 bool enable = ii == row &&
text == wxS(
"1" );
1224 plot->EnableCursor( vectorName, traceType,
id, enable, signalName );
1244 int row = aEvent.GetRow();
1245 int col = aEvent.GetCol();
1251 CURSOR* cursor1 =
nullptr;
1252 CURSOR* cursor2 =
nullptr;
1265 if( cursorName == wxS(
"1" ) && cursor1 )
1267 else if( cursorName == wxS(
"2" ) && cursor2 )
1269 else if( cursorName ==
_(
"Diff" ) && cursor1 && cursor2 )
1277 wxFAIL_MSG( wxT(
"All other columns are supposed to be read-only!" ) );
1314 int row = aEvent.GetRow();
1315 int col = aEvent.GetCol();
1325 wxFAIL_MSG( wxT(
"All other columns are supposed to be read-only!" ) );
1333 for( row = rowCount - 1; row >= 0; row-- )
1343 int killRows = emptyRows - 1;
1346 else if( emptyRows == 0 )
1369 static wxRegEx measureParamsRegEx( wxT(
"^"
1373 "([a-zA-Z])\\(([^\\)]+)\\)" ) );
1382 if(
text.IsEmpty() )
1389 wxString resultName = wxString::Format( wxS(
"meas_result_%u" ), aRow );
1390 wxString result = wxS(
"?" );
1392 if( measureParamsRegEx.Matches(
text ) )
1394 wxString func = measureParamsRegEx.GetMatch(
text, 1 ).Upper();
1395 wxUniChar signalType = measureParamsRegEx.GetMatch(
text, 2 ).Upper()[0];
1396 wxString deviceName = measureParamsRegEx.GetMatch(
text, 3 );
1400 if( signalType ==
'I' )
1402 else if( signalType ==
'P' )
1406 text = func +
" " + deviceName +
":power";
1411 if( func.EndsWith( wxS(
"_AT" ) ) )
1413 else if( func.StartsWith( wxS(
"INTEG" ) ) )
1415 switch( plotPanel->
GetType() )
1417 case SIM_TYPE::ST_TRANSIENT:
1418 if ( signalType ==
'P' )
1421 units += wxS(
".s" );
1423 case SIM_TYPE::ST_AC:
1424 case SIM_TYPE::ST_DISTORTION:
1425 case SIM_TYPE::ST_NOISE:
1426 case SIM_TYPE::ST_SENSITIVITY:
1427 units += wxS(
"·Hz" );
1429 case SIM_TYPE::ST_DC:
1430 case SIM_TYPE::ST_OP:
1431 case SIM_TYPE::ST_POLE_ZERO:
1432 case SIM_TYPE::ST_TRANS_FUNC:
1435 units += wxS(
"·?" );
1446 wxString cmd = wxString::Format( wxS(
"meas %s %s %s" ), simType, resultName,
text );
1447 m_simulator->Command(
"echo " + cmd.ToStdString() );
1450 std::vector<double> resultVec =
m_simulator->GetMagPlot( resultName.ToStdString() );
1452 if( resultVec.size() > 0 )
1479 wxString ref = aSymbol->
GetRef( &aSheetPath );
1484 if( tuner->GetSymbolRef() == ref )
1510 const wxString& aRef,
const wxString& aValue )
1518 + wxString::Format(
_(
"%s not found" ), aRef ) );
1530 + wxString::Format(
_(
"%s is not tunable" ), aRef ) );
1615 m_simConsole->AppendText(
_(
"Error: no current simulation.\n" ) );
1624 m_simConsole->AppendText(
_(
"Error: simulation type not defined.\n" ) );
1630 m_simConsole->AppendText(
_(
"Error: simulation type doesn't support plotting.\n" ) );
1635 if( simType ==
ST_AC )
1664 if( aNewSignals.count(
id ) == 0 )
1669 plotPanel->
DeleteTrace( vectorName, traceType | subType );
1682 if(
TRACE* trace = plotPanel->
GetTrace( vectorName, traceType | subType ) )
1683 trace->SetName( aNewSignals.at(
id ) );
1688 if(
TRACE* trace = plotPanel->
GetTrace( vectorName, traceType ) )
1689 trace->SetName( aNewSignals.at(
id ) );
1716 wxString simVectorName = aVectorName;
1719 simVectorName = simVectorName.AfterFirst(
'(' ).BeforeLast(
')' ) + wxS(
":power" );
1724 m_simulator->Command( wxString::Format( wxT(
"print %s" ), aVectorName ).ToStdString() );
1730 wxString xAxisName(
m_simulator->GetXAxis( simType ) );
1732 if( xAxisName.IsEmpty() )
1735 std::vector<double> data_x;
1736 std::vector<double> data_y;
1740 data_x =
m_simulator->GetMagPlot( (
const char*) xAxisName.c_str() );
1746 data_y =
m_simulator->GetMagPlot( (
const char*) simVectorName.c_str() );
1748 data_y =
m_simulator->GetPhasePlot( (
const char*) simVectorName.c_str() );
1750 wxFAIL_MSG( wxT(
"Plot type missing AC_PHASE or AC_MAG bit" ) );
1757 data_y =
m_simulator->GetMagPlot( (
const char*) simVectorName.c_str() );
1761 wxFAIL_MSG( wxT(
"Unhandled plot type" ) );
1765 unsigned int size = data_x.size();
1771 if( simType ==
ST_DC
1779 size_t outer = ( size_t )( ( source2.
m_vend - v ) / source2.
m_vincrement ).ToDouble();
1780 size_t inner = data_x.size() / ( outer + 1 );
1782 wxASSERT( data_x.size() % ( outer + 1 ) == 0 );
1784 for(
size_t idx = 0; idx <= outer; idx++ )
1786 if(
TRACE* trace = aPlotPanel->
AddTrace( aVectorName, aTraceType ) )
1788 if( data_y.size() >= size )
1790 std::vector<double> sub_x( data_x.begin() + offset,
1791 data_x.begin() + offset + inner );
1792 std::vector<double> sub_y( data_y.begin() + offset,
1793 data_y.begin() + offset + inner );
1795 aPlotPanel->
SetTraceData( trace, inner, sub_x.data(), sub_y.data() );
1803 else if(
TRACE* trace = aPlotPanel->
AddTrace( aVectorName, aTraceType ) )
1805 if( data_y.size() >= size )
1806 aPlotPanel->
SetTraceData( trace, size, data_x.data(), data_y.data() );
1815 for(
int row = 0; row <
m_signalsGrid->GetNumberRows(); ++row )
1821 if(
TRACE* trace =
plot ?
plot->GetTrace( vectorName, traceType ) :
nullptr )
1825 wxGridCellAttr* attr =
new wxGridCellAttr;
1828 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
1834 attr =
new wxGridCellAttr;
1835 attr->SetRenderer(
new wxGridCellBoolRenderer() );
1836 attr->SetReadOnly();
1837 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
1840 attr =
new wxGridCellAttr;
1841 attr->SetRenderer(
new wxGridCellBoolRenderer() );
1842 attr->SetReadOnly();
1843 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
1846 if( trace->HasCursor( 1 ) )
1851 if( trace->HasCursor( 2 ) )
1860 wxGridCellAttr* attr =
new wxGridCellAttr;
1861 attr->SetReadOnly();
1865 attr =
new wxGridCellAttr;
1866 attr->SetReadOnly();
1870 attr =
new wxGridCellAttr;
1871 attr->SetReadOnly();
1881 auto quoteNetNames =
1882 [&]( wxString aExpression ) -> wxString
1885 aExpression.Replace( netname, quotedNetname );
1892 std::string cmd =
"let user{} = {}";
1894 m_simulator->Command(
"echo " + fmt::format( cmd,
id, signal.ToStdString() ) );
1895 m_simulator->Command( fmt::format( cmd,
id, quoteNetNames( signal ).ToStdString() ) );
1908 wxString ref = tuner->GetSymbolRef();
1909 KIID symbolId = tuner->GetSymbol( &sheetPath );
1915 reporter.
Report( wxString::Format(
_(
"%s not found" ), ref ) );
1923 reporter.
Report( wxString::Format(
_(
"%s is not tunable" ), ref ) );
1927 double floatVal = tuner->GetValue().ToDouble();
1938 const wxString& aSignalName,
const wxString& aParams )
1941 [&](
int aCursorId,
double x )
1945 cursor->SetName( aSignalName );
1953 wxArrayString items = wxSplit( aParams,
'|' );
1955 for(
const wxString& item : items )
1957 if( item.StartsWith( wxS(
"rgb" ) ) )
1964 else if( item.StartsWith( wxS(
"cursor1" ) ) )
1966 wxArrayString parts = wxSplit( item,
':' );
1969 if( parts.size() == 3 )
1971 parts[0].AfterFirst(
'=' ).ToDouble( &val );
1974 addCursor( 1, val );
1977 else if( item.StartsWith( wxS(
"cursor2" ) ) )
1979 wxArrayString parts = wxSplit( item,
':' );
1982 if( parts.size() == 3 )
1984 parts[0].AfterFirst(
'=' ).ToDouble( &val );
1987 addCursor( 2, val );
1990 else if( item.StartsWith( wxS(
"cursorD" ) ) )
1992 wxArrayString parts = wxSplit( item,
':' );
1994 if( parts.size() == 3 )
2000 else if( item == wxS(
"dottedSecondary" ) )
2004 else if( item == wxS(
"hideGrid" ) )
2016 wxTextFile file( aPath );
2018#define DISPLAY_LOAD_ERROR( fmt ) DisplayErrorMessage( this, wxString::Format( _( fmt ), \
2019 file.GetCurrentLine()+1 ) )
2025 wxString firstLine = file.GetFirstLine();
2026 wxString plotCountLine;
2028 if( firstLine.StartsWith( wxT(
"version " ) ) )
2030 if( !firstLine.substr( 8 ).ToLong( &version ) )
2038 plotCountLine = file.GetNextLine();
2042 plotCountLine = firstLine;
2047 if( !plotCountLine.ToLong( &plotsCount ) )
2055 std::map<SIM_PLOT_PANEL*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
2057 for(
long i = 0; i < plotsCount; ++i )
2059 long plotType, tracesCount;
2061 if( !file.GetNextLine().ToLong( &plotType ) )
2070 wxString simCommand;
2072 wxStringTokenizer tokenizer( command, wxT(
"\r\n" ), wxTOKEN_STRTOK );
2086 while( tokenizer.HasMoreTokens() )
2088 wxString line = tokenizer.GetNextToken();
2090 if( line.StartsWith( wxT(
".kicad adjustpaths" ) ) )
2092 else if( line.StartsWith( wxT(
".save all" ) ) )
2094 else if( line.StartsWith( wxT(
".probe alli" ) ) )
2096 else if( line.StartsWith( wxT(
".probe allp" ) ) )
2099 simCommand += line + wxT(
"\n" );
2105 if( !file.GetNextLine().ToLong( &tracesCount ) )
2114 traceInfo[ plotPanel ] = {};
2116 for(
long j = 0; j < tracesCount; ++j )
2119 wxString
name, param;
2121 if( !file.GetNextLine().ToLong( &traceType ) )
2129 name = file.GetNextLine();
2131 if(
name.IsEmpty() )
2139 param = file.GetNextLine();
2142 traceInfo[ plotPanel ].emplace_back( std::make_tuple( traceType,
name, param ) );
2146 long userDefinedSignalCount;
2147 long measurementCount;
2149 if( file.GetNextLine().ToLong( &userDefinedSignalCount ) )
2151 for(
int ii = 0; ii < (int) userDefinedSignalCount; ++ii )
2154 file.GetNextLine().ToLong( &measurementCount );
2159 for(
int row = 0; row < (int) measurementCount; ++row )
2166 for(
const auto& [ plotPanel, traceInfoVector ] : traceInfo )
2168 for(
const auto& [ traceType, signalName, param ] : traceInfoVector )
2170 if( traceType ==
SPT_UNKNOWN && signalName == wxS(
"$LEGEND" ) )
2172 wxArrayString coords = wxSplit( param,
' ' );
2174 if( coords.size() >= 2 )
2179 coords[0].ToLong( &x );
2180 coords[1].ToLong( &y );
2181 plotPanel->SetLegendPosition( wxPoint( (
int) x, (
int) y ) );
2184 plotPanel->ShowLegend(
true );
2189 TRACE* trace = plotPanel->AddTrace( vectorName, (
int) traceType );
2191 if( version >= 4 && trace )
2196 plotPanel->UpdatePlotColors();
2201 wxString schTextSimCommand =
m_circuitModel->GetSchTextSimCommand().Lower();
2208 for(
int ii = 0; ii < (int)
m_plotNotebook->GetPageCount(); ++ii )
2212 if(
plot &&
plot->GetType() == schTextSimType )
2214 if( schTextSimType ==
ST_DC )
2216 wxString plotSimCommand =
plot->GetSimCommand().Lower();
2217 found = plotSimCommand.GetChar( 4 ) == schTextSimCommand.GetChar( 4 );
2238 wxFileName filename( aPath );
2239 filename.MakeRelativeTo(
Prj().GetProjectPath() );
2242 m_simulator->Settings()->SetWorkbookFilename( filename.GetFullPath() );
2259 wxFileName filename = aPath;
2262 wxTextFile file( filename.GetFullPath() );
2276 file.AddLine( wxT(
"version 4" ) );
2278 file.AddLine( wxString::Format( wxT(
"%llu" ),
m_plotNotebook->GetPageCount() ) );
2286 file.AddLine( wxString::Format( wxT(
"%llu" ), 0ull ) );
2290 file.AddLine( wxString::Format( wxT(
"%d" ), basePanel->
GetType() ) );
2296 command += wxT(
"\n.kicad adjustpaths" );
2299 command += wxT(
"\n.save all" );
2302 command += wxT(
"\n.probe alli" );
2305 command += wxT(
"\n.probe allp" );
2313 file.AddLine( wxString::Format( wxT(
"%llu" ), 0ull ) );
2317 size_t traceCount = plotPanel->
GetTraces().size();
2322 file.AddLine( wxString::Format( wxT(
"%llu" ), traceCount ) );
2324 auto findSignalName =
2325 [&](
const wxString& aVectorName ) -> wxString
2338 file.AddLine( wxString::Format( wxT(
"%d" ), trace->GetType() ) );
2339 file.AddLine( findSignalName( trace->GetName() ) );
2345 msg += wxString::Format( wxS(
"|cursor1=%E:%s:%s" ),
2353 msg += wxString::Format( wxS(
"|cursor2=%E:%s:%s" ),
2359 if( trace->GetCursor( 1 ) || trace->GetCursor( 2 ) )
2361 msg += wxString::Format( wxS(
"|cursorD:%s:%s" ),
2367 msg += wxS(
"|dottedSecondary" );
2370 msg += wxS(
"|hideGrid" );
2372 file.AddLine( msg );
2377 file.AddLine( wxString::Format( wxT(
"%d" ),
SPT_UNKNOWN ) );
2378 file.AddLine( wxT(
"$LEGEND" ) );
2379 file.AddLine( wxString::Format( wxT(
"%d %d" ),
2388 file.AddLine( signal );
2390 std::vector<wxString> measurements;
2391 std::vector<wxString> formats;
2402 file.AddLine( wxString::Format( wxT(
"%llu" ), measurements.size() ) );
2404 for(
size_t i = 0; i < measurements.size(); i++ )
2406 file.AddLine( measurements[i] );
2407 file.AddLine( formats[i] );
2410 bool res = file.Write();
2416 filename.MakeRelativeTo(
Prj().GetProjectPath() );
2417 m_simulator->Settings()->SetWorkbookFilename( filename.GetFullPath() );
2435 default: wxFAIL_MSG( wxS(
"Unhandled simulation type" ) );
return SPT_UNKNOWN;
2448 for(
size_t page = 0; page <
m_plotNotebook->GetPageCount(); page++ )
2522 if(
m_plotNotebook->GetPageIndex( plotPanelWindow ) != wxNOT_FOUND )
2534 wxString oldCommand;
2536 if(
m_plotNotebook->GetPageIndex( plotPanelWindow ) != wxNOT_FOUND )
2539 oldCommand = wxString();
2545 if( !plotPanelWindow )
2549 plotPanelWindow =
NewPlotPanel( newCommand, newOptions );
2553 else if( plotPanelWindow->
GetType() != newSimType
2554 || ( newSimType ==
ST_DC
2555 && oldCommand.Lower().GetChar( 4 ) != newCommand.Lower().GetChar( 4 ) ) )
2557 plotPanelWindow =
NewPlotPanel( newCommand, newOptions );
2582 wxFileName filename =
m_simulator->Settings()->GetWorkbookFilename();
2584 if( filename.GetName().IsEmpty() )
2586 if(
Prj().GetProjectName().IsEmpty() )
2587 filename.SetFullName( wxT(
"noname.wbk" ) );
2589 filename.SetFullName(
Prj().GetProjectName() + wxT(
".wbk" ) );
2634 CURSOR* cursor1 =
nullptr;
2635 wxString cursor1Name;
2636 wxString cursor1Units;
2637 CURSOR* cursor2 =
nullptr;
2638 wxString cursor2Name;
2639 wxString cursor2Units;
2642 [&](
TRACE* aTrace ) -> wxString
2646 else if( aTrace->GetType() &
SPT_POWER )
2653 [&](
TRACE* aTrace ) -> wxString
2657 else if( aTrace->GetType() &
SPT_POWER )
2664 [
this](
double aValue,
int aCursorId,
int aCol ) -> wxString
2677 cursor1Name = getNameY( trace );
2678 cursor1Units = getUnitsY( trace );
2680 wxRealPoint coords =
cursor->GetCoords();
2700 cursor2Name = getNameY( trace );
2701 cursor2Units = getUnitsY( trace );
2703 wxRealPoint coords =
cursor->GetCoords();
2718 if( cursor1 && cursor2 && cursor1Units == cursor2Units )
2727 signal = wxString::Format( wxS(
"%s[2 - 1]" ), cursor2->
GetName() );
2729 signal = wxString::Format( wxS(
"%s - %s" ), cursor2->
GetName(), cursor1->
GetName() );
2741 wxString valColName =
_(
"Value" );
2743 if( !cursor1Name.IsEmpty() )
2745 if( cursor2Name.IsEmpty() || cursor1Name == cursor2Name )
2746 valColName = cursor1Name;
2748 else if( !cursor2Name.IsEmpty() )
2750 valColName = cursor2Name;
2771 auto showGridCondition =
2775 return plot &&
plot->IsGridShown();
2778 auto showLegendCondition =
2782 return plot &&
plot->IsLegendShown();
2785 auto showDottedCondition =
2789 return plot &&
plot->GetDottedSecondary();
2792 auto darkModePlotCondition =
2816#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
2817#define CHECK( x ) ACTION_CONDITIONS().Check( x )
2845 SetCursor( wxCURSOR_ARROWWAIT );
2851 SetCursor( wxCURSOR_ARROW );
2860 if( !plotPanelWindow || plotPanelWindow->
GetType() != simType )
2887 std::vector<wxString> oldSignals =
m_signals;
2899 wxCHECK_RET( plotPanel, wxT(
"not a SIM_PLOT_PANEL" ) );
2902 std::map<TRACE*, std::pair<wxString, int>> traceMap;
2905 traceMap[ trace ] = { wxEmptyString,
SPT_UNKNOWN };
2907 for(
const wxString& signal :
m_signals )
2912 if( simType ==
ST_AC )
2916 if(
TRACE* trace = plotPanel->
GetTrace( vectorName, traceType | subType ) )
2917 traceMap[ trace ] = { vectorName, traceType };
2922 if(
TRACE* trace = plotPanel->
GetTrace( vectorName, traceType ) )
2923 traceMap[ trace ] = { vectorName, traceType };
2929 for(
const auto& [ trace, traceInfo ] : traceMap )
2931 if( traceInfo.first.IsEmpty() )
2935 for(
const auto& [ trace, traceInfo ] : traceMap )
2937 if( !traceInfo.first.IsEmpty() )
2938 updateTrace( traceInfo.first, traceInfo.second, plotPanel );
2948 else if( simType ==
ST_OP )
2950 m_simConsole->AppendText(
_(
"\n\nSimulation results:\n\n" ) );
2953 for(
const std::string& vec :
m_simulator->AllPlots() )
2955 std::vector<double> val_list =
m_simulator->GetRealPlot( vec, 1 );
2957 if( val_list.size() == 0 )
2965 const size_t tab = 25;
2966 size_t padding = ( signal.length() < tab ) ? ( tab - signal.length() ) : 1;
2968 value.Append( type ==
SPT_CURRENT ? wxS(
"A" ) : wxS(
"V" ) );
2970 msg.Printf( wxT(
"%s%s\n" ),
2971 ( signal + wxT(
":" ) ).Pad( padding, wxUniChar(
' ' ) ),
2977 if( signal.StartsWith( wxS(
"V(" ) ) || signal.StartsWith( wxS(
"I(" ) ) )
2978 signal = signal.SubString( 2, signal.Length() - 2 );
2998 static bool updateInProgress =
false;
3001 if( updateInProgress )
3004 updateInProgress =
true;
3017 std::unique_lock<std::mutex> simulatorLock(
m_simulator->GetMutex(), std::try_to_lock );
3019 if( simulatorLock.owns_lock() )
3034 updateInProgress =
false;
3047 if( aEvent.GetId() == wxID_EXIT )
3050 if( aEvent.GetId() == wxID_CLOSE )
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
static TOOL_ACTION toggleGrid
static TOOL_ACTION cancelInteractive
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Handle actions that are shared between different applications.
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
SIMULATOR_FRAME * m_parent
CURSORS_GRID_TRICKS(SIMULATOR_FRAME *aParent, WX_GRID *aGrid)
The SIMULATOR_FRAME holds the main user-interface for running simulations.
const wxRealPoint & GetCoords() const
void SetCoordX(double aValue)
int GetSimOptions() const
void SetSimOptions(int aOptions)
bool SetSimCommand(const wxString &aCommand)
const wxString & GetSimCommand() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
bool StartsWith(const wxString &aTerm)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
static TOOL_ACTION simCommand
static TOOL_ACTION openWorkbook
static TOOL_ACTION stopSimulation
static TOOL_ACTION toggleLegend
static TOOL_ACTION saveWorkbook
static TOOL_ACTION saveWorkbookAs
static TOOL_ACTION exportPlotAsCSV
static TOOL_ACTION simTune
static TOOL_ACTION toggleDarkModePlots
static TOOL_ACTION exportPlotAsPNG
static TOOL_ACTION showNetlist
static TOOL_ACTION simProbe
static TOOL_ACTION toggleDottedSecondary
static TOOL_ACTION runSimulation
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
WX_GRID * m_grid
I don't own the grid, but he owns me.
A color representation with 4 components: red, green, blue, alpha.
wxString ToCSSString() const
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Hold a translatable error message and may be used when throwing exceptions containing a translated er...
const wxString What() const
void doPopupSelection(wxCommandEvent &event) override
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
SIMULATOR_FRAME * m_parent
MEASUREMENTS_GRID_TRICKS(SIMULATOR_FRAME *aParent, WX_GRID *aGrid)
@ OPTION_SAVE_ALL_CURRENTS
@ OPTION_SAVE_ALL_VOLTAGES
@ OPTION_SAVE_ALL_DISSIPATIONS
@ OPTION_ADJUST_INCLUDE_PATHS
const SPICE_ITEM * FindItem(const std::string &aRefName) const
Find and return the item corresponding to aRefName.
Special netlist exporter flavor that allows one to override simulation commands.
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Return simulation type basing on a simulation command directive.
Container for Ngspice simulator settings.
void SetModelMode(NGSPICE_MODEL_MODE aMode)
A singleton reporter that reports to nowhere.
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
A pure virtual class used to derive REPORTER objects from.
Holds all the data relating to one schematic.
void SetOperatingPoint(const wxString &aSignal, double aValue)
Set operating points from a .op simulation.
void ClearOperatingPoints()
Clear operating points from a .op simulation.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Schematic editor (Eeschema) main window.
void RefreshOperatingPointDisplay()
Refresh the display of any operaintg points.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
SCHEMATIC & Schematic() const
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_ITEM * GetItem(const KIID &aID) const
Fetch a SCH_ITEM by ID.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void doPopupSelection(wxCommandEvent &event) override
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
SIMULATOR_FRAME * m_parent
SIGNALS_GRID_TRICKS(SIMULATOR_FRAME *aParent, WX_GRID *aGrid)
Handle actions for the various symbol editor and viewers.
Class SIMULATOR_FRAME_BASE.
wxSplitterWindow * m_splitterMeasurements
wxBoxSizer * m_sizerTuners
wxSplitterWindow * m_splitterCursors
wxTextCtrl * m_simConsole
SIM_NOTEBOOK * m_plotNotebook
wxSplitterWindow * m_splitterPlotAndConsole
WX_GRID * m_measurementsGrid
wxSplitterWindow * m_splitterLeftRight
wxSplitterWindow * m_splitterSignals
The SIMULATOR_FRAME holds the main user-interface for running simulations.
SPICE_VALUE_FORMAT GetMeasureFormat(int aRow) const
Get/Set the format of a value in the measurements grid.
void rebuildSignalsList()
Rebuild the list of signals available from the netlist.
void ShowChangedLanguage() override
bool canCloseWindow(wxCloseEvent &aEvent) override
void doAddTrace(const wxString &aName, SIM_TRACE_TYPE aType)
Add a new trace to the current plot.
void onSimFinished(wxCommandEvent &aEvent)
void onSimUpdate(wxCommandEvent &aEvent)
void onPlotClose(wxAuiNotebookEvent &event) override
void onSimReport(wxCommandEvent &aEvent)
wxString GetCurrentSimCommand() const
SIM_PANEL_BASE * NewPlotPanel(const wxString &aSimCommand, int aSimOptions)
Create a new plot tab for a given simulation type.
void AddMeasurement(const wxString &aCmd)
Add a measurement to the measurements grid.
SIM_TRACE_TYPE getXAxisType(SIM_TYPE aType) const
Return X axis for a given simulation type.
void initWorkbook()
Load the currently active workbook stored in the project settings.
std::shared_ptr< NGSPICE_CIRCUIT_MODEL > m_circuitModel
void onExit(wxCommandEvent &event)
std::vector< wxString > m_signals
std::shared_ptr< SPICE_SIMULATOR > m_simulator
SPICE_VALUE_FORMAT GetCursorFormat(int aCursorId, int aValueCol) const
Get/Set the number of significant digits and the range for formatting a cursor value.
void UpdateMeasurement(int aRow)
Update a measurement in the measurements grid.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
std::map< int, wxString > m_userDefinedSignals
void updateSignalsGrid()
Update the values in the signals grid.
void OnFilterMouseMoved(wxMouseEvent &aEvent) override
void AddCurrentTrace(const wxString &aDeviceName)
Add a current trace for a given device to the current plot.
void onPlotClosed(wxAuiNotebookEvent &event) override
int m_splitterPlotAndConsoleSashPosition
void OnModify() override
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
bool SaveWorkbook(const wxString &aPath)
Save plot, signal, cursor, measurement, etc.
void updateCursors()
Update the cursor values (in the grid) and graphics (in the plot window).
std::list< TUNER_SLIDER * > m_tuners
SPICE expressions need quoted versions of the netnames since KiCad allows '-' and '/' in netnames.
std::map< wxString, wxString > m_quotedNetnames
Panel that was used as the most recent one for simulations.
void onSignalsGridCellChanged(wxGridEvent &aEvent) override
void doCloseWindow() override
void RemoveTuner(TUNER_SLIDER *aTuner)
Remove an existing tuner.
void AddVoltageTrace(const wxString &aNetName)
Add a voltage trace for a given net to the current plot.
void onCursorUpdate(wxCommandEvent &aEvent)
void onPlotChanged(wxAuiNotebookEvent &event) override
void ToggleDarkModePlots()
Toggle dark-mode of the plot tabs.
SIM_THREAD_REPORTER * m_reporter
void AddTuner(const SCH_SHEET_PATH &aSheetPath, SCH_SYMBOL *aSymbol)
Add a tuner for a symbol.
bool LoadSimulator()
Check and load the current netlist into the simulator.
void onSimStarted(wxCommandEvent &aEvent)
SIM_PANEL_BASE * getCurrentPlotWindow() const
Return the currently opened plot panel (or NULL if there is none).
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SIM_PLOT_PANEL * GetCurrentPlot() const
Return the current tab (or NULL if there is none).
wxString vectorNameFromSignalName(const wxString &aSignalName, int *aTraceType)
Get the simulator output vector name for a given signal name and type.
void onMeasurementsGridCellChanged(wxGridEvent &aEvent) override
int m_splitterSignalsSashPosition
void updateTitle()
Set the main window title bar text.
void parseTraceParams(SIM_PLOT_PANEL *aPlotPanel, TRACE *aTrace, const wxString &aSignalName, const wxString &aParams)
void DeleteMeasurement(int aRow)
Delete a row from the measurements grid.
void onNotebookModified(wxCommandEvent &event)
const NGSPICE_CIRCUIT_MODEL * GetExporter() const
Return the netlist exporter object used for simulations.
int GetCurrentOptions() const
bool LoadWorkbook(const wxString &aPath)
Load plot, signal, cursor, measurement, etc.
void SetMeasureFormat(int aRow, const SPICE_VALUE_FORMAT &aFormat)
void applyUserDefinedSignals()
Apply user-defined signals to the SPICE session.
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Return a pointer to the window settings for this frame.
void onCursorsGridCellChanged(wxGridEvent &aEvent) override
void updateTrace(const wxString &aVectorName, int aTraceType, SIM_PLOT_PANEL *aPlotPanel)
Update a trace in a particular SIM_PLOT_PANEL.
bool EditSimCommand()
Shows a dialog for editing the current tab's simulation command, or creating a new tab with a differe...
int m_splitterTuneValuesSashPosition
int m_splitterLeftRightSashPosition
SPICE_VALUE_FORMAT m_cursorFormats[3][2]
void SetUserDefinedSignals(const std::map< int, wxString > &aSignals)
void OnFilterText(wxCommandEvent &aEvent) override
SIM_PANEL_BASE * m_lastSimPlot
void applyTuners()
Apply component values specified using tuner sliders to the current netlist.
void rebuildSignalsGrid(wxString aFilter)
Rebuild the filtered list of signals in the signals grid.
void onPlotDragged(wxAuiNotebookEvent &event) override
void setSubWindowsSashSize()
int m_splitterCursorsSashPosition
unsigned int m_plotNumber
SCH_EDIT_FRAME * m_schematicFrame
void SetCursorFormat(int aCursorId, int aValueCol, const SPICE_VALUE_FORMAT &aFormat)
void UpdateTunerValue(const SCH_SHEET_PATH &aSheetPath, const KIID &aSymbol, const wxString &aRef, const wxString &aValue)
Safely update a field of the associated symbol without dereferencing the symbol.
static std::shared_ptr< SPICE_SIMULATOR > CreateInstance(const std::string &aName)
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< LIB_PIN * > &aPins)
virtual const PARAM * GetTunerParam() const
const SPICE_GENERATOR & SpiceGenerator() const
void SetParamValue(int aParamIndex, const std::string &aValue, SIM_VALUE::NOTATION aNotation=SIM_VALUE::NOTATION::SI)
void WriteFields(std::vector< T > &aFields) const
bool DeleteAllPages() override
bool AddPage(wxWindow *aPage, const wxString &aCaption, bool aSelect=false, const wxBitmap &aBitmap=wxNullBitmap)
static bool IsPlottable(SIM_TYPE aSimType)
const wxString & GetSimCommand() const
void SetSimCommand(const wxString &aSimCommand)
void SetSimOptions(int aOptions)
int GetSimOptions() const
static void FillDefaultColorList(bool aWhiteBg)
Fills m_colorList by a default set of colors.
wxPoint GetLegendPosition() const
void UpdateTraceStyle(TRACE *trace)
Update plot colors.
void ResetScales()
Update trace line style.
wxString GetLabelY2() const
wxString GetUnitsX() const
TRACE * AddTrace(const wxString &aVectorName, int aType)
wxString GetLabelY3() const
bool DeleteTrace(const wxString &aVectorName, int aTraceType)
bool IsLegendShown() const
TRACE * GetTrace(const wxString &aVecName, int aType) const
wxString GetUnitsY3() const
void SetDottedSecondary(bool aEnable)
Draw secondary signal traces (current or phase) with dotted lines.
bool GetDottedSecondary() const
Toggle cursor for a particular trace.
const std::map< wxString, TRACE * > & GetTraces() const
void SetTraceData(TRACE *aTrace, unsigned int aPoints, const double *aX, const double *aY)
wxString GetUnitsY2() const
mpWindow * GetPlotWin() const
void ShowGrid(bool aEnable)
wxString GetLabelY1() const
wxString GetUnitsY1() const
wxString GetLabelX() const
SIMULATOR_FRAME * m_parent
SIM_THREAD_REPORTER(SIMULATOR_FRAME *aParent)
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
void OnSimStateChange(SPICE_SIMULATOR *aObject, SIM_STATE aNewState) override
bool HasMessage() const override
Returns true if the reporter client is non-empty.
virtual std::string TunerCommand(const SPICE_ITEM &aItem, double aValue) const
Interface to receive simulation updates from SPICE_SIMULATOR class.
wxString GetWorkbookFilename() const
Helper class to recognize Spice formatted values.
wxString ToString() const
Return string value as when converting double to string (e.g.
wxString ToSpiceString() const
Return string value in Spice format (e.g.
SIMULATOR_FRAME * m_frame
~SUPPRESS_GRID_CELL_EVENTS()
SUPPRESS_GRID_CELL_EVENTS(SIMULATOR_FRAME *aFrame)
void SetTraceColour(const wxColour &aColour)
void SetCursor(int aCursorId, CURSOR *aCursor)
wxColour GetTraceColour() const
Custom widget to handle quick component values modification and simulation on the fly.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
A wrapper for reporting to a wxString object.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
const wxString & GetName() const
Get layer name.
const wxPen & GetPen() const
Get pen set for this layer.
void UpdateAll()
Refresh display.
void EnableMouseWheelPan(bool enabled)
Enable/disable trackpad friendly panning (2-axis scroll wheel)
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
Abstract pattern-matching tool and implementations.
@ GRIDTRICKS_FIRST_CLIENT_ID
const std::string WorkbookFileExtension
wxFont GetStatusFont(wxWindow *aWindow)
SIM_TYPE
< Possible simulation types
#define DISPLAY_LOAD_ERROR(fmt)
wxDEFINE_EVENT(EVT_SIM_UPDATE, wxCommandEvent)
wxString vectorNameFromSignalId(int aUserDefinedSignalId)
MEASUREMENTS_GIRD_COLUMNS
@ MYID_DELETE_MEASUREMENT
SIM_TRACE_TYPE operator|(SIM_TRACE_TYPE aFirst, SIM_TRACE_TYPE aSecond)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
int measurements_panel_height
Stores the common settings that are saved and loaded for each window / frame.
Definition of file extensions used in Kicad.