eeschema, sim: fix wrong names of the signals

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9062
This commit is contained in:
Sylwester Kocjan 2021-09-07 23:18:22 +02:00
parent f013dbc7c4
commit f9c5c97f74
6 changed files with 29 additions and 21 deletions

View File

@ -695,6 +695,12 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, con
SIM_TYPE simType = m_exporter->GetSimType();
wxString spiceVector = m_exporter->ComponentToVector( aName, aType, aParam );
wxString plotTitle = wxString::Format( "%s(%s)", aParam, aName );
if( aType & SPT_AC_MAG )
plotTitle += " (mag)";
else if( aType & SPT_AC_PHASE )
plotTitle += " (phase)";
if( !SIM_PANEL_BASE::IsPlottable( simType ) )
{
// There is no plot to be shown
@ -768,15 +774,16 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, con
for( size_t idx = 0; idx <= outer; idx++ )
{
name = wxString::Format( "%s (%s = %s V)", aName, source2.m_source, v.ToString() );
name = wxString::Format( "%s (%s = %s V)", plotTitle, source2.m_source,
v.ToString() );
std::vector<double> sub_x( data_x.begin() + offset,
data_x.begin() + offset + inner );
std::vector<double> sub_y( data_y.begin() + offset,
data_y.begin() + offset + inner );
m_workbook->AddTrace( aPlotPanel, name, inner, sub_x.data(), sub_y.data(), aType,
aParam );
m_workbook->AddTrace( aPlotPanel, name, aName, inner, sub_x.data(), sub_y.data(),
aType, aParam );
v = v + source2.m_vincrement;
offset += inner;
@ -786,7 +793,8 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, con
}
}
m_workbook->AddTrace( aPlotPanel, aName, size, data_x.data(), data_y.data(), aType, aParam );
m_workbook->AddTrace( aPlotPanel, plotTitle, aName, size, data_x.data(), data_y.data(), aType,
aParam );
return true;
}

View File

@ -178,8 +178,10 @@ private:
* Update plot in a particular SIM_PLOT_PANEL. If the panel does not contain
* the plot, it will be added.
*
* @param aDescriptor contains the plot description.
* @param aPanel is the panel that should receive the update.
* @param aName is the device/net name.
* @param aType describes the type of plot.
* @param aParam is the parameter for the device/net (e.g. I, Id, V).
* @param aPlotPanel is the panel that should receive the update.
* @return True if a plot was successfully added/updated.
*/
bool updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam,

View File

@ -449,16 +449,12 @@ void SIM_PLOT_PANEL::UpdateTraceStyle( TRACE* trace )
}
bool SIM_PLOT_PANEL::addTrace( const wxString& aName, int aPoints, const double* aX,
const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam )
bool SIM_PLOT_PANEL::addTrace( const wxString& aTitle, const wxString& aName, int aPoints,
const double* aX, const double* aY, SIM_PLOT_TYPE aType,
const wxString& aParam )
{
TRACE* trace = nullptr;
wxString name = aName;
if( aType & SPT_AC_MAG )
name += " (mag)";
else if( aType & SPT_AC_PHASE )
name += " (phase)";
wxString name = aTitle;
// Find previous entry, if there is one
auto prev = m_traces.find( name );

View File

@ -290,8 +290,8 @@ public:
}
protected:
bool addTrace( const wxString& aName, int aPoints, const double* aX, const double* aY,
SIM_PLOT_TYPE aType, const wxString& aParam );
bool addTrace( const wxString& aTitle, const wxString& aName, int aPoints, const double* aX,
const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam );
bool deleteTrace( const wxString& aName );

View File

@ -70,10 +70,11 @@ bool SIM_WORKBOOK::DeletePage( size_t page )
}
bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName, int aPoints, const
double* aX, const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam )
bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle,
const wxString& aName, int aPoints, const double* aX, const double* aY,
SIM_PLOT_TYPE aType, const wxString& aParam )
{
bool res = aPlotPanel->addTrace( aName, aPoints, aX, aY, aType, aParam );
bool res = aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType, aParam );
setModified( res );
return res;
}

View File

@ -48,8 +48,9 @@ public:
// Custom methods
bool AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName, int aPoints, const double*
aX, const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam );
bool AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle, const wxString& aName,
int aPoints, const double* aX, const double* aY, SIM_PLOT_TYPE aType,
const wxString& aParam );
bool DeleteTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName );
void SetSimCommand( SIM_PANEL_BASE* aPlotPanel, const wxString& aSimCommand )