NETINFO_ITEMs are owned by BOARD.
Lifecylce management must go through BOARD_COMMIT (or at least the frame's undo/redo lists).
This commit is contained in:
parent
6136c2438d
commit
31c488bc23
|
@ -131,7 +131,7 @@ public:
|
|||
return NO_NET;
|
||||
}
|
||||
|
||||
void SetNetInfo( NETINFO_LIST* aNetInfoList )
|
||||
void SetNetInfo( const NETINFO_LIST* aNetInfoList )
|
||||
{
|
||||
m_netinfoList = aNetInfoList;
|
||||
rebuildList();
|
||||
|
@ -233,12 +233,10 @@ public:
|
|||
BOARD* board = m_netinfoList->GetParent();
|
||||
NETINFO_ITEM *newnet = new NETINFO_ITEM( m_board, remainingName, 0 );
|
||||
|
||||
// add the new netinfo through the board's function so that
|
||||
// board listeners get notified and things stay in sync.
|
||||
if( board != nullptr )
|
||||
wxASSERT( board );
|
||||
|
||||
if( board )
|
||||
board->Add( newnet );
|
||||
else
|
||||
m_netinfoList->AppendNet( newnet );
|
||||
|
||||
rebuildList();
|
||||
|
||||
|
@ -249,12 +247,10 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
// This indicates that the NETINFO_ITEM was not successfully appended
|
||||
// to the list for unknown reasons
|
||||
if( board != nullptr )
|
||||
// This indicates that the NETINFO_ITEM was not successfully appended to the
|
||||
// list for unknown reasons
|
||||
if( board )
|
||||
board->Remove( newnet );
|
||||
else
|
||||
m_netinfoList->RemoveNet( newnet );
|
||||
|
||||
delete newnet;
|
||||
}
|
||||
|
@ -540,7 +536,7 @@ protected:
|
|||
int m_minPopupWidth;
|
||||
int m_maxPopupHeight;
|
||||
|
||||
NETINFO_LIST* m_netinfoList;
|
||||
const NETINFO_LIST* m_netinfoList;
|
||||
wxString m_indeterminateLabel;
|
||||
BOARD* m_board;
|
||||
|
||||
|
@ -609,7 +605,7 @@ void NET_SELECTOR::onKeyDown( wxKeyEvent& aEvt )
|
|||
}
|
||||
|
||||
|
||||
void NET_SELECTOR::SetNetInfo( NETINFO_LIST* aNetInfoList )
|
||||
void NET_SELECTOR::SetNetInfo( const NETINFO_LIST* aNetInfoList )
|
||||
{
|
||||
m_netSelectorPopup->SetNetInfo( aNetInfoList );
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReloadFootprint( FOOTPRINT* aFootprint )
|
|||
return;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->GetNetInfo().RemoveUnusedNets();
|
||||
GetBoard()->RemoveUnusedNets( nullptr );
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
|
||||
|
@ -504,7 +504,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
return;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->GetNetInfo().RemoveUnusedNets();
|
||||
GetBoard()->RemoveUnusedNets( nullptr );
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
INFOBAR_REPORTER infoReporter( m_infoBar );
|
||||
|
|
|
@ -199,7 +199,7 @@ public:
|
|||
return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
|
||||
}
|
||||
|
||||
LIB_SYMBOL* GetParent() const
|
||||
LIB_SYMBOL* GetParent() const // Replace EDA_ITEM::GetParent() with a more useful return-type
|
||||
{
|
||||
return (LIB_SYMBOL*) m_parent;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
~NET_SELECTOR() override;
|
||||
|
||||
void SetNetInfo( NETINFO_LIST* aNetInfoList );
|
||||
void SetNetInfo( const NETINFO_LIST* aNetInfoList );
|
||||
|
||||
// Set to wxEmptyString to disallow indeterminate settings
|
||||
void SetIndeterminateString( const wxString& aString );
|
||||
|
|
|
@ -1163,6 +1163,12 @@ BOARD_ITEM* BOARD::GetItem( const KIID& aID ) const
|
|||
return group;
|
||||
}
|
||||
|
||||
for( NETINFO_ITEM* netInfo : m_NetInfo )
|
||||
{
|
||||
if( netInfo->m_Uuid == aID )
|
||||
return netInfo;
|
||||
}
|
||||
|
||||
if( m_Uuid == aID )
|
||||
return const_cast<BOARD*>( this );
|
||||
|
||||
|
|
|
@ -805,9 +805,9 @@ public:
|
|||
return m_NetInfo;
|
||||
}
|
||||
|
||||
NETINFO_LIST& GetNetInfo()
|
||||
void RemoveUnusedNets( BOARD_COMMIT* aCommit )
|
||||
{
|
||||
return m_NetInfo;
|
||||
m_NetInfo.RemoveUnusedNets( aCommit );
|
||||
}
|
||||
|
||||
#ifndef SWIG
|
||||
|
|
|
@ -370,7 +370,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow()
|
|||
|
||||
void DIALOG_COPPER_ZONE::readNetInformation()
|
||||
{
|
||||
NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
|
||||
const NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
|
||||
|
||||
m_netInfoItemList.clear();
|
||||
m_netInfoItemList.reserve( netInfoList.GetNetCount() );
|
||||
|
|
|
@ -2112,9 +2112,9 @@ void DIALOG_NET_INSPECTOR::onRenameNet( wxCommandEvent& aEvent )
|
|||
// is easier.
|
||||
auto removed_item = m_data_model->deleteItem( m_data_model->findItem( net ) );
|
||||
|
||||
m_brd->GetNetInfo().RemoveNet( net );
|
||||
m_brd->Remove( net );
|
||||
net->SetNetname( fullNetName );
|
||||
m_brd->GetNetInfo().AppendNet( net );
|
||||
m_brd->Add( net );
|
||||
m_frame->OnModify();
|
||||
|
||||
if( netFilterMatches( net ) )
|
||||
|
|
|
@ -1058,7 +1058,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
|
|||
selectionTool->ClearSelection( true /* quiet mode */ );
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->GetNetInfo().RemoveUnusedNets();
|
||||
GetBoard()->RemoveUnusedNets( nullptr );
|
||||
|
||||
FOOTPRINT* footprint = PROJECT_PCB::PcbFootprintLibs( &Prj() )->FootprintLoad( getCurNickname(),
|
||||
getCurFootprintName() );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,27 +36,16 @@
|
|||
#include <string_utils.h>
|
||||
|
||||
|
||||
|
||||
class wxDC;
|
||||
class LINE_READER;
|
||||
class EDA_DRAW_FRAME;
|
||||
class PAD;
|
||||
class PCB_TRACK;
|
||||
class BOARD;
|
||||
class BOARD_ITEM;
|
||||
class BOARD_COMMIT;
|
||||
class MSG_PANEL_ITEM;
|
||||
class PCB_BASE_FRAME;
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* flags for a RATSNEST_ITEM */
|
||||
/*****************************/
|
||||
#define CH_VISIBLE 1 /* Visible */
|
||||
#define CH_UNROUTABLE 2 /* Don't use autorouter. */
|
||||
#define CH_ROUTE_REQ 4 /* Must be routed by the autorouter. */
|
||||
#define CH_ACTIF 8 /* Not routed. */
|
||||
#define LOCAL_RATSNEST_ITEM 0x8000 /* Line between two pads of a single footprint. */
|
||||
|
||||
DECL_VEC_FOR_SWIG( PADS_VEC, PAD* )
|
||||
DECL_VEC_FOR_SWIG( TRACKS_VEC, PCB_TRACK* )
|
||||
|
||||
|
@ -175,7 +164,7 @@ public:
|
|||
*/
|
||||
void Clear();
|
||||
|
||||
BOARD* GetParent() const
|
||||
BOARD* GetParent() const // Replace EDA_ITEM::GetParent() with a more useful return-type
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
@ -360,22 +349,6 @@ public:
|
|||
*/
|
||||
unsigned GetNetCount() const { return m_netNames.size(); }
|
||||
|
||||
/**
|
||||
* Add \a aNewElement to the end of the net list. Negative net code means it is going to be
|
||||
* auto-assigned.
|
||||
*/
|
||||
void AppendNet( NETINFO_ITEM* aNewElement );
|
||||
|
||||
/**
|
||||
* Remove a net from the net list.
|
||||
*/
|
||||
void RemoveNet( NETINFO_ITEM* aNet );
|
||||
void RemoveUnusedNets();
|
||||
|
||||
/**
|
||||
* @return the number of pads in board.
|
||||
*/
|
||||
|
||||
/// Return the name map, at least for python.
|
||||
const NETNAMES_MAP& NetsByName() const { return m_netNames; }
|
||||
|
||||
|
@ -471,6 +444,19 @@ public:
|
|||
return m_parent;
|
||||
}
|
||||
|
||||
protected: // Access is through the BOARD, which is a friend class
|
||||
/**
|
||||
* Add \a aNewElement to the end of the net list. Negative net code means it is going to be
|
||||
* auto-assigned.
|
||||
*/
|
||||
void AppendNet( NETINFO_ITEM* aNewElement );
|
||||
|
||||
/**
|
||||
* Remove a net from the net list.
|
||||
*/
|
||||
void RemoveNet( NETINFO_ITEM* aNet );
|
||||
void RemoveUnusedNets( BOARD_COMMIT* aCommit );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Delete the list of nets (and free memory).
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <board.h>
|
||||
#include <board_commit.h>
|
||||
#include <footprint.h>
|
||||
#include <macros.h>
|
||||
#include <pad.h>
|
||||
|
@ -113,19 +114,24 @@ void NETINFO_LIST::RemoveNet( NETINFO_ITEM* aNet )
|
|||
}
|
||||
|
||||
|
||||
void NETINFO_LIST::RemoveUnusedNets()
|
||||
void NETINFO_LIST::RemoveUnusedNets( BOARD_COMMIT* aCommit )
|
||||
{
|
||||
NETCODES_MAP existingNets = m_netCodes;
|
||||
std::vector<NETINFO_ITEM*> unusedNets;
|
||||
|
||||
m_netCodes.clear();
|
||||
m_netNames.clear();
|
||||
|
||||
for( std::pair<const int, NETINFO_ITEM*> item : existingNets )
|
||||
for( const auto& [ netCode, netInfo ] : existingNets )
|
||||
{
|
||||
if( item.second->IsCurrent() )
|
||||
if( netInfo->IsCurrent() )
|
||||
{
|
||||
m_netNames.insert( std::make_pair( item.second->GetNetname(), item.second ) );
|
||||
m_netCodes.insert( std::make_pair( item.first, item.second ) );
|
||||
m_netNames.insert( std::make_pair( netInfo->GetNetname(), netInfo ) );
|
||||
m_netCodes.insert( std::make_pair( netCode, netInfo ) );
|
||||
}
|
||||
else if( aCommit )
|
||||
{
|
||||
aCommit->Removed( netInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1239,7 +1239,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
}
|
||||
}
|
||||
|
||||
m_board->GetNetInfo().RemoveUnusedNets();
|
||||
m_board->RemoveUnusedNets( &m_commit );
|
||||
|
||||
// When new footprints are added, the automatic zone refill is disabled because:
|
||||
// * it creates crashes when calculating dynamic ratsnests if auto refill is enabled.
|
||||
|
|
|
@ -60,7 +60,7 @@ bool PCB_EDIT_FRAME::LoadProjectSettings()
|
|||
KIGFX::RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
|
||||
KIGFX::PCB_RENDER_SETTINGS* renderSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( rs );
|
||||
|
||||
NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
||||
const NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
||||
|
||||
std::set<int>& hiddenNets = renderSettings->GetHiddenNets();
|
||||
hiddenNets.clear();
|
||||
|
@ -154,7 +154,7 @@ void PCB_EDIT_FRAME::SaveProjectLocalSettings()
|
|||
// Save render settings that aren't stored in PCB_DISPLAY_OPTIONS
|
||||
|
||||
std::shared_ptr<NET_SETTINGS>& netSettings = project.NetSettings();
|
||||
NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
||||
const NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
||||
KIGFX::RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
|
||||
KIGFX::PCB_RENDER_SETTINGS* renderSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( rs );
|
||||
|
||||
|
@ -224,7 +224,7 @@ void PCB_EDIT_FRAME::saveProjectSettings()
|
|||
localSettings.m_AutoTrackWidth = bds.m_UseConnectedTrackWidth;
|
||||
|
||||
// Net display settings
|
||||
NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
||||
const NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
||||
KIGFX::RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
|
||||
KIGFX::PCB_RENDER_SETTINGS* renderSettings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( rs );
|
||||
|
||||
|
|
|
@ -1449,7 +1449,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
|
|||
PIN_REF empty( m_pcb->m_network );
|
||||
std::string componentId;
|
||||
int highestNetCode = 0;
|
||||
NETINFO_LIST& netInfo = aBoard->GetNetInfo();
|
||||
const NETINFO_LIST& netInfo = aBoard->GetNetInfo();
|
||||
|
||||
// find the highest numbered netCode within the board.
|
||||
for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
|
||||
|
|
|
@ -2947,11 +2947,11 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
|
|||
int selectPossibleNetsByPopMenu( std::list<int>& aNetcodeList )
|
||||
{
|
||||
ACTION_MENU menu( true );
|
||||
NETINFO_LIST& netInfo = m_board->GetNetInfo();
|
||||
const NETINFO_LIST& netInfo = m_board->GetNetInfo();
|
||||
std::map<int, int> menuIDNetCodeMap;
|
||||
int menuID = 1;
|
||||
|
||||
for( auto& netcode : aNetcodeList )
|
||||
for( int netcode : aNetcodeList )
|
||||
{
|
||||
wxString menuText;
|
||||
if( menuID < 10 )
|
||||
|
|
|
@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE( IntrospectedProperties )
|
|||
|
||||
BOARD brd;
|
||||
|
||||
NETINFO_LIST& netInfo = brd.GetNetInfo();
|
||||
const NETINFO_LIST& netInfo = brd.GetNetInfo();
|
||||
|
||||
std::shared_ptr<NETCLASS> netclass1( new NETCLASS( "HV" ) );
|
||||
std::shared_ptr<NETCLASS> netclass2( new NETCLASS( "otherClass" ) );
|
||||
|
|
Loading…
Reference in New Issue