Eeschema: simulation: allow adding signals by name like V(/out) or I(R1)

NEW: A text entry allows adding signals by name. This includes vectors
not in the signal list, which is useful for plotting calculated vectors
like `let AB=V(a)*V(b)`. It's also a faster way to add a signal if you
know its name already.

Fixes: lp:1851373
* https://bugs.launchpad.net/kicad/+bug/1851373
This commit is contained in:
Jonatan Liljedahl 2019-11-07 09:47:12 +01:00 committed by Wayne Stambaugh
parent bf8bb17f42
commit c71202d143
5 changed files with 206 additions and 107 deletions

View File

@ -86,6 +86,37 @@ bool DIALOG_SIGNAL_LIST::TransferDataToWindow()
} }
bool DIALOG_SIGNAL_LIST::addSignalToPlotFrame( const wxString& aPlotName )
{
// Get the part in the parentheses
wxString name = aPlotName.AfterFirst( '(' ).BeforeLast( ')' );
if( !name.IsEmpty() )
{
wxUniChar firstChar = aPlotName[0];
if( firstChar == 'V' || firstChar == 'v' )
{
m_plotFrame->AddVoltagePlot( name );
}
else if( firstChar == 'I' || firstChar == 'i' )
{
m_plotFrame->AddCurrentPlot( name, aPlotName.BeforeFirst( '(' ) );
}
else
{
return false;
}
}
else
{
return false;
}
return true;
}
void DIALOG_SIGNAL_LIST::addSelectionToPlotFrame() void DIALOG_SIGNAL_LIST::addSelectionToPlotFrame()
{ {
for( unsigned int i = 0; i < m_signals->GetCount(); ++i ) for( unsigned int i = 0; i < m_signals->GetCount(); ++i )
@ -93,22 +124,19 @@ void DIALOG_SIGNAL_LIST::addSelectionToPlotFrame()
if( m_signals->IsSelected( i ) ) if( m_signals->IsSelected( i ) )
{ {
const wxString& plotName = m_signals->GetString( i ); const wxString& plotName = m_signals->GetString( i );
if( !addSignalToPlotFrame( plotName ) )
// Get the part in the parentheses
wxString name = plotName.AfterFirst( '(' ).BeforeLast( ')' );
if( plotName[0] == 'V' )
{
m_plotFrame->AddVoltagePlot( name );
}
else if( plotName[0] == 'I' )
{
m_plotFrame->AddCurrentPlot( name, plotName.BeforeFirst( '(' ) );
}
else
{
wxASSERT_MSG( false, "Unhandled plot type" ); wxASSERT_MSG( false, "Unhandled plot type" );
}
} }
} }
// Add manually entered signal, if any
const wxString& plotName = m_signalEntry->GetValue();
if( !plotName.IsEmpty() )
{
if( !addSignalToPlotFrame( plotName ) )
m_plotFrame->AddVoltagePlot( plotName ); // Assume it's a V plot by default
m_signalEntry->SetSelection( -1, -1 );
}
} }

View File

@ -45,6 +45,7 @@ private:
} }
void addSelectionToPlotFrame(); void addSelectionToPlotFrame();
bool addSignalToPlotFrame( const wxString& aPlotName );
SIM_PLOT_FRAME* m_plotFrame; SIM_PLOT_FRAME* m_plotFrame;
NETLIST_EXPORTER_PSPICE_SIM* m_exporter; NETLIST_EXPORTER_PSPICE_SIM* m_exporter;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -21,6 +21,13 @@ DIALOG_SIGNAL_LIST_BASE::DIALOG_SIGNAL_LIST_BASE( wxWindow* parent, wxWindowID i
bSizer6->Add( m_signals, 1, wxALL|wxEXPAND, 5 ); bSizer6->Add( m_signals, 1, wxALL|wxEXPAND, 5 );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Add signal by name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bSizer6->Add( m_staticText1, 0, wxALL, 5 );
m_signalEntry = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
bSizer6->Add( m_signalEntry, 0, wxALL|wxEXPAND, 5 );
m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK ); m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK ); m_sdbSizer->AddButton( m_sdbSizerOK );
@ -39,11 +46,13 @@ DIALOG_SIGNAL_LIST_BASE::DIALOG_SIGNAL_LIST_BASE( wxWindow* parent, wxWindowID i
// Connect Events // Connect Events
m_signals->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_SIGNAL_LIST_BASE::onSignalAdd ), NULL, this ); m_signals->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_SIGNAL_LIST_BASE::onSignalAdd ), NULL, this );
m_signalEntry->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIGNAL_LIST_BASE::onSignalAdd ), NULL, this );
} }
DIALOG_SIGNAL_LIST_BASE::~DIALOG_SIGNAL_LIST_BASE() DIALOG_SIGNAL_LIST_BASE::~DIALOG_SIGNAL_LIST_BASE()
{ {
// Disconnect Events // Disconnect Events
m_signals->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_SIGNAL_LIST_BASE::onSignalAdd ), NULL, this ); m_signals->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_SIGNAL_LIST_BASE::onSignalAdd ), NULL, this );
m_signalEntry->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_SIGNAL_LIST_BASE::onSignalAdd ), NULL, this );
} }

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project> <wxFormBuilder_Project>
<FileVersion major="1" minor="13" /> <FileVersion major="1" minor="15" />
<object class="Project" expanded="1"> <object class="Project" expanded="1">
<property name="class_decoration"></property> <property name="class_decoration"></property>
<property name="code_generation">C++</property> <property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">dialog_signal_list_base</property> <property name="file">dialog_signal_list_base</property>
<property name="first_id">1000</property> <property name="first_id">1000</property>
<property name="help_provider">none</property> <property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property> <property name="internationalize">1</property>
<property name="name">DIALOG_SIGNAL_LIST_BASE</property> <property name="name">DIALOG_SIGNAL_LIST_BASE</property>
<property name="namespace"></property> <property name="namespace"></property>
@ -52,42 +53,6 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizer6</property> <property name="name">bSizer6</property>
@ -154,31 +119,133 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnListBox"></event>
<event name="OnListBoxDClick">onSignalAdd</event> <event name="OnListBoxDClick">onSignalAdd</event>
<event name="OnMiddleDClick"></event> </object>
<event name="OnMiddleDown"></event> </object>
<event name="OnMiddleUp"></event> <object class="sizeritem" expanded="1">
<event name="OnMotion"></event> <property name="border">5</property>
<event name="OnMouseEvents"></event> <property name="flag">wxALL</property>
<event name="OnMouseWheel"></event> <property name="proportion">0</property>
<event name="OnPaint"></event> <object class="wxStaticText" expanded="1">
<event name="OnRightDClick"></event> <property name="BottomDockable">1</property>
<event name="OnRightDown"></event> <property name="LeftDockable">1</property>
<event name="OnRightUp"></event> <property name="RightDockable">1</property>
<event name="OnSetFocus"></event> <property name="TopDockable">1</property>
<event name="OnSize"></event> <property name="aui_layer"></property>
<event name="OnUpdateUI"></event> <property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Add signal by name:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_signalEntry</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">onSignalAdd</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
@ -197,14 +264,6 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">m_sdbSizer</property> <property name="name">m_sdbSizer</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object> </object>
</object> </object>
</object> </object>

View File

@ -1,12 +1,11 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_SIGNAL_LIST_BASE_H__ #pragma once
#define __DIALOG_SIGNAL_LIST_BASE_H__
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
@ -18,6 +17,8 @@
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -34,6 +35,8 @@ class DIALOG_SIGNAL_LIST_BASE : public DIALOG_SHIM
protected: protected:
wxListBox* m_signals; wxListBox* m_signals;
wxStaticText* m_staticText1;
wxTextCtrl* m_signalEntry;
wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel; wxButton* m_sdbSizerCancel;
@ -49,4 +52,3 @@ class DIALOG_SIGNAL_LIST_BASE : public DIALOG_SHIM
}; };
#endif //__DIALOG_SIGNAL_LIST_BASE_H__