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 SetHostFrame (PCB_EDIT_FRAME *aFrame)
 
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_EDIT_FRAMEm_frame
 
std::unique_ptr< BOARD_COMMITm_commit
 
DISPLAY_OPTIONSm_dispOptions
 

Detailed Description

Definition at line 41 of file pns_kicad_iface.h.

Constructor & Destructor Documentation

PNS_KICAD_IFACE::PNS_KICAD_IFACE ( )

Definition at line 447 of file pns_kicad_iface.cpp.

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

448 {
449  m_ruleResolver = nullptr;
450  m_board = nullptr;
451  m_frame = nullptr;
452  m_view = nullptr;
453  m_previewItems = nullptr;
454  m_world = nullptr;
455  m_router = nullptr;
456  m_debugDecorator = nullptr;
457  m_dispOptions = nullptr;
458 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
PNS::NODE * m_world
PCB_EDIT_FRAME * m_frame
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
KIGFX::VIEW_GROUP * m_previewItems
PNS::ROUTER * m_router
KIGFX::VIEW * m_view
DISPLAY_OPTIONS * m_dispOptions
PNS_KICAD_IFACE::~PNS_KICAD_IFACE ( )

Definition at line 461 of file pns_kicad_iface.cpp.

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

462 {
463  delete m_ruleResolver;
464  delete m_debugDecorator;
465 
466  if( m_previewItems )
467  {
469  delete m_previewItems;
470  }
471 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:139
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 877 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.

878 {
879  BOARD_CONNECTED_ITEM* newBI = NULL;
880 
881  switch( aItem->Kind() )
882  {
884  {
885  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
886  TRACK* track = new TRACK( m_board );
887  const SEG& s = seg->Seg();
888  track->SetStart( wxPoint( s.A.x, s.A.y ) );
889  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
890  track->SetWidth( seg->Width() );
891  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
892  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
893  newBI = track;
894  break;
895  }
896 
897  case PNS::ITEM::VIA_T:
898  {
899  VIA* via_board = new VIA( m_board );
900  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
901  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
902  via_board->SetWidth( via->Diameter() );
903  via_board->SetDrill( via->Drill() );
904  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
905  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
906  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
907  ToLAYER_ID( via->Layers().End() ) );
908  newBI = via_board;
909  break;
910  }
911 
912  default:
913  break;
914  }
915 
916  if( newBI )
917  {
918  aItem->SetParent( newBI );
919  newBI->ClearFlags();
920 
921  m_commit->Add( newBI );
922  }
923 }
VECTOR2I & B
Definition: seg.h:52
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:443
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:416
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:116
int Drill() const
Definition: pns_via.h:120
int Diameter() const
Definition: pns_via.h:109
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
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:113
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
VECTOR2I & A
Definition: seg.h:51
void SetLayerPair(LAYER_ID aTopLayer, LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer...
std::unique_ptr< BOARD_COMMIT > m_commit
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
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:37
LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:766
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:450
int Net() const
Function Net()
Definition: pns_item.h:177
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
void SetStart(const wxPoint &aStart)
Definition: class_track.h:119
const SEG & Seg() const
Definition: pns_segment.h:93
void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 926 of file pns_kicad_iface.cpp.

References EraseView(), m_commit, and m_frame.

927 {
928  EraseView();
929  m_commit->Push( wxT( "Added a track" ) );
930  m_commit.reset( new BOARD_COMMIT( m_frame ) );
931 }
std::unique_ptr< BOARD_COMMIT > m_commit
PCB_EDIT_FRAME * m_frame
void EraseView() override
void PNS_KICAD_IFACE::DisplayItem ( const PNS::ITEM aItem,
int  aColor = 0,
int  aClearance = 0 
)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 823 of file pns_kicad_iface.cpp.

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

824 {
825  wxLogTrace( "PNS", "DisplayItem %p", aItem );
826 
827  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
828 
829  if( aColor >= 0 )
830  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
831 
832  if( aClearance >= 0 )
833  {
834  pitem->SetClearance( aClearance );
835 
836  if( m_dispOptions )
837  {
838  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
839  pitem->ShowTrackClearance( clearanceDisp != DO_NOT_SHOW_CLEARANCE );
840  pitem->ShowViaClearance( clearanceDisp != DO_NOT_SHOW_CLEARANCE
841  && clearanceDisp != SHOW_CLEARANCE_NEW_TRACKS );
842  }
843  }
844 
845 
846  m_previewItems->Add( pitem );
848 }
void SetClearance(int aClearance)
void ShowTrackClearance(bool aEnabled)
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
void SetColor(const KIGFX::COLOR4D &aColor)
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
Definition: pcbstruct.h:74
KIGFX::VIEW * m_view
DISPLAY_OPTIONS * m_dispOptions
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 805 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().

806 {
807  for( auto item : m_hiddenItems )
808  m_view->SetVisible( item, true );
809 
810  m_hiddenItems.clear();
811 
812  if( m_previewItems )
813  {
816  }
817 
818  if( m_debugDecorator )
820 }
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:139
KIGFX::VIEW_GROUP * m_previewItems
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Function SetVisible() Sets the item visibility.
Definition: view.cpp:1330
PNS::DEBUG_DECORATOR * PNS_KICAD_IFACE::GetDebugDecorator ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 441 of file pns_kicad_iface.cpp.

References m_debugDecorator.

442 {
443  return m_debugDecorator;
444 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
PNS::RULE_RESOLVER * PNS_KICAD_IFACE::GetRuleResolver ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 961 of file pns_kicad_iface.cpp.

References m_ruleResolver.

962 {
963  return m_ruleResolver;
964 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
void PNS_KICAD_IFACE::HideItem ( PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 851 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().

852 {
853  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
854 
855  if( parent )
856  {
857  if( m_view->IsVisible( parent ) )
858  m_hiddenItems.insert( parent );
859 
860  m_view->SetVisible( parent, false );
861  m_view->Update( parent, KIGFX::APPEARANCE );
862  }
863 }
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...
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Function SetVisible() Sets the item visibility.
Definition: view.cpp:1330
bool IsVisible(const VIEW_ITEM *aItem) const
Function IsVisible() Returns information if the item is visible (or not).
Definition: view.cpp:1370
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 866 of file pns_kicad_iface.cpp.

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

867 {
868  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
869 
870  if( parent )
871  {
872  m_commit->Remove( parent );
873  }
874 }
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 752 of file pns_kicad_iface.cpp.

References m_board.

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

753 {
754  m_board = aBoard;
755  wxLogTrace( "PNS", "m_board = %p", m_board );
756 }
void PNS_KICAD_IFACE::SetHostFrame ( PCB_EDIT_FRAME aFrame)

Definition at line 973 of file pns_kicad_iface.cpp.

References PCB_BASE_FRAME::GetDisplayOptions(), m_commit, m_dispOptions, and m_frame.

974 {
975  m_frame = aFrame;
976 
977  m_commit.reset( new BOARD_COMMIT( m_frame ) );
979 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
std::unique_ptr< BOARD_COMMIT > m_commit
PCB_EDIT_FRAME * m_frame
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
DISPLAY_OPTIONS * m_dispOptions
void PNS_KICAD_IFACE::SetRouter ( PNS::ROUTER aRouter)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 967 of file pns_kicad_iface.cpp.

References m_router.

968 {
969  m_router = aRouter;
970 }
PNS::ROUTER * m_router
void PNS_KICAD_IFACE::SetView ( KIGFX::VIEW aView)

Definition at line 934 of file pns_kicad_iface.cpp.

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

935 {
936  wxLogTrace( "PNS", "SetView %p", aView );
937 
938  if( m_previewItems )
939  {
941  delete m_previewItems;
942  }
943 
944  m_view = aView;
948 
949  delete m_debugDecorator;
952 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:139
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
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
void SetView(KIGFX::VIEW *aView)
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
general purpose overlay
std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE::syncPad ( D_PAD aPad)
private

Definition at line 474 of file pns_kicad_iface.cpp.

References LSET::AllCuMask(), SHAPE_CONVEX::Append(), D_PAD::BuildPadPolygon(), D_PAD::BuildPadShapePolygon(), D_PAD::BuildSegmentFromOvalShape(), delta, D_PAD::GetAttribute(), 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(), PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PAD_ATTRIB_STANDARD, PAD_SHAPE_CIRCLE, 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().

475 {
476  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
477 
478  // ignore non-copper pads
479  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
480  return NULL;
481 
482  switch( aPad->GetAttribute() )
483  {
484  case PAD_ATTRIB_STANDARD:
485  break;
486 
487  case PAD_ATTRIB_SMD:
489  case PAD_ATTRIB_CONN:
490  {
491  LSET lmsk = aPad->GetLayerSet();
492  bool is_copper = false;
493 
494  for( int i = 0; i < MAX_CU_LAYERS; i++ )
495  {
496  if( lmsk[i] )
497  {
498  is_copper = true;
499 
501  layers = LAYER_RANGE( i );
502 
503  break;
504  }
505  }
506 
507  if( !is_copper )
508  return NULL;
509  }
510  break;
511 
512  default:
513  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
514  return NULL;
515  }
516 
517  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
518 
519  solid->SetLayers( layers );
520  solid->SetNet( aPad->GetNetCode() );
521  solid->SetParent( aPad );
522 
523  wxPoint wx_c = aPad->ShapePos();
524  wxSize wx_sz = aPad->GetSize();
525  wxPoint offset = aPad->GetOffset();
526 
527  VECTOR2I c( wx_c.x, wx_c.y );
528  VECTOR2I sz( wx_sz.x, wx_sz.y );
529 
530  RotatePoint( &offset, aPad->GetOrientation() );
531 
532  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
533  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
534 
535  double orient = aPad->GetOrientation() / 10.0;
536 
537  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
538  {
539  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
540  }
541  else
542  {
543  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
544  {
545  if( orient == 90.0 || orient == 270.0 )
546  sz = VECTOR2I( sz.y, sz.x );
547 
548  switch( aPad->GetShape() )
549  {
550  case PAD_SHAPE_OVAL:
551  if( sz.x == sz.y )
552  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
553  else
554  {
555  VECTOR2I delta;
556 
557  if( sz.x > sz.y )
558  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
559  else
560  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
561 
562  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
563  std::min( sz.x, sz.y ) );
564  solid->SetShape( shape );
565  }
566  break;
567 
568  case PAD_SHAPE_RECT:
569  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
570  break;
571 
572  case PAD_SHAPE_TRAPEZOID:
573  {
574  wxPoint coords[4];
575  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
576  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
577 
578  for( int ii = 0; ii < 4; ii++ )
579  {
580  shape->Append( wx_c + coords[ii] );
581  }
582 
583  solid->SetShape( shape );
584  break;
585  }
586 
587  case PAD_SHAPE_ROUNDRECT:
588  {
589  SHAPE_POLY_SET outline;
590  const int segmentToCircleCount = 64;
591 
592  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
593 
594  // TransformRoundRectToPolygon creates only one convex polygon
595  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
596  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
597 
598  for( int ii = 0; ii < poly.PointCount(); ++ii )
599  {
600  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
601  }
602 
603  solid->SetShape( shape );
604  }
605  break;
606 
607  default:
608  wxLogTrace( "PNS", "unsupported pad shape" );
609  return nullptr;
610  }
611  }
612  else
613  {
614  switch( aPad->GetShape() )
615  {
616  // PAD_SHAPE_CIRCLE already handled above
617 
618  case PAD_SHAPE_OVAL:
619  if( sz.x == sz.y )
620  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
621  else
622  {
623  wxPoint start;
624  wxPoint end;
625  wxPoint corner;
626 
627  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
628 
629  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
630 
631  if( start.y == 0 )
632  corner = wxPoint( start.x, -( w / 2 ) );
633  else
634  corner = wxPoint( w / 2, start.y );
635 
636  RotatePoint( &start, aPad->GetOrientation() );
637  RotatePoint( &corner, aPad->GetOrientation() );
638  shape->Append( wx_c + corner );
639 
640  for( int rot = 100; rot <= 1800; rot += 100 )
641  {
642  wxPoint p( corner );
643  RotatePoint( &p, start, rot );
644  shape->Append( wx_c + p );
645  }
646 
647  if( end.y == 0 )
648  corner = wxPoint( end.x, w / 2 );
649  else
650  corner = wxPoint( -( w / 2 ), end.y );
651 
652  RotatePoint( &end, aPad->GetOrientation() );
653  RotatePoint( &corner, aPad->GetOrientation() );
654  shape->Append( wx_c + corner );
655 
656  for( int rot = 100; rot <= 1800; rot += 100 )
657  {
658  wxPoint p( corner );
659  RotatePoint( &p, end, rot );
660  shape->Append( wx_c + p );
661  }
662 
663  solid->SetShape( shape );
664  }
665  break;
666 
667  case PAD_SHAPE_RECT:
668  case PAD_SHAPE_TRAPEZOID:
669  {
670  wxPoint coords[4];
671  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
672 
673  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
674  for( int ii = 0; ii < 4; ii++ )
675  {
676  shape->Append( wx_c + coords[ii] );
677  }
678 
679  solid->SetShape( shape );
680  break;
681  }
682 
683  case PAD_SHAPE_ROUNDRECT:
684  {
685  SHAPE_POLY_SET outline;
686  const int segmentToCircleCount = 32;
687  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
688  segmentToCircleCount, 1.0 );
689 
690  // TransformRoundRectToPolygon creates only one convex polygon
691  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
692  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
693 
694  for( int ii = 0; ii < poly.PointCount(); ++ii )
695  {
696  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
697  }
698 
699  solid->SetShape( shape );
700  break;
701  }
702 
703  default:
704  wxLogTrace( "PNS", "unsupported pad shape" );
705  return nullptr;
706  }
707  }
708  }
709  return solid;
710 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu LAYER_IDs.
Definition: lset.cpp:638
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
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:59
Class SHAPE_CONVEX.
Definition: shape_convex.h:42
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
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 LAYER_IDs.
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:235
const wxSize & GetSize() const
Definition: class_pad.h:182
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:60
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:214
Usual pad.
Definition: pad_shapes.h:58
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:367
VECTOR2I & Point(int aIndex)
Function Point()
const wxPoint & GetOffset() const
Definition: class_pad.h:191
Class LAYER_RANGE.
Definition: pns_layerset.h:32
#define min(a, b)
Definition: auxiliary.h:85
std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE::syncTrack ( TRACK aTrack)
private

Definition at line 713 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().

714 {
715  std::unique_ptr< PNS::SEGMENT > segment(
716  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
717  );
718 
719  segment->SetWidth( aTrack->GetWidth() );
720  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
721  segment->SetParent( aTrack );
722 
723  if( aTrack->IsLocked() )
724  segment->Mark( PNS::MK_LOCKED );
725 
726  return segment;
727 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:135
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const wxPoint & GetEnd() const
Definition: class_track.h:117
const wxPoint & GetStart() const
Definition: class_track.h:120
int GetNetCode() const
Function GetNetCode.
Definition: seg.h:37
int GetWidth() const
Definition: class_track.h:114
Class LAYER_RANGE.
Definition: pns_layerset.h:32
std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE::syncVia ( VIA aVia)
private

Definition at line 730 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().

731 {
732  LAYER_ID top, bottom;
733  aVia->LayerPair( &top, &bottom );
734  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
735  aVia->GetPosition(),
736  LAYER_RANGE( top, bottom ),
737  aVia->GetWidth(),
738  aVia->GetDrillValue(),
739  aVia->GetNetCode(),
740  aVia->GetViaType() )
741  );
742 
743  via->SetParent( aVia );
744 
745  if( aVia->IsLocked() )
746  via->Mark( PNS::MK_LOCKED );
747 
748  return via;
749 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:135
VIATYPE_T GetViaType() const
Definition: class_track.h:442
int GetNetCode() const
Function GetNetCode.
void LayerPair(LAYER_ID *top_layer, LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
int GetWidth() const
Definition: class_track.h:114
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 759 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().

760 {
761  if( !m_board )
762  {
763  wxLogTrace( "PNS", "No board attached, aborting sync." );
764  return;
765  }
766 
767  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
768  {
769  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
770  {
771  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
772 
773  if( solid )
774  aWorld->Add( std::move( solid ) );
775  }
776  }
777 
778  for( TRACK* t = m_board->m_Track; t; t = t->Next() )
779  {
780  KICAD_T type = t->Type();
781 
782  if( type == PCB_TRACE_T ) {
783  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
784  if( segment ) {
785  aWorld->Add( std::move( segment ) );
786  }
787  } else if( type == PCB_VIA_T ) {
788  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
789  if( via ) {
790  aWorld->Add( std::move( via ) );
791  }
792  }
793  }
794 
795  int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
796 
797  delete m_ruleResolver;
799 
800  aWorld->SetRuleResolver( m_ruleResolver );
801  aWorld->SetMaxClearance( 4 * worstClearance );
802 }
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
MODULE * Next() const
Definition: class_module.h:99
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:90
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
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:106
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
PNS::ROUTER * m_router
TRACK * Next() const
Definition: class_track.h:97
DLIST< MODULE > m_Modules
Definition: class_board.h:243
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
DLIST< TRACK > m_Track
Definition: class_board.h:244
void Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:596
void PNS_KICAD_IFACE::UpdateNet ( int  aNetCode)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 955 of file pns_kicad_iface.cpp.

956 {
957  wxLogTrace( "PNS", "Update-net %d", aNetCode );
958 }

Member Data Documentation

BOARD* PNS_KICAD_IFACE::m_board
private

Definition at line 78 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 80 of file pns_kicad_iface.h.

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

PNS_PCBNEW_DEBUG_DECORATOR* PNS_KICAD_IFACE::m_debugDecorator
private
DISPLAY_OPTIONS* PNS_KICAD_IFACE::m_dispOptions
private

Definition at line 81 of file pns_kicad_iface.h.

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

PCB_EDIT_FRAME* PNS_KICAD_IFACE::m_frame
private

Definition at line 79 of file pns_kicad_iface.h.

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

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

Definition at line 74 of file pns_kicad_iface.h.

Referenced by EraseView(), and HideItem().

KIGFX::VIEW_GROUP* PNS_KICAD_IFACE::m_previewItems
private

Definition at line 73 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 77 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 65 of file pns_kicad_iface.h.

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

KIGFX::VIEW* PNS_KICAD_IFACE::m_view
private

Definition at line 72 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 76 of file pns_kicad_iface.h.

Referenced by PNS_KICAD_IFACE().


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