KiCad PCB EDA Suite
pns_kicad_iface.cpp
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2016 CERN
5  * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <undo_redo_container.h>
23 #include <class_board.h>
24 #include <board_connected_item.h>
25 #include <class_module.h>
26 #include <class_track.h>
27 #include <class_zone.h>
28 #include <class_drawsegment.h>
29 #include <board_commit.h>
31 #include <geometry/convex_hull.h>
32 #include <confirm.h>
33 
34 #include <view/view.h>
35 #include <view/view_item.h>
36 #include <view/view_group.h>
38 
39 #include <pcb_painter.h>
40 
41 #include <geometry/shape.h>
43 #include <geometry/shape_rect.h>
44 #include <geometry/shape_circle.h>
45 #include <geometry/shape_arc.h>
46 #include <geometry/convex_hull.h>
47 
48 #include "tools/pcb_tool.h"
49 
50 #include "pns_kicad_iface.h"
51 
52 #include "../../include/geometry/shape_simple.h"
53 #include "pns_routing_settings.h"
54 #include "pns_sizes_settings.h"
55 #include "pns_item.h"
56 #include "pns_solid.h"
57 #include "pns_segment.h"
58 #include "pns_solid.h"
59 #include "pns_itemset.h"
60 #include "pns_node.h"
61 #include "pns_topology.h"
62 #include "pns_router.h"
63 #include "pns_debug_decorator.h"
64 #include "router_preview_item.h"
65 
67 {
68 public:
69  PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER* aRouter );
70  virtual ~PNS_PCBNEW_RULE_RESOLVER();
71 
72  virtual int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const override;
73  virtual int Clearance( int aNetCode ) const override;
74  virtual int DpCoupledNet( int aNet ) override;
75  virtual int DpNetPolarity( int aNet ) override;
76  virtual bool DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN ) override;
77  virtual wxString NetName( int aNet ) override;
78 
79 private:
81  {
84  int clearance;
85  };
86 
87  int localPadClearance( const PNS::ITEM* aItem ) const;
88  int matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName );
89 
92 
93  std::vector<CLEARANCE_ENT> m_netClearanceCache;
94  std::unordered_map<const D_PAD*, int> m_localClearanceCache;
96 };
97 
98 
100  m_router( aRouter ),
101  m_board( aBoard )
102 {
103  PNS::NODE* world = m_router->GetWorld();
104 
105  PNS::TOPOLOGY topo( world );
107 
108  // Build clearance cache for net classes
109  for( unsigned int i = 0; i < m_board->GetNetCount(); i++ )
110  {
111  NETINFO_ITEM* ni = m_board->FindNet( i );
112 
113  if( ni == NULL )
114  continue;
115 
116  CLEARANCE_ENT ent;
117  ent.coupledNet = DpCoupledNet( i );
118 
119  wxString netClassName = ni->GetClassName();
120  NETCLASSPTR nc = m_board->GetDesignSettings().m_NetClasses.Find( netClassName );
121 
122  int clearance = nc->GetClearance();
123  ent.clearance = clearance;
124  ent.dpClearance = nc->GetDiffPairGap();
125  m_netClearanceCache[i] = ent;
126 
127  wxLogTrace( "PNS", "Add net %u netclass %s clearance %d Diff Pair clearance %d",
128  i, netClassName.mb_str(), clearance, ent.dpClearance );
129  }
130 
131  // Build clearance cache for pads
132  for( MODULE* mod = m_board->m_Modules; mod ; mod = mod->Next() )
133  {
134  auto moduleClearance = mod->GetLocalClearance();
135 
136  for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() )
137  {
138  int padClearance = pad->GetLocalClearance();
139 
140  if( padClearance > 0 )
141  m_localClearanceCache[ pad ] = padClearance;
142 
143  else if( moduleClearance > 0 )
144  m_localClearanceCache[ pad ] = moduleClearance;
145  }
146  }
147 
148  auto defaultRule = m_board->GetDesignSettings().m_NetClasses.Find ("Default");
149 
150  if( defaultRule )
151  {
152  m_defaultClearance = defaultRule->GetClearance();
153  }
154  else
155  {
156  m_defaultClearance = Millimeter2iu(0.254);
157  }
158 }
159 
160 
162 {
163 }
164 
165 
167 {
168  if( !aItem->Parent() || aItem->Parent()->Type() != PCB_PAD_T )
169  return 0;
170 
171  const D_PAD* pad = static_cast<D_PAD*>( aItem->Parent() );
172 
173  auto i = m_localClearanceCache.find( pad );
174 
175  if( i == m_localClearanceCache.end() )
176  return 0;
177 
178  return i->second;
179 }
180 
181 
182 int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const
183 {
184  int net_a = aA->Net();
185  int cl_a = ( net_a >= 0 ? m_netClearanceCache[net_a].clearance : m_defaultClearance );
186  int net_b = aB->Net();
187  int cl_b = ( net_b >= 0 ? m_netClearanceCache[net_b].clearance : m_defaultClearance );
188 
189  // Clearance in differential pairs can only happen when there is a specific net
190  if( net_a >= 0 && net_b >= 0 && m_netClearanceCache[net_a].coupledNet == net_b )
191  {
192  cl_a = m_netClearanceCache[net_a].dpClearance;
193  cl_b = m_netClearanceCache[net_b].dpClearance;
194  }
195 
196  // Pad clearance is 0 if the ITEM* is not a pad
197  int pad_a = localPadClearance( aA );
198  int pad_b = localPadClearance( aB );
199 
200  if( pad_a > 0 )
201  cl_a = pad_a;
202 
203  if( pad_b > 0 )
204  cl_b = pad_b;
205 
206  return std::max( cl_a, cl_b );
207 }
208 
209 
210 int PNS_PCBNEW_RULE_RESOLVER::Clearance( int aNetCode ) const
211 {
212  if( aNetCode > 0 && aNetCode < (int) m_netClearanceCache.size() )
213  return m_netClearanceCache[aNetCode].clearance;
214 
215  return m_defaultClearance;
216 }
217 
218 
219 int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName )
220 {
221  int rv = 0;
222 
223  if( aNetName.EndsWith( "+" ) )
224  {
225  aComplementNet = "-";
226  rv = 1;
227  }
228  else if( aNetName.EndsWith( "P" ) )
229  {
230  aComplementNet = "N";
231  rv = 1;
232  }
233  else if( aNetName.EndsWith( "-" ) )
234  {
235  aComplementNet = "+";
236  rv = -1;
237  }
238  else if( aNetName.EndsWith( "N" ) )
239  {
240  aComplementNet = "P";
241  rv = -1;
242  }
243  // Match P followed by 2 digits
244  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "P" )
245  {
246  aComplementNet = "N" + aNetName.Right( 2 );
247  rv = 1;
248  }
249  // Match P followed by 1 digit
250  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "P" )
251  {
252  aComplementNet = "N" + aNetName.Right( 1 );
253  rv = 1;
254  }
255  // Match N followed by 2 digits
256  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "N" )
257  {
258  aComplementNet = "P" + aNetName.Right( 2 );
259  rv = -1;
260  }
261  // Match N followed by 1 digit
262  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "N" )
263  {
264  aComplementNet = "P" + aNetName.Right( 1 );
265  rv = -1;
266  }
267  if( rv != 0 )
268  {
269  aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
270  aComplementNet = aBaseDpName + aComplementNet;
271  }
272 
273  return rv;
274 }
275 
276 
278 {
279  wxString refName = m_board->FindNet( aNet )->GetNetname();
280  wxString dummy, coupledNetName;
281 
282  if( matchDpSuffix( refName, coupledNetName, dummy ) )
283  {
284  NETINFO_ITEM* net = m_board->FindNet( coupledNetName );
285 
286  if( !net )
287  return -1;
288 
289  return net->GetNet();
290  }
291 
292  return -1;
293 }
294 
295 
297 {
298  return m_board->FindNet( aNet )->GetNetname();
299 }
300 
301 
303 {
304  wxString refName = m_board->FindNet( aNet )->GetNetname();
305  wxString dummy1, dummy2;
306 
307  return matchDpSuffix( refName, dummy1, dummy2 );
308 }
309 
310 
311 bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN )
312 {
313  if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
314  return false;
315 
316  wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
317  wxString netNameN, netNameCoupled, netNameBase;
318 
319  int r = matchDpSuffix( netNameP, netNameCoupled, netNameBase );
320 
321  if( r == 0 )
322  return false;
323  else if( r == 1 )
324  {
325  netNameN = netNameCoupled;
326  }
327  else
328  {
329  netNameN = netNameP;
330  netNameP = netNameCoupled;
331  }
332 
333 // wxLogTrace( "PNS","p %s n %s base %s\n", (const char *)netNameP.c_str(), (const char *)netNameN.c_str(), (const char *)netNameBase.c_str() );
334 
335  NETINFO_ITEM* netInfoP = m_board->FindNet( netNameP );
336  NETINFO_ITEM* netInfoN = m_board->FindNet( netNameN );
337 
338  //wxLogTrace( "PNS","ip %p in %p\n", netInfoP, netInfoN);
339 
340  if( !netInfoP || !netInfoN )
341  return false;
342 
343  aNetP = netInfoP->GetNet();
344  aNetN = netInfoN->GetNet();
345 
346  return true;
347 }
348 
349 
351 {
352 public:
353  PNS_PCBNEW_DEBUG_DECORATOR( KIGFX::VIEW* aView = NULL ): PNS::DEBUG_DECORATOR(),
354  m_view( NULL ), m_items( NULL )
355  {
356  SetView( aView );
357  }
358 
360  {
361  Clear();
362  delete m_items;
363  }
364 
365  void SetView( KIGFX::VIEW* aView )
366  {
367  Clear();
368  delete m_items;
369  m_items = NULL;
370  m_view = aView;
371 
372  if( m_view == NULL )
373  return;
374 
375  m_items = new KIGFX::VIEW_GROUP( m_view );
376  m_items->SetLayer( LAYER_GP_OVERLAY ) ;
377  m_view->Add( m_items );
378  }
379 
380  void AddPoint( VECTOR2I aP, int aColor ) override
381  {
383 
384  l.Append( aP - VECTOR2I( -50000, -50000 ) );
385  l.Append( aP + VECTOR2I( -50000, -50000 ) );
386 
387  AddLine( l, aColor, 10000 );
388 
389  l.Clear();
390  l.Append( aP - VECTOR2I( 50000, -50000 ) );
391  l.Append( aP + VECTOR2I( 50000, -50000 ) );
392 
393  AddLine( l, aColor, 10000 );
394  }
395 
396  void AddBox( BOX2I aB, int aColor ) override
397  {
399 
400  VECTOR2I o = aB.GetOrigin();
401  VECTOR2I s = aB.GetSize();
402 
403  l.Append( o );
404  l.Append( o.x + s.x, o.y );
405  l.Append( o.x + s.x, o.y + s.y );
406  l.Append( o.x, o.y + s.y );
407  l.Append( o );
408 
409  AddLine( l, aColor, 10000 );
410  }
411 
412  void AddSegment( SEG aS, int aColor ) override
413  {
415 
416  l.Append( aS.A );
417  l.Append( aS.B );
418 
419  AddLine( l, aColor, 10000 );
420  }
421 
422  void AddDirections( VECTOR2D aP, int aMask, int aColor ) override
423  {
424  BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );
425 
426  AddBox( b, aColor );
427  for( int i = 0; i < 8; i++ )
428  {
429  if( ( 1 << i ) & aMask )
430  {
432  AddSegment( SEG( aP, aP + v ), aColor );
433  }
434  }
435  }
436 
437  void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth ) override
438  {
439  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( NULL, m_view );
440 
441  pitem->Line( aLine, aWidth, aType );
442  m_items->Add( pitem ); // Should not be needed, as m_items has been passed as a parent group in alloc;
443  m_view->Update( m_items );
444  }
445 
446  void Clear() override
447  {
448  if( m_view && m_items )
449  {
450  m_items->FreeItems();
451  m_view->Update( m_items );
452  }
453  }
454 
455 private:
458 };
459 
460 
462 {
463  return m_debugDecorator;
464 }
465 
466 
468 {
469  m_ruleResolver = nullptr;
470  m_board = nullptr;
471  m_tool = nullptr;
472  m_view = nullptr;
473  m_previewItems = nullptr;
474  m_router = nullptr;
475  m_debugDecorator = nullptr;
476  m_dispOptions = nullptr;
477 }
478 
479 
481 {
482  delete m_ruleResolver;
483  delete m_debugDecorator;
484 
485  if( m_previewItems )
486  {
487  m_previewItems->FreeItems();
488  delete m_previewItems;
489  }
490 }
491 
492 
493 std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
494 {
495  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
496 
497  // ignore non-copper pads
498  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
499  return NULL;
500 
501  switch( aPad->GetAttribute() )
502  {
503  case PAD_ATTRIB_STANDARD:
504  break;
505 
506  case PAD_ATTRIB_SMD:
508  case PAD_ATTRIB_CONN:
509  {
510  LSET lmsk = aPad->GetLayerSet();
511  bool is_copper = false;
512 
513  for( int i = 0; i < MAX_CU_LAYERS; i++ )
514  {
515  if( lmsk[i] )
516  {
517  is_copper = true;
518 
520  layers = LAYER_RANGE( i );
521 
522  break;
523  }
524  }
525 
526  if( !is_copper )
527  return NULL;
528  }
529  break;
530 
531  default:
532  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
533  return NULL;
534  }
535 
536  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
537 
538  solid->SetLayers( layers );
539  solid->SetNet( aPad->GetNetCode() );
540  solid->SetParent( aPad );
541 
542  wxPoint wx_c = aPad->ShapePos();
543  wxSize wx_sz = aPad->GetSize();
544  wxPoint offset = aPad->GetOffset();
545 
546  VECTOR2I c( wx_c.x, wx_c.y );
547  VECTOR2I sz( wx_sz.x, wx_sz.y );
548 
549  RotatePoint( &offset, aPad->GetOrientation() );
550 
551  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
552  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
553 
554  double orient = aPad->GetOrientation() / 10.0;
555 
556  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
557  {
558  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
559  }
560  else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
561  {
562  SHAPE_POLY_SET outline;
563  outline.Append( aPad->GetCustomShapeAsPolygon() );
564  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
565 
566  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
567 
568  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
569  shape->Append( *iter );
570 
571  solid->SetShape( shape );
572  }
573  else
574  {
575  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
576  {
577  if( orient == 90.0 || orient == 270.0 )
578  sz = VECTOR2I( sz.y, sz.x );
579 
580  switch( aPad->GetShape() )
581  {
582  case PAD_SHAPE_OVAL:
583  if( sz.x == sz.y )
584  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
585  else
586  {
587  VECTOR2I delta;
588 
589  if( sz.x > sz.y )
590  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
591  else
592  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
593 
594  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
595  std::min( sz.x, sz.y ) );
596  solid->SetShape( shape );
597  }
598  break;
599 
600  case PAD_SHAPE_RECT:
601  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
602  break;
603 
604  case PAD_SHAPE_TRAPEZOID:
605  {
606  wxPoint coords[4];
607  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
608  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
609 
610  for( int ii = 0; ii < 4; ii++ )
611  {
612  shape->Append( wx_c + coords[ii] );
613  }
614 
615  solid->SetShape( shape );
616  break;
617  }
618 
619  case PAD_SHAPE_ROUNDRECT:
620  {
621  SHAPE_POLY_SET outline;
622  const int segmentToCircleCount = 64;
623 
624  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
625 
626  // TransformRoundRectToPolygon creates only one convex polygon
627  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
628  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
629 
630  for( int ii = 0; ii < poly.PointCount(); ++ii )
631  {
632  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
633  }
634 
635  solid->SetShape( shape );
636  }
637  break;
638 
639  default:
640  wxLogTrace( "PNS", "unsupported pad shape" );
641  return nullptr;
642  }
643  }
644  else
645  {
646  switch( aPad->GetShape() )
647  {
648  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
649 
650  case PAD_SHAPE_OVAL:
651  if( sz.x == sz.y )
652  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
653  else
654  {
655  wxPoint start;
656  wxPoint end;
657  wxPoint corner;
658 
659  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
660 
661  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
662 
663  if( start.y == 0 )
664  corner = wxPoint( start.x, -( w / 2 ) );
665  else
666  corner = wxPoint( w / 2, start.y );
667 
668  RotatePoint( &start, aPad->GetOrientation() );
669  RotatePoint( &corner, aPad->GetOrientation() );
670  shape->Append( wx_c + corner );
671 
672  for( int rot = 100; rot <= 1800; rot += 100 )
673  {
674  wxPoint p( corner );
675  RotatePoint( &p, start, rot );
676  shape->Append( wx_c + p );
677  }
678 
679  if( end.y == 0 )
680  corner = wxPoint( end.x, w / 2 );
681  else
682  corner = wxPoint( -( w / 2 ), end.y );
683 
684  RotatePoint( &end, aPad->GetOrientation() );
685  RotatePoint( &corner, aPad->GetOrientation() );
686  shape->Append( wx_c + corner );
687 
688  for( int rot = 100; rot <= 1800; rot += 100 )
689  {
690  wxPoint p( corner );
691  RotatePoint( &p, end, rot );
692  shape->Append( wx_c + p );
693  }
694 
695  solid->SetShape( shape );
696  }
697  break;
698 
699  case PAD_SHAPE_RECT:
700  case PAD_SHAPE_TRAPEZOID:
701  {
702  wxPoint coords[4];
703  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
704 
705  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
706  for( int ii = 0; ii < 4; ii++ )
707  {
708  shape->Append( wx_c + coords[ii] );
709  }
710 
711  solid->SetShape( shape );
712  break;
713  }
714 
715  case PAD_SHAPE_ROUNDRECT:
716  {
717  SHAPE_POLY_SET outline;
718  const int segmentToCircleCount = 32;
719  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
720  segmentToCircleCount, 1.0 );
721 
722  // TransformRoundRectToPolygon creates only one convex polygon
723  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
724  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
725 
726  for( int ii = 0; ii < poly.PointCount(); ++ii )
727  {
728  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
729  }
730 
731  solid->SetShape( shape );
732  break;
733  }
734 
735  default:
736  wxLogTrace( "PNS", "unsupported pad shape" );
737  return nullptr;
738  }
739  }
740  }
741  return solid;
742 }
743 
744 
745 std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
746 {
747  std::unique_ptr< PNS::SEGMENT > segment(
748  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
749  );
750 
751  segment->SetWidth( aTrack->GetWidth() );
752  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
753  segment->SetParent( aTrack );
754 
755  if( aTrack->IsLocked() )
756  segment->Mark( PNS::MK_LOCKED );
757 
758  return segment;
759 }
760 
761 
762 std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE::syncVia( VIA* aVia )
763 {
764  PCB_LAYER_ID top, bottom;
765  aVia->LayerPair( &top, &bottom );
766  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
767  aVia->GetPosition(),
768  LAYER_RANGE( top, bottom ),
769  aVia->GetWidth(),
770  aVia->GetDrillValue(),
771  aVia->GetNetCode(),
772  aVia->GetViaType() )
773  );
774 
775  via->SetParent( aVia );
776 
777  if( aVia->IsLocked() )
778  via->Mark( PNS::MK_LOCKED );
779 
780  return via;
781 }
782 
783 
785 {
786  SHAPE_POLY_SET poly;
787 
788  // TODO handle no-via restriction
789  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
790  return false;
791 
792  aZone->BuildSmoothedPoly( poly );
793  poly.CacheTriangulation();
794 
795  if( !poly.IsTriangulationUpToDate() )
796  {
797  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
798  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
799  dlg.ShowDetailedText(
800  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
801  "Please verify it is not a self-intersecting polygon." ), aZone->GetSelectMenuText() ) );
802  dlg.DoNotShowCheckbox();
803  dlg.ShowModal();
804 
805  return false;
806  }
807 
808  LSET layers = aZone->GetLayerSet();
809 
810  for( int layer = F_Cu; layer <= B_Cu; layer++ )
811  {
812  if ( ! layers[layer] )
813  continue;
814 
815  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
816  {
817  auto tri = poly.TriangulatedPolygon( outline );
818 
819  for( int i = 0; i < tri->GetTriangleCount(); i++)
820  {
821  VECTOR2I a, b, c;
822  tri->GetTriangle( i, a, b, c );
823  auto triShape = new SHAPE_SIMPLE;
824 
825  triShape->Append( a );
826  triShape->Append( b );
827  triShape->Append( c );
828 
829  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
830 
831  solid->SetLayer( layer );
832  solid->SetNet( 0 );
833  solid->SetParent( aZone );
834  solid->SetShape( triShape );
835  solid->SetRoutable( false );
836 
837  aWorld->Add( std::move( solid ) );
838  }
839  }
840  }
841 
842  return true;
843 }
844 
846 {
847  std::vector<SHAPE_SEGMENT*> segs;
848 
849  if( aItem->GetLayer() != Edge_Cuts )
850  return false;
851 
852  switch( aItem->GetShape() )
853  {
854  case S_ARC:
855  {
856  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), (double) aItem->GetAngle() / 10.0 );
857 
858  auto l = arc.ConvertToPolyline();
859 
860  for( int i = 0; i < l.SegmentCount(); i++ )
861  {
862  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
863  segs.push_back( seg );
864  }
865 
866  break;
867  }
868 
869  case S_SEGMENT:
870  {
871  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() );
872  segs.push_back( seg );
873 
874  break;
875  }
876 
877  case S_CIRCLE:
878  {
879  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
880  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
881 
882  auto l = circle.ConvertToPolyline();
883 
884  for( int i = 0; i < l.SegmentCount(); i++ )
885  {
886  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
887  segs.push_back( seg );
888  }
889 
890  break;
891  }
892 
893  default:
894  break;
895  }
896 
897  for( auto seg : segs )
898  {
899  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
900 
901  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
902  solid->SetNet( -1 );
903  solid->SetParent( nullptr );
904  solid->SetShape( seg );
905  solid->SetRoutable( false );
906 
907  aWorld->Add( std::move( solid ) );
908  }
909 
910  return true;
911 }
912 
914 {
915  m_board = aBoard;
916  wxLogTrace( "PNS", "m_board = %p", m_board );
917 }
918 
919 
921 {
922  int worstPadClearance = 0;
923 
924  if( !m_board )
925  {
926  wxLogTrace( "PNS", "No board attached, aborting sync." );
927  return;
928  }
929 
930  for( auto gitem : m_board->Drawings() )
931  {
932  if ( gitem->Type() == PCB_LINE_T )
933  {
934  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
935  }
936  }
937 
938  for( auto zone : m_board->Zones() )
939  {
940  syncZone( aWorld, zone );
941  }
942 
943  for( auto module : m_board->Modules() )
944  {
945  for( auto pad : module->Pads() )
946  {
947  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
948 
949  if( solid )
950  aWorld->Add( std::move( solid ) );
951 
952 
953  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
954  }
955  }
956 
957  for( auto t : m_board->Tracks() )
958  {
959  KICAD_T type = t->Type();
960 
961  if( type == PCB_TRACE_T ) {
962  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
963  if( segment ) {
964  aWorld->Add( std::move( segment ) );
965  }
966  } else if( type == PCB_VIA_T ) {
967  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
968  if( via ) {
969  aWorld->Add( std::move( via ) );
970  }
971  }
972  }
973 
974  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
975 
976  delete m_ruleResolver;
977  m_ruleResolver = new PNS_PCBNEW_RULE_RESOLVER( m_board, m_router );
978 
979  aWorld->SetRuleResolver( m_ruleResolver );
980  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
981 }
982 
983 
985 {
986  for( auto item : m_hiddenItems )
987  m_view->SetVisible( item, true );
988 
989  m_hiddenItems.clear();
990 
991  if( m_previewItems )
992  {
993  m_previewItems->FreeItems();
994  m_view->Update( m_previewItems );
995  }
996 
997  if( m_debugDecorator )
998  m_debugDecorator->Clear();
999 }
1000 
1001 
1002 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance )
1003 {
1004  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1005 
1006  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1007 
1008  if( aColor >= 0 )
1009  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1010 
1011  if( aClearance >= 0 )
1012  {
1013  pitem->SetClearance( aClearance );
1014 
1015  if( m_dispOptions )
1016  {
1017  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
1020  && clearanceDisp != PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS );
1021  }
1022  }
1023 
1024 
1025  m_previewItems->Add( pitem );
1026  m_view->Update( m_previewItems );
1027 }
1028 
1029 
1031 {
1032  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1033 
1034  if( parent )
1035  {
1036  if( m_view->IsVisible( parent ) )
1037  m_hiddenItems.insert( parent );
1038 
1039  m_view->SetVisible( parent, false );
1040  m_view->Update( parent, KIGFX::APPEARANCE );
1041  }
1042 }
1043 
1044 
1046 {
1047  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1048 
1049  if( parent )
1050  {
1051  m_commit->Remove( parent );
1052  }
1053 }
1054 
1055 
1057 {
1058  BOARD_CONNECTED_ITEM* newBI = NULL;
1059 
1060  switch( aItem->Kind() )
1061  {
1062  case PNS::ITEM::SEGMENT_T:
1063  {
1064  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1065  TRACK* track = new TRACK( m_board );
1066  const SEG& s = seg->Seg();
1067  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1068  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1069  track->SetWidth( seg->Width() );
1070  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1071  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1072  newBI = track;
1073  break;
1074  }
1075 
1076  case PNS::ITEM::VIA_T:
1077  {
1078  VIA* via_board = new VIA( m_board );
1079  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1080  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1081  via_board->SetWidth( via->Diameter() );
1082  via_board->SetDrill( via->Drill() );
1083  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1084  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1085  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1086  ToLAYER_ID( via->Layers().End() ) );
1087  newBI = via_board;
1088  break;
1089  }
1090 
1091  default:
1092  break;
1093  }
1094 
1095  if( newBI )
1096  {
1097  aItem->SetParent( newBI );
1098  newBI->ClearFlags();
1099 
1100  m_commit->Add( newBI );
1101  }
1102 }
1103 
1104 
1106 {
1107  EraseView();
1108  m_commit->Push( _( "Added a track" ) );
1109  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1110 }
1111 
1112 
1114 {
1115  wxLogTrace( "PNS", "SetView %p", aView );
1116 
1117  if( m_previewItems )
1118  {
1119  m_previewItems->FreeItems();
1120  delete m_previewItems;
1121  }
1122 
1123  m_view = aView;
1124  m_previewItems = new KIGFX::VIEW_GROUP( m_view );
1125  m_previewItems->SetLayer( LAYER_GP_OVERLAY ) ;
1126  m_view->Add( m_previewItems );
1127 
1128  delete m_debugDecorator;
1129  m_debugDecorator = new PNS_PCBNEW_DEBUG_DECORATOR();
1130  m_debugDecorator->SetView( m_view );
1131 }
1132 
1133 
1134 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1135 {
1136  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1137 }
1138 
1139 
1141 {
1142  return m_ruleResolver;
1143 }
1144 
1145 
1147 {
1148  m_router = aRouter;
1149 }
1150 
1151 
1153 {
1154  m_tool = aTool;
1155  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1156 }
1157 
1159 {
1160  m_dispOptions = aDispOptions;
1161 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:137
const VECTOR2I ToVector() const
Function ToVector()
Definition: direction45.h:298
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
const Vec & GetOrigin() const
Definition: box2.h:181
Class ITEM.
Definition: pns_item.h:53
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
int matchDpSuffix(wxString aNetName, wxString &aComplementNet, wxString &aBaseDpName)
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
Class SHAPE_SIMPLE.
Definition: shape_simple.h:42
void SetView(KIGFX::VIEW *aView)
virtual bool DpNetPair(PNS::ITEM *aItem, int &aNetP, int &aNetN) override
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:144
Class NODE.
Definition: pns_node.h:136
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:461
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:209
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
Helper class to create more flexible dialogs, including &#39;do not show again&#39; checkbox handling...
Definition: confirm.h:43
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:433
void DoNotShowCheckbox()
Shows the &#39;do not show again&#39; checkbox
Definition: confirm.h:53
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
This file is part of the common library.
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:118
const wxPoint GetCenter() const override
Function GetCenter()
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int PointCount() const
Function PointCount()
void AddPoint(VECTOR2I aP, int aColor) override
int Drill() const
Definition: pns_via.h:120
Class BOARD to handle a board.
int Diameter() const
Definition: pns_via.h:109
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
wxString GetClassName() const
Function GetClassName returns the class name.
Definition: netinfo.h:131
void UpdateNet(int aNetCode) override
void AddBox(BOX2I aB, int aColor) override
void SetRouter(PNS::ROUTER *aRouter) override
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly if it exists...
int localPadClearance(const PNS::ITEM *aItem) const
void SetClearance(int aClearance)
Classes to handle copper zones.
usual segment : line with rounded ends
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
No updates are required.
Definition: view_item.h:55
Class RULE_RESOLVER.
Definition: pns_node.h:56
bool IsTriangulationUpToDate() const
PNS_PCBNEW_DEBUG_DECORATOR(KIGFX::VIEW *aView=NULL)
void Line(const SHAPE_LINE_CHAIN &aLine, int aWidth=0, int aStyle=0)
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
void ShowTrackClearance(bool aEnabled)
int OutlineCount() const
Returns the number of outlines in the set
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
const VECTOR2I & Pos() const
Definition: pns_via.h:88
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:162
const Vec & GetSize() const
Definition: box2.h:177
void HideItem(PNS::ITEM *aItem) override
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
const wxPoint GetPosition() const override
Function GetPosition.
Definition: class_zone.cpp:169
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
PNS::DEBUG_DECORATOR * GetDebugDecorator() override
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
static const int delta[8][2]
Definition: solve.cpp:112
const wxPoint & GetEnd() const
Definition: class_track.h:119
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
NODE * GetWorld() const
Definition: pns_router.h:143
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
KIGFX::VIEW_GROUP * m_items
void SetWidth(int aWidth)
Definition: class_track.h:115
const wxPoint & GetArcStart() const
virtual int DpNetPolarity(int aNet) override
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:156
VIATYPE_T ViaType() const
Definition: pns_via.h:99
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:230
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
int End() const
Definition: pns_layerset.h:88
void SetParent(BOARD_CONNECTED_ITEM *aParent)
Function SetParent()
Definition: pns_item.h:149
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
STROKE_T GetShape() const
Class LSET is a set of PCB_LAYER_IDs.
VIEW_ITEM class definition.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:253
VIATYPE_T GetViaType() const
Definition: class_track.h:460
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Class DIRECTION_45.
Definition: direction45.h:36
const wxPoint & GetStart() const
Definition: class_track.h:122
Arcs (with rounded ends)
virtual int DpCoupledNet(int aNet) override
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:402
void ShowViaClearance(bool aEnabled)
std::vector< CLEARANCE_ENT > m_netClearanceCache
const wxSize & GetSize() const
Definition: class_pad.h:269
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:535
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
general purpose overlay
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 SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=0.02f) const
Definition: shape_arc.cpp:209
int Width() const
Definition: pns_segment.h:88
int Start() const
Definition: pns_layerset.h:83
int GetNet() const
Function GetNet.
Definition: netinfo.h:227
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:62
void SetColor(const KIGFX::COLOR4D &aColor)
const wxPoint GetPosition() const override
Definition: class_track.h:432
void DisplayItem(const PNS::ITEM *aItem, int aColor=0, int aClearance=0) override
void Commit() override
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...
PNS::RULE_RESOLVER * GetRuleResolver() override
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:122
void EraseView() override
int GetNetCode() const
Function GetNetCode.
Definition: seg.h:36
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
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...
void SyncWorld(PNS::NODE *aWorld) override
bool GetDoNotAllowTracks() const
Definition: class_zone.h:605
ZONE_CONTAINERS & Zones()
Definition: class_board.h:255
double GetAngle() const
Board layer functions and definitions.
Class to handle a graphic segment.
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
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
DLIST< MODULE > m_Modules
Definition: class_board.h:247
Class SHAPE_LINE_CHAIN.
void RemoveItem(PNS::ITEM *aItem) override
int GetWidth() const
Definition: class_track.h:116
virtual wxString NetName(int aNet) override
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
size_t i
Definition: json11.cpp:597
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
VECTOR2I A
Definition: seg.h:46
void AddItem(PNS::ITEM *aItem) override
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:468
void SetView(KIGFX::VIEW *aView)
Usual pad.
Definition: pad_shapes.h:60
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
int Net() const
Function Net()
Definition: pns_item.h:179
int GetWidth() const
void SetHostTool(PCB_TOOL *aTool)
void BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape...
wxPoint ShapePos() const
Definition: class_pad.cpp:500
int ShowModal() override
Definition: confirm.cpp:91
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
void Clear()
Function Clear() Removes all points from the line chain.
void SetStart(const wxPoint &aStart)
Definition: class_track.h:121
const SEG & Seg() const
Definition: pns_segment.h:93
VECTOR2I & Point(int aIndex)
Function Point()
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:252
void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType, int aWidth) override
Module description (excepted pads)
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:235
void AddDirections(VECTOR2D aP, int aMask, int aColor) override
virtual int Clearance(const PNS::ITEM *aA, const PNS::ITEM *aB) const override
Class VIEW.
Definition: view.h:58
Class BOARD_CONNECTED_ITEM.
Directions
Enum Directions Represents available directions - there are 8 of them, as on a rectilinear map (north...
Definition: direction45.h:45
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
void SetDisplayOptions(PCB_DISPLAY_OPTIONS *aDispOptions)
void AddSegment(SEG aS, int aColor) override
Push and Shove diff pair dimensions (gap) settings dialog.
void SetBoard(BOARD *aBoard)
std::unordered_map< const D_PAD *, int > m_localClearanceCache
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:594
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:151
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
#define mod(a, n)
Definition: greymap.cpp:24
PNS_PCBNEW_RULE_RESOLVER(BOARD *aBoard, PNS::ROUTER *aRouter)
const wxPoint & GetOffset() const
Definition: class_pad.h:278
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:159
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
Class LAYER_RANGE.
Definition: pns_layerset.h:32
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:254
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:776
#define min(a, b)
Definition: auxiliary.h:85
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
VECTOR2I B
Definition: seg.h:47