KiCad PCB EDA Suite
PNS_LOG_PLAYER_KICAD_IFACE Class Reference

#include <pns_log_player.h>

Inheritance diagram for PNS_LOG_PLAYER_KICAD_IFACE:
PNS_KICAD_IFACE_BASE PNS::ROUTER_IFACE

Public Member Functions

 PNS_LOG_PLAYER_KICAD_IFACE (PNS_LOG_VIEW_TRACKER *aViewTracker)
 
 ~PNS_LOG_PLAYER_KICAD_IFACE ()
 
void HideItem (PNS::ITEM *aItem) override
 
void DisplayItem (const PNS::ITEM *aItem, int aClearance, bool aEdit=false) override
 
void EraseView () override
 
void SetBoard (BOARD *aBoard)
 
void SyncWorld (PNS::NODE *aWorld) override
 
bool IsAnyLayerVisible (const LAYER_RANGE &aLayer) const override
 
bool IsFlashedOnLayer (const PNS::ITEM *aItem, int aLayer) const override
 
bool IsItemVisible (const PNS::ITEM *aItem) const override
 
void DisplayRatline (const SHAPE_LINE_CHAIN &aRatline, int aColor=-1) override
 
void AddItem (PNS::ITEM *aItem) override
 
void UpdateItem (PNS::ITEM *aItem) override
 
void RemoveItem (PNS::ITEM *aItem) override
 
void Commit () override
 
bool ImportSizes (PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
 
int StackupHeight (int aFirstLayer, int aSecondLayer) const override
 
void UpdateNet (int aNetCode) override
 
void SetDebugDecorator (PNS::DEBUG_DECORATOR *aDec)
 
void SetStartLayer (int aLayer)
 
virtual PNS::NODEGetWorld () const override
 
BOARDGetBoard () const
 
virtual EDA_UNITS GetUnits () const
 
PNS::RULE_RESOLVERGetRuleResolver () override
 
PNS::DEBUG_DECORATORGetDebugDecorator () override
 

Protected Member Functions

std::unique_ptr< PNS::SOLIDsyncPad (PAD *aPad)
 
std::unique_ptr< PNS::SEGMENTsyncTrack (PCB_TRACK *aTrack)
 
std::unique_ptr< PNS::ARCsyncArc (PCB_ARC *aArc)
 
std::unique_ptr< PNS::VIAsyncVia (PCB_VIA *aVia)
 
bool syncTextItem (PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
 
bool syncGraphicalItem (PNS::NODE *aWorld, PCB_SHAPE *aItem)
 
bool syncZone (PNS::NODE *aWorld, ZONE *aZone, SHAPE_POLY_SET *aBoardOutline)
 
bool inheritTrackWidth (PNS::ITEM *aItem, int *aInheritedWidth)
 

Protected Attributes

PNS_PCBNEW_RULE_RESOLVERm_ruleResolver
 
PNS::DEBUG_DECORATORm_debugDecorator
 
PNS::NODEm_world
 
BOARDm_board
 
int m_startLayer
 

Private Attributes

PNS_LOG_VIEW_TRACKERm_viewTracker
 

Detailed Description

Definition at line 64 of file pns_log_player.h.

Constructor & Destructor Documentation

◆ PNS_LOG_PLAYER_KICAD_IFACE()

PNS_LOG_PLAYER_KICAD_IFACE::PNS_LOG_PLAYER_KICAD_IFACE ( PNS_LOG_VIEW_TRACKER aViewTracker)

Definition at line 204 of file pns_log_player.cpp.

204 :
205 m_viewTracker( aViewTracker )
206{
207}
PNS_LOG_VIEW_TRACKER * m_viewTracker

◆ ~PNS_LOG_PLAYER_KICAD_IFACE()

PNS_LOG_PLAYER_KICAD_IFACE::~PNS_LOG_PLAYER_KICAD_IFACE ( )

Definition at line 209 of file pns_log_player.cpp.

210{
211}

Member Function Documentation

◆ AddItem()

void PNS_KICAD_IFACE_BASE::AddItem ( PNS::ITEM aItem)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 1603 of file pns_kicad_iface.cpp.

1604{
1605
1606}

◆ Commit()

void PNS_KICAD_IFACE_BASE::Commit ( )
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 67 of file pns_kicad_iface.h.

67{}

◆ DisplayItem()

void PNS_LOG_PLAYER_KICAD_IFACE::DisplayItem ( const PNS::ITEM aItem,
int  aClearance,
bool  aEdit = false 
)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 219 of file pns_log_player.cpp.

220{
221 //printf("DBG disp %p\n", aItem);
222 m_viewTracker->DisplayItem( aItem );
223}
void DisplayItem(const PNS::ITEM *aItem)

References PNS_LOG_VIEW_TRACKER::DisplayItem(), and m_viewTracker.

◆ DisplayRatline()

void PNS_KICAD_IFACE_BASE::DisplayRatline ( const SHAPE_LINE_CHAIN aRatline,
int  aColor = -1 
)
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 63 of file pns_kicad_iface.h.

63{}

◆ EraseView()

void PNS_KICAD_IFACE_BASE::EraseView ( )
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 55 of file pns_kicad_iface.h.

55{};

◆ GetBoard()

BOARD * PNS_KICAD_IFACE_BASE::GetBoard ( ) const
inlineinherited

Definition at line 79 of file pns_kicad_iface.h.

79{ return m_board; }

References PNS_KICAD_IFACE_BASE::m_board.

Referenced by ROUTER_TOOL::saveRouterDebugLog().

◆ GetDebugDecorator()

PNS::DEBUG_DECORATOR * PNS_KICAD_IFACE_BASE::GetDebugDecorator ( )
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 876 of file pns_kicad_iface.cpp.

877{
878 return m_debugDecorator;
879}
PNS::DEBUG_DECORATOR * m_debugDecorator

References PNS_KICAD_IFACE_BASE::m_debugDecorator.

◆ GetRuleResolver()

PNS::RULE_RESOLVER * PNS_KICAD_IFACE_BASE::GetRuleResolver ( )
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 1750 of file pns_kicad_iface.cpp.

1751{
1752 return m_ruleResolver;
1753}
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References PNS_KICAD_IFACE_BASE::m_ruleResolver.

Referenced by ROUTER_TOOL::UpdateMessagePanel().

◆ GetUnits()

virtual EDA_UNITS PNS_KICAD_IFACE_BASE::GetUnits ( ) const
inlinevirtualinherited

Reimplemented in PNS_KICAD_IFACE.

Definition at line 81 of file pns_kicad_iface.h.

81{ return EDA_UNITS::MILLIMETRES; };

References MILLIMETRES.

Referenced by PNS_KICAD_IFACE_BASE::syncZone().

◆ GetWorld()

virtual PNS::NODE * PNS_KICAD_IFACE_BASE::GetWorld ( ) const
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 77 of file pns_kicad_iface.h.

77{ return m_world; };

References PNS_KICAD_IFACE_BASE::m_world.

◆ HideItem()

void PNS_LOG_PLAYER_KICAD_IFACE::HideItem ( PNS::ITEM aItem)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 213 of file pns_log_player.cpp.

214{
215 //printf("DBG hide %p\n", aItem);
216 m_viewTracker->HideItem( aItem );
217}
void HideItem(PNS::ITEM *aItem)

References PNS_LOG_VIEW_TRACKER::HideItem(), and m_viewTracker.

◆ ImportSizes()

bool PNS_KICAD_IFACE_BASE::ImportSizes ( PNS::SIZES_SETTINGS aSizes,
PNS::ITEM aStartItem,
int  aNet 
)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 540 of file pns_kicad_iface.cpp.

542{
544 PNS::CONSTRAINT constraint;
545
546 if( aStartItem && m_startLayer < 0 )
547 m_startLayer = aStartItem->Layer();
548
549 aSizes.SetMinClearance( bds.m_MinClearance );
550
551 int trackWidth = bds.m_TrackMinWidth;
552 bool found = false;
553
554 if( bds.m_UseConnectedTrackWidth && !bds.m_TempOverrideTrackWidth && aStartItem != nullptr )
555 {
556 found = inheritTrackWidth( aStartItem, &trackWidth );
557
558 if( found )
559 aSizes.SetWidthSource( _( "existing track" ) );
560 }
561
562 if( !found && bds.UseNetClassTrack() && aStartItem )
563 {
565 m_startLayer, &constraint ) )
566 {
567 trackWidth = std::max( trackWidth, constraint.m_Value.Opt() );
568 found = true;
569
570 if( trackWidth == constraint.m_Value.Opt() )
571 aSizes.SetWidthSource( constraint.m_RuleName );
572 else
573 aSizes.SetWidthSource( _( "board minimum width" ) );
574 }
575 }
576
577 if( !found )
578 {
579 trackWidth = std::max( trackWidth, bds.GetCurrentTrackWidth() );
580
581 if( bds.UseNetClassTrack() )
582 aSizes.SetWidthSource( _( "netclass 'Default'" ) );
583 else if( trackWidth == bds.GetCurrentTrackWidth() )
584 aSizes.SetWidthSource( _( "user choice" ) );
585 else
586 aSizes.SetWidthSource( _( "board minimum width" ) );
587 }
588
589 aSizes.SetTrackWidth( trackWidth );
591
592 int viaDiameter = bds.m_ViasMinSize;
593 int viaDrill = bds.m_MinThroughDrill;
594
595 if( bds.UseNetClassVia() && aStartItem ) // netclass value
596 {
598 nullptr, m_startLayer, &constraint ) )
599 {
600 viaDiameter = std::max( viaDiameter, constraint.m_Value.Opt() );
601 }
602
604 m_startLayer, &constraint ) )
605 {
606 viaDrill = std::max( viaDrill, constraint.m_Value.Opt() );
607 }
608 }
609 else
610 {
611 viaDiameter = bds.GetCurrentViaSize();
612 viaDrill = bds.GetCurrentViaDrill();
613 }
614
615 aSizes.SetViaDiameter( viaDiameter );
616 aSizes.SetViaDrill( viaDrill );
617
618 int diffPairWidth = bds.m_TrackMinWidth;
619 int diffPairGap = bds.m_MinClearance;
620 int diffPairViaGap = bds.m_MinClearance;
621
622 found = false;
623
624 // First try to pick up diff pair width from starting track, if enabled
625 if( bds.m_UseConnectedTrackWidth && aStartItem )
626 found = inheritTrackWidth( aStartItem, &diffPairWidth );
627
628 // Next, pick up gap from netclass, and width also if we didn't get a starting width above
629 if( bds.UseNetClassDiffPair() && aStartItem )
630 {
632 nullptr, m_startLayer, &constraint ) )
633 {
634 diffPairWidth = std::max( diffPairWidth, constraint.m_Value.Opt() );
635 }
636
638 nullptr, m_startLayer, &constraint ) )
639 {
640 diffPairGap = std::max( diffPairGap, constraint.m_Value.Opt() );
641 diffPairViaGap = std::max( diffPairViaGap, constraint.m_Value.Opt() );
642 }
643 }
644 else
645 {
646 diffPairWidth = bds.GetCurrentDiffPairWidth();
647 diffPairGap = bds.GetCurrentDiffPairGap();
648 diffPairViaGap = bds.GetCurrentDiffPairViaGap();
649 }
650
651 aSizes.SetDiffPairWidth( diffPairWidth );
652 aSizes.SetDiffPairGap( diffPairGap );
653 aSizes.SetDiffPairViaGap( diffPairViaGap );
654 aSizes.SetDiffPairViaGapSameAsTraceGap( false );
655
656 int holeToHoleMin = bds.m_HoleToHoleMin;
657 PNS::VIA dummyVia;
658
660 &dummyVia, UNDEFINED_LAYER, &constraint ) )
661 {
662 holeToHoleMin = constraint.m_Value.Min();
663 }
664
665 aSizes.SetHoleToHole( holeToHoleMin );
666
667 return true;
668}
Container for design settings for a BOARD object.
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
bool UseNetClassTrack() const
Return true if netclass values should be used to obtain appropriate track width.
bool UseNetClassDiffPair() const
Return true if netclass values should be used to obtain appropriate diff pair dimensions.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:617
T Min() const
Definition: minoptmax.h:33
T Opt() const
Definition: minoptmax.h:35
virtual int Layer() const
Definition: pns_item.h:160
void SetTrackWidth(int aWidth)
void SetDiffPairViaGapSameAsTraceGap(bool aEnable)
void SetDiffPairWidth(int aWidth)
void SetDiffPairGap(int aGap)
void SetHoleToHole(int aHoleToHole)
void SetViaDrill(int aDrill)
void SetDiffPairViaGap(int aGap)
void SetMinClearance(int aClearance)
void SetViaDiameter(int aDiameter)
void SetWidthSource(const wxString &aSource)
void SetTrackWidthIsExplicit(bool aIsExplicit)
bool inheritTrackWidth(PNS::ITEM *aItem, int *aInheritedWidth)
virtual bool QueryConstraint(PNS::CONSTRAINT_TYPE aType, const PNS::ITEM *aItemA, const PNS::ITEM *aItemB, int aLayer, PNS::CONSTRAINT *aConstraint) override
#define _(s)
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
wxString m_RuleName
Definition: pns_node.h:72
MINOPTMAX< int > m_Value
Definition: pns_node.h:70

References _, PNS::CT_DIFF_PAIR_GAP, PNS::CT_HOLE_TO_HOLE, PNS::CT_VIA_DIAMETER, PNS::CT_VIA_HOLE, PNS::CT_WIDTH, BOARD_DESIGN_SETTINGS::GetCurrentDiffPairGap(), BOARD_DESIGN_SETTINGS::GetCurrentDiffPairViaGap(), BOARD_DESIGN_SETTINGS::GetCurrentDiffPairWidth(), BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), PNS_KICAD_IFACE_BASE::inheritTrackWidth(), PNS::ITEM::Layer(), PNS_KICAD_IFACE_BASE::m_board, BOARD_DESIGN_SETTINGS::m_HoleToHoleMin, BOARD_DESIGN_SETTINGS::m_MinClearance, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, PNS::CONSTRAINT::m_RuleName, PNS_KICAD_IFACE_BASE::m_ruleResolver, PNS_KICAD_IFACE_BASE::m_startLayer, BOARD_DESIGN_SETTINGS::m_TempOverrideTrackWidth, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, BOARD_DESIGN_SETTINGS::m_UseConnectedTrackWidth, PNS::CONSTRAINT::m_Value, BOARD_DESIGN_SETTINGS::m_ViasMinSize, MINOPTMAX< T >::Min(), MINOPTMAX< T >::Opt(), PNS_PCBNEW_RULE_RESOLVER::QueryConstraint(), PNS::SIZES_SETTINGS::SetDiffPairGap(), PNS::SIZES_SETTINGS::SetDiffPairViaGap(), PNS::SIZES_SETTINGS::SetDiffPairViaGapSameAsTraceGap(), PNS::SIZES_SETTINGS::SetDiffPairWidth(), PNS::SIZES_SETTINGS::SetHoleToHole(), PNS::SIZES_SETTINGS::SetMinClearance(), PNS::SIZES_SETTINGS::SetTrackWidth(), PNS::SIZES_SETTINGS::SetTrackWidthIsExplicit(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetWidthSource(), UNDEFINED_LAYER, BOARD_DESIGN_SETTINGS::UseNetClassDiffPair(), BOARD_DESIGN_SETTINGS::UseNetClassTrack(), and BOARD_DESIGN_SETTINGS::UseNetClassVia().

Referenced by ROUTER_TOOL::onTrackViaSizeChanged(), and ROUTER_TOOL::prepareInteractive().

◆ inheritTrackWidth()

bool PNS_KICAD_IFACE_BASE::inheritTrackWidth ( PNS::ITEM aItem,
int *  aInheritedWidth 
)
protectedinherited

Definition at line 477 of file pns_kicad_iface.cpp.

478{
479 VECTOR2I p;
480
481 assert( aItem->Owner() != nullptr );
482
483 auto tryGetTrackWidth =
484 []( PNS::ITEM* aPnsItem ) -> int
485 {
486 switch( aPnsItem->Kind() )
487 {
488 case PNS::ITEM::SEGMENT_T: return static_cast<PNS::SEGMENT*>( aPnsItem )->Width();
489 case PNS::ITEM::ARC_T: return static_cast<PNS::ARC*>( aPnsItem )->Width();
490 default: return -1;
491 }
492 };
493
494 int itemTrackWidth = tryGetTrackWidth( aItem );
495
496 if( itemTrackWidth > 0 )
497 {
498 *aInheritedWidth = itemTrackWidth;
499 return true;
500 }
501
502 switch( aItem->Kind() )
503 {
504 case PNS::ITEM::VIA_T:
505 p = static_cast<PNS::VIA*>( aItem )->Pos();
506 break;
507
509 p = static_cast<PNS::SOLID*>( aItem )->Pos();
510 break;
511
512 default:
513 return false;
514 }
515
516 PNS::JOINT* jt = static_cast<PNS::NODE*>( aItem->Owner() )->FindJoint( p, aItem );
517
518 assert( jt != nullptr );
519
520 int mval = INT_MAX;
521
522 PNS::ITEM_SET linkedSegs = jt->Links();
524
525 for( PNS::ITEM* item : linkedSegs.Items() )
526 {
527 int w = tryGetTrackWidth( item );
528 assert( w > 0 );
529 mval = std::min( w, mval );
530 }
531
532 if( mval == INT_MAX )
533 return false;
534
535 *aInheritedWidth = mval;
536 return true;
537}
ITEM_SET & ExcludeItem(const ITEM *aItem)
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:68
ENTRIES & Items()
Definition: pns_itemset.h:135
Base class for PNS router board items.
Definition: pns_item.h:56
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:132
NODE * Owner() const
Return the owner of this item, or NULL if there's none.
Definition: pns_item.h:173
@ SOLID_T
Definition: pns_item.h:63
@ SEGMENT_T
Definition: pns_item.h:66
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
Definition: pns_joint.h:43
ITEM_SET & Links()
Definition: pns_joint.h:251
Keep the router "world" - i.e.
Definition: pns_node.h:155

References PNS::ITEM::ARC_T, PNS::ITEM_SET::ExcludeItem(), PNS::ITEM_SET::FilterKinds(), PNS::ITEM_SET::Items(), PNS::ITEM::Kind(), PNS::JOINT::Links(), PNS::ITEM::Owner(), PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by PNS_KICAD_IFACE_BASE::ImportSizes().

◆ IsAnyLayerVisible()

bool PNS_KICAD_IFACE_BASE::IsAnyLayerVisible ( const LAYER_RANGE aLayer) const
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 58 of file pns_kicad_iface.h.

58{ return true; };

◆ IsFlashedOnLayer()

bool PNS_KICAD_IFACE_BASE::IsFlashedOnLayer ( const PNS::ITEM aItem,
int  aLayer 
) const
overridevirtualinherited

Default is all layers

Implements PNS::ROUTER_IFACE.

Definition at line 1254 of file pns_kicad_iface.cpp.

1255{
1257 if( aLayer < 0 )
1258 return true;
1259
1260 if( aItem->Parent() )
1261 {
1262 switch( aItem->Parent()->Type() )
1263 {
1264 case PCB_VIA_T:
1265 {
1266 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem->Parent() );
1267
1268 return via->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
1269 }
1270
1271 case PCB_PAD_T:
1272 {
1273 const PAD* pad = static_cast<const PAD*>( aItem->Parent() );
1274
1275 return pad->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
1276 }
1277
1278 default:
1279 break;
1280 }
1281 }
1282
1283 return aItem->Layers().Overlaps( aLayer );
1284}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
Definition: pad.h:58
BOARD_ITEM * Parent() const
Definition: pns_item.h:151
const LAYER_RANGE & Layers() const
Definition: pns_item.h:156
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87

References PNS::ITEM::Layers(), LAYER_RANGE::Overlaps(), pad, PNS::ITEM::Parent(), PCB_PAD_T, PCB_VIA_T, EDA_ITEM::Type(), and via.

◆ IsItemVisible()

bool PNS_KICAD_IFACE_BASE::IsItemVisible ( const PNS::ITEM aItem) const
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 60 of file pns_kicad_iface.h.

60{ return true; };

◆ RemoveItem()

void PNS_KICAD_IFACE_BASE::RemoveItem ( PNS::ITEM aItem)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 1511 of file pns_kicad_iface.cpp.

1512{
1513}

◆ SetBoard()

void PNS_KICAD_IFACE_BASE::SetBoard ( BOARD aBoard)
inherited

Definition at line 1232 of file pns_kicad_iface.cpp.

1233{
1234 m_board = aBoard;
1235 wxLogTrace( wxT( "PNS" ), wxT( "m_board = %p" ), m_board );
1236}

References PNS_KICAD_IFACE_BASE::m_board.

Referenced by PNS::TOOL_BASE::Reset().

◆ SetDebugDecorator()

void PNS_KICAD_IFACE_BASE::SetDebugDecorator ( PNS::DEBUG_DECORATOR aDec)
inherited

Definition at line 1438 of file pns_kicad_iface.cpp.

1439{
1440 m_debugDecorator = aDec;
1441}

References PNS_KICAD_IFACE_BASE::m_debugDecorator.

◆ SetStartLayer()

void PNS_KICAD_IFACE_BASE::SetStartLayer ( int  aLayer)
inlineinherited

Definition at line 75 of file pns_kicad_iface.h.

75{ m_startLayer = aLayer; }

References PNS_KICAD_IFACE_BASE::m_startLayer.

Referenced by ROUTER_TOOL::prepareInteractive().

◆ StackupHeight()

int PNS_KICAD_IFACE_BASE::StackupHeight ( int  aFirstLayer,
int  aSecondLayer 
) const
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 671 of file pns_kicad_iface.cpp.

672{
674 return 0;
675
677
678 return stackup.GetLayerDistance( ToLAYER_ID( aFirstLayer ), ToLAYER_ID( aSecondLayer ) );
679}
BOARD_STACKUP & GetStackupDescriptor()
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
Manage layers needed to make a physical board.
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:926

References BOARD::GetDesignSettings(), BOARD_STACKUP::GetLayerDistance(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), PNS_KICAD_IFACE_BASE::m_board, BOARD_DESIGN_SETTINGS::m_UseHeightForLengthCalcs, and ToLAYER_ID().

◆ syncArc()

std::unique_ptr< PNS::ARC > PNS_KICAD_IFACE_BASE::syncArc ( PCB_ARC aArc)
protectedinherited

Definition at line 1034 of file pns_kicad_iface.cpp.

1035{
1036 auto arc = std::make_unique<PNS::ARC>(
1037 SHAPE_ARC( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), aArc->GetWidth() ),
1038 aArc->GetNetCode() );
1039
1040 arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
1041 arc->SetParent( aArc );
1042
1043 if( aArc->IsLocked() )
1044 arc->Mark( PNS::MK_LOCKED );
1045
1046 return arc;
1047}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:167
virtual bool IsLocked() const
Definition: board_item.cpp:65
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
const VECTOR2I & GetMid() const
Definition: pcb_track.h:274
int GetWidth() const
Definition: pcb_track.h:105
const VECTOR2I & GetStart() const
Definition: pcb_track.h:111
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:108
@ MK_LOCKED
Definition: pns_item.h:43

References PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_ARC::GetMid(), BOARD_CONNECTED_ITEM::GetNetCode(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), BOARD_ITEM::IsLocked(), and PNS::MK_LOCKED.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncGraphicalItem()

bool PNS_KICAD_IFACE_BASE::syncGraphicalItem ( PNS::NODE aWorld,
PCB_SHAPE aItem 
)
protectedinherited

Definition at line 1185 of file pns_kicad_iface.cpp.

1186{
1187 if( aItem->GetLayer() == Edge_Cuts
1188 || aItem->GetLayer() == Margin
1189 || IsCopperLayer( aItem->GetLayer() ) )
1190 {
1191 std::vector<SHAPE*> shapes = aItem->MakeEffectiveShapes();
1192
1193 for( SHAPE* shape : shapes )
1194 {
1195 std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1196
1197 if( aItem->GetLayer() == Edge_Cuts || aItem->GetLayer() == Margin )
1198 solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
1199 else
1200 solid->SetLayer( aItem->GetLayer() );
1201
1202 if( aItem->GetLayer() == Edge_Cuts )
1203 {
1204 switch( shape->Type() )
1205 {
1206 case SH_SEGMENT: static_cast<SHAPE_SEGMENT*>( shape )->SetWidth( 0 ); break;
1207 case SH_ARC: static_cast<SHAPE_ARC*>( shape )->SetWidth( 0 ); break;
1208 case SH_LINE_CHAIN: static_cast<SHAPE_LINE_CHAIN*>( shape )->SetWidth( 0 ); break;
1209 default: /* remaining shapes don't have width */ break;
1210 }
1211 }
1212
1213 solid->SetNet( -1 );
1214 solid->SetParent( aItem );
1215 solid->SetShape( shape ); // takes ownership
1216
1217 if( shapes.size() > 1 )
1218 solid->SetIsCompoundShapePrimitive();
1219
1220 solid->SetRoutable( false );
1221
1222 aWorld->Add( std::move( solid ) );
1223 }
1224
1225 return true;
1226 }
1227
1228 return false;
1229}
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:285
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:656
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
Definition: shape.h:123
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:823
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_Cu
Definition: layer_ids.h:95
@ Margin
Definition: layer_ids.h:114
@ F_Cu
Definition: layer_ids.h:64
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
@ SH_SEGMENT
line segment
Definition: shape.h:45
@ SH_ARC
circular arc
Definition: shape.h:51
@ SH_LINE_CHAIN
line chain (polyline)
Definition: shape.h:46

References PNS::NODE::Add(), B_Cu, Edge_Cuts, F_Cu, BOARD_ITEM::GetLayer(), IsCopperLayer(), EDA_SHAPE::MakeEffectiveShapes(), Margin, PCAD2KICAD::SetWidth(), SH_ARC, SH_LINE_CHAIN, and SH_SEGMENT.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncPad()

std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE_BASE::syncPad ( PAD aPad)
protectedinherited

Definition at line 919 of file pns_kicad_iface.cpp.

920{
921 LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
922
923 // ignore non-copper pads except for those with holes
924 if( ( aPad->GetLayerSet() & LSET::AllCuMask() ).none() && aPad->GetDrillSize().x == 0 )
925 return nullptr;
926
927 switch( aPad->GetAttribute() )
928 {
929 case PAD_ATTRIB::PTH:
930 case PAD_ATTRIB::NPTH:
931 break;
932
933 case PAD_ATTRIB::CONN:
934 case PAD_ATTRIB::SMD:
935 {
936 LSET lmsk = aPad->GetLayerSet();
937 bool is_copper = false;
938
939 for( int i = 0; i < MAX_CU_LAYERS; i++ )
940 {
941 if( lmsk[i] )
942 {
943 is_copper = true;
944
945 if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
946 layers = LAYER_RANGE( i );
947
948 break;
949 }
950 }
951
952 if( !is_copper )
953 return nullptr;
954
955 break;
956 }
957
958 default:
959 wxLogTrace( wxT( "PNS" ), wxT( "unsupported pad type 0x%x" ), aPad->GetAttribute() );
960 return nullptr;
961 }
962
963 std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
964
965 if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
966 solid->SetRoutable( false );
967
968 solid->SetLayers( layers );
969 solid->SetNet( aPad->GetNetCode() );
970 solid->SetParent( aPad );
971 solid->SetPadToDie( aPad->GetPadToDieLength() );
972 solid->SetOrientation( aPad->GetOrientation() );
973
974 if( aPad->IsFreePad() )
975 solid->SetIsFreePad();
976
977 VECTOR2I wx_c = aPad->ShapePos();
978 VECTOR2I offset = aPad->GetOffset();
979
980 VECTOR2I c( wx_c.x, wx_c.y );
981
982 RotatePoint( offset, aPad->GetOrientation() );
983
984 solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
985 solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
986
987 if( aPad->GetDrillSize().x > 0 )
988 {
989 SHAPE_SEGMENT* slot = (SHAPE_SEGMENT*) aPad->GetEffectiveHoleShape()->Clone();
990
991 if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
992 {
994 slot->SetWidth( slot->GetWidth() + bds.GetHolePlatingThickness() * 2 );
995 }
996
997 solid->SetHole( slot );
998 }
999
1000 std::shared_ptr<SHAPE> shape = aPad->GetEffectiveShape();
1001
1002 if( shape->HasIndexableSubshapes() && shape->GetIndexableSubshapeCount() == 1 )
1003 {
1004 std::vector<const SHAPE*> subshapes;
1005 shape->GetIndexableSubshapes( subshapes );
1006
1007 solid->SetShape( subshapes[0]->Clone() );
1008 }
1009 else
1010 {
1011 solid->SetShape( shape->Clone() );
1012 }
1013
1014 return solid;
1015}
int GetHolePlatingThickness() const
Pad & via drills are finish size.
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:391
const VECTOR2I & GetDrillSize() const
Definition: pad.h:261
PAD_ATTRIB GetAttribute() const
Definition: pad.h:394
const VECTOR2I & GetOffset() const
Definition: pad.h:268
VECTOR2I ShapePos() const
Definition: pad.cpp:748
bool IsFreePad() const
Definition: pad.cpp:167
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:364
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:347
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:384
int GetPadToDieLength() const
Definition: pad.h:407
int GetWidth() const
void SetWidth(int aWidth)
#define MAX_CU_LAYERS
Definition: layer_ids.h:140
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:277
@ NPTH
like PAD_PTH, but not plated
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ CONN
Like smd, does not appear on the solder paste layer (default)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References LSET::AllCuMask(), PNS::Clone(), CONN, PAD::GetAttribute(), BOARD::GetDesignSettings(), PAD::GetDrillSize(), PAD::GetEffectiveHoleShape(), PAD::GetEffectiveShape(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), PAD::GetLayerSet(), BOARD_CONNECTED_ITEM::GetNetCode(), PAD::GetOffset(), PAD::GetOrientation(), PAD::GetPadToDieLength(), SHAPE_SEGMENT::GetWidth(), PAD::IsFreePad(), PNS_KICAD_IFACE_BASE::m_board, MAX_CU_LAYERS, NPTH, PTH, RotatePoint(), SHAPE_SEGMENT::SetWidth(), PAD::ShapePos(), SMD, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncTextItem()

bool PNS_KICAD_IFACE_BASE::syncTextItem ( PNS::NODE aWorld,
EDA_TEXT aText,
PCB_LAYER_ID  aLayer 
)
protectedinherited

Definition at line 1146 of file pns_kicad_iface.cpp.

1147{
1148 if( !IsCopperLayer( aLayer ) )
1149 return false;
1150
1151 std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1152
1153 solid->SetLayer( aLayer );
1154 solid->SetNet( -1 );
1155 solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
1156 solid->SetShape( aText->GetEffectiveTextShape()->Clone() );
1157 solid->SetRoutable( false );
1158
1159 aWorld->Add( std::move( solid ) );
1160
1161 return true;
1162
1163 /* A coarser (but faster) method:
1164 *
1165 SHAPE_POLY_SET outline;
1166 SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
1167
1168 aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
1169
1170 for( auto iter = outline.CIterate( 0 ); iter; iter++ )
1171 shape->Append( *iter );
1172
1173 solid->SetShape( shape );
1174
1175 solid->SetLayer( aLayer );
1176 solid->SetNet( -1 );
1177 solid->SetParent( nullptr );
1178 solid->SetRoutable( false );
1179 aWorld->Add( std::move( solid ) );
1180 return true;
1181 */
1182}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
Definition: eda_text.cpp:847

References PNS::NODE::Add(), EDA_TEXT::GetEffectiveTextShape(), and IsCopperLayer().

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncTrack()

std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE_BASE::syncTrack ( PCB_TRACK aTrack)
protectedinherited

Definition at line 1018 of file pns_kicad_iface.cpp.

1019{
1020 auto segment = std::make_unique<PNS::SEGMENT>( SEG( aTrack->GetStart(), aTrack->GetEnd() ),
1021 aTrack->GetNetCode() );
1022
1023 segment->SetWidth( aTrack->GetWidth() );
1024 segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
1025 segment->SetParent( aTrack );
1026
1027 if( aTrack->IsLocked() )
1028 segment->Mark( PNS::MK_LOCKED );
1029
1030 return segment;
1031}
Definition: seg.h:42

References PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), BOARD_ITEM::IsLocked(), and PNS::MK_LOCKED.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncVia()

std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE_BASE::syncVia ( PCB_VIA aVia)
protectedinherited

Definition at line 1050 of file pns_kicad_iface.cpp.

1051{
1052 PCB_LAYER_ID top, bottom;
1053 aVia->LayerPair( &top, &bottom );
1054
1055 auto via = std::make_unique<PNS::VIA>( aVia->GetPosition(),
1056 LAYER_RANGE( aVia->TopLayer(), aVia->BottomLayer() ),
1057 aVia->GetWidth(),
1058 aVia->GetDrillValue(),
1059 aVia->GetNetCode(),
1060 aVia->GetViaType() );
1061
1062 via->SetParent( aVia );
1063
1064 if( aVia->IsLocked() )
1065 via->Mark( PNS::MK_LOCKED );
1066
1067 via->SetIsFree( aVia->GetIsFree() );
1068
1070 via->SetHole( SHAPE_CIRCLE( aVia->GetPosition(),
1071 aVia->GetDrillValue() / 2 + bds.GetHolePlatingThickness() ) );
1072
1073 return via;
1074}
bool GetIsFree() const
Checks if the via is a free via (as opposed to one created on a track by the router).
Definition: pcb_track.h:492
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:563
VECTOR2I GetPosition() const override
Definition: pcb_track.h:401
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:557
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:185
VIATYPE GetViaType() const
Definition: pcb_track.h:353
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
Definition: pcb_track.cpp:535

References PCB_VIA::BottomLayer(), BOARD::GetDesignSettings(), PCB_VIA::GetDrillValue(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), PCB_VIA::GetIsFree(), BOARD_CONNECTED_ITEM::GetNetCode(), PCB_VIA::GetPosition(), PCB_VIA::GetViaType(), PCB_TRACK::GetWidth(), BOARD_ITEM::IsLocked(), PCB_VIA::LayerPair(), PNS_KICAD_IFACE_BASE::m_board, PNS::MK_LOCKED, PCB_VIA::TopLayer(), and via.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ SyncWorld()

void PNS_KICAD_IFACE_BASE::SyncWorld ( PNS::NODE aWorld)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 1318 of file pns_kicad_iface.cpp.

1319{
1320 if( !m_board )
1321 {
1322 wxLogTrace( wxT( "PNS" ), wxT( "No board attached, aborting sync." ) );
1323 return;
1324 }
1325
1326 int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1327
1328 m_world = aWorld;
1329
1330 for( BOARD_ITEM* gitem : m_board->Drawings() )
1331 {
1332 if ( gitem->Type() == PCB_SHAPE_T || gitem->Type() == PCB_TEXTBOX_T )
1333 {
1334 syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( gitem ) );
1335 }
1336 else if( gitem->Type() == PCB_TEXT_T )
1337 {
1338 syncTextItem( aWorld, static_cast<PCB_TEXT*>( gitem ), gitem->GetLayer() );
1339 }
1340 }
1341
1342 SHAPE_POLY_SET buffer;
1343 SHAPE_POLY_SET* boardOutline = nullptr;
1344
1345 if( m_board->GetBoardPolygonOutlines( buffer ) )
1346 boardOutline = &buffer;
1347
1348 for( ZONE* zone : m_board->Zones() )
1349 {
1350 syncZone( aWorld, zone, boardOutline );
1351 }
1352
1353 for( FOOTPRINT* footprint : m_board->Footprints() )
1354 {
1355 for( PAD* pad : footprint->Pads() )
1356 {
1357 if( std::unique_ptr<PNS::SOLID> solid = syncPad( pad ) )
1358 aWorld->Add( std::move( solid ) );
1359
1360 worstClearance = std::max( worstClearance, pad->GetLocalClearance() );
1361
1362 if( pad->GetProperty() == PAD_PROP::CASTELLATED )
1363 {
1364 std::unique_ptr<SHAPE> hole;
1365 hole.reset( pad->GetEffectiveHoleShape()->Clone() );
1366 aWorld->AddEdgeExclusion( std::move( hole ) );
1367 }
1368 }
1369
1370 syncTextItem( aWorld, &footprint->Reference(), footprint->Reference().GetLayer() );
1371 syncTextItem( aWorld, &footprint->Value(), footprint->Value().GetLayer() );
1372
1373 for( FP_ZONE* zone : footprint->Zones() )
1374 syncZone( aWorld, zone, boardOutline );
1375
1376 for( BOARD_ITEM* mgitem : footprint->GraphicalItems() )
1377 {
1378 if( mgitem->Type() == PCB_FP_SHAPE_T || mgitem->Type() == PCB_FP_TEXTBOX_T )
1379 {
1380 syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( mgitem ) );
1381 }
1382 else if( mgitem->Type() == PCB_FP_TEXT_T )
1383 {
1384 syncTextItem( aWorld, static_cast<FP_TEXT*>( mgitem ), mgitem->GetLayer() );
1385 }
1386 }
1387 }
1388
1389 for( PCB_TRACK* t : m_board->Tracks() )
1390 {
1391 KICAD_T type = t->Type();
1392
1393 if( type == PCB_TRACE_T )
1394 {
1395 if( auto segment = syncTrack( t ) )
1396 aWorld->Add( std::move( segment ) );
1397 }
1398 else if( type == PCB_ARC_T )
1399 {
1400 if( auto arc = syncArc( static_cast<PCB_ARC*>( t ) ) )
1401 aWorld->Add( std::move( arc ) );
1402 }
1403 else if( type == PCB_VIA_T )
1404 {
1405 if( auto via = syncVia( static_cast<PCB_VIA*>( t ) ) )
1406 aWorld->Add( std::move( via ) );
1407 }
1408 }
1409
1410 // NB: if this were ever to become a long-lived object we would need to dirty its
1411 // clearance cache here....
1412 delete m_ruleResolver;
1414
1416 aWorld->SetMaxClearance( worstClearance + m_ruleResolver->ClearanceEpsilon() );
1417}
ZONES & Zones()
Definition: board.h:313
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition: board.cpp:1892
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
DRAWINGS & Drawings()
Definition: board.h:310
A specialization of ZONE for use in footprints.
Definition: zone.h:897
void SetMaxClearance(int aClearance)
Assign a clearance resolution function object.
Definition: pns_node.h:185
void SetRuleResolver(RULE_RESOLVER *aFunc)
Definition: pns_node.h:191
void AddEdgeExclusion(std::unique_ptr< SHAPE > aShape)
Definition: pns_node.cpp:720
bool syncGraphicalItem(PNS::NODE *aWorld, PCB_SHAPE *aItem)
bool syncZone(PNS::NODE *aWorld, ZONE *aZone, SHAPE_POLY_SET *aBoardOutline)
std::unique_ptr< PNS::ARC > syncArc(PCB_ARC *aArc)
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
std::unique_ptr< PNS::SOLID > syncPad(PAD *aPad)
std::unique_ptr< PNS::SEGMENT > syncTrack(PCB_TRACK *aTrack)
std::unique_ptr< PNS::VIA > syncVia(PCB_VIA *aVia)
Represent a set of closed polygons.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
@ CASTELLATED
a pad with a castellated through hole
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101

References PNS::NODE::Add(), PNS::NODE::AddEdgeExclusion(), CASTELLATED, PNS_PCBNEW_RULE_RESOLVER::ClearanceEpsilon(), BOARD::Drawings(), BOARD::Footprints(), BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue(), BOARD::GetBoardPolygonOutlines(), BOARD::GetDesignSettings(), BOARD_ITEM::GetLayer(), PNS_KICAD_IFACE_BASE::m_board, PNS_KICAD_IFACE_BASE::m_ruleResolver, PNS_KICAD_IFACE_BASE::m_world, pad, PCB_ARC_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PNS::NODE::SetMaxClearance(), PNS::NODE::SetRuleResolver(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncPad(), PNS_KICAD_IFACE_BASE::syncTextItem(), PNS_KICAD_IFACE_BASE::syncTrack(), PNS_KICAD_IFACE_BASE::syncVia(), PNS_KICAD_IFACE_BASE::syncZone(), BOARD::Tracks(), via, and BOARD::Zones().

◆ syncZone()

bool PNS_KICAD_IFACE_BASE::syncZone ( PNS::NODE aWorld,
ZONE aZone,
SHAPE_POLY_SET aBoardOutline 
)
protectedinherited

Definition at line 1077 of file pns_kicad_iface.cpp.

1078{
1079 SHAPE_POLY_SET* poly;
1080
1081 if( !aZone->GetIsRuleArea() && aZone->GetZoneName().IsEmpty() )
1082 return false;
1083
1084 // TODO handle aZone->GetDoNotAllowVias()
1085 // TODO handle rules which disallow tracks & vias
1086 if( !aZone->GetIsRuleArea() || !aZone->GetDoNotAllowTracks() )
1087 return false;
1088
1089 LSET layers = aZone->GetLayerSet();
1090
1091 poly = aZone->Outline();
1092 poly->CacheTriangulation( false );
1093
1094 if( !poly->IsTriangulationUpToDate() )
1095 {
1096 UNITS_PROVIDER unitsProvider( pcbIUScale, GetUnits() );
1097 KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ),
1098 aZone->GetSelectMenuText( &unitsProvider ) ),
1100 dlg.ShowDetailedText( wxString::Format( _( "This zone cannot be handled by the router.\n"
1101 "Please verify it is not a self-intersecting "
1102 "polygon." ) ) );
1103 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1104 dlg.ShowModal();
1105
1106 return false;
1107 }
1108
1109 for( int layer = F_Cu; layer <= B_Cu; layer++ )
1110 {
1111 if( !layers[ layer ] )
1112 continue;
1113
1114 for( int outline = 0; outline < poly->OutlineCount(); outline++ )
1115 {
1116 const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly->TriangulatedPolygon( outline );
1117
1118 for( size_t i = 0; i < tri->GetTriangleCount(); i++)
1119 {
1120 VECTOR2I a, b, c;
1121 tri->GetTriangle( i, a, b, c );
1122 SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
1123
1124 triShape->Append( a );
1125 triShape->Append( b );
1126 triShape->Append( c );
1127
1128 std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1129
1130 solid->SetLayer( layer );
1131 solid->SetNet( -1 );
1132 solid->SetParent( aZone );
1133 solid->SetShape( triShape );
1134 solid->SetIsCompoundShapePrimitive();
1135 solid->SetRoutable( false );
1136
1137 aWorld->Add( std::move( solid ) );
1138 }
1139 }
1140 }
1141
1142 return true;
1143}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:46
@ KD_WARNING
Definition: confirm.h:49
virtual EDA_UNITS GetUnits() const
void GetTriangle(int index, VECTOR2I &a, VECTOR2I &b, VECTOR2I &c) const
bool IsTriangulationUpToDate() const
void CacheTriangulation(bool aPartition=true)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42
void Append(int aX, int aY)
Append a new point at the end of the polygon.
Definition: shape_simple.h:135
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:691
bool GetDoNotAllowTracks() const
Definition: zone.h:694
SHAPE_POLY_SET * Outline()
Definition: zone.h:305
wxString GetZoneName() const
Definition: zone.h:117
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:115
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: zone.cpp:716
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References _, PNS::NODE::Add(), SHAPE_SIMPLE::Append(), B_Cu, SHAPE_POLY_SET::CacheTriangulation(), KIDIALOG::DoNotShowCheckbox(), F_Cu, Format(), ZONE::GetDoNotAllowTracks(), ZONE::GetIsRuleArea(), ZONE::GetLayerSet(), ZONE::GetSelectMenuText(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::GetTriangle(), SHAPE_POLY_SET::TRIANGULATED_POLYGON::GetTriangleCount(), PNS_KICAD_IFACE_BASE::GetUnits(), ZONE::GetZoneName(), SHAPE_POLY_SET::IsTriangulationUpToDate(), KIDIALOG::KD_WARNING, ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), pcbIUScale, KIDIALOG::ShowModal(), and SHAPE_POLY_SET::TriangulatedPolygon().

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ UpdateItem()

void PNS_KICAD_IFACE_BASE::UpdateItem ( PNS::ITEM aItem)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 1536 of file pns_kicad_iface.cpp.

1537{
1538}

◆ UpdateNet()

void PNS_KICAD_IFACE_BASE::UpdateNet ( int  aNetCode)
inlineoverridevirtualinherited

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 71 of file pns_kicad_iface.h.

71{}

Member Data Documentation

◆ m_board

◆ m_debugDecorator

◆ m_ruleResolver

◆ m_startLayer

int PNS_KICAD_IFACE_BASE::m_startLayer
protectedinherited

◆ m_viewTracker

PNS_LOG_VIEW_TRACKER* PNS_LOG_PLAYER_KICAD_IFACE::m_viewTracker
private

Definition at line 74 of file pns_log_player.h.

Referenced by DisplayItem(), and HideItem().

◆ m_world

PNS::NODE* PNS_KICAD_IFACE_BASE::m_world
protectedinherited

The documentation for this class was generated from the following files: