2011-12-16 20:12:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file netlist_control.cpp
|
|
|
|
* @brief Dialog box for creating netlists.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/* Functions relative to the dialog creating the netlist for Pcbnew.
|
2009-11-04 20:46:53 +00:00
|
|
|
* The dialog is a notebook with 4 fixed netlist format:
|
2011-09-30 18:15:37 +00:00
|
|
|
* Pcbnew ORCADPCB2 CADSTAR and SPICE
|
2007-11-10 14:35:04 +00:00
|
|
|
* 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.
|
2009-11-04 20:46:53 +00:00
|
|
|
* these external converters are referred there as plugins,
|
2007-11-10 14:35:04 +00:00
|
|
|
* but there are not really plugins, there are only external binaries
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <netlist.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <netlist_control.h>
|
|
|
|
#include <dialogs/annotate_dialog.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2011-03-31 15:22:34 +00:00
|
|
|
|
2010-06-28 13:11:14 +00:00
|
|
|
//Imported function:
|
2010-07-14 13:24:36 +00:00
|
|
|
int TestDuplicateSheetNames( bool aCreateMarker );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
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
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnUserNetlistTypeName
|
2007-11-10 14:35:04 +00:00
|
|
|
* to retrieve user netlist type names
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param first_item = true: return first name of the list, false = return next
|
2007-11-10 14:35:04 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2010-12-14 15:56:30 +00:00
|
|
|
wxString ReturnUserNetlistTypeName( bool first_item )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
|
|
|
static int index;
|
|
|
|
wxString name, msg;
|
|
|
|
|
|
|
|
if( first_item )
|
|
|
|
index = 0;
|
|
|
|
else
|
|
|
|
index++;
|
|
|
|
|
|
|
|
msg = CUSTOM_NETLIST_TITLE;
|
|
|
|
msg << index + 1;
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
if( wxGetApp().GetSettings() )
|
|
|
|
name = wxGetApp().GetSettings()->Read( msg );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
BEGIN_EVENT_TABLE( NETLIST_DIALOG, wxDialog )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, NETLIST_DIALOG::OnCancelClick )
|
|
|
|
EVT_BUTTON( ID_CREATE_NETLIST, NETLIST_DIALOG::GenNetlist )
|
|
|
|
EVT_BUTTON( ID_SETUP_PLUGIN, NETLIST_DIALOG::AddNewPluginPanel )
|
|
|
|
EVT_BUTTON( ID_DELETE_PLUGIN, NETLIST_DIALOG::DeletePluginPanel )
|
|
|
|
EVT_BUTTON( ID_VALIDATE_PLUGIN, NETLIST_DIALOG::ValidatePluginPanel )
|
2010-12-14 15:56:30 +00:00
|
|
|
EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT,
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_DIALOG::SelectNetlistType )
|
2011-03-31 15:22:34 +00:00
|
|
|
EVT_CHECKBOX( ID_ADD_SUBCIRCUIT_PREFIX,
|
|
|
|
NETLIST_DIALOG::EnableSubcircuitPrefix )
|
2011-02-08 18:39:41 +00:00
|
|
|
EVT_BUTTON( ID_RUN_SIMULATOR, NETLIST_DIALOG::RunSimulator )
|
2007-11-10 14:35:04 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************/
|
|
|
|
/* Functions for these classes */
|
|
|
|
/*******************************/
|
|
|
|
|
|
|
|
|
2010-12-29 17:47:32 +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
|
|
|
|
*/
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent,
|
2011-03-14 15:17:18 +00:00
|
|
|
const wxString& title,
|
|
|
|
int id_NetType,
|
|
|
|
int idCheckBox,
|
|
|
|
int idCreateFile,
|
|
|
|
bool selected ) :
|
2010-12-14 15:56:30 +00:00
|
|
|
wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_SUNKEN )
|
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;
|
2011-04-01 12:12:19 +00:00
|
|
|
m_AddSubPrefix = NULL;
|
2007-11-05 06:14:55 +00:00
|
|
|
m_ButtonCancel = NULL;
|
2012-01-26 09:37:36 +00:00
|
|
|
m_NetOption = NULL;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
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-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
|
|
|
|
2011-03-14 15:17:18 +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
|
|
|
}
|
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
if( id_NetType == NET_TYPE_PCBNEW )
|
|
|
|
{
|
|
|
|
wxString netlist_opt[2] = { _( "Pcbnew Format" ), _( "Advanced Format" ) };
|
|
|
|
m_NetOption = new wxRadioBox( this, -1, _( "Netlist Options:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
2, netlist_opt, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
|
|
|
m_LeftBoxSizer->Add( m_NetOption, 0, wxGROW | wxALL, 5 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Create the buttons: Create Netlist or browse Plugin and Cancel
|
2007-11-10 14:35:04 +00:00
|
|
|
* 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;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
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" ) );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
m_RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
|
2011-03-14 15:17:18 +00:00
|
|
|
Button->SetDefault();
|
|
|
|
m_ButtonCancel = new wxButton( this, wxID_CANCEL, _( "&Cancel" ) );
|
|
|
|
m_RightBoxSizer->Add( m_ButtonCancel, 0, wxGROW | wxALL, 5 );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
|
2008-02-27 19:38:16 +00:00
|
|
|
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
|
|
|
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
|
|
|
|
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,
|
2011-03-14 15:17:18 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxNB_TOP ); // @todo: tabs on top are being hidden on linux
|
2010-08-11 15:32:44 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
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] =
|
2011-02-08 18:39:41 +00:00
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook,
|
2011-03-14 15:17:18 +00:00
|
|
|
wxT( "Pcbnew" ),
|
|
|
|
NET_TYPE_PCBNEW,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->GetNetListFormat() == 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] =
|
2011-02-08 18:39:41 +00:00
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook,
|
2011-03-14 15:17:18 +00:00
|
|
|
wxT( "OrcadPCB2" ),
|
|
|
|
NET_TYPE_ORCADPCB2,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->GetNetListFormat() == 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] =
|
2011-02-08 18:39:41 +00:00
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook,
|
2011-03-14 15:17:18 +00:00
|
|
|
wxT( "CadStar" ),
|
|
|
|
NET_TYPE_CADSTAR,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->GetNetListFormat() == 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();
|
|
|
|
|
2010-08-11 14:47:16 +00:00
|
|
|
// GetSizer()->Fit( this );
|
2007-11-10 14:35:04 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2010-08-11 15:32:44 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
Centre();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::InstallPageSpice()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
wxButton* Button;
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG* page;
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
page = m_PanelNetType[PANELSPICE] =
|
2011-03-14 15:17:18 +00:00
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook,
|
|
|
|
wxT( "Spice" ),
|
|
|
|
NET_TYPE_SPICE,
|
|
|
|
0, 0,
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->GetNetListFormat() == NET_TYPE_SPICE );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
|
|
|
page->m_IsCurrentFormat = new wxCheckBox( page, ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
_( "Default format" ) );
|
2011-12-09 16:37:11 +00:00
|
|
|
page->m_IsCurrentFormat->SetValue( m_Parent->GetNetListFormat() == NET_TYPE_SPICE );
|
2011-03-31 15:22:34 +00:00
|
|
|
page->m_LeftBoxSizer->Add( page->m_IsCurrentFormat, 1, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
page->m_AddSubPrefix = new wxCheckBox( page, ID_ADD_SUBCIRCUIT_PREFIX,
|
|
|
|
_( "Prefix references 'U' and 'IC' with 'X'" ) );
|
2011-12-09 16:37:11 +00:00
|
|
|
page->m_AddSubPrefix->SetValue( m_Parent->GetAddReferencePrefix() );
|
2011-03-31 15:22:34 +00:00
|
|
|
page->m_LeftBoxSizer->Add( page->m_AddSubPrefix, 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" ) };
|
2012-01-26 09:37:36 +00:00
|
|
|
page->m_NetOption = new wxRadioBox( page, -1, _( "Netlist Options:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
2, netlist_opt, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
if( !g_OptNetListUseNames )
|
2012-01-26 09:37:36 +00:00
|
|
|
page->m_NetOption->SetSelection( 1 );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
page->m_LeftBoxSizer->Add( page->m_NetOption, 0, wxGROW | wxALL, 5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2011-09-06 19:42:46 +00:00
|
|
|
page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
|
|
|
|
|
|
|
|
page->m_CommandStringCtrl = new wxTextCtrl( page, -1, m_Parent->GetSimulatorCommand(),
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
|
|
|
|
page->m_CommandStringCtrl->SetInsertionPoint( 1 );
|
|
|
|
page->m_LowBoxSizer->Add( page->m_CommandStringCtrl,
|
|
|
|
0,
|
|
|
|
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
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 );
|
2011-03-14 15:17:18 +00:00
|
|
|
Button->SetDefault();
|
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
|
|
|
/* create the pages for custom netlist format selection:
|
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
|
|
|
{
|
2010-07-14 13:24:36 +00:00
|
|
|
bool selected;
|
|
|
|
int ii, CustomCount;
|
2007-11-10 14:35:04 +00:00
|
|
|
wxString title, previoustitle, msg;
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG* CurrPage;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
CustomCount = CUSTOMPANEL_COUNTMAX;
|
|
|
|
previoustitle = wxT( "dummy_title" );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
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
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
selected = m_Parent->GetNetListFormat() == ( NET_TYPE_CUSTOM1 + ii );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/* Install the panel "Add Plugin" after
|
2009-11-04 20:46:53 +00:00
|
|
|
* the last initialized panel */
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
previoustitle = title;
|
2011-12-09 16:37:11 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
if( title.IsEmpty() )
|
2007-11-10 14:35:04 +00:00
|
|
|
CurrPage =
|
|
|
|
m_PanelNetType[PANELCUSTOMBASE + ii] =
|
2011-02-08 18:39:41 +00:00
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook,
|
2011-03-14 15:17:18 +00:00
|
|
|
_( "Add Plugin" ),
|
|
|
|
NET_TYPE_CUSTOM1 + ii,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_SETUP_PLUGIN,
|
|
|
|
selected );
|
2007-11-10 14:35:04 +00:00
|
|
|
else /* Install a plugin panel */
|
|
|
|
CurrPage =
|
|
|
|
m_PanelNetType[PANELCUSTOMBASE + ii] =
|
2011-02-08 18:39:41 +00:00
|
|
|
new NETLIST_PAGE_DIALOG( m_NoteBook,
|
2011-03-14 15:17:18 +00:00
|
|
|
title,
|
|
|
|
NET_TYPE_CUSTOM1 + ii,
|
|
|
|
ID_CURRENT_FORMAT_IS_DEFAULT,
|
|
|
|
ID_CREATE_NETLIST,
|
|
|
|
selected );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
msg = CUSTOM_NETLIST_COMMAND;
|
|
|
|
msg << ii + 1;
|
2011-12-16 20:12:49 +00:00
|
|
|
wxString Command = wxGetApp().GetSettings()->Read( msg );
|
2011-09-06 19:42:46 +00:00
|
|
|
|
|
|
|
CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage,
|
|
|
|
-1, _( "Netlist command:" ) ), 0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
|
|
|
|
|
|
|
|
CurrPage->m_CommandStringCtrl = new wxTextCtrl( CurrPage, -1, Command,
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
|
|
|
|
CurrPage->m_CommandStringCtrl->SetInsertionPoint( 1 );
|
|
|
|
CurrPage->m_LowBoxSizer->Add( CurrPage->m_CommandStringCtrl,
|
|
|
|
0,
|
|
|
|
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
CurrPage->m_LowBoxSizer->Add( new wxStaticText( CurrPage,
|
|
|
|
-1, _( "Title:" ) ), 0,
|
|
|
|
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
|
|
|
|
|
|
|
|
CurrPage->m_TitleStringCtrl = new wxTextCtrl( CurrPage, -1, title,
|
|
|
|
wxDefaultPosition, wxDefaultSize );
|
|
|
|
|
|
|
|
CurrPage->m_TitleStringCtrl->SetInsertionPoint( 1 );
|
|
|
|
CurrPage->m_LowBoxSizer->Add( CurrPage->m_TitleStringCtrl,
|
|
|
|
0,
|
|
|
|
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
/*
|
|
|
|
* Browse plugin files, add a new panel
|
|
|
|
* and set m_CommandStringCtrl field
|
2007-11-05 06:14:55 +00:00
|
|
|
*/
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::AddNewPluginPanel( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
wxString FullFileName, Mask, Path;
|
|
|
|
|
|
|
|
Mask = wxT( "*" );
|
2011-12-16 20:12:49 +00:00
|
|
|
Path = wxGetApp().GetExecutablePath();
|
2007-11-10 14:35:04 +00:00
|
|
|
FullFileName = EDA_FileSelector( _( "Plugin files:" ),
|
2009-11-04 20:46:53 +00:00
|
|
|
Path,
|
|
|
|
FullFileName,
|
|
|
|
wxEmptyString,
|
|
|
|
Mask,
|
2007-11-10 14:35:04 +00:00
|
|
|
this,
|
|
|
|
wxFD_OPEN,
|
2011-03-14 15:17:18 +00:00
|
|
|
true
|
2007-11-10 14:35:04 +00:00
|
|
|
);
|
2007-11-05 06:14:55 +00:00
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG* CurrPage;
|
|
|
|
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-02-08 12:01:14 +00:00
|
|
|
// Creates a default command line, suitable for external tool xslproc:
|
2011-02-08 18:39:41 +00:00
|
|
|
// try to build a default command line depending on plugin extension
|
2011-02-08 12:01:14 +00:00
|
|
|
wxString cmdLine;
|
2011-02-08 18:39:41 +00:00
|
|
|
wxFileName fn( FullFileName );
|
|
|
|
wxString ext = fn.GetExt();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
if( ext == wxT("xsl" ) )
|
2011-02-10 08:27:36 +00:00
|
|
|
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) );
|
2011-02-08 18:39:41 +00:00
|
|
|
else if( ext == wxT("exe" ) || ext.IsEmpty() )
|
2011-02-10 08:27:36 +00:00
|
|
|
cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) );
|
2011-02-08 18:39:41 +00:00
|
|
|
else
|
|
|
|
cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) );
|
|
|
|
|
2011-02-08 12:01:14 +00:00
|
|
|
CurrPage->m_CommandStringCtrl->SetValue( cmdLine );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
|
|
|
/* Get a title for this page */
|
|
|
|
wxString title = CurrPage->m_TitleStringCtrl->GetValue();
|
2011-09-06 19:42:46 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
if( title.IsEmpty() )
|
2009-04-17 08:51:02 +00:00
|
|
|
DisplayInfoMessage( this,
|
2011-03-14 15:17:18 +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 15:02:33 +00:00
|
|
|
/* Called when the check box "default format" is clicked
|
2008-12-08 15:27:13 +00:00
|
|
|
*/
|
2011-03-14 15:17:18 +00:00
|
|
|
void NETLIST_DIALOG::SelectNetlistType( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-11-10 14:35:04 +00:00
|
|
|
int ii;
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG* 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] )
|
2011-03-14 15:17:18 +00:00
|
|
|
m_PanelNetType[ii]->m_IsCurrentFormat->SetValue( false );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->SetNetListFormat( CurrPage->m_IdNetType );
|
2011-03-14 15:17:18 +00:00
|
|
|
CurrPage->m_IsCurrentFormat->SetValue( true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2011-04-01 12:12:19 +00:00
|
|
|
/* Called when the check box m_AddSubPrefix
|
|
|
|
* "default format" is clicked
|
|
|
|
* ( Spice format only )
|
2011-03-31 15:22:34 +00:00
|
|
|
*/
|
|
|
|
void NETLIST_DIALOG::EnableSubcircuitPrefix( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
|
|
|
|
NETLIST_PAGE_DIALOG* CurrPage;
|
|
|
|
|
|
|
|
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
|
|
|
|
2011-04-01 12:12:19 +00:00
|
|
|
if( CurrPage == NULL || CurrPage->m_AddSubPrefix == NULL )
|
2011-03-31 15:22:34 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->SetAddReferencePrefix( CurrPage->m_AddSubPrefix->IsChecked() );
|
2011-03-31 15:22:34 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::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
|
|
|
|
2011-06-15 18:44:24 +00:00
|
|
|
m_Parent->SetSimulatorCommand( m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue() );
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->SetNetListFormat( 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;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
|
|
|
if( m_PanelNetType[ii]->m_IsCurrentFormat->GetValue() == true )
|
2011-12-09 16:37:11 +00:00
|
|
|
m_Parent->SetNetListFormat( m_PanelNetType[ii]->m_IdNetType );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
g_OptNetListUseNames = true; // Used for pspice, gnucap
|
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
if( m_PanelNetType[PANELSPICE]->m_NetOption->GetSelection() == 1 )
|
2011-03-14 15:17:18 +00:00
|
|
|
g_OptNetListUseNames = false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function GenNetlist
|
2007-11-10 14:35:04 +00:00
|
|
|
* Create the netlist file:
|
2009-11-04 20:46:53 +00:00
|
|
|
* calculate the filename with the suitable extensions
|
2007-11-10 14:35:04 +00:00
|
|
|
* and run the netlist creator
|
|
|
|
*/
|
2011-03-14 15:17:18 +00:00
|
|
|
void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
|
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
|
|
|
|
2011-02-08 18:39:41 +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;
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
/* Calculate the netlist filename */
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
switch( CurrPage->m_IdNetType )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
|
|
|
case NET_TYPE_SPICE:
|
2010-08-11 14:47:16 +00:00
|
|
|
fileExt = wxT( "cir" );
|
|
|
|
fileWildcard = _( "SPICE netlist file (.cir)|*.cir" );
|
2012-01-26 09:37:36 +00:00
|
|
|
// Set spice netlist options:
|
|
|
|
if( g_OptNetListUseNames )
|
|
|
|
netlist_opt |= NET_USE_NETNAMES;
|
|
|
|
if( CurrPage->m_AddSubPrefix->GetValue() )
|
|
|
|
netlist_opt |= NET_USE_X_PREFIX;
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_TYPE_CADSTAR:
|
2010-08-11 14:47:16 +00:00
|
|
|
fileExt = wxT( "frp" );
|
|
|
|
fileWildcard = _( "CadStar netlist file (.frp)|*.frp" );
|
2007-11-05 06:14:55 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-11 05:58:34 +00:00
|
|
|
case NET_TYPE_PCBNEW:
|
2012-01-26 09:37:36 +00:00
|
|
|
if( CurrPage->m_NetOption->GetSelection() != 0 )
|
|
|
|
netlist_opt = NET_PCBNEW_USE_NEW_FORMAT;
|
|
|
|
fileExt = NetlistFileExtension;
|
|
|
|
fileWildcard = NetlistFileWildcard;
|
|
|
|
break;
|
|
|
|
|
2010-08-11 14:47:16 +00:00
|
|
|
case NET_TYPE_ORCADPCB2:
|
|
|
|
fileExt = NetlistFileExtension;
|
|
|
|
fileWildcard = NetlistFileWildcard;
|
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
|
2012-01-26 09:37:36 +00:00
|
|
|
fileExt = wxEmptyString;
|
2010-08-11 14:47:16 +00:00
|
|
|
fileWildcard = AllFilesWildcard;
|
|
|
|
title.Printf( _( "%s Export" ), CurrPage->m_TitleStringCtrl->GetValue().GetData() );
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
|
|
|
|
2010-08-11 14:47:16 +00:00
|
|
|
fn.SetExt( fileExt );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-08-11 05:58:34 +00:00
|
|
|
wxFileDialog dlg( this, title, fn.GetPath(),
|
2010-08-11 14:47:16 +00:00
|
|
|
fn.GetFullName(), fileWildcard,
|
2010-07-14 13:24:36 +00:00
|
|
|
wxFD_SAVE );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-11-05 06:14:55 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
m_Parent->ClearMsgPanel();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
if( CurrPage->m_CommandStringCtrl )
|
2011-06-15 18:44:24 +00:00
|
|
|
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
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
m_Parent->CreateNetlist( CurrPage->m_IdNetType, dlg.GetPath(), netlist_opt );
|
2010-07-14 13:24:36 +00:00
|
|
|
|
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
|
|
|
|
EndModal( NET_OK );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
/* Function CreateNetlist
|
|
|
|
* > test for some issues (missing or duplicate references and sheet names)
|
|
|
|
* > build netlist info
|
|
|
|
* > create the netlist file
|
|
|
|
* param aFormat = netlist format (NET_TYPE_PCBNEW ...)
|
|
|
|
* param aFullFileName = full netlist file name
|
|
|
|
* param aNetlistOptions = netlist options using OR'ed bits (see WriteNetListFile).
|
|
|
|
* return true if success.
|
2010-07-14 13:24:36 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
|
2012-01-26 09:37:36 +00:00
|
|
|
unsigned aNetlistOptions )
|
2010-07-14 13:24:36 +00:00
|
|
|
{
|
2010-12-31 19:47:39 +00:00
|
|
|
SCH_SHEET_LIST sheets;
|
|
|
|
sheets.AnnotatePowerSymbols();
|
2010-07-14 13:24:36 +00:00
|
|
|
|
|
|
|
// Performs some controls:
|
|
|
|
if( CheckAnnotate( NULL, 0 ) )
|
2007-11-05 06:14:55 +00:00
|
|
|
{
|
2011-01-10 17:47:50 +00:00
|
|
|
if( !IsOK( NULL, _( "Some items are not annotated\n\
|
|
|
|
Do you want to annotate schematic?" ) ) )
|
|
|
|
return false;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2011-01-10 17:47:50 +00:00
|
|
|
// Schematic must be annotated: call Annotate dialog:
|
|
|
|
wxCommandEvent event;
|
|
|
|
OnAnnotate( event );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2011-01-10 17:47:50 +00:00
|
|
|
if( CheckAnnotate( NULL, 0 ) )
|
2010-07-14 13:24:36 +00:00
|
|
|
return false;
|
2007-11-05 06:14:55 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 13:11:14 +00:00
|
|
|
// Test duplicate sheet names:
|
2010-07-14 13:24:36 +00:00
|
|
|
if( TestDuplicateSheetNames( false ) > 0 )
|
2010-06-28 13:11:14 +00:00
|
|
|
{
|
2010-07-14 13:24:36 +00:00
|
|
|
if( !IsOK( NULL, _( "Error: duplicate sheet names. Continue?" ) ) )
|
|
|
|
return false;
|
2010-06-28 13:11:14 +00:00
|
|
|
}
|
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
/* Cleanup the entire hierarchy */
|
2010-12-31 19:47:39 +00:00
|
|
|
SCH_SCREENS screens;
|
|
|
|
screens.SchematicCleanUp();
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
BuildNetListBase();
|
2012-01-26 09:37:36 +00:00
|
|
|
bool success = WriteNetListFile( aFormat, aFullFileName, aNetlistOptions );
|
2007-11-05 06:14:55 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
return success;
|
2007-11-10 14:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::OnCancelClick( wxCommandEvent& event )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
|
|
|
EndModal( NET_ABORT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2010-07-14 13:24:36 +00:00
|
|
|
wxString ExecFile, CommandLine;
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2011-06-15 18:44:24 +00:00
|
|
|
wxString tmp = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue();
|
|
|
|
tmp.Trim( false );
|
|
|
|
tmp.Trim( true );
|
|
|
|
m_Parent->SetSimulatorCommand( tmp );
|
|
|
|
ExecFile = tmp.BeforeFirst( ' ' );
|
|
|
|
CommandLine = tmp.AfterFirst( ' ' );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
|
|
|
/* Calculate the netlist filename */
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( wxT( "cir" ) );
|
|
|
|
CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" );
|
2007-11-10 14:35:04 +00:00
|
|
|
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG* CurrPage;
|
|
|
|
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
|
2012-01-26 09:37:36 +00:00
|
|
|
g_OptNetListUseNames = CurrPage->m_NetOption->GetSelection() == 0;
|
2010-07-14 13:24:36 +00:00
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
// Set spice netlist options:
|
|
|
|
unsigned netlist_opt = 0;
|
2011-06-15 18:44:24 +00:00
|
|
|
|
2012-01-26 09:37:36 +00:00
|
|
|
if( g_OptNetListUseNames )
|
|
|
|
netlist_opt |= NET_USE_NETNAMES;
|
|
|
|
if( CurrPage->m_AddSubPrefix && CurrPage->m_AddSubPrefix->GetValue() )
|
|
|
|
netlist_opt |= NET_USE_X_PREFIX;
|
2011-06-15 18:44:24 +00:00
|
|
|
|
2011-03-31 15:22:34 +00:00
|
|
|
if( ! m_Parent->CreateNetlist( CurrPage->m_IdNetType, fn.GetFullPath(),
|
2012-01-26 09:37:36 +00:00
|
|
|
netlist_opt ) )
|
2010-07-14 13:24:36 +00:00
|
|
|
return;
|
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
ExecuteFile( this, ExecFile, CommandLine );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function WriteCurrentNetlistSetup
|
2007-11-10 14:35:04 +00:00
|
|
|
* Write the current netlist options setup in the configuration
|
|
|
|
*/
|
2011-03-14 15:17:18 +00:00
|
|
|
void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2010-07-14 13:24:36 +00:00
|
|
|
wxString msg, Command;
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfig* config = wxGetApp().GetSettings();
|
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++ )
|
|
|
|
{
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_PAGE_DIALOG* CurrPage = m_PanelNetType[ii + PANELCUSTOMBASE];
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage == NULL )
|
|
|
|
break;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
msg = wxT( "Custom" );
|
2007-11-05 06:14:55 +00:00
|
|
|
msg << ii + 1;
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
if( CurrPage->m_TitleStringCtrl )
|
|
|
|
{
|
|
|
|
wxString title = CurrPage->m_TitleStringCtrl->GetValue();
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-05 06:14:55 +00:00
|
|
|
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
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function DeletePluginPanel
|
2007-11-10 14:35:04 +00:00
|
|
|
* Remove a panel relative to a netlist plugin
|
|
|
|
*/
|
2011-03-14 15:17:18 +00:00
|
|
|
void NETLIST_DIALOG::DeletePluginPanel( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
NETLIST_PAGE_DIALOG* CurrPage = (NETLIST_PAGE_DIALOG*) 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 );
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
if( CurrPage->m_IsCurrentFormat->IsChecked() )
|
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
CurrPage->m_IsCurrentFormat->SetValue( false );
|
|
|
|
m_PanelNetType[PANELPCBNEW]->m_IsCurrentFormat->SetValue( true );
|
2007-11-10 14:35:04 +00:00
|
|
|
}
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
WriteCurrentNetlistSetup();
|
|
|
|
EndModal( NET_PLUGIN_CHANGE );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ValidatePluginPanel
|
2007-11-10 14:35:04 +00:00
|
|
|
* Validate the panel info relative to a new netlist plugin
|
|
|
|
*/
|
2011-03-14 15:17:18 +00:00
|
|
|
void NETLIST_DIALOG::ValidatePluginPanel( wxCommandEvent& event )
|
2007-11-10 14:35:04 +00:00
|
|
|
{
|
2011-03-14 15:17:18 +00:00
|
|
|
NETLIST_PAGE_DIALOG* CurrPage = (NETLIST_PAGE_DIALOG*) 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;
|
|
|
|
}
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2007-11-10 14:35:04 +00:00
|
|
|
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
|
|
|
}
|