Browse Source

Remove tuners for components that were removed

pull/3/merge
Maciej Suminski 9 years ago
parent
commit
672fd76995
  1. 31
      eeschema/netlist_exporters/netlist_exporter_pspice.h
  2. 33
      eeschema/sim/sim_plot_frame.cpp
  3. 8
      eeschema/sim/sim_plot_frame.h

31
eeschema/netlist_exporters/netlist_exporter_pspice.h

@ -63,6 +63,22 @@ enum SPICE_PRIMITIVE {
/// @todo add NET_ADJUST_INCLUDE_PATHS & NET_ADJUST_PASSIVE_VALS checkboxes in the netlist export dialog
struct SPICE_ITEM
{
SCH_COMPONENT* m_parent;
wxChar m_primitive;
wxString m_model;
wxString m_refName;
bool m_enabled;
///> Array containing Standard Pin Name
std::vector<NETLIST_OBJECT*> m_pins;
///> Numeric indices into m_SortedComponentPinList
std::vector<int> m_pinSequence;
};
/**
* Class NETLIST_EXPORTER_PSPICE
* generates a PSPICE compatible netlist
@ -80,21 +96,6 @@ public:
{
}
struct SPICE_ITEM
{
SCH_COMPONENT* m_parent;
wxChar m_primitive;
wxString m_model;
wxString m_refName;
bool m_enabled;
///> Array containing Standard Pin Name
std::vector<NETLIST_OBJECT*> m_pins;
///> Numeric indices into m_SortedComponentPinList
std::vector<int> m_pinSequence;
};
typedef std::list<SPICE_ITEM> SPICE_ITEM_LIST;
///> Net name to node number mapping

33
eeschema/sim/sim_plot_frame.cpp

@ -172,6 +172,7 @@ void SIM_PLOT_FRAME::StartSimulation()
m_simulator->SetReporter( new SIM_THREAD_REPORTER( this ) );
m_simulator->Init();
m_simulator->LoadNetlist( formatter.GetString() );
updateTuners();
applyTuners();
m_simulator->Run();
@ -260,9 +261,11 @@ void SIM_PLOT_FRAME::AddTuner( SCH_COMPONENT* aComponent )
}
void SIM_PLOT_FRAME::RemoveTuner( TUNER_SLIDER* aTuner )
void SIM_PLOT_FRAME::RemoveTuner( TUNER_SLIDER* aTuner, bool aErase )
{
m_tuners.remove( aTuner );
if( aErase )
m_tuners.remove( aTuner );
aTuner->Destroy();
m_sidePanel->Layout();
}
@ -433,6 +436,32 @@ void SIM_PLOT_FRAME::updateCursors()
}
void SIM_PLOT_FRAME::updateTuners()
{
const auto& spiceItems = m_exporter->GetSpiceItems();
for( auto it = m_tuners.begin(); it != m_tuners.end(); /* iteration inside the loop */ )
{
const wxString& ref = (*it)->GetComponentName();
if( std::find_if( spiceItems.begin(), spiceItems.end(), [&]( const SPICE_ITEM& item )
{
return item.m_refName == ref;
}) == spiceItems.end() )
{
// The component does not exist anymore, remove the associated tuner
TUNER_SLIDER* tuner = *it;
it = m_tuners.erase( it );
RemoveTuner( tuner, false );
}
else
{
++it;
}
}
}
void SIM_PLOT_FRAME::applyTuners()
{
for( auto& tuner : m_tuners )

8
eeschema/sim/sim_plot_frame.h

@ -131,7 +131,7 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
void AddCurrentPlot( const wxString& aDeviceName, const wxString& aParam );
void AddTuner( SCH_COMPONENT* aComponent );
void RemoveTuner( TUNER_SLIDER* aTuner );
void RemoveTuner( TUNER_SLIDER* aTuner, bool aErase = true );
SIM_PLOT_PANEL* CurrentPlot() const;
@ -172,6 +172,12 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
*/
void updateCursors();
/**
* @brief Filters out tuners for components that do not exist anymore.
* Decisions are based on the current NETLIST_EXPORTER data.
*/
void updateTuners();
/**
* @brief Applies component values specified using tunder sliders to the current netlist.
*/

Loading…
Cancel
Save