Use same ratsnest colours in the router as the rest of KiCad.

This commit is contained in:
Jeff Young 2022-10-16 22:21:14 +01:00
parent e9f8454a67
commit 3e53426b6c
5 changed files with 34 additions and 8 deletions

View File

@ -848,10 +848,10 @@ void DIFF_PAIR_PLACER::updateLeadingRatLine()
TOPOLOGY topo( m_lastNode ); TOPOLOGY topo( m_lastNode );
if( topo.LeadingRatLine( &m_currentTrace.PLine(), ratLineP ) ) if( topo.LeadingRatLine( &m_currentTrace.PLine(), ratLineP ) )
m_router->GetInterface()->DisplayRatline( ratLineP, 1 ); m_router->GetInterface()->DisplayRatline( ratLineP, m_netP );
if( topo.LeadingRatLine ( &m_currentTrace.NLine(), ratLineN ) ) if( topo.LeadingRatLine ( &m_currentTrace.NLine(), ratLineN ) )
m_router->GetInterface()->DisplayRatline( ratLineN, 3 ); m_router->GetInterface()->DisplayRatline( ratLineN, m_netN );
} }

View File

@ -47,6 +47,8 @@
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_engine.h> #include <drc/drc_engine.h>
#include <connectivity/connectivity_data.h>
#include <wx/log.h> #include <wx/log.h>
#include <memory> #include <memory>
@ -1497,10 +1499,34 @@ void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aClearance, bool
} }
void PNS_KICAD_IFACE::DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor ) void PNS_KICAD_IFACE::DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aNetCode )
{ {
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aRatline, m_view ); ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aRatline, m_view );
pitem->SetColor( COLOR4D( static_cast<EDA_COLOR_T>( aColor ) ) );
KIGFX::RENDER_SETTINGS* renderSettings = m_view->GetPainter()->GetSettings();
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( renderSettings );
bool colorByNet = rs->GetNetColorMode() != NET_COLOR_MODE::OFF;
COLOR4D defaultColor = rs->GetColor( nullptr, LAYER_RATSNEST );
COLOR4D color = defaultColor;
std::shared_ptr<CONNECTIVITY_DATA> connectivity = m_board->GetConnectivity();
std::set<int> highlightedNets = rs->GetHighlightNetCodes();
std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
std::map<wxString, KIGFX::COLOR4D>& ncColors = rs->GetNetclassColorMap();
const std::map<int, wxString>& ncMap = connectivity->GetNetclassMap();
if( colorByNet && netColors.count( aNetCode ) )
color = netColors.at( aNetCode );
else if( colorByNet && ncMap.count( aNetCode ) && ncColors.count( ncMap.at( aNetCode ) ) )
color = ncColors.at( ncMap.at( aNetCode ) );
else
color = defaultColor;
if( color == COLOR4D::UNSPECIFIED )
color = defaultColor;
pitem->SetColor( color.Brightened( 0.5 ).WithAlpha( std::min( 1.0, color.a + 0.4 ) ) );
m_previewItems->Add( pitem ); m_previewItems->Add( pitem );
m_view->Update( m_previewItems ); m_view->Update( m_previewItems );
} }

View File

@ -60,7 +60,7 @@ public:
bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; }; bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
void HideItem( PNS::ITEM* aItem ) override {} void HideItem( PNS::ITEM* aItem ) override {}
void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override {} void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override {}
void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override {} void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aNetCode ) override {}
void AddItem( PNS::ITEM* aItem ) override; void AddItem( PNS::ITEM* aItem ) override;
void UpdateItem( PNS::ITEM* aItem ) override; void UpdateItem( PNS::ITEM* aItem ) override;
void RemoveItem( PNS::ITEM* aItem ) override; void RemoveItem( PNS::ITEM* aItem ) override;
@ -116,7 +116,7 @@ public:
bool IsItemVisible( const PNS::ITEM* aItem ) const override; bool IsItemVisible( const PNS::ITEM* aItem ) const override;
void HideItem( PNS::ITEM* aItem ) override; void HideItem( PNS::ITEM* aItem ) override;
void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override; void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override;
void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override; void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aNetCode ) override;
void Commit() override; void Commit() override;
void AddItem( PNS::ITEM* aItem ) override; void AddItem( PNS::ITEM* aItem ) override;
void UpdateItem( PNS::ITEM* aItem ) override; void UpdateItem( PNS::ITEM* aItem ) override;

View File

@ -1726,7 +1726,7 @@ void LINE_PLACER::updateLeadingRatLine()
TOPOLOGY topo( m_lastNode ); TOPOLOGY topo( m_lastNode );
if( topo.LeadingRatLine( &current, ratLine ) ) if( topo.LeadingRatLine( &current, ratLine ) )
m_router->GetInterface()->DisplayRatline( ratLine, 5 ); m_router->GetInterface()->DisplayRatline( ratLine, m_currentNet );
} }

View File

@ -97,7 +97,7 @@ enum DRAG_MODE
virtual bool IsItemVisible( const PNS::ITEM* aItem ) const = 0; virtual bool IsItemVisible( const PNS::ITEM* aItem ) const = 0;
virtual bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const = 0; virtual bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const = 0;
virtual void DisplayItem( const ITEM* aItem, int aClearance, bool aEdit = false ) = 0; virtual void DisplayItem( const ITEM* aItem, int aClearance, bool aEdit = false ) = 0;
virtual void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) = 0; virtual void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aNetCode ) = 0;
virtual void HideItem( ITEM* aItem ) = 0; virtual void HideItem( ITEM* aItem ) = 0;
virtual void Commit() = 0; virtual void Commit() = 0;
virtual bool ImportSizes( SIZES_SETTINGS& aSizes, ITEM* aStartItem, int aNet ) = 0; virtual bool ImportSizes( SIZES_SETTINGS& aSizes, ITEM* aStartItem, int aNet ) = 0;