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(); SIM_TYPE simType = m_exporter->GetSimType();
wxString spiceVector = m_exporter->ComponentToVector( aName, aType, aParam ); 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 ) ) if( !SIM_PANEL_BASE::IsPlottable( simType ) )
{ {
// There is no plot to be shown // 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++ ) 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, std::vector<double> sub_x( data_x.begin() + offset,
data_x.begin() + offset + inner ); data_x.begin() + offset + inner );
std::vector<double> sub_y( data_y.begin() + offset, std::vector<double> sub_y( data_y.begin() + offset,
data_y.begin() + offset + inner ); data_y.begin() + offset + inner );
m_workbook->AddTrace( aPlotPanel, name, inner, sub_x.data(), sub_y.data(), aType, m_workbook->AddTrace( aPlotPanel, name, aName, inner, sub_x.data(), sub_y.data(),
aParam ); aType, aParam );
v = v + source2.m_vincrement; v = v + source2.m_vincrement;
offset += inner; 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; return true;
} }

View File

@ -178,8 +178,10 @@ private:
* Update plot in a particular SIM_PLOT_PANEL. If the panel does not contain * Update plot in a particular SIM_PLOT_PANEL. If the panel does not contain
* the plot, it will be added. * the plot, it will be added.
* *
* @param aDescriptor contains the plot description. * @param aName is the device/net name.
* @param aPanel is the panel that should receive the update. * @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. * @return True if a plot was successfully added/updated.
*/ */
bool updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam, 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, bool SIM_PLOT_PANEL::addTrace( const wxString& aTitle, const wxString& aName, int aPoints,
const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam ) const double* aX, const double* aY, SIM_PLOT_TYPE aType,
const wxString& aParam )
{ {
TRACE* trace = nullptr; TRACE* trace = nullptr;
wxString name = aName; wxString name = aTitle;
if( aType & SPT_AC_MAG )
name += " (mag)";
else if( aType & SPT_AC_PHASE )
name += " (phase)";
// Find previous entry, if there is one // Find previous entry, if there is one
auto prev = m_traces.find( name ); auto prev = m_traces.find( name );

View File

@ -290,8 +290,8 @@ public:
} }
protected: protected:
bool addTrace( const wxString& aName, int aPoints, const double* aX, const double* aY, bool addTrace( const wxString& aTitle, const wxString& aName, int aPoints, const double* aX,
SIM_PLOT_TYPE aType, const wxString& aParam ); const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam );
bool deleteTrace( const wxString& aName ); 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 bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle,
double* aX, const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam ) 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 ); setModified( res );
return res; return res;
} }

View File

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