Formatting (no functional changes).

This commit is contained in:
Jeff Young 2023-08-31 13:25:13 +01:00
parent 37717a8281
commit c049e1e90d
3 changed files with 53 additions and 51 deletions

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-2021 CERN * Copyright (C) 2013-2021 CERN
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Christian Gagneraud <chgans@gna.org> * Author: Christian Gagneraud <chgans@gna.org>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -37,7 +37,9 @@ class ITEM;
class DEBUG_DECORATOR class DEBUG_DECORATOR
{ {
public: public:
DEBUG_DECORATOR() : m_debugEnabled( false ) {} DEBUG_DECORATOR() :
m_debugEnabled( false )
{}
struct SRC_LOCATION_INFO struct SRC_LOCATION_INFO
{ {

View File

@ -850,8 +850,9 @@ int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( const wxString& aNetName, wxString&
if( rv != 0 && count >= 1 ) if( rv != 0 && count >= 1 )
{ {
aComplementNet = aNetName.Left( aNetName.length() - count ) + aComplementNet aComplementNet = aNetName.Left( aNetName.length() - count )
+ aNetName.Right( count - 1 ); + aComplementNet
+ aNetName.Right( count - 1 );
} }
return rv; return rv;
@ -973,7 +974,7 @@ public:
} }
void AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, int aSize, void AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, int aSize,
const wxString& aName = wxT( "" ), const wxString& aName = wxT( "" ),
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
{ {
@ -991,7 +992,7 @@ public:
} }
void AddItem( const PNS::ITEM* aItem, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0, void AddItem( const PNS::ITEM* aItem, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0,
const wxString& aName = wxT( "" ), const wxString& aName = wxT( "" ),
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
{ {
if( !m_view || !aItem ) if( !m_view || !aItem )
@ -1008,7 +1009,7 @@ public:
} }
void AddShape( const BOX2I& aBox, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0, void AddShape( const BOX2I& aBox, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0,
const wxString& aName = wxT( "" ), const wxString& aName = wxT( "" ),
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
{ {
SHAPE_LINE_CHAIN l; SHAPE_LINE_CHAIN l;
@ -1027,7 +1028,7 @@ public:
} }
void AddShape( const SHAPE* aShape, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0, void AddShape( const SHAPE* aShape, const KIGFX::COLOR4D& aColor, int aOverrideWidth = 0,
const wxString& aName = wxT( "" ), const wxString& aName = wxT( "" ),
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
{ {
if( !m_view || !aShape ) if( !m_view || !aShape )
@ -1110,7 +1111,7 @@ PNS_KICAD_IFACE::~PNS_KICAD_IFACE()
delete m_ruleResolver; delete m_ruleResolver;
delete m_debugDecorator; delete m_debugDecorator;
if( m_previewItems ) if( m_previewItems )
{ {
m_previewItems->FreeItems(); m_previewItems->FreeItems();
delete m_previewItems; delete m_previewItems;

View File

@ -40,17 +40,14 @@ PNS_DEBUG_SHAPE::PNS_DEBUG_SHAPE( PNS_DEBUG_SHAPE* aParent )
PNS_DEBUG_SHAPE::~PNS_DEBUG_SHAPE() PNS_DEBUG_SHAPE::~PNS_DEBUG_SHAPE()
{ {
for( auto s : m_shapes ) for( SHAPE* shape : m_shapes )
{ delete shape;
delete s;
}
for( auto ch : m_children ) for( PNS_DEBUG_SHAPE* child : m_children )
{ delete child;
delete ch;
}
} }
PNS_DEBUG_SHAPE* PNS_DEBUG_SHAPE::NewChild() PNS_DEBUG_SHAPE* PNS_DEBUG_SHAPE::NewChild()
{ {
PNS_DEBUG_SHAPE* ent = new PNS_DEBUG_SHAPE( this ); PNS_DEBUG_SHAPE* ent = new PNS_DEBUG_SHAPE( this );
@ -59,18 +56,20 @@ PNS_DEBUG_SHAPE* PNS_DEBUG_SHAPE::NewChild()
return ent; return ent;
} }
void PNS_DEBUG_SHAPE::AddChild( PNS_DEBUG_SHAPE* ent ) void PNS_DEBUG_SHAPE::AddChild( PNS_DEBUG_SHAPE* ent )
{ {
ent->m_parent = this; ent->m_parent = this;
m_children.push_back( ent ); m_children.push_back( ent );
} }
bool PNS_DEBUG_SHAPE::IsVisible() const bool PNS_DEBUG_SHAPE::IsVisible() const
{ {
if( m_visible ) if( m_visible )
return true; return true;
auto parent = m_parent; PNS_DEBUG_SHAPE* parent = m_parent;
while( parent ) while( parent )
{ {
@ -83,19 +82,17 @@ bool PNS_DEBUG_SHAPE::IsVisible() const
return false; return false;
} }
void PNS_DEBUG_SHAPE::IterateTree( void PNS_DEBUG_SHAPE::IterateTree( std::function<bool( PNS_DEBUG_SHAPE* )> visitor, int depth )
std::function<bool( PNS_DEBUG_SHAPE* )> visitor, int depth )
{ {
if( !visitor( this ) ) if( !visitor( this ) )
return; return;
for( auto child : m_children ) for( PNS_DEBUG_SHAPE* child : m_children )
{
child->IterateTree( visitor, depth + 1 ); child->IterateTree( visitor, depth + 1 );
}
} }
PNS_DEBUG_STAGE::PNS_DEBUG_STAGE() PNS_DEBUG_STAGE::PNS_DEBUG_STAGE()
{ {
m_name = "<unknown>"; m_name = "<unknown>";
@ -109,20 +106,19 @@ PNS_DEBUG_STAGE::~PNS_DEBUG_STAGE()
} }
PNS_TEST_DEBUG_DECORATOR::PNS_TEST_DEBUG_DECORATOR() PNS_TEST_DEBUG_DECORATOR::PNS_TEST_DEBUG_DECORATOR()
{ {
m_iter = 0; m_iter = 0;
m_grouping = false; m_grouping = false;
m_activeEntry = nullptr; m_activeEntry = nullptr;
SetDebugEnabled( true ); SetDebugEnabled( true );
} }
PNS_TEST_DEBUG_DECORATOR::~PNS_TEST_DEBUG_DECORATOR()
{
// fixme: I know it's a hacky tool but it should clean after itself at some point...
}
PNS_TEST_DEBUG_DECORATOR::~PNS_TEST_DEBUG_DECORATOR()
{
// fixme: I know it's a hacky tool but it should clean after itself at some point...
}
PNS_DEBUG_STAGE* PNS_TEST_DEBUG_DECORATOR::currentStage() PNS_DEBUG_STAGE* PNS_TEST_DEBUG_DECORATOR::currentStage()
@ -145,9 +141,7 @@ void PNS_TEST_DEBUG_DECORATOR::BeginGroup( const wxString& name, int aLevel,
ent->m_level = aLevel; ent->m_level = aLevel;
if( m_activeEntry ) if( m_activeEntry )
{
m_activeEntry->AddChild( ent ); m_activeEntry->AddChild( ent );
}
m_activeEntry = ent; m_activeEntry = ent;
m_grouping = true; m_grouping = true;
@ -165,17 +159,19 @@ void PNS_TEST_DEBUG_DECORATOR::EndGroup( const SRC_LOCATION_INFO& aSrcLoc )
m_grouping = false; m_grouping = false;
} }
void PNS_TEST_DEBUG_DECORATOR::addEntry( PNS_DEBUG_SHAPE* ent ) void PNS_TEST_DEBUG_DECORATOR::addEntry( PNS_DEBUG_SHAPE* ent )
{ {
auto st = currentStage(); auto st = currentStage();
m_activeEntry->AddChild( ent ); m_activeEntry->AddChild( ent );
} }
void PNS_TEST_DEBUG_DECORATOR::AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, void PNS_TEST_DEBUG_DECORATOR::AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor,
int aSize, const wxString& aName, int aSize, const wxString& aName,
const SRC_LOCATION_INFO& aSrcLoc ) const SRC_LOCATION_INFO& aSrcLoc )
{ {
auto sh = new SHAPE_LINE_CHAIN; SHAPE_LINE_CHAIN* sh = new SHAPE_LINE_CHAIN;
sh->Append( aP.x - aSize, aP.y - aSize ); sh->Append( aP.x - aSize, aP.y - aSize );
sh->Append( aP.x + aSize, aP.y + aSize ); sh->Append( aP.x + aSize, aP.y + aSize );
@ -201,7 +197,7 @@ void PNS_TEST_DEBUG_DECORATOR::AddItem( const PNS::ITEM* aItem, const KIGFX::COL
int aOverrideWidth, const wxString& aName, int aOverrideWidth, const wxString& aName,
const SRC_LOCATION_INFO& aSrcLoc ) const SRC_LOCATION_INFO& aSrcLoc )
{ {
auto sh = aItem->Shape()->Clone(); SHAPE* sh = aItem->Shape()->Clone();
PNS_DEBUG_SHAPE* ent = new PNS_DEBUG_SHAPE(); PNS_DEBUG_SHAPE* ent = new PNS_DEBUG_SHAPE();
ent->m_shapes.push_back( sh ); ent->m_shapes.push_back( sh );
@ -219,7 +215,7 @@ void PNS_TEST_DEBUG_DECORATOR::AddShape( const SHAPE* aShape, const KIGFX::COLOR
int aOverrideWidth, const wxString& aName, int aOverrideWidth, const wxString& aName,
const SRC_LOCATION_INFO& aSrcLoc ) const SRC_LOCATION_INFO& aSrcLoc )
{ {
auto sh = aShape->Clone(); SHAPE* sh = aShape->Clone();
PNS_DEBUG_SHAPE* ent = new PNS_DEBUG_SHAPE(); PNS_DEBUG_SHAPE* ent = new PNS_DEBUG_SHAPE();
ent->m_shapes.push_back( sh ); ent->m_shapes.push_back( sh );
@ -261,25 +257,28 @@ void PNS_TEST_DEBUG_DECORATOR::SetCurrentStageStatus( bool stat )
m_stages.back()->m_status = stat; m_stages.back()->m_status = stat;
} }
BOX2I PNS_TEST_DEBUG_DECORATOR::GetStageExtents( int stage ) const BOX2I PNS_TEST_DEBUG_DECORATOR::GetStageExtents( int stage ) const
{ {
PNS_DEBUG_STAGE* st = m_stages[stage]; PNS_DEBUG_STAGE* st = m_stages[stage];
BOX2I bb; BOX2I bb;
bool first = true; bool first = true;
auto visitor = [&]( PNS_DEBUG_SHAPE* ent ) -> bool { auto visitor =
for( auto sh : ent->m_shapes ) [&]( PNS_DEBUG_SHAPE* ent ) -> bool
{ {
if( first ) for( SHAPE* sh : ent->m_shapes )
bb = sh->BBox(); {
else if( first )
bb.Merge( sh->BBox() ); bb = sh->BBox();
else
bb.Merge( sh->BBox() );
first = false; first = false;
} }
return true; return true;
}; };
return bb; return bb;
} }