2011-12-16 20:12:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-08-11 07:44:06 +00:00
|
|
|
* Copyright (C) 2013-2017 Jean-Pierre Charras, jp.charras@wanadoo.fr
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
2021-01-30 16:30:35 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-16 20:12:49 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
/* Functions relative to the dialog creating the netlist for Pcbnew. The dialog is a notebook
|
|
|
|
* with 4 fixed netlist formats:
|
|
|
|
* Pcbnew
|
|
|
|
* ORCADPCB2
|
|
|
|
* CADSTAR
|
|
|
|
* SPICE
|
|
|
|
* and up to CUSTOMPANEL_COUNTMAX user programmable formats. These external converters are
|
|
|
|
* referred to as plugins, but they are really just external binaries.
|
2007-11-10 14:35:04 +00:00
|
|
|
*/
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <netlist.h>
|
2013-06-27 20:34:30 +00:00
|
|
|
#include <dialogs/dialog_netlist_base.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2013-06-27 20:34:30 +00:00
|
|
|
#include <invoke_sch_dialog.h>
|
2016-08-11 12:41:20 +00:00
|
|
|
#include <netlist_exporters/netlist_exporter_pspice.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eeschema_settings.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2021-02-17 04:26:46 +00:00
|
|
|
#include <paths.h>
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
#include <eeschema_id.h>
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/checkbox.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wx/msgdlg.h>
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/regex.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
|
|
|
|
|
|
|
|
|
|
|
|
/* panel (notebook page) identifiers */
|
|
|
|
enum panel_netlist_index {
|
|
|
|
PANELPCBNEW = 0, /* Handle Netlist format Pcbnew */
|
|
|
|
PANELORCADPCB2, /* Handle Netlist format OracdPcb2 */
|
|
|
|
PANELCADSTAR, /* Handle Netlist format CadStar */
|
|
|
|
PANELSPICE, /* Handle Netlist format Pspice */
|
|
|
|
PANELCUSTOMBASE /* First auxiliary panel (custom netlists).
|
|
|
|
* others use PANELCUSTOMBASE+1, PANELCUSTOMBASE+2.. */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* wxPanels for creating the NoteBook pages for each netlist format: */
|
|
|
|
class NETLIST_PAGE_DIALOG : public wxPanel
|
|
|
|
{
|
2021-03-21 17:31:23 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
public:
|
2021-03-21 17:31:23 +00:00
|
|
|
/**
|
|
|
|
* Create a setup page for one netlist format.
|
|
|
|
*
|
|
|
|
* Used in Netlist format dialog box creation.
|
|
|
|
*
|
|
|
|
* @param parent is the wxNotebook parent.
|
|
|
|
* @param title is the title of the notebook page.
|
|
|
|
* @param id_NetType is the netlist ID type.
|
|
|
|
*/
|
|
|
|
NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
|
|
|
|
NETLIST_TYPE_ID id_NetType );
|
|
|
|
~NETLIST_PAGE_DIALOG() { };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the name of the netlist format for this page.
|
|
|
|
*/
|
|
|
|
const wxString GetPageNetFmtName() { return m_pageNetFmtName; }
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
NETLIST_TYPE_ID m_IdNetType;
|
2016-09-16 18:36:19 +00:00
|
|
|
// opt to reformat passive component values (e.g. 1M -> 1Meg):
|
2019-08-04 21:43:23 +00:00
|
|
|
wxCheckBox* m_AdjustPassiveValues;
|
2013-06-27 20:34:30 +00:00
|
|
|
wxTextCtrl* m_CommandStringCtrl;
|
|
|
|
wxTextCtrl* m_TitleStringCtrl;
|
|
|
|
wxBoxSizer* m_LeftBoxSizer;
|
|
|
|
wxBoxSizer* m_RightBoxSizer;
|
|
|
|
wxBoxSizer* m_RightOptionsBoxSizer;
|
|
|
|
wxBoxSizer* m_LowBoxSizer;
|
2014-11-22 11:57:02 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
private:
|
|
|
|
wxString m_pageNetFmtName;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Dialog frame for creating netlists */
|
|
|
|
class NETLIST_DIALOG : public NETLIST_DIALOG_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NETLIST_DIALOG( SCH_EDIT_FRAME* parent );
|
|
|
|
~NETLIST_DIALOG() { };
|
|
|
|
|
|
|
|
private:
|
2021-03-21 17:31:23 +00:00
|
|
|
friend class NETLIST_PAGE_DIALOG;
|
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
void InstallCustomPages();
|
2013-06-27 20:34:30 +00:00
|
|
|
NETLIST_PAGE_DIALOG* AddOneCustomPage( const wxString & aTitle,
|
|
|
|
const wxString & aCommandString,
|
|
|
|
NETLIST_TYPE_ID aNetTypeId );
|
2019-08-04 21:43:23 +00:00
|
|
|
void InstallPageSpice();
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
void NetlistUpdateOpt();
|
2017-08-11 07:44:06 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
// Called when changing the notebook page (and therefore the current netlist format)
|
|
|
|
void OnNetlistTypeSelection( wxNotebookEvent& event ) override;
|
2017-08-11 07:44:06 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
/**
|
2021-03-21 17:31:23 +00:00
|
|
|
* Add a new panel for a new netlist plugin.
|
2013-06-27 20:34:30 +00:00
|
|
|
*/
|
2019-08-04 21:43:23 +00:00
|
|
|
void OnAddGenerator( wxCommandEvent& event ) override;
|
2013-06-27 20:34:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-21 17:31:23 +00:00
|
|
|
* Remove a panel relative to a netlist plugin.
|
2013-06-27 20:34:30 +00:00
|
|
|
*/
|
2019-08-04 21:43:23 +00:00
|
|
|
void OnDelGenerator( wxCommandEvent& event ) override;
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2020-08-04 10:51:56 +00:00
|
|
|
/**
|
2021-03-21 17:31:23 +00:00
|
|
|
* Run the external spice simulator command.
|
2020-08-04 10:51:56 +00:00
|
|
|
*/
|
|
|
|
void OnRunExternSpiceCommand( wxCommandEvent& event );
|
|
|
|
|
2020-08-04 11:57:41 +00:00
|
|
|
/**
|
2021-03-21 17:31:23 +00:00
|
|
|
* Enable (if the command line is not empty or disable the button to run spice command.
|
2020-08-04 11:57:41 +00:00
|
|
|
*/
|
|
|
|
void OnRunSpiceButtUI( wxUpdateUIEvent& event );
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
/**
|
2021-03-21 17:31:23 +00:00
|
|
|
* Write the current netlist options setup in the configuration.
|
2013-06-27 20:34:30 +00:00
|
|
|
*/
|
|
|
|
void WriteCurrentNetlistSetup();
|
|
|
|
|
|
|
|
/**
|
2021-03-21 17:31:23 +00:00
|
|
|
* Return the filename extension and the wildcard string for this page or a void name
|
|
|
|
* if there is no default name.
|
|
|
|
*
|
|
|
|
* @param aType is the netlist type ( NET_TYPE_PCBNEW ... ).
|
|
|
|
* @param aExt [in] is a holder for the netlist file extension.
|
|
|
|
* @param aWildCard [in] is a holder for netlist file dialog wildcard.
|
|
|
|
* @return true for known netlist type, false for custom formats.
|
2013-06-27 20:34:30 +00:00
|
|
|
*/
|
2021-03-21 17:31:23 +00:00
|
|
|
bool FilenamePrms( NETLIST_TYPE_ID aType, wxString* aExt, wxString* aWildCard );
|
2013-06-27 20:34:30 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2021-03-21 17:31:23 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SCH_EDIT_FRAME* m_Parent;
|
|
|
|
wxString m_DefaultNetFmtName;
|
|
|
|
NETLIST_PAGE_DIALOG* m_PanelNetType[4 + CUSTOMPANEL_COUNTMAX];
|
2013-06-27 20:34:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
class NETLIST_DIALOG_ADD_GENERATOR : public NETLIST_DIALOG_ADD_GENERATOR_BASE
|
2013-06-27 20:34:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-05-27 18:43:39 +00:00
|
|
|
NETLIST_DIALOG_ADD_GENERATOR( NETLIST_DIALOG* parent );
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); }
|
|
|
|
const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); }
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
bool TransferDataFromWindow() override;
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
private:
|
2013-06-27 20:34:30 +00:00
|
|
|
/*
|
|
|
|
* Browse plugin files, and set m_CommandStringCtrl field
|
|
|
|
*/
|
2019-05-27 18:43:39 +00:00
|
|
|
void OnBrowseGenerators( wxCommandEvent& event ) override;
|
2021-03-21 17:31:23 +00:00
|
|
|
|
|
|
|
NETLIST_DIALOG* m_Parent;
|
2013-06-27 20:34:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
/* Event id for notebook page buttons: */
|
|
|
|
enum id_netlist {
|
|
|
|
ID_CREATE_NETLIST = ID_END_EESCHEMA_ID_LIST + 1,
|
2020-08-04 10:51:56 +00:00
|
|
|
ID_USE_NETCODE_AS_NETNAME,
|
|
|
|
ID_RUN_SIMULATOR
|
2012-08-21 10:45:54 +00:00
|
|
|
};
|
2011-03-31 15:22:34 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
|
2020-08-04 10:51:56 +00:00
|
|
|
EVT_BUTTON( ID_RUN_SIMULATOR, NETLIST_DIALOG::OnRunExternSpiceCommand )
|
2020-08-04 11:57:41 +00:00
|
|
|
EVT_UPDATE_UI( ID_RUN_SIMULATOR, NETLIST_DIALOG::OnRunSpiceButtUI )
|
2007-11-10 14:35:04 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2020-11-24 22:16:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
|
2012-08-21 10:45:54 +00:00
|
|
|
NETLIST_TYPE_ID id_NetType ) :
|
2020-11-24 22:16:41 +00:00
|
|
|
wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-08-04 21:43:23 +00:00
|
|
|
m_IdNetType = id_NetType;
|
|
|
|
m_pageNetFmtName = title;
|
2021-07-16 20:13:26 +00:00
|
|
|
m_CommandStringCtrl = nullptr;
|
|
|
|
m_TitleStringCtrl = nullptr;
|
|
|
|
m_AdjustPassiveValues = nullptr;
|
2012-09-28 17:47:41 +00:00
|
|
|
|
2020-11-24 22:16:41 +00:00
|
|
|
wxString netfmtName = static_cast<NETLIST_DIALOG*>( parent->GetParent() )->m_DefaultNetFmtName;
|
2012-03-12 10:04:40 +00:00
|
|
|
|
|
|
|
bool selected = m_pageNetFmtName == netfmtName;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
parent->AddPage( this, title, selected );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
SetSizer( MainBoxSizer );
|
|
|
|
wxBoxSizer* UpperBoxSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
m_LowBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
MainBoxSizer->Add( UpperBoxSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
MainBoxSizer->Add( m_LowBoxSizer, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
m_LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
m_RightBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
m_RightOptionsBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
UpperBoxSizer->Add( m_LeftBoxSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
UpperBoxSizer->Add( m_RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2011-03-14 15:17:18 +00:00
|
|
|
UpperBoxSizer->Add( m_RightOptionsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
|
2012-08-21 10:45:54 +00:00
|
|
|
NETLIST_DIALOG_BASE( parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-05 06:14:55 +00:00
|
|
|
m_Parent = parent;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2020-07-06 21:21:42 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = m_Parent->Schematic().Settings();
|
|
|
|
|
|
|
|
m_DefaultNetFmtName = settings.m_NetFormatName;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
|
2021-07-16 20:13:26 +00:00
|
|
|
page = nullptr;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
// Add notebook pages:
|
2021-02-26 00:35:07 +00:00
|
|
|
m_PanelNetType[PANELPCBNEW] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "KiCad" ),
|
2019-08-04 21:43:23 +00:00
|
|
|
NET_TYPE_PCBNEW );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
m_PanelNetType[PANELORCADPCB2] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "OrcadPCB2" ),
|
|
|
|
NET_TYPE_ORCADPCB2 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
m_PanelNetType[PANELCADSTAR] = new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "CadStar" ),
|
|
|
|
NET_TYPE_CADSTAR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
InstallPageSpice();
|
|
|
|
InstallCustomPages();
|
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
// We use a sdbSizer here to get the order right, which is platform-dependent
|
|
|
|
m_sdbSizer2OK->SetLabel( _( "Export Netlist" ) );
|
|
|
|
m_sdbSizer2Cancel->SetLabel( _( "Close" ) );
|
|
|
|
m_buttonSizer->Layout();
|
|
|
|
|
|
|
|
m_sdbSizer2OK->SetDefault();
|
2010-08-11 15:32:44 +00:00
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-04 10:51:56 +00:00
|
|
|
void NETLIST_DIALOG::OnRunExternSpiceCommand( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Run the external spice simulator command
|
|
|
|
NetlistUpdateOpt();
|
|
|
|
|
|
|
|
SCHEMATIC_SETTINGS& settings = m_Parent->Schematic().Settings();
|
|
|
|
wxString simulatorCommand = settings.m_SpiceCommandString;
|
|
|
|
|
|
|
|
unsigned netlist_opt = 0;
|
|
|
|
|
|
|
|
// Calculate the netlist filename and options
|
|
|
|
wxFileName fn = m_Parent->Schematic().GetFileName();
|
|
|
|
fn.SetExt( wxT( "cir" ) );
|
|
|
|
|
|
|
|
if( settings.m_SpiceAdjustPassiveValues )
|
|
|
|
netlist_opt |= NET_ADJUST_PASSIVE_VALS;
|
|
|
|
|
|
|
|
// Build the command line
|
|
|
|
wxString commandLine = simulatorCommand;
|
|
|
|
commandLine.Replace( "%I", fn.GetFullPath(), true );
|
|
|
|
|
2021-01-30 16:30:35 +00:00
|
|
|
if( m_Parent->ReadyToNetlist( _( "Simulator requires a fully annotated schematic." ) ) )
|
2020-08-04 10:51:56 +00:00
|
|
|
{
|
2021-01-30 16:30:35 +00:00
|
|
|
m_Parent->WriteNetListFile( NET_TYPE_SPICE, fn.GetFullPath(), netlist_opt, nullptr );
|
2021-10-22 23:49:34 +00:00
|
|
|
commandLine.Trim( true ).Trim( false );
|
|
|
|
|
|
|
|
if( !commandLine.IsEmpty() )
|
|
|
|
wxExecute( commandLine, wxEXEC_ASYNC );
|
2020-08-04 10:51:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-04 11:57:41 +00:00
|
|
|
void NETLIST_DIALOG::OnRunSpiceButtUI( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
bool disable = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->IsEmpty();
|
|
|
|
aEvent.Enable( !disable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::InstallPageSpice()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-08-04 21:43:23 +00:00
|
|
|
NETLIST_PAGE_DIALOG* page = m_PanelNetType[PANELSPICE] =
|
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook, wxT( "Spice" ), NET_TYPE_SPICE );
|
|
|
|
|
2020-07-06 21:21:42 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = m_Parent->Schematic().Settings();
|
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
page->m_AdjustPassiveValues = new wxCheckBox( page, ID_USE_NETCODE_AS_NETNAME,
|
|
|
|
_( "Reformat passive symbol values" ) );
|
|
|
|
page->m_AdjustPassiveValues->SetToolTip( _( "Reformat passive symbol values e.g. 1M -> 1Meg" ) );
|
2020-07-06 21:21:42 +00:00
|
|
|
page->m_AdjustPassiveValues->SetValue( settings.m_SpiceAdjustPassiveValues );
|
2019-08-04 21:43:23 +00:00
|
|
|
page->m_LeftBoxSizer->Add( page->m_AdjustPassiveValues, 0, wxGROW | wxBOTTOM | wxRIGHT, 5 );
|
2020-08-04 10:51:56 +00:00
|
|
|
|
|
|
|
wxString simulatorCommand = settings.m_SpiceCommandString;
|
|
|
|
wxStaticText* spice_label = new wxStaticText( page, -1, _( "External simulator command:" ) );
|
|
|
|
spice_label->SetToolTip( _( "Enter the command line to run spice\n"
|
|
|
|
"Usually <path to spice binary> %I\n"
|
2021-07-16 20:13:26 +00:00
|
|
|
"%I will be replaced by the actual spice netlist name" ) );
|
2020-08-04 10:51:56 +00:00
|
|
|
page->m_LowBoxSizer->Add( spice_label, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
page->m_CommandStringCtrl = new wxTextCtrl( page, -1, simulatorCommand,
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
|
|
|
|
page->m_CommandStringCtrl->SetInsertionPoint( 1 );
|
|
|
|
page->m_LowBoxSizer->Add( page->m_CommandStringCtrl, 0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
// Add button to run spice command
|
|
|
|
wxButton* button = new wxButton( page, ID_RUN_SIMULATOR,
|
|
|
|
_( "Create Netlist and Run Simulator Command" ) );
|
|
|
|
page->m_LowBoxSizer->Add( button, 0, wxGROW | wxBOTTOM | wxLEFT | wxRIGHT, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
void NETLIST_DIALOG::InstallCustomPages()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
NETLIST_PAGE_DIALOG* currPage;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
2020-03-21 16:31:48 +00:00
|
|
|
wxASSERT( cfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-03-21 16:31:48 +00:00
|
|
|
if( cfg )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2020-03-21 16:31:48 +00:00
|
|
|
for( size_t i = 0;
|
2021-09-05 14:13:52 +00:00
|
|
|
i < CUSTOMPANEL_COUNTMAX && i < cfg->m_NetlistPanel.plugins.size();
|
2020-03-21 16:31:48 +00:00
|
|
|
i++ )
|
|
|
|
{
|
|
|
|
// pairs of (title, command) are stored
|
2021-09-05 14:13:52 +00:00
|
|
|
wxString title = cfg->m_NetlistPanel.plugins[i].name;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
if( i >= cfg->m_NetlistPanel.plugins.size() )
|
2020-03-21 16:31:48 +00:00
|
|
|
break; // No more panel to install
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
wxString command = cfg->m_NetlistPanel.plugins[i].command;
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2020-03-21 16:31:48 +00:00
|
|
|
currPage = AddOneCustomPage( title, command,
|
|
|
|
static_cast<NETLIST_TYPE_ID>( NET_TYPE_CUSTOM1 + i ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-03-21 16:31:48 +00:00
|
|
|
m_PanelNetType[PANELCUSTOMBASE + i] = currPage;
|
|
|
|
}
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2021-07-28 17:25:40 +00:00
|
|
|
NETLIST_PAGE_DIALOG* NETLIST_DIALOG::AddOneCustomPage( const wxString& aTitle,
|
|
|
|
const wxString& aCommandString,
|
2012-08-21 10:45:54 +00:00
|
|
|
NETLIST_TYPE_ID aNetTypeId )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-08-04 21:43:23 +00:00
|
|
|
NETLIST_PAGE_DIALOG* currPage = new NETLIST_PAGE_DIALOG( m_NoteBook, aTitle, aNetTypeId );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Title:" ) ), 0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
currPage->m_TitleStringCtrl = new wxTextCtrl( currPage, -1, aTitle,
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
currPage->m_TitleStringCtrl->SetInsertionPoint( 1 );
|
|
|
|
currPage->m_LowBoxSizer->Add( currPage->m_TitleStringCtrl, 0,
|
|
|
|
wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
currPage->m_LowBoxSizer->Add( new wxStaticText( currPage, -1, _( "Netlist command:" ) ), 0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
currPage->m_CommandStringCtrl = new wxTextCtrl( currPage, -1, aCommandString,
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
currPage->m_CommandStringCtrl->SetInsertionPoint( 1 );
|
2019-08-04 21:43:23 +00:00
|
|
|
currPage->m_LowBoxSizer->Add( currPage->m_CommandStringCtrl, 0,
|
|
|
|
wxGROW | wxTOP | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
return currPage;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
void NETLIST_DIALOG::OnNetlistTypeSelection( wxNotebookEvent& event )
|
|
|
|
{
|
|
|
|
NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
2017-08-11 07:44:06 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( currPage == nullptr )
|
2012-08-21 10:45:54 +00:00
|
|
|
return;
|
|
|
|
|
2021-02-26 00:35:07 +00:00
|
|
|
m_DefaultNetFmtName = currPage->GetPageNetFmtName();
|
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
m_buttonDelGenerator->Enable( currPage->m_IdNetType >= NET_TYPE_CUSTOM1 );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::NetlistUpdateOpt()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-08-04 21:43:23 +00:00
|
|
|
bool adjust = m_PanelNetType[ PANELSPICE ]->m_AdjustPassiveValues->IsChecked();
|
2020-08-04 10:51:56 +00:00
|
|
|
wxString spice_cmd_string = m_PanelNetType[ PANELSPICE ]->m_CommandStringCtrl->GetValue();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2020-07-06 21:21:42 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = m_Parent->Schematic().Settings();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2020-07-06 21:21:42 +00:00
|
|
|
settings.m_SpiceAdjustPassiveValues = adjust;
|
2020-08-04 10:51:56 +00:00
|
|
|
settings.m_SpiceCommandString = spice_cmd_string;
|
2020-07-06 21:21:42 +00:00
|
|
|
settings.m_NetFormatName = wxEmptyString;
|
2021-02-26 00:35:07 +00:00
|
|
|
settings.m_NetFormatName = m_DefaultNetFmtName;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
bool NETLIST_DIALOG::TransferDataFromWindow()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-08-11 14:47:16 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString fileWildcard;
|
|
|
|
wxString fileExt;
|
|
|
|
wxString title = _( "Save Netlist File" );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
NetlistUpdateOpt();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
NETLIST_PAGE_DIALOG* currPage;
|
|
|
|
currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
unsigned netlist_opt = 0;
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
// Calculate the netlist filename
|
2020-05-13 02:00:37 +00:00
|
|
|
fn = m_Parent->Schematic().GetFileName();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
FilenamePrms( currPage->m_IdNetType, &fileExt, &fileWildcard );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
// Set some parameters
|
|
|
|
switch( currPage->m_IdNetType )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
|
|
|
case NET_TYPE_SPICE:
|
2012-01-26 09:37:36 +00:00
|
|
|
// Set spice netlist options:
|
2019-08-04 21:43:23 +00:00
|
|
|
if( currPage->m_AdjustPassiveValues->GetValue() )
|
2016-09-16 18:36:19 +00:00
|
|
|
netlist_opt |= NET_ADJUST_PASSIVE_VALS;
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_TYPE_CADSTAR:
|
|
|
|
break;
|
|
|
|
|
2010-08-11 05:58:34 +00:00
|
|
|
case NET_TYPE_PCBNEW:
|
2012-01-26 09:37:36 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-11 14:47:16 +00:00
|
|
|
case NET_TYPE_ORCADPCB2:
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
2010-08-11 05:58:34 +00:00
|
|
|
|
2010-08-11 14:47:16 +00:00
|
|
|
default: // custom, NET_TYPE_CUSTOM1 and greater
|
2018-03-25 23:51:16 +00:00
|
|
|
{
|
2021-09-03 18:38:29 +00:00
|
|
|
title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue() );
|
2018-03-25 23:51:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-07-21 21:37:49 +00:00
|
|
|
}
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2010-08-11 14:47:16 +00:00
|
|
|
fn.SetExt( fileExt );
|
2013-05-27 13:59:10 +00:00
|
|
|
|
|
|
|
if( fn.GetPath().IsEmpty() )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
|
2013-05-27 13:59:10 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
wxString fullpath = fn.GetFullPath();
|
2019-01-08 12:26:36 +00:00
|
|
|
wxString fullname = fn.GetFullName();
|
|
|
|
wxString path = fn.GetPath();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
// full name does not and should not include the path, per wx docs.
|
2019-01-08 12:26:36 +00:00
|
|
|
wxFileDialog dlg( this, title, path, fullname, fileWildcard, wxFD_SAVE );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2019-01-08 12:26:36 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2019-08-04 21:43:23 +00:00
|
|
|
return false;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2019-01-08 12:26:36 +00:00
|
|
|
fullpath = dlg.GetPath(); // directory + filename
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
m_Parent->ClearMsgPanel();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( currPage->m_CommandStringCtrl )
|
|
|
|
m_Parent->SetNetListerCommand( currPage->m_CommandStringCtrl->GetValue() );
|
2010-07-14 13:24:36 +00:00
|
|
|
else
|
2011-06-15 18:44:24 +00:00
|
|
|
m_Parent->SetNetListerCommand( wxEmptyString );
|
2010-07-14 13:24:36 +00:00
|
|
|
|
2021-01-30 16:30:35 +00:00
|
|
|
if( m_Parent->ReadyToNetlist( _( "Exporting netlist requires a fully annotated schematic." ) ) )
|
2020-05-23 17:14:05 +00:00
|
|
|
m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt, nullptr );
|
2010-07-14 13:24:36 +00:00
|
|
|
|
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
return true;
|
2010-07-14 13:24:36 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
bool NETLIST_DIALOG::FilenamePrms( NETLIST_TYPE_ID aType, wxString * aExt, wxString * aWildCard )
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
|
|
|
wxString fileExt;
|
|
|
|
wxString fileWildcard;
|
2019-08-04 21:43:23 +00:00
|
|
|
bool ret = true;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
switch( aType )
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
|
|
|
case NET_TYPE_SPICE:
|
|
|
|
fileExt = wxT( "cir" );
|
2017-11-12 00:31:38 +00:00
|
|
|
fileWildcard = SpiceNetlistFileWildcard();
|
2012-08-21 10:45:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_TYPE_CADSTAR:
|
|
|
|
fileExt = wxT( "frp" );
|
2017-11-12 00:31:38 +00:00
|
|
|
fileWildcard = CadstarNetlistFileWildcard();
|
2012-08-21 10:45:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_TYPE_PCBNEW:
|
|
|
|
case NET_TYPE_ORCADPCB2:
|
|
|
|
fileExt = NetlistFileExtension;
|
2017-11-12 00:31:38 +00:00
|
|
|
fileWildcard = NetlistFileWildcard();
|
2012-08-21 10:45:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: // custom, NET_TYPE_CUSTOM1 and greater
|
2019-01-08 11:57:39 +00:00
|
|
|
fileWildcard = AllFilesWildcard();
|
2012-08-21 10:45:54 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aExt )
|
|
|
|
*aExt = fileExt;
|
|
|
|
|
|
|
|
if( aWildCard )
|
|
|
|
*aWildCard = fileWildcard;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-07-14 13:24:36 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
|
|
|
void NETLIST_DIALOG::WriteCurrentNetlistSetup()
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2019-08-04 21:43:23 +00:00
|
|
|
wxString msg;
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
NetlistUpdateOpt();
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
wxASSERT( cfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
if( !cfg )
|
|
|
|
return;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
cfg->m_NetlistPanel.plugins.clear();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
// Update existing custom pages
|
|
|
|
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
|
|
|
|
{
|
|
|
|
NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
if( currPage == nullptr )
|
|
|
|
break;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
wxString title = currPage->m_TitleStringCtrl->GetValue();
|
|
|
|
wxString command = currPage->m_CommandStringCtrl->GetValue();
|
2020-03-25 13:13:03 +00:00
|
|
|
|
2021-09-05 14:13:52 +00:00
|
|
|
if( title.IsEmpty() || command.IsEmpty() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cfg->m_NetlistPanel.plugins.emplace_back( title, wxEmptyString );
|
|
|
|
cfg->m_NetlistPanel.plugins.back().command = command;
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
NETLIST_PAGE_DIALOG* currPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
currPage->m_CommandStringCtrl->SetValue( wxEmptyString );
|
|
|
|
currPage->m_TitleStringCtrl->SetValue( wxEmptyString );
|
2021-02-26 00:35:07 +00:00
|
|
|
m_DefaultNetFmtName = m_PanelNetType[PANELPCBNEW]->GetPageNetFmtName();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
WriteCurrentNetlistSetup();
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( NET_PLUGIN_CHANGE );
|
|
|
|
else
|
|
|
|
EndDialog( NET_PLUGIN_CHANGE );
|
2007-11-10 14:35:04 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
void NETLIST_DIALOG::OnAddGenerator( wxCommandEvent& event )
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2019-05-27 18:43:39 +00:00
|
|
|
NETLIST_DIALOG_ADD_GENERATOR dlg( this );
|
2019-08-04 21:43:23 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Creates a new custom plugin page
|
2019-05-27 18:43:39 +00:00
|
|
|
wxString title = dlg.GetGeneratorTitle();
|
2012-08-21 10:45:54 +00:00
|
|
|
|
|
|
|
// Verify it does not exists
|
|
|
|
int netTypeId = PANELCUSTOMBASE; // the first not used type id
|
|
|
|
NETLIST_PAGE_DIALOG* currPage;
|
2019-08-04 21:43:23 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
|
|
|
|
{
|
|
|
|
netTypeId = PANELCUSTOMBASE + ii;
|
|
|
|
currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( currPage == nullptr )
|
2012-08-21 10:45:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if( currPage->GetPageNetFmtName() == title )
|
|
|
|
{
|
2019-08-04 21:43:23 +00:00
|
|
|
wxMessageBox( _("This plugin already exists.") );
|
2012-08-21 10:45:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
wxString cmd = dlg.GetGeneratorTCommandLine();
|
2012-08-21 10:45:54 +00:00
|
|
|
currPage = AddOneCustomPage( title,cmd, (NETLIST_TYPE_ID)netTypeId );
|
|
|
|
m_PanelNetType[netTypeId] = currPage;
|
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( NET_PLUGIN_CHANGE );
|
|
|
|
else
|
|
|
|
EndDialog( NET_PLUGIN_CHANGE );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
NETLIST_DIALOG_ADD_GENERATOR::NETLIST_DIALOG_ADD_GENERATOR( NETLIST_DIALOG* parent ) :
|
|
|
|
NETLIST_DIALOG_ADD_GENERATOR_BASE( parent )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
m_Parent = parent;
|
2019-08-04 21:43:23 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
2012-08-21 10:45:54 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
bool NETLIST_DIALOG_ADD_GENERATOR::TransferDataFromWindow()
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2021-07-21 21:37:49 +00:00
|
|
|
if( !wxDialog::TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( m_textCtrlCommand->GetValue() == wxEmptyString )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2021-07-21 21:37:49 +00:00
|
|
|
wxMessageBox( _( "You must provide a netlist generator command string" ) );
|
|
|
|
return false;
|
2007-11-10 14:35:04 +00:00
|
|
|
}
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( m_textCtrlName->GetValue() == wxEmptyString )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2021-07-21 21:37:49 +00:00
|
|
|
wxMessageBox( _( "You must provide a netlist generator title" ) );
|
|
|
|
return false;
|
2007-11-10 14:35:04 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
return true;
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 20:34:30 +00:00
|
|
|
|
2019-05-27 18:43:39 +00:00
|
|
|
void NETLIST_DIALOG_ADD_GENERATOR::OnBrowseGenerators( wxCommandEvent& event )
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2019-01-06 04:23:13 +00:00
|
|
|
wxString FullFileName, Path;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2014-10-17 17:45:33 +00:00
|
|
|
#ifndef __WXMAC__
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
Path = Pgm().GetExecutablePath();
|
2014-10-17 17:45:33 +00:00
|
|
|
#else
|
2021-02-17 04:26:46 +00:00
|
|
|
Path = PATHS::GetOSXKicadDataDir() + wxT( "/plugins" );
|
2014-10-17 17:45:33 +00:00
|
|
|
#endif
|
2021-07-28 17:25:40 +00:00
|
|
|
|
|
|
|
FullFileName = wxFileSelector( _( "Generator File" ), Path, FullFileName,
|
|
|
|
wxEmptyString, wxFileSelectorDefaultWildcardStr,
|
|
|
|
wxFD_OPEN, this );
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2019-08-04 21:43:23 +00:00
|
|
|
// Creates a default command line, suitable for external tool xslproc or python, based on
|
|
|
|
// the plugin extension ("xsl" or "exe" or "py")
|
2012-08-21 10:45:54 +00:00
|
|
|
wxString cmdLine;
|
|
|
|
wxFileName fn( FullFileName );
|
|
|
|
wxString ext = fn.GetExt();
|
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
if( ext == wxT( "xsl" ) )
|
|
|
|
cmdLine.Printf( wxT( "xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName );
|
|
|
|
else if( ext == wxT( "exe" ) || ext.IsEmpty() )
|
|
|
|
cmdLine.Printf( wxT( "\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName );
|
|
|
|
else if( ext == wxT( "py" ) || ext.IsEmpty() )
|
|
|
|
cmdLine.Printf( wxT( "python \"%s\" \"%%I\" \"%%O\"" ), FullFileName );
|
2012-08-21 10:45:54 +00:00
|
|
|
else
|
2021-07-21 21:37:49 +00:00
|
|
|
cmdLine.Printf( wxT( "\"%s\"" ), FullFileName );
|
2012-08-21 10:45:54 +00:00
|
|
|
|
|
|
|
m_textCtrlCommand->SetValue( cmdLine );
|
|
|
|
|
2021-09-03 18:38:29 +00:00
|
|
|
// We need a title for this panel
|
|
|
|
// Propose a default value if empty ( i.e. the short filename of the script)
|
|
|
|
if( m_textCtrlName->GetValue().IsEmpty() )
|
|
|
|
m_textCtrlName->SetValue( fn.GetName() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2013-06-27 20:34:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller )
|
|
|
|
{
|
|
|
|
NETLIST_DIALOG dlg( aCaller );
|
|
|
|
|
2020-07-06 21:21:42 +00:00
|
|
|
SCHEMATIC_SETTINGS& settings = aCaller->Schematic().Settings();
|
|
|
|
|
|
|
|
wxString curr_default_netformat = settings.m_NetFormatName;
|
2019-06-10 16:44:46 +00:00
|
|
|
|
|
|
|
int ret = dlg.ShowModal();
|
|
|
|
|
2021-03-21 17:31:23 +00:00
|
|
|
// Update the default netlist and store it in prj config if it was explicitly changed.
|
2020-07-06 21:21:42 +00:00
|
|
|
settings.m_NetFormatName = dlg.m_DefaultNetFmtName; // can have temporary changed
|
2019-06-10 16:44:46 +00:00
|
|
|
|
|
|
|
if( curr_default_netformat != dlg.m_DefaultNetFmtName )
|
2020-02-28 00:05:40 +00:00
|
|
|
aCaller->SaveProjectSettings();
|
2019-06-10 16:44:46 +00:00
|
|
|
|
|
|
|
return ret;
|
2013-06-27 20:34:30 +00:00
|
|
|
}
|