From 843974b0bf533c135749eaead85f19b2c9be9901 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 31 Oct 2020 15:41:50 +0000 Subject: [PATCH] Cleanup and formtting. --- pcbnew/router/pns_tool_base.cpp | 50 +++++++++++++-------------------- pcbnew/router/pns_tool_base.h | 31 ++++++++++---------- 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 59c2454954..d5e8706363 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -60,7 +60,6 @@ TOOL_BASE::TOOL_BASE( const std::string& aToolName ) : m_cancelled = false; m_startItem = nullptr; - m_startLayer = 0; m_startHighlight = false; m_endItem = nullptr; @@ -187,8 +186,7 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b ITEM* rv = NULL; - bool highContrast = ( displayOptions().m_ContrastModeDisplay != - HIGH_CONTRAST_MODE::NORMAL ); + bool highContrast = ( displayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ); for( int i = 0; i < candidateCount; i++ ) { @@ -221,8 +219,8 @@ void TOOL_BASE::highlightNet( bool aEnabled, int aNetcode ) { // If the user has previously set the current net to be highlighted, // we assume they want to keep it highlighted after routing - m_startHighlight = - ( rs->IsHighlightEnabled() && rs->GetHighlightNetCodes().count( aNetcode ) ); + m_startHighlight = ( rs->IsHighlightEnabled() + && rs->GetHighlightNetCodes().count( aNetcode ) ); rs->SetHighlight( true, aNetcode ); } @@ -338,7 +336,9 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent ) { m_endItem = endItem; m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos ); - } else { + } + else + { m_endItem = nullptr; m_endSnapPoint = m_gridHelper->Align( mousePos ); } @@ -347,35 +347,13 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent ) if( m_endItem ) { - wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() ); + wxLogTrace( "PNS", "%s, layer : %d", + m_endItem->KindStr().c_str(), + m_endItem->Layers().Start() ); } } -void TOOL_BASE::deleteTraces( ITEM* aStartItem, bool aWholeTrack ) -{ - NODE *node = m_router->GetWorld()->Branch(); - - if( !aStartItem ) - return; - - if( !aWholeTrack ) - { - node->Remove( aStartItem ); - } - else - { - TOPOLOGY topo( node ); - ITEM_SET path = topo.AssembleTrivialPath( aStartItem ); - - for( const auto& ent : path.Items() ) - node->Remove( ent.item ); - } - - m_router->CommitRouting( node ); -} - - ROUTER *TOOL_BASE::Router() const { return m_router; @@ -410,15 +388,25 @@ const VECTOR2I TOOL_BASE::snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP) auto B = li->Anchor( 1 ); if( ( aP - A ).EuclideanNorm() < w / 2 ) + { anchor = A; + } else if( ( aP - B ).EuclideanNorm() < w / 2 ) + { anchor = B; + } else // TODO(snh): Clean this up + { if( aItem->Kind() == ITEM::SEGMENT_T ) + { anchor = m_gridHelper->AlignToSegment( aP, static_cast( li )->Seg() ); + } else if( aItem->Kind() == ITEM::ARC_T ) + { anchor = m_gridHelper->AlignToArc( aP, *static_cast( static_cast( li )->Shape() ) ); + } + } break; } diff --git a/pcbnew/router/pns_tool_base.h b/pcbnew/router/pns_tool_base.h index 97b1ffa10b..f650853578 100644 --- a/pcbnew/router/pns_tool_base.h +++ b/pcbnew/router/pns_tool_base.h @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2014 CERN - * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. * Author: Tomasz Wlostowski * Author: Maciej Suminski * @@ -53,30 +53,31 @@ public: protected: bool checkSnap( ITEM* aItem ); + const VECTOR2I snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP); + virtual ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1, - bool aIgnorePads = false, const std::vector aAvoidItems = {} ); + bool aIgnorePads = false, + const std::vector aAvoidItems = {} ); + virtual void highlightNet( bool aEnabled, int aNetcode = -1 ); + virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false ); virtual void updateEndItem( const TOOL_EVENT& aEvent ); - void deleteTraces( ITEM* aStartItem, bool aWholeTrack ); - MSG_PANEL_ITEMS m_panelItems; + SIZES_SETTINGS m_savedSizes; // Stores sizes settings between router invocations + ITEM* m_startItem; + VECTOR2I m_startSnapPoint; + bool m_startHighlight; // Was net highlighted before routing? - SIZES_SETTINGS m_savedSizes; ///< Stores sizes settings between router invocations - ITEM* m_startItem; - int m_startLayer; - VECTOR2I m_startSnapPoint; - bool m_startHighlight; ///< Keeps track of whether the net was highlighted before routing + ITEM* m_endItem; + VECTOR2I m_endSnapPoint; - ITEM* m_endItem; - VECTOR2I m_endSnapPoint; - - GRID_HELPER* m_gridHelper; + GRID_HELPER* m_gridHelper; PNS_KICAD_IFACE* m_iface; - ROUTER* m_router; + ROUTER* m_router; - bool m_cancelled; + bool m_cancelled; }; }