KiCad PCB EDA Suite
PNS_KICAD_IFACE Class Reference

#include <pns_kicad_iface.h>

Inheritance diagram for PNS_KICAD_IFACE:
PNS::ROUTER_IFACE

Public Member Functions

 PNS_KICAD_IFACE ()
 
 ~PNS_KICAD_IFACE ()
 
void SetRouter (PNS::ROUTER *aRouter) override
 
void SetHostTool (PCB_TOOL *aTool)
 
void SetDisplayOptions (PCB_DISPLAY_OPTIONS *aDispOptions)
 
void SetBoard (BOARD *aBoard)
 
void SetView (KIGFX::VIEW *aView)
 
void SyncWorld (PNS::NODE *aWorld) override
 
void EraseView () override
 
void HideItem (PNS::ITEM *aItem) override
 
void DisplayItem (const PNS::ITEM *aItem, int aColor=0, int aClearance=0) override
 
void AddItem (PNS::ITEM *aItem) override
 
void RemoveItem (PNS::ITEM *aItem) override
 
void Commit () override
 
void UpdateNet (int aNetCode) override
 
PNS::RULE_RESOLVERGetRuleResolver () override
 
PNS::DEBUG_DECORATORGetDebugDecorator () override
 

Private Member Functions

std::unique_ptr< PNS::SOLIDsyncPad (D_PAD *aPad)
 
std::unique_ptr< PNS::SEGMENTsyncTrack (TRACK *aTrack)
 
std::unique_ptr< PNS::VIAsyncVia (VIA *aVia)
 

Private Attributes

PNS_PCBNEW_RULE_RESOLVERm_ruleResolver
 
PNS_PCBNEW_DEBUG_DECORATORm_debugDecorator
 
KIGFX::VIEWm_view
 
KIGFX::VIEW_GROUPm_previewItems
 
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
 
PNS::NODEm_world
 
PNS::ROUTERm_router
 
BOARDm_board
 
PCB_TOOLm_tool
 
std::unique_ptr< BOARD_COMMITm_commit
 
PCB_DISPLAY_OPTIONSm_dispOptions
 

Detailed Description

Definition at line 42 of file pns_kicad_iface.h.

Constructor & Destructor Documentation

PNS_KICAD_IFACE::PNS_KICAD_IFACE ( )

Definition at line 470 of file pns_kicad_iface.cpp.

References m_board, m_debugDecorator, m_dispOptions, m_previewItems, m_router, m_ruleResolver, m_tool, m_view, and m_world.

471 {
472  m_ruleResolver = nullptr;
473  m_board = nullptr;
474  m_tool = nullptr;
475  m_view = nullptr;
476  m_previewItems = nullptr;
477  m_world = nullptr;
478  m_router = nullptr;
479  m_debugDecorator = nullptr;
480  m_dispOptions = nullptr;
481 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
PNS::NODE * m_world
PCB_DISPLAY_OPTIONS * m_dispOptions
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
KIGFX::VIEW_GROUP * m_previewItems
PNS::ROUTER * m_router
KIGFX::VIEW * m_view
PCB_TOOL * m_tool
PNS_KICAD_IFACE::~PNS_KICAD_IFACE ( )

Definition at line 484 of file pns_kicad_iface.cpp.

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

485 {
486  delete m_ruleResolver;
487  delete m_debugDecorator;
488 
489  if( m_previewItems )
490  {
492  delete m_previewItems;
493  }
494 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:141
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
KIGFX::VIEW_GROUP * m_previewItems

Member Function Documentation

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

Implements PNS::ROUTER_IFACE.

Definition at line 940 of file pns_kicad_iface.cpp.

References SEG::A, SEG::B, EDA_ITEM::ClearFlags(), PNS::VIA::Diameter(), PNS::VIA::Drill(), LAYER_RANGE::End(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), m_board, m_commit, PNS::ITEM::Net(), PNS::VIA::Pos(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, VIA::SetDrill(), TRACK::SetEnd(), BOARD_ITEM::SetLayer(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::ITEM::SetParent(), VIA::SetPosition(), TRACK::SetStart(), VIA::SetViaType(), TRACK::SetWidth(), LAYER_RANGE::Start(), ToLAYER_ID(), VIA, PNS::ITEM::VIA_T, PNS::VIA::ViaType(), PNS::SEGMENT::Width(), VECTOR2< T >::x, and VECTOR2< T >::y.

941 {
942  BOARD_CONNECTED_ITEM* newBI = NULL;
943 
944  switch( aItem->Kind() )
945  {
947  {
948  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
949  TRACK* track = new TRACK( m_board );
950  const SEG& s = seg->Seg();
951  track->SetStart( wxPoint( s.A.x, s.A.y ) );
952  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
953  track->SetWidth( seg->Width() );
954  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
955  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
956  newBI = track;
957  break;
958  }
959 
960  case PNS::ITEM::VIA_T:
961  {
962  VIA* via_board = new VIA( m_board );
963  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
964  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
965  via_board->SetWidth( via->Diameter() );
966  via_board->SetDrill( via->Drill() );
967  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
968  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
969  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
970  ToLAYER_ID( via->Layers().End() ) );
971  newBI = via_board;
972  break;
973  }
974 
975  default:
976  break;
977  }
978 
979  if( newBI )
980  {
981  aItem->SetParent( newBI );
982  newBI->ClearFlags();
983 
984  m_commit->Add( newBI );
985  }
986 }
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:444
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:416
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:119
int Drill() const
Definition: pns_via.h:120
int Diameter() const
Definition: pns_via.h:109
const VECTOR2I & Pos() const
Definition: pns_via.h:88
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
void SetWidth(int aWidth)
Definition: class_track.h:116
VIATYPE_T ViaType() const
Definition: pns_via.h:99
int End() const
Definition: pns_layerset.h:88
void SetParent(BOARD_CONNECTED_ITEM *aParent)
Function SetParent()
Definition: pns_item.h:147
std::unique_ptr< BOARD_COMMIT > m_commit
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
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...
int Width() const
Definition: pns_segment.h:88
int Start() const
Definition: pns_layerset.h:83
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:120
Definition: seg.h:36
VECTOR2I A
Definition: seg.h:46
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:451
int Net() const
Function Net()
Definition: pns_item.h:177
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
void SetStart(const wxPoint &aStart)
Definition: class_track.h:122
const SEG & Seg() const
Definition: pns_segment.h:93
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:774
VECTOR2I B
Definition: seg.h:47
void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 989 of file pns_kicad_iface.cpp.

References EraseView(), m_commit, and m_tool.

990 {
991  EraseView();
992  m_commit->Push( wxT( "Added a track" ) );
993  m_commit.reset( new BOARD_COMMIT( m_tool ) );
994 }
std::unique_ptr< BOARD_COMMIT > m_commit
void EraseView() override
PCB_TOOL * m_tool
void PNS_KICAD_IFACE::DisplayItem ( const PNS::ITEM aItem,
int  aColor = 0,
int  aClearance = 0 
)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 886 of file pns_kicad_iface.cpp.

References KIGFX::VIEW_GROUP::Add(), PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE, m_dispOptions, m_previewItems, PCB_DISPLAY_OPTIONS::m_ShowTrackClearanceMode, m_view, ROUTER_PREVIEW_ITEM::SetClearance(), ROUTER_PREVIEW_ITEM::SetColor(), PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS, ROUTER_PREVIEW_ITEM::ShowTrackClearance(), ROUTER_PREVIEW_ITEM::ShowViaClearance(), and KIGFX::VIEW::Update().

887 {
888  wxLogTrace( "PNS", "DisplayItem %p", aItem );
889 
890  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
891 
892  if( aColor >= 0 )
893  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
894 
895  if( aClearance >= 0 )
896  {
897  pitem->SetClearance( aClearance );
898 
899  if( m_dispOptions )
900  {
901  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
905  }
906  }
907 
908 
909  m_previewItems->Add( pitem );
911 }
void SetClearance(int aClearance)
void ShowTrackClearance(bool aEnabled)
PCB_DISPLAY_OPTIONS * m_dispOptions
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
void ShowViaClearance(bool aEnabled)
KIGFX::VIEW_GROUP * m_previewItems
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
void SetColor(const KIGFX::COLOR4D &aColor)
KIGFX::VIEW * m_view
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void PNS_KICAD_IFACE::EraseView ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 868 of file pns_kicad_iface.cpp.

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

Referenced by Commit().

869 {
870  for( auto item : m_hiddenItems )
871  m_view->SetVisible( item, true );
872 
873  m_hiddenItems.clear();
874 
875  if( m_previewItems )
876  {
879  }
880 
881  if( m_debugDecorator )
883 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:141
KIGFX::VIEW_GROUP * m_previewItems
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1331
PNS::DEBUG_DECORATOR * PNS_KICAD_IFACE::GetDebugDecorator ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 464 of file pns_kicad_iface.cpp.

References m_debugDecorator.

465 {
466  return m_debugDecorator;
467 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
PNS::RULE_RESOLVER * PNS_KICAD_IFACE::GetRuleResolver ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1024 of file pns_kicad_iface.cpp.

References m_ruleResolver.

1025 {
1026  return m_ruleResolver;
1027 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
void PNS_KICAD_IFACE::HideItem ( PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 914 of file pns_kicad_iface.cpp.

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

915 {
916  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
917 
918  if( parent )
919  {
920  if( m_view->IsVisible( parent ) )
921  m_hiddenItems.insert( parent );
922 
923  m_view->SetVisible( parent, false );
924  m_view->Update( parent, KIGFX::APPEARANCE );
925  }
926 }
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
No updates are required.
Definition: view_item.h:55
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1331
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1371
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:157
void PNS_KICAD_IFACE::RemoveItem ( PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 929 of file pns_kicad_iface.cpp.

References m_commit, and PNS::ITEM::Parent().

930 {
931  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
932 
933  if( parent )
934  {
935  m_commit->Remove( parent );
936  }
937 }
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
std::unique_ptr< BOARD_COMMIT > m_commit
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:157
void PNS_KICAD_IFACE::SetBoard ( BOARD aBoard)

Definition at line 815 of file pns_kicad_iface.cpp.

References m_board.

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

816 {
817  m_board = aBoard;
818  wxLogTrace( "PNS", "m_board = %p", m_board );
819 }
void PNS_KICAD_IFACE::SetDisplayOptions ( PCB_DISPLAY_OPTIONS aDispOptions)

Definition at line 1042 of file pns_kicad_iface.cpp.

References m_dispOptions.

1043 {
1044  m_dispOptions = aDispOptions;
1045 }
PCB_DISPLAY_OPTIONS * m_dispOptions
void PNS_KICAD_IFACE::SetHostTool ( PCB_TOOL aTool)

Definition at line 1036 of file pns_kicad_iface.cpp.

References m_commit, and m_tool.

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

1037 {
1038  m_tool = aTool;
1039  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1040 }
std::unique_ptr< BOARD_COMMIT > m_commit
PCB_TOOL * m_tool
void PNS_KICAD_IFACE::SetRouter ( PNS::ROUTER aRouter)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1030 of file pns_kicad_iface.cpp.

References m_router.

1031 {
1032  m_router = aRouter;
1033 }
PNS::ROUTER * m_router
void PNS_KICAD_IFACE::SetView ( KIGFX::VIEW aView)

Definition at line 997 of file pns_kicad_iface.cpp.

References KIGFX::VIEW::Add(), KIGFX::VIEW_GROUP::FreeItems(), LAYER_GP_OVERLAY, m_debugDecorator, m_previewItems, m_view, KIGFX::VIEW_GROUP::SetLayer(), and PNS_PCBNEW_DEBUG_DECORATOR::SetView().

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

998 {
999  wxLogTrace( "PNS", "SetView %p", aView );
1000 
1001  if( m_previewItems )
1002  {
1004  delete m_previewItems;
1005  }
1006 
1007  m_view = aView;
1011 
1012  delete m_debugDecorator;
1015 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:141
general purpose overlay
KIGFX::VIEW_GROUP * m_previewItems
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
KIGFX::VIEW * m_view
void SetView(KIGFX::VIEW *aView)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE::syncPad ( D_PAD aPad)
private

Definition at line 497 of file pns_kicad_iface.cpp.

References LSET::AllCuMask(), SHAPE_CONVEX::Append(), SHAPE_POLY_SET::Append(), D_PAD::BuildPadPolygon(), D_PAD::BuildPadShapePolygon(), D_PAD::BuildSegmentFromOvalShape(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), D_PAD::CustomShapeAsPolygonToBoardPosition(), delta, D_PAD::GetAttribute(), D_PAD::GetCustomShapeAsPolygon(), D_PAD::GetLayerSet(), BOARD_CONNECTED_ITEM::GetNetCode(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetShape(), D_PAD::GetSize(), MAX_CU_LAYERS, min, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PAD_ATTRIB_STANDARD, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), D_PAD::ShapePos(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by SyncWorld().

498 {
499  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
500 
501  // ignore non-copper pads
502  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
503  return NULL;
504 
505  switch( aPad->GetAttribute() )
506  {
507  case PAD_ATTRIB_STANDARD:
508  break;
509 
510  case PAD_ATTRIB_SMD:
512  case PAD_ATTRIB_CONN:
513  {
514  LSET lmsk = aPad->GetLayerSet();
515  bool is_copper = false;
516 
517  for( int i = 0; i < MAX_CU_LAYERS; i++ )
518  {
519  if( lmsk[i] )
520  {
521  is_copper = true;
522 
524  layers = LAYER_RANGE( i );
525 
526  break;
527  }
528  }
529 
530  if( !is_copper )
531  return NULL;
532  }
533  break;
534 
535  default:
536  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
537  return NULL;
538  }
539 
540  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
541 
542  solid->SetLayers( layers );
543  solid->SetNet( aPad->GetNetCode() );
544  solid->SetParent( aPad );
545 
546  wxPoint wx_c = aPad->ShapePos();
547  wxSize wx_sz = aPad->GetSize();
548  wxPoint offset = aPad->GetOffset();
549 
550  VECTOR2I c( wx_c.x, wx_c.y );
551  VECTOR2I sz( wx_sz.x, wx_sz.y );
552 
553  RotatePoint( &offset, aPad->GetOrientation() );
554 
555  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
556  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
557 
558  double orient = aPad->GetOrientation() / 10.0;
559 
560  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
561  {
562  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
563  }
564  else
565  {
566  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
567  {
568  if( orient == 90.0 || orient == 270.0 )
569  sz = VECTOR2I( sz.y, sz.x );
570 
571  switch( aPad->GetShape() )
572  {
573  case PAD_SHAPE_OVAL:
574  if( sz.x == sz.y )
575  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
576  else
577  {
578  VECTOR2I delta;
579 
580  if( sz.x > sz.y )
581  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
582  else
583  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
584 
585  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
586  std::min( sz.x, sz.y ) );
587  solid->SetShape( shape );
588  }
589  break;
590 
591  case PAD_SHAPE_RECT:
592  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
593  break;
594 
595  case PAD_SHAPE_TRAPEZOID:
596  {
597  wxPoint coords[4];
598  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
599  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
600 
601  for( int ii = 0; ii < 4; ii++ )
602  {
603  shape->Append( wx_c + coords[ii] );
604  }
605 
606  solid->SetShape( shape );
607  break;
608  }
609 
610  case PAD_SHAPE_ROUNDRECT:
611  {
612  SHAPE_POLY_SET outline;
613  const int segmentToCircleCount = 64;
614 
615  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
616 
617  // TransformRoundRectToPolygon creates only one convex polygon
618  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
619  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
620 
621  for( int ii = 0; ii < poly.PointCount(); ++ii )
622  {
623  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
624  }
625 
626  solid->SetShape( shape );
627  }
628  break;
629 
630  case PAD_SHAPE_CUSTOM:
631  {
632  SHAPE_POLY_SET outline;
633  outline.Append( aPad->GetCustomShapeAsPolygon() );
634  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
635 
636  for( int jj = 0; jj < outline.OutlineCount(); ++jj )
637  {
638  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
639  const SHAPE_LINE_CHAIN& poly = outline.COutline( jj );
640 
641  for( int ii = 0; ii < poly.PointCount(); ii++ )
642  shape->Append( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
643 
644  solid->SetShape( shape );
645  }
646 
647  break;
648  }
649 
650  default:
651  wxLogTrace( "PNS", "unsupported pad shape" );
652  return nullptr;
653  }
654  }
655  else
656  {
657  switch( aPad->GetShape() )
658  {
659  // PAD_SHAPE_CIRCLE already handled above
660 
661  case PAD_SHAPE_OVAL:
662  if( sz.x == sz.y )
663  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
664  else
665  {
666  wxPoint start;
667  wxPoint end;
668  wxPoint corner;
669 
670  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
671 
672  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
673 
674  if( start.y == 0 )
675  corner = wxPoint( start.x, -( w / 2 ) );
676  else
677  corner = wxPoint( w / 2, start.y );
678 
679  RotatePoint( &start, aPad->GetOrientation() );
680  RotatePoint( &corner, aPad->GetOrientation() );
681  shape->Append( wx_c + corner );
682 
683  for( int rot = 100; rot <= 1800; rot += 100 )
684  {
685  wxPoint p( corner );
686  RotatePoint( &p, start, rot );
687  shape->Append( wx_c + p );
688  }
689 
690  if( end.y == 0 )
691  corner = wxPoint( end.x, w / 2 );
692  else
693  corner = wxPoint( -( w / 2 ), end.y );
694 
695  RotatePoint( &end, aPad->GetOrientation() );
696  RotatePoint( &corner, aPad->GetOrientation() );
697  shape->Append( wx_c + corner );
698 
699  for( int rot = 100; rot <= 1800; rot += 100 )
700  {
701  wxPoint p( corner );
702  RotatePoint( &p, end, rot );
703  shape->Append( wx_c + p );
704  }
705 
706  solid->SetShape( shape );
707  }
708  break;
709 
710  case PAD_SHAPE_RECT:
711  case PAD_SHAPE_TRAPEZOID:
712  {
713  wxPoint coords[4];
714  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
715 
716  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
717  for( int ii = 0; ii < 4; ii++ )
718  {
719  shape->Append( wx_c + coords[ii] );
720  }
721 
722  solid->SetShape( shape );
723  break;
724  }
725 
726  case PAD_SHAPE_ROUNDRECT:
727  {
728  SHAPE_POLY_SET outline;
729  const int segmentToCircleCount = 32;
730  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
731  segmentToCircleCount, 1.0 );
732 
733  // TransformRoundRectToPolygon creates only one convex polygon
734  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
735  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
736 
737  for( int ii = 0; ii < poly.PointCount(); ++ii )
738  {
739  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
740  }
741 
742  solid->SetShape( shape );
743  break;
744  }
745 
746  case PAD_SHAPE_CUSTOM:
747  {
748  SHAPE_POLY_SET outline;
749  outline.Append( aPad->GetCustomShapeAsPolygon() );
750  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
751 
752  for( int jj = 0; jj < outline.OutlineCount(); ++jj )
753  {
754  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
755  const SHAPE_LINE_CHAIN& poly = outline.COutline( jj );
756 
757  for( int ii = 0; ii < poly.PointCount(); ii++ )
758  shape->Append( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
759 
760  solid->SetShape( shape );
761  }
762 
763  break;
764  }
765 
766  default:
767  wxLogTrace( "PNS", "unsupported pad shape" );
768  return nullptr;
769  }
770  }
771  }
772  return solid;
773 }
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:646
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:398
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
int PointCount() const
Function PointCount()
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
Class SHAPE_CONVEX.
Definition: shape_convex.h:42
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int OutlineCount() const
Returns the number of outlines in the set
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
static const int delta[8][2]
Definition: solve.cpp:112
void Append(int aX, int aY)
Function Append()
Definition: shape_convex.h:151
Class LSET is a set of PCB_LAYER_IDs.
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
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:395
const wxSize & GetSize() const
Definition: class_pad.h:269
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:62
int GetNetCode() const
Function GetNetCode.
int BuildSegmentFromOvalShape(wxPoint &aSegStart, wxPoint &aSegEnd, double aRotation, const wxSize &aMargin) const
Function BuildSegmentFromOvalShape Has meaning only for OVAL (and ROUND) pads Build an equivalent seg...
Class SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
Usual pad.
Definition: pad_shapes.h:60
void BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape...
wxPoint ShapePos() const
Definition: class_pad.cpp:500
VECTOR2I & Point(int aIndex)
Function Point()
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const wxPoint & GetOffset() const
Definition: class_pad.h:278
Class LAYER_RANGE.
Definition: pns_layerset.h:32
#define min(a, b)
Definition: auxiliary.h:85
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE::syncTrack ( TRACK aTrack)
private

Definition at line 776 of file pns_kicad_iface.cpp.

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

Referenced by SyncWorld().

777 {
778  std::unique_ptr< PNS::SEGMENT > segment(
779  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
780  );
781 
782  segment->SetWidth( aTrack->GetWidth() );
783  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
784  segment->SetParent( aTrack );
785 
786  if( aTrack->IsLocked() )
787  segment->Mark( PNS::MK_LOCKED );
788 
789  return segment;
790 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:138
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const wxPoint & GetEnd() const
Definition: class_track.h:120
const wxPoint & GetStart() const
Definition: class_track.h:123
int GetNetCode() const
Function GetNetCode.
Definition: seg.h:36
int GetWidth() const
Definition: class_track.h:117
Class LAYER_RANGE.
Definition: pns_layerset.h:32
std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE::syncVia ( VIA aVia)
private

Definition at line 793 of file pns_kicad_iface.cpp.

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

Referenced by SyncWorld().

794 {
795  PCB_LAYER_ID top, bottom;
796  aVia->LayerPair( &top, &bottom );
797  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
798  aVia->GetPosition(),
799  LAYER_RANGE( top, bottom ),
800  aVia->GetWidth(),
801  aVia->GetDrillValue(),
802  aVia->GetNetCode(),
803  aVia->GetViaType() )
804  );
805 
806  via->SetParent( aVia );
807 
808  if( aVia->IsLocked() )
809  via->Mark( PNS::MK_LOCKED );
810 
811  return via;
812 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:138
PCB_LAYER_ID
A quick note on layer IDs:
VIATYPE_T GetViaType() const
Definition: class_track.h:443
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.
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:117
const wxPoint & GetPosition() const override
Definition: class_track.h:415
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void PNS_KICAD_IFACE::SyncWorld ( PNS::NODE aWorld)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 822 of file pns_kicad_iface.cpp.

References PNS::NODE::Add(), BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue(), BOARD::GetDesignSettings(), m_board, BOARD::m_Modules, m_router, m_ruleResolver, BOARD::m_Track, TRACK::Next(), MODULE::Next(), D_PAD::Next(), PCB_TRACE_T, PCB_VIA_T, PNS::NODE::SetMaxClearance(), PNS::NODE::SetRuleResolver(), syncPad(), syncTrack(), and syncVia().

823 {
824  if( !m_board )
825  {
826  wxLogTrace( "PNS", "No board attached, aborting sync." );
827  return;
828  }
829 
830  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
831  {
832  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
833  {
834  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
835 
836  if( solid )
837  aWorld->Add( std::move( solid ) );
838  }
839  }
840 
841  for( TRACK* t = m_board->m_Track; t; t = t->Next() )
842  {
843  KICAD_T type = t->Type();
844 
845  if( type == PCB_TRACE_T ) {
846  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
847  if( segment ) {
848  aWorld->Add( std::move( segment ) );
849  }
850  } else if( type == PCB_VIA_T ) {
851  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
852  if( via ) {
853  aWorld->Add( std::move( via ) );
854  }
855  }
856  }
857 
858  int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
859 
860  delete m_ruleResolver;
862 
863  aWorld->SetRuleResolver( m_ruleResolver );
864  aWorld->SetMaxClearance( 4 * worstClearance );
865 }
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
MODULE * Next() const
Definition: class_module.h:120
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:163
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:95
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:157
D_PAD * Next() const
Definition: class_pad.h:160
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
PNS::ROUTER * m_router
TRACK * Next() const
Definition: class_track.h:100
DLIST< MODULE > m_Modules
Definition: class_board.h:245
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
DLIST< TRACK > m_Track
Definition: class_board.h:246
void Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:594
void PNS_KICAD_IFACE::UpdateNet ( int  aNetCode)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1018 of file pns_kicad_iface.cpp.

1019 {
1020  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1021 }

Member Data Documentation

BOARD* PNS_KICAD_IFACE::m_board
private

Definition at line 80 of file pns_kicad_iface.h.

Referenced by AddItem(), PNS_KICAD_IFACE(), SetBoard(), and SyncWorld().

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

Definition at line 82 of file pns_kicad_iface.h.

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

PNS_PCBNEW_DEBUG_DECORATOR* PNS_KICAD_IFACE::m_debugDecorator
private
PCB_DISPLAY_OPTIONS* PNS_KICAD_IFACE::m_dispOptions
private

Definition at line 83 of file pns_kicad_iface.h.

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

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

Definition at line 76 of file pns_kicad_iface.h.

Referenced by EraseView(), and HideItem().

KIGFX::VIEW_GROUP* PNS_KICAD_IFACE::m_previewItems
private

Definition at line 75 of file pns_kicad_iface.h.

Referenced by DisplayItem(), EraseView(), PNS_KICAD_IFACE(), SetView(), and ~PNS_KICAD_IFACE().

PNS::ROUTER* PNS_KICAD_IFACE::m_router
private

Definition at line 79 of file pns_kicad_iface.h.

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

PNS_PCBNEW_RULE_RESOLVER* PNS_KICAD_IFACE::m_ruleResolver
private

Definition at line 67 of file pns_kicad_iface.h.

Referenced by GetRuleResolver(), PNS_KICAD_IFACE(), SyncWorld(), and ~PNS_KICAD_IFACE().

PCB_TOOL* PNS_KICAD_IFACE::m_tool
private

Definition at line 81 of file pns_kicad_iface.h.

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

KIGFX::VIEW* PNS_KICAD_IFACE::m_view
private

Definition at line 74 of file pns_kicad_iface.h.

Referenced by DisplayItem(), EraseView(), HideItem(), PNS_KICAD_IFACE(), and SetView().

PNS::NODE* PNS_KICAD_IFACE::m_world
private

Definition at line 78 of file pns_kicad_iface.h.

Referenced by PNS_KICAD_IFACE().


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