pcbnew: multiple fixes concerning track->pad net propagation used by Track/Via properties dialog:

- Added ignore netcode option to CONNECTIVITY_DATA::GetConnectedItems()
- PlaceModule() now ensures the module added to the board (and thus to the connectivity database) has correct bounding box necessary for R-trees to work
- Use recursive connected pad search so that the new net is propagated to all pads

Fixes: lp:1787961
* https://bugs.launchpad.net/kicad/+bug/1787961
This commit is contained in:
Tomasz Włostowski 2019-01-18 02:50:50 +01:00
parent 7bec707160
commit 9657039af2
5 changed files with 33 additions and 10 deletions

View File

@ -650,9 +650,12 @@ int D_PAD::GetSolderMaskMargin() const
if( margin == 0 )
{
BOARD* brd = GetBoard();
if( brd )
{
margin = brd->GetDesignSettings().m_SolderMaskMargin;
}
}
}
// ensure mask have a size always >= 0
if( margin < 0 )

View File

@ -353,11 +353,14 @@ void CONNECTIVITY_DATA::Clear()
const std::vector<BOARD_CONNECTED_ITEM*> CONNECTIVITY_DATA::GetConnectedItems(
const BOARD_CONNECTED_ITEM* aItem,
const KICAD_T aTypes[] ) const
const KICAD_T aTypes[],
bool aIgnoreNetcodes ) const
{
std::vector<BOARD_CONNECTED_ITEM*> rv;
const auto clusters = m_connAlgo->SearchClusters( CN_CONNECTIVITY_ALGO::CSM_CONNECTIVITY_CHECK,
aTypes, aItem->GetNetCode() );
const auto clusters = m_connAlgo->SearchClusters(
aIgnoreNetcodes ? CN_CONNECTIVITY_ALGO::CSM_PROPAGATE : CN_CONNECTIVITY_ALGO::CSM_CONNECTIVITY_CHECK,
aTypes,
aIgnoreNetcodes ? -1 : aItem->GetNetCode() );
for( auto cl : clusters )
{

View File

@ -175,7 +175,7 @@ public:
const std::vector<D_PAD*> GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem ) const;
const void GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem, std::set<D_PAD*>* pads ) const;
const void GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem, std::set<D_PAD*>* pads) const;
const std::vector<BOARD_CONNECTED_ITEM*> GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, KICAD_T aTypes[] );
@ -212,7 +212,7 @@ public:
* @param aTypes allows one to filter by item types.
*/
const std::vector<BOARD_CONNECTED_ITEM*> GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem,
const KICAD_T aTypes[] ) const;
const KICAD_T aTypes[], bool aIgnoreNetcodes = false ) const;
/**
* Function GetNetItems()

View File

@ -344,8 +344,15 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow()
for( auto& item : m_items )
{
auto boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
connectivity->GetConnectedPads( boardItem, &connectedPads );
const KICAD_T ourTypes[] = { PCB_TRACE_T, PCB_PAD_T, PCB_VIA_T, PCB_MODULE_T, EOT };
auto connectedItems = connectivity->GetConnectedItems( static_cast<BOARD_CONNECTED_ITEM*>( item ), ourTypes, true );
for ( auto citem : connectedItems )
{
if( citem->Type() == PCB_PAD_T )
{
connectedPads.insert( static_cast<D_PAD*>( citem ) );
}
}
}
for( D_PAD* pad : connectedPads )

View File

@ -483,9 +483,19 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
continue;
module->SetLink( 0 );
m_frame->AddModuleToBoard( module );
commit.Added( module );
module->SetFlags( IS_NEW ); // whatever
module->SetTimeStamp( GetNewTimeStamp() );
// Put it on FRONT layer,
// (Can be stored flipped if the lib is an archive built from a board)
if( module->IsFlipped() )
module->Flip( module->GetPosition() );
module->SetOrientation( 0 );
module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
commit.Add( module );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
controls->SetCursorPosition( cursorPos, false );
}