KiCad PCB EDA Suite
PNS_KICAD_IFACE Class Reference

#include <pns_kicad_iface.h>

Inheritance diagram for PNS_KICAD_IFACE:
PNS_KICAD_IFACE_BASE PNS::ROUTER_IFACE

Classes

struct  OFFSET
 

Public Member Functions

 PNS_KICAD_IFACE ()
 
 ~PNS_KICAD_IFACE ()
 
void SetHostTool (PCB_TOOL_BASE *aTool)
 
void SetDisplayOptions (const PCB_DISPLAY_OPTIONS *aDispOptions)
 
void SetView (KIGFX::VIEW *aView)
 
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 Commit () override
 
void AddItem (PNS::ITEM *aItem) override
 
void RemoveItem (PNS::ITEM *aItem) override
 
void UpdateNet (int aNetCode) override
 
void SetRouter (PNS::ROUTER *aRouter) override
 
void SetBoard (BOARD *aBoard)
 
void SyncWorld (PNS::NODE *aWorld) override
 
void SetDebugDecorator (PNS::DEBUG_DECORATOR *aDec)
 
PNS::RULE_RESOLVERGetRuleResolver () override
 
PNS::DEBUG_DECORATORGetDebugDecorator () override
 

Protected Member Functions

std::unique_ptr< PNS::SOLIDsyncPad (D_PAD *aPad)
 
std::unique_ptr< PNS::SEGMENTsyncTrack (TRACK *aTrack)
 
std::unique_ptr< PNS::ARCsyncArc (ARC *aArc)
 
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)
 

Protected Attributes

PNS_PCBNEW_RULE_RESOLVERm_ruleResolver
 
PNS::DEBUG_DECORATORm_debugDecorator
 
PNS::ROUTERm_router
 
BOARDm_board
 

Private Attributes

std::map< D_PAD *, OFFSETm_moduleOffsets
 
KIGFX::VIEWm_view
 
KIGFX::VIEW_GROUPm_previewItems
 
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
 
PCB_TOOL_BASEm_tool
 
std::unique_ptr< BOARD_COMMITm_commit
 
const PCB_DISPLAY_OPTIONSm_dispOptions
 

Detailed Description

Definition at line 87 of file pns_kicad_iface.h.

Constructor & Destructor Documentation

◆ PNS_KICAD_IFACE()

PNS_KICAD_IFACE::PNS_KICAD_IFACE ( )

Definition at line 544 of file pns_kicad_iface.cpp.

545 {
546  m_tool = nullptr;
547  m_view = nullptr;
548  m_previewItems = nullptr;
549  m_dispOptions = nullptr;
550 }
KIGFX::VIEW_GROUP * m_previewItems
const PCB_DISPLAY_OPTIONS * m_dispOptions
KIGFX::VIEW * m_view
PCB_TOOL_BASE * m_tool

References m_dispOptions, m_previewItems, m_tool, and m_view.

◆ ~PNS_KICAD_IFACE()

PNS_KICAD_IFACE::~PNS_KICAD_IFACE ( )

Definition at line 560 of file pns_kicad_iface.cpp.

561 {
562  if( m_previewItems )
563  {
565  delete m_previewItems;
566  }
567 }
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:197
KIGFX::VIEW_GROUP * m_previewItems

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

Member Function Documentation

◆ AddItem()

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1126 of file pns_kicad_iface.cpp.

1127 {
1128  BOARD_CONNECTED_ITEM* newBI = NULL;
1129 
1130  switch( aItem->Kind() )
1131  {
1132  case PNS::ITEM::ARC_T:
1133  {
1134  auto arc = static_cast<PNS::ARC*>( aItem );
1135  ARC* new_arc = new ARC( m_board, static_cast<const SHAPE_ARC*>( arc->Shape() ) );
1136  new_arc->SetWidth( arc->Width() );
1137  new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
1138  new_arc->SetNetCode( std::max<int>( 0, arc->Net() ) );
1139  newBI = new_arc;
1140  break;
1141  }
1142 
1143  case PNS::ITEM::SEGMENT_T:
1144  {
1145  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1146  TRACK* track = new TRACK( m_board );
1147  const SEG& s = seg->Seg();
1148  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1149  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1150  track->SetWidth( seg->Width() );
1151  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1152  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1153  newBI = track;
1154  break;
1155  }
1156 
1157  case PNS::ITEM::VIA_T:
1158  {
1159  VIA* via_board = new VIA( m_board );
1160  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1161  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1162  via_board->SetWidth( via->Diameter() );
1163  via_board->SetDrill( via->Drill() );
1164  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1165  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1166  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1167  ToLAYER_ID( via->Layers().End() ) );
1168  newBI = via_board;
1169  break;
1170  }
1171 
1172  case PNS::ITEM::SOLID_T:
1173  {
1174  auto pad = static_cast<D_PAD*>( aItem->Parent() );
1175  auto pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1176 
1177  m_moduleOffsets[ pad ].p_new = pos;
1178  return;
1179  }
1180 
1181  default:
1182  break;
1183  }
1184 
1185  if( newBI )
1186  {
1187  //newBI->SetLocalRatsnestVisible( m_dispOptions->m_ShowGlobalRatsnest );
1188  aItem->SetParent( newBI );
1189  newBI->ClearFlags();
1190 
1191  m_commit->Add( newBI );
1192  }
1193 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:146
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:407
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:114
VIATYPE ViaType() const
Definition: pns_via.h:111
int Width() const override
Definition: pns_segment.h:78
const SEG & Seg() const
Definition: pns_segment.h:83
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:111
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:145
int Diameter() const
Definition: pns_via.h:121
#define NULL
std::unique_ptr< BOARD_COMMIT > m_commit
int Net() const
Definition: pns_item.h:149
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.
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:442
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:123
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
void SetStart(const wxPoint &aStart)
Definition: class_track.h:117
std::map< D_PAD *, OFFSET > m_moduleOffsets
int Drill() const
Definition: pns_via.h:132
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:369
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
VECTOR2I B
Definition: seg.h:48

References SEG::A, ARC, PNS::ITEM::ARC_T, SEG::B, EDA_ITEM::ClearFlags(), PNS::VIA::Diameter(), PNS::VIA::Drill(), LAYER_RANGE::End(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), PNS_KICAD_IFACE_BASE::m_board, m_commit, m_moduleOffsets, PNS::ITEM::Net(), NULL, PNS::ITEM::Parent(), 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(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), ToLAYER_ID(), TRACK, 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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1196 of file pns_kicad_iface.cpp.

1197 {
1198  std::set<MODULE*> processedMods;
1199 
1200  EraseView();
1201 
1202  for( auto mo : m_moduleOffsets )
1203  {
1204  auto offset = mo.second.p_new - mo.second.p_old;
1205  auto mod = mo.first->GetParent();
1206 
1207  VECTOR2I p_orig = mod->GetPosition();
1208  VECTOR2I p_new = p_orig + offset;
1209 
1210  if( processedMods.find( mod ) != processedMods.end() )
1211  continue;
1212 
1213  processedMods.insert( mod );
1214  m_commit->Modify( mod );
1215  mod->SetPosition( wxPoint( p_new.x, p_new.y ));
1216  }
1217 
1218  m_moduleOffsets.clear();
1219 
1220  m_commit->Push( _( "Interactive Router" ) );
1221  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1222 }
std::unique_ptr< BOARD_COMMIT > m_commit
void EraseView() override
#define _(s)
Definition: 3d_actions.cpp:33
PCB_TOOL_BASE * m_tool
std::map< D_PAD *, OFFSET > m_moduleOffsets

References _, EraseView(), m_commit, m_moduleOffsets, m_tool, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ DisplayItem()

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1036 of file pns_kicad_iface.cpp.

1037 {
1038  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1039 
1040  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1041 
1042  if( aColor >= 0 )
1043  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1044 
1045  if( aClearance >= 0 )
1046  {
1047  pitem->SetClearance( aClearance );
1048 
1050  {
1052  pitem->ShowTrackClearance( false );
1053  pitem->ShowViaClearance( false );
1054  break;
1057  pitem->ShowTrackClearance( true );
1058  pitem->ShowViaClearance( true );
1059  break;
1060 
1062  pitem->ShowTrackClearance( !aEdit );
1063  pitem->ShowViaClearance( !aEdit );
1064  break;
1065 
1067  pitem->ShowTrackClearance( !aEdit );
1068  pitem->ShowViaClearance( false );
1069  break;
1070  }
1071  }
1072 
1073 
1074  m_previewItems->Add( pitem );
1076 }
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:99

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1014 of file pns_kicad_iface.cpp.

1015 {
1016  for( auto item : m_hiddenItems )
1017  m_view->SetVisible( item, true );
1018 
1019  m_hiddenItems.clear();
1020 
1021  if( m_previewItems )
1022  {
1025  }
1026 
1027  if( m_debugDecorator )
1029 }
PNS::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::DEBUG_DECORATOR::Clear(), KIGFX::VIEW_GROUP::FreeItems(), PNS_KICAD_IFACE_BASE::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_BASE::GetDebugDecorator ( )
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 528 of file pns_kicad_iface.cpp.

529 {
530  return m_debugDecorator;
531 }
PNS::DEBUG_DECORATOR * m_debugDecorator

References PNS_KICAD_IFACE_BASE::m_debugDecorator.

◆ GetRuleResolver()

PNS::RULE_RESOLVER * PNS_KICAD_IFACE_BASE::GetRuleResolver ( )
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 1258 of file pns_kicad_iface.cpp.

1259 {
1260  return m_ruleResolver;
1261 }
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver

References PNS_KICAD_IFACE_BASE::m_ruleResolver.

◆ HideItem()

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1079 of file pns_kicad_iface.cpp.

1080 {
1081  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1082 
1083  if( parent )
1084  {
1085  if( m_view->IsVisible( parent ) )
1086  m_hiddenItems.insert( parent );
1087 
1088  m_view->SetVisible( parent, false );
1089  m_view->Update( parent, KIGFX::APPEARANCE );
1090  }
1091 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:146
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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 869 of file pns_kicad_iface.cpp.

870 {
871  if( !m_view )
872  return false;
873 
874  for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
875  if( m_view->IsLayerVisible( i ) )
876  return true;
877 
878  return false;
879 }
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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 882 of file pns_kicad_iface.cpp.

883 {
884  // by default, all items are visible (new ones created by the router have parent == NULL as they have not been
885  // committed yet to the BOARD)
886  if( !m_view || !aItem->Parent() )
887  return true;
888 
889  auto item = aItem->Parent();
890  bool isOnVisibleLayer = true;
891 
893  {
894  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
895  int layers_count;
896  auto activeLayers = m_view->GetPainter()->GetSettings()->GetActiveLayers();
897 
898  isOnVisibleLayer = false;
899  item->ViewGetLayers( layers, layers_count );
900 
901  for( int i = 0; i < layers_count; ++i )
902  {
903  // Item is on at least one of the active layers
904  if( activeLayers.count( layers[i] ) > 0 )
905  {
906  isOnVisibleLayer = true;
907  break;
908  }
909  }
910  }
911 
912  if( m_view->IsVisible( item ) && isOnVisibleLayer
913  && item->ViewGetLOD( item->GetLayer(), m_view ) < m_view->GetScale() )
914  return true;
915 
916  // Items hidden in the router are not hidden on the board
917  if( m_hiddenItems.find( item ) != m_hiddenItems.end() )
918  return true;
919 
920  return false;
921 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:146
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
const std::set< unsigned int > GetActiveLayers() const
Function GetActiveLayers() Returns the set of currently active layers.
bool GetHighContrast() const
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter 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

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

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1100 of file pns_kicad_iface.cpp.

1101 {
1102  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1103 
1104  if ( aItem->OfKind(PNS::ITEM::SOLID_T) )
1105  {
1106  auto pad = static_cast<D_PAD*>( parent );
1107  auto pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1108 
1109  m_moduleOffsets[ pad ].p_old = pos;
1110  return;
1111  }
1112 
1113  if( parent )
1114  {
1115  m_commit->Remove( parent );
1116  }
1117 }
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:146
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
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:133
std::map< D_PAD *, OFFSET > m_moduleOffsets

References m_commit, m_moduleOffsets, PNS::ITEM::OfKind(), PNS::ITEM::Parent(), and PNS::ITEM::SOLID_T.

◆ SetBoard()

void PNS_KICAD_IFACE_BASE::SetBoard ( BOARD aBoard)
inherited

Definition at line 862 of file pns_kicad_iface.cpp.

863 {
864  m_board = aBoard;
865  wxLogTrace( "PNS", "m_board = %p", m_board );
866 }

References PNS_KICAD_IFACE_BASE::m_board.

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

◆ SetDebugDecorator()

void PNS_KICAD_IFACE_BASE::SetDebugDecorator ( PNS::DEBUG_DECORATOR aDec)
inherited

Definition at line 1031 of file pns_kicad_iface.cpp.

1032 {
1033  m_debugDecorator = aDec;
1034 }
PNS::DEBUG_DECORATOR * m_debugDecorator

References PNS_KICAD_IFACE_BASE::m_debugDecorator.

◆ SetDisplayOptions()

void PNS_KICAD_IFACE::SetDisplayOptions ( const PCB_DISPLAY_OPTIONS aDispOptions)

Definition at line 1276 of file pns_kicad_iface.cpp.

1277 {
1278  m_dispOptions = aDispOptions;
1279 }
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 1270 of file pns_kicad_iface.cpp.

1271 {
1272  m_tool = aTool;
1273  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1274 }
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_BASE::SetRouter ( PNS::ROUTER aRouter)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 1264 of file pns_kicad_iface.cpp.

1265 {
1266  m_router = aRouter;
1267 }
PNS::ROUTER * m_router

References PNS_KICAD_IFACE_BASE::m_router.

◆ SetView()

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

Definition at line 1225 of file pns_kicad_iface.cpp.

1226 {
1227  wxLogTrace( "PNS", "SetView %p", aView );
1228 
1229  if( m_previewItems )
1230  {
1232  delete m_previewItems;
1233  }
1234 
1235  m_view = aView;
1238 
1239  if(m_view)
1241 
1242  delete m_debugDecorator;
1243 
1244  auto dec = new PNS_PCBNEW_DEBUG_DECORATOR();
1245  m_debugDecorator = dec;
1246 
1247  if( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
1248  dec->SetView( m_view );
1249 }
PNS::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
currently selected items overlay
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
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(), ADVANCED_CFG::GetCfg(), LAYER_SELECT_OVERLAY, PNS_KICAD_IFACE_BASE::m_debugDecorator, m_previewItems, m_view, and KIGFX::VIEW_GROUP::SetLayer().

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

◆ syncArc()

std::unique_ptr< PNS::ARC > PNS_KICAD_IFACE_BASE::syncArc ( ARC aArc)
protectedinherited

Definition at line 672 of file pns_kicad_iface.cpp.

673 {
674  std::unique_ptr< PNS::ARC > arc(
675  new PNS::ARC( SHAPE_ARC( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(),
676  aArc->GetWidth() ), aArc->GetNetCode() )
677  );
678 
679  arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
680  arc->SetParent( aArc );
681 
682  if( aArc->IsLocked() )
683  arc->Mark( PNS::MK_LOCKED );
684 
685  return arc;
686 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:133
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:118
const wxPoint & GetMid() const
Definition: class_track.h:288
int GetWidth() const
Definition: class_track.h:112
const wxPoint & GetEnd() const
Definition: class_track.h:115
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(), ARC::GetMid(), BOARD_CONNECTED_ITEM::GetNetCode(), TRACK::GetStart(), TRACK::GetWidth(), TRACK::IsLocked(), and PNS::MK_LOCKED.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncGraphicalItem()

bool PNS_KICAD_IFACE_BASE::syncGraphicalItem ( PNS::NODE aWorld,
DRAWSEGMENT aItem 
)
protectedinherited

Definition at line 832 of file pns_kicad_iface.cpp.

833 {
834  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
835  return false;
836 
837  // TODO: where do we handle filled polygons on copper layers?
838  if( aItem->GetShape() == S_POLYGON && aItem->IsPolygonFilled() )
839  return false;
840 
841  for( SHAPE* shape : aItem->MakeEffectiveShapes() )
842  {
843  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
844 
845  if( aItem->GetLayer() == Edge_Cuts )
846  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
847  else
848  solid->SetLayer( aItem->GetLayer() );
849 
850  solid->SetNet( -1 );
851  solid->SetParent( nullptr );
852  solid->SetShape( shape );
853  solid->SetRoutable( false );
854 
855  aWorld->Add( std::move( solid ) );
856  }
857 
858  return true;
859 }
STROKE_T GetShape() const
polygon (not yet used for tracks, but could be in microwave apps)
std::vector< SHAPE * > MakeEffectiveShapes()
Makes a set of SHAPE objects representing the DRAWSEGMENT.
SHAPE.
Definition: shape.h:74
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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:620
LAYER_RANGE.
Definition: pns_layerset.h:32

References PNS::NODE::Add(), B_Cu, Edge_Cuts, F_Cu, BOARD_ITEM::GetLayer(), DRAWSEGMENT::GetShape(), IsCopperLayer(), DRAWSEGMENT::IsPolygonFilled(), DRAWSEGMENT::MakeEffectiveShapes(), and S_POLYGON.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncPad()

std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE_BASE::syncPad ( D_PAD aPad)
protectedinherited

Definition at line 570 of file pns_kicad_iface.cpp.

571 {
572  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
573 
574  // ignore non-copper pads
575  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
576  return NULL;
577 
578  switch( aPad->GetAttribute() )
579  {
580  case PAD_ATTRIB_STANDARD:
581  break;
582 
583  case PAD_ATTRIB_SMD:
585  case PAD_ATTRIB_CONN:
586  {
587  LSET lmsk = aPad->GetLayerSet();
588  bool is_copper = false;
589 
590  for( int i = 0; i < MAX_CU_LAYERS; i++ )
591  {
592  if( lmsk[i] )
593  {
594  is_copper = true;
595 
597  layers = LAYER_RANGE( i );
598 
599  break;
600  }
601  }
602 
603  if( !is_copper )
604  return NULL;
605  }
606  break;
607 
608  default:
609  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
610  return NULL;
611  }
612 
613  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
614 
615  solid->SetLayers( layers );
616  solid->SetNet( aPad->GetNetCode() );
617  solid->SetParent( aPad );
618  solid->SetPadToDie( aPad->GetPadToDieLength() );
619 
620  wxPoint wx_c = aPad->ShapePos();
621  wxSize wx_sz = aPad->GetSize();
622  wxPoint offset = aPad->GetOffset();
623 
624  VECTOR2I c( wx_c.x, wx_c.y );
625 
626  RotatePoint( &offset, aPad->GetOrientation() );
627 
628  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
629  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
630 
631  if( aPad->GetEffectiveShapes().size() == 1 )
632  {
633  solid->SetShape( aPad->GetEffectiveShapes()[0]->Clone() );
634  }
635  else
636  {
637  // JEY TODO:
638  // TOM TODO: move to SHAPE_COMPOUND...
639 
640  SHAPE_POLY_SET outline;
641  aPad->TransformShapeWithClearanceToPolygon( outline, 0 );
642 
643  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
644 
645  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
646  shape->Append( *iter );
647 
648  solid->SetShape( shape );
649  }
650 
651  return solid;
652 }
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:712
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:85
int GetPadToDieLength() const
Definition: class_pad.h:342
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const std::vector< std::shared_ptr< SHAPE > > & GetEffectiveShapes() const
Function GetEffectiveShapes Returns a list of SHAPE objects representing the pad's copper.
Definition: class_pad.cpp:194
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:332
LSET is a set of PCB_LAYER_IDs.
#define NULL
SHAPE_POLY_SET.
const wxPoint & GetOffset() const
Definition: class_pad.h:229
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:329
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:313
wxPoint ShapePos() const
Definition: class_pad.cpp:491
const wxSize & GetSize() const
Definition: class_pad.h:220
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:144
LAYER_RANGE.
Definition: pns_layerset.h:32

References LSET::AllCuMask(), SHAPE_SIMPLE::Append(), SHAPE_POLY_SET::CIterate(), D_PAD::GetAttribute(), D_PAD::GetEffectiveShapes(), D_PAD::GetLayerSet(), BOARD_CONNECTED_ITEM::GetNetCode(), D_PAD::GetOffset(), D_PAD::GetOrientation(), D_PAD::GetPadToDieLength(), D_PAD::GetSize(), MAX_CU_LAYERS, NULL, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PAD_ATTRIB_STANDARD, RotatePoint(), D_PAD::ShapePos(), D_PAD::TransformShapeWithClearanceToPolygon(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncTextItem()

bool PNS_KICAD_IFACE_BASE::syncTextItem ( PNS::NODE aWorld,
EDA_TEXT aText,
PCB_LAYER_ID  aLayer 
)
protectedinherited

Definition at line 780 of file pns_kicad_iface.cpp.

781 {
782  if( !IsCopperLayer( aLayer ) )
783  return false;
784 
785  int textWidth = aText->GetEffectiveTextPenWidth();
786  std::vector<wxPoint> textShape;
787 
788  aText->TransformTextShapeToSegmentList( textShape );
789 
790  if( textShape.size() < 2 )
791  return false;
792 
793  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
794  {
795  VECTOR2I start( textShape[jj] );
796  VECTOR2I end( textShape[jj+1] );
797  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
798 
799  solid->SetLayer( aLayer );
800  solid->SetNet( -1 );
801  solid->SetParent( nullptr );
802  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
803  solid->SetRoutable( false );
804 
805  aWorld->Add( std::move( solid ) );
806  }
807 
808  return true;
809 
810  /* A coarser (but faster) method:
811  *
812  SHAPE_POLY_SET outline;
813  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
814 
815  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
816 
817  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
818  shape->Append( *iter );
819 
820  solid->SetShape( shape );
821 
822  solid->SetLayer( aLayer );
823  solid->SetNet( -1 );
824  solid->SetParent( nullptr );
825  solid->SetRoutable( false );
826  aWorld->Add( std::move( solid ) );
827  return true;
828  */
829 }
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:578
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:620

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

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncTrack()

std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE_BASE::syncTrack ( TRACK aTrack)
protectedinherited

Definition at line 655 of file pns_kicad_iface.cpp.

656 {
657  std::unique_ptr< PNS::SEGMENT > segment(
658  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
659  );
660 
661  segment->SetWidth( aTrack->GetWidth() );
662  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
663  segment->SetParent( aTrack );
664 
665  if( aTrack->IsLocked() )
666  segment->Mark( PNS::MK_LOCKED );
667 
668  return segment;
669 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:133
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:118
Definition: seg.h:39
int GetWidth() const
Definition: class_track.h:112
const wxPoint & GetEnd() const
Definition: class_track.h:115
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 PNS_KICAD_IFACE_BASE::SyncWorld().

◆ syncVia()

std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE_BASE::syncVia ( VIA aVia)
protectedinherited

Definition at line 689 of file pns_kicad_iface.cpp.

690 {
691  PCB_LAYER_ID top, bottom;
692  aVia->LayerPair( &top, &bottom );
693  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
694  aVia->GetPosition(),
695  LAYER_RANGE( top, bottom ),
696  aVia->GetWidth(),
697  aVia->GetDrillValue(),
698  aVia->GetNetCode(),
699  aVia->GetViaType() )
700  );
701 
702  via->SetParent( aVia );
703 
704  if( aVia->IsLocked() )
705  via->Mark( PNS::MK_LOCKED );
706 
707  return via;
708 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:133
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:406
int GetWidth() const
Definition: class_track.h:112
VIATYPE GetViaType() const
Definition: class_track.h:368
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 PNS_KICAD_IFACE_BASE::SyncWorld().

◆ SyncWorld()

void PNS_KICAD_IFACE_BASE::SyncWorld ( PNS::NODE aWorld)
overridevirtualinherited

Implements PNS::ROUTER_IFACE.

Definition at line 924 of file pns_kicad_iface.cpp.

925 {
926  int worstPadClearance = 0;
927 
928  if( !m_board )
929  {
930  wxLogTrace( "PNS", "No board attached, aborting sync." );
931  return;
932  }
933 
934  for( auto gitem : m_board->Drawings() )
935  {
936  if ( gitem->Type() == PCB_LINE_T )
937  {
938  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
939  }
940  else if( gitem->Type() == PCB_TEXT_T )
941  {
942  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
943  }
944  }
945 
946  for( auto zone : m_board->Zones() )
947  {
948  syncZone( aWorld, zone );
949  }
950 
951  for( auto module : m_board->Modules() )
952  {
953  for( auto pad : module->Pads() )
954  {
955  if( auto solid = syncPad( pad ) )
956  aWorld->Add( std::move( solid ) );
957 
958  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
959  }
960 
961  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
962  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
963 
964  for( MODULE_ZONE_CONTAINER* zone : module->Zones() )
965  syncZone( aWorld, zone );
966 
967  if( module->IsNetTie() )
968  continue;
969 
970  for( auto mgitem : module->GraphicalItems() )
971  {
972  if( mgitem->Type() == PCB_MODULE_EDGE_T )
973  {
974  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
975  }
976  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
977  {
978  syncTextItem( aWorld, static_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
979  }
980  }
981  }
982 
983  for( auto t : m_board->Tracks() )
984  {
985  KICAD_T type = t->Type();
986 
987  if( type == PCB_TRACE_T )
988  {
989  if( auto segment = syncTrack( t ) )
990  aWorld->Add( std::move( segment ) );
991  }
992  else if( type == PCB_ARC_T )
993  {
994  if( auto arc = syncArc( static_cast<ARC*>( t ) ) )
995  aWorld->Add( std::move( arc ) );
996  }
997  else if( type == PCB_VIA_T )
998  {
999  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1000  aWorld->Add( std::move( via ) );
1001  }
1002  }
1003 
1004  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1005 
1006  delete m_ruleResolver;
1008 
1009  aWorld->SetRuleResolver( m_ruleResolver );
1010  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1011 }
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:171
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:165
MODULES & Modules()
Definition: class_board.h:266
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
PNS::ROUTER * m_router
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
std::unique_ptr< PNS::ARC > syncArc(ARC *aArc)
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
MODULE_ZONE_CONTAINER is the same item as ZONE_CONTAINER, but with a specific type id ZONE_CONTAINER ...
Definition: class_zone.h:952
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
DRAWINGS & Drawings()
Definition: class_board.h:275
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620
TRACKS & Tracks()
Definition: class_board.h:257
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)

References PNS::NODE::Add(), BOARD::Drawings(), BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue(), BOARD::GetDesignSettings(), PNS_KICAD_IFACE_BASE::m_board, PNS_KICAD_IFACE_BASE::m_router, PNS_KICAD_IFACE_BASE::m_ruleResolver, BOARD::Modules(), PCB_ARC_T, 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(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncPad(), PNS_KICAD_IFACE_BASE::syncTextItem(), PNS_KICAD_IFACE_BASE::syncTrack(), PNS_KICAD_IFACE_BASE::syncVia(), PNS_KICAD_IFACE_BASE::syncZone(), BOARD::Tracks(), and BOARD::Zones().

◆ syncZone()

bool PNS_KICAD_IFACE_BASE::syncZone ( PNS::NODE aWorld,
ZONE_CONTAINER aZone 
)
protectedinherited

Definition at line 711 of file pns_kicad_iface.cpp.

712 {
713  SHAPE_POLY_SET poly;
714 
715  // TODO handle no-via restriction
716  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
717  return false;
718 
719  // Some intersecting zones, despite being on the same layer with the same net, cannot be
720  // merged due to other parameters such as fillet radius. The copper pour will end up
721  // effectively merged though, so we want to keep the corners of such intersections sharp.
722  std::set<VECTOR2I> colinearCorners;
723  aZone->GetColinearCorners( m_board, colinearCorners );
724 
725  aZone->BuildSmoothedPoly( poly, &colinearCorners );
726  poly.CacheTriangulation();
727 
728  if( !poly.IsTriangulationUpToDate() )
729  {
730  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
731  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
732  dlg.ShowDetailedText(
733  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
734  "Please verify it is not a self-intersecting polygon." ),
736  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
737  dlg.ShowModal();
738 
739  return false;
740  }
741 
742  LSET layers = aZone->GetLayerSet();
743 
744  for( int layer = F_Cu; layer <= B_Cu; layer++ )
745  {
746  if ( ! layers[layer] )
747  continue;
748 
749  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
750  {
751  auto tri = poly.TriangulatedPolygon( outline );
752 
753  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
754  {
755  VECTOR2I a, b, c;
756  tri->GetTriangle( i, a, b, c );
757  auto triShape = new SHAPE_SIMPLE;
758 
759  triShape->Append( a );
760  triShape->Append( b );
761  triShape->Append( c );
762 
763  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
764 
765  solid->SetLayer( layer );
766  solid->SetNet( -1 );
767  solid->SetParent( aZone );
768  solid->SetShape( triShape );
769  solid->SetRoutable( false );
770 
771  aWorld->Add( std::move( solid ) );
772  }
773  }
774  }
775 
776  return true;
777 }
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:230
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:312
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:702
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:914
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:33
bool GetDoNotAllowTracks() const
Definition: class_zone.h:705
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:144

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, PNS_KICAD_IFACE_BASE::m_board, MILLIMETRES, SHAPE_POLY_SET::OutlineCount(), KIDIALOG::ShowModal(), SHAPE_POLY_SET::TriangulatedPolygon(), wxPoint::x, and wxPoint::y.

Referenced by PNS_KICAD_IFACE_BASE::SyncWorld().

◆ UpdateNet()

void PNS_KICAD_IFACE::UpdateNet ( int  aNetCode)
overridevirtual

Reimplemented from PNS_KICAD_IFACE_BASE.

Definition at line 1252 of file pns_kicad_iface.cpp.

1253 {
1254  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1255 
1256 }

Member Data Documentation

◆ m_board

◆ m_commit

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

Definition at line 118 of file pns_kicad_iface.h.

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

◆ m_debugDecorator

◆ m_dispOptions

const PCB_DISPLAY_OPTIONS* PNS_KICAD_IFACE::m_dispOptions
private

Definition at line 119 of file pns_kicad_iface.h.

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

◆ m_hiddenItems

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

Definition at line 115 of file pns_kicad_iface.h.

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

◆ m_moduleOffsets

std::map<D_PAD*, OFFSET> PNS_KICAD_IFACE::m_moduleOffsets
private

Definition at line 112 of file pns_kicad_iface.h.

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

◆ m_previewItems

KIGFX::VIEW_GROUP* PNS_KICAD_IFACE::m_previewItems
private

Definition at line 114 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_BASE::m_router
protectedinherited

◆ m_ruleResolver

◆ m_tool

PCB_TOOL_BASE* PNS_KICAD_IFACE::m_tool
private

Definition at line 117 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: