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)
 
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)
 

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

References PNS_PCBNEW_RULE_RESOLVER::m_board, and PNS_PCBNEW_RULE_RESOLVER::m_router.

464 {
465  m_ruleResolver = nullptr;
466  m_board = nullptr;
467  m_tool = nullptr;
468  m_view = nullptr;
469  m_previewItems = nullptr;
470  m_router = nullptr;
471  m_debugDecorator = nullptr;
472  m_dispOptions = nullptr;
473 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
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 476 of file pns_kicad_iface.cpp.

477 {
478  delete m_ruleResolver;
479  delete m_debugDecorator;
480 
481  if( m_previewItems )
482  {
484  delete m_previewItems;
485  }
486 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:197
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 1148 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(), PNS_PCBNEW_RULE_RESOLVER::m_board, 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.

1149 {
1150  BOARD_CONNECTED_ITEM* newBI = NULL;
1151 
1152  switch( aItem->Kind() )
1153  {
1154  case PNS::ITEM::SEGMENT_T:
1155  {
1156  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1157  TRACK* track = new TRACK( m_board );
1158  const SEG& s = seg->Seg();
1159  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1160  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1161  track->SetWidth( seg->Width() );
1162  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1163  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1164  newBI = track;
1165  break;
1166  }
1167 
1168  case PNS::ITEM::VIA_T:
1169  {
1170  VIA* via_board = new VIA( m_board );
1171  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1172  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1173  via_board->SetWidth( via->Diameter() );
1174  via_board->SetDrill( via->Drill() );
1175  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1176  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1177  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1178  ToLAYER_ID( via->Layers().End() ) );
1179  newBI = via_board;
1180  break;
1181  }
1182 
1183  default:
1184  break;
1185  }
1186 
1187  if( newBI )
1188  {
1189  aItem->SetParent( newBI );
1190  newBI->ClearFlags();
1191 
1192  m_commit->Add( newBI );
1193  }
1194 }
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:458
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:209
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:430
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:118
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:115
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:149
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:122
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:465
int Net() const
Function Net()
Definition: pns_item.h:179
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void SetStart(const wxPoint &aStart)
Definition: class_track.h:121
const SEG & Seg() const
Definition: pns_segment.h:93
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
VECTOR2I B
Definition: seg.h:47
void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1197 of file pns_kicad_iface.cpp.

1198 {
1199  EraseView();
1200  m_commit->Push( _( "Added a track" ) );
1201  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1202 }
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 1094 of file pns_kicad_iface.cpp.

References PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE, ROUTER_PREVIEW_ITEM::SetClearance(), ROUTER_PREVIEW_ITEM::SetColor(), PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS, ROUTER_PREVIEW_ITEM::ShowTrackClearance(), and ROUTER_PREVIEW_ITEM::ShowViaClearance().

1095 {
1096  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1097 
1098  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1099 
1100  if( aColor >= 0 )
1101  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1102 
1103  if( aClearance >= 0 )
1104  {
1105  pitem->SetClearance( aClearance );
1106 
1107  if( m_dispOptions )
1108  {
1109  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
1112  && clearanceDisp != PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS );
1113  }
1114  }
1115 
1116 
1117  m_previewItems->Add( pitem );
1119 }
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:1521
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 1076 of file pns_kicad_iface.cpp.

1077 {
1078  for( auto item : m_hiddenItems )
1079  m_view->SetVisible( item, true );
1080 
1081  m_hiddenItems.clear();
1082 
1083  if( m_previewItems )
1084  {
1087  }
1088 
1089  if( m_debugDecorator )
1091 }
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:197
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:1521
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1467
PNS::DEBUG_DECORATOR * PNS_KICAD_IFACE::GetDebugDecorator ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 457 of file pns_kicad_iface.cpp.

458 {
459  return m_debugDecorator;
460 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
PNS::RULE_RESOLVER * PNS_KICAD_IFACE::GetRuleResolver ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1232 of file pns_kicad_iface.cpp.

1233 {
1234  return m_ruleResolver;
1235 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
void PNS_KICAD_IFACE::HideItem ( PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1122 of file pns_kicad_iface.cpp.

References KIGFX::APPEARANCE, and PNS::ITEM::Parent().

1123 {
1124  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1125 
1126  if( parent )
1127  {
1128  if( m_view->IsVisible( parent ) )
1129  m_hiddenItems.insert( parent );
1130 
1131  m_view->SetVisible( parent, false );
1132  m_view->Update( parent, KIGFX::APPEARANCE );
1133  }
1134 }
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:1521
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1467
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1507
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:159
void PNS_KICAD_IFACE::RemoveItem ( PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1137 of file pns_kicad_iface.cpp.

References PNS::ITEM::Parent().

1138 {
1139  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1140 
1141  if( parent )
1142  {
1143  m_commit->Remove( parent );
1144  }
1145 }
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:159
void PNS_KICAD_IFACE::SetBoard ( BOARD aBoard)

Definition at line 983 of file pns_kicad_iface.cpp.

References PNS_PCBNEW_RULE_RESOLVER::m_board.

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

984 {
985  m_board = aBoard;
986  wxLogTrace( "PNS", "m_board = %p", m_board );
987 }
void PNS_KICAD_IFACE::SetDisplayOptions ( PCB_DISPLAY_OPTIONS aDispOptions)

Definition at line 1250 of file pns_kicad_iface.cpp.

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

1251 {
1252  m_dispOptions = aDispOptions;
1253 }
PCB_DISPLAY_OPTIONS * m_dispOptions
void PNS_KICAD_IFACE::SetHostTool ( PCB_TOOL aTool)

Definition at line 1244 of file pns_kicad_iface.cpp.

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

1245 {
1246  m_tool = aTool;
1247  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1248 }
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 1238 of file pns_kicad_iface.cpp.

References PNS_PCBNEW_RULE_RESOLVER::m_router.

1239 {
1240  m_router = aRouter;
1241 }
PNS::ROUTER * m_router
void PNS_KICAD_IFACE::SetView ( KIGFX::VIEW aView)

Definition at line 1205 of file pns_kicad_iface.cpp.

References LAYER_SELECT_OVERLAY.

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

1206 {
1207  wxLogTrace( "PNS", "SetView %p", aView );
1208 
1209  if( m_previewItems )
1210  {
1212  delete m_previewItems;
1213  }
1214 
1215  m_view = aView;
1219 
1220  delete m_debugDecorator;
1223 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:197
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)
currently selected items overlay
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:335
bool PNS_KICAD_IFACE::syncGraphicalItem ( PNS::NODE aWorld,
DRAWSEGMENT aItem 
)
private

Definition at line 895 of file pns_kicad_iface.cpp.

References PNS::NODE::Add(), B_Cu, SHAPE_ARC::ConvertToPolyline(), Edge_Cuts, F_Cu, DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBezierPoints(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetLayer(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), i, IsCopperLayer(), DRAWSEGMENT::RebuildBezierToSegmentsPointsList(), S_ARC, S_CIRCLE, S_CURVE, and S_SEGMENT.

896 {
897  std::vector<SHAPE_SEGMENT*> segs;
898 
899  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
900  return false;
901 
902  switch( aItem->GetShape() )
903  {
904  case S_ARC:
905  {
906  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), (double) aItem->GetAngle() / 10.0 );
907 
908  auto l = arc.ConvertToPolyline();
909 
910  for( int i = 0; i < l.SegmentCount(); i++ )
911  {
912  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
913  segs.push_back( seg );
914  }
915 
916  break;
917  }
918 
919  case S_SEGMENT:
920  {
921  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() );
922  segs.push_back( seg );
923 
924  break;
925  }
926 
927  case S_CIRCLE:
928  {
929  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
930  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
931 
932  auto l = circle.ConvertToPolyline();
933 
934  for( int i = 0; i < l.SegmentCount(); i++ )
935  {
936  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
937  segs.push_back( seg );
938  }
939 
940  break;
941  }
942 
943  case S_CURVE:
944  {
945  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
946  wxPoint start_pt = aItem->GetBezierPoints()[0];
947 
948  for( unsigned int jj = 1; jj < aItem->GetBezierPoints().size(); jj++ )
949  {
950  wxPoint end_pt = aItem->GetBezierPoints()[jj];
951  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT(
952  VECTOR2I( start_pt ), VECTOR2I( end_pt ), aItem->GetWidth() );
953  segs.push_back( seg );
954  start_pt = end_pt;
955  }
956  }
957  break;
958 
959  default:
960  break;
961  }
962 
963  for( auto seg : segs )
964  {
965  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
966 
967  if( aItem->GetLayer() == Edge_Cuts )
968  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
969  else
970  solid->SetLayer( aItem->GetLayer() );
971 
972  solid->SetNet( -1 );
973  solid->SetParent( nullptr );
974  solid->SetShape( seg );
975  solid->SetRoutable( false );
976 
977  aWorld->Add( std::move( solid ) );
978  }
979 
980  return true;
981 }
const wxPoint GetCenter() const override
Function GetCenter()
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
usual segment : line with rounded ends
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
const wxPoint & GetArcStart() const
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Arcs (with rounded ends)
Bezier Curve.
const std::vector< wxPoint > & GetBezierPoints() const
double GetAngle() const
size_t i
Definition: json11.cpp:597
int GetWidth() const
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:594
Class LAYER_RANGE.
Definition: pns_layerset.h:32
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=500.0) const
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:208
std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE::syncPad ( D_PAD aPad)
private

Definition at line 489 of file pns_kicad_iface.cpp.

References LSET::AllCuMask(), SHAPE_SIMPLE::Append(), SHAPE_POLY_SET::Append(), D_PAD::BuildPadPolygon(), D_PAD::BuildPadShapePolygon(), D_PAD::BuildSegmentFromOvalShape(), SHAPE_POLY_SET::CIterate(), 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(), i, 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_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.

490 {
491  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
492 
493  // ignore non-copper pads
494  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
495  return NULL;
496 
497  switch( aPad->GetAttribute() )
498  {
499  case PAD_ATTRIB_STANDARD:
500  break;
501 
502  case PAD_ATTRIB_SMD:
504  case PAD_ATTRIB_CONN:
505  {
506  LSET lmsk = aPad->GetLayerSet();
507  bool is_copper = false;
508 
509  for( int i = 0; i < MAX_CU_LAYERS; i++ )
510  {
511  if( lmsk[i] )
512  {
513  is_copper = true;
514 
516  layers = LAYER_RANGE( i );
517 
518  break;
519  }
520  }
521 
522  if( !is_copper )
523  return NULL;
524  }
525  break;
526 
527  default:
528  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
529  return NULL;
530  }
531 
532  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
533 
534  solid->SetLayers( layers );
535  solid->SetNet( aPad->GetNetCode() );
536  solid->SetParent( aPad );
537 
538  wxPoint wx_c = aPad->ShapePos();
539  wxSize wx_sz = aPad->GetSize();
540  wxPoint offset = aPad->GetOffset();
541 
542  VECTOR2I c( wx_c.x, wx_c.y );
543  VECTOR2I sz( wx_sz.x, wx_sz.y );
544 
545  RotatePoint( &offset, aPad->GetOrientation() );
546 
547  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
548  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
549 
550  double orient = aPad->GetOrientation() / 10.0;
551 
552  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
553  {
554  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
555  }
556  else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
557  {
558  SHAPE_POLY_SET outline;
559  outline.Append( aPad->GetCustomShapeAsPolygon() );
560  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
561 
562  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
563 
564  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
565  shape->Append( *iter );
566 
567  solid->SetShape( shape );
568  }
569  else
570  {
571  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
572  {
573  if( orient == 90.0 || orient == 270.0 )
574  sz = VECTOR2I( sz.y, sz.x );
575 
576  switch( aPad->GetShape() )
577  {
578  case PAD_SHAPE_OVAL:
579  if( sz.x == sz.y )
580  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
581  else
582  {
583  VECTOR2I delta;
584 
585  if( sz.x > sz.y )
586  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
587  else
588  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
589 
590  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
591  std::min( sz.x, sz.y ) );
592  solid->SetShape( shape );
593  }
594  break;
595 
596  case PAD_SHAPE_RECT:
597  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
598  break;
599 
600  case PAD_SHAPE_TRAPEZOID:
601  {
602  wxPoint coords[4];
603  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
604  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
605 
606  for( int ii = 0; ii < 4; ii++ )
607  {
608  shape->Append( wx_c + coords[ii] );
609  }
610 
611  solid->SetShape( shape );
612  break;
613  }
614 
615  case PAD_SHAPE_ROUNDRECT:
616  {
617  SHAPE_POLY_SET outline;
618  const int segmentToCircleCount = 64;
619 
620  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
621 
622  // TransformRoundRectToPolygon creates only one convex polygon
623  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
624  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
625 
626  for( int ii = 0; ii < poly.PointCount(); ++ii )
627  {
628  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
629  }
630 
631  solid->SetShape( shape );
632  }
633  break;
634 
635  default:
636  wxLogTrace( "PNS", "unsupported pad shape" );
637  return nullptr;
638  }
639  }
640  else
641  {
642  switch( aPad->GetShape() )
643  {
644  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
645 
646  case PAD_SHAPE_OVAL:
647  if( sz.x == sz.y )
648  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
649  else
650  {
651  wxPoint start;
652  wxPoint end;
653  wxPoint corner;
654 
655  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
656 
657  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
658 
659  if( start.y == 0 )
660  corner = wxPoint( start.x, -( w / 2 ) );
661  else
662  corner = wxPoint( w / 2, start.y );
663 
664  RotatePoint( &start, aPad->GetOrientation() );
665  RotatePoint( &corner, aPad->GetOrientation() );
666  shape->Append( wx_c + corner );
667 
668  for( int rot = 100; rot <= 1800; rot += 100 )
669  {
670  wxPoint p( corner );
671  RotatePoint( &p, start, rot );
672  shape->Append( wx_c + p );
673  }
674 
675  if( end.y == 0 )
676  corner = wxPoint( end.x, w / 2 );
677  else
678  corner = wxPoint( -( w / 2 ), end.y );
679 
680  RotatePoint( &end, aPad->GetOrientation() );
681  RotatePoint( &corner, aPad->GetOrientation() );
682  shape->Append( wx_c + corner );
683 
684  for( int rot = 100; rot <= 1800; rot += 100 )
685  {
686  wxPoint p( corner );
687  RotatePoint( &p, end, rot );
688  shape->Append( wx_c + p );
689  }
690 
691  solid->SetShape( shape );
692  }
693  break;
694 
695  case PAD_SHAPE_RECT:
696  case PAD_SHAPE_TRAPEZOID:
697  {
698  wxPoint coords[4];
699  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
700 
701  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
702  for( int ii = 0; ii < 4; ii++ )
703  {
704  shape->Append( wx_c + coords[ii] );
705  }
706 
707  solid->SetShape( shape );
708  break;
709  }
710 
711  case PAD_SHAPE_ROUNDRECT:
712  {
713  SHAPE_POLY_SET outline;
714  const int segmentToCircleCount = 32;
715  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
716  segmentToCircleCount, 1.0 );
717 
718  // TransformRoundRectToPolygon creates only one convex polygon
719  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
720  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
721 
722  for( int ii = 0; ii < poly.PointCount(); ++ii )
723  {
724  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
725  }
726 
727  solid->SetShape( shape );
728  break;
729  }
730 
731  default:
732  wxLogTrace( "PNS", "unsupported pad shape" );
733  return nullptr;
734  }
735  }
736  }
737  return solid;
738 }
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:673
Class SHAPE_SIMPLE.
Definition: shape_simple.h:42
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
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
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
static const int delta[8][2]
Definition: solve.cpp:112
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:402
const wxSize & GetSize() const
Definition: class_pad.h:269
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.
size_t i
Definition: json11.cpp:597
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
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:517
VECTOR2I & Point(int aIndex)
Function Point()
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:151
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) ...
bool PNS_KICAD_IFACE::syncTextItem ( PNS::NODE aWorld,
EDA_TEXT aText,
PCB_LAYER_ID  aLayer 
)
private

Definition at line 843 of file pns_kicad_iface.cpp.

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

844 {
845  if( !IsCopperLayer( aLayer ) )
846  return false;
847 
848  int textWidth = aText->GetThickness();
849  std::vector<wxPoint> textShape;
850 
851  aText->TransformTextShapeToSegmentList( textShape );
852 
853  if( textShape.size() < 2 )
854  return false;
855 
856  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
857  {
858  VECTOR2I start( textShape[jj] );
859  VECTOR2I end( textShape[jj+1] );
860  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
861 
862  solid->SetLayer( aLayer );
863  solid->SetNet( -1 );
864  solid->SetParent( nullptr );
865  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
866  solid->SetRoutable( false );
867 
868  aWorld->Add( std::move( solid ) );
869  }
870 
871  return true;
872 
873  /* A coarser (but faster) method:
874  *
875  SHAPE_POLY_SET outline;
876  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
877 
878  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
879 
880  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
881  shape->Append( *iter );
882 
883  solid->SetShape( shape );
884 
885  solid->SetLayer( aLayer );
886  solid->SetNet( -1 );
887  solid->SetParent( nullptr );
888  solid->SetRoutable( false );
889  aWorld->Add( std::move( solid ) );
890  return true;
891  */
892 }
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment each segment is stored as 2 wxPoints: the starting point ...
Definition: eda_text.cpp:480
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:594
std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE::syncTrack ( TRACK aTrack)
private

Definition at line 741 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.

742 {
743  std::unique_ptr< PNS::SEGMENT > segment(
744  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
745  );
746 
747  segment->SetWidth( aTrack->GetWidth() );
748  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
749  segment->SetParent( aTrack );
750 
751  if( aTrack->IsLocked() )
752  segment->Mark( PNS::MK_LOCKED );
753 
754  return segment;
755 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:137
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const wxPoint & GetEnd() const
Definition: class_track.h:119
const wxPoint & GetStart() const
Definition: class_track.h:122
int GetNetCode() const
Function GetNetCode.
Definition: seg.h:36
int GetWidth() const
Definition: class_track.h:116
Class LAYER_RANGE.
Definition: pns_layerset.h:32
std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE::syncVia ( VIA aVia)
private

Definition at line 758 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.

759 {
760  PCB_LAYER_ID top, bottom;
761  aVia->LayerPair( &top, &bottom );
762  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
763  aVia->GetPosition(),
764  LAYER_RANGE( top, bottom ),
765  aVia->GetWidth(),
766  aVia->GetDrillValue(),
767  aVia->GetNetCode(),
768  aVia->GetViaType() )
769  );
770 
771  via->SetParent( aVia );
772 
773  if( aVia->IsLocked() )
774  via->Mark( PNS::MK_LOCKED );
775 
776  return via;
777 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:137
PCB_LAYER_ID
A quick note on layer IDs:
VIATYPE_T GetViaType() const
Definition: class_track.h:457
const wxPoint GetPosition() const override
Definition: class_track.h:429
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:116
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void PNS_KICAD_IFACE::SyncWorld ( PNS::NODE aWorld)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 990 of file pns_kicad_iface.cpp.

References PNS::NODE::Add(), BOARD::Drawings(), BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue(), BOARD::GetDesignSettings(), PNS_PCBNEW_RULE_RESOLVER::m_board, PNS_PCBNEW_RULE_RESOLVER::m_router, max, BOARD::Modules(), PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PNS_PCBNEW_RULE_RESOLVER::PNS_PCBNEW_RULE_RESOLVER(), PNS::NODE::SetMaxClearance(), PNS::NODE::SetRuleResolver(), BOARD::Tracks(), and BOARD::Zones().

991 {
992  int worstPadClearance = 0;
993 
994  if( !m_board )
995  {
996  wxLogTrace( "PNS", "No board attached, aborting sync." );
997  return;
998  }
999 
1000  for( auto gitem : m_board->Drawings() )
1001  {
1002  if ( gitem->Type() == PCB_LINE_T )
1003  {
1004  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1005  }
1006  else if( gitem->Type() == PCB_TEXT_T )
1007  {
1008  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1009  }
1010  }
1011 
1012  for( auto zone : m_board->Zones() )
1013  {
1014  syncZone( aWorld, zone );
1015  }
1016 
1017  for( auto module : m_board->Modules() )
1018  {
1019  for( auto pad : module->Pads() )
1020  {
1021  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
1022 
1023  if( solid )
1024  aWorld->Add( std::move( solid ) );
1025 
1026 
1027  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1028  }
1029 
1030  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1031  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1032 
1033  if( module->IsNetTie() )
1034  continue;
1035 
1036  for( auto mgitem : module->GraphicalItems() )
1037  {
1038  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1039  {
1040  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1041  }
1042  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1043  {
1044  syncTextItem( aWorld, dynamic_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1045  }
1046  }
1047  }
1048 
1049  for( auto t : m_board->Tracks() )
1050  {
1051  KICAD_T type = t->Type();
1052 
1053  if( type == PCB_TRACE_T ) {
1054  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
1055  if( segment ) {
1056  aWorld->Add( std::move( segment ) );
1057  }
1058  } else if( type == PCB_VIA_T ) {
1059  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
1060  if( via ) {
1061  aWorld->Add( std::move( via ) );
1062  }
1063  }
1064  }
1065 
1066  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1067 
1068  delete m_ruleResolver;
1070 
1071  aWorld->SetRuleResolver( m_ruleResolver );
1072  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1073 }
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:162
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:95
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:156
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:254
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
PNS::ROUTER * m_router
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
ZONE_CONTAINERS & Zones()
Definition: class_board.h:256
#define max(a, b)
Definition: auxiliary.h:86
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:253
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:594
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:255
bool PNS_KICAD_IFACE::syncZone ( PNS::NODE aWorld,
ZONE_CONTAINER aZone 
)
private

Definition at line 780 of file pns_kicad_iface.cpp.

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

781 {
782  SHAPE_POLY_SET poly;
783 
784  // TODO handle no-via restriction
785  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
786  return false;
787 
788  aZone->BuildSmoothedPoly( poly );
789  poly.CacheTriangulation();
790 
791  if( !poly.IsTriangulationUpToDate() )
792  {
793  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
794  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
795  dlg.ShowDetailedText(
796  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
797  "Please verify it is not a self-intersecting polygon." ),
798  aZone->GetSelectMenuText( MILLIMETRES ) ) );
799  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
800  dlg.ShowModal();
801 
802  return false;
803  }
804 
805  LSET layers = aZone->GetLayerSet();
806 
807  for( int layer = F_Cu; layer <= B_Cu; layer++ )
808  {
809  if ( ! layers[layer] )
810  continue;
811 
812  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
813  {
814  auto tri = poly.TriangulatedPolygon( outline );
815 
816  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
817  {
818  VECTOR2I a, b, c;
819  tri->GetTriangle( i, a, b, c );
820  auto triShape = new SHAPE_SIMPLE;
821 
822  triShape->Append( a );
823  triShape->Append( b );
824  triShape->Append( c );
825 
826  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
827 
828  solid->SetLayer( layer );
829  solid->SetNet( 0 );
830  solid->SetParent( aZone );
831  solid->SetShape( triShape );
832  solid->SetRoutable( false );
833 
834  aWorld->Add( std::move( solid ) );
835  }
836  }
837  }
838 
839  return true;
840 }
Class SHAPE_SIMPLE.
Definition: shape_simple.h:42
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:44
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly if it exists...
bool IsTriangulationUpToDate() const
int OutlineCount() const
Returns the number of outlines in the set
const wxPoint GetPosition() const override
Function GetPosition.
Definition: class_zone.cpp:169
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:623
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:230
Class LSET is a set of PCB_LAYER_IDs.
Class SHAPE_POLY_SET.
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
bool GetDoNotAllowTracks() const
Definition: class_zone.h:626
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
size_t i
Definition: json11.cpp:597
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:594
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:151
void PNS_KICAD_IFACE::UpdateNet ( int  aNetCode)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1226 of file pns_kicad_iface.cpp.

1227 {
1228  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1229 }

Member Data Documentation

BOARD* PNS_KICAD_IFACE::m_board
private

Definition at line 82 of file pns_kicad_iface.h.

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

Definition at line 84 of file pns_kicad_iface.h.

PNS_PCBNEW_DEBUG_DECORATOR* PNS_KICAD_IFACE::m_debugDecorator
private

Definition at line 68 of file pns_kicad_iface.h.

PCB_DISPLAY_OPTIONS* PNS_KICAD_IFACE::m_dispOptions
private

Definition at line 85 of file pns_kicad_iface.h.

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

Definition at line 79 of file pns_kicad_iface.h.

KIGFX::VIEW_GROUP* PNS_KICAD_IFACE::m_previewItems
private

Definition at line 78 of file pns_kicad_iface.h.

PNS::ROUTER* PNS_KICAD_IFACE::m_router
private

Definition at line 81 of file pns_kicad_iface.h.

PNS_PCBNEW_RULE_RESOLVER* PNS_KICAD_IFACE::m_ruleResolver
private

Definition at line 67 of file pns_kicad_iface.h.

PCB_TOOL* PNS_KICAD_IFACE::m_tool
private

Definition at line 83 of file pns_kicad_iface.h.

KIGFX::VIEW* PNS_KICAD_IFACE::m_view
private

Definition at line 77 of file pns_kicad_iface.h.


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