Commit 7eb1a136 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: First draft to use a new netlist format ( containing the same info as...

Pcbnew:  First draft to use a new netlist format ( containing the same info as the intermediate netlist, but using S expressions)
* Eeschema can generate this netlist format.
*   Pcbnew can use (automatic identification) the current format or the new format.
*   Cvpcb does not use yet the new format.
parent 4cbb5c5e
...@@ -4,6 +4,16 @@ KiCad ChangeLog 2012 ...@@ -4,6 +4,16 @@ KiCad ChangeLog 2012
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2012-Jan-26, UPDATE Jean-Pierre Charras <jp.charras@wanadoo.fr>
================================================================================
Pcbnew:
First draft to use a new netlist format (using S expressions)
Eeschema can generate this netlist format.
Pcbnew can use (automatic identification) the current format or the new format.
Cvpcb does not use yet the new format.
To do:
New format in Cvpcb: how to use the .cmp file with the new netlist format
2012-Jan-22 UPDATE Dick Hollenbeck <dick@softplc.com> 2012-Jan-22 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
......
KiCad installation
==================
The parts of KiCad
------------------
KiCad consists of 3 packages:
kicad - KiCad programs and core files.
kicad-doc - Documentation and interactive help (optional package).
kicad-library - KiCad schematic, pcb & 3D-model libraries (optional package).
Installation from binary packages
---------------------------------
KiCad binary packages exist for Linux and Windows (XP, 2000).
Data files (schematic, boards, libraries) are compatible with all platforms.
*.zip - KiCad packages for Windows.
*.tbz2 - KiCad for Linux.
Installation from binary packages for Windows
---------------------------------------------
KiCad can be installed in 'C:\kicad', 'D:\kicad', 'C:\Program files\kicad',
'D:\Program files\kicad'.
For example, for an installation in the folder 'C:\kicad', unzip KiCad
packages:
kicad-{version}.zip
kicad-doc-{version}.zip
kicad-library-{version}.zip
to the folder 'C:\kicad'.
The main program is the project manager (kicad.exe) and from it you can run
the other programs (schematic editor - eeschema, pcb editor - pcbnew,
utilities: cvpcb and gerbview).
You can create a shortcut to 'C:\kicad\bin\kicad.exe'.
Installation from binary packages for Linux
-------------------------------------------
KiCad can be installed in '/usr' or '/usr/local'.
You must have "root" access for installation.
cd /
tar -xjf kicad-{version}.tbz2
tar -xjf kicad-doc-{version}.tbz2
tar -xjf kicad-library-{version}.tbz2
The main program is '/usr/bin/kicad'.
Windows KiCad tree
------------------
kicad/bin - Binaries (executable files).
kicad/doc - Various documentation.
kicad/doc/help - Interactive help.
kicad/share/demos - Sample schematics and printed boards.
kicad/share/internat - Interface localization files.
kicad/share/library - Libraries for schematic.
kicad/share/modules - Module libraries for printed boards.
kicad/share/modules/packages3d - 3D component models (.wrl and .wings format).
Files '*.mod' are libraries, and files '*.brd' are printed boards you can
view with pcbnew.
Files *.brd show the existing modules (and 3D shapes) in libraries.
Linux KiCad tree
----------------
/usr/bin - Binaries (executable files).
/usr/share/doc/kicad/ - Various documentation.
/usr/share/doc/kicad/help - Interactive help.
/usr/share/kicad/demos - Sample schematics and printed boards.
/usr/share/kicad/internat - Dictionaries for interface localization.
/usr/share/kicad/library - Interface localization files.
/usr/share/kicad/modules - Module libraries for printed boards.
/usr/share/kicad/modules/packages3d - 3D component models (.wrl and .wings format).
if not found search kicad in
/usr/local/
and if found, kicad uses the same tree as the Windows KiCad tree above
Files '*.mod' are the libraries, and files '*.brd' are printed boards you can
view with pcbnew.
Files *.brd show the existing modules (and 3D shapes) in libraries.
Warning:
Do not change the KiCad tree, or the location of binary files,
else KiCad will not be able to find its required files (configuration,
libraries, etc.).
Mac OS X KiCad tree
-------------------
System wide files
/Library/Application Support/kicad/demos
/Library/Application Support/kicad/internat
/Library/Application Support/kicad/library
/Library/Application Support/kicad/modules
/Library/Application Support/kicad/modules/packages3d
User files can be the same as the system wide files but only inside the users home directory.
$HOME/Library/Application Support/kicad
Warning:
These paths are hardcoded into KiCad, if you put them somewhere else KiCad will not find them when a new
project is created.
Installation from source code
-----------------------------
Some dependencies must be satisfied for the correct installation of KiCad:
wxWidgets >= 2.8.11 http://www.wxwidgets.org/
CMake >= 2.6.4 http://www.cmake.org/
Boost C++ Libraries (files used by kicad are provided in kicad sources) http://www.boost.org/
OpenGL
Linux: Mesa 3D Graphics Library http://www.mesa3d.org/
Windows: built-in
Zlib Compression Library http://www.zlib.net/
In source-tree-build are mostly unwanted, so make a subdir called "build" and
change to it.
Call cmake with the path to KiCad. E.g., when your build-folder is "build"
within source-tree, type "cmake ../".
Now your system get checked if it is able compiling KiCad and cmake generates
the Makefiles.
After calling cmake just type "make" and build begins.
It is easy to build only a specific binary such as pcbnew alone:
make pcbnew
After "make" type "make install" and install begins.
You may install to a temporary-root with
make install DESTDIR=<temproot>
If you want to uninstall KiCad again type "make uninstall" from within the
build directory.
Important parameters to cmake
-----------------------------
-DCMAKE_BUILD_TYPE=<buildtype>
<buildtype> may current one of "Debug" and "Release".
-DCMAKE_INSTALL_PREFIX=<prefix>
Default to "/usr/local".
-DwxWidgets_ROOT_DIR=<wxInstallDir>
Required for Windows platform.
-DwxWidgets_USE_DEBUG=ON
Can be used only with -DCMAKE_BUILD_TYPE=Debug
-DwxWidgets_USE_STATIC=ON
For building statically linked executables. Can be used only if wxWidgets
configured and builded with "--enable-monolithic --disable-shared" parameters.
-DwxWidgets_USE_STATIC=OFF
For building dinamically linked executables. Can be used only if wxWidgets
configured and builded with "--disable-monolithic --enable-shared" parameters.
-DwxUSE_UNICODE=ON
Require on locale utf8 for build the KiCad with cyrillic fonts support.
-DKICAD_GOST=ON
Build the KiCad with russian GOST support.
-DKICAD_KEEPCASE=ON
Build the KiCad with no component name conversion to uppercase (if you want your
ADuC.../Si.../bq... components named as just so).
-DCMAKE_CXX_FLAGS=<some extra flags>
Extra flags for the c++ compiler for your system required.
-DCMAKE_VERBOSE_MAKEFILE=ON
When more output is wanted use this cmake parameter or call "make VERBOSE=1".
Extra CFLAGS and linker flags
-----------------------------
If you require extra flags for compiler and linker you may give them via
environment variables
"CXXFLAGS" (c++ compiler)
"LDFLAGS" (for linker)
"CFLAGS" (for c-compiler, not needed in kdesvn build)
eg., it may usefull on 64bit systems "-m64" to CXXFLAGS and LDFLAGS.
This diff is collapsed.
This diff is collapsed.
...@@ -126,6 +126,7 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, ...@@ -126,6 +126,7 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent,
m_IsCurrentFormat = NULL; m_IsCurrentFormat = NULL;
m_AddSubPrefix = NULL; m_AddSubPrefix = NULL;
m_ButtonCancel = NULL; m_ButtonCancel = NULL;
m_NetOption = NULL;
parent->AddPage( this, title, selected ); parent->AddPage( this, title, selected );
...@@ -153,7 +154,18 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, ...@@ -153,7 +154,18 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent,
m_IsCurrentFormat->SetValue( selected ); m_IsCurrentFormat->SetValue( selected );
} }
/* Create the buttons: Create Neltist or browse Plugin and Cancel 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
* and a third button for plugins : Remove or Ok button */ * and a third button for plugins : Remove or Ok button */
if( idCreateFile ) if( idCreateFile )
{ {
...@@ -275,15 +287,15 @@ void NETLIST_DIALOG::InstallPageSpice() ...@@ -275,15 +287,15 @@ void NETLIST_DIALOG::InstallPageSpice()
wxString netlist_opt[2] = { _( "Use Net Names" ), _( "Use Net Numbers" ) }; wxString netlist_opt[2] = { _( "Use Net Names" ), _( "Use Net Numbers" ) };
m_UseNetNamesInNetlist = new wxRadioBox( page, -1, _( "Netlist Options:" ), page->m_NetOption = new wxRadioBox( page, -1, _( "Netlist Options:" ),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
2, netlist_opt, 1, 2, netlist_opt, 1,
wxRA_SPECIFY_COLS ); wxRA_SPECIFY_COLS );
if( !g_OptNetListUseNames ) if( !g_OptNetListUseNames )
m_UseNetNamesInNetlist->SetSelection( 1 ); page->m_NetOption->SetSelection( 1 );
page->m_LeftBoxSizer->Add( m_UseNetNamesInNetlist, 0, wxGROW | wxALL, 5 ); page->m_LeftBoxSizer->Add( page->m_NetOption, 0, wxGROW | wxALL, 5 );
page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0, page->m_LowBoxSizer->Add( new wxStaticText( page, -1, _( "Simulator command:" ) ), 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
...@@ -496,7 +508,7 @@ void NETLIST_DIALOG::NetlistUpdateOpt() ...@@ -496,7 +508,7 @@ void NETLIST_DIALOG::NetlistUpdateOpt()
g_OptNetListUseNames = true; // Used for pspice, gnucap g_OptNetListUseNames = true; // Used for pspice, gnucap
if( m_UseNetNamesInNetlist->GetSelection() == 1 ) if( m_PanelNetType[PANELSPICE]->m_NetOption->GetSelection() == 1 )
g_OptNetListUseNames = false; g_OptNetListUseNames = false;
} }
...@@ -519,6 +531,8 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -519,6 +531,8 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
NETLIST_PAGE_DIALOG* CurrPage; NETLIST_PAGE_DIALOG* CurrPage;
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
unsigned netlist_opt = 0;
/* Calculate the netlist filename */ /* Calculate the netlist filename */
fn = g_RootSheet->GetScreen()->GetFileName(); fn = g_RootSheet->GetScreen()->GetFileName();
...@@ -527,6 +541,11 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -527,6 +541,11 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
case NET_TYPE_SPICE: case NET_TYPE_SPICE:
fileExt = wxT( "cir" ); fileExt = wxT( "cir" );
fileWildcard = _( "SPICE netlist file (.cir)|*.cir" ); fileWildcard = _( "SPICE netlist file (.cir)|*.cir" );
// Set spice netlist options:
if( g_OptNetListUseNames )
netlist_opt |= NET_USE_NETNAMES;
if( CurrPage->m_AddSubPrefix->GetValue() )
netlist_opt |= NET_USE_X_PREFIX;
break; break;
case NET_TYPE_CADSTAR: case NET_TYPE_CADSTAR:
...@@ -535,13 +554,19 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -535,13 +554,19 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
break; break;
case NET_TYPE_PCBNEW: case NET_TYPE_PCBNEW:
if( CurrPage->m_NetOption->GetSelection() != 0 )
netlist_opt = NET_PCBNEW_USE_NEW_FORMAT;
fileExt = NetlistFileExtension;
fileWildcard = NetlistFileWildcard;
break;
case NET_TYPE_ORCADPCB2: case NET_TYPE_ORCADPCB2:
fileExt = NetlistFileExtension; fileExt = NetlistFileExtension;
fileWildcard = NetlistFileWildcard; fileWildcard = NetlistFileWildcard;
break; break;
default: // custom, NET_TYPE_CUSTOM1 and greater default: // custom, NET_TYPE_CUSTOM1 and greater
fileExt = wxEmptyString; // wxT( "" ); fileExt = wxEmptyString;
fileWildcard = AllFilesWildcard; fileWildcard = AllFilesWildcard;
title.Printf( _( "%s Export" ), CurrPage->m_TitleStringCtrl->GetValue().GetData() ); title.Printf( _( "%s Export" ), CurrPage->m_TitleStringCtrl->GetValue().GetData() );
} }
...@@ -562,12 +587,7 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -562,12 +587,7 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
else else
m_Parent->SetNetListerCommand( wxEmptyString ); m_Parent->SetNetListerCommand( wxEmptyString );
bool addSubPrefix = false; m_Parent->CreateNetlist( CurrPage->m_IdNetType, dlg.GetPath(), netlist_opt );
if( CurrPage->m_AddSubPrefix )
addSubPrefix = CurrPage->m_AddSubPrefix->GetValue();
m_Parent->CreateNetlist( CurrPage->m_IdNetType, dlg.GetPath(), g_OptNetListUseNames,
addSubPrefix );
WriteCurrentNetlistSetup(); WriteCurrentNetlistSetup();
...@@ -575,22 +595,17 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) ...@@ -575,22 +595,17 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
} }
/** /* Function CreateNetlist
* Function CreateNetlist * > test for some issues (missing or duplicate references and sheet names)
* Create a netlist file: * > build netlist info
* build netlist info * > create the netlist file
* test issues * param aFormat = netlist format (NET_TYPE_PCBNEW ...)
* create file * param aFullFileName = full netlist file name
* @param aFormat = netlist format (NET_TYPE_PCBNEW ...) * param aNetlistOptions = netlist options using OR'ed bits (see WriteNetListFile).
* @param aFullFileName = full netlist file name * return true if success.
* @param aUse_netnames = bool. if true, use net names from labels in schematic
* if false, use net numbers (net codes)
* bool aUse_netnames is used only for Spice netlist
* @return true if success.
*/ */
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName, bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
bool aUse_netnames, unsigned aNetlistOptions )
bool aUsePrefix )
{ {
SCH_SHEET_LIST sheets; SCH_SHEET_LIST sheets;
sheets.AnnotatePowerSymbols(); sheets.AnnotatePowerSymbols();
...@@ -622,7 +637,7 @@ Do you want to annotate schematic?" ) ) ) ...@@ -622,7 +637,7 @@ Do you want to annotate schematic?" ) ) )
screens.SchematicCleanUp(); screens.SchematicCleanUp();
BuildNetListBase(); BuildNetListBase();
bool success = WriteNetListFile( aFormat, aFullFileName, g_OptNetListUseNames, aUsePrefix ); bool success = WriteNetListFile( aFormat, aFullFileName, aNetlistOptions );
return success; return success;
} }
...@@ -651,17 +666,20 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) ...@@ -651,17 +666,20 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
fn.SetExt( wxT( "cir" ) ); fn.SetExt( wxT( "cir" ) );
CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" ); CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" );
g_OptNetListUseNames = m_UseNetNamesInNetlist->GetSelection() == 0;
NETLIST_PAGE_DIALOG* CurrPage; NETLIST_PAGE_DIALOG* CurrPage;
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
g_OptNetListUseNames = CurrPage->m_NetOption->GetSelection() == 0;
bool addSubPrefix = false; // Set spice netlist options:
unsigned netlist_opt = 0;
if( CurrPage->m_AddSubPrefix ) if( g_OptNetListUseNames )
addSubPrefix = CurrPage->m_AddSubPrefix->GetValue(); netlist_opt |= NET_USE_NETNAMES;
if( CurrPage->m_AddSubPrefix && CurrPage->m_AddSubPrefix->GetValue() )
netlist_opt |= NET_USE_X_PREFIX;
if( ! m_Parent->CreateNetlist( CurrPage->m_IdNetType, fn.GetFullPath(), if( ! m_Parent->CreateNetlist( CurrPage->m_IdNetType, fn.GetFullPath(),
g_OptNetListUseNames,addSubPrefix ) ) netlist_opt ) )
return; return;
ExecuteFile( this, ExecFile, CommandLine ); ExecuteFile( this, ExecFile, CommandLine );
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#ifndef _NETLIST_CONTROL_H_ #ifndef _NETLIST_CONTROL_H_
#define _NETLIST_CONTROL_H_ #define _NETLIST_CONTROL_H_
class WinEDA_EnterText;
/* Event id for notebook page buttons: */ /* Event id for notebook page buttons: */
enum id_netlist { enum id_netlist {
...@@ -55,7 +53,9 @@ public: ...@@ -55,7 +53,9 @@ public:
wxBoxSizer* m_RightBoxSizer; wxBoxSizer* m_RightBoxSizer;
wxBoxSizer* m_RightOptionsBoxSizer; wxBoxSizer* m_RightOptionsBoxSizer;
wxBoxSizer* m_LowBoxSizer; wxBoxSizer* m_LowBoxSizer;
wxRadioBox* m_NetOption;
public:
/** Contructor to create a setup page for one netlist format. /** Contructor to create a setup page for one netlist format.
* Used in Netlist format Dialog box creation * Used in Netlist format Dialog box creation
* @param parent = wxNotebook * parent * @param parent = wxNotebook * parent
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
#define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins #define CUSTOMPANEL_COUNTMAX 8 // Max number of netlist plugins
/* Id to select netlist type */ // Id to select netlist type
enum TypeNetForm { enum TypeNetForm {
NET_TYPE_UNINIT = 0, NET_TYPE_UNINIT = 0,
NET_TYPE_PCBNEW, NET_TYPE_PCBNEW,
...@@ -90,6 +90,12 @@ enum TypeNetForm { ...@@ -90,6 +90,12 @@ enum TypeNetForm {
NET_TYPE_CUSTOM_MAX = NET_TYPE_CUSTOM1 + CUSTOMPANEL_COUNTMAX - 1 NET_TYPE_CUSTOM_MAX = NET_TYPE_CUSTOM1 + CUSTOMPANEL_COUNTMAX - 1
}; };
// Options for Spice netlist generation (OR'ed bits
enum netlistOptions {
NET_USE_NETNAMES = 1, // for Spice netlist : use netnames instead of numbers
NET_USE_X_PREFIX = 2, // for Spice netlist : change "U" and "IC" refernce prefix to "X"
NET_PCBNEW_USE_NEW_FORMAT = 1, // For Pcbnew use the new format (S expression and SWEET)
};
/* Dialog frame for creating netlists */ /* Dialog frame for creating netlists */
class NETLIST_DIALOG : public wxDialog class NETLIST_DIALOG : public wxDialog
...@@ -98,7 +104,6 @@ public: ...@@ -98,7 +104,6 @@ public:
SCH_EDIT_FRAME* m_Parent; SCH_EDIT_FRAME* m_Parent;
wxNotebook* m_NoteBook; wxNotebook* m_NoteBook;
NETLIST_PAGE_DIALOG* m_PanelNetType[4 + CUSTOMPANEL_COUNTMAX]; NETLIST_PAGE_DIALOG* m_PanelNetType[4 + CUSTOMPANEL_COUNTMAX];
wxRadioBox* m_UseNetNamesInNetlist;
public: public:
......
...@@ -445,37 +445,43 @@ public: ...@@ -445,37 +445,43 @@ public:
/** /**
* Function CreateNetlist * Function CreateNetlist
* Create a netlist file: * <ul>
* build netlist info * <li> test for some issues (missing or duplicate references and sheet names)
* test issues * <li> build netlist info
* create file * <li> create the netlist file (different formats)
* </ul>
* @param aFormat = netlist format (NET_TYPE_PCBNEW ...) * @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
* @param aFullFileName = full netlist file name * @param aFullFileName = full netlist file name
* @param aUse_netnames = bool. if true, use net names from labels in schematic * @param aNetlistOptions = netlist options using OR'ed bits.
* if false, use net numbers (net codes) * <p>
* bool aUse_netnames is used only for Spice netlist * For SPICE netlist only:
* @param aUsePrefix Prefix reference designator with an 'X' for spice output. * if NET_USE_NETNAMES is set, use net names from labels in schematic
* else use net numbers (net codes)
* if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
* </p>
* @return true if success. * @return true if success.
*/ */
bool CreateNetlist( int aFormat, bool CreateNetlist( int aFormat,
const wxString& aFullFileName, const wxString& aFullFileName,
bool aUse_netnames, unsigned aNetlistOptions );
bool aUsePrefix );
/** /**
* Function WriteNetListFile * Function WriteNetListFile
* Create the netlist file. Netlist info must be existing * Create the netlist file. Netlist info must be existing
* @param aFormat = netlist format (NET_TYPE_PCBNEW ...) * @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
* @param aFullFileName = full netlist file name * @param aFullFileName = full netlist file name
* @param aUse_netnames = bool. if true, use net names from labels in schematic * @param aNetlistOptions = netlist options using OR'ed bits.
* if false, use net numbers (net codes) * <p>
* bool aUse_netnames is used only for Spice netlist * For SPICE netlist only:
* if NET_USE_NETNAMES is set, use net names from labels in schematic
* else use net numbers (net codes)
* if NET_USE_X_PREFIX is set : change "U" and "IC" refernce prefix to "X"
* </p>
* @return true if success. * @return true if success.
*/ */
bool WriteNetListFile( int aFormat, bool WriteNetListFile( int aFormat,
const wxString& aFullFileName, const wxString& aFullFileName,
bool aUse_netnames, unsigned aNetlistOptions );
bool aUsePrefix );
/** /**
* Function DeleteAnnotation * Function DeleteAnnotation
......
...@@ -1336,12 +1336,11 @@ public: ...@@ -1336,12 +1336,11 @@ public:
/** /**
* Function RemoveMisConnectedTracks * Function RemoveMisConnectedTracks
* finds all track segments which are mis-connected (to more than one net). * finds all track segments which are mis-connected (to more than one net).
* When such a bad segment is found, mark it as needing to be removed. * When such a bad segment is found, it is flagged to be removed.
* and remove all tracks having at least one flagged segment. * All tracks having at least one flagged segment are removed.
* @param aDC = the current device context (can be NULL)
* @return true if any change is made * @return true if any change is made
*/ */
bool RemoveMisConnectedTracks( wxDC* aDC ); bool RemoveMisConnectedTracks();
// Autoplacement: // Autoplacement:
......
KiCad Free Documentation Licence
================================
Copyright (c) jean-pierre Charras
Copyright (C) KiCad Developers
Everyone is permitted to copy and distribute verbatim copies
of this licence document, but changing it is not allowed.
KICAD FREE DOCUMENTATION LICENCE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1. Permission is granted to make and distribute verbatim copies of this
manual or piece of documentation provided any copyright notice and this
permission notice are preserved on all copies.
2. Permission is granted to process this file or document through a
document processing system and, at your option and the option of any third
party, print the results, provided a printed document carries a copying
permission notice identical to this one.
3. Permission is granted to copy and distribute modified versions of this
manual or piece of documentation under the conditions for verbatim
copying, provided also that any sections describing licensing conditions
for this manual, such as, in particular, the GNU General Public Licence,
the GNU Library General Public Licence, and any wxWindows Licence are
included exactly as in the original, and provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
4. Permission is granted to copy and distribute translations of this
manual or piece of documentation into another language, under the above
conditions for modified versions, except that sections related to
licensing, including this paragraph, may also be included in translations
approved by the copyright holders of the respective licence documents in
addition to the original French or English.
WARRANTY DISCLAIMER
5. BECAUSE THIS MANUAL OR PIECE OF DOCUMENTATION IS LICENSED FREE OF CHARGE,
THERE IS NO WARRANTY FOR IT, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
PARTIES PROVIDE THIS MANUAL OR PIECE OF DOCUMENTATION "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF
THE MANUAL OR PIECE OF DOCUMENTATION IS WITH YOU. SHOULD THE MANUAL OR
PIECE OF DOCUMENTATION PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR OR CORRECTION.
6. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE MANUAL OR PIECE OF DOCUMENTATION AS PERMITTED ABOVE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
MANUAL OR PIECE OF DOCUMENTATION (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF A PROGRAM BASED ON THE MANUAL OR PIECE OF
DOCUMENTATION TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
...@@ -151,6 +151,8 @@ set(PCBNEW_SRCS ...@@ -151,6 +151,8 @@ set(PCBNEW_SRCS
muonde.cpp muonde.cpp
muwave_command.cpp muwave_command.cpp
netlist.cpp netlist.cpp
netlist_reader_firstformat.cpp
netlist_reader_kicad.cpp
onleftclick.cpp onleftclick.cpp
onrightclick.cpp onrightclick.cpp
pcb_plot_params.cpp pcb_plot_params.cpp
......
...@@ -686,8 +686,12 @@ TRACK* MergeColinearSegmentIfPossible( BOARD* aPcb, TRACK* aTrackRef, TRACK* aCa ...@@ -686,8 +686,12 @@ TRACK* MergeColinearSegmentIfPossible( BOARD* aPcb, TRACK* aTrackRef, TRACK* aCa
} }
bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) bool PCB_EDIT_FRAME::RemoveMisConnectedTracks()
{ {
/* finds all track segments which are mis-connected (to more than one net).
* When such a bad segment is found, it is flagged to be removed.
* All tracks having at least one flagged segment are removed.
*/
TRACK* segment; TRACK* segment;
TRACK* other; TRACK* other;
TRACK* next; TRACK* next;
...@@ -735,14 +739,14 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) ...@@ -735,14 +739,14 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC )
if( net_code_e < 0 ) if( net_code_e < 0 )
continue; // the "end" of segment is not connected continue; // the "end" of segment is not connected
// Netcodes do not agree, so mark the segment as needed to be removed // Netcodes do not agree, so mark the segment as "to be removed"
if( net_code_s != net_code_e ) if( net_code_s != net_code_e )
{ {
segment->SetState( FLAG0, ON ); segment->SetState( FLAG0, ON );
} }
} }
// Remove flagged segments // Remove tracks having a flagged segment
for( segment = GetBoard()->m_Track; segment; segment = next ) for( segment = GetBoard()->m_Track; segment; segment = next )
{ {
next = (TRACK*) segment->Next(); next = (TRACK*) segment->Next();
...@@ -752,9 +756,11 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC ) ...@@ -752,9 +756,11 @@ bool PCB_EDIT_FRAME::RemoveMisConnectedTracks( wxDC* aDC )
segment->SetState( FLAG0, OFF ); segment->SetState( FLAG0, OFF );
isModified = true; isModified = true;
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
Remove_One_Track( aDC, segment ); Remove_One_Track( NULL, segment );
// the current segment could be deleted, so restart to the beginning // the current segment is deleted,
// we do not know the next "not yet tested" segment,
// so restart to the beginning
next = GetBoard()->m_Track; next = GetBoard()->m_Track;
} }
} }
......
This diff is collapsed.
This diff is collapsed.
/**
* @file pcbnew/netlist_reader_firstformat.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 1992-2011 KiCad Developers, see change_log.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
*/
/*
* Netlist reader using the first format of pcbnew netlist.
* This netlist reader build the list of modules found in netlist
* (list in m_modulesInNetlist)
* and update pads netnames
*/
#include <fctsys.h>
#include <kicad_string.h>
#include <wxPcbStruct.h>
#include <richio.h>
#include <class_board.h>
#include <class_module.h>
#include <pcbnew.h>
#include <netlist_reader.h>
// constants used by ReadOldFmtNetlistModuleDescr():
#define BUILDLIST true
#define READMODULE false
/*
* Function ReadOldFmtdNetList
* Update footprints (load missing footprints and delete on request extra
* footprints)
* Update References, values, "TIME STAMP" and connectivity data
* return true if Ok
*
* the format of the netlist is something like:
* # EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22
* (
* ( 40C08647 $noname R20 4,7K {Lib=R}
* ( 1 VCC )
* ( 2 MODB_1 )
* )
* ( 40C0863F $noname R18 4,7_k {Lib=R}
* ( 1 VCC )
* ( 2 MODA_1 )
* )
* }
* #End
*/
bool NETLIST_READER::ReadOldFmtdNetList( FILE* aFile )
{
int state = 0;
bool is_comment = false;
/* First, read the netlist: Build the list of footprints found in netlist
*/
// netlineReader dtor will close aFile
FILE_LINE_READER netlineReader( aFile, m_netlistFullName );
while( netlineReader.ReadLine() )
{
char* line = StrPurge( netlineReader.Line() );
if( is_comment ) // Comments in progress
{
// Test for end of the current comment
if( ( line = strchr( line, '}' ) ) == NULL )
continue;
is_comment = false;
}
if( *line == '{' ) // Start Comment
{
is_comment = true;
if( ( line = strchr( line, '}' ) ) == NULL )
continue;
}
if( *line == '(' )
state++;
if( *line == ')' )
state--;
if( state == 2 )
{
ReadOldFmtNetlistModuleDescr( line, BUILDLIST );
continue;
}
if( state >= 3 ) // First pass: pad descriptions are not read here.
{
state--;
}
}
if( BuildModuleListOnly() )
return true; // at this point, the module list is read and built.
// Load new footprints
bool success = InitializeModules();
if( ! success )
wxMessageBox( _("Some footprints are not found in libraries") );
TestFootprintsMatchingAndExchange();
/* Second read , All footprints are on board.
* Update the schematic info (pad netnames)
*/
netlineReader.Rewind();
m_currModule = NULL;
state = 0;
is_comment = false;
while( netlineReader.ReadLine() )
{
char* line = StrPurge( netlineReader.Line() );
if( is_comment ) // we are reading a comment
{
// Test for end of the current comment
if( ( line = strchr( line, '}' ) ) == NULL )
continue;
is_comment = false;
}
if( *line == '{' ) // this is the beginning of a comment
{
is_comment = true;
if( ( line = strchr( line, '}' ) ) == NULL )
continue;
}
if( *line == '(' )
state++;
if( *line == ')' )
state--;
if( state == 2 )
{
m_currModule = ReadOldFmtNetlistModuleDescr( line, READMODULE );
continue;
}
if( state >= 3 )
{
if( m_currModule )
SetPadNetName( line );
state--;
}
}
return true;
}
/* Function ReadOldFmtNetlistModuleDescr
* Read the beginning of a footprint description, from the netlist
* and add a module info to m_modulesInNetlist
* Analyze lines like:
* ( /40C08647 $noname R20 4.7K {Lib=R}
* (1 VCC)
* (2 MODB_1)
* )
*/
MODULE* NETLIST_READER::ReadOldFmtNetlistModuleDescr( char* aText, bool aBuildList )
{
char* text;
wxString timeStampPath; // the full time stamp read from netlist
wxString footprintName; // the footprint name read from netlist
wxString cmpValue; // the component value read from netlist
wxString cmpReference; // the component schematic reference read from netlist
bool error = false;
char line[1024];
strcpy( line, aText );
cmpValue = wxT( "~" );
// Read descr line like /40C08647 $noname R20 4.7K {Lib=R}
// Read time stamp (first word)
if( ( text = strtok( line, " ()\t\n" ) ) == NULL )
error = true;
else
timeStampPath = FROM_UTF8( text );
// Read footprint name (second word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
error = true;
else
footprintName = FROM_UTF8( text );
// Read schematic reference (third word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
error = true;
else
cmpReference = FROM_UTF8( text );
// Read schematic value (forth word)
if( ( text = strtok( NULL, " ()\t\n" ) ) == NULL )
error = true;
else
cmpValue = FROM_UTF8( text );
if( error )
return NULL;
if( aBuildList )
{
MODULE_INFO* mod_info = new MODULE_INFO( footprintName, cmpReference,
cmpValue, timeStampPath );
AddModuleInfo( mod_info );
return NULL;
}
// search the module loaded on board
// reference and time stamps are already updated so we can used search by reference
MODULE* module = m_pcbframe->GetBoard()->FindModuleByReference( cmpReference );
if( module == NULL )
{
if( m_messageWindow )
{
wxString msg;
msg.Printf( _( "Component [%s] not found" ), GetChars( cmpReference ) );
m_messageWindow->AppendText( msg + wxT( "\n" ) );
}
}
return module;
}
/*
* Function SetPadNetName
* Update a pad netname using the current footprint
* Line format: ( <pad number> = <net name> )
* Param aText = current line read from netlist
*/
bool NETLIST_READER::SetPadNetName( char* aText )
{
char* p;
char line[256];
if( m_currModule == NULL )
return false;
strncpy( line, aText, sizeof(line) );
if( ( p = strtok( line, " ()\t\n" ) ) == NULL )
return false;
wxString pinName = FROM_UTF8( p );
if( ( p = strtok( NULL, " ()\t\n" ) ) == NULL )
return false;
wxString netName = FROM_UTF8( p );
bool found = false;
for( D_PAD* pad = m_currModule->m_Pads; pad; pad = pad->Next() )
{
wxString padName = pad->GetPadName();
if( padName == pinName )
{
found = true;
if( (char) netName[0] != '?' )
pad->SetNetname( netName );
else
pad->SetNetname( wxEmptyString );
}
}
if( !found )
{
if( m_messageWindow )
{
wxString msg;
msg.Printf( _( "Module [%s]: Pad [%s] not found" ),
GetChars( m_currModule->m_Reference->m_Text ),
GetChars( pinName ) );
m_messageWindow->AppendText( msg + wxT( "\n" ) );
}
}
return found;
}
/**
* @file pcbnew/netlist_reader_kicad.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2011 Jean-Pierre Charras.
* Copyright (C) 1992-2011 KiCad Developers, see change_log.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
*/
#include <wx/wx.h>
#include <netlist_lexer.h> // netlist_lexer is common to Eeschema and Pcbnew
#include <netlist_reader.h>
using namespace NL_T;
/**
* Class PCB_PLOT_PARAMS_PARSER
* is the parser class for PCB_PLOT_PARAMS.
*/
class NETLIST_READER_KICAD_PARSER : public NETLIST_LEXER
{
private:
T token;
NETLIST_READER * netlist_reader;
public:
NETLIST_READER_KICAD_PARSER( FILE_LINE_READER* aReader, NETLIST_READER *aNetlistReader );
/**
* Function Parse
* parse the full netlist
*/
void Parse( BOARD * aBrd ) throw( IO_ERROR, PARSE_ERROR );
/**
* Function ParseComp
* parse the comp description like
* (comp (ref P1)
* (value DB25FEMELLE)
* (footprint DB25FC)
* (libsource (lib conn) (part DB25))
* (sheetpath (names /) (tstamps /))
* (tstamp 3256759C))
*/
MODULE_INFO* ParseComp() throw( IO_ERROR, PARSE_ERROR );
void ParseNet( BOARD * aBrd ) throw( IO_ERROR, PARSE_ERROR );
/**
* Function SkipCurrent
* Skip the current token level, i.e
* search for the RIGHT parenthesis which closes the current description
*/
void SkipCurrent() throw( IO_ERROR, PARSE_ERROR );
// Useful for debug only:
const char* getTokenName( T aTok )
{
return NETLIST_LEXER::TokenName( aTok );
}
};
bool NETLIST_READER::ReadKicadNetList( FILE* aFile )
{
bool success = true;
BOARD * brd = m_pcbframe->GetBoard();
// netlineReader dtor will close aFile
FILE_LINE_READER netlineReader( aFile, m_netlistFullName );
NETLIST_READER_KICAD_PARSER netlist_parser( &netlineReader, this );
netlist_parser.Parse( brd );
return success;
}
// NETLIST_READER_KICAD_PARSER
NETLIST_READER_KICAD_PARSER::NETLIST_READER_KICAD_PARSER( FILE_LINE_READER* aReader,
NETLIST_READER *aNetlistReader ) :
NETLIST_LEXER( aReader )
{
netlist_reader = aNetlistReader;
}
/**
* Function SkipCurrent
* Skip the current token level, i.e
* search for the RIGHT parenthesis which closes the current description
*/
void NETLIST_READER_KICAD_PARSER::SkipCurrent() throw( IO_ERROR, PARSE_ERROR )
{
int curr_level = 0;
while( ( token = NextTok() ) != T_EOF )
{
if( token == T_LEFT )
curr_level--;
if( token == T_RIGHT )
{
curr_level++;
if( curr_level > 0 )
return;
}
}
}
void NETLIST_READER_KICAD_PARSER::Parse( BOARD * aBrd )
throw( IO_ERROR, PARSE_ERROR )
{
wxString text;
while( ( token = NextTok() ) != T_EOF )
{
if( token == T_LEFT )
token = NextTok();
if( token == T_components )
{
// The section comp starts here.
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
if( token == T_comp )
{
// A comp section if found. Read it
MODULE_INFO* mod_info = ParseComp();
netlist_reader->AddModuleInfo( mod_info );
}
}
if( netlist_reader->BuildModuleListOnly() )
return; // at this point, the module list is read and built.
// Load new footprints
netlist_reader->InitializeModules();
netlist_reader->TestFootprintsMatchingAndExchange();
}
if( token == T_nets )
{
// The section nets starts here.
while( ( token = NextTok() ) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
if( token == T_net )
{
// A net section if found. Read it
ParseNet( aBrd );
}
}
}
}
}
void NETLIST_READER_KICAD_PARSER::ParseNet( BOARD * aBrd )
throw( IO_ERROR, PARSE_ERROR )
{
/* Parses a section like
* (net (code 20) (name /PC-A0)
* (node (ref BUS1) (pin 62))
* (node (ref U3) (pin 3))
* (node (ref U9) (pin M6)))
*/
wxString code;
wxString name;
wxString cmpref;
wxString pin;
D_PAD * pad = NULL;
int nodecount = 0;
// The token net was read, so the next data is (code <number>)
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_code:
NeedSYMBOLorNUMBER();
code = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_name:
NeedSYMBOLorNUMBER();
name = FROM_UTF8( CurText() );
NeedRIGHT();
if( name.IsEmpty() ) // Give a dummy net name like N-000109
name = wxT("N-00000") + code;
break;
case T_node:
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_ref:
NeedSYMBOLorNUMBER();
cmpref = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_pin:
NeedSYMBOLorNUMBER();
pin = FROM_UTF8( CurText() );
NeedRIGHT();
break;
default:
SkipCurrent();
break;
}
}
pad = netlist_reader->SetPadNetName( cmpref, pin, name );
nodecount++;
break;
default:
SkipCurrent();
break;
}
}
// When there is onlu one item in net, clear pad netname
if( nodecount < 2 && pad )
pad->SetNetname( wxEmptyString );
}
MODULE_INFO* NETLIST_READER_KICAD_PARSER::ParseComp()
throw( IO_ERROR, PARSE_ERROR )
{
/* Parses a section like
* (comp (ref P1)
* (value DB25FEMELLE)
* (footprint DB25FC)
* (libsource (lib conn) (part DB25))
* (sheetpath (names /) (tstamps /))
* (tstamp 3256759C))
*
* other fields (unused) are skipped
* A component need a reference, value, foorprint name and a full time stamp
* The full time stamp is the sheetpath time stamp + the component time stamp
*/
wxString ref;
wxString value;
wxString footprint;
wxString pathtimestamp, timestamp;
// The token comp was read, so the next data is (ref P1)
while( (token = NextTok()) != T_RIGHT )
{
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_ref:
NeedSYMBOLorNUMBER();
ref = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_value:
NeedSYMBOLorNUMBER();
value = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_footprint:
NeedSYMBOLorNUMBER();
footprint = FROM_UTF8( CurText() );
NeedRIGHT();
break;
case T_libsource:
// Currently not used data, skip it
SkipCurrent();
break;
case T_sheetpath:
while( ( token = NextTok() ) != T_tstamps );
NeedSYMBOLorNUMBER();
pathtimestamp = FROM_UTF8( CurText() );
NeedRIGHT();
NeedRIGHT();
break;
case T_tstamp:
NeedSYMBOLorNUMBER();
timestamp = FROM_UTF8( CurText() );
NeedRIGHT();
break;
default:
// Skip not used data (i.e all other tokens)
SkipCurrent();
break;
}
}
pathtimestamp += timestamp;
MODULE_INFO* mod_info = new MODULE_INFO( footprint, ref, value, pathtimestamp );
return mod_info;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment