From d248736f081d3d084523b6c0aaca90a08934cd09 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 10 Jul 2020 21:37:53 -0400 Subject: [PATCH] Draw ratsnest with colors if color data is available --- pcbnew/pcb_painter.cpp | 2 -- pcbnew/ratsnest/ratsnest_viewitem.cpp | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index e342a13c58..ebbc48de5e 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -238,8 +238,6 @@ void PCB_RENDER_SETTINGS::LoadNetSettings( const NET_SETTINGS& aSettings, const } m_hiddenNets = aHiddenNets; - - } diff --git a/pcbnew/ratsnest/ratsnest_viewitem.cpp b/pcbnew/ratsnest/ratsnest_viewitem.cpp index 5f3cc6a12c..a4a47e4a10 100644 --- a/pcbnew/ratsnest/ratsnest_viewitem.cpp +++ b/pcbnew/ratsnest/ratsnest_viewitem.cpp @@ -84,7 +84,7 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const std::set highlightedNets = rs->GetHighlightNetCodes(); const std::set& hiddenNets = rs->GetHiddenNets(); - gal->SetStrokeColor( color.Brightened(0.5) ); + std::map& netColors = rs->GetNetColorMap(); const bool curved_ratsnest = rs->GetCurvedRatsnestLinesEnabled(); @@ -94,6 +94,13 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const if( hiddenNets.count( l.netCode ) ) continue; + if( colorByNet && netColors.count( l.netCode ) ) + color = netColors.at( l.netCode ); + else + color = defaultColor; + + gal->SetStrokeColor( color.Brightened( 0.5 ) ); + if ( l.a == l.b ) { gal->DrawLine( VECTOR2I( l.a.x - CROSS_SIZE, l.a.y - CROSS_SIZE ), @@ -128,10 +135,10 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const if( !net ) continue; - if( colorByNet ) - { - // TODO(JE) - RN_NET to net name / netclass name link - } + if( colorByNet && netColors.count( i ) ) + color = netColors.at( i ); + else + color = defaultColor; // Draw the "static" ratsnest if( highlightedNets.count( i ) )