diff --git a/pcbnew/generators/pcb_generator_meanders.cpp b/pcbnew/generators/pcb_generator_meanders.cpp index d1e1b1c345..c5f98fd683 100644 --- a/pcbnew/generators/pcb_generator_meanders.cpp +++ b/pcbnew/generators/pcb_generator_meanders.cpp @@ -449,7 +449,7 @@ public: } } - aCommit->Push( "Remove meander", APPEND_UNDO ); + aCommit->Push( "Remove Meander", APPEND_UNDO ); } std::optional getLineBetweenPoints( VECTOR2I origStart, VECTOR2I origEnd, @@ -1047,11 +1047,14 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) { if( m_pickerItem ) { + GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); + if( !m_meander ) { - // First click; create a meander generator + // First click; create a meander + + generatorTool->HighlightNet( nullptr ); - m_toolMgr->GetTool()->UnbrightenItem( m_pickerItem ); m_frame->SetActiveLayer( m_pickerItem->GetLayer() ); m_meander = new PCB_GENERATOR_MEANDERS( m_board, m_pickerItem->GetLayer() ); @@ -1067,8 +1070,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) else { // Second click; we're done - BOARD_COMMIT commit( m_frame ); - GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); + BOARD_COMMIT commit( m_frame ); m_meander->EditStart( generatorTool, m_board, m_frame, &commit ); m_meander->Update( generatorTool, m_board, m_frame, &commit ); @@ -1089,6 +1091,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide(); GENERAL_COLLECTOR collector; + GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); collector.Collect( board, { PCB_TRACE_T, PCB_ARC_T }, aPos, guide ); @@ -1100,29 +1103,27 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) if( !m_meander ) { - // First click not yet made; we're in brighten-track-under-cursor mode + // First click not yet made; we're in highlight-net-under-cursor mode - if( m_pickerItem != item ) + if( !m_pickerItem ) { - if( m_pickerItem ) - selTool->UnbrightenItem( m_pickerItem ); - - m_pickerItem = item; - - if( m_pickerItem ) - selTool->BrightenItem( m_pickerItem ); + m_pickerItem = static_cast( item ); + generatorTool->HighlightNet( m_pickerItem ); + } + else + { + m_pickerItem = static_cast( item ); + generatorTool->UpdateHighlightedNet( m_pickerItem ); } } else { - // First click alread made; we're in preview-meander mode + // First click already made; we're in preview-meander mode m_meander->SetEnd( aPos ); if( m_meander->GetPosition() != m_meander->GetEnd() ) { - GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); - m_meander->EditStart( generatorTool, m_board, m_frame, nullptr ); m_meander->Update( generatorTool, m_board, m_frame, nullptr ); } @@ -1142,6 +1143,10 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) picker->SetFinalizeHandler( [this]( const int& aFinalState ) { + GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); + + generatorTool->HighlightNet( nullptr ); + // Ensure the cursor gets changed & updated m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_frame->GetCanvas()->Refresh(); diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 8f17b05396..2b02617e68 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -278,6 +278,18 @@ void TOOL_BASE::highlightNets( bool aEnabled, std::set aNets ) } +void TOOL_BASE::updateHighlightedNets( std::set aNets ) +{ + RENDER_SETTINGS* rs = getView()->GetPainter()->GetSettings(); + std::set netcodes; + + for( const NET_HANDLE& net : aNets ) + netcodes.insert( m_router->GetInterface()->GetNetCode( net ) ); + + rs->SetHighlight( netcodes, true ); +} + + bool TOOL_BASE::checkSnap( ITEM *aItem ) { // Sync PNS engine settings with the general PCB editor options. diff --git a/pcbnew/router/pns_tool_base.h b/pcbnew/router/pns_tool_base.h index d6c543ffd7..5aa6bb3da6 100644 --- a/pcbnew/router/pns_tool_base.h +++ b/pcbnew/router/pns_tool_base.h @@ -63,6 +63,7 @@ protected: const std::vector aAvoidItems = {} ); virtual void highlightNets( bool aEnabled, std::set aNetcodes = {} ); + virtual void updateHighlightedNets( std::set aNetcodes = {} ); virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false ); virtual void updateEndItem( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index fa9975d725..f4e7ff7a98 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -352,7 +352,7 @@ private: STROKE_PARAMS m_stroke; // Current stroke for multi-segment drawing TEXT_ATTRIBUTES m_textAttrs; - BOARD_ITEM* m_pickerItem; + BOARD_CONNECTED_ITEM* m_pickerItem; PCB_GENERATOR_MEANDERS* m_meander; diff --git a/pcbnew/tools/generator_tool.cpp b/pcbnew/tools/generator_tool.cpp index 13b8c36b2d..df77a10001 100644 --- a/pcbnew/tools/generator_tool.cpp +++ b/pcbnew/tools/generator_tool.cpp @@ -250,6 +250,24 @@ int GENERATOR_TOOL::GenEditAction( const TOOL_EVENT& aEvent ) } +void GENERATOR_TOOL::HighlightNet( BOARD_CONNECTED_ITEM* aStartItem ) +{ + if( aStartItem && aStartItem->GetNet() ) + highlightNets( true, { aStartItem->GetNet() } ); + else + highlightNets( false ); +} + + +void GENERATOR_TOOL::UpdateHighlightedNet( BOARD_CONNECTED_ITEM* aStartItem ) +{ + if( aStartItem && aStartItem->GetNet() ) + updateHighlightedNets( { aStartItem->GetNet() } ); + else + highlightNets( false ); +} + + void GENERATOR_TOOL::setTransitions() { // Generator actions diff --git a/pcbnew/tools/generator_tool.h b/pcbnew/tools/generator_tool.h index 2d85fa6094..93f7fb8879 100644 --- a/pcbnew/tools/generator_tool.h +++ b/pcbnew/tools/generator_tool.h @@ -58,6 +58,9 @@ public: int RegenerateItem( const TOOL_EVENT& aEvent ); int GenEditAction( const TOOL_EVENT& aEvent ); + void HighlightNet( BOARD_CONNECTED_ITEM* aStartItem ); + void UpdateHighlightedNet( BOARD_CONNECTED_ITEM* aStartItem ); + private: ///< Set up handlers for various events. void setTransitions() override;