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

1154 {
1155  BOARD_CONNECTED_ITEM* newBI = NULL;
1156 
1157  switch( aItem->Kind() )
1158  {
1159  case PNS::ITEM::SEGMENT_T:
1160  {
1161  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1162  TRACK* track = new TRACK( m_board );
1163  const SEG& s = seg->Seg();
1164  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1165  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1166  track->SetWidth( seg->Width() );
1167  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1168  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1169  newBI = track;
1170  break;
1171  }
1172 
1173  case PNS::ITEM::VIA_T:
1174  {
1175  VIA* via_board = new VIA( m_board );
1176  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1177  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1178  via_board->SetWidth( via->Diameter() );
1179  via_board->SetDrill( via->Drill() );
1180  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1181  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1182  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1183  ToLAYER_ID( via->Layers().End() ) );
1184  newBI = via_board;
1185  break;
1186  }
1187 
1188  default:
1189  break;
1190  }
1191 
1192  if( newBI )
1193  {
1194  aItem->SetParent( newBI );
1195  newBI->ClearFlags();
1196 
1197  m_commit->Add( newBI );
1198  }
1199 }
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:462
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:209
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:434
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:122
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:119
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:44
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:469
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:125
const SEG & Seg() const
Definition: pns_segment.h:93
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
VECTOR2I B
Definition: seg.h:45
void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1202 of file pns_kicad_iface.cpp.

1203 {
1204  EraseView();
1205  m_commit->Push( _( "Added a track" ) );
1206  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1207 }
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 1099 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().

1100 {
1101  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1102 
1103  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1104 
1105  if( aColor >= 0 )
1106  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1107 
1108  if( aClearance >= 0 )
1109  {
1110  pitem->SetClearance( aClearance );
1111 
1112  if( m_dispOptions )
1113  {
1114  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
1117  && clearanceDisp != PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS );
1118  }
1119  }
1120 
1121 
1122  m_previewItems->Add( pitem );
1124 }
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:1538
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 1081 of file pns_kicad_iface.cpp.

1082 {
1083  for( auto item : m_hiddenItems )
1084  m_view->SetVisible( item, true );
1085 
1086  m_hiddenItems.clear();
1087 
1088  if( m_previewItems )
1089  {
1092  }
1093 
1094  if( m_debugDecorator )
1096 }
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:1538
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1484
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 1237 of file pns_kicad_iface.cpp.

1238 {
1239  return m_ruleResolver;
1240 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
void PNS_KICAD_IFACE::HideItem ( PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1127 of file pns_kicad_iface.cpp.

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

1128 {
1129  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1130 
1131  if( parent )
1132  {
1133  if( m_view->IsVisible( parent ) )
1134  m_hiddenItems.insert( parent );
1135 
1136  m_view->SetVisible( parent, false );
1137  m_view->Update( parent, KIGFX::APPEARANCE );
1138  }
1139 }
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:1538
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1484
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1524
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 1142 of file pns_kicad_iface.cpp.

References PNS::ITEM::Parent().

1143 {
1144  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1145 
1146  if( parent )
1147  {
1148  m_commit->Remove( parent );
1149  }
1150 }
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 988 of file pns_kicad_iface.cpp.

References PNS_PCBNEW_RULE_RESOLVER::m_board.

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

989 {
990  m_board = aBoard;
991  wxLogTrace( "PNS", "m_board = %p", m_board );
992 }
void PNS_KICAD_IFACE::SetDisplayOptions ( PCB_DISPLAY_OPTIONS aDispOptions)

Definition at line 1255 of file pns_kicad_iface.cpp.

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

1256 {
1257  m_dispOptions = aDispOptions;
1258 }
PCB_DISPLAY_OPTIONS * m_dispOptions
void PNS_KICAD_IFACE::SetHostTool ( PCB_TOOL aTool)

Definition at line 1249 of file pns_kicad_iface.cpp.

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

1250 {
1251  m_tool = aTool;
1252  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1253 }
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 1243 of file pns_kicad_iface.cpp.

References PNS_PCBNEW_RULE_RESOLVER::m_router.

1244 {
1245  m_router = aRouter;
1246 }
PNS::ROUTER * m_router
void PNS_KICAD_IFACE::SetView ( KIGFX::VIEW aView)

Definition at line 1210 of file pns_kicad_iface.cpp.

References LAYER_SELECT_OVERLAY.

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

1211 {
1212  wxLogTrace( "PNS", "SetView %p", aView );
1213 
1214  if( m_previewItems )
1215  {
1217  delete m_previewItems;
1218  }
1219 
1220  m_view = aView;
1224 
1225  delete m_debugDecorator;
1228 }
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:345
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, DRAWSEGMENT::BuildPolyPointsList(), 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::IsPolygonFilled(), DRAWSEGMENT::RebuildBezierToSegmentsPointsList(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, 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(), aItem->GetAngle() / 10.0 );
907  auto l = arc.ConvertToPolyline();
908 
909  for( int i = 0; i < l.SegmentCount(); i++ )
910  {
911  SHAPE_SEGMENT* seg = new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() );
912  segs.push_back( seg );
913  }
914 
915  break;
916  }
917 
918  case S_SEGMENT:
919  segs.push_back(
920  new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() ) );
921 
922  break;
923 
924  case S_CIRCLE:
925  {
926  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
927  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
928  auto l = circle.ConvertToPolyline();
929 
930  for( int i = 0; i < l.SegmentCount(); i++ )
931  segs.push_back( new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() ) );
932 
933  break;
934  }
935 
936  case S_CURVE:
937  {
938  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
939  auto pts = aItem->GetBezierPoints();
940 
941  for( size_t ii = 1; ii < pts.size(); ii++ )
942  {
943  segs.push_back( new SHAPE_SEGMENT(
944  VECTOR2I( pts[ii - 1] ), VECTOR2I( pts[ii] ), aItem->GetWidth() ) );
945  }
946  break;
947  }
948 
949  case S_POLYGON:
950  if( !aItem->IsPolygonFilled() )
951  {
952  auto poly = aItem->BuildPolyPointsList();
953  for( size_t ii = 1; ii < poly.size(); ii++ )
954  {
955  segs.push_back( new SHAPE_SEGMENT(
956  VECTOR2I( poly[ii - 1] ), VECTOR2I( poly[ii] ), aItem->GetWidth() ) );
957  }
958 
959  segs.push_back( new SHAPE_SEGMENT(
960  VECTOR2I( poly.back() ), VECTOR2I( poly.front() ), aItem->GetWidth() ) );
961  }
962  break;
963 
964  default:
965  break;
966  }
967 
968  for( auto seg : segs )
969  {
970  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
971 
972  if( aItem->GetLayer() == Edge_Cuts )
973  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
974  else
975  solid->SetLayer( aItem->GetLayer() );
976 
977  solid->SetNet( -1 );
978  solid->SetParent( nullptr );
979  solid->SetShape( seg );
980  solid->SetRoutable( false );
981 
982  aWorld->Add( std::move( solid ) );
983  }
984 
985  return true;
986 }
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
const wxPoint GetCenter() const override
Function GetCenter()
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
polygon (not yet used for tracks, but could be in microwave apps)
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.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
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(), ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF, 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(), VECTOR2< T >::x, 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 = ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF;
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:676
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:516
VECTOR2I & Point(int aIndex)
Function Point()
#define ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF
Definition: pcbnew.h:42
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:141
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const wxPoint & GetEnd() const
Definition: class_track.h:123
const wxPoint & GetStart() const
Definition: class_track.h:126
int GetNetCode() const
Function GetNetCode.
Definition: seg.h:36
int GetWidth() const
Definition: class_track.h:120
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:141
PCB_LAYER_ID
A quick note on layer IDs:
VIATYPE_T GetViaType() const
Definition: class_track.h:461
const wxPoint GetPosition() const override
Definition: class_track.h:433
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:120
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void PNS_KICAD_IFACE::SyncWorld ( PNS::NODE aWorld)
overridevirtual

Implements PNS::ROUTER_IFACE.

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

996 {
997  int worstPadClearance = 0;
998 
999  if( !m_board )
1000  {
1001  wxLogTrace( "PNS", "No board attached, aborting sync." );
1002  return;
1003  }
1004 
1005  for( auto gitem : m_board->Drawings() )
1006  {
1007  if ( gitem->Type() == PCB_LINE_T )
1008  {
1009  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1010  }
1011  else if( gitem->Type() == PCB_TEXT_T )
1012  {
1013  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1014  }
1015  }
1016 
1017  for( auto zone : m_board->Zones() )
1018  {
1019  syncZone( aWorld, zone );
1020  }
1021 
1022  for( auto module : m_board->Modules() )
1023  {
1024  for( auto pad : module->Pads() )
1025  {
1026  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
1027 
1028  if( solid )
1029  aWorld->Add( std::move( solid ) );
1030 
1031 
1032  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1033  }
1034 
1035  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1036  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1037 
1038  if( module->IsNetTie() )
1039  continue;
1040 
1041  for( auto mgitem : module->GraphicalItems() )
1042  {
1043  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1044  {
1045  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1046  }
1047  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1048  {
1049  syncTextItem( aWorld, dynamic_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1050  }
1051  }
1052  }
1053 
1054  for( auto t : m_board->Tracks() )
1055  {
1056  KICAD_T type = t->Type();
1057 
1058  if( type == PCB_TRACE_T ) {
1059  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
1060  if( segment ) {
1061  aWorld->Add( std::move( segment ) );
1062  }
1063  } else if( type == PCB_VIA_T ) {
1064  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
1065  if( via ) {
1066  aWorld->Add( std::move( via ) );
1067  }
1068  }
1069  }
1070 
1071  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1072 
1073  delete m_ruleResolver;
1075 
1076  aWorld->SetRuleResolver( m_ruleResolver );
1077  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1078 }
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:255
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
PNS::ROUTER * m_router
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
ZONE_CONTAINERS & Zones()
Definition: class_board.h:257
#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:254
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:256
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(), and SHAPE_POLY_SET::TriangulatedPolygon().

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:630
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:633
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 1231 of file pns_kicad_iface.cpp.

1232 {
1233  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1234 }

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: