KiCad PCB EDA Suite
dialog_signal_list.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * https://www.gnu.org/licenses/gpl-3.0.html
20  * or you may search the http://www.gnu.org website for the version 3 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include "dialog_signal_list.h"
26 #include <sim/sim_plot_frame.h>
27 
29 
31  : DIALOG_SIGNAL_LIST_BASE( aParent ), m_plotFrame( aParent ), m_exporter( aExporter )
32 {
33 
34 }
35 
36 
38 {
39  if( !DIALOG_SIGNAL_LIST_BASE::TransferDataFromWindow() )
40  return false;
41 
43 
44  return true;
45 }
46 
47 
49 {
50  // Create a list of possible signals
52  if( m_exporter )
53  {
54  // Voltage list
55  for( const auto& net : m_exporter->GetNetIndexMap() )
56  {
57  if( net.first != "GND" )
58  m_signals->Append( wxString::Format( "V(%s)", net.first ) );
59  }
60 
61  // For some reason, it is not possible to plot currents in any but transient analysis
63  {
64  for( const auto& item : m_exporter->GetSpiceItems() )
65  {
66  // Add all possible currents for the primitive
67  for( const auto& current :
69  {
70  m_signals->Append( wxString::Format( "%s(%s)", current, item.m_refName ) );
71  }
72  }
73  }
74  }
75 
76  bool success = DIALOG_SIGNAL_LIST_BASE::TransferDataToWindow();
77 
78  // Now all widgets have the size fixed, call FinishDialogSettings
80 
81  return success;
82 }
83 
84 
86 {
87  for( unsigned int i = 0; i < m_signals->GetCount(); ++i )
88  {
89  if( m_signals->IsSelected( i ) )
90  {
91  const wxString& plotName = m_signals->GetString( i );
92 
93  // Get the part in the parentheses
94  wxString name = plotName.AfterFirst( '(' ).BeforeLast( ')' );
95 
96  if( plotName[0] == 'V' )
97  {
98  m_plotFrame->AddVoltagePlot( name );
99  }
100  else if( plotName[0] == 'I' )
101  {
102  m_plotFrame->AddCurrentPlot( name, plotName.BeforeFirst( '(' ) );
103  }
104  else
105  {
106  wxASSERT_MSG( false, "Unhandled plot type" );
107  }
108  }
109  }
110 }
const NET_INDEX_MAP & GetNetIndexMap() const
Returns a map of circuit nodes to net names.
NETLIST_EXPORTER_PSPICE_SIM * m_exporter
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SIGNAL_LIST_BASE.
void AddVoltagePlot(const wxString &aNetName)
Adds a voltage plot for a given net name.
void AddCurrentPlot(const wxString &aDeviceName, const wxString &aParam)
Adds a current plot for a particular device.
DIALOG_SIGNAL_LIST(SIM_PLOT_FRAME *aParent, NETLIST_EXPORTER_PSPICE_SIM *aExporter)
static const std::vector< wxString > & GetCurrents(SPICE_PRIMITIVE aPrimitive)
Returns a list of currents that can be probed in a Spice primitive.
const SPICE_ITEM_LIST & GetSpiceItems() const
Returns list of items representing schematic components in the Spice world.
bool TransferDataFromWindow() override
Implementing SIM_PLOT_FRAME_BASE.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
SPICE_PRIMITIVE
Basic Spice component primitives
SIM_PLOT_FRAME * m_plotFrame
bool TransferDataToWindow() override
SIM_TYPE GetSimType()
Returns simulation type basing on the simulation command directives.
Special netlist exporter flavor that allows to override simulation commands.