Update ratsnest while dragging footprints.
Fixes https://gitlab.com/kicad/code/kicad/issues/9391
This commit is contained in:
parent
ccd3a1e6a9
commit
36d11f745e
|
@ -788,7 +788,7 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForItems( std::vector<B
|
|||
std::vector<CN_EDGE> edges;
|
||||
std::set<BOARD_CONNECTED_ITEM*> item_set;
|
||||
|
||||
for( auto item : aItems )
|
||||
for( BOARD_ITEM* item : aItems )
|
||||
{
|
||||
if( item->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
|
@ -809,18 +809,18 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForItems( std::vector<B
|
|||
|
||||
for( const auto& netcode : nets )
|
||||
{
|
||||
const auto& net = GetRatsnestForNet( netcode );
|
||||
RN_NET* net = GetRatsnestForNet( netcode );
|
||||
|
||||
for( const auto& edge : net->GetEdges() )
|
||||
for( const CN_EDGE& edge : net->GetEdges() )
|
||||
{
|
||||
auto srcNode = edge.GetSourceNode();
|
||||
auto dstNode = edge.GetTargetNode();
|
||||
std::shared_ptr<CN_ANCHOR> srcNode = edge.GetSourceNode();
|
||||
std::shared_ptr<CN_ANCHOR> dstNode = edge.GetTargetNode();
|
||||
|
||||
auto srcParent = srcNode->Parent();
|
||||
auto dstParent = dstNode->Parent();
|
||||
BOARD_CONNECTED_ITEM* srcParent = srcNode->Parent();
|
||||
BOARD_CONNECTED_ITEM* dstParent = dstNode->Parent();
|
||||
|
||||
bool srcFound = ( item_set.find(srcParent) != item_set.end() );
|
||||
bool dstFound = ( item_set.find(dstParent) != item_set.end() );
|
||||
bool srcFound = ( item_set.find( srcParent ) != item_set.end() );
|
||||
bool dstFound = ( item_set.find( dstParent ) != item_set.end() );
|
||||
|
||||
if ( srcFound && dstFound )
|
||||
edges.push_back( edge );
|
||||
|
@ -831,6 +831,21 @@ const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForItems( std::vector<B
|
|||
}
|
||||
|
||||
|
||||
const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForPad( const PAD* aPad )
|
||||
{
|
||||
std::vector<CN_EDGE> edges;
|
||||
RN_NET* net = GetRatsnestForNet( aPad->GetNetCode() );
|
||||
|
||||
for( const CN_EDGE& edge : net->GetEdges() )
|
||||
{
|
||||
if( edge.GetSourceNode()->Parent() == aPad || edge.GetTargetNode()->Parent() == aPad )
|
||||
edges.push_back( edge );
|
||||
}
|
||||
|
||||
return edges;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<CN_EDGE> CONNECTIVITY_DATA::GetRatsnestForComponent( FOOTPRINT* aComponent, bool aSkipInternalConnections )
|
||||
{
|
||||
std::set<int> nets;
|
||||
|
|
|
@ -294,6 +294,8 @@ public:
|
|||
#ifndef SWIG
|
||||
const std::vector<CN_EDGE> GetRatsnestForItems( const std::vector<BOARD_ITEM*> aItems );
|
||||
|
||||
const std::vector<CN_EDGE> GetRatsnestForPad( const PAD* aPad );
|
||||
|
||||
const std::vector<CN_EDGE> GetRatsnestForComponent( FOOTPRINT* aComponent,
|
||||
bool aSkipInternalConnections = false );
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,8 @@ using namespace std::placeholders;
|
|||
#include <dialogs/dialog_track_via_size.h>
|
||||
#include <widgets/infobar.h>
|
||||
#include <widgets/appearance_controls.h>
|
||||
#include <connectivity/connectivity_data.h>
|
||||
#include <connectivity/connectivity_algo.h>
|
||||
#include <confirm.h>
|
||||
#include <bitmaps.h>
|
||||
#include <tool/action_menu.h>
|
||||
|
@ -1603,17 +1605,31 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
PNS::ITEM_SET itemsToDrag;
|
||||
const FOOTPRINT* footprint = nullptr;
|
||||
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivityData = board()->GetConnectivity();
|
||||
std::vector<BOARD_ITEM*> dynamicItems;
|
||||
std::unique_ptr<CONNECTIVITY_DATA> dynamicData = nullptr;
|
||||
VECTOR2I lastOffset;
|
||||
|
||||
if( item->Type() == PCB_FOOTPRINT_T )
|
||||
{
|
||||
footprint = static_cast<const FOOTPRINT*>(item);
|
||||
|
||||
for( const PAD* pad : footprint->Pads() )
|
||||
for( PAD* pad : footprint->Pads() )
|
||||
{
|
||||
PNS::ITEM* solid = m_router->GetWorld()->FindItemByParent( pad );
|
||||
|
||||
if( solid )
|
||||
itemsToDrag.Add( solid );
|
||||
|
||||
if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
|
||||
{
|
||||
if( connectivityData->GetRatsnestForPad( pad ).size() > 0 )
|
||||
dynamicItems.push_back( pad );
|
||||
}
|
||||
}
|
||||
|
||||
dynamicData = std::make_unique<CONNECTIVITY_DATA>( dynamicItems, true );
|
||||
connectivityData->BlockRatsnestItems( dynamicItems );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1717,6 +1733,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
VECTOR2I offset = m_endSnapPoint - p;
|
||||
BOARD_ITEM* previewItem;
|
||||
wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) );
|
||||
|
||||
view()->ClearPreview();
|
||||
|
||||
|
@ -1727,7 +1744,6 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
if( drawing->Type() == PCB_FP_SHAPE_T )
|
||||
{
|
||||
FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
|
||||
wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) );
|
||||
shape->FP_SHAPE::Move( fp_offset );
|
||||
}
|
||||
else
|
||||
|
@ -1756,6 +1772,11 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
view()->AddToPreview( previewItem );
|
||||
view()->Hide( zone, true );
|
||||
}
|
||||
|
||||
// Update ratsnest
|
||||
dynamicData->Move( offset - lastOffset );
|
||||
lastOffset = offset;
|
||||
connectivityData->ComputeDynamicRatsnest( dynamicItems, dynamicData.get() );
|
||||
}
|
||||
}
|
||||
else if( hasMouseMoved && ( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
|
||||
|
@ -1800,6 +1821,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
|||
|
||||
view()->ClearPreview();
|
||||
view()->ShowPreview( false );
|
||||
|
||||
connectivityData->ClearDynamicRatsnest();
|
||||
}
|
||||
|
||||
if( m_router->RoutingInProgress() )
|
||||
|
|
Loading…
Reference in New Issue