KiCad PCB EDA Suite
PNS_KICAD_IFACE_BASE Class Reference

#include <pns_kicad_iface.h>

Inheritance diagram for PNS_KICAD_IFACE_BASE:
PNS::ROUTER_IFACE PNS_KICAD_IFACE

Public Member Functions

 PNS_KICAD_IFACE_BASE ()
 
 ~PNS_KICAD_IFACE_BASE ()
 
void SetRouter (PNS::ROUTER *aRouter) override
 
void SetHostTool (PCB_TOOL_BASE *aTool)
 
void SetDisplayOptions (const PCB_DISPLAY_OPTIONS *aDispOptions)
 
void EraseView () override
 
void SetBoard (BOARD *aBoard)
 
void SyncWorld (PNS::NODE *aWorld) override
 
bool IsAnyLayerVisible (const LAYER_RANGE &aLayer) override
 
bool IsItemVisible (const PNS::ITEM *aItem) override
 
void HideItem (PNS::ITEM *aItem) override
 
void DisplayItem (const PNS::ITEM *aItem, int aColor=0, int aClearance=0, bool aEdit=false) override
 
void AddItem (PNS::ITEM *aItem) override
 
void RemoveItem (PNS::ITEM *aItem) override
 
void Commit () override
 
void UpdateNet (int aNetCode) override
 
void SetDebugDecorator (PNS::DEBUG_DECORATOR *aDec)
 
PNS::RULE_RESOLVERGetRuleResolver () override
 
PNS::DEBUG_DECORATORGetDebugDecorator () override
 

Protected Member Functions

std::unique_ptr< PNS::SOLIDsyncPad (D_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, DRAWSEGMENT *aItem)
 
bool syncZone (PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
 

Protected Attributes

PNS_PCBNEW_RULE_RESOLVERm_ruleResolver
 
PNS::DEBUG_DECORATORm_debugDecorator
 
PNS::ROUTERm_router
 
BOARDm_board
 

Detailed Description

Definition at line 44 of file pns_kicad_iface.h.

Constructor & Destructor Documentation

◆ PNS_KICAD_IFACE_BASE()

PNS_KICAD_IFACE_BASE::PNS_KICAD_IFACE_BASE ( )

Definition at line 534 of file pns_kicad_iface.cpp.

535 {
536  m_ruleResolver = nullptr;
537  m_board = nullptr;
538  m_router = nullptr;
539  m_debugDecorator = nullptr;
540  m_router = nullptr;
541 }
PNS::DEBUG_DECORATOR * m_debugDecorator
PNS::ROUTER * m_router
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References m_board, m_debugDecorator, m_router, and m_ruleResolver.

◆ ~PNS_KICAD_IFACE_BASE()

PNS_KICAD_IFACE_BASE::~PNS_KICAD_IFACE_BASE ( )

Definition at line 553 of file pns_kicad_iface.cpp.

554 {
555  delete m_ruleResolver;
556  delete m_debugDecorator;
557 }
PNS::DEBUG_DECORATOR * m_debugDecorator
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References m_debugDecorator, and m_ruleResolver.

Member Function Documentation

◆ AddItem()

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

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 1120 of file pns_kicad_iface.cpp.

1121 {
1122 
1123 }

◆ Commit()

void PNS_KICAD_IFACE_BASE::Commit ( )
inlineoverridevirtual

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 62 of file pns_kicad_iface.h.

62 {}

◆ DisplayItem()

void PNS_KICAD_IFACE_BASE::DisplayItem ( const PNS::ITEM aItem,
int  aColor = 0,
int  aClearance = 0,
bool  aEdit = false 
)
inlineoverridevirtual

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 59 of file pns_kicad_iface.h.

59 {}

◆ EraseView()

void PNS_KICAD_IFACE_BASE::EraseView ( )
inlineoverridevirtual

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 53 of file pns_kicad_iface.h.

53 {};

◆ GetDebugDecorator()

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

Implements PNS::ROUTER_IFACE.

Definition at line 528 of file pns_kicad_iface.cpp.

529 {
530  return m_debugDecorator;
531 }
PNS::DEBUG_DECORATOR * m_debugDecorator

References m_debugDecorator.

◆ GetRuleResolver()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1258 of file pns_kicad_iface.cpp.

1259 {
1260  return m_ruleResolver;
1261 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References m_ruleResolver.

◆ HideItem()

void PNS_KICAD_IFACE_BASE::HideItem ( PNS::ITEM aItem)
inlineoverridevirtual

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 58 of file pns_kicad_iface.h.

58 {}

◆ IsAnyLayerVisible()

bool PNS_KICAD_IFACE_BASE::IsAnyLayerVisible ( const LAYER_RANGE aLayer)
inlineoverridevirtual

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 56 of file pns_kicad_iface.h.

56 { return true; };

◆ IsItemVisible()

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

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 57 of file pns_kicad_iface.h.

57 { return true; }

◆ RemoveItem()

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

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 1094 of file pns_kicad_iface.cpp.

1095 {
1096 
1097 }

◆ SetBoard()

void PNS_KICAD_IFACE_BASE::SetBoard ( BOARD aBoard)

Definition at line 862 of file pns_kicad_iface.cpp.

863 {
864  m_board = aBoard;
865  wxLogTrace( "PNS", "m_board = %p", m_board );
866 }

References m_board.

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

◆ SetDebugDecorator()

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

Definition at line 1031 of file pns_kicad_iface.cpp.

1032 {
1033  m_debugDecorator = aDec;
1034 }
PNS::DEBUG_DECORATOR * m_debugDecorator

References m_debugDecorator.

◆ SetDisplayOptions()

void PNS_KICAD_IFACE_BASE::SetDisplayOptions ( const PCB_DISPLAY_OPTIONS aDispOptions)

◆ SetHostTool()

void PNS_KICAD_IFACE_BASE::SetHostTool ( PCB_TOOL_BASE aTool)

◆ SetRouter()

void PNS_KICAD_IFACE_BASE::SetRouter ( PNS::ROUTER aRouter)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1264 of file pns_kicad_iface.cpp.

1265 {
1266  m_router = aRouter;
1267 }
PNS::ROUTER * m_router

References m_router.

◆ syncArc()

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

Definition at line 672 of file pns_kicad_iface.cpp.

673 {
674  std::unique_ptr< PNS::ARC > arc(
675  new PNS::ARC( SHAPE_ARC( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(),
676  aArc->GetWidth() ), aArc->GetNetCode() )
677  );
678 
679  arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
680  arc->SetParent( aArc );
681 
682  if( aArc->IsLocked() )
683  arc->Mark( PNS::MK_LOCKED );
684 
685  return arc;
686 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:138
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:118
const wxPoint & GetMid() const
Definition: class_track.h:293
int GetWidth() const
Definition: class_track.h:112
const wxPoint & GetEnd() const
Definition: class_track.h:115
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
LAYER_RANGE.
Definition: pns_layerset.h:32

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

Referenced by SyncWorld().

◆ syncGraphicalItem()

bool PNS_KICAD_IFACE_BASE::syncGraphicalItem ( PNS::NODE aWorld,
DRAWSEGMENT aItem 
)
protected

Definition at line 832 of file pns_kicad_iface.cpp.

833 {
834  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
835  return false;
836 
837  // TODO: where do we handle filled polygons on copper layers?
838  if( aItem->GetShape() == S_POLYGON && aItem->IsPolygonFilled() )
839  return false;
840 
841  for( SHAPE* shape : aItem->MakeEffectiveShapes() )
842  {
843  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
844 
845  if( aItem->GetLayer() == Edge_Cuts )
846  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
847  else
848  solid->SetLayer( aItem->GetLayer() );
849 
850  solid->SetNet( -1 );
851  solid->SetParent( nullptr );
852  solid->SetShape( shape );
853  solid->SetRoutable( false );
854 
855  aWorld->Add( std::move( solid ) );
856  }
857 
858  return true;
859 }
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
std::vector< SHAPE * > MakeEffectiveShapes()
Makes a set of SHAPE objects representing the DRAWSEGMENT.
SHAPE.
Definition: shape.h:74
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620
LAYER_RANGE.
Definition: pns_layerset.h:32

References PNS::NODE::Add(), B_Cu, Edge_Cuts, F_Cu, BOARD_ITEM::GetLayer(), DRAWSEGMENT::GetShape(), IsCopperLayer(), DRAWSEGMENT::IsPolygonFilled(), DRAWSEGMENT::MakeEffectiveShapes(), and S_POLYGON.

Referenced by SyncWorld().

◆ syncPad()

std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE_BASE::syncPad ( D_PAD aPad)
protected

Definition at line 570 of file pns_kicad_iface.cpp.

571 {
572  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
573 
574  // ignore non-copper pads
575  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
576  return NULL;
577 
578  switch( aPad->GetAttribute() )
579  {
580  case PAD_ATTRIB_STANDARD:
581  break;
582 
583  case PAD_ATTRIB_SMD:
585  case PAD_ATTRIB_CONN:
586  {
587  LSET lmsk = aPad->GetLayerSet();
588  bool is_copper = false;
589 
590  for( int i = 0; i < MAX_CU_LAYERS; i++ )
591  {
592  if( lmsk[i] )
593  {
594  is_copper = true;
595 
597  layers = LAYER_RANGE( i );
598 
599  break;
600  }
601  }
602 
603  if( !is_copper )
604  return NULL;
605  }
606  break;
607 
608  default:
609  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
610  return NULL;
611  }
612 
613  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
614 
615  solid->SetLayers( layers );
616  solid->SetNet( aPad->GetNetCode() );
617  solid->SetParent( aPad );
618  solid->SetPadToDie( aPad->GetPadToDieLength() );
619 
620  wxPoint wx_c = aPad->ShapePos();
621  wxSize wx_sz = aPad->GetSize();
622  wxPoint offset = aPad->GetOffset();
623 
624  VECTOR2I c( wx_c.x, wx_c.y );
625 
626  RotatePoint( &offset, aPad->GetOrientation() );
627 
628  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
629  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
630 
631  if( aPad->GetEffectiveShapes().size() == 1 )
632  {
633  solid->SetShape( aPad->GetEffectiveShapes()[0]->Clone() );
634  }
635  else
636  {
637  // JEY TODO:
638  // TOM TODO: move to SHAPE_COMPOUND...
639 
640  SHAPE_POLY_SET outline;
641  aPad->TransformShapeWithClearanceToPolygon( outline, 0 );
642 
643  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
644 
645  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
646  shape->Append( *iter );
647 
648  solid->SetShape( shape );
649  }
650 
651  return solid;
652 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
SHAPE_SIMPLE.
Definition: shape_simple.h:42
int GetNetCode() const
Function GetNetCode.
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
int GetPadToDieLength() const
Definition: class_pad.h:338
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const std::vector< std::shared_ptr< SHAPE > > & GetEffectiveShapes() const
Function GetEffectiveShapes Some pad shapes can be complex (rounded/chamfered rectangle),...
Definition: class_pad.cpp:194
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:328
LSET is a set of PCB_LAYER_IDs.
#define NULL
SHAPE_POLY_SET.
const wxPoint & GetOffset() const
Definition: class_pad.h:230
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:325
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, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:315
wxPoint ShapePos() const
Definition: class_pad.cpp:491
const wxSize & GetSize() const
Definition: class_pad.h:221
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:144
LAYER_RANGE.
Definition: pns_layerset.h:32

References LSET::AllCuMask(), SHAPE_SIMPLE::Append(), SHAPE_POLY_SET::CIterate(), D_PAD::GetAttribute(), D_PAD::GetEffectiveShapes(), D_PAD::GetLayerSet(), BOARD_CONNECTED_ITEM::GetNetCode(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetPadToDieLength(), D_PAD::GetSize(), MAX_CU_LAYERS, NULL, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PAD_ATTRIB_STANDARD, RotatePoint(), D_PAD::ShapePos(), D_PAD::TransformShapeWithClearanceToPolygon(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by SyncWorld().

◆ syncTextItem()

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

Definition at line 780 of file pns_kicad_iface.cpp.

781 {
782  if( !IsCopperLayer( aLayer ) )
783  return false;
784 
785  int textWidth = aText->GetEffectiveTextPenWidth();
786  std::vector<wxPoint> textShape;
787 
788  aText->TransformTextShapeToSegmentList( textShape );
789 
790  if( textShape.size() < 2 )
791  return false;
792 
793  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
794  {
795  VECTOR2I start( textShape[jj] );
796  VECTOR2I end( textShape[jj+1] );
797  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
798 
799  solid->SetLayer( aLayer );
800  solid->SetNet( -1 );
801  solid->SetParent( nullptr );
802  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
803  solid->SetRoutable( false );
804 
805  aWorld->Add( std::move( solid ) );
806  }
807 
808  return true;
809 
810  /* A coarser (but faster) method:
811  *
812  SHAPE_POLY_SET outline;
813  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
814 
815  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
816 
817  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
818  shape->Append( *iter );
819 
820  solid->SetShape( shape );
821 
822  solid->SetLayer( aLayer );
823  solid->SetNet( -1 );
824  solid->SetParent( nullptr );
825  solid->SetRoutable( false );
826  aWorld->Add( std::move( solid ) );
827  return true;
828  */
829 }
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:578
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620

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

Referenced by SyncWorld().

◆ syncTrack()

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

Definition at line 655 of file pns_kicad_iface.cpp.

656 {
657  std::unique_ptr< PNS::SEGMENT > segment(
658  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
659  );
660 
661  segment->SetWidth( aTrack->GetWidth() );
662  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
663  segment->SetParent( aTrack );
664 
665  if( aTrack->IsLocked() )
666  segment->Mark( PNS::MK_LOCKED );
667 
668  return segment;
669 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:138
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:118
Definition: seg.h:39
int GetWidth() const
Definition: class_track.h:112
const wxPoint & GetEnd() const
Definition: class_track.h:115
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
LAYER_RANGE.
Definition: pns_layerset.h:32

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

Referenced by SyncWorld().

◆ syncVia()

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

Definition at line 689 of file pns_kicad_iface.cpp.

690 {
691  PCB_LAYER_ID top, bottom;
692  aVia->LayerPair( &top, &bottom );
693  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
694  aVia->GetPosition(),
695  LAYER_RANGE( top, bottom ),
696  aVia->GetWidth(),
697  aVia->GetDrillValue(),
698  aVia->GetNetCode(),
699  aVia->GetViaType() )
700  );
701 
702  via->SetParent( aVia );
703 
704  if( aVia->IsLocked() )
705  via->Mark( PNS::MK_LOCKED );
706 
707  return via;
708 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:138
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...
int GetNetCode() const
Function GetNetCode.
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 ...
int GetWidth() const
Definition: class_track.h:112
VIATYPE GetViaType() const
Definition: class_track.h:373
wxPoint GetPosition() const override
Definition: class_track.h:411
LAYER_RANGE.
Definition: pns_layerset.h:32

References VIA::GetDrillValue(), BOARD_CONNECTED_ITEM::GetNetCode(), VIA::GetPosition(), VIA::GetViaType(), TRACK::GetWidth(), TRACK::IsLocked(), VIA::LayerPair(), and PNS::MK_LOCKED.

Referenced by SyncWorld().

◆ SyncWorld()

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

Implements PNS::ROUTER_IFACE.

Definition at line 924 of file pns_kicad_iface.cpp.

925 {
926  int worstPadClearance = 0;
927 
928  if( !m_board )
929  {
930  wxLogTrace( "PNS", "No board attached, aborting sync." );
931  return;
932  }
933 
934  for( auto gitem : m_board->Drawings() )
935  {
936  if ( gitem->Type() == PCB_LINE_T )
937  {
938  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
939  }
940  else if( gitem->Type() == PCB_TEXT_T )
941  {
942  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
943  }
944  }
945 
946  for( auto zone : m_board->Zones() )
947  {
948  syncZone( aWorld, zone );
949  }
950 
951  for( auto module : m_board->Modules() )
952  {
953  for( auto pad : module->Pads() )
954  {
955  if( auto solid = syncPad( pad ) )
956  aWorld->Add( std::move( solid ) );
957 
958  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
959  }
960 
961  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
962  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
963 
964  for( MODULE_ZONE_CONTAINER* zone : module->Zones() )
965  syncZone( aWorld, zone );
966 
967  if( module->IsNetTie() )
968  continue;
969 
970  for( auto mgitem : module->GraphicalItems() )
971  {
972  if( mgitem->Type() == PCB_MODULE_EDGE_T )
973  {
974  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
975  }
976  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
977  {
978  syncTextItem( aWorld, static_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
979  }
980  }
981  }
982 
983  for( auto t : m_board->Tracks() )
984  {
985  KICAD_T type = t->Type();
986 
987  if( type == PCB_TRACE_T )
988  {
989  if( auto segment = syncTrack( t ) )
990  aWorld->Add( std::move( segment ) );
991  }
992  else if( type == PCB_ARC_T )
993  {
994  if( auto arc = syncArc( static_cast<ARC*>( t ) ) )
995  aWorld->Add( std::move( arc ) );
996  }
997  else if( type == PCB_VIA_T )
998  {
999  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1000  aWorld->Add( std::move( via ) );
1001  }
1002  }
1003 
1004  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1005 
1006  delete m_ruleResolver;
1008 
1009  aWorld->SetRuleResolver( m_ruleResolver );
1010  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1011 }
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:171
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:165
MODULES & Modules()
Definition: class_board.h:266
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
PNS::ROUTER * m_router
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
std::unique_ptr< PNS::ARC > syncArc(ARC *aArc)
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
MODULE_ZONE_CONTAINER is the same item as ZONE_CONTAINER, but with a specific type id ZONE_CONTAINER ...
Definition: class_zone.h:952
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
DRAWINGS & Drawings()
Definition: class_board.h:275
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620
TRACKS & Tracks()
Definition: class_board.h:257
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)

References PNS::NODE::Add(), BOARD::Drawings(), BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue(), BOARD::GetDesignSettings(), m_board, m_router, m_ruleResolver, BOARD::Modules(), PCB_ARC_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PNS::NODE::SetMaxClearance(), PNS::NODE::SetRuleResolver(), syncArc(), syncGraphicalItem(), syncPad(), syncTextItem(), syncTrack(), syncVia(), syncZone(), BOARD::Tracks(), and BOARD::Zones().

◆ syncZone()

bool PNS_KICAD_IFACE_BASE::syncZone ( PNS::NODE aWorld,
ZONE_CONTAINER aZone 
)
protected

Definition at line 711 of file pns_kicad_iface.cpp.

712 {
713  SHAPE_POLY_SET poly;
714 
715  // TODO handle no-via restriction
716  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
717  return false;
718 
719  // Some intersecting zones, despite being on the same layer with the same net, cannot be
720  // merged due to other parameters such as fillet radius. The copper pour will end up
721  // effectively merged though, so we want to keep the corners of such intersections sharp.
722  std::set<VECTOR2I> colinearCorners;
723  aZone->GetColinearCorners( m_board, colinearCorners );
724 
725  aZone->BuildSmoothedPoly( poly, &colinearCorners );
726  poly.CacheTriangulation();
727 
728  if( !poly.IsTriangulationUpToDate() )
729  {
730  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
731  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
732  dlg.ShowDetailedText(
733  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
734  "Please verify it is not a self-intersecting polygon." ),
736  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
737  dlg.ShowModal();
738 
739  return false;
740  }
741 
742  LSET layers = aZone->GetLayerSet();
743 
744  for( int layer = F_Cu; layer <= B_Cu; layer++ )
745  {
746  if ( ! layers[layer] )
747  continue;
748 
749  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
750  {
751  auto tri = poly.TriangulatedPolygon( outline );
752 
753  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
754  {
755  VECTOR2I a, b, c;
756  tri->GetTriangle( i, a, b, c );
757  auto triShape = new SHAPE_SIMPLE;
758 
759  triShape->Append( a );
760  triShape->Append( b );
761  triShape->Append( c );
762 
763  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
764 
765  solid->SetLayer( layer );
766  solid->SetNet( -1 );
767  solid->SetParent( aZone );
768  solid->SetShape( triShape );
769  solid->SetRoutable( false );
770 
771  aWorld->Add( std::move( solid ) );
772  }
773  }
774  }
775 
776  return true;
777 }
SHAPE_SIMPLE.
Definition: shape_simple.h:42
int OutlineCount() const
Returns the number of outlines in the set
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
bool IsTriangulationUpToDate() const
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:312
void GetColinearCorners(BOARD *aBoard, std::set< VECTOR2I > &colinearCorners)
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
LSET is a set of PCB_LAYER_IDs.
SHAPE_POLY_SET.
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, std::set< VECTOR2I > *aPreserveCorners) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly.
wxPoint GetPosition() const override
Definition: class_zone.cpp:230
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:702
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_zone.cpp:914
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
bool GetDoNotAllowTracks() const
Definition: class_zone.h:705
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:144

References _, PNS::NODE::Add(), SHAPE_SIMPLE::Append(), B_Cu, ZONE_CONTAINER::BuildSmoothedPoly(), SHAPE_POLY_SET::CacheTriangulation(), KIDIALOG::DoNotShowCheckbox(), F_Cu, Format(), ZONE_CONTAINER::GetColinearCorners(), ZONE_CONTAINER::GetDoNotAllowTracks(), ZONE_CONTAINER::GetIsKeepout(), ZONE_CONTAINER::GetLayerSet(), ZONE_CONTAINER::GetPosition(), ZONE_CONTAINER::GetSelectMenuText(), SHAPE_POLY_SET::IsTriangulationUpToDate(), KIDIALOG::KD_WARNING, m_board, MILLIMETRES, SHAPE_POLY_SET::OutlineCount(), KIDIALOG::ShowModal(), SHAPE_POLY_SET::TriangulatedPolygon(), wxPoint::x, and wxPoint::y.

Referenced by SyncWorld().

◆ UpdateNet()

void PNS_KICAD_IFACE_BASE::UpdateNet ( int  aNetCode)
inlineoverridevirtual

Implements PNS::ROUTER_IFACE.

Reimplemented in PNS_KICAD_IFACE.

Definition at line 64 of file pns_kicad_iface.h.

64 {}

Member Data Documentation

◆ m_board

BOARD* PNS_KICAD_IFACE_BASE::m_board
protected

◆ m_debugDecorator

◆ m_router

PNS::ROUTER* PNS_KICAD_IFACE_BASE::m_router
protected

Definition at line 83 of file pns_kicad_iface.h.

Referenced by PNS_KICAD_IFACE_BASE(), SetRouter(), and SyncWorld().

◆ m_ruleResolver

PNS_PCBNEW_RULE_RESOLVER* PNS_KICAD_IFACE_BASE::m_ruleResolver
protected

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