2007-11-05 06:14:55 +00:00
|
|
|
/**********************************/
|
|
|
|
/* Dialog box for netlist outputs */
|
|
|
|
/**********************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/* Functions relatives to the dialog creating the netlist for pcbnew.
|
|
|
|
* The dialo is a notebook with 4 fixed netlist format:
|
|
|
|
* PCBNEW ORCADPCB2 CADSTAR and SPICE
|
|
|
|
* and up to CUSTOMPANEL_COUNTMAX (see netlist.h) user programmable format
|
|
|
|
* calling an external converter with convert an intermediate format to the
|
|
|
|
* user specific format.
|
|
|
|
* these external converters are refered there as plugins,
|
|
|
|
* but there are not really plugins, there are only external binaries
|
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
2007-11-10 14:35:04 +00:00
|
|
|
#include "netlist.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
2008-02-27 19:38:16 +00:00
|
|
|
#include "netlist_control.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// ID for configuration:
|
2007-11-10 14:35:04 +00:00
|
|
|
#define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" )
|
|
|
|
#define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/****************************************************/
|
|
|
|
wxString ReturnUserNetlistTypeName( bool first_item )
|
|
|
|
/****************************************************/
|
|
|
|
|
|
|
|
/** Function ReturnUserNetlistTypeName
|
|
|
|
* to retrieve user netlist type names
|
|
|
|
* @param first = true: return first name of the list, false = return next
|
|
|
|
* @return a wxString : name of the type netlist or empty string
|
|
|
|
* this function must be called first with "first_item" = true
|
|
|
|
* and after with "first_item" = false to get all the other existing netlist names
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
static int index;
|
|
|
|
wxString name, msg;
|
|
|
|
|
|
|
|
if( first_item )
|
|
|
|
index = 0;
|
|
|
|
else
|
|
|
|
index++;
|
|
|
|
|
|
|
|
msg = CUSTOM_NETLIST_TITLE;
|
|
|
|
msg << index + 1;
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( wxGetApp().m_EDA_Config )
|
|
|
|
name = wxGetApp().m_EDA_Config->Read( msg );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_NetlistFrame, wxDialog )
|
2008-12-08 15:27:13 +00:00
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_NetlistFrame::OnCancelClick )
|
|
|
|
EVT_BUTTON( ID_CREATE_NETLIST, WinEDA_NetlistFrame::GenNetlist )
|
|
|
|
EVT_BUTTON( ID_SETUP_PLUGIN, WinEDA_NetlistFrame::SetupPluginData )
|
|
|
|
EVT_BUTTON( ID_DELETE_PLUGIN, WinEDA_NetlistFrame::DeletePluginPanel )
|
|
|
|
EVT_BUTTON( ID_VALIDATE_PLUGIN, WinEDA_NetlistFrame::ValidatePluginPanel )
|
|
|
|
EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
WinEDA_NetlistFrame::SelectNetlistType )
|
|
|
|
EVT_BUTTON( ID_RUN_SIMULATOR, WinEDA_NetlistFrame::RunSimulator )
|
2007-11-10 14:35:04 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************/
|
|
|
|
/* Functions for these classes */
|
|
|
|
/*******************************/
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
EDA_NoteBookPage::EDA_NoteBookPage( wxNotebook* parent,
|
|
|
|
const wxString& title,
|
|
|
|
int id_NetType,
|
|
|
|
int idCheckBox,
|
2009-04-29 17:09:00 +00:00
|
|
|
int idCreateFile,
|
|
|
|
bool selected ) :
|
2008-12-08 15:27:13 +00:00
|
|
|
wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL |
|
|
|
|
wxBORDER_SUNKEN )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
/** Contructor to create a setup page for one netlist format.
|
2007-11-05 06:14:55 +00:00
|
|
|
* Used in Netlist format Dialog box creation
|
2007-11-10 14:35:04 +00:00
|
|
|
* @param parent = wxNotebook * parent
|
|
|
|
* @param title = title (name) of the notebook page
|
|
|
|
* @param id_NetType = netlist type id
|
|
|
|
* @param idCheckBox = event ID attached to the "format is default" check box
|
|
|
|
* @param idCreateFile = event ID attached to the "create netlist" button
|
2007-11-05 06:14:55 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-05 06:14:55 +00:00
|
|
|
m_IdNetType = id_NetType;
|
|
|
|
m_CommandStringCtrl = NULL;
|
2007-11-10 14:35:04 +00:00
|
|
|
m_TitleStringCtrl = NULL;
|
|
|
|
m_IsCurrentFormat = NULL;
|
2007-11-05 06:14:55 +00:00
|
|
|
m_ButtonCancel = NULL;
|
|
|
|
|
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 );
|
2008-12-08 15:27:13 +00:00
|
|
|
UpperBoxSizer->Add( m_RightOptionsBoxSizer,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxALL,
|
|
|
|
5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
if( idCheckBox )
|
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
wxStaticText* text = new wxStaticText( this, -1, _( "Options:" ) );
|
|
|
|
m_LeftBoxSizer->Add( text, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
m_IsCurrentFormat =
|
|
|
|
new wxCheckBox( this, idCheckBox, _( "Default format" ) );
|
2007-11-10 14:35:04 +00:00
|
|
|
m_LeftBoxSizer->Add( m_IsCurrentFormat, 0, wxGROW | wxALL, 5 );
|
2009-04-29 17:09:00 +00:00
|
|
|
m_IsCurrentFormat->SetValue( selected );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/* Create the buttons: Create Neltist or browse Plugin and Cancel
|
|
|
|
* and a third button for plugins : Remove or Ok button */
|
|
|
|
if( idCreateFile )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
wxButton* Button;
|
|
|
|
if( idCreateFile == ID_SETUP_PLUGIN ) /* This is the "add plugin" panel */
|
|
|
|
Button = new wxButton( this, idCreateFile, _( "&Browse Plugin" ) );
|
2007-11-05 06:14:55 +00:00
|
|
|
else
|
2007-11-10 14:35:04 +00:00
|
|
|
Button = new wxButton( this, idCreateFile, _( "&Netlist" ) );
|
|
|
|
m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
m_ButtonCancel =
|
2008-12-08 15:27:13 +00:00
|
|
|
Button = new wxButton( this, wxID_CANCEL, _( "&Cancel" ) );
|
2007-11-10 14:35:04 +00:00
|
|
|
m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
/* Add special buttons to plugin panels:
|
|
|
|
* for panel plugins: added the "delete" button
|
|
|
|
* for the last panel (add plugin) a Ok button is added
|
|
|
|
*/
|
|
|
|
if( idCreateFile == ID_SETUP_PLUGIN ) /* This is the "add plugin" panel: add Ok button */
|
|
|
|
{
|
|
|
|
Button = new wxButton( this, ID_VALIDATE_PLUGIN, _( "&Ok" ) );
|
|
|
|
m_RightOptionsBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
}
|
|
|
|
else if( id_NetType >= PANELCUSTOMBASE ) /* This is a plugin panel: add delete button */
|
|
|
|
{
|
|
|
|
Button = new wxButton( this, ID_DELETE_PLUGIN, _( "&Delete" ) );
|
|
|
|
m_RightOptionsBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
|
|
|
}
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************************/
|
2008-02-27 19:38:16 +00:00
|
|
|
WinEDA_NetlistFrame::WinEDA_NetlistFrame( WinEDA_SchematicFrame* parent ) :
|
|
|
|
wxDialog( parent, -1, _( "Netlist" ), wxDefaultPosition,
|
2007-11-10 14:35:04 +00:00
|
|
|
wxDefaultSize, DIALOG_STYLE | MAYBE_RESIZE_BORDER )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Constructor for the netlist generation dialog box
|
2007-11-05 06:14:55 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
int ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
m_Parent = parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
for( ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
|
|
|
m_PanelNetType[ii] = NULL;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
Centre();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
wxBoxSizer* GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
SetSizer( GeneralBoxSizer );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
m_NoteBook = new wxNotebook( this, ID_NETLIST_NOTEBOOK,
|
2007-11-10 14:35:04 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
GeneralBoxSizer->Add( m_NoteBook, 0, wxGROW | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
// Add notebook pages:
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
// Add Panel FORMAT PCBNEW
|
2009-04-29 17:09:00 +00:00
|
|
|
m_PanelNetType[PANELPCBNEW] =
|
|
|
|
new EDA_NoteBookPage( m_NoteBook,
|
|
|
|
wxT( "Pcbnew" ),
|
|
|
|
NET_TYPE_PCBNEW,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
|
|
|
m_Parent->m_NetlistFormat == NET_TYPE_PCBNEW );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
// Add Panel FORMAT ORCADPCB2
|
2009-04-29 17:09:00 +00:00
|
|
|
m_PanelNetType[PANELORCADPCB2] =
|
|
|
|
new EDA_NoteBookPage( m_NoteBook,
|
|
|
|
wxT( "OrcadPCB2" ),
|
|
|
|
NET_TYPE_ORCADPCB2,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
|
|
|
m_Parent->m_NetlistFormat == NET_TYPE_ORCADPCB2 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
// Add Panel FORMAT CADSTAR
|
2009-04-29 17:09:00 +00:00
|
|
|
m_PanelNetType[PANELCADSTAR] =
|
|
|
|
new EDA_NoteBookPage( m_NoteBook,
|
|
|
|
wxT( "CadStar" ),
|
|
|
|
NET_TYPE_CADSTAR,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
|
|
|
m_Parent->m_NetlistFormat == NET_TYPE_CADSTAR );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Add Panel spice
|
|
|
|
InstallPageSpice();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Add custom panels:
|
|
|
|
InstallCustomPages();
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_NetlistFrame::InstallPageSpice()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Create the spice page
|
2007-11-05 06:14:55 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
wxButton* Button;
|
|
|
|
EDA_NoteBookPage* page;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
page = m_PanelNetType[PANELSPICE] =
|
|
|
|
new EDA_NoteBookPage( m_NoteBook,
|
|
|
|
wxT( "Spice" ),
|
|
|
|
NET_TYPE_SPICE,
|
|
|
|
0, 0,
|
|
|
|
m_Parent->m_NetlistFormat == NET_TYPE_SPICE );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
page->m_IsCurrentFormat =
|
|
|
|
new wxCheckBox( page, ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
_( "Default format" ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
page->m_IsCurrentFormat->SetValue( m_Parent->m_NetlistFormat == NET_TYPE_SPICE );
|
2007-11-10 14:35:04 +00:00
|
|
|
page->m_LeftBoxSizer->Add( page->m_IsCurrentFormat, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
wxString netlist_opt[2] = { _( "Use Net Names" ), _( "Use Net Numbers" ) };
|
|
|
|
m_UseNetNamesInNetlist = new wxRadioBox( page, -1, _( "Netlist Options:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2008-12-08 15:27:13 +00:00
|
|
|
2, netlist_opt, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
2007-11-10 14:35:04 +00:00
|
|
|
if( !g_OptNetListUseNames )
|
|
|
|
m_UseNetNamesInNetlist->SetSelection( 1 );
|
|
|
|
page->m_LeftBoxSizer->Add( m_UseNetNamesInNetlist, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
page->m_CommandStringCtrl = new WinEDA_EnterText( page,
|
2008-12-08 15:27:13 +00:00
|
|
|
_( "Simulator command:" ),
|
2007-11-10 14:35:04 +00:00
|
|
|
g_SimulatorCommandLine,
|
2008-12-08 15:27:13 +00:00
|
|
|
page->m_LowBoxSizer,
|
|
|
|
wxDefaultSize );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Add buttons
|
2007-11-10 14:35:04 +00:00
|
|
|
Button = new wxButton( page, ID_CREATE_NETLIST, _( "Netlist" ) );
|
|
|
|
page->m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
Button = new wxButton( page, ID_RUN_SIMULATOR, _( "&Run Simulator" ) );
|
|
|
|
page->m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
Button = new wxButton( page, wxID_CANCEL, _( "&Cancel" ) );
|
|
|
|
page->m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_NetlistFrame::InstallCustomPages()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* create the pages for custom netlist format selection:
|
2007-11-05 06:14:55 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
bool selected;
|
2008-12-08 15:27:13 +00:00
|
|
|
int ii, CustomCount;
|
2007-11-10 14:35:04 +00:00
|
|
|
wxString title, previoustitle, msg;
|
|
|
|
EDA_NoteBookPage* CurrPage;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
CustomCount = CUSTOMPANEL_COUNTMAX;
|
|
|
|
previoustitle = wxT( "dummy_title" );
|
2007-11-05 06:14:55 +00:00
|
|
|
for( ii = 0; ii < CustomCount; ii++ )
|
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
title = ReturnUserNetlistTypeName( ii == 0 ? true : false );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
if( title.IsEmpty() && previoustitle.IsEmpty() )
|
2007-11-10 14:35:04 +00:00
|
|
|
break; // No more panel to install
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
selected = m_Parent->m_NetlistFormat == ( NET_TYPE_CUSTOM1 + ii );
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/* Install the panel "Add Plugin" after
|
|
|
|
* the last initialised panel */
|
2007-11-05 06:14:55 +00:00
|
|
|
previoustitle = title;
|
|
|
|
if( title.IsEmpty() )
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage =
|
|
|
|
m_PanelNetType[PANELCUSTOMBASE + ii] =
|
2008-12-08 15:27:13 +00:00
|
|
|
new EDA_NoteBookPage( m_NoteBook,
|
|
|
|
_( "Add Plugin" ),
|
2007-11-10 14:35:04 +00:00
|
|
|
NET_TYPE_CUSTOM1 + ii,
|
2008-12-08 15:27:13 +00:00
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
2009-04-29 17:09:00 +00:00
|
|
|
ID_SETUP_PLUGIN,
|
|
|
|
selected );
|
2007-11-10 14:35:04 +00:00
|
|
|
else /* Install a plugin panel */
|
|
|
|
CurrPage =
|
|
|
|
m_PanelNetType[PANELCUSTOMBASE + ii] =
|
2008-12-08 15:27:13 +00:00
|
|
|
new EDA_NoteBookPage( m_NoteBook,
|
|
|
|
title,
|
2007-11-10 14:35:04 +00:00
|
|
|
NET_TYPE_CUSTOM1 + ii,
|
2008-12-08 15:27:13 +00:00
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
2009-04-29 17:09:00 +00:00
|
|
|
ID_CREATE_NETLIST,
|
|
|
|
selected );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
msg = CUSTOM_NETLIST_COMMAND;
|
|
|
|
msg << ii + 1;
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString Command = wxGetApp().m_EDA_Config->Read( msg );
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage->m_CommandStringCtrl =
|
|
|
|
new WinEDA_EnterText( CurrPage,
|
|
|
|
_( "Netlist command:" ), Command,
|
|
|
|
CurrPage->m_LowBoxSizer,
|
|
|
|
wxDefaultSize );
|
|
|
|
|
|
|
|
CurrPage->m_TitleStringCtrl =
|
|
|
|
new WinEDA_EnterText( CurrPage,
|
|
|
|
_( "Title:" ), title,
|
|
|
|
CurrPage->m_LowBoxSizer,
|
|
|
|
wxDefaultSize );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
void WinEDA_NetlistFrame::SetupPluginData( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Browse the plugin files and set the m_CommandStringCtrl field
|
2007-11-05 06:14:55 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
wxString FullFileName, Mask, Path;
|
|
|
|
|
|
|
|
Mask = wxT( "*" );
|
2008-12-08 15:27:13 +00:00
|
|
|
Path = wxGetApp().m_BinDir;
|
2007-11-10 14:35:04 +00:00
|
|
|
FullFileName = EDA_FileSelector( _( "Plugin files:" ),
|
|
|
|
Path, /* Chemin par defaut */
|
|
|
|
FullFileName, /* nom fichier par defaut */
|
|
|
|
wxEmptyString, /* extension par defaut */
|
|
|
|
Mask, /* Masque d'affichage */
|
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
|
|
|
TRUE
|
|
|
|
);
|
2007-11-05 06:14:55 +00:00
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
EDA_NoteBookPage* CurrPage;
|
|
|
|
CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage == NULL )
|
|
|
|
return;
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage->m_CommandStringCtrl->SetValue( FullFileName );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
/* Get a title for this page */
|
|
|
|
wxString title = CurrPage->m_TitleStringCtrl->GetValue();
|
|
|
|
if( title.IsEmpty() )
|
2009-04-17 08:51:02 +00:00
|
|
|
DisplayInfoMessage( this,
|
2008-12-08 15:27:13 +00:00
|
|
|
_( "Do not forget to choose a title for this netlist control page" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
void WinEDA_NetlistFrame::SelectNetlistType( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-11-10 15:02:33 +00:00
|
|
|
/* Called when the check box "default format" is clicked
|
2008-12-08 15:27:13 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
int ii;
|
|
|
|
EDA_NoteBookPage* CurrPage;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
for( ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ )
|
|
|
|
if( m_PanelNetType[ii] )
|
2007-11-10 14:35:04 +00:00
|
|
|
m_PanelNetType[ii]->m_IsCurrentFormat->SetValue( FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
m_Parent->m_NetlistFormat = CurrPage->m_IdNetType;
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage->m_IsCurrentFormat->SetValue( TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_NetlistFrame::NetlistUpdateOpt()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************/
|
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
int ii;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
g_SimulatorCommandLine =
|
|
|
|
m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue();
|
2009-04-29 17:09:00 +00:00
|
|
|
m_Parent->m_NetlistFormat = NET_TYPE_PCBNEW;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
for( ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ )
|
|
|
|
{
|
|
|
|
if( m_PanelNetType[ii] == NULL )
|
|
|
|
break;
|
|
|
|
if( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == TRUE )
|
2009-04-29 17:09:00 +00:00
|
|
|
m_Parent->m_NetlistFormat = m_PanelNetType[ii]->m_IdNetType;
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_OptNetListUseNames = TRUE; // Used for pspice, gnucap
|
|
|
|
if( m_UseNetNamesInNetlist->GetSelection() == 1 )
|
|
|
|
g_OptNetListUseNames = FALSE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
/** Function GenNetlist
|
|
|
|
* Create the netlist file:
|
|
|
|
* calcualte the filename with the suitable extentions
|
|
|
|
* and run the netlist creator
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString FileWildcard, FileExt;
|
2007-11-10 14:35:04 +00:00
|
|
|
wxString msg, Command;
|
2009-04-29 17:09:00 +00:00
|
|
|
int netformat_tmp = m_Parent->m_NetlistFormat;
|
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
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
EDA_NoteBookPage* CurrPage;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
|
2009-04-29 17:09:00 +00:00
|
|
|
m_Parent->m_NetlistFormat = CurrPage->m_IdNetType;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/* Calculate the netlist filename */
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
switch( m_Parent->m_NetlistFormat )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
|
|
|
case NET_TYPE_SPICE:
|
2009-04-05 20:49:15 +00:00
|
|
|
FileExt = wxT( "cir" );
|
|
|
|
FileWildcard = _( "SPICE netlist file (.cir)|*.cir" );
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_TYPE_CADSTAR:
|
2009-04-05 20:49:15 +00:00
|
|
|
FileExt = wxT( "frp" );
|
|
|
|
FileWildcard = _( "CadStar netlist file (.frp)|*.frp" );
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-04-05 20:49:15 +00:00
|
|
|
FileExt = NetlistFileExtension;
|
|
|
|
FileWildcard = NetlistFileWildcard;
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( FileExt );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save Netlist Files" ), fn.GetPath(),
|
|
|
|
fn.GetFullName(), FileWildcard,
|
2009-04-25 10:12:30 +00:00
|
|
|
wxFD_SAVE /*| wxFD_OVERWRITE_PROMPT*/ );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-11-05 06:14:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_Parent->MsgPanel->EraseMsgBox();
|
|
|
|
|
|
|
|
ReAnnotatePowerSymbolsOnly();
|
2009-07-05 12:09:41 +00:00
|
|
|
if( m_Parent->CheckAnnotate( NULL, 0 ) )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
if( !IsOK( this, _( "Must be Annotated, Continue ?" ) ) )
|
2007-11-05 06:14:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup the entire hierarchy */
|
2008-12-08 15:27:13 +00:00
|
|
|
EDA_ScreenList ScreenList;
|
|
|
|
for( SCH_SCREEN* screen = ScreenList.GetFirst();
|
|
|
|
screen != NULL;
|
|
|
|
screen = ScreenList.GetNext() )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
|
|
|
bool ModifyWires;
|
2007-11-10 14:35:04 +00:00
|
|
|
ModifyWires = screen->SchematicCleanUp( NULL );
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// if wire list has changed, delete the Undo Redo list to avoid
|
|
|
|
// pointer problems with deleted data
|
|
|
|
if( ModifyWires )
|
|
|
|
screen->ClearUndoRedoList();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Parent->BuildNetListBase();
|
|
|
|
if( CurrPage->m_CommandStringCtrl )
|
|
|
|
g_NetListerCommandLine = CurrPage->m_CommandStringCtrl->GetValue();
|
|
|
|
else
|
|
|
|
g_NetListerCommandLine.Empty();
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
switch( m_Parent->m_NetlistFormat )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
|
|
|
default:
|
2009-04-05 20:49:15 +00:00
|
|
|
WriteNetList( m_Parent, dlg.GetPath(), TRUE );
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_TYPE_CADSTAR:
|
|
|
|
case NET_TYPE_ORCADPCB2:
|
2009-04-05 20:49:15 +00:00
|
|
|
WriteNetList( m_Parent, dlg.GetPath(), FALSE );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
case NET_TYPE_SPICE:
|
|
|
|
g_OptNetListUseNames = TRUE; // Used for pspice, gnucap
|
|
|
|
if( m_UseNetNamesInNetlist->GetSelection() == 1 )
|
|
|
|
g_OptNetListUseNames = FALSE;
|
2009-04-05 20:49:15 +00:00
|
|
|
WriteNetList( m_Parent, dlg.GetPath(), g_OptNetListUseNames );
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
m_Parent->m_NetlistFormat = netformat_tmp;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
|
|
|
|
EndModal( NET_OK );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
|
|
|
void WinEDA_NetlistFrame::OnCancelClick( wxCommandEvent& event )
|
|
|
|
/***********************************************************/
|
|
|
|
{
|
|
|
|
EndModal( NET_ABORT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
|
|
|
void WinEDA_NetlistFrame::RunSimulator( wxCommandEvent& event )
|
|
|
|
/***********************************************************/
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
wxString ExecFile, CommandLine;
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
g_SimulatorCommandLine =
|
|
|
|
m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue();
|
|
|
|
g_SimulatorCommandLine.Trim( FALSE );
|
|
|
|
g_SimulatorCommandLine.Trim( TRUE );
|
|
|
|
ExecFile = g_SimulatorCommandLine.BeforeFirst( ' ' );
|
|
|
|
|
|
|
|
CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' );
|
|
|
|
|
|
|
|
/* Calculate the netlist filename */
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
|
|
|
fn.SetExt( wxT( "cir" ) );
|
|
|
|
CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
ExecuteFile( this, ExecFile, CommandLine );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
|
|
|
void WinEDA_NetlistFrame::WriteCurrentNetlistSetup( void )
|
|
|
|
/*********************************************************/
|
|
|
|
|
|
|
|
/** Function WriteCurrentNetlistSetup
|
|
|
|
* Write the current netlist options setup in the configuration
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
wxString msg, Command;
|
2008-12-08 15:27:13 +00:00
|
|
|
wxConfig* config = wxGetApp().m_EDA_Config;
|
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
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
// Update the new titles
|
|
|
|
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
|
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
EDA_NoteBookPage* CurrPage = m_PanelNetType[ii + PANELCUSTOMBASE];
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage == NULL )
|
|
|
|
break;
|
2007-11-10 14:35:04 +00:00
|
|
|
msg = wxT( "Custom" );
|
2007-11-05 06:14:55 +00:00
|
|
|
msg << ii + 1;
|
|
|
|
if( CurrPage->m_TitleStringCtrl )
|
|
|
|
{
|
|
|
|
wxString title = CurrPage->m_TitleStringCtrl->GetValue();
|
|
|
|
if( msg != title ) // Title has changed, Update config
|
|
|
|
{
|
|
|
|
msg = CUSTOM_NETLIST_TITLE;
|
|
|
|
msg << ii + 1;
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( msg, title );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( CurrPage->m_CommandStringCtrl )
|
|
|
|
{
|
|
|
|
Command = CurrPage->m_CommandStringCtrl->GetValue();
|
2008-12-08 15:27:13 +00:00
|
|
|
msg = CUSTOM_NETLIST_COMMAND;
|
2007-11-05 06:14:55 +00:00
|
|
|
msg << ii + 1;
|
2008-12-08 15:27:13 +00:00
|
|
|
config->Write( msg, 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
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/******************************************************************/
|
|
|
|
void WinEDA_NetlistFrame::DeletePluginPanel( wxCommandEvent& event )
|
|
|
|
/******************************************************************/
|
|
|
|
|
|
|
|
/** Function DeletePluginPanel
|
|
|
|
* Remove a panel relative to a netlist plugin
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
EDA_NoteBookPage* CurrPage =
|
|
|
|
(EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage->m_CommandStringCtrl->SetValue( wxEmptyString );
|
|
|
|
CurrPage->m_TitleStringCtrl->SetValue( wxEmptyString );
|
|
|
|
if( CurrPage->m_IsCurrentFormat->IsChecked() )
|
|
|
|
{
|
|
|
|
CurrPage->m_IsCurrentFormat->SetValue( FALSE );
|
|
|
|
m_PanelNetType[PANELPCBNEW]->m_IsCurrentFormat->SetValue( TRUE );
|
|
|
|
}
|
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
EndModal( NET_PLUGIN_CHANGE );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/******************************************************************/
|
|
|
|
void WinEDA_NetlistFrame::ValidatePluginPanel( wxCommandEvent& event )
|
|
|
|
/******************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/** Function ValidatePluginPanel
|
|
|
|
* Validate the panel info relative to a new netlist plugin
|
|
|
|
*/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
EDA_NoteBookPage* CurrPage =
|
|
|
|
(EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
if( CurrPage->m_CommandStringCtrl->GetValue() == wxEmptyString )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Error. You must provide a command String" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( CurrPage->m_TitleStringCtrl->GetValue() == wxEmptyString )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Error. You must provide a Title" ) );
|
|
|
|
return;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
EndModal( NET_PLUGIN_CHANGE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|