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_BASE *aTool)
 
void SetDisplayOptions (const PCB_DISPLAY_OPTIONS *aDispOptions)
 
void SetBoard (BOARD *aBoard)
 
void SetView (KIGFX::VIEW *aView)
 
void SyncWorld (PNS::NODE *aWorld) override
 
void EraseView () override
 
bool IsAnyLayerVisible (const LAYER_RANGE &aLayer) override
 
bool IsItemVisible (const PNS::ITEM *aItem) override
 
void HideItem (PNS::ITEM *aItem) override
 
void DisplayItem (const PNS::ITEM *aItem, int aColor=0, int aClearance=0, bool aEdit=false) override
 
void AddItem (PNS::ITEM *aItem) override
 
void RemoveItem (PNS::ITEM *aItem) override
 
void Commit () override
 
void UpdateNet (int aNetCode) override
 
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_TOOL_BASEm_tool
 
std::unique_ptr< BOARD_COMMITm_commit
 
const 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::PNS_KICAD_IFACE ( )

Definition at line 526 of file pns_kicad_iface.cpp.

527 {
528  m_ruleResolver = nullptr;
529  m_board = nullptr;
530  m_tool = nullptr;
531  m_view = nullptr;
532  m_previewItems = nullptr;
533  m_router = nullptr;
534  m_debugDecorator = nullptr;
535  m_dispOptions = nullptr;
536 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
KIGFX::VIEW_GROUP * m_previewItems
PNS::ROUTER * m_router
const PCB_DISPLAY_OPTIONS * m_dispOptions
KIGFX::VIEW * m_view
PCB_TOOL_BASE * m_tool

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

◆ ~PNS_KICAD_IFACE()

PNS_KICAD_IFACE::~PNS_KICAD_IFACE ( )

Definition at line 539 of file pns_kicad_iface.cpp.

540 {
541  delete m_ruleResolver;
542  delete m_debugDecorator;
543 
544  if( m_previewItems )
545  {
547  delete m_previewItems;
548  }
549 }
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

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

Member Function Documentation

◆ AddItem()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1287 of file pns_kicad_iface.cpp.

1288 {
1289  BOARD_CONNECTED_ITEM* newBI = NULL;
1290 
1291  switch( aItem->Kind() )
1292  {
1293  case PNS::ITEM::SEGMENT_T:
1294  {
1295  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1296  TRACK* track = new TRACK( m_board );
1297  const SEG& s = seg->Seg();
1298  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1299  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1300  track->SetWidth( seg->Width() );
1301  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1302  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1303  newBI = track;
1304  break;
1305  }
1306 
1307  case PNS::ITEM::VIA_T:
1308  {
1309  VIA* via_board = new VIA( m_board );
1310  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1311  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1312  via_board->SetWidth( via->Diameter() );
1313  via_board->SetDrill( via->Drill() );
1314  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1315  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1316  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1317  ToLAYER_ID( via->Layers().End() ) );
1318  newBI = via_board;
1319  break;
1320  }
1321 
1322  default:
1323  break;
1324  }
1325 
1326  if( newBI )
1327  {
1329  aItem->SetParent( newBI );
1330  newBI->ClearFlags();
1331 
1332  m_commit->Add( newBI );
1333  }
1334 }
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:310
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:105
VIATYPE ViaType() const
Definition: pns_via.h:111
void SetLocalRatsnestVisible(bool aVisible)
const SEG & Seg() const
Definition: pns_segment.h:93
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
const VECTOR2I & Pos() const
Definition: pns_via.h:100
void SetWidth(int aWidth)
Definition: class_track.h:102
int Start() const
Definition: pns_layerset.h:83
int End() const
Definition: pns_layerset.h:88
void SetParent(BOARD_CONNECTED_ITEM *aParent)
Definition: pns_item.h:144
int Diameter() const
Definition: pns_via.h:121
int Width() const
Definition: pns_segment.h:88
#define NULL
std::unique_ptr< BOARD_COMMIT > m_commit
int Net() const
Definition: pns_item.h:148
bool SetNetCode(int aNetCode, bool aNoAssert=false)
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.
const PCB_DISPLAY_OPTIONS * m_dispOptions
Definition: seg.h:39
VECTOR2I A
Definition: seg.h:47
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:351
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:122
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:256
void SetStart(const wxPoint &aStart)
Definition: class_track.h:108
int Drill() const
Definition: pns_via.h:132
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:341
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
VECTOR2I B
Definition: seg.h:48

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, m_dispOptions, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, PNS::ITEM::Net(), NULL, PNS::VIA::Pos(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, VIA::SetDrill(), TRACK::SetEnd(), BOARD_ITEM::SetLayer(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetLocalRatsnestVisible(), 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.

◆ Commit()

void PNS_KICAD_IFACE::Commit ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1337 of file pns_kicad_iface.cpp.

1338 {
1339  EraseView();
1340  m_commit->Push( _( "Added a track" ) );
1341  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1342 }
std::unique_ptr< BOARD_COMMIT > m_commit
void EraseView() override
#define _(s)
Definition: 3d_actions.cpp:31
PCB_TOOL_BASE * m_tool

References _, EraseView(), m_commit, and m_tool.

◆ DisplayItem()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1218 of file pns_kicad_iface.cpp.

1219 {
1220  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1221 
1222  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1223 
1224  if( aColor >= 0 )
1225  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1226 
1227  if( aClearance >= 0 )
1228  {
1229  pitem->SetClearance( aClearance );
1230 
1232  {
1234  pitem->ShowTrackClearance( false );
1235  pitem->ShowViaClearance( false );
1236  break;
1239  pitem->ShowTrackClearance( true );
1240  pitem->ShowViaClearance( true );
1241  break;
1242 
1244  pitem->ShowTrackClearance( !aEdit );
1245  pitem->ShowViaClearance( !aEdit );
1246  break;
1247 
1249  pitem->ShowTrackClearance( !aEdit );
1250  pitem->ShowViaClearance( false );
1251  break;
1252  }
1253  }
1254 
1255 
1256  m_previewItems->Add( pitem );
1258 }
void SetClearance(int aClearance)
void ShowTrackClearance(bool aEnabled)
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:1540
void SetColor(const KIGFX::COLOR4D &aColor)
const PCB_DISPLAY_OPTIONS * m_dispOptions
KIGFX::VIEW * m_view
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ EraseView()

void PNS_KICAD_IFACE::EraseView ( )
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1200 of file pns_kicad_iface.cpp.

1201 {
1202  for( auto item : m_hiddenItems )
1203  m_view->SetVisible( item, true );
1204 
1205  m_hiddenItems.clear();
1206 
1207  if( m_previewItems )
1208  {
1211  }
1212 
1213  if( m_debugDecorator )
1215 }
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:1540
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1486

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

◆ GetDebugDecorator()

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

Implements PNS::ROUTER_IFACE.

Definition at line 520 of file pns_kicad_iface.cpp.

521 {
522  return m_debugDecorator;
523 }
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator

References m_debugDecorator.

◆ GetRuleResolver()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1372 of file pns_kicad_iface.cpp.

1373 {
1374  return m_ruleResolver;
1375 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References m_ruleResolver.

◆ HideItem()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1261 of file pns_kicad_iface.cpp.

1262 {
1263  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1264 
1265  if( parent )
1266  {
1267  if( m_view->IsVisible( parent ) )
1268  m_hiddenItems.insert( parent );
1269 
1270  m_view->SetVisible( parent, false );
1271  m_view->Update( parent, KIGFX::APPEARANCE );
1272  }
1273 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:145
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
No updates are required.
Definition: view_item.h:55
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1526
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:1540
KIGFX::VIEW * m_view
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1486

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

◆ IsAnyLayerVisible()

bool PNS_KICAD_IFACE::IsAnyLayerVisible ( const LAYER_RANGE aLayer)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1062 of file pns_kicad_iface.cpp.

1063 {
1064  if( !m_view )
1065  return false;
1066 
1067  for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
1068  if( m_view->IsLayerVisible( i ) )
1069  return true;
1070 
1071  return false;
1072 }
int Start() const
Definition: pns_layerset.h:83
int End() const
Definition: pns_layerset.h:88
KIGFX::VIEW * m_view
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416

References LAYER_RANGE::End(), KIGFX::VIEW::IsLayerVisible(), m_view, and LAYER_RANGE::Start().

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

◆ IsItemVisible()

bool PNS_KICAD_IFACE::IsItemVisible ( const PNS::ITEM aItem)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1075 of file pns_kicad_iface.cpp.

1076 {
1077  if( !m_view || !aItem->Parent() )
1078  return false;
1079 
1080  auto item = aItem->Parent();
1081  bool isOnVisibleLayer = true;
1082 
1084  {
1085  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
1086  int layers_count;
1087  auto activeLayers = m_view->GetPainter()->GetSettings()->GetActiveLayers();
1088 
1089  isOnVisibleLayer = false;
1090  item->ViewGetLayers( layers, layers_count );
1091 
1092  for( int i = 0; i < layers_count; ++i )
1093  {
1094  // Item is on at least one of the active layers
1095  if( activeLayers.count( layers[i] ) > 0 )
1096  {
1097  isOnVisibleLayer = true;
1098  break;
1099  }
1100  }
1101  }
1102 
1103  if( m_view->IsVisible( item ) && isOnVisibleLayer
1104  && item->ViewGetLOD( item->GetLayer(), m_view ) < m_view->GetScale() )
1105  return true;
1106 
1107  // Items hidden in the router are not hidden on the board
1108  if( m_hiddenItems.find( item ) != m_hiddenItems.end() )
1109  return true;
1110 
1111  return false;
1112 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:145
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:701
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1526
bool GetHighContrast() const
Function GetHighContrast Returns information about high contrast display mode.
Definition: painter.h:163
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
KIGFX::VIEW * m_view
double GetScale() const
Function GetScale()
Definition: view.h:257
const std::set< unsigned int > GetActiveLayers()
Function GetActiveLayers() Returns the set of currently active layers.
Definition: painter.h:89

References KIGFX::RENDER_SETTINGS::GetActiveLayers(), KIGFX::RENDER_SETTINGS::GetHighContrast(), KIGFX::VIEW::GetPainter(), KIGFX::VIEW::GetScale(), KIGFX::PAINTER::GetSettings(), KIGFX::VIEW::IsVisible(), m_hiddenItems, m_view, PNS::ITEM::Parent(), and KIGFX::VIEW::VIEW_MAX_LAYERS.

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

◆ RemoveItem()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1276 of file pns_kicad_iface.cpp.

1277 {
1278  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1279 
1280  if( parent )
1281  {
1282  m_commit->Remove( parent );
1283  }
1284 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:145
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
std::unique_ptr< BOARD_COMMIT > m_commit

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

◆ SetBoard()

void PNS_KICAD_IFACE::SetBoard ( BOARD aBoard)

Definition at line 1055 of file pns_kicad_iface.cpp.

1056 {
1057  m_board = aBoard;
1058  wxLogTrace( "PNS", "m_board = %p", m_board );
1059 }

References m_board.

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

◆ SetDisplayOptions()

void PNS_KICAD_IFACE::SetDisplayOptions ( const PCB_DISPLAY_OPTIONS aDispOptions)

Definition at line 1390 of file pns_kicad_iface.cpp.

1391 {
1392  m_dispOptions = aDispOptions;
1393 }
const PCB_DISPLAY_OPTIONS * m_dispOptions

References m_dispOptions.

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

◆ SetHostTool()

void PNS_KICAD_IFACE::SetHostTool ( PCB_TOOL_BASE aTool)

Definition at line 1384 of file pns_kicad_iface.cpp.

1385 {
1386  m_tool = aTool;
1387  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1388 }
std::unique_ptr< BOARD_COMMIT > m_commit
PCB_TOOL_BASE * m_tool

References m_commit, and m_tool.

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

◆ SetRouter()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1378 of file pns_kicad_iface.cpp.

1379 {
1380  m_router = aRouter;
1381 }
PNS::ROUTER * m_router

References m_router.

◆ SetView()

void PNS_KICAD_IFACE::SetView ( KIGFX::VIEW aView)

Definition at line 1345 of file pns_kicad_iface.cpp.

1346 {
1347  wxLogTrace( "PNS", "SetView %p", aView );
1348 
1349  if( m_previewItems )
1350  {
1352  delete m_previewItems;
1353  }
1354 
1355  m_view = aView;
1359 
1360  delete m_debugDecorator;
1363 }
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:346

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

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

◆ syncGraphicalItem()

bool PNS_KICAD_IFACE::syncGraphicalItem ( PNS::NODE aWorld,
DRAWSEGMENT aItem 
)
private

Definition at line 961 of file pns_kicad_iface.cpp.

962 {
963  std::vector<SHAPE_SEGMENT*> segs;
964 
965  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
966  return false;
967 
968  switch( aItem->GetShape() )
969  {
970  case S_ARC:
971  {
972  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), aItem->GetAngle() / 10.0 );
973  auto l = arc.ConvertToPolyline();
974 
975  for( int i = 0; i < l.SegmentCount(); i++ )
976  {
977  SHAPE_SEGMENT* seg = new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() );
978  segs.push_back( seg );
979  }
980 
981  break;
982  }
983 
984  case S_SEGMENT:
985  segs.push_back(
986  new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() ) );
987 
988  break;
989 
990  case S_CIRCLE:
991  {
992  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
993  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
994  auto l = circle.ConvertToPolyline();
995 
996  for( int i = 0; i < l.SegmentCount(); i++ )
997  segs.push_back( new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() ) );
998 
999  break;
1000  }
1001 
1002  case S_CURVE:
1003  {
1004  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
1005  auto pts = aItem->GetBezierPoints();
1006 
1007  for( size_t ii = 1; ii < pts.size(); ii++ )
1008  {
1009  segs.push_back( new SHAPE_SEGMENT(
1010  VECTOR2I( pts[ii - 1] ), VECTOR2I( pts[ii] ), aItem->GetWidth() ) );
1011  }
1012  break;
1013  }
1014 
1015  case S_POLYGON:
1016  if( !aItem->IsPolygonFilled() )
1017  {
1018  auto poly = aItem->BuildPolyPointsList();
1019  for( size_t ii = 1; ii < poly.size(); ii++ )
1020  {
1021  segs.push_back( new SHAPE_SEGMENT(
1022  VECTOR2I( poly[ii - 1] ), VECTOR2I( poly[ii] ), aItem->GetWidth() ) );
1023  }
1024 
1025  segs.push_back( new SHAPE_SEGMENT(
1026  VECTOR2I( poly.back() ), VECTOR2I( poly.front() ), aItem->GetWidth() ) );
1027  }
1028  break;
1029 
1030  default:
1031  break;
1032  }
1033 
1034  for( auto seg : segs )
1035  {
1036  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
1037 
1038  if( aItem->GetLayer() == Edge_Cuts )
1039  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
1040  else
1041  solid->SetLayer( aItem->GetLayer() );
1042 
1043  solid->SetNet( -1 );
1044  solid->SetParent( nullptr );
1045  solid->SetShape( seg );
1046  solid->SetRoutable( false );
1047 
1048  aWorld->Add( std::move( solid ) );
1049  }
1050 
1051  return true;
1052 }
const wxPoint GetCenter() const override
Function GetCenter()
STROKE_T GetShape() const
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
const std::vector< wxPoint > & GetBezierPoints() const
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...
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Arcs (with rounded ends)
const wxPoint & GetArcStart() const
Bezier Curve.
int GetWidth() const
double GetAngle() 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.
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:247
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:590
LAYER_RANGE.
Definition: pns_layerset.h:32

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(), IsCopperLayer(), DRAWSEGMENT::IsPolygonFilled(), DRAWSEGMENT::RebuildBezierToSegmentsPointsList(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, and S_SEGMENT.

Referenced by SyncWorld().

◆ syncPad()

std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE::syncPad ( D_PAD aPad)
private

Definition at line 552 of file pns_kicad_iface.cpp.

553 {
554  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
555 
556  // ignore non-copper pads
557  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
558  return NULL;
559 
560  switch( aPad->GetAttribute() )
561  {
562  case PAD_ATTRIB_STANDARD:
563  break;
564 
565  case PAD_ATTRIB_SMD:
567  case PAD_ATTRIB_CONN:
568  {
569  LSET lmsk = aPad->GetLayerSet();
570  bool is_copper = false;
571 
572  for( int i = 0; i < MAX_CU_LAYERS; i++ )
573  {
574  if( lmsk[i] )
575  {
576  is_copper = true;
577 
579  layers = LAYER_RANGE( i );
580 
581  break;
582  }
583  }
584 
585  if( !is_copper )
586  return NULL;
587  }
588  break;
589 
590  default:
591  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
592  return NULL;
593  }
594 
595  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
596 
597  solid->SetLayers( layers );
598  solid->SetNet( aPad->GetNetCode() );
599  solid->SetParent( aPad );
600  solid->SetPadToDie( aPad->GetPadToDieLength() );
601 
602  wxPoint wx_c = aPad->ShapePos();
603  wxSize wx_sz = aPad->GetSize();
604  wxPoint offset = aPad->GetOffset();
605 
606  VECTOR2I c( wx_c.x, wx_c.y );
607  VECTOR2I sz( wx_sz.x, wx_sz.y );
608 
609  RotatePoint( &offset, aPad->GetOrientation() );
610 
611  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
612  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
613 
614  double orient = aPad->GetOrientation() / 10.0;
615 
616  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
617  {
618  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
619  }
620  else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
621  {
622  SHAPE_POLY_SET outline;
623  outline.Append( aPad->GetCustomShapeAsPolygon() );
624  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
625 
626  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
627 
628  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
629  shape->Append( *iter );
630 
631  solid->SetShape( shape );
632  }
633  else
634  {
635  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
636  {
637  if( orient == 90.0 || orient == 270.0 )
638  sz = VECTOR2I( sz.y, sz.x );
639 
640  switch( aPad->GetShape() )
641  {
642  case PAD_SHAPE_OVAL:
643  if( sz.x == sz.y )
644  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
645  else
646  {
647  VECTOR2I delta;
648 
649  if( sz.x > sz.y )
650  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
651  else
652  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
653 
654  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
655  std::min( sz.x, sz.y ) );
656  solid->SetShape( shape );
657  }
658  break;
659 
660  case PAD_SHAPE_RECT:
661  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
662  break;
663 
664  case PAD_SHAPE_TRAPEZOID:
665  {
666  wxPoint coords[4];
667  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
668  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
669 
670  for( int ii = 0; ii < 4; ii++ )
671  {
672  shape->Append( wx_c + coords[ii] );
673  }
674 
675  solid->SetShape( shape );
676  break;
677  }
678 
680  case PAD_SHAPE_ROUNDRECT:
681  {
682  SHAPE_POLY_SET outline;
683  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ) );
684 
685  // TransformRoundRectToPolygon creates only one convex polygon
686  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
687  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
688 
689  for( int ii = 0; ii < poly.PointCount(); ++ii )
690  shape->Append( poly.CPoint( ii ) );
691 
692  solid->SetShape( shape );
693  }
694  break;
695 
696  default:
697  wxLogTrace( "PNS", "unsupported pad shape" );
698  return nullptr;
699  }
700  }
701  else
702  {
703  switch( aPad->GetShape() )
704  {
705  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
706 
707  case PAD_SHAPE_OVAL:
708  if( sz.x == sz.y )
709  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
710  else
711  {
712  wxPoint start;
713  wxPoint end;
714  wxPoint corner;
715 
716  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
717 
718  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
719 
720  if( start.y == 0 )
721  corner = wxPoint( start.x, -( w / 2 ) );
722  else
723  corner = wxPoint( w / 2, start.y );
724 
725  RotatePoint( &start, aPad->GetOrientation() );
726  RotatePoint( &corner, aPad->GetOrientation() );
727  shape->Append( wx_c + corner );
728 
729  for( int rot = 100; rot <= 1800; rot += 100 )
730  {
731  wxPoint p( corner );
732  RotatePoint( &p, start, rot );
733  shape->Append( wx_c + p );
734  }
735 
736  if( end.y == 0 )
737  corner = wxPoint( end.x, w / 2 );
738  else
739  corner = wxPoint( -( w / 2 ), end.y );
740 
741  RotatePoint( &end, aPad->GetOrientation() );
742  RotatePoint( &corner, aPad->GetOrientation() );
743  shape->Append( wx_c + corner );
744 
745  for( int rot = 100; rot <= 1800; rot += 100 )
746  {
747  wxPoint p( corner );
748  RotatePoint( &p, end, rot );
749  shape->Append( wx_c + p );
750  }
751 
752  solid->SetShape( shape );
753  }
754  break;
755 
756  case PAD_SHAPE_RECT:
757  case PAD_SHAPE_TRAPEZOID:
758  {
759  wxPoint coords[4];
760  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
761 
762  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
763  for( int ii = 0; ii < 4; ii++ )
764  {
765  shape->Append( wx_c + coords[ii] );
766  }
767 
768  solid->SetShape( shape );
769  break;
770  }
771 
773  case PAD_SHAPE_ROUNDRECT:
774  {
775  SHAPE_POLY_SET outline;
776  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ) );
777 
778  // TransformRoundRectToPolygon creates only one convex polygon
779  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
780  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
781 
782  for( int ii = 0; ii < poly.PointCount(); ++ii )
783  {
784  shape->Append( wxPoint( poly.CPoint( ii ).x, poly.CPoint( ii ).y ) );
785  }
786 
787  solid->SetShape( shape );
788  break;
789  }
790 
791  default:
792  wxLogTrace( "PNS", "unsupported pad shape" );
793  return nullptr;
794  }
795  }
796  }
797  return solid;
798 }
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:686
SHAPE_SIMPLE.
Definition: shape_simple.h:42
int GetNetCode() const
Function GetNetCode.
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:66
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...
int GetPadToDieLength() const
Definition: class_pad.h:455
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:62
void BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aError=ARC_HIGH_DEF) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape,...
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
int PointCount() const
Function PointCount()
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:445
const VECTOR2I & CPoint(int aIndex) const
Function Point()
LSET is a set of PCB_LAYER_IDs.
#define NULL
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
const wxPoint & GetOffset() const
Definition: class_pad.h:309
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:442
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:63
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:422
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0,...
wxPoint ShapePos() const
Definition: class_pad.cpp:570
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:374
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:237
const wxSize & GetSize() const
Definition: class_pad.h:300
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:137
LAYER_RANGE.
Definition: pns_layerset.h:32
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)

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

Referenced by SyncWorld().

◆ syncTextItem()

bool PNS_KICAD_IFACE::syncTextItem ( PNS::NODE aWorld,
EDA_TEXT aText,
PCB_LAYER_ID  aLayer 
)
private

Definition at line 909 of file pns_kicad_iface.cpp.

910 {
911  if( !IsCopperLayer( aLayer ) )
912  return false;
913 
914  int textWidth = aText->GetThickness();
915  std::vector<wxPoint> textShape;
916 
917  aText->TransformTextShapeToSegmentList( textShape );
918 
919  if( textShape.size() < 2 )
920  return false;
921 
922  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
923  {
924  VECTOR2I start( textShape[jj] );
925  VECTOR2I end( textShape[jj+1] );
926  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
927 
928  solid->SetLayer( aLayer );
929  solid->SetNet( -1 );
930  solid->SetParent( nullptr );
931  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
932  solid->SetRoutable( false );
933 
934  aWorld->Add( std::move( solid ) );
935  }
936 
937  return true;
938 
939  /* A coarser (but faster) method:
940  *
941  SHAPE_POLY_SET outline;
942  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
943 
944  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
945 
946  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
947  shape->Append( *iter );
948 
949  solid->SetShape( shape );
950 
951  solid->SetLayer( aLayer );
952  solid->SetNet( -1 );
953  solid->SetParent( nullptr );
954  solid->SetRoutable( false );
955  aWorld->Add( std::move( solid ) );
956  return true;
957  */
958 }
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:544
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:590

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

Referenced by SyncWorld().

◆ syncTrack()

std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE::syncTrack ( TRACK aTrack)
private

Definition at line 801 of file pns_kicad_iface.cpp.

802 {
803  std::unique_ptr< PNS::SEGMENT > segment(
804  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
805  );
806 
807  segment->SetWidth( aTrack->GetWidth() );
808  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
809  segment->SetParent( aTrack );
810 
811  if( aTrack->IsLocked() )
812  segment->Mark( PNS::MK_LOCKED );
813 
814  return segment;
815 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:124
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:109
Definition: seg.h:39
int GetWidth() const
Definition: class_track.h:103
const wxPoint & GetEnd() const
Definition: class_track.h:106
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
LAYER_RANGE.
Definition: pns_layerset.h:32

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

Referenced by SyncWorld().

◆ syncVia()

std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE::syncVia ( VIA aVia)
private

Definition at line 818 of file pns_kicad_iface.cpp.

819 {
820  PCB_LAYER_ID top, bottom;
821  aVia->LayerPair( &top, &bottom );
822  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
823  aVia->GetPosition(),
824  LAYER_RANGE( top, bottom ),
825  aVia->GetWidth(),
826  aVia->GetDrillValue(),
827  aVia->GetNetCode(),
828  aVia->GetViaType() )
829  );
830 
831  via->SetParent( aVia );
832 
833  if( aVia->IsLocked() )
834  via->Mark( PNS::MK_LOCKED );
835 
836  return via;
837 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:124
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
int GetNetCode() const
Function GetNetCode.
PCB_LAYER_ID
A quick note on layer IDs:
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
const wxPoint GetPosition() const override
Definition: class_track.h:309
int GetWidth() const
Definition: class_track.h:103
VIATYPE GetViaType() const
Definition: class_track.h:336
LAYER_RANGE.
Definition: pns_layerset.h:32

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

Referenced by SyncWorld().

◆ SyncWorld()

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

Implements PNS::ROUTER_IFACE.

Definition at line 1115 of file pns_kicad_iface.cpp.

1116 {
1117  int worstPadClearance = 0;
1118 
1119  if( !m_board )
1120  {
1121  wxLogTrace( "PNS", "No board attached, aborting sync." );
1122  return;
1123  }
1124 
1125  for( auto gitem : m_board->Drawings() )
1126  {
1127  if ( gitem->Type() == PCB_LINE_T )
1128  {
1129  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1130  }
1131  else if( gitem->Type() == PCB_TEXT_T )
1132  {
1133  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1134  }
1135  }
1136 
1137  for( auto zone : m_board->Zones() )
1138  {
1139  syncZone( aWorld, zone );
1140  }
1141 
1142  for( auto module : m_board->Modules() )
1143  {
1144  for( auto pad : module->Pads() )
1145  {
1146  if( auto solid = syncPad( pad ) )
1147  aWorld->Add( std::move( solid ) );
1148 
1149  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1150  }
1151 
1152  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1153  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1154 
1155  for( MODULE_ZONE_CONTAINER* zone : module->Zones() )
1156  syncZone( aWorld, zone );
1157 
1158  if( module->IsNetTie() )
1159  continue;
1160 
1161  for( auto mgitem : module->GraphicalItems() )
1162  {
1163  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1164  {
1165  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1166  }
1167  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1168  {
1169  syncTextItem( aWorld, static_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1170  }
1171  }
1172  }
1173 
1174  for( auto t : m_board->Tracks() )
1175  {
1176  KICAD_T type = t->Type();
1177 
1178  if( type == PCB_TRACE_T )
1179  {
1180  if( auto segment = syncTrack( t ) )
1181  aWorld->Add( std::move( segment ) );
1182  }
1183  else if( type == PCB_VIA_T )
1184  {
1185  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1186  aWorld->Add( std::move( via ) );
1187  }
1188  }
1189 
1190  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1191 
1192  delete m_ruleResolver;
1194 
1195  aWorld->SetRuleResolver( m_ruleResolver );
1196  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1197 }
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:166
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:160
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
MODULES & Modules()
Definition: class_board.h:226
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
PNS::ROUTER * m_router
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
ZONE_CONTAINERS & Zones()
Definition: class_board.h:240
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)
MODULE_ZONE_CONTAINER is the same item as ZONE_CONTAINER, but with a specific type id ZONE_CONTAINER ...
Definition: class_zone.h:828
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
DRAWINGS & Drawings()
Definition: class_board.h:235
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:590
TRACKS & Tracks()
Definition: class_board.h:217

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

◆ syncZone()

bool PNS_KICAD_IFACE::syncZone ( PNS::NODE aWorld,
ZONE_CONTAINER aZone 
)
private

Definition at line 840 of file pns_kicad_iface.cpp.

841 {
842  SHAPE_POLY_SET poly;
843 
844  // TODO handle no-via restriction
845  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
846  return false;
847 
848  // Some intersecting zones, despite being on the same layer with the same net, cannot be
849  // merged due to other parameters such as fillet radius. The copper pour will end up
850  // effectively merged though, so we want to keep the corners of such intersections sharp.
851  std::set<VECTOR2I> colinearCorners;
852  aZone->GetColinearCorners( m_board, colinearCorners );
853 
854  aZone->BuildSmoothedPoly( poly, &colinearCorners );
855  poly.CacheTriangulation();
856 
857  if( !poly.IsTriangulationUpToDate() )
858  {
859  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
860  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
861  dlg.ShowDetailedText(
862  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
863  "Please verify it is not a self-intersecting polygon." ),
865  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
866  dlg.ShowModal();
867 
868  return false;
869  }
870 
871  LSET layers = aZone->GetLayerSet();
872 
873  for( int layer = F_Cu; layer <= B_Cu; layer++ )
874  {
875  if ( ! layers[layer] )
876  continue;
877 
878  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
879  {
880  auto tri = poly.TriangulatedPolygon( outline );
881 
882  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
883  {
884  VECTOR2I a, b, c;
885  tri->GetTriangle( i, a, b, c );
886  auto triShape = new SHAPE_SIMPLE;
887 
888  triShape->Append( a );
889  triShape->Append( b );
890  triShape->Append( c );
891 
892  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
893 
894  solid->SetLayer( layer );
895  solid->SetNet( -1 );
896  solid->SetParent( aZone );
897  solid->SetShape( triShape );
898  solid->SetRoutable( false );
899 
900  aWorld->Add( std::move( solid ) );
901  }
902  }
903  }
904 
905  return true;
906 }
SHAPE_SIMPLE.
Definition: shape_simple.h:42
int OutlineCount() const
Returns the number of outlines in the set
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
const wxPoint GetPosition() const override
Definition: class_zone.cpp:198
bool IsTriangulationUpToDate() const
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:268
void GetColinearCorners(BOARD *aBoard, std::set< VECTOR2I > &colinearCorners)
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
LSET is a set of PCB_LAYER_IDs.
SHAPE_POLY_SET.
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, std::set< VECTOR2I > *aPreserveCorners) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly.
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:631
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_zone.cpp:935
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:31
bool GetDoNotAllowTracks() const
Definition: class_zone.h:634
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:590
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:137

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

Referenced by SyncWorld().

◆ UpdateNet()

void PNS_KICAD_IFACE::UpdateNet ( int  aNetCode)
overridevirtual

Implements PNS::ROUTER_IFACE.

Definition at line 1366 of file pns_kicad_iface.cpp.

1367 {
1368  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1369 }

Member Data Documentation

◆ m_board

BOARD* PNS_KICAD_IFACE::m_board
private

Definition at line 84 of file pns_kicad_iface.h.

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

◆ m_commit

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

Definition at line 86 of file pns_kicad_iface.h.

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

◆ m_debugDecorator

PNS_PCBNEW_DEBUG_DECORATOR* PNS_KICAD_IFACE::m_debugDecorator
private

◆ m_dispOptions

const PCB_DISPLAY_OPTIONS* PNS_KICAD_IFACE::m_dispOptions
private

Definition at line 87 of file pns_kicad_iface.h.

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

◆ m_hiddenItems

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

Definition at line 81 of file pns_kicad_iface.h.

Referenced by EraseView(), HideItem(), and IsItemVisible().

◆ m_previewItems

KIGFX::VIEW_GROUP* PNS_KICAD_IFACE::m_previewItems
private

Definition at line 80 of file pns_kicad_iface.h.

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

◆ m_router

PNS::ROUTER* PNS_KICAD_IFACE::m_router
private

Definition at line 83 of file pns_kicad_iface.h.

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

◆ m_ruleResolver

PNS_PCBNEW_RULE_RESOLVER* PNS_KICAD_IFACE::m_ruleResolver
private

Definition at line 69 of file pns_kicad_iface.h.

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

◆ m_tool

PCB_TOOL_BASE* PNS_KICAD_IFACE::m_tool
private

Definition at line 85 of file pns_kicad_iface.h.

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

◆ m_view

KIGFX::VIEW* PNS_KICAD_IFACE::m_view
private

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