2014-02-12 17:01:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-08-18 14:17:16 +00:00
|
|
|
* Copyright (C) 1992-2020 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
|
|
|
|
*/
|
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
|
|
|
#include <pad.h>
|
|
|
|
#include <track.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2018-01-30 14:34:09 +00:00
|
|
|
#include <netinfo.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
|
|
|
|
// Constructor and destructor
|
2020-12-08 12:28:26 +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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.
* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
and C++ so that the resultant type name is common in both languages, and
the types AGREE.
* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.
* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.
* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
Having the name consistent between like types is helpful, and between
languages. std::map<> ends up as SOMETHING_MAP.
* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
instead of hashtables, because swig does not yet support std::unordered_map.
* You can now get to any netclass or net info. NETNAMES_MAP and NETCODES_MAP
are traversable basically the same as a python dictionary using a python
string (not wsString) as the key! The wxString typemap converts python
string to wxString before the lookup happens. Iteration also works.
2016-07-18 17:23:09 +00:00
|
|
|
NETINFO_ITEM* NETINFO_LIST::GetNetItem( int aNetCode ) const
|
|
|
|
{
|
|
|
|
NETCODES_MAP::const_iterator result = m_netCodes.find( aNetCode );
|
|
|
|
|
|
|
|
if( result != m_netCodes.end() )
|
|
|
|
return (*result).second;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NETINFO_ITEM* NETINFO_LIST::GetNetItem( const wxString& aNetName ) const
|
|
|
|
{
|
|
|
|
NETNAMES_MAP::const_iterator result = m_netNames.find( aNetName );
|
|
|
|
|
|
|
|
if( result != m_netNames.end() )
|
|
|
|
return (*result).second;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-29 10:29:56 +00:00
|
|
|
void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
|
|
|
|
{
|
|
|
|
for( NETCODES_MAP::iterator i = m_netCodes.begin(); i != m_netCodes.end(); ++i )
|
|
|
|
{
|
|
|
|
if ( i->second == aNet )
|
|
|
|
{
|
|
|
|
m_netCodes.erase(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( NETNAMES_MAP::iterator i = m_netNames.begin(); i != m_netNames.end(); ++i )
|
|
|
|
{
|
|
|
|
if ( i->second == aNet )
|
|
|
|
{
|
|
|
|
m_netNames.erase(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-01-29 14:43:40 +00:00
|
|
|
|
2020-12-08 12:28:26 +00:00
|
|
|
m_newNetCode = std::min( m_newNetCode, aNet->m_netCode - 1 );
|
2016-01-29 10:29:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-13 21:35:05 +00:00
|
|
|
void NETINFO_LIST::RemoveUnusedNets()
|
|
|
|
{
|
|
|
|
NETCODES_MAP existingNets = m_netCodes;
|
|
|
|
|
|
|
|
m_netCodes.clear();
|
|
|
|
m_netNames.clear();
|
|
|
|
|
|
|
|
for( std::pair<const int, NETINFO_ITEM*> item : existingNets )
|
|
|
|
{
|
|
|
|
if( item.second->IsCurrent() )
|
|
|
|
{
|
|
|
|
m_netNames.insert( std::make_pair( item.second->GetNetname(), item.second ) );
|
|
|
|
m_netCodes.insert( std::make_pair( item.first, item.second ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2020-12-08 13:02:08 +00:00
|
|
|
aNewElement->m_netCode = sameName->GetNetCode();
|
2014-06-02 09:41:54 +00:00
|
|
|
|
|
|
|
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
|
2020-12-08 12:28:26 +00:00
|
|
|
else if( aNewElement->m_netCode != (int) m_netCodes.size() || aNewElement->m_netCode < 0 )
|
2014-06-02 09:41:54 +00:00
|
|
|
{
|
2020-12-08 12:28:26 +00:00
|
|
|
aNewElement->m_netCode = getFreeNetCode();
|
2014-06-02 09:41:54 +00:00
|
|
|
}
|
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 );
|
2020-12-08 13:02:08 +00:00
|
|
|
assert( GetNetItem( aNewElement->GetNetCode() ) == NULL );
|
2014-01-10 17:04:07 +00:00
|
|
|
|
|
|
|
// add an entry for fast look up by a net name using a map
|
|
|
|
m_netNames.insert( std::make_pair( aNewElement->GetNetname(), aNewElement ) );
|
2020-12-08 13:02:08 +00:00
|
|
|
m_netCodes.insert( std::make_pair( aNewElement->GetNetCode(), aNewElement ) );
|
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
|
|
|
{
|
2014-01-09 14:51:47 +00:00
|
|
|
// Restore the initial state of NETINFO_ITEMs
|
2020-07-06 10:51:04 +00:00
|
|
|
for( NETINFO_ITEM* net : *this )
|
2014-01-16 15:47:31 +00:00
|
|
|
net->Clear();
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2020-12-08 12:28:26 +00:00
|
|
|
m_parent->SynchronizeNetsAndNetClasses( );
|
|
|
|
m_parent->SetAreasNetCodesFromNetNames();
|
2013-03-14 22:54:47 +00:00
|
|
|
}
|
|
|
|
|
2020-07-06 10:51:04 +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;
|
2020-08-26 23:52:12 +00:00
|
|
|
|
2014-01-16 13:20:51 +00:00
|
|
|
for( it = m_netNames.begin(), itEnd = m_netNames.end(); it != itEnd; ++it )
|
2009-10-13 16:29:02 +00:00
|
|
|
{
|
2020-08-18 14:17:16 +00:00
|
|
|
wxLogDebug( "[%d]: netcode:%d netname:<%s>\n",
|
|
|
|
i++,
|
2020-12-08 13:02:08 +00:00
|
|
|
it->second->GetNetCode(),
|
2020-08-18 14:17:16 +00:00
|
|
|
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
|
|
|
|
2014-06-02 09:41:54 +00:00
|
|
|
int NETINFO_LIST::getFreeNetCode()
|
2014-01-16 13:20:51 +00:00
|
|
|
{
|
2020-08-26 23:52:12 +00:00
|
|
|
do
|
|
|
|
{
|
2014-01-16 13:20:51 +00:00
|
|
|
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
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : m_board->Zones() )
|
2020-08-26 23:52:12 +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
|
|
|
|
|
|
|
// Tracks
|
2020-08-26 23:52:12 +00:00
|
|
|
for( TRACK* track : m_board->Tracks() )
|
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
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
// footprints/pads
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : m_board->Footprints() )
|
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
|
|
|
{
|
2020-11-13 00:43:45 +00:00
|
|
|
for( PAD* pad : footprint->Pads() )
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
2020-08-26 23:52:12 +00:00
|
|
|
|
|
|
|
for( auto net : nets )
|
|
|
|
m_netMapping[net] = 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2016-01-29 10:29:56 +00:00
|
|
|
const int NETINFO_LIST::ORPHANED = -1;
|
2015-02-17 16:32:47 +00:00
|
|
|
|