2014-02-12 17:01:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2014-04-24 18:54:49 +00:00
|
|
|
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-02-12 17:01:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file class_netinfolist.cpp
|
|
|
|
*/
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
#include <class_pad.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_netinfo.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
|
|
|
|
// Constructor and destructor
|
2014-01-10 17:04:07 +00:00
|
|
|
NETINFO_LIST::NETINFO_LIST( BOARD* aParent ) : m_Parent( aParent )
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2014-01-10 17:04:07 +00:00
|
|
|
// Make sure that the unconnected net has number 0
|
|
|
|
AppendNet( new NETINFO_ITEM( aParent, wxEmptyString, 0 ) );
|
2014-06-02 09:41:54 +00:00
|
|
|
|
|
|
|
m_newNetCode = 0;
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NETINFO_LIST::~NETINFO_LIST()
|
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
clear();
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
void NETINFO_LIST::clear()
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2014-01-16 13:20:51 +00:00
|
|
|
NETNAMES_MAP::iterator it, itEnd;
|
|
|
|
for( it = m_netNames.begin(), itEnd = m_netNames.end(); it != itEnd; ++it )
|
|
|
|
delete it->second;
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
m_PadsFullList.clear();
|
2014-01-10 17:04:07 +00:00
|
|
|
m_netNames.clear();
|
2014-01-16 13:20:51 +00:00
|
|
|
m_netCodes.clear();
|
2014-06-02 09:41:54 +00:00
|
|
|
m_newNetCode = 0;
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-06 18:08:49 +00:00
|
|
|
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2014-06-02 09:41:54 +00:00
|
|
|
// if there is a net with such name then just assign the correct number
|
|
|
|
NETINFO_ITEM* sameName = GetNetItem( aNewElement->GetNetname() );
|
|
|
|
|
|
|
|
if( sameName != NULL )
|
|
|
|
{
|
|
|
|
aNewElement->m_NetCode = sameName->GetNet();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// be sure that net codes are consecutive
|
2014-01-16 13:20:51 +00:00
|
|
|
// negative net code means that it has to be auto assigned
|
2014-06-02 09:41:54 +00:00
|
|
|
else if( ( aNewElement->m_NetCode != (int) m_netCodes.size() ) || ( aNewElement->m_NetCode < 0 ) )
|
|
|
|
{
|
|
|
|
aNewElement->m_NetCode = getFreeNetCode();
|
|
|
|
}
|
2014-01-16 13:20:51 +00:00
|
|
|
|
2014-01-10 17:04:07 +00:00
|
|
|
// net names & codes are supposed to be unique
|
|
|
|
assert( GetNetItem( aNewElement->GetNetname() ) == NULL );
|
|
|
|
assert( GetNetItem( aNewElement->GetNet() ) == NULL );
|
|
|
|
|
|
|
|
// add an entry for fast look up by a net name using a map
|
|
|
|
m_netNames.insert( std::make_pair( aNewElement->GetNetname(), aNewElement ) );
|
2014-01-16 13:20:51 +00:00
|
|
|
m_netCodes.insert( std::make_pair( aNewElement->GetNet(), aNewElement ) );
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* sort function, to sort pad list by netnames
|
2009-09-17 17:48:40 +00:00
|
|
|
* this is a case sensitive sort.
|
|
|
|
* DO NOT change it because NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname )
|
|
|
|
* when search a net by its net name does a binary search
|
|
|
|
* and expects to have a nets list sorted by an alphabetic case sensitive sort
|
2009-05-24 18:28:36 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
static bool padlistSortByNetnames( const D_PAD* a, const D_PAD* b )
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
|
|
|
return ( a->GetNetname().Cmp( b->GetNetname() ) ) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute and update the net_codes for PADS et and equipots (.m_NetCode member)
|
|
|
|
* net_codes are >= 1 (net_code = 0 means not connected)
|
2009-09-17 17:48:40 +00:00
|
|
|
* Update the net buffer
|
2009-05-24 18:28:36 +00:00
|
|
|
* Must be called after editing pads (netname, or deleting) or after read a netlist
|
|
|
|
* set to 1 flag NET_CODE_OK of m_Pcb->m_Status_Pcb;
|
|
|
|
* m_Pcb->m_NbNodes and m_Pcb->m_NbNets are updated
|
2009-09-17 17:48:40 +00:00
|
|
|
* Be aware NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname )
|
|
|
|
* when search a net by its net name does a binary search
|
|
|
|
* and expects to have a nets list sorted by an alphabetic case sensitive sort
|
2013-08-24 08:08:55 +00:00
|
|
|
* So do not change Build_Pads_Full_List() which build a sorted list of pads
|
2009-05-24 18:28:36 +00:00
|
|
|
*/
|
2011-12-10 05:33:24 +00:00
|
|
|
void NETINFO_LIST::buildListOfNets()
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
D_PAD* pad;
|
|
|
|
int nodes_count = 0;
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
// Build the PAD list, sorted by net
|
|
|
|
buildPadsFullList();
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2014-01-09 14:51:47 +00:00
|
|
|
// Restore the initial state of NETINFO_ITEMs
|
2014-01-16 15:47:31 +00:00
|
|
|
for( NETINFO_LIST::iterator net( begin() ), netEnd( end() ); net != netEnd; ++net )
|
|
|
|
net->Clear();
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2014-01-09 14:51:47 +00:00
|
|
|
// Assign pads to appropriate NETINFO_ITEMs
|
2009-06-11 14:26:17 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PadsFullList.size(); ii++ )
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2009-06-11 14:26:17 +00:00
|
|
|
pad = m_PadsFullList[ii];
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( pad->GetNetCode() == NETINFO_LIST::UNCONNECTED ) // pad not connected
|
2009-05-24 18:28:36 +00:00
|
|
|
continue;
|
2012-05-20 13:14:46 +00:00
|
|
|
|
2014-01-10 17:04:07 +00:00
|
|
|
// Add pad to the appropriate list of pads
|
2014-02-25 10:40:34 +00:00
|
|
|
NETINFO_ITEM* net = pad->GetNet();
|
2015-09-23 23:02:40 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
// it should not be possible for BOARD_CONNECTED_ITEM to return NULL as a result of GetNet()
|
|
|
|
wxASSERT( net );
|
|
|
|
|
|
|
|
if( net )
|
|
|
|
net->m_PadInNetList.push_back( pad );
|
2012-05-20 13:14:46 +00:00
|
|
|
|
2014-01-09 14:51:47 +00:00
|
|
|
++nodes_count;
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-09 18:52:44 +00:00
|
|
|
m_Parent->SetNodeCount( nodes_count );
|
2009-08-17 02:59:38 +00:00
|
|
|
|
|
|
|
m_Parent->SynchronizeNetsAndNetClasses( );
|
2009-05-24 18:28:36 +00:00
|
|
|
|
|
|
|
m_Parent->m_Status_Pcb |= NET_CODES_OK;
|
|
|
|
|
|
|
|
m_Parent->SetAreasNetCodesFromNetNames();
|
2013-03-14 22:54:47 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 23:02:40 +00:00
|
|
|
|
2013-03-14 22:54:47 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void NETINFO_LIST::Show() const
|
|
|
|
{
|
2014-01-16 13:20:51 +00:00
|
|
|
int i = 0;
|
|
|
|
NETNAMES_MAP::const_iterator it, itEnd;
|
|
|
|
for( it = m_netNames.begin(), itEnd = m_netNames.end(); it != itEnd; ++it )
|
2009-10-13 16:29:02 +00:00
|
|
|
{
|
2013-03-14 22:54:47 +00:00
|
|
|
printf( "[%d]: netcode:%d netname:<%s>\n",
|
2014-01-16 13:20:51 +00:00
|
|
|
i++, it->second->GetNet(),
|
|
|
|
TO_UTF8( it->second->GetNetname() ) );
|
2009-10-13 16:29:02 +00:00
|
|
|
}
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
2013-03-14 22:54:47 +00:00
|
|
|
#endif
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2015-09-23 23:02:40 +00:00
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
void NETINFO_LIST::buildPadsFullList()
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
/*
|
|
|
|
* initialize:
|
|
|
|
* m_Pads (list of pads)
|
|
|
|
* set m_Status_Pcb = LISTE_PAD_OK;
|
|
|
|
* also clear m_Pcb->m_FullRatsnest that could have bad data
|
|
|
|
* (m_Pcb->m_FullRatsnest uses pointer to pads)
|
|
|
|
* Be aware NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname )
|
|
|
|
* when search a net by its net name does a binary search
|
|
|
|
* and expects to have a nets list sorted by an alphabetic case sensitive sort
|
|
|
|
* So do not change the sort function used here
|
|
|
|
*/
|
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
if( m_Parent->m_Status_Pcb & LISTE_PAD_OK )
|
2009-05-24 18:28:36 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// empty the old list
|
2009-06-11 14:26:17 +00:00
|
|
|
m_PadsFullList.clear();
|
|
|
|
m_Parent->m_FullRatsnest.clear();
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
// Clear variables used in ratsnest computation
|
2009-06-11 14:26:17 +00:00
|
|
|
for( MODULE* module = m_Parent->m_Modules; module; module = module->Next() )
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
2009-05-24 18:28:36 +00:00
|
|
|
{
|
2009-06-11 14:26:17 +00:00
|
|
|
m_PadsFullList.push_back( pad );
|
2009-05-24 18:28:36 +00:00
|
|
|
|
|
|
|
pad->SetSubRatsnest( 0 );
|
|
|
|
pad->SetParent( module );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort pad list per net
|
2011-12-10 05:33:24 +00:00
|
|
|
sort( m_PadsFullList.begin(), m_PadsFullList.end(), padlistSortByNetnames );
|
2009-05-24 18:28:36 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
m_Parent->m_Status_Pcb = LISTE_PAD_OK;
|
2009-05-24 18:28:36 +00:00
|
|
|
}
|
2014-01-15 08:34:16 +00:00
|
|
|
|
|
|
|
|
2014-06-02 09:41:54 +00:00
|
|
|
int NETINFO_LIST::getFreeNetCode()
|
2014-01-16 13:20:51 +00:00
|
|
|
{
|
|
|
|
do {
|
|
|
|
if( m_newNetCode < 0 )
|
|
|
|
m_newNetCode = 0;
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
} while( m_netCodes.count( ++m_newNetCode ) != 0 );
|
2014-01-16 13:20:51 +00:00
|
|
|
|
|
|
|
return m_newNetCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
int NETINFO_MAPPING::Translate( int aNetCode ) const
|
|
|
|
{
|
|
|
|
std::map<int, int>::const_iterator value = m_netMapping.find( aNetCode );
|
|
|
|
|
|
|
|
if( value != m_netMapping.end() )
|
|
|
|
return value->second;
|
|
|
|
|
|
|
|
// There was no entry for the given net code
|
|
|
|
return aNetCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NETINFO_MAPPING::Update()
|
|
|
|
{
|
|
|
|
// Collect all the used nets
|
|
|
|
std::set<int> nets;
|
|
|
|
|
|
|
|
// Be sure that the unconnected gets 0 and is mapped as 0
|
|
|
|
nets.insert( 0 );
|
|
|
|
|
|
|
|
// Zones
|
|
|
|
for( int i = 0; i < m_board->GetAreaCount(); ++i )
|
2014-02-25 10:40:34 +00:00
|
|
|
nets.insert( m_board->GetArea( i )->GetNetCode() );
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
|
|
|
|
// Tracks
|
|
|
|
for( TRACK* track = m_board->m_Track; track; track = track->Next() )
|
2014-02-25 10:40:34 +00:00
|
|
|
nets.insert( track->GetNetCode() );
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
|
|
|
|
// Modules/pads
|
|
|
|
for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
|
|
|
|
{
|
|
|
|
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
|
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
nets.insert( pad->GetNetCode() );
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Segzones
|
|
|
|
for( SEGZONE* zone = m_board->m_Zone; zone; zone = zone->Next() )
|
2014-02-25 10:40:34 +00:00
|
|
|
nets.insert( zone->GetNetCode() );
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
|
|
|
|
// Prepare the new mapping
|
|
|
|
m_netMapping.clear();
|
|
|
|
|
2014-02-12 17:01:03 +00:00
|
|
|
// Now the nets variable stores all the used net codes (not only for pads) and we are ready to
|
|
|
|
// assign new consecutive net numbers
|
Added NETINFO_MAPPING, to ease saving nets with consecutive net codes (without modifying the net codes during the run time).
Now, nets are saved with consecutive net codes (both modern & legacy plugins).
Zones are saved together with their nets, without depending on the fact if there are any pads with such net. Therefore validation of zone net names was removed (pcbnew/class_board.cpp).
Performed tests:
- Changed a pad's net name from empty to existent - ok, name was changed.
- Changed a pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty.
- Changed a pad's net name from existent to empty - ok, net name became empty
- Changed a pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed.
- Drawn a zone that belongs to a net, then modified schematics so the net does not exist anymore. After reloading the net list, all pads/tracks are updated. Zones still belongs to the net that does not exist in the schematic (but still exists in .kicad_pcb file). After running DRC, the zone becomes not filled.
- Undo & redo affects assignment of a polygon to a specific net (you may change net of a polygon, refill it and undo/redo the changes).
- KiCad s-expr & legacy, Eagle, P-CAD boards seem to load without any problem (they also contain correct net names assigned to the appropriate pads). All types of board file formats were loaded, then saved in sexpr format and reopened with a KiCad built from the master branch (without my modifications).
- A few boards were also saved using the legacy format and were opened with the master KiCad without any issues.
- Change a net name for a pad, restore with undo/redo - ok
- Remove everything, restore with undo - ok
- Remove everything, reload netlist - ok
Differences observed between files saved by the master branch KiCad and this one:
- list of nets are not saved in any particular order, so net codes may differ
- the default net class does not contain the unconnected net
2014-01-28 09:19:51 +00:00
|
|
|
int newNetCode = 0;
|
|
|
|
for( std::set<int>::const_iterator it = nets.begin(), itEnd = nets.end(); it != itEnd; ++it )
|
|
|
|
m_netMapping[*it] = newNetCode++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NETINFO_ITEM* NETINFO_MAPPING::iterator::operator*() const
|
|
|
|
{
|
|
|
|
return m_mapping->m_board->FindNet( m_iterator->first );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NETINFO_ITEM* NETINFO_MAPPING::iterator::operator->() const
|
|
|
|
{
|
|
|
|
return m_mapping->m_board->FindNet( m_iterator->first );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-15 08:34:16 +00:00
|
|
|
const int NETINFO_LIST::UNCONNECTED = 0;
|
2015-02-17 16:32:47 +00:00
|
|
|
const int NETINFO_LIST::FORCE_ORPHANED = -1;
|
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
NETINFO_ITEM NETINFO_LIST::ORPHANED = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED );
|