2021-05-04 22:35:04 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sim/sim_workbook.h>
|
|
|
|
|
|
|
|
TRACE_DESC::TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxString& aName,
|
|
|
|
SIM_PLOT_TYPE aType, const wxString& aParam ) :
|
|
|
|
m_name( aName ),
|
|
|
|
m_type( aType ),
|
|
|
|
m_param( aParam )
|
|
|
|
{
|
|
|
|
// Title generation
|
|
|
|
m_title = wxString::Format( "%s(%s)", aParam, aName );
|
|
|
|
|
|
|
|
if( aType & SPT_AC_MAG )
|
|
|
|
m_title += " (mag)";
|
|
|
|
else if( aType & SPT_AC_PHASE )
|
|
|
|
m_title += " (phase)";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SIM_WORKBOOK::SIM_WORKBOOK() :
|
2021-05-09 23:32:49 +00:00
|
|
|
m_flagModified( false )
|
2021-05-04 22:35:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SIM_WORKBOOK::Clear()
|
|
|
|
{
|
|
|
|
m_plots.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SIM_WORKBOOK::AddPlotPanel( SIM_PANEL_BASE* aPlotPanel )
|
|
|
|
{
|
|
|
|
wxASSERT( m_plots.count( aPlotPanel ) == 0 );
|
|
|
|
m_plots[aPlotPanel] = PLOT_INFO();
|
|
|
|
|
2021-05-09 23:32:49 +00:00
|
|
|
m_flagModified = true;
|
2021-05-04 22:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SIM_WORKBOOK::RemovePlotPanel( SIM_PANEL_BASE* aPlotPanel )
|
|
|
|
{
|
|
|
|
wxASSERT( m_plots.count( aPlotPanel ) == 1 );
|
|
|
|
m_plots.erase( aPlotPanel );
|
|
|
|
|
2021-05-09 23:32:49 +00:00
|
|
|
m_flagModified = true;
|
2021-05-04 22:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-11 23:27:34 +00:00
|
|
|
std::vector<const SIM_PANEL_BASE*> SIM_WORKBOOK::GetSortedPlotPanels() const
|
|
|
|
{
|
|
|
|
std::vector<const SIM_PANEL_BASE*> plotPanels;
|
|
|
|
|
|
|
|
for( const auto& plot : m_plots )
|
|
|
|
plotPanels.push_back( plot.first );
|
|
|
|
|
|
|
|
std::sort( plotPanels.begin(), plotPanels.end(),
|
|
|
|
[&]( const SIM_PANEL_BASE*& a, const SIM_PANEL_BASE*& b )
|
|
|
|
{
|
|
|
|
return m_plots.at( a ).pos < m_plots.at( b ).pos;
|
|
|
|
});
|
|
|
|
|
|
|
|
return plotPanels;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-04 22:35:04 +00:00
|
|
|
void SIM_WORKBOOK::AddTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName,
|
|
|
|
const TRACE_DESC& aTrace )
|
|
|
|
{
|
2021-05-09 23:32:49 +00:00
|
|
|
m_plots.at( aPlotPanel ).m_traces.insert(
|
2021-05-04 22:35:04 +00:00
|
|
|
std::make_pair( aName, aTrace ) );
|
|
|
|
|
2021-05-09 23:32:49 +00:00
|
|
|
m_flagModified = true;
|
2021-05-04 22:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SIM_WORKBOOK::RemoveTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName )
|
|
|
|
{
|
2021-05-09 23:32:49 +00:00
|
|
|
auto& traceMap = m_plots.at( aPlotPanel ).m_traces;
|
2021-05-04 22:35:04 +00:00
|
|
|
auto traceIt = traceMap.find( aName );
|
|
|
|
wxASSERT( traceIt != traceMap.end() );
|
|
|
|
traceMap.erase( traceIt );
|
|
|
|
|
2021-05-09 23:32:49 +00:00
|
|
|
m_flagModified = true;
|
2021-05-04 22:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SIM_WORKBOOK::TRACE_MAP::const_iterator SIM_WORKBOOK::RemoveTrace( const SIM_PANEL_BASE* aPlotPanel,
|
|
|
|
TRACE_MAP::const_iterator aIt )
|
|
|
|
{
|
2021-05-09 23:32:49 +00:00
|
|
|
m_flagModified = true;
|
2021-05-04 22:35:04 +00:00
|
|
|
return m_plots.at( aPlotPanel ).m_traces.erase( aIt );
|
|
|
|
}
|