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)
 
void SetStartLayer (int aLayer)
 
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 (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

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 109 of file pns_kicad_iface.h.

Constructor & Destructor Documentation

◆ PNS_KICAD_IFACE()

PNS_KICAD_IFACE::PNS_KICAD_IFACE ( )

Definition at line 851 of file pns_kicad_iface.cpp.

852 {
853  m_tool = nullptr;
854  m_view = nullptr;
855  m_previewItems = nullptr;
856  m_dispOptions = nullptr;
857 }
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 865 of file pns_kicad_iface.cpp.

866 {
867  delete m_ruleResolver;
868  delete m_debugDecorator;
869 
870  if( m_previewItems )
871  {
873  delete m_previewItems;
874  }
875 }
PNS::DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:192
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 1575 of file pns_kicad_iface.cpp.

1576 {
1577  BOARD_CONNECTED_ITEM* newBI = nullptr;
1578 
1579  switch( aItem->Kind() )
1580  {
1581  case PNS::ITEM::ARC_T:
1582  {
1583  PNS::ARC* arc = static_cast<PNS::ARC*>( aItem );
1584  PCB_ARC* new_arc = new PCB_ARC( m_board, static_cast<const SHAPE_ARC*>( arc->Shape() ) );
1585  new_arc->SetWidth( arc->Width() );
1586  new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
1587  new_arc->SetNetCode( std::max<int>( 0, arc->Net() ) );
1588  newBI = new_arc;
1589  break;
1590  }
1591 
1592  case PNS::ITEM::SEGMENT_T:
1593  {
1594  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1595  PCB_TRACK* track = new PCB_TRACK( m_board );
1596  const SEG& s = seg->Seg();
1597  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1598  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1599  track->SetWidth( seg->Width() );
1600  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1601  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1602  newBI = track;
1603  break;
1604  }
1605 
1606  case PNS::ITEM::VIA_T:
1607  {
1608  PCB_VIA* via_board = new PCB_VIA( m_board );
1609  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1610  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1611  via_board->SetWidth( via->Diameter() );
1612  via_board->SetDrill( via->Drill() );
1613  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1614  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1615  via_board->SetIsFree( via->IsFree() );
1616  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1617  ToLAYER_ID( via->Layers().End() ) );
1618  newBI = via_board;
1619  break;
1620  }
1621 
1622  case PNS::ITEM::SOLID_T:
1623  {
1624  PAD* pad = static_cast<PAD*>( aItem->Parent() );
1625  VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1626 
1627  m_fpOffsets[ pad ].p_new = pos;
1628  return;
1629  }
1630 
1631  default:
1632  break;
1633  }
1634 
1635  if( newBI )
1636  {
1637  //newBI->SetLocalRatsnestVisible( m_dispOptions->m_ShowGlobalRatsnest );
1638  aItem->SetParent( newBI );
1639  newBI->ClearFlags();
1640 
1641  m_commit->Add( newBI );
1642  }
1643 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: pcb_track.h:453
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
int Width() const override
Definition: pns_arc.h:87
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: pcb_track.cpp:413
int Width() const override
Definition: pns_segment.h:79
void SetParent(BOARD_ITEM *aParent)
Definition: pns_item.h:148
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetPosition(const wxPoint &aPoint) override
Definition: pcb_track.h:391
BOARD_ITEM * Parent() const
Definition: pns_item.h:149
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,...
int Start() const
Definition: pns_layerset.h:82
std::unique_ptr< BOARD_COMMIT > m_commit
int Net() const
Definition: pns_item.h:152
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:353
Definition: seg.h:40
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_arc.h:77
void SetWidth(int aWidth)
Definition: pcb_track.h:101
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:482
VECTOR2I A
Definition: seg.h:48
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:130
Definition: pad.h:57
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:154
VECTOR2I B
Definition: seg.h:49

References SEG::A, 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(), pad, PNS::ITEM::Parent(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PCB_VIA::SetDrill(), PCB_TRACK::SetEnd(), PCB_VIA::SetIsFree(), BOARD_ITEM::SetLayer(), PCB_VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::ITEM::SetParent(), PCB_VIA::SetPosition(), PCB_TRACK::SetStart(), PCB_VIA::SetViaType(), PCB_TRACK::SetWidth(), PNS::ARC::Shape(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), ToLAYER_ID(), via, PNS::ITEM::VIA_T, PNS::SEGMENT::Width(), PNS::ARC::Width(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Commit()

void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1646 of file pns_kicad_iface.cpp.

1647 {
1648  std::set<FOOTPRINT*> processedFootprints;
1649 
1650  EraseView();
1651 
1652  for( auto fpOffset : m_fpOffsets )
1653  {
1654  VECTOR2I offset = fpOffset.second.p_new - fpOffset.second.p_old;
1655  FOOTPRINT* footprint = fpOffset.first->GetParent();
1656 
1657  VECTOR2I p_orig = footprint->GetPosition();
1658  VECTOR2I p_new = p_orig + offset;
1659 
1660  if( processedFootprints.find( footprint ) != processedFootprints.end() )
1661  continue;
1662 
1663  processedFootprints.insert( footprint );
1664  m_commit->Modify( footprint );
1665  footprint->SetPosition( wxPoint( p_new.x, p_new.y ) );
1666  }
1667 
1668  m_fpOffsets.clear();
1669 
1670  m_commit->Push( _( "Interactive Router" ) );
1671  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1672 }
std::unique_ptr< BOARD_COMMIT > m_commit
#define _(s)
void EraseView() override
PCB_TOOL_BASE * m_tool
wxPoint GetPosition() const override
Definition: footprint.h:186
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1561
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
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 1412 of file pns_kicad_iface.cpp.

1413 {
1414  if( aItem->IsVirtual() )
1415  return;
1416 
1417  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1418 
1419  // Note: SEGMENT_T is used for placed tracks; LINE_T is used for the routing head
1421  static int tracksOrVias = tracks | PNS::ITEM::VIA_T;
1422 
1423  if( aClearance >= 0 )
1424  {
1425  pitem->SetClearance( aClearance );
1426 
1428  {
1431  pitem->ShowClearance( aItem->OfKind( tracksOrVias ) );
1432  break;
1433 
1435  pitem->ShowClearance( aItem->OfKind( tracksOrVias ) && !aEdit );
1436  break;
1437 
1439  pitem->ShowClearance( aItem->OfKind( tracks ) && !aEdit );
1440  break;
1441 
1442  default:
1443  pitem->ShowClearance( false );
1444  break;
1445  }
1446  }
1447 
1448  m_previewItems->Add( pitem );
1450 }
void ShowClearance(bool aEnabled)
void SetClearance(int aClearance)
bool IsVirtual() const
Definition: pns_item.h:235
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
KIGFX::VIEW_GROUP * m_previewItems
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
const PCB_DISPLAY_OPTIONS * m_dispOptions
KIGFX::VIEW * m_view
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:138
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:1576

References KIGFX::VIEW_GROUP::Add(), PNS::ITEM::ARC_T, PNS::ITEM::IsVirtual(), PNS::ITEM::LINE_T, m_dispOptions, m_previewItems, PCB_DISPLAY_OPTIONS::m_ShowTrackClearanceMode, m_view, PNS::ITEM::OfKind(), PNS::ITEM::SEGMENT_T, 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::ShowClearance(), KIGFX::VIEW::Update(), and PNS::ITEM::VIA_T.

◆ DisplayRatline()

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1453 of file pns_kicad_iface.cpp.

1454 {
1455  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( nullptr, m_view );
1456  pitem->Line( aRatline, 10000, aColor );
1457  m_previewItems->Add( pitem );
1459 }
void Line(const SHAPE_LINE_CHAIN &aLine, int aWidth=0, int aStyle=-1)
KIGFX::VIEW_GROUP * m_previewItems
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
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:1576

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

1389 {
1390  for( auto item : m_hiddenItems )
1391  m_view->SetVisible( item, true );
1392 
1393  m_hiddenItems.clear();
1394 
1395  if( m_previewItems )
1396  {
1399  }
1400 
1401  if( m_debugDecorator )
1403 }
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:192
KIGFX::VIEW_GROUP * m_previewItems
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1522
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:1576

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 82 of file pns_kicad_iface.h.

83  {
84  return m_board;
85  }

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

836 {
837  return m_debugDecorator;
838 }
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 1711 of file pns_kicad_iface.cpp.

1712 {
1713  return m_ruleResolver;
1714 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References PNS_KICAD_IFACE_BASE::m_ruleResolver.

Referenced by ROUTER_TOOL::updateMessagePanel().

◆ 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.

78  {
79  return m_world;
80  };

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

1463 {
1464  BOARD_ITEM* parent = aItem->Parent();
1465 
1466  if( parent )
1467  {
1468  if( m_view->IsVisible( parent ) )
1469  m_hiddenItems.insert( parent );
1470 
1471  m_view->SetVisible( parent, false );
1472  m_view->Update( parent, KIGFX::APPEARANCE );
1473  }
1474 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
BOARD_ITEM * Parent() const
Definition: pns_item.h:149
Visibility flag has changed.
Definition: view_item.h:47
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:1562
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1522
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:1576

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

457 {
459  PNS::CONSTRAINT constraint;
460 
461  if( aStartItem && m_startLayer < 0 )
462  m_startLayer = aStartItem->Layer();
463 
464  aSizes.SetMinClearance( bds.m_MinClearance );
465 
466  int trackWidth = bds.m_TrackMinWidth;
467  bool found = false;
468 
469  if( bds.m_UseConnectedTrackWidth && aStartItem != nullptr )
470  {
471  found = inheritTrackWidth( aStartItem, &trackWidth );
472 
473  if( found )
474  aSizes.SetWidthSource( _( "existing track" ) );
475  }
476 
477  if( !found && bds.UseNetClassTrack() && aStartItem )
478  {
480  m_startLayer, &constraint ) )
481  {
482  trackWidth = std::max( trackWidth, constraint.m_Value.Opt() );
483  found = true;
484 
485  if( trackWidth == constraint.m_Value.Opt() )
486  aSizes.SetWidthSource( constraint.m_RuleName );
487  else
488  aSizes.SetWidthSource( _( "board minimum width" ) );
489  }
490  }
491 
492  if( !found )
493  {
494  trackWidth = std::max( trackWidth, bds.GetCurrentTrackWidth() );
495 
496  if( bds.UseNetClassTrack() )
497  aSizes.SetWidthSource( _( "netclass 'Default'" ) );
498  else if( trackWidth == bds.GetCurrentTrackWidth() )
499  aSizes.SetWidthSource( _( "user choice" ) );
500  else
501  aSizes.SetWidthSource( _( "board minimum width" ) );
502  }
503 
504  aSizes.SetTrackWidth( trackWidth );
506 
507  int viaDiameter = bds.m_ViasMinSize;
508  int viaDrill = bds.m_MinThroughDrill;
509 
510  if( bds.UseNetClassVia() && aStartItem ) // netclass value
511  {
513  nullptr, m_startLayer, &constraint ) )
514  {
515  viaDiameter = std::max( viaDiameter, constraint.m_Value.Opt() );
516  }
517 
519  m_startLayer, &constraint ) )
520  {
521  viaDrill = std::max( viaDrill, constraint.m_Value.Opt() );
522  }
523  }
524  else
525  {
526  viaDiameter = bds.GetCurrentViaSize();
527  viaDrill = bds.GetCurrentViaDrill();
528  }
529 
530  aSizes.SetViaDiameter( viaDiameter );
531  aSizes.SetViaDrill( viaDrill );
532 
533  int diffPairWidth = bds.m_TrackMinWidth;
534  int diffPairGap = bds.m_MinClearance;
535  int diffPairViaGap = bds.m_MinClearance;
536 
537  found = false;
538 
539  // First try to pick up diff pair width from starting track, if enabled
540  if( bds.m_UseConnectedTrackWidth && aStartItem )
541  found = inheritTrackWidth( aStartItem, &diffPairWidth );
542 
543  // Next, pick up gap from netclass, and width also if we didn't get a starting width above
544  if( bds.UseNetClassDiffPair() && aStartItem )
545  {
547  nullptr, m_startLayer, &constraint ) )
548  {
549  diffPairWidth = std::max( diffPairWidth, constraint.m_Value.Opt() );
550  }
551 
553  nullptr, m_startLayer, &constraint ) )
554  {
555  diffPairGap = std::max( diffPairGap, constraint.m_Value.Opt() );
556  diffPairViaGap = std::max( diffPairViaGap, constraint.m_Value.Opt() );
557  }
558  }
559  else
560  {
561  diffPairWidth = bds.GetCurrentDiffPairWidth();
562  diffPairGap = bds.GetCurrentDiffPairGap();
563  diffPairViaGap = bds.GetCurrentDiffPairViaGap();
564  }
565 
566  aSizes.SetDiffPairWidth( diffPairWidth );
567  aSizes.SetDiffPairGap( diffPairGap );
568  aSizes.SetDiffPairViaGap( diffPairViaGap );
569 
570  int holeToHoleMin = bds.m_HoleToHoleMin;
571  PNS::VIA dummyVia;
572 
574  &dummyVia, UNDEFINED_LAYER, &constraint ) )
575  {
576  holeToHoleMin = constraint.m_Value.Min();
577  }
578 
579  aSizes.SetHoleToHole( holeToHoleMin );
580 
581  aSizes.ClearLayerPairs();
582 
583  return true;
584 }
bool UseNetClassTrack() const
Return true if netclass values should be used to obtain appropriate track width.
virtual int Layer() const
Definition: pns_item.h:158
void SetTrackWidthIsExplicit(bool aIsExplicit)
void SetWidthSource(const wxString &aSource)
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
wxString m_RuleName
Definition: pns_node.h:72
void SetViaDrill(int aDrill)
T Min() const
Definition: minoptmax.h:33
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
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.
#define _(s)
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::CONSTRAINT::m_RuleName, PNS_KICAD_IFACE_BASE::m_ruleResolver, PNS_KICAD_IFACE_BASE::m_startLayer, 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::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 392 of file pns_kicad_iface.cpp.

393 {
394  VECTOR2I p;
395 
396  assert( aItem->Owner() != nullptr );
397 
398  auto tryGetTrackWidth =
399  []( PNS::ITEM* aPnsItem ) -> int
400  {
401  switch( aPnsItem->Kind() )
402  {
403  case PNS::ITEM::SEGMENT_T: return static_cast<PNS::SEGMENT*>( aPnsItem )->Width();
404  case PNS::ITEM::ARC_T: return static_cast<PNS::ARC*>( aPnsItem )->Width();
405  default: return -1;
406  }
407  };
408 
409  int itemTrackWidth = tryGetTrackWidth( aItem );
410 
411  if( itemTrackWidth > 0 )
412  {
413  *aInheritedWidth = itemTrackWidth;
414  return true;
415  }
416 
417  switch( aItem->Kind() )
418  {
419  case PNS::ITEM::VIA_T:
420  p = static_cast<PNS::VIA*>( aItem )->Pos();
421  break;
422 
423  case PNS::ITEM::SOLID_T:
424  p = static_cast<PNS::SOLID*>( aItem )->Pos();
425  break;
426 
427  default:
428  return false;
429  }
430 
431  PNS::JOINT* jt = static_cast<PNS::NODE*>( aItem->Owner() )->FindJoint( p, aItem );
432 
433  assert( jt != nullptr );
434 
435  int mval = INT_MAX;
436 
437  PNS::ITEM_SET linkedSegs = jt->Links();
439 
440  for( PNS::ITEM* item : linkedSegs.Items() )
441  {
442  int w = tryGetTrackWidth( item );
443  assert( w > 0 );
444  mval = std::min( w, mval );
445  }
446 
447  if( mval == INT_MAX )
448  return false;
449 
450  *aInheritedWidth = mval;
451  return true;
452 }
Base class for PNS router board items.
Definition: pns_item.h:55
ENTRIES & Items()
Definition: pns_itemset.h:135
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:228
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:42
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:130
NODE * Owner() const
Return the owner of this item, or NULL if there's none.
Definition: pns_item.h:171

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::IsAnyLayerVisible ( const LAYER_RANGE aLayer) const
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1214 of file pns_kicad_iface.cpp.

1215 {
1216  if( !m_view )
1217  return false;
1218 
1219  for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
1220  {
1221  if( m_view->IsLayerVisible( i ) )
1222  return true;
1223  }
1224 
1225  return false;
1226 }
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:405

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

1230 {
1232  if( aLayer < 0 )
1233  return true;
1234 
1235  if( aItem->Parent() )
1236  {
1237  switch( aItem->Parent()->Type() )
1238  {
1239  case PCB_VIA_T:
1240  {
1241  const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem->Parent() );
1242 
1243  return via->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
1244  }
1245 
1246  case PCB_PAD_T:
1247  {
1248  const PAD* pad = static_cast<const PAD*>( aItem->Parent() );
1249 
1250  return pad->FlashLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
1251  }
1252 
1253  default:
1254  break;
1255  }
1256  }
1257 
1258  return aItem->Layers().Overlaps( aLayer );
1259 }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
BOARD_ITEM * Parent() const
Definition: pns_item.h:149
class PAD, a pad in a footprint
Definition: typeinfo.h:89
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: pad.h:57
const LAYER_RANGE & Layers() const
Definition: pns_item.h:154
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

1263 {
1264  // by default, all items are visible (new ones created by the router have parent == NULL
1265  // as they have not been committed yet to the BOARD)
1266  if( !m_view || !aItem->Parent() )
1267  return true;
1268 
1269  BOARD_ITEM* item = aItem->Parent();
1270  bool isOnVisibleLayer = true;
1271  RENDER_SETTINGS* settings = m_view->GetPainter()->GetSettings();
1272 
1273  if( settings->GetHighContrast() )
1274  isOnVisibleLayer = item->IsOnLayer( settings->GetPrimaryHighContrastLayer() );
1275 
1276  if( m_view->IsVisible( item ) && isOnVisibleLayer
1277  && item->ViewGetLOD( item->GetLayer(), m_view ) < m_view->GetScale() )
1278  {
1279  return true;
1280  }
1281 
1282  // Items hidden in the router are not hidden on the board
1283  if( m_hiddenItems.find( item ) != m_hiddenItems.end() )
1284  return true;
1285 
1286  return false;
1287 }
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:49
BOARD_ITEM * Parent() const
Definition: pns_item.h:149
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
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:200
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
Definition: view.cpp:1562
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:264
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:132

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

1483 {
1484  BOARD_ITEM* parent = aItem->Parent();
1485 
1486  if( aItem->OfKind( PNS::ITEM::SOLID_T ) )
1487  {
1488  PAD* pad = static_cast<PAD*>( parent );
1489  VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1490 
1491  m_fpOffsets[ pad ].p_old = pos;
1492  return;
1493  }
1494 
1495  if( parent )
1496  {
1497  m_commit->Remove( parent );
1498  }
1499 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
BOARD_ITEM * Parent() const
Definition: pns_item.h:149
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:138
Definition: pad.h:57
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 1207 of file pns_kicad_iface.cpp.

1208 {
1209  m_board = aBoard;
1210  wxLogTrace( "PNS", "m_board = %p", m_board );
1211 }

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

1407 {
1408  m_debugDecorator = aDec;
1409 }
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 1724 of file pns_kicad_iface.cpp.

1725 {
1726  m_dispOptions = aDispOptions;
1727 }
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 1717 of file pns_kicad_iface.cpp.

1718 {
1719  m_tool = aTool;
1720  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1721 }
std::unique_ptr< BOARD_COMMIT > m_commit
PCB_TOOL_BASE * m_tool

References m_commit, and m_tool.

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

◆ 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().

◆ SetView()

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

Definition at line 1675 of file pns_kicad_iface.cpp.

1676 {
1677  wxLogTrace( "PNS", "SetView %p", aView );
1678 
1679  if( m_previewItems )
1680  {
1682  delete m_previewItems;
1683  }
1684 
1685  m_view = aView;
1688 
1689  if(m_view)
1691 
1692  delete m_debugDecorator;
1693 
1694  auto dec = new PNS_PCBNEW_DEBUG_DECORATOR();
1695  m_debugDecorator = dec;
1696 
1697  dec->SetDebugEnabled( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics );
1698 
1699  if( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
1700  dec->SetView( m_view );
1701 }
currently selected items overlay
Definition: layer_ids.h:215
PNS::DEBUG_DECORATOR * m_debugDecorator
void SetDebugEnabled(bool aEnabled)
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:192
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:98
KIGFX::VIEW * m_view
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:320

References KIGFX::VIEW::Add(), KIGFX::VIEW_GROUP::FreeItems(), ADVANCED_CFG::GetCfg(), LAYER_SELECT_OVERLAY, PNS_KICAD_IFACE_BASE::m_debugDecorator, m_previewItems, m_view, PNS::DEBUG_DECORATOR::SetDebugEnabled(), 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 587 of file pns_kicad_iface.cpp.

588 {
590  return 0;
591 
593 
594  return stackup.GetLayerDistance( ToLAYER_ID( aFirstLayer ), ToLAYER_ID( aSecondLayer ) );
595 }
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.cpp:590
BOARD_STACKUP & GetStackupDescriptor()
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
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, 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 990 of file pns_kicad_iface.cpp.

991 {
992  auto arc = std::make_unique<PNS::ARC>(
993  SHAPE_ARC( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), aArc->GetWidth() ),
994  aArc->GetNetCode() );
995 
996  arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
997  arc->SetParent( aArc );
998 
999  if( aArc->IsLocked() )
1000  arc->Mark( PNS::MK_LOCKED );
1001 
1002  return arc;
1003 }
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
int GetWidth() const
Definition: pcb_track.h:102
virtual bool IsLocked() const
Definition: board_item.cpp:64
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
const wxPoint & GetMid() const
Definition: pcb_track.h:271
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
const wxPoint & GetStart() const
Definition: pcb_track.h:108

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

1157 {
1158  if( aItem->GetLayer() == Edge_Cuts
1159  || aItem->GetLayer() == Margin
1160  || IsCopperLayer( aItem->GetLayer() ) )
1161  {
1162  // TODO: where do we handle filled polygons on copper layers?
1163  if( aItem->GetShape() == SHAPE_T::POLY && aItem->IsFilled() )
1164  return false;
1165 
1166  std::vector<SHAPE*> shapes = aItem->MakeEffectiveShapes();
1167 
1168  for( SHAPE* shape : shapes )
1169  {
1170  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1171 
1172  if( aItem->GetLayer() == Edge_Cuts || aItem->GetLayer() == Margin )
1173  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
1174  else
1175  solid->SetLayer( aItem->GetLayer() );
1176 
1177  if( aItem->GetLayer() == Edge_Cuts )
1178  {
1179  switch( shape->Type() )
1180  {
1181  case SH_SEGMENT: static_cast<SHAPE_SEGMENT*>( shape )->SetWidth( 0 ); break;
1182  case SH_ARC: static_cast<SHAPE_ARC*>( shape )->SetWidth( 0 ); break;
1183  case SH_LINE_CHAIN: static_cast<SHAPE_LINE_CHAIN*>( shape )->SetWidth( 0 ); break;
1184  default: /* remaining shapes don't have width */ break;
1185  }
1186  }
1187 
1188  solid->SetNet( -1 );
1189  solid->SetParent( aItem );
1190  solid->SetShape( shape ); // takes ownership
1191 
1192  if( shapes.size() > 1 )
1193  solid->SetIsCompoundShapePrimitive();
1194 
1195  solid->SetRoutable( false );
1196 
1197  aWorld->Add( std::move( solid ) );
1198  }
1199 
1200  return true;
1201  }
1202 
1203  return false;
1204 }
std::vector< SHAPE * > MakeEffectiveShapes() const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1057
bool IsFilled() const
Definition: eda_shape.h:81
circular arc
Definition: shape.h:50
An abstract shape on 2D plane.
Definition: shape.h:116
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:797
Definition: layer_ids.h:71
line chain (polyline)
Definition: shape.h:45
SHAPE_T GetShape() const
Definition: eda_shape.h:92
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:639
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(), EDA_SHAPE::GetShape(), IsCopperLayer(), EDA_SHAPE::IsFilled(), EDA_SHAPE::MakeEffectiveShapes(), Margin, POLY, 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 878 of file pns_kicad_iface.cpp.

879 {
880  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
881 
882  // ignore non-copper pads except for those with holes
883  if( ( aPad->GetLayerSet() & LSET::AllCuMask() ).none() && aPad->GetDrillSize().x == 0 )
884  return nullptr;
885 
886  switch( aPad->GetAttribute() )
887  {
888  case PAD_ATTRIB::PTH:
889  case PAD_ATTRIB::NPTH:
890  break;
891 
892  case PAD_ATTRIB::CONN:
893  case PAD_ATTRIB::SMD:
894  {
895  LSET lmsk = aPad->GetLayerSet();
896  bool is_copper = false;
897 
898  for( int i = 0; i < MAX_CU_LAYERS; i++ )
899  {
900  if( lmsk[i] )
901  {
902  is_copper = true;
903 
904  if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
905  layers = LAYER_RANGE( i );
906 
907  break;
908  }
909  }
910 
911  if( !is_copper )
912  return nullptr;
913 
914  break;
915  }
916 
917  default:
918  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
919  return nullptr;
920  }
921 
922  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
923 
924  if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
925  solid->SetRoutable( false );
926 
927  solid->SetLayers( layers );
928  solid->SetNet( aPad->GetNetCode() );
929  solid->SetParent( aPad );
930  solid->SetPadToDie( aPad->GetPadToDieLength() );
931  solid->SetOrientation( aPad->GetOrientation() );
932 
933  wxPoint wx_c = aPad->ShapePos();
934  wxPoint offset = aPad->GetOffset();
935 
936  VECTOR2I c( wx_c.x, wx_c.y );
937 
938  RotatePoint( &offset, aPad->GetOrientation() );
939 
940  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
941  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
942 
943  if( aPad->GetDrillSize().x > 0 )
944  {
946 
947  if( aPad->GetAttribute() != PAD_ATTRIB::NPTH )
948  {
950  slot->SetWidth( slot->GetWidth() + bds.GetHolePlatingThickness() * 2 );
951  }
952 
953  solid->SetHole( slot );
954  }
955 
956  std::shared_ptr<SHAPE> shape = aPad->GetEffectiveShape();
957 
958  if( shape->HasIndexableSubshapes() && shape->GetIndexableSubshapeCount() == 1 )
959  {
960  std::vector<SHAPE*> subshapes;
961  shape->GetIndexableSubshapes( subshapes );
962 
963  solid->SetShape( subshapes[0]->Clone() );
964  }
965  else
966  {
967  solid->SetShape( shape->Clone() );
968  }
969 
970  return solid;
971 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
int GetHolePlatingThickness() const
Pad & via drills are finish size.
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Return a SHAPE object representing the pad's hole.
Definition: pad.cpp:295
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
Plated through hole pad.
const wxPoint & GetOffset() const
Definition: pad.h:250
const wxSize & GetDrillSize() const
Definition: pad.h:243
wxPoint ShapePos() const
Definition: pad.cpp:665
like PAD_PTH, but not plated
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
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
#define MAX_CU_LAYERS
Definition: layer_ids.h:147
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:286
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:368
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:271
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
Definition: shape_segment.h:57
PAD_ATTRIB GetAttribute() const
Definition: pad.h:371
int GetWidth() const
int GetPadToDieLength() const
Definition: pad.h:384
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_SEGMENT::Clone(), 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(), 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 1105 of file pns_kicad_iface.cpp.

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

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 ( PCB_TRACK aTrack)
protectedinherited

Definition at line 974 of file pns_kicad_iface.cpp.

975 {
976  auto segment = std::make_unique<PNS::SEGMENT>( SEG( aTrack->GetStart(), aTrack->GetEnd() ),
977  aTrack->GetNetCode() );
978 
979  segment->SetWidth( aTrack->GetWidth() );
980  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
981  segment->SetParent( aTrack );
982 
983  if( aTrack->IsLocked() )
984  segment->Mark( PNS::MK_LOCKED );
985 
986  return segment;
987 }
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
int GetWidth() const
Definition: pcb_track.h:102
virtual bool IsLocked() const
Definition: board_item.cpp:64
Definition: seg.h:40
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
const wxPoint & GetStart() const
Definition: pcb_track.h:108

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

1007 {
1008  PCB_LAYER_ID top, bottom;
1009  aVia->LayerPair( &top, &bottom );
1010 
1011  auto via = std::make_unique<PNS::VIA>( aVia->GetPosition(),
1012  LAYER_RANGE( aVia->TopLayer(), aVia->BottomLayer() ),
1013  aVia->GetWidth(),
1014  aVia->GetDrillValue(),
1015  aVia->GetNetCode(),
1016  aVia->GetViaType() );
1017 
1018  via->SetParent( aVia );
1019 
1020  if( aVia->IsLocked() )
1021  via->Mark( PNS::MK_LOCKED );
1022 
1023  via->SetIsFree( aVia->GetIsFree() );
1024 
1026  via->SetHole( SHAPE_CIRCLE( aVia->GetPosition(),
1027  aVia->GetDrillValue() / 2 + bds.GetHolePlatingThickness() ) );
1028 
1029  return via;
1030 }
wxPoint GetPosition() const override
Definition: pcb_track.h:390
VIATYPE GetViaType() const
Definition: pcb_track.h:352
int GetHolePlatingThickness() const
Pad & via drills are finish size.
int GetWidth() const
Definition: pcb_track.h:102
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:462
virtual bool IsLocked() const
Definition: board_item.cpp:64
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:456
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:434
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:481
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:166
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
Container for design settings for a BOARD object.

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

1291 {
1292  if( !m_board )
1293  {
1294  wxLogTrace( "PNS", "No board attached, aborting sync." );
1295  return;
1296  }
1297 
1298  int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1299 
1300  m_world = aWorld;
1301 
1302  for( BOARD_ITEM* gitem : m_board->Drawings() )
1303  {
1304  if ( gitem->Type() == PCB_SHAPE_T )
1305  {
1306  syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( gitem ) );
1307  }
1308  else if( gitem->Type() == PCB_TEXT_T )
1309  {
1310  syncTextItem( aWorld, static_cast<PCB_TEXT*>( gitem ), gitem->GetLayer() );
1311  }
1312  }
1313 
1314  SHAPE_POLY_SET buffer;
1315  SHAPE_POLY_SET* boardOutline = nullptr;
1316 
1317  if( m_board->GetBoardPolygonOutlines( buffer ) )
1318  boardOutline = &buffer;
1319 
1320  for( ZONE* zone : m_board->Zones() )
1321  {
1322  syncZone( aWorld, zone, boardOutline );
1323  }
1324 
1325  for( FOOTPRINT* footprint : m_board->Footprints() )
1326  {
1327  for( PAD* pad : footprint->Pads() )
1328  {
1329  if( std::unique_ptr<PNS::SOLID> solid = syncPad( pad ) )
1330  aWorld->Add( std::move( solid ) );
1331 
1332  worstClearance = std::max( worstClearance, pad->GetLocalClearance() );
1333  }
1334 
1335  syncTextItem( aWorld, &footprint->Reference(), footprint->Reference().GetLayer() );
1336  syncTextItem( aWorld, &footprint->Value(), footprint->Value().GetLayer() );
1337 
1338  for( FP_ZONE* zone : footprint->Zones() )
1339  syncZone( aWorld, zone, boardOutline );
1340 
1341  if( footprint->IsNetTie() )
1342  continue;
1343 
1344  for( BOARD_ITEM* mgitem : footprint->GraphicalItems() )
1345  {
1346  if( mgitem->Type() == PCB_FP_SHAPE_T )
1347  {
1348  syncGraphicalItem( aWorld, static_cast<PCB_SHAPE*>( mgitem ) );
1349  }
1350  else if( mgitem->Type() == PCB_FP_TEXT_T )
1351  {
1352  syncTextItem( aWorld, static_cast<FP_TEXT*>( mgitem ), mgitem->GetLayer() );
1353  }
1354  }
1355  }
1356 
1357  for( PCB_TRACK* t : m_board->Tracks() )
1358  {
1359  KICAD_T type = t->Type();
1360 
1361  if( type == PCB_TRACE_T )
1362  {
1363  if( auto segment = syncTrack( t ) )
1364  aWorld->Add( std::move( segment ) );
1365  }
1366  else if( type == PCB_ARC_T )
1367  {
1368  if( auto arc = syncArc( static_cast<PCB_ARC*>( t ) ) )
1369  aWorld->Add( std::move( arc ) );
1370  }
1371  else if( type == PCB_VIA_T )
1372  {
1373  if( auto via = syncVia( static_cast<PCB_VIA*>( t ) ) )
1374  aWorld->Add( std::move( via ) );
1375  }
1376  }
1377 
1378  // NB: if this were ever to become a long-lived object we would need to dirty its
1379  // clearance cache here....
1380  delete m_ruleResolver;
1382 
1383  aWorld->SetRuleResolver( m_ruleResolver );
1384  aWorld->SetMaxClearance( worstClearance + m_ruleResolver->ClearanceEpsilon() );
1385 }
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
std::unique_ptr< PNS::SEGMENT > syncTrack(PCB_TRACK *aTrack)
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:1880
ZONES & Zones()
Definition: board.h:240
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:49
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
void SetRuleResolver(RULE_RESOLVER *aFunc)
Definition: pns_node.h:174
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_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:168
std::unique_ptr< PNS::VIA > syncVia(PCB_VIA *aVia)
Represent a set of closed polygons.
FOOTPRINTS & Footprints()
Definition: board.h:234
std::unique_ptr< PNS::ARC > syncArc(PCB_ARC *aArc)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
Definition: pad.h:57
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
DRAWINGS & Drawings()
Definition: board.h:237
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:639
A specialization of ZONE for use in footprints.
Definition: zone.h:945
TRACKS & Tracks()
Definition: board.h:231
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 1033 of file pns_kicad_iface.cpp.

1034 {
1035  SHAPE_POLY_SET* poly;
1036 
1037  if( !aZone->GetIsRuleArea() && aZone->GetZoneName().IsEmpty() )
1038  return false;
1039 
1040  // Required by expression function insideArea()
1041  aZone->CacheBoundingBox();
1042 
1043  // TODO handle aZone->GetDoNotAllowVias()
1044  // TODO handle rules which disallow tracks & vias
1045  if( !aZone->GetIsRuleArea() || !aZone->GetDoNotAllowTracks() )
1046  return false;
1047 
1048  LSET layers = aZone->GetLayerSet();
1049  EDA_UNITS units = EDA_UNITS::MILLIMETRES; // TODO: get real units
1050 
1051  poly = aZone->Outline();
1052  poly->CacheTriangulation( false );
1053 
1054  if( !poly->IsTriangulationUpToDate() )
1055  {
1056  KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ),
1057  aZone->GetSelectMenuText( units ) ),
1059  dlg.ShowDetailedText( wxString::Format( _( "This zone cannot be handled by the router.\n"
1060  "Please verify it is not a self-intersecting "
1061  "polygon." ) ) );
1062  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1063  dlg.ShowModal();
1064 
1065  return false;
1066  }
1067 
1068  for( int layer = F_Cu; layer <= B_Cu; layer++ )
1069  {
1070  if( !layers[ layer ] )
1071  continue;
1072 
1073  for( int outline = 0; outline < poly->OutlineCount(); outline++ )
1074  {
1075  const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly->TriangulatedPolygon( outline );
1076 
1077  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
1078  {
1079  VECTOR2I a, b, c;
1080  tri->GetTriangle( i, a, b, c );
1081  SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
1082 
1083  triShape->Append( a );
1084  triShape->Append( b );
1085  triShape->Append( c );
1086 
1087  std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
1088 
1089  solid->SetLayer( layer );
1090  solid->SetNet( -1 );
1091  solid->SetParent( aZone );
1092  solid->SetShape( triShape );
1093  solid->SetIsCompoundShapePrimitive();
1094  solid->SetRoutable( false );
1095 
1096  aWorld->Add( std::move( solid ) );
1097  }
1098  }
1099  }
1100 
1101  return true;
1102 }
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:41
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:733
void GetTriangle(int index, VECTOR2I &a, VECTOR2I &b, VECTOR2I &c) const
SHAPE_POLY_SET * Outline()
Definition: zone.h:320
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:295
bool IsTriangulationUpToDate() const
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
Represent a set of closed polygons.
bool GetDoNotAllowTracks() const
Definition: zone.h:736
#define _(s)
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
Definition: layer_ids.h:71
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:870
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:639
void Append(int aX, int aY)
Append a new point at the end of the polygon.
Definition: shape_simple.h:135

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

1508 {
1509  BOARD_ITEM* board_item = aItem->Parent();
1510 
1511  m_commit->Modify( board_item );
1512 
1513  switch( aItem->Kind() )
1514  {
1515  case PNS::ITEM::ARC_T:
1516  {
1517  PNS::ARC* arc = static_cast<PNS::ARC*>( aItem );
1518  PCB_ARC* arc_board = static_cast<PCB_ARC*>( board_item );
1519  const SHAPE_ARC* arc_shape = static_cast<const SHAPE_ARC*>( arc->Shape() );
1520  arc_board->SetStart( wxPoint( arc_shape->GetP0() ) );
1521  arc_board->SetEnd( wxPoint( arc_shape->GetP1() ) );
1522  arc_board->SetMid( wxPoint( arc_shape->GetArcMid() ) );
1523  arc_board->SetWidth( arc->Width() );
1524  break;
1525  }
1526 
1527  case PNS::ITEM::SEGMENT_T:
1528  {
1529  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1530  PCB_TRACK* track = static_cast<PCB_TRACK*>( board_item );
1531  const SEG& s = seg->Seg();
1532  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1533  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1534  track->SetWidth( seg->Width() );
1535  break;
1536  }
1537 
1538  case PNS::ITEM::VIA_T:
1539  {
1540  PCB_VIA* via_board = static_cast<PCB_VIA*>( board_item );
1541  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1542  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1543  via_board->SetWidth( via->Diameter() );
1544  via_board->SetDrill( via->Drill() );
1545  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1546  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1547  via_board->SetIsFree( via->IsFree() );
1548  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1549  ToLAYER_ID( via->Layers().End() ) );
1550  break;
1551  }
1552 
1553  case PNS::ITEM::SOLID_T:
1554  {
1555  PAD* pad = static_cast<PAD*>( aItem->Parent() );
1556  VECTOR2I pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1557 
1558  m_fpOffsets[ pad ].p_old = pad->GetPosition();
1559  m_fpOffsets[ pad ].p_new = pos;
1560  break;
1561  }
1562 
1563  default:
1564  break;
1565  }
1566 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: pcb_track.h:453
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
int Width() const override
Definition: pns_arc.h:87
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: pcb_track.cpp:413
int Width() const override
Definition: pns_segment.h:79
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetPosition(const wxPoint &aPoint) override
Definition: pcb_track.h:391
BOARD_ITEM * Parent() const
Definition: pns_item.h:149
const SEG & Seg() const
Definition: pns_segment.h:84
std::unique_ptr< BOARD_COMMIT > m_commit
void SetMid(const wxPoint &aMid)
Definition: pcb_track.h:270
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:113
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:353
Definition: seg.h:40
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_arc.h:77
void SetWidth(int aWidth)
Definition: pcb_track.h:101
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:482
VECTOR2I A
Definition: seg.h:48
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:130
Definition: pad.h:57
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:112
VECTOR2I B
Definition: seg.h:49

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, PCB_VIA::SetDrill(), PCB_TRACK::SetEnd(), PCB_VIA::SetIsFree(), PCB_VIA::SetLayerPair(), PCB_ARC::SetMid(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_VIA::SetPosition(), PCB_TRACK::SetStart(), PCB_VIA::SetViaType(), PCB_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 1704 of file pns_kicad_iface.cpp.

1705 {
1706  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1707 
1708 }

Member Data Documentation

◆ m_board

◆ m_commit

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

Definition at line 146 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 147 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 140 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 143 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_startLayer

int PNS_KICAD_IFACE_BASE::m_startLayer
protectedinherited

◆ m_tool

PCB_TOOL_BASE* PNS_KICAD_IFACE::m_tool
private

Definition at line 145 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: