pcbnew: support for removing NETINFO_ITEMS from BOARD for proper netlist undo
This commit is contained in:
parent
867a0444bd
commit
5ef6001e06
|
@ -672,6 +672,10 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
|
||||||
|
|
||||||
switch( aBoardItem->Type() )
|
switch( aBoardItem->Type() )
|
||||||
{
|
{
|
||||||
|
case PCB_NETINFO_T:
|
||||||
|
aBoardItem->SetParent( this );
|
||||||
|
m_NetInfo.AppendNet( (NETINFO_ITEM*) aBoardItem );
|
||||||
|
|
||||||
// this one uses a vector
|
// this one uses a vector
|
||||||
case PCB_MARKER_T:
|
case PCB_MARKER_T:
|
||||||
aBoardItem->SetParent( this );
|
aBoardItem->SetParent( this );
|
||||||
|
@ -737,10 +741,6 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
|
||||||
aBoardItem->SetParent( this );
|
aBoardItem->SetParent( this );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_NETINFO_T:
|
|
||||||
m_NetInfo.AppendNet( (NETINFO_ITEM *) aBoardItem );
|
|
||||||
break;
|
|
||||||
|
|
||||||
// other types may use linked list
|
// other types may use linked list
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -763,6 +763,10 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
|
||||||
|
|
||||||
switch( aBoardItem->Type() )
|
switch( aBoardItem->Type() )
|
||||||
{
|
{
|
||||||
|
case PCB_NETINFO_T:
|
||||||
|
m_NetInfo.RemoveNet ( (NETINFO_ITEM*) aBoardItem );
|
||||||
|
break;
|
||||||
|
|
||||||
case PCB_MARKER_T:
|
case PCB_MARKER_T:
|
||||||
|
|
||||||
// find the item in the vector, then remove it
|
// find the item in the vector, then remove it
|
||||||
|
@ -811,11 +815,6 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
|
||||||
m_Drawings.Remove( aBoardItem );
|
m_Drawings.Remove( aBoardItem );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_NETINFO_T:
|
|
||||||
printf( "Unimpl! remove netinfo!\n" );
|
|
||||||
assert( false );
|
|
||||||
break;
|
|
||||||
|
|
||||||
// other types may use linked list
|
// other types may use linked list
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
|
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
|
||||||
|
@ -1261,7 +1260,7 @@ NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
|
||||||
wxASSERT( m_NetInfo.GetNetCount() > 0 ); // net zero should exist
|
wxASSERT( m_NetInfo.GetNetCount() > 0 ); // net zero should exist
|
||||||
|
|
||||||
if( aNetcode == NETINFO_LIST::UNCONNECTED && m_NetInfo.GetNetCount() == 0 )
|
if( aNetcode == NETINFO_LIST::UNCONNECTED && m_NetInfo.GetNetCount() == 0 )
|
||||||
return &NETINFO_LIST::ORPHANED;
|
return &NETINFO_LIST::ORPHANED_ITEM;
|
||||||
else
|
else
|
||||||
return m_NetInfo.GetNetItem( aNetcode );
|
return m_NetInfo.GetNetItem( aNetcode );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <class_board_item.h>
|
#include <class_board_item.h>
|
||||||
|
|
||||||
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
|
BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
|
||||||
BOARD_ITEM( aParent, idtype ), m_netinfo( &NETINFO_LIST::ORPHANED ),
|
BOARD_ITEM( aParent, idtype ), m_netinfo( &NETINFO_LIST::ORPHANED_ITEM ),
|
||||||
m_Subnet( 0 ), m_ZoneSubnet( 0 )
|
m_Subnet( 0 ), m_ZoneSubnet( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert )
|
||||||
if( ( aNetCode >= 0 ) && board )
|
if( ( aNetCode >= 0 ) && board )
|
||||||
m_netinfo = board->FindNet( aNetCode );
|
m_netinfo = board->FindNet( aNetCode );
|
||||||
else
|
else
|
||||||
m_netinfo = &NETINFO_LIST::ORPHANED;
|
m_netinfo = &NETINFO_LIST::ORPHANED_ITEM;
|
||||||
|
|
||||||
if( !aNoAssert )
|
if( !aNoAssert )
|
||||||
assert( m_netinfo );
|
assert( m_netinfo );
|
||||||
|
|
|
@ -186,7 +186,7 @@ void MODULE::ClearAllNets()
|
||||||
// Force the ORPHANED dummy net info for all pads.
|
// Force the ORPHANED dummy net info for all pads.
|
||||||
// ORPHANED dummy net does not depend on a board
|
// ORPHANED dummy net does not depend on a board
|
||||||
for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
|
for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
|
||||||
pad->SetNetCode( NETINFO_LIST::FORCE_ORPHANED );
|
pad->SetNetCode( NETINFO_LIST::ORPHANED );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -291,12 +291,18 @@ public:
|
||||||
unsigned GetNetCount() const { return m_netNames.size(); }
|
unsigned GetNetCount() const { return m_netNames.size(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Append
|
* Function AppendNet
|
||||||
* adds \a aNewElement to the end of the list. Negative net code means it is going to be
|
* adds \a aNewElement to the end of the net list. Negative net code means it is going to be
|
||||||
* auto-assigned.
|
* auto-assigned.
|
||||||
*/
|
*/
|
||||||
void AppendNet( NETINFO_ITEM* aNewElement );
|
void AppendNet( NETINFO_ITEM* aNewElement );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function RemoveNet
|
||||||
|
* Removes a new from the net list.
|
||||||
|
*/
|
||||||
|
void RemoveNet( NETINFO_ITEM* aNet );
|
||||||
/**
|
/**
|
||||||
* Function GetPadCount
|
* Function GetPadCount
|
||||||
* @return the number of pads in board
|
* @return the number of pads in board
|
||||||
|
@ -348,11 +354,11 @@ public:
|
||||||
|
|
||||||
///> Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED
|
///> Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED
|
||||||
///> (typically -1) when calling SetNetCode od board connected items
|
///> (typically -1) when calling SetNetCode od board connected items
|
||||||
static const int FORCE_ORPHANED;
|
static const int ORPHANED;
|
||||||
|
|
||||||
///> NETINFO_ITEM meaning that there was no net assigned for an item, as there was no
|
///> NETINFO_ITEM meaning that there was no net assigned for an item, as there was no
|
||||||
///> board storing net list available.
|
///> board storing net list available.
|
||||||
static NETINFO_ITEM ORPHANED;
|
static NETINFO_ITEM ORPHANED_ITEM;
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void Show() const;
|
void Show() const;
|
||||||
|
|
|
@ -69,6 +69,28 @@ void NETINFO_LIST::clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
|
void NETINFO_LIST::AppendNet( NETINFO_ITEM* aNewElement )
|
||||||
{
|
{
|
||||||
// if there is a net with such name then just assign the correct number
|
// if there is a net with such name then just assign the correct number
|
||||||
|
@ -295,6 +317,6 @@ NETINFO_ITEM* NETINFO_MAPPING::iterator::operator->() const
|
||||||
|
|
||||||
|
|
||||||
const int NETINFO_LIST::UNCONNECTED = 0;
|
const int NETINFO_LIST::UNCONNECTED = 0;
|
||||||
const int NETINFO_LIST::FORCE_ORPHANED = -1;
|
const int NETINFO_LIST::ORPHANED = -1;
|
||||||
|
|
||||||
NETINFO_ITEM NETINFO_LIST::ORPHANED = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED );
|
NETINFO_ITEM NETINFO_LIST::ORPHANED_ITEM = NETINFO_ITEM( NULL, wxEmptyString, NETINFO_LIST::UNCONNECTED );
|
|
@ -52,13 +52,23 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||||
toolManager->RunAction( COMMON_ACTIONS::selectionClear, true );
|
toolManager->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->LoadFootprints( *m_netlist, &reporter );
|
try {
|
||||||
|
m_frame->LoadFootprints( *m_netlist, &reporter );
|
||||||
|
}
|
||||||
|
catch( IO_ERROR &error )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
reporter.Report( _( "Failed to load one or more footprints. Please add the missing libraries in PCBNew configuration. "
|
||||||
|
"The PCB will not update completely." ), REPORTER::RPT_ERROR );
|
||||||
|
reporter.Report( error.errorText, REPORTER::RPT_INFO );
|
||||||
|
}
|
||||||
|
|
||||||
BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() );
|
BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() );
|
||||||
|
|
||||||
updater.SetReporter ( &reporter );
|
updater.SetReporter ( &reporter );
|
||||||
updater.SetIsDryRun( aDryRun);
|
updater.SetIsDryRun( aDryRun);
|
||||||
updater.SetLookupByTimestamp( true );
|
updater.SetLookupByTimestamp( m_matchByTimestamp->GetValue() );
|
||||||
updater.SetDeleteUnusedComponents ( true );
|
updater.SetDeleteUnusedComponents ( true );
|
||||||
updater.SetReplaceFootprints( true );
|
updater.SetReplaceFootprints( true );
|
||||||
updater.SetDeleteSinglePadNets ( false );
|
updater.SetDeleteSinglePadNets ( false );
|
||||||
|
@ -94,7 +104,7 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||||
|
|
||||||
void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event )
|
void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
|
PerformUpdate( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DIALOG_UPDATE_PCB::OnCancelClick( wxCommandEvent& event )
|
void DIALOG_UPDATE_PCB::OnCancelClick( wxCommandEvent& event )
|
||||||
|
|
Loading…
Reference in New Issue