KiCad PCB EDA Suite
PNS_KICAD_IFACE Class Reference

#include <pns_kicad_iface.h>

Inheritance diagram for PNS_KICAD_IFACE:
PNS_KICAD_IFACE_BASE PNS::ROUTER_IFACE

Classes

struct  OFFSET
 

Public Member Functions

 PNS_KICAD_IFACE ()
 
 ~PNS_KICAD_IFACE ()
 
void SetHostTool (PCB_TOOL_BASE *aTool)
 
void SetDisplayOptions (const PCB_DISPLAY_OPTIONS *aDispOptions)
 
void SetView (KIGFX::VIEW *aView)
 
void EraseView () override
 
bool IsAnyLayerVisible (const LAYER_RANGE &aLayer) const override
 
bool IsItemVisible (const PNS::ITEM *aItem) const override
 
bool IsFlashedOnLayer (const PNS::ITEM *aItem, int aLayer) const override
 
void HideItem (PNS::ITEM *aItem) override
 
void DisplayItem (const PNS::ITEM *aItem, int aClearance, bool aEdit=false) override
 
void DisplayRatline (const SHAPE_LINE_CHAIN &aRatline, int aColor=-1) override
 
void Commit () override
 
void AddItem (PNS::ITEM *aItem) override
 
void UpdateItem (PNS::ITEM *aItem) override
 
void RemoveItem (PNS::ITEM *aItem) override
 
void UpdateNet (int aNetCode) override
 
void SetBoard (BOARD *aBoard)
 
void SyncWorld (PNS::NODE *aWorld) override
 
bool ImportSizes (PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
 
int StackupHeight (int aFirstLayer, int aSecondLayer) const override
 
void SetDebugDecorator (PNS::DEBUG_DECORATOR *aDec)
 
virtual PNS::NODEGetWorld () const override
 
BOARDGetBoard () const
 
PNS::RULE_RESOLVERGetRuleResolver () override
 
PNS::DEBUG_DECORATORGetDebugDecorator () override
 

Protected Member Functions

std::unique_ptr< PNS::SOLIDsyncPad (PAD *aPad)
 
std::unique_ptr< PNS::SEGMENTsyncTrack (TRACK *aTrack)
 
std::unique_ptr< PNS::ARCsyncArc (ARC *aArc)
 
std::unique_ptr< PNS::VIAsyncVia (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
 

Private Attributes

std::map< PAD *, OFFSETm_fpOffsets
 
KIGFX::VIEWm_view
 
KIGFX::VIEW_GROUPm_previewItems
 
std::unordered_set< BOARD_ITEM * > m_hiddenItems
 
PCB_TOOL_BASEm_tool
 
std::unique_ptr< BOARD_COMMITm_commit
 
const PCB_DISPLAY_OPTIONSm_dispOptions
 

Detailed Description

Definition at line 106 of file pns_kicad_iface.h.

Constructor & Destructor Documentation

◆ PNS_KICAD_IFACE()

PNS_KICAD_IFACE::PNS_KICAD_IFACE ( )

Definition at line 829 of file pns_kicad_iface.cpp.

830 {
831  m_tool = nullptr;
832  m_view = nullptr;
833  m_previewItems = nullptr;
834  m_dispOptions = nullptr;
835 }
KIGFX::VIEW_GROUP * m_previewItems
const PCB_DISPLAY_OPTIONS * m_dispOptions
KIGFX::VIEW * m_view
PCB_TOOL_BASE * m_tool

References m_dispOptions, m_previewItems, m_tool, and m_view.

◆ ~PNS_KICAD_IFACE()

PNS_KICAD_IFACE::~PNS_KICAD_IFACE ( )

Definition at line 843 of file pns_kicad_iface.cpp.

844 {
845  delete m_ruleResolver;
846  delete m_debugDecorator;
847 
848  if( m_previewItems )
849  {
851  delete m_previewItems;
852  }
853 }
PNS::DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:198
KIGFX::VIEW_GROUP * m_previewItems
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References KIGFX::VIEW_GROUP::FreeItems(), PNS_KICAD_IFACE_BASE::m_debugDecorator, m_previewItems, and PNS_KICAD_IFACE_BASE::m_ruleResolver.

Member Function Documentation

◆ AddItem()

void PNS_KICAD_IFACE::AddItem ( PNS::ITEM aItem)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1556 of file pns_kicad_iface.cpp.

1557 {
1558  BOARD_CONNECTED_ITEM* newBI = NULL;
1559 
1560  switch( aItem->Kind() )
1561  {
1562  case PNS::ITEM::ARC_T:
1563  {
1564  auto arc = static_cast<PNS::ARC*>( aItem );
1565  ARC* new_arc = new ARC( m_board, static_cast<const SHAPE_ARC*>( arc->Shape() ) );
1566  new_arc->SetWidth( arc->Width() );
1567  new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
1568  new_arc->SetNetCode( std::max<int>( 0, arc->Net() ) );
1569  newBI = new_arc;
1570  break;
1571  }
1572 
1573  case PNS::ITEM::SEGMENT_T:
1574  {
1575  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1576  TRACK* track = new TRACK( m_board );
1577  const SEG& s = seg->Seg();
1578  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1579  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1580  track->SetWidth( seg->Width() );
1581  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1582  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1583  newBI = track;
1584  break;
1585  }
1586 
1587  case PNS::ITEM::VIA_T:
1588  {
1589  VIA* via_board = new VIA( m_board );
1590  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1591  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1592  via_board->SetWidth( via->Diameter() );
1593  via_board->SetDrill( via->Drill() );
1594  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1595  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1596  via_board->SetIsFree( via->IsFree() );
1597  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1598  ToLAYER_ID( via->Layers().End() ) );
1599  newBI = via_board;
1600  break;
1601  }
1602 
1603  case PNS::ITEM::SOLID_T:
1604  {
1605  PAD* pad = static_cast<PAD*>( aItem->Parent() );
1606  VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1607 
1608  m_fpOffsets[ pad ].p_new = pos;
1609  return;
1610  }
1611 
1612  default:
1613  break;
1614  }
1615 
1616  if( newBI )
1617  {
1618  //newBI->SetLocalRatsnestVisible( m_dispOptions->m_ShowGlobalRatsnest );
1619  aItem->SetParent( newBI );
1620  newBI->ClearFlags();
1621 
1622  m_commit->Add( newBI );
1623  }
1624 }
Definition: track.h:343
void SetPosition(const wxPoint &aPoint) override
Definition: track.h:412
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
void SetEnd(const wxPoint &aEnd)
Definition: track.h:112
int Width() const override
Definition: pns_segment.h:79
void SetParent(BOARD_ITEM *aParent)
Definition: pns_item.h:144
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
BOARD_ITEM * Parent() const
Definition: pns_item.h:145
const SEG & Seg() const
Definition: pns_segment.h:84
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
void SetWidth(int aWidth)
Definition: track.h:109
int Start() const
Definition: pns_layerset.h:82
#define NULL
std::unique_ptr< BOARD_COMMIT > m_commit
int Net() const
Definition: pns_item.h:148
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_layer contains the top layer, the other layer is in m_bottomLayer.
Definition: track.cpp:414
Definition: seg.h:41
Definition: track.h:262
VECTOR2I A
Definition: seg.h:49
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: track.h:474
void SetIsFree(bool aFree=true)
Definition: track.h:503
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:126
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:204
void SetStart(const wxPoint &aStart)
Definition: track.h:115
Definition: pad.h:60
void SetViaType(VIATYPE aViaType)
Definition: track.h:374
std::map< PAD *, OFFSET > m_fpOffsets
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
Definition: track.h:83
VECTOR2I B
Definition: seg.h:50

References SEG::A, ARC, PNS::ITEM::ARC_T, SEG::B, EDA_ITEM::ClearFlags(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), PNS_KICAD_IFACE_BASE::m_board, m_commit, m_fpOffsets, PNS::ITEM::Net(), NULL, pad, PNS::ITEM::Parent(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, VIA::SetDrill(), TRACK::SetEnd(), VIA::SetIsFree(), BOARD_ITEM::SetLayer(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::ITEM::SetParent(), VIA::SetPosition(), TRACK::SetStart(), VIA::SetViaType(), TRACK::SetWidth(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), ToLAYER_ID(), TRACK, VIA, via, PNS::ITEM::VIA_T, PNS::SEGMENT::Width(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Commit()

void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1627 of file pns_kicad_iface.cpp.

1628 {
1629  std::set<FOOTPRINT*> processedMods;
1630 
1631  EraseView();
1632 
1633  for( auto fpOffset : m_fpOffsets )
1634  {
1635  VECTOR2I offset = fpOffset.second.p_new - fpOffset.second.p_old;
1636  FOOTPRINT* footprint = fpOffset.first->GetParent();
1637 
1638  VECTOR2I p_orig = footprint->GetPosition();
1639  VECTOR2I p_new = p_orig + offset;
1640 
1641  if( processedMods.find( footprint ) != processedMods.end() )
1642  continue;
1643 
1644  processedMods.insert( footprint );
1645  m_commit->Modify( footprint );
1646  footprint->SetPosition( wxPoint( p_new.x, p_new.y ) );
1647  }
1648 
1649  m_fpOffsets.clear();
1650 
1651  m_commit->Push( _( "Interactive Router" ) );
1652  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1653 }
std::unique_ptr< BOARD_COMMIT > m_commit
void EraseView() override
#define _(s)
Definition: 3d_actions.cpp:33
PCB_TOOL_BASE * m_tool
wxPoint GetPosition() const override
Definition: footprint.h:182
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1438
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:168
std::map< PAD *, OFFSET > m_fpOffsets

References _, EraseView(), BOARD_ITEM::GetParent(), FOOTPRINT::GetPosition(), m_commit, m_fpOffsets, m_tool, FOOTPRINT::SetPosition(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ DisplayItem()

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1394 of file pns_kicad_iface.cpp.

1395 {
1396  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1397 
1398  if( aClearance >= 0 )
1399  {
1400  pitem->SetClearance( aClearance );
1401 
1403  {
1405  pitem->ShowTrackClearance( false );
1406  pitem->ShowViaClearance( false );
1407  break;
1410  pitem->ShowTrackClearance( true );
1411  pitem->ShowViaClearance( true );
1412  break;
1413 
1415  pitem->ShowTrackClearance( !aEdit );
1416  pitem->ShowViaClearance( !aEdit );
1417  break;
1418 
1420  pitem->ShowTrackClearance( !aEdit );
1421  pitem->ShowViaClearance( false );
1422  break;
1423  }
1424  }
1425 
1426 
1427  m_previewItems->Add( pitem );
1429 }
void SetClearance(int aClearance)
void ShowTrackClearance(bool aEnabled)
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
void ShowViaClearance(bool aEnabled)
KIGFX::VIEW_GROUP * m_previewItems
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
const PCB_DISPLAY_OPTIONS * m_dispOptions
KIGFX::VIEW * m_view
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1503

References KIGFX::VIEW_GROUP::Add(), PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE, m_dispOptions, m_previewItems, PCB_DISPLAY_OPTIONS::m_ShowTrackClearanceMode, m_view, ROUTER_PREVIEW_ITEM::SetClearance(), PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WHILE_ROUTING, PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_ALWAYS, PCB_DISPLAY_OPTIONS::SHOW_TRACK_CLEARANCE_WITH_VIA_WHILE_ROUTING, PCB_DISPLAY_OPTIONS::SHOW_WHILE_ROUTING_OR_DRAGGING, ROUTER_PREVIEW_ITEM::ShowTrackClearance(), ROUTER_PREVIEW_ITEM::ShowViaClearance(), and KIGFX::VIEW::Update().

◆ DisplayRatline()

void PNS_KICAD_IFACE::DisplayRatline ( const SHAPE_LINE_CHAIN aRatline,
int  aColor = -1 
)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1432 of file pns_kicad_iface.cpp.

1433 {
1434  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( nullptr, m_view );
1435  pitem->Line( aRatline, 10000, aColor );
1436  m_previewItems->Add( pitem );
1438 }
void Line(const SHAPE_LINE_CHAIN &aLine, int aWidth=0, int aStyle=0)
KIGFX::VIEW_GROUP * m_previewItems
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
KIGFX::VIEW * m_view
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1503

References KIGFX::VIEW_GROUP::Add(), ROUTER_PREVIEW_ITEM::Line(), m_previewItems, m_view, and KIGFX::VIEW::Update().

◆ EraseView()

void PNS_KICAD_IFACE::EraseView ( )
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1372 of file pns_kicad_iface.cpp.

1373 {
1374  for( auto item : m_hiddenItems )
1375  m_view->SetVisible( item, true );
1376 
1377  m_hiddenItems.clear();
1378 
1379  if( m_previewItems )
1380  {
1383  }
1384 
1385  if( m_debugDecorator )
1387 }
PNS::DEBUG_DECORATOR * m_debugDecorator
std::unordered_set< BOARD_ITEM * > m_hiddenItems
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:198
KIGFX::VIEW_GROUP * m_previewItems
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1449
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1503

References PNS::DEBUG_DECORATOR::Clear(), KIGFX::VIEW_GROUP::FreeItems(), PNS_KICAD_IFACE_BASE::m_debugDecorator, m_hiddenItems, m_previewItems, m_view, KIGFX::VIEW::SetVisible(), and KIGFX::VIEW::Update().

Referenced by Commit().

◆ GetBoard()

BOARD* PNS_KICAD_IFACE_BASE::GetBoard ( ) const
inlineinherited

Definition at line 80 of file pns_kicad_iface.h.

81  {
82  return m_board;
83  }

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 814 of file pns_kicad_iface.cpp.

815 {
816  return m_debugDecorator;
817 }
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 1689 of file pns_kicad_iface.cpp.

1690 {
1691  return m_ruleResolver;
1692 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References PNS_KICAD_IFACE_BASE::m_ruleResolver.

◆ GetWorld()

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

Implements PNS::ROUTER_IFACE.

Definition at line 75 of file pns_kicad_iface.h.

76  {
77  return m_world;
78  };

References PNS_KICAD_IFACE_BASE::m_world.

◆ HideItem()

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1441 of file pns_kicad_iface.cpp.

1442 {
1443  BOARD_ITEM* parent = aItem->Parent();
1444 
1445  if( parent )
1446  {
1447  if( m_view->IsVisible( parent ) )
1448  m_hiddenItems.insert( parent );
1449 
1450  m_view->SetVisible( parent, false );
1451  m_view->Update( parent, KIGFX::APPEARANCE );
1452  }
1453 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
BOARD_ITEM * Parent() const
Definition: pns_item.h:145
Visibility flag has changed.
Definition: view_item.h:52
std::unordered_set< BOARD_ITEM * > m_hiddenItems
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
Definition: view.cpp:1489
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1449
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1503

References KIGFX::APPEARANCE, KIGFX::VIEW::IsVisible(), m_hiddenItems, m_view, PNS::ITEM::Parent(), KIGFX::VIEW::SetVisible(), and KIGFX::VIEW::Update().

◆ ImportSizes()

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

Implements PNS::ROUTER_IFACE.

Definition at line 431 of file pns_kicad_iface.cpp.

432 {
434  PNS::CONSTRAINT constraint;
435 
436  aSizes.SetMinClearance( bds.m_MinClearance );
437 
438  int trackWidth = bds.m_TrackMinWidth;
439  bool found = false;
440 
441  if( bds.m_UseConnectedTrackWidth && aStartItem != nullptr )
442  {
443  found = inheritTrackWidth( aStartItem, &trackWidth );
444  }
445 
446  if( !found && bds.UseNetClassTrack() && aStartItem )
447  {
449  aStartItem->Layer(), &constraint ) )
450  {
451  trackWidth = constraint.m_Value.Opt();
452  found = true; // Note: allowed to override anything, including bds.m_TrackMinWidth
453  }
454  }
455 
456  if( !found )
457  {
458  trackWidth = bds.GetCurrentTrackWidth();
459  }
460 
461  aSizes.SetTrackWidth( trackWidth );
462 
463  int viaDiameter = bds.m_ViasMinSize;
464  int viaDrill = bds.m_MinThroughDrill;
465 
466  if( bds.UseNetClassVia() && aStartItem ) // netclass value
467  {
469  nullptr, aStartItem->Layer(), &constraint ) )
470  {
471  viaDiameter = constraint.m_Value.Opt();
472  }
473 
475  nullptr, aStartItem->Layer(), &constraint ) )
476  {
477  viaDrill = constraint.m_Value.Opt();
478  }
479  }
480  else
481  {
482  viaDiameter = bds.GetCurrentViaSize();
483  viaDrill = bds.GetCurrentViaDrill();
484  }
485 
486  aSizes.SetViaDiameter( viaDiameter );
487  aSizes.SetViaDrill( viaDrill );
488 
489  int diffPairWidth = bds.m_TrackMinWidth;
490  int diffPairGap = bds.m_MinClearance;
491  int diffPairViaGap = bds.m_MinClearance;
492 
493  found = false;
494 
495  // First try to pick up diff pair width from starting track, if enabled
496  if( bds.m_UseConnectedTrackWidth && aStartItem )
497  found = inheritTrackWidth( aStartItem, &diffPairWidth );
498 
499  // Next, pick up gap from netclass, and width also if we didn't get a starting width above
500  if( bds.UseNetClassDiffPair() && aStartItem )
501  {
503  nullptr, aStartItem->Layer(), &constraint ) )
504  {
505  diffPairWidth = constraint.m_Value.Opt();
506  }
507 
509  nullptr, aStartItem->Layer(), &constraint ) )
510  {
511  diffPairGap = constraint.m_Value.Opt();
512  diffPairViaGap = constraint.m_Value.Opt();
513  }
514  }
515  else
516  {
517  diffPairWidth = bds.GetCurrentDiffPairWidth();
518  diffPairGap = bds.GetCurrentDiffPairGap();
519  diffPairViaGap = bds.GetCurrentDiffPairViaGap();
520  }
521 
522  //printf( "DPWidth: %d gap %d\n", diffPairWidth, diffPairGap );
523 
524  aSizes.SetDiffPairWidth( diffPairWidth );
525  aSizes.SetDiffPairGap( diffPairGap );
526  aSizes.SetDiffPairViaGap( diffPairViaGap );
527 
528  int holeToHoleMin = bds.m_HoleToHoleMin;
529  PNS::VIA dummyVia;
530 
532  &dummyVia, UNDEFINED_LAYER, &constraint ) )
533  {
534  holeToHoleMin = constraint.m_Value.Min();
535  }
536 
537  aSizes.SetHoleToHole( holeToHoleMin );
538 
539  aSizes.ClearLayerPairs();
540 
541  return true;
542 }
bool UseNetClassTrack() const
Return true if netclass values should be used to obtain appropriate track width.
virtual int Layer() const
Definition: pns_item.h:154
bool inheritTrackWidth(PNS::ITEM *aItem, int *aInheritedWidth)
bool UseNetClassDiffPair() const
Return true if netclass values should be used to obtain appropriate diff pair dimensions.
T Opt() const
Definition: minoptmax.h:35
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
void SetViaDrill(int aDrill)
T Min() const
Definition: minoptmax.h:33
void SetTrackWidth(int aWidth)
void SetDiffPairViaGap(int aGap)
void SetMinClearance(int aClearance)
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
void SetHoleToHole(int aHoleToHole)
void SetDiffPairGap(int aGap)
virtual bool QueryConstraint(PNS::CONSTRAINT_TYPE aType, const PNS::ITEM *aItemA, const PNS::ITEM *aItemB, int aLayer, PNS::CONSTRAINT *aConstraint) override
MINOPTMAX< int > m_Value
Definition: pns_node.h:70
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
void SetViaDiameter(int aDiameter)
void SetDiffPairWidth(int aWidth)
Container for design settings for a BOARD object.

References PNS::SIZES_SETTINGS::ClearLayerPairs(), 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_KICAD_IFACE_BASE::m_ruleResolver, 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::SetDiffPairWidth(), PNS::SIZES_SETTINGS::SetHoleToHole(), PNS::SIZES_SETTINGS::SetMinClearance(), PNS::SIZES_SETTINGS::SetTrackWidth(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), 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 368 of file pns_kicad_iface.cpp.

369 {
370  VECTOR2I p;
371 
372  assert( aItem->Owner() != NULL );
373 
374  auto tryGetTrackWidth =
375  []( PNS::ITEM* aPnsItem ) -> int
376  {
377  switch( aPnsItem->Kind() )
378  {
379  case PNS::ITEM::SEGMENT_T: return static_cast<PNS::SEGMENT*>( aPnsItem )->Width();
380  case PNS::ITEM::ARC_T: return static_cast<PNS::ARC*>( aPnsItem )->Width();
381  default: return -1;
382  }
383  };
384 
385  int itemTrackWidth = tryGetTrackWidth( aItem );
386 
387  if( itemTrackWidth > 0 )
388  {
389  *aInheritedWidth = itemTrackWidth;
390  return true;
391  }
392 
393  switch( aItem->Kind() )
394  {
395  case PNS::ITEM::VIA_T:
396  p = static_cast<PNS::VIA*>( aItem )->Pos();
397  break;
398 
399  case PNS::ITEM::SOLID_T:
400  p = static_cast<PNS::SOLID*>( aItem )->Pos();
401  break;
402 
403  default:
404  return false;
405  }
406 
407  PNS::JOINT* jt = static_cast<PNS::NODE*>( aItem->Owner() )->FindJoint( p, aItem );
408 
409  assert( jt != NULL );
410 
411  int mval = INT_MAX;
412 
413  PNS::ITEM_SET linkedSegs = jt->Links();
415 
416  for( PNS::ITEM* item : linkedSegs.Items() )
417  {
418  int w = tryGetTrackWidth( item );
419  assert( w > 0 );
420  mval = std::min( w, mval );
421  }
422 
423  if( mval == INT_MAX )
424  return false;
425 
426  *aInheritedWidth = mval;
427  return true;
428 }
Base class for PNS router board items.
Definition: pns_item.h:55
ENTRIES & Items()
Definition: pns_itemset.h:138
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:68
ITEM_SET & ExcludeItem(const ITEM *aItem)
ITEM_SET & Links()
Definition: pns_joint.h:205
Represents a 2D point on a given set of layers and belonging to a certain net, that links together a ...
Definition: pns_joint.h:42
#define NULL
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:126
NODE * Owner() const
Return the owner of this item, or NULL if there's none.
Definition: pns_item.h:167

References PNS::ITEM::ARC_T, PNS::ITEM_SET::ExcludeItem(), PNS::ITEM_SET::FilterKinds(), PNS::ITEM_SET::Items(), PNS::ITEM::Kind(), PNS::JOINT::Links(), NULL, 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::IsAnyLayerVisible ( const LAYER_RANGE aLayer) const
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1200 of file pns_kicad_iface.cpp.

1201 {
1202  if( !m_view )
1203  return false;
1204 
1205  for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
1206  if( m_view->IsLayerVisible( i ) )
1207  return true;
1208 
1209  return false;
1210 }
int Start() const
Definition: pns_layerset.h:82
int End() const
Definition: pns_layerset.h:87
KIGFX::VIEW * m_view
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404

References LAYER_RANGE::End(), KIGFX::VIEW::IsLayerVisible(), m_view, and LAYER_RANGE::Start().

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

◆ IsFlashedOnLayer()

bool PNS_KICAD_IFACE::IsFlashedOnLayer ( const PNS::ITEM aItem,
int  aLayer 
) const
overridevirtual

Default is all layers

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1213 of file pns_kicad_iface.cpp.

1214 {
1216  if( aLayer < 0 )
1217  return true;
1218 
1219  if( aItem->Parent() )
1220  {
1221  switch( aItem->Parent()->Type() )
1222  {
1223  case PCB_VIA_T:
1224  {
1225  const VIA* via = static_cast<const VIA*>( aItem->Parent() );
1226 
1227  return via->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
1228  }
1229 
1230  case PCB_PAD_T:
1231  {
1232  const PAD* pad = static_cast<const PAD*>( aItem->Parent() );
1233 
1234  return pad->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
1235  }
1236 
1237  default:
1238  break;
1239  }
1240  }
1241 
1242  return aItem->Layers().Overlaps( aLayer );
1243 }
Definition: track.h:343
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
BOARD_ITEM * Parent() const
Definition: pns_item.h:145
class PAD, a pad in a footprint
Definition: typeinfo.h:89
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: pad.h:60
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163

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::IsItemVisible ( const PNS::ITEM aItem) const
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1246 of file pns_kicad_iface.cpp.

1247 {
1248  // by default, all items are visible (new ones created by the router have parent == NULL
1249  // as they have not been committed yet to the BOARD)
1250  if( !m_view || !aItem->Parent() )
1251  return true;
1252 
1253  BOARD_ITEM* item = aItem->Parent();
1254  bool isOnVisibleLayer = true;
1255  RENDER_SETTINGS* settings = m_view->GetPainter()->GetSettings();
1256 
1257  if( settings->GetHighContrast() )
1258  isOnVisibleLayer = item->IsOnLayer( settings->GetPrimaryHighContrastLayer() );
1259 
1260  if( m_view->IsVisible( item ) && isOnVisibleLayer
1261  && item->ViewGetLOD( item->GetLayer(), m_view ) < m_view->GetScale() )
1262  {
1263  return true;
1264  }
1265 
1266  // Items hidden in the router are not hidden on the board
1267  if( m_hiddenItems.find( item ) != m_hiddenItems.end() )
1268  return true;
1269 
1270  return false;
1271 }
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
BOARD_ITEM * Parent() const
Definition: pns_item.h:145
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
std::unordered_set< BOARD_ITEM * > m_hiddenItems
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:231
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
Definition: view.cpp:1489
bool GetHighContrast() const
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
KIGFX::VIEW * m_view
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
double GetScale() const
Definition: view.h:263
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:137

References KIGFX::RENDER_SETTINGS::GetHighContrast(), BOARD_ITEM::GetLayer(), KIGFX::VIEW::GetPainter(), KIGFX::RENDER_SETTINGS::GetPrimaryHighContrastLayer(), KIGFX::VIEW::GetScale(), KIGFX::PAINTER::GetSettings(), BOARD_ITEM::IsOnLayer(), KIGFX::VIEW::IsVisible(), m_hiddenItems, m_view, PNS::ITEM::Parent(), and KIGFX::VIEW_ITEM::ViewGetLOD().

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

◆ RemoveItem()

void PNS_KICAD_IFACE::RemoveItem ( PNS::ITEM aItem)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1462 of file pns_kicad_iface.cpp.

1463 {
1464  BOARD_ITEM* parent = aItem->Parent();
1465 
1466  if( aItem->OfKind( PNS::ITEM::SOLID_T ) )
1467  {
1468  PAD* pad = static_cast<PAD*>( parent );
1469  VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1470 
1471  m_fpOffsets[ pad ].p_old = pos;
1472  return;
1473  }
1474 
1475  if( parent )
1476  {
1477  m_commit->Remove( parent );
1478  }
1479 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
BOARD_ITEM * Parent() const
Definition: pns_item.h:145
std::unique_ptr< BOARD_COMMIT > m_commit
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:134
Definition: pad.h:60
std::map< PAD *, OFFSET > m_fpOffsets

References m_commit, m_fpOffsets, PNS::ITEM::OfKind(), pad, PNS::ITEM::Parent(), and PNS::ITEM::SOLID_T.

◆ SetBoard()

void PNS_KICAD_IFACE_BASE::SetBoard ( BOARD aBoard)
inherited

Definition at line 1193 of file pns_kicad_iface.cpp.

1194 {
1195  m_board = aBoard;
1196  wxLogTrace( "PNS", "m_board = %p", m_board );
1197 }

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 1389 of file pns_kicad_iface.cpp.

1390 {
1391  m_debugDecorator = aDec;
1392 }
PNS::DEBUG_DECORATOR * m_debugDecorator

References PNS_KICAD_IFACE_BASE::m_debugDecorator.

◆ SetDisplayOptions()

void PNS_KICAD_IFACE::SetDisplayOptions ( const PCB_DISPLAY_OPTIONS aDispOptions)

Definition at line 1701 of file pns_kicad_iface.cpp.

1702 {
1703  m_dispOptions = aDispOptions;
1704 }
const PCB_DISPLAY_OPTIONS * m_dispOptions

References m_dispOptions.

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

◆ SetHostTool()

void PNS_KICAD_IFACE::SetHostTool ( PCB_TOOL_BASE aTool)

Definition at line 1695 of file pns_kicad_iface.cpp.

1696 {
1697  m_tool = aTool;
1698  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1699 }
std::unique_ptr< BOARD_COMMIT > m_commit
PCB_TOOL_BASE * m_tool

References m_commit, and m_tool.

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

◆ SetView()

void PNS_KICAD_IFACE::SetView ( KIGFX::VIEW aView)

Definition at line 1656 of file pns_kicad_iface.cpp.

1657 {
1658  wxLogTrace( "PNS", "SetView %p", aView );
1659 
1660  if( m_previewItems )
1661  {
1663  delete m_previewItems;
1664  }
1665 
1666  m_view = aView;
1669 
1670  if(m_view)
1672 
1673  delete m_debugDecorator;
1674 
1675  auto dec = new PNS_PCBNEW_DEBUG_DECORATOR();
1676  m_debugDecorator = dec;
1677 
1678  if( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
1679  dec->SetView( m_view );
1680 }
PNS::DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:198
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:46
KIGFX::VIEW_GROUP * m_previewItems
virtual void SetLayer(int aLayer)
Set layer used to draw the group.
Definition: view_group.h:108
KIGFX::VIEW * m_view
currently selected items overlay
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:322

References KIGFX::VIEW::Add(), KIGFX::VIEW_GROUP::FreeItems(), ADVANCED_CFG::GetCfg(), LAYER_SELECT_OVERLAY, PNS_KICAD_IFACE_BASE::m_debugDecorator, m_previewItems, m_view, and KIGFX::VIEW_GROUP::SetLayer().

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

◆ StackupHeight()

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

Implements PNS::ROUTER_IFACE.

Definition at line 545 of file pns_kicad_iface.cpp.

546 {
547  if( !m_board )
548  return 0;
549 
551 
552  return stackup.GetLayerDistance( ToLAYER_ID( aFirstLayer ), ToLAYER_ID( aSecondLayer ) );
553 }
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.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
BOARD_STACKUP & GetStackupDescriptor()
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905

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

◆ syncArc()

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

Definition at line 984 of file pns_kicad_iface.cpp.

985 {
986  auto arc = std::make_unique<PNS::ARC>( SHAPE_ARC( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(),
987  aArc->GetWidth() ),
988  aArc->GetNetCode() );
989 
990  arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
991  arc->SetParent( aArc );
992 
993  if( aArc->IsLocked() )
994  arc->Mark( PNS::MK_LOCKED );
995 
996  return arc;
997 }
const wxPoint & GetStart() const
Definition: track.h:116
const wxPoint & GetMid() const
Definition: track.h:292
virtual bool IsLocked() const
Definition: board_item.h:249
int GetWidth() const
Definition: track.h:110
const wxPoint & GetEnd() const
Definition: track.h:113
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31

References TRACK::GetEnd(), BOARD_ITEM::GetLayer(), ARC::GetMid(), BOARD_CONNECTED_ITEM::GetNetCode(), TRACK::GetStart(), 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 1148 of file pns_kicad_iface.cpp.

1149 {
1150  if( aItem->GetLayer() == Edge_Cuts
1151  || aItem->GetLayer() == Margin
1152  || IsCopperLayer( aItem->GetLayer() ) )
1153  {
1154  // TODO: where do we handle filled polygons on copper layers?
1155  if( aItem->GetShape() == S_POLYGON && aItem->IsFilled() )
1156  return false;
1157 
1158  for( SHAPE* shape : aItem->MakeEffectiveShapes() )
1159  {
1160  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1161 
1162  if( aItem->GetLayer() == Edge_Cuts || aItem->GetLayer() == Margin )
1163  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
1164  else
1165  solid->SetLayer( aItem->GetLayer() );
1166 
1167  if( aItem->GetLayer() == Edge_Cuts )
1168  {
1169  switch( shape->Type() )
1170  {
1171  case SH_SEGMENT: static_cast<SHAPE_SEGMENT*>( shape )->SetWidth( 0 ); break;
1172  case SH_ARC: static_cast<SHAPE_ARC*>( shape )->SetWidth( 0 ); break;
1173  case SH_LINE_CHAIN: static_cast<SHAPE_LINE_CHAIN*>( shape )->SetWidth( 0 ); break;
1174  default: /* remaining shapes don't have width */ break;
1175  }
1176  }
1177 
1178  solid->SetNet( -1 );
1179  solid->SetParent( aItem );
1180  solid->SetShape( shape );
1181  solid->SetRoutable( false );
1182 
1183  aWorld->Add( std::move( solid ) );
1184  }
1185 
1186  return true;
1187  }
1188 
1189  return false;
1190 }
bool IsFilled() const
Definition: pcb_shape.h:96
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:54
circular arc
Definition: shape.h:50
An abstract shape on 2D plane.
Definition: shape.h:116
std::vector< SHAPE * > MakeEffectiveShapes() const
Makes a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:1086
line chain (polyline)
Definition: shape.h:45
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:130
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
line segment
Definition: shape.h:44

References PNS::NODE::Add(), B_Cu, Edge_Cuts, F_Cu, BOARD_ITEM::GetLayer(), PCB_SHAPE::GetShape(), IsCopperLayer(), PCB_SHAPE::IsFilled(), PCB_SHAPE::MakeEffectiveShapes(), Margin, S_POLYGON, 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 856 of file pns_kicad_iface.cpp.

857 {
858  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
859 
860  // ignore non-copper pads except for those with holes
861  if( ( aPad->GetLayerSet() & LSET::AllCuMask() ).none() && aPad->GetDrillSize().x == 0 )
862  return NULL;
863 
864  switch( aPad->GetAttribute() )
865  {
866  case PAD_ATTRIB_PTH:
867  case PAD_ATTRIB_NPTH:
868  break;
869 
870  case PAD_ATTRIB_CONN:
871  case PAD_ATTRIB_SMD:
872  {
873  LSET lmsk = aPad->GetLayerSet();
874  bool is_copper = false;
875 
876  for( int i = 0; i < MAX_CU_LAYERS; i++ )
877  {
878  if( lmsk[i] )
879  {
880  is_copper = true;
881 
882  if( aPad->GetAttribute() != PAD_ATTRIB_NPTH )
883  layers = LAYER_RANGE( i );
884 
885  break;
886  }
887  }
888 
889  if( !is_copper )
890  return NULL;
891  }
892  break;
893 
894  default:
895  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
896  return NULL;
897  }
898 
899  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
900 
901  if( aPad->GetDrillSize().x > 0 )
902  {
904 
905  if( aPad->GetAttribute() != PAD_ATTRIB_NPTH )
906  {
908  slot->SetWidth( slot->GetWidth() + bds.GetHolePlatingThickness() * 2 );
909  }
910 
911  solid->SetHole( slot );
912  }
913 
914  if( aPad->GetAttribute() == PAD_ATTRIB_NPTH )
915  solid->SetRoutable( false );
916 
917  solid->SetLayers( layers );
918  solid->SetNet( aPad->GetNetCode() );
919  solid->SetParent( aPad );
920  solid->SetPadToDie( aPad->GetPadToDieLength() );
921  solid->SetOrientation( aPad->GetOrientation() );
922 
923  wxPoint wx_c = aPad->ShapePos();
924  wxPoint offset = aPad->GetOffset();
925 
926  VECTOR2I c( wx_c.x, wx_c.y );
927 
928  RotatePoint( &offset, aPad->GetOrientation() );
929 
930  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
931  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
932 
933 
934  auto shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
935 
936  if( shapes && shapes->Size() == 1 )
937  {
938  solid->SetShape( shapes->Shapes()[0]->Clone() );
939  }
940  else
941  {
942  // Fixme (but not urgent). For complex pad shapes, we pass a single simple polygon to the
943  // router, otherwise it won't know how to correctly build walkaround 'hulls' for the pad
944  // primitives - it can recognize only simple shapes, but not COMPOUNDs made of multiple shapes.
945  // The proper way to fix this would be to implement SHAPE_COMPOUND::ConvertToSimplePolygon(),
946  // but the complexity of pad polygonization code (see PAD::GetEffectivePolygon), including
947  // approximation error handling makes me slightly scared to do it right now.
948 
949  // NOTE: PAD::GetEffectivePolygon puts the error on the inside, but we want the error on
950  // the outside so that the collision hull is larger than the pad
951 
952  SHAPE_POLY_SET outline;
953  aPad->TransformShapeWithClearanceToPolygon( outline, UNDEFINED_LAYER, 0, ARC_HIGH_DEF,
954  ERROR_OUTSIDE );
955 
956  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
957 
958  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
959  shape->Append( *iter );
960 
961  solid->SetShape( shape );
962  }
963 
964  return solid;
965 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
SHAPE_SIMPLE.
Definition: shape_simple.h:43
int GetHolePlatingThickness() const
Pad & via drills are finish size.
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Return a SHAPE object representing the pad's hole.
Definition: pad.cpp:286
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
PAD_ATTR_T GetAttribute() const
Definition: pad.h:371
const wxPoint & GetOffset() const
Definition: pad.h:249
const wxSize & GetDrillSize() const
Definition: pad.h:242
wxPoint ShapePos() const
Definition: pad.cpp:657
LSET is a set of PCB_LAYER_IDs.
#define NULL
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
Definition: pad.h:349
Represent a set of closed polygons.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:277
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:368
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
Definition: shape_segment.h:57
Plated through hole pad.
Definition: pad_shapes.h:80
int GetWidth() const
int GetPadToDieLength() const
Definition: pad.h:384
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:145
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
void SetWidth(int aWidth)
Container for design settings for a BOARD object.

References LSET::AllCuMask(), SHAPE_SIMPLE::Append(), SHAPE_POLY_SET::CIterate(), SHAPE_SEGMENT::Clone(), ERROR_OUTSIDE, 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(), PNS_KICAD_IFACE_BASE::m_board, MAX_CU_LAYERS, NULL, PAD_ATTRIB_CONN, PAD_ATTRIB_NPTH, PAD_ATTRIB_PTH, PAD_ATTRIB_SMD, RotatePoint(), SHAPE_SEGMENT::SetWidth(), PAD::ShapePos(), PAD::TransformShapeWithClearanceToPolygon(), UNDEFINED_LAYER, 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 1098 of file pns_kicad_iface.cpp.

1099 {
1100  if( !IsCopperLayer( aLayer ) )
1101  return false;
1102 
1103  int textWidth = aText->GetEffectiveTextPenWidth();
1104  std::vector<wxPoint> textShape = aText->TransformToSegmentList();
1105 
1106  if( textShape.size() < 2 )
1107  return false;
1108 
1109  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
1110  {
1111  VECTOR2I start( textShape[jj] );
1112  VECTOR2I end( textShape[jj+1] );
1113  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1114 
1115  solid->SetLayer( aLayer );
1116  solid->SetNet( -1 );
1117  solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
1118  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
1119  solid->SetRoutable( false );
1120 
1121  aWorld->Add( std::move( solid ) );
1122  }
1123 
1124  return true;
1125 
1126  /* A coarser (but faster) method:
1127  *
1128  SHAPE_POLY_SET outline;
1129  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
1130 
1131  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
1132 
1133  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
1134  shape->Append( *iter );
1135 
1136  solid->SetShape( shape );
1137 
1138  solid->SetLayer( aLayer );
1139  solid->SetNet( -1 );
1140  solid->SetParent( nullptr );
1141  solid->SetRoutable( false );
1142  aWorld->Add( std::move( solid ) );
1143  return true;
1144  */
1145 }
std::vector< wxPoint > TransformToSegmentList() const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:580
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613

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

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncTrack()

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

Definition at line 968 of file pns_kicad_iface.cpp.

969 {
970  auto segment = std::make_unique<PNS::SEGMENT>( SEG( aTrack->GetStart(), aTrack->GetEnd() ),
971  aTrack->GetNetCode() );
972 
973  segment->SetWidth( aTrack->GetWidth() );
974  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
975  segment->SetParent( aTrack );
976 
977  if( aTrack->IsLocked() )
978  segment->Mark( PNS::MK_LOCKED );
979 
980  return segment;
981 }
const wxPoint & GetStart() const
Definition: track.h:116
Definition: seg.h:41
virtual bool IsLocked() const
Definition: board_item.h:249
int GetWidth() const
Definition: track.h:110
const wxPoint & GetEnd() const
Definition: track.h:113
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:173
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31

References TRACK::GetEnd(), BOARD_ITEM::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), TRACK::GetStart(), 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 ( VIA aVia)
protectedinherited

Definition at line 1000 of file pns_kicad_iface.cpp.

1001 {
1002  PCB_LAYER_ID top, bottom;
1003  aVia->LayerPair( &top, &bottom );
1004 
1005  auto via = std::make_unique<PNS::VIA>( aVia->GetPosition(),
1006  LAYER_RANGE( aVia->TopLayer(), aVia->BottomLayer() ),
1007  aVia->GetWidth(),
1008  aVia->GetDrillValue(),
1009  aVia->GetNetCode(),
1010  aVia->GetViaType() );
1011 
1012  via->SetParent( aVia );
1013 
1014  if( aVia->IsLocked() )
1015  via->Mark( PNS::MK_LOCKED );
1016 
1017  via->SetIsFree( aVia->GetIsFree() );
1018 
1020  via->SetHole( SHAPE_CIRCLE( aVia->GetPosition(),
1021  aVia->GetDrill() / 2 + bds.GetHolePlatingThickness() ) );
1022 
1023  return via;
1024 }
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: track.cpp:435
int GetHolePlatingThickness() const
Pad & via drills are finish size.
bool GetIsFree() const
Checks if the via is a free via (as opposed to one created on a track by the router).
Definition: track.h:502
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
PCB_LAYER_ID
A quick note on layer IDs:
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: track.cpp:173
int GetDrill() const
Function GetDrill returns the local drill setting for this VIA.
Definition: track.h:481
virtual bool IsLocked() const
Definition: board_item.h:249
int GetWidth() const
Definition: track.h:110
VIATYPE GetViaType() const
Definition: track.h:373
PCB_LAYER_ID TopLayer() const
Definition: track.cpp:457
wxPoint GetPosition() const override
Definition: track.h:411
PCB_LAYER_ID BottomLayer() const
Definition: track.cpp:463
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
Container for design settings for a BOARD object.

References VIA::BottomLayer(), BOARD::GetDesignSettings(), VIA::GetDrill(), VIA::GetDrillValue(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), VIA::GetIsFree(), BOARD_CONNECTED_ITEM::GetNetCode(), VIA::GetPosition(), VIA::GetViaType(), TRACK::GetWidth(), BOARD_ITEM::IsLocked(), VIA::LayerPair(), PNS_KICAD_IFACE_BASE::m_board, PNS::MK_LOCKED, 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 1274 of file pns_kicad_iface.cpp.

1275 {
1276  if( !m_board )
1277  {
1278  wxLogTrace( "PNS", "No board attached, aborting sync." );
1279  return;
1280  }
1281 
1282  int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1283 
1284  m_world = aWorld;
1285 
1286  for( BOARD_ITEM* gitem : m_board->Drawings() )
1287  {
1288  if ( gitem->Type() == PCB_SHAPE_T )
1289  {
1290  syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( gitem ) );
1291  }
1292  else if( gitem->Type() == PCB_TEXT_T )
1293  {
1294  syncTextItem( aWorld, static_cast<PCB_TEXT*>( gitem ), gitem->GetLayer() );
1295  }
1296  }
1297 
1298  SHAPE_POLY_SET buffer;
1299  SHAPE_POLY_SET* boardOutline = nullptr;
1300 
1301  if( m_board->GetBoardPolygonOutlines( buffer ) )
1302  boardOutline = &buffer;
1303 
1304  for( ZONE* zone : m_board->Zones() )
1305  {
1306  syncZone( aWorld, zone, boardOutline );
1307  }
1308 
1309  for( FOOTPRINT* footprint : m_board->Footprints() )
1310  {
1311  for( PAD* pad : footprint->Pads() )
1312  {
1313  if( std::unique_ptr<PNS::SOLID> solid = syncPad( pad ) )
1314  aWorld->Add( std::move( solid ) );
1315 
1316  worstClearance = std::max( worstClearance, pad->GetLocalClearance() );
1317  }
1318 
1319  syncTextItem( aWorld, &footprint->Reference(), footprint->Reference().GetLayer() );
1320  syncTextItem( aWorld, &footprint->Value(), footprint->Value().GetLayer() );
1321 
1322  for( FP_ZONE* zone : footprint->Zones() )
1323  syncZone( aWorld, zone, boardOutline );
1324 
1325  if( footprint->IsNetTie() )
1326  continue;
1327 
1328  for( BOARD_ITEM* mgitem : footprint->GraphicalItems() )
1329  {
1330  if( mgitem->Type() == PCB_FP_SHAPE_T )
1331  {
1332  syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( mgitem ) );
1333  }
1334  else if( mgitem->Type() == PCB_FP_TEXT_T )
1335  {
1336  syncTextItem( aWorld, static_cast<FP_TEXT*>( mgitem ), mgitem->GetLayer() );
1337  }
1338  }
1339  }
1340 
1341  for( TRACK* t : m_board->Tracks() )
1342  {
1343  KICAD_T type = t->Type();
1344 
1345  if( type == PCB_TRACE_T )
1346  {
1347  if( auto segment = syncTrack( t ) )
1348  aWorld->Add( std::move( segment ) );
1349  }
1350  else if( type == PCB_ARC_T )
1351  {
1352  if( auto arc = syncArc( static_cast<ARC*>( t ) ) )
1353  aWorld->Add( std::move( arc ) );
1354  }
1355  else if( type == PCB_VIA_T )
1356  {
1357  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1358  aWorld->Add( std::move( via ) );
1359  }
1360  }
1361 
1362  // NB: if this were ever to become a long-lived object we would need to dirty its
1363  // clearance cache here....
1364  delete m_ruleResolver;
1366 
1367  aWorld->SetRuleResolver( m_ruleResolver );
1368  aWorld->SetMaxClearance( worstClearance + m_ruleResolver->ClearanceEpsilon() );
1369 }
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
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:1922
ZONES & Zones()
Definition: board.h:311
bool syncGraphicalItem(PNS::NODE *aWorld, PCB_SHAPE *aItem)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
void SetRuleResolver(RULE_RESOLVER *aFunc)
Definition: pns_node.h:173
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void SetMaxClearance(int aClearance)
Assign a clearance resolution function object.
Definition: pns_node.h:167
Represent a set of closed polygons.
FOOTPRINTS & Footprints()
Definition: board.h:305
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
std::unique_ptr< PNS::ARC > syncArc(ARC *aArc)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
Definition: pad.h:60
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
DRAWINGS & Drawings()
Definition: board.h:308
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613
A specialization of ZONE for use in footprints.
Definition: zone.h:943
TRACKS & Tracks()
Definition: board.h:302
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
Definition: track.h:83
std::unique_ptr< PNS::SOLID > syncPad(PAD *aPad)
bool syncZone(PNS::NODE *aWorld, ZONE *aZone, SHAPE_POLY_SET *aBoardOutline)

References PNS::NODE::Add(), PNS_PCBNEW_RULE_RESOLVER::ClearanceEpsilon(), BOARD::Drawings(), BOARD::Footprints(), BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue(), BOARD::GetBoardPolygonOutlines(), BOARD::GetDesignSettings(), 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_SHAPE_T, PCB_TEXT_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 1027 of file pns_kicad_iface.cpp.

1028 {
1029  SHAPE_POLY_SET* poly;
1030 
1031  if( !aZone->GetIsRuleArea() && aZone->GetZoneName().IsEmpty() )
1032  return false;
1033 
1034  // Required by expression function insideArea()
1035  aZone->CacheBoundingBox();
1036 
1037  // TODO handle aZone->GetDoNotAllowVias()
1038  // TODO handle rules which disallow tracks & vias
1039  if( !aZone->GetIsRuleArea() || !aZone->GetDoNotAllowTracks() )
1040  return false;
1041 
1042  LSET layers = aZone->GetLayerSet();
1043  EDA_UNITS units = EDA_UNITS::MILLIMETRES; // TODO: get real units
1044 
1045  poly = aZone->Outline();
1046  poly->CacheTriangulation( false );
1047 
1048  if( !poly->IsTriangulationUpToDate() )
1049  {
1050  KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ),
1051  aZone->GetSelectMenuText( units ) ),
1053  dlg.ShowDetailedText( wxString::Format( _( "This zone cannot be handled by the router.\n"
1054  "Please verify it is not a self-intersecting "
1055  "polygon." ) ) );
1056  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1057  dlg.ShowModal();
1058 
1059  return false;
1060  }
1061 
1062  for( int layer = F_Cu; layer <= B_Cu; layer++ )
1063  {
1064  if( !layers[ layer ] )
1065  continue;
1066 
1067  for( int outline = 0; outline < poly->OutlineCount(); outline++ )
1068  {
1069  const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly->TriangulatedPolygon( outline );
1070 
1071  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
1072  {
1073  VECTOR2I a, b, c;
1074  tri->GetTriangle( i, a, b, c );
1075  SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
1076 
1077  triShape->Append( a );
1078  triShape->Append( b );
1079  triShape->Append( c );
1080 
1081  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1082 
1083  solid->SetLayer( layer );
1084  solid->SetNet( -1 );
1085  solid->SetParent( aZone );
1086  solid->SetShape( triShape );
1087  solid->SetRoutable( false );
1088 
1089  aWorld->Add( std::move( solid ) );
1090  }
1091  }
1092  }
1093 
1094  return true;
1095 }
SHAPE_SIMPLE.
Definition: shape_simple.h:43
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:730
void GetTriangle(int index, VECTOR2I &a, VECTOR2I &b, VECTOR2I &c) const
SHAPE_POLY_SET * Outline()
Definition: zone.h:317
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:289
bool IsTriangulationUpToDate() const
LSET is a set of PCB_LAYER_IDs.
Represent a set of closed polygons.
bool GetDoNotAllowTracks() const
Definition: zone.h:733
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
EDA_UNITS
Definition: eda_units.h:38
void CacheBoundingBox()
Definition: zone.h:146
#define _(s)
Definition: 3d_actions.cpp:33
void CacheTriangulation(bool aPartition=true)
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: zone.cpp:853
wxString GetZoneName() const
Definition: zone.h:129
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:613
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:145

References _, PNS::NODE::Add(), SHAPE_SIMPLE::Append(), B_Cu, ZONE::CacheBoundingBox(), 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(), ZONE::GetZoneName(), SHAPE_POLY_SET::IsTriangulationUpToDate(), KIDIALOG::KD_WARNING, MILLIMETRES, ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), KIDIALOG::ShowModal(), and SHAPE_POLY_SET::TriangulatedPolygon().

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ UpdateItem()

void PNS_KICAD_IFACE::UpdateItem ( PNS::ITEM aItem)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1488 of file pns_kicad_iface.cpp.

1489 {
1490  BOARD_ITEM* board_item = aItem->Parent();
1491 
1492  m_commit->Modify( board_item );
1493 
1494  switch( aItem->Kind() )
1495  {
1496  case PNS::ITEM::ARC_T:
1497  {
1498  PNS::ARC* arc = static_cast<PNS::ARC*>( aItem );
1499  ARC* arc_board = static_cast<ARC*>( board_item );
1500  const SHAPE_ARC* arc_shape = static_cast<const SHAPE_ARC*>( arc->Shape() );
1501  arc_board->SetStart( wxPoint( arc_shape->GetP0() ) );
1502  arc_board->SetEnd( wxPoint( arc_shape->GetP1() ) );
1503  arc_board->SetMid( wxPoint( arc_shape->GetArcMid() ) );
1504  arc_board->SetWidth( arc->Width() );
1505  break;
1506  }
1507 
1508  case PNS::ITEM::SEGMENT_T:
1509  {
1510  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1511  TRACK* track = static_cast<TRACK*>( board_item );
1512  const SEG& s = seg->Seg();
1513  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1514  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1515  track->SetWidth( seg->Width() );
1516  break;
1517  }
1518 
1519  case PNS::ITEM::VIA_T:
1520  {
1521  VIA* via_board = static_cast<VIA*>( board_item );
1522  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1523  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1524  via_board->SetWidth( via->Diameter() );
1525  via_board->SetDrill( via->Drill() );
1526  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1527  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1528  via_board->SetIsFree( via->IsFree() );
1529  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1530  ToLAYER_ID( via->Layers().End() ) );
1531  break;
1532  }
1533 
1534  case PNS::ITEM::SOLID_T:
1535  {
1536  PAD* pad = static_cast<PAD*>( aItem->Parent() );
1537  VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1538 
1539  m_fpOffsets[ pad ].p_old = pad->GetPosition();
1540  m_fpOffsets[ pad ].p_new = pos;
1541  break;
1542  }
1543 
1544  default:
1545  break;
1546  }
1547 }
Definition: track.h:343
void SetPosition(const wxPoint &aPoint) override
Definition: track.h:412
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
void SetEnd(const wxPoint &aEnd)
Definition: track.h:112
int Width() const override
Definition: pns_arc.h:87
int Width() const override
Definition: pns_segment.h:79
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
BOARD_ITEM * Parent() const
Definition: pns_item.h:145
const SEG & Seg() const
Definition: pns_segment.h:84
void SetWidth(int aWidth)
Definition: track.h:109
std::unique_ptr< BOARD_COMMIT > m_commit
const VECTOR2I & GetP0() const
Definition: shape_arc.h:95
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:97
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_layer contains the top layer, the other layer is in m_bottomLayer.
Definition: track.cpp:414
void SetMid(const wxPoint &aMid)
Definition: track.h:291
Definition: seg.h:41
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_arc.h:77
Definition: track.h:262
VECTOR2I A
Definition: seg.h:49
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: track.h:474
void SetIsFree(bool aFree=true)
Definition: track.h:503
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:126
void SetStart(const wxPoint &aStart)
Definition: track.h:115
Definition: pad.h:60
void SetViaType(VIATYPE aViaType)
Definition: track.h:374
std::map< PAD *, OFFSET > m_fpOffsets
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
const VECTOR2I & GetP1() const
Definition: shape_arc.h:96
Definition: track.h:83
VECTOR2I B
Definition: seg.h:50

References SEG::A, PNS::ITEM::ARC_T, SEG::B, SHAPE_ARC::GetArcMid(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), PNS::ITEM::Kind(), m_commit, m_fpOffsets, pad, PNS::ITEM::Parent(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, VIA::SetDrill(), TRACK::SetEnd(), VIA::SetIsFree(), VIA::SetLayerPair(), ARC::SetMid(), BOARD_CONNECTED_ITEM::SetNetCode(), VIA::SetPosition(), TRACK::SetStart(), VIA::SetViaType(), TRACK::SetWidth(), PNS::ARC::Shape(), PNS::ITEM::SOLID_T, ToLAYER_ID(), via, PNS::ITEM::VIA_T, PNS::SEGMENT::Width(), PNS::ARC::Width(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ UpdateNet()

void PNS_KICAD_IFACE::UpdateNet ( int  aNetCode)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1683 of file pns_kicad_iface.cpp.

1684 {
1685  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1686 
1687 }

Member Data Documentation

◆ m_board

◆ m_commit

std::unique_ptr<BOARD_COMMIT> PNS_KICAD_IFACE::m_commit
private

Definition at line 142 of file pns_kicad_iface.h.

Referenced by AddItem(), Commit(), RemoveItem(), SetHostTool(), and UpdateItem().

◆ m_debugDecorator

◆ m_dispOptions

const PCB_DISPLAY_OPTIONS* PNS_KICAD_IFACE::m_dispOptions
private

Definition at line 143 of file pns_kicad_iface.h.

Referenced by DisplayItem(), PNS_KICAD_IFACE(), and SetDisplayOptions().

◆ m_fpOffsets

std::map<PAD*, OFFSET> PNS_KICAD_IFACE::m_fpOffsets
private

Definition at line 136 of file pns_kicad_iface.h.

Referenced by AddItem(), Commit(), RemoveItem(), and UpdateItem().

◆ m_hiddenItems

std::unordered_set<BOARD_ITEM*> PNS_KICAD_IFACE::m_hiddenItems
private

Definition at line 139 of file pns_kicad_iface.h.

Referenced by EraseView(), HideItem(), and IsItemVisible().

◆ m_previewItems

KIGFX::VIEW_GROUP* PNS_KICAD_IFACE::m_previewItems
private

◆ m_ruleResolver

◆ m_tool

PCB_TOOL_BASE* PNS_KICAD_IFACE::m_tool
private

Definition at line 141 of file pns_kicad_iface.h.

Referenced by Commit(), PNS_KICAD_IFACE(), and SetHostTool().

◆ m_view

KIGFX::VIEW* PNS_KICAD_IFACE::m_view
private

◆ m_world

PNS::NODE* PNS_KICAD_IFACE_BASE::m_world
protectedinherited

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