Cleanup and formtting.

This commit is contained in:
Jeff Young 2020-10-31 15:41:50 +00:00
parent ba4d711356
commit 843974b0bf
2 changed files with 35 additions and 46 deletions

View File

@ -60,7 +60,6 @@ TOOL_BASE::TOOL_BASE( const std::string& aToolName ) :
m_cancelled = false; m_cancelled = false;
m_startItem = nullptr; m_startItem = nullptr;
m_startLayer = 0;
m_startHighlight = false; m_startHighlight = false;
m_endItem = nullptr; m_endItem = nullptr;
@ -187,8 +186,7 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
ITEM* rv = NULL; ITEM* rv = NULL;
bool highContrast = ( displayOptions().m_ContrastModeDisplay != bool highContrast = ( displayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL );
HIGH_CONTRAST_MODE::NORMAL );
for( int i = 0; i < candidateCount; i++ ) 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, // If the user has previously set the current net to be highlighted,
// we assume they want to keep it highlighted after routing // we assume they want to keep it highlighted after routing
m_startHighlight = m_startHighlight = ( rs->IsHighlightEnabled()
( rs->IsHighlightEnabled() && rs->GetHighlightNetCodes().count( aNetcode ) ); && rs->GetHighlightNetCodes().count( aNetcode ) );
rs->SetHighlight( true, aNetcode ); rs->SetHighlight( true, aNetcode );
} }
@ -338,7 +336,9 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
{ {
m_endItem = endItem; m_endItem = endItem;
m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos ); m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
} else { }
else
{
m_endItem = nullptr; m_endItem = nullptr;
m_endSnapPoint = m_gridHelper->Align( mousePos ); m_endSnapPoint = m_gridHelper->Align( mousePos );
} }
@ -347,35 +347,13 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
if( m_endItem ) 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 ROUTER *TOOL_BASE::Router() const
{ {
return m_router; return m_router;
@ -410,15 +388,25 @@ const VECTOR2I TOOL_BASE::snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP)
auto B = li->Anchor( 1 ); auto B = li->Anchor( 1 );
if( ( aP - A ).EuclideanNorm() < w / 2 ) if( ( aP - A ).EuclideanNorm() < w / 2 )
{
anchor = A; anchor = A;
}
else if( ( aP - B ).EuclideanNorm() < w / 2 ) else if( ( aP - B ).EuclideanNorm() < w / 2 )
{
anchor = B; anchor = B;
}
else // TODO(snh): Clean this up else // TODO(snh): Clean this up
{
if( aItem->Kind() == ITEM::SEGMENT_T ) if( aItem->Kind() == ITEM::SEGMENT_T )
{
anchor = m_gridHelper->AlignToSegment( aP, static_cast<SEGMENT*>( li )->Seg() ); anchor = m_gridHelper->AlignToSegment( aP, static_cast<SEGMENT*>( li )->Seg() );
}
else if( aItem->Kind() == ITEM::ARC_T ) else if( aItem->Kind() == ITEM::ARC_T )
{
anchor = m_gridHelper->AlignToArc( aP, anchor = m_gridHelper->AlignToArc( aP,
*static_cast<const SHAPE_ARC*>( static_cast<ARC*>( li )->Shape() ) ); *static_cast<const SHAPE_ARC*>( static_cast<ARC*>( li )->Shape() ) );
}
}
break; break;
} }

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router * KiRouter - a push-and-(sometimes-)shove PCB router
* *
* Copyright (C) 2013-2014 CERN * 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 <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Maciej Suminski <maciej.suminski@cern.ch> * Author: Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -53,30 +53,31 @@ public:
protected: protected:
bool checkSnap( ITEM* aItem ); bool checkSnap( ITEM* aItem );
const VECTOR2I snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP); const VECTOR2I snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP);
virtual ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1, virtual ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1,
bool aIgnorePads = false, const std::vector<ITEM*> aAvoidItems = {} ); bool aIgnorePads = false,
const std::vector<ITEM*> aAvoidItems = {} );
virtual void highlightNet( bool aEnabled, int aNetcode = -1 ); virtual void highlightNet( bool aEnabled, int aNetcode = -1 );
virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false ); virtual void updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads = false );
virtual void updateEndItem( const TOOL_EVENT& aEvent ); 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_endItem;
ITEM* m_startItem; VECTOR2I m_endSnapPoint;
int m_startLayer;
VECTOR2I m_startSnapPoint;
bool m_startHighlight; ///< Keeps track of whether the net was highlighted before routing
ITEM* m_endItem; GRID_HELPER* m_gridHelper;
VECTOR2I m_endSnapPoint;
GRID_HELPER* m_gridHelper;
PNS_KICAD_IFACE* m_iface; PNS_KICAD_IFACE* m_iface;
ROUTER* m_router; ROUTER* m_router;
bool m_cancelled; bool m_cancelled;
}; };
} }