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" && net.first != "0" )
58  m_signals->Append( wxString::Format( "V(%s)", net.first ) );
59  }
60 
61  auto simType = m_exporter->GetSimType();
62 
63  if( simType == ST_TRANSIENT || simType == ST_DC )
64  {
65  for( const auto& item : m_exporter->GetSpiceItems() )
66  {
67  // Add all possible currents for the primitive
68  for( const auto& current :
70  {
71  m_signals->Append( wxString::Format( "%s(%s)", current, item.m_refName ) );
72  }
73  }
74  }
75  }
76 
77  bool success = DIALOG_SIGNAL_LIST_BASE::TransferDataToWindow();
78 
79  // Now all widgets have the size fixed, call FinishDialogSettings
81 
82  return success;
83 }
84 
85 
87 {
88  for( unsigned int i = 0; i < m_signals->GetCount(); ++i )
89  {
90  if( m_signals->IsSelected( i ) )
91  {
92  const wxString& plotName = m_signals->GetString( i );
93 
94  // Get the part in the parentheses
95  wxString name = plotName.AfterFirst( '(' ).BeforeLast( ')' );
96 
97  if( plotName[0] == 'V' )
98  {
99  m_plotFrame->AddVoltagePlot( name );
100  }
101  else if( plotName[0] == 'I' )
102  {
103  m_plotFrame->AddCurrentPlot( name, plotName.BeforeFirst( '(' ) );
104  }
105  else
106  {
107  wxASSERT_MSG( false, "Unhandled plot type" );
108  }
109  }
110  }
111 }
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.
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
bool TransferDataFromWindow() override
Implementing SIM_PLOT_FRAME_BASE.
const char * name
Definition: DXF_plotter.cpp:61
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
size_t i
Definition: json11.cpp:597
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.