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_convex.h>
46 #include <geometry/shape_arc.h>
47 #include <geometry/convex_hull.h>
48 
49 #include "tools/pcb_tool.h"
50 
51 #include "pns_kicad_iface.h"
52 #include "pns_routing_settings.h"
53 #include "pns_sizes_settings.h"
54 #include "pns_item.h"
55 #include "pns_solid.h"
56 #include "pns_segment.h"
57 #include "pns_solid.h"
58 #include "pns_itemset.h"
59 #include "pns_node.h"
60 #include "pns_topology.h"
61 #include "pns_router.h"
62 #include "pns_debug_decorator.h"
63 #include "router_preview_item.h"
64 
66 {
67 public:
68  PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER* aRouter );
69  virtual ~PNS_PCBNEW_RULE_RESOLVER();
70 
71  virtual int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const override;
72  virtual int Clearance( int aNetCode ) const override;
73  virtual void OverrideClearance( bool aEnable, int aNetA = 0, int aNetB = 0, int aClearance = 0 ) override;
74  virtual void UseDpGap( bool aUseDpGap ) override { m_useDpGap = aUseDpGap; }
75  virtual int DpCoupledNet( int aNet ) override;
76  virtual int DpNetPolarity( int aNet ) override;
77  virtual bool DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN ) override;
78 
79 private:
81  {
83  int clearance;
84  };
85 
86  int localPadClearance( const PNS::ITEM* aItem ) const;
87  int matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName );
88 
91 
92  std::vector<CLEARANCE_ENT> m_netClearanceCache;
93  std::unordered_map<const D_PAD*, int> m_localClearanceCache;
98  bool m_useDpGap;
99 };
100 
101 
103  m_router( aRouter ),
104  m_board( aBoard )
105 {
106  PNS::NODE* world = m_router->GetWorld();
107 
108  PNS::TOPOLOGY topo( world );
110 
111  // Build clearance cache for net classes
112  for( unsigned int i = 0; i < m_board->GetNetCount(); i++ )
113  {
114  NETINFO_ITEM* ni = m_board->FindNet( i );
115 
116  if( ni == NULL )
117  continue;
118 
119  CLEARANCE_ENT ent;
120  ent.coupledNet = DpCoupledNet( i );
121 
122  wxString netClassName = ni->GetClassName();
123  NETCLASSPTR nc = m_board->GetDesignSettings().m_NetClasses.Find( netClassName );
124 
125  int clearance = nc->GetClearance();
126  ent.clearance = clearance;
127  m_netClearanceCache[i] = ent;
128 
129  wxLogTrace( "PNS", "Add net %u netclass %s clearance %d", i, netClassName.mb_str(), clearance );
130  }
131 
132  // Build clearance cache for pads
133  for( MODULE* mod = m_board->m_Modules; mod ; mod = mod->Next() )
134  {
135  auto moduleClearance = mod->GetLocalClearance();
136 
137  for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() )
138  {
139  int padClearance = pad->GetLocalClearance();
140 
141  if( padClearance > 0 )
142  m_localClearanceCache[ pad ] = padClearance;
143 
144  else if( moduleClearance > 0 )
145  m_localClearanceCache[ pad ] = moduleClearance;
146  }
147  }
148 
149  //printf("DefaultCL : %d\n", m_board->GetDesignSettings().m_NetClasses.Find ("Default clearance")->GetClearance());
150 
151  m_overrideEnabled = false;
152  m_defaultClearance = Millimeter2iu( 0.254 ); // m_board->m_NetClasses.Find ("Default clearance")->GetClearance();
153  m_overrideNetA = 0;
154  m_overrideNetB = 0;
156  m_useDpGap = false;
157 }
158 
159 
161 {
162 }
163 
164 
166 {
167  if( !aItem->Parent() || aItem->Parent()->Type() != PCB_PAD_T )
168  return 0;
169 
170  const D_PAD* pad = static_cast<D_PAD*>( aItem->Parent() );
171 
172  auto i = m_localClearanceCache.find( pad );
173 
174  if( i == m_localClearanceCache.end() )
175  return 0;
176 
177  return i->second;
178 }
179 
180 
181 int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const
182 {
183  int net_a = aA->Net();
184  int cl_a = ( net_a >= 0 ? m_netClearanceCache[net_a].clearance : m_defaultClearance );
185  int net_b = aB->Net();
186  int cl_b = ( net_b >= 0 ? m_netClearanceCache[net_b].clearance : m_defaultClearance );
187 
188  bool linesOnly = aA->OfKind( PNS::ITEM::SEGMENT_T | PNS::ITEM::LINE_T )
190 
191  if( linesOnly && net_a >= 0 && net_b >= 0 && m_netClearanceCache[net_a].coupledNet == net_b )
192  {
193  cl_a = cl_b = m_router->Sizes().DiffPairGap() - 2 * PNS_HULL_MARGIN;
194  }
195 
196  int pad_a = localPadClearance( aA );
197  int pad_b = localPadClearance( aB );
198 
199  if( pad_a > 0 )
200  cl_a = pad_a;
201 
202  if( pad_b > 0 )
203  cl_b = pad_b;
204 
205  return std::max( cl_a, cl_b );
206 }
207 
208 
209 int PNS_PCBNEW_RULE_RESOLVER::Clearance( int aNetCode ) const
210 {
211  if( aNetCode > 0 && aNetCode < (int) m_netClearanceCache.size() )
212  return m_netClearanceCache[aNetCode].clearance;
213 
214  return m_defaultClearance;
215 }
216 
217 
218 // fixme: ugly hack to make the optimizer respect gap width for currently routed differential pair.
219 void PNS_PCBNEW_RULE_RESOLVER::OverrideClearance( bool aEnable, int aNetA, int aNetB , int aClearance )
220 {
221  m_overrideEnabled = aEnable;
222  m_overrideNetA = aNetA;
223  m_overrideNetB = aNetB;
224  m_overrideClearance = aClearance;
225 }
226 
227 
228 int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName )
229 {
230  int rv = 0;
231 
232  if( aNetName.EndsWith( "+" ) )
233  {
234  aComplementNet = "-";
235  rv = 1;
236  }
237  else if( aNetName.EndsWith( "P" ) )
238  {
239  aComplementNet = "N";
240  rv = 1;
241  }
242  else if( aNetName.EndsWith( "-" ) )
243  {
244  aComplementNet = "+";
245  rv = -1;
246  }
247  else if( aNetName.EndsWith( "N" ) )
248  {
249  aComplementNet = "P";
250  rv = -1;
251  }
252  // Match P followed by 2 digits
253  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "P" )
254  {
255  aComplementNet = "N" + aNetName.Right( 2 );
256  rv = 1;
257  }
258  // Match P followed by 1 digit
259  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "P" )
260  {
261  aComplementNet = "N" + aNetName.Right( 1 );
262  rv = 1;
263  }
264  // Match N followed by 2 digits
265  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "N" )
266  {
267  aComplementNet = "P" + aNetName.Right( 2 );
268  rv = -1;
269  }
270  // Match N followed by 1 digit
271  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "N" )
272  {
273  aComplementNet = "P" + aNetName.Right( 1 );
274  rv = -1;
275  }
276  if( rv != 0 )
277  {
278  aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
279  aComplementNet = aBaseDpName + aComplementNet;
280  }
281 
282  return rv;
283 }
284 
285 
287 {
288  wxString refName = m_board->FindNet( aNet )->GetNetname();
289  wxString dummy, coupledNetName;
290 
291  if( matchDpSuffix( refName, coupledNetName, dummy ) )
292  {
293  NETINFO_ITEM* net = m_board->FindNet( coupledNetName );
294 
295  if( !net )
296  return -1;
297 
298  return net->GetNet();
299  }
300 
301  return -1;
302 }
303 
304 
306 {
307  wxString refName = m_board->FindNet( aNet )->GetNetname();
308  wxString dummy1, dummy2;
309 
310  return matchDpSuffix( refName, dummy1, dummy2 );
311 }
312 
313 
314 bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN )
315 {
316  if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
317  return false;
318 
319  wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
320  wxString netNameN, netNameCoupled, netNameBase;
321 
322  int r = matchDpSuffix( netNameP, netNameCoupled, netNameBase );
323 
324  if( r == 0 )
325  return false;
326  else if( r == 1 )
327  {
328  netNameN = netNameCoupled;
329  }
330  else
331  {
332  netNameN = netNameP;
333  netNameP = netNameCoupled;
334  }
335 
336 // wxLogTrace( "PNS","p %s n %s base %s\n", (const char *)netNameP.c_str(), (const char *)netNameN.c_str(), (const char *)netNameBase.c_str() );
337 
338  NETINFO_ITEM* netInfoP = m_board->FindNet( netNameP );
339  NETINFO_ITEM* netInfoN = m_board->FindNet( netNameN );
340 
341  //wxLogTrace( "PNS","ip %p in %p\n", netInfoP, netInfoN);
342 
343  if( !netInfoP || !netInfoN )
344  return false;
345 
346  aNetP = netInfoP->GetNet();
347  aNetN = netInfoN->GetNet();
348 
349  return true;
350 }
351 
352 
354 {
355 public:
356  PNS_PCBNEW_DEBUG_DECORATOR( KIGFX::VIEW* aView = NULL ): PNS::DEBUG_DECORATOR(),
357  m_view( NULL ), m_items( NULL )
358  {
359  SetView( aView );
360  }
361 
363  {
364  Clear();
365  delete m_items;
366  }
367 
368  void SetView( KIGFX::VIEW* aView )
369  {
370  Clear();
371  delete m_items;
372  m_items = NULL;
373  m_view = aView;
374 
375  if( m_view == NULL )
376  return;
377 
378  m_items = new KIGFX::VIEW_GROUP( m_view );
379  m_items->SetLayer( LAYER_GP_OVERLAY ) ;
380  m_view->Add( m_items );
381  }
382 
383  void AddPoint( VECTOR2I aP, int aColor ) override
384  {
386 
387  l.Append( aP - VECTOR2I( -50000, -50000 ) );
388  l.Append( aP + VECTOR2I( -50000, -50000 ) );
389 
390  AddLine( l, aColor, 10000 );
391 
392  l.Clear();
393  l.Append( aP - VECTOR2I( 50000, -50000 ) );
394  l.Append( aP + VECTOR2I( 50000, -50000 ) );
395 
396  AddLine( l, aColor, 10000 );
397  }
398 
399  void AddBox( BOX2I aB, int aColor ) override
400  {
402 
403  VECTOR2I o = aB.GetOrigin();
404  VECTOR2I s = aB.GetSize();
405 
406  l.Append( o );
407  l.Append( o.x + s.x, o.y );
408  l.Append( o.x + s.x, o.y + s.y );
409  l.Append( o.x, o.y + s.y );
410  l.Append( o );
411 
412  AddLine( l, aColor, 10000 );
413  }
414 
415  void AddSegment( SEG aS, int aColor ) override
416  {
418 
419  l.Append( aS.A );
420  l.Append( aS.B );
421 
422  AddLine( l, aColor, 10000 );
423  }
424 
425  void AddDirections( VECTOR2D aP, int aMask, int aColor ) override
426  {
427  BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );
428 
429  AddBox( b, aColor );
430  for( int i = 0; i < 8; i++ )
431  {
432  if( ( 1 << i ) & aMask )
433  {
434  VECTOR2I v = DIRECTION_45( ( DIRECTION_45::Directions ) i ).ToVector() * 100000;
435  AddSegment( SEG( aP, aP + v ), aColor );
436  }
437  }
438  }
439 
440  void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth ) override
441  {
442  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( NULL, m_view );
443 
444  pitem->Line( aLine, aWidth, aType );
445  m_items->Add( pitem ); // Should not be needed, as m_items has been passed as a parent group in alloc;
446  m_view->Update( m_items );
447  }
448 
449  void Clear() override
450  {
451  if( m_view && m_items )
452  {
453  m_items->FreeItems();
454  m_view->Update( m_items );
455  }
456  }
457 
458 private:
461 };
462 
463 
465 {
466  return m_debugDecorator;
467 }
468 
469 
471 {
472  m_ruleResolver = nullptr;
473  m_board = nullptr;
474  m_tool = nullptr;
475  m_view = nullptr;
476  m_previewItems = nullptr;
477  m_router = nullptr;
478  m_debugDecorator = nullptr;
479  m_dispOptions = nullptr;
480 }
481 
482 
484 {
485  delete m_ruleResolver;
486  delete m_debugDecorator;
487 
488  if( m_previewItems )
489  {
490  m_previewItems->FreeItems();
491  delete m_previewItems;
492  }
493 }
494 
495 
496 std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
497 {
498  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
499 
500  // ignore non-copper pads
501  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
502  return NULL;
503 
504  switch( aPad->GetAttribute() )
505  {
506  case PAD_ATTRIB_STANDARD:
507  break;
508 
509  case PAD_ATTRIB_SMD:
511  case PAD_ATTRIB_CONN:
512  {
513  LSET lmsk = aPad->GetLayerSet();
514  bool is_copper = false;
515 
516  for( int i = 0; i < MAX_CU_LAYERS; i++ )
517  {
518  if( lmsk[i] )
519  {
520  is_copper = true;
521 
523  layers = LAYER_RANGE( i );
524 
525  break;
526  }
527  }
528 
529  if( !is_copper )
530  return NULL;
531  }
532  break;
533 
534  default:
535  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
536  return NULL;
537  }
538 
539  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
540 
541  solid->SetLayers( layers );
542  solid->SetNet( aPad->GetNetCode() );
543  solid->SetParent( aPad );
544 
545  wxPoint wx_c = aPad->ShapePos();
546  wxSize wx_sz = aPad->GetSize();
547  wxPoint offset = aPad->GetOffset();
548 
549  VECTOR2I c( wx_c.x, wx_c.y );
550  VECTOR2I sz( wx_sz.x, wx_sz.y );
551 
552  RotatePoint( &offset, aPad->GetOrientation() );
553 
554  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
555  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
556 
557  double orient = aPad->GetOrientation() / 10.0;
558 
559  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
560  {
561  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
562  }
563  else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
564  {
565  SHAPE_POLY_SET outline;
566  outline.Append( aPad->GetCustomShapeAsPolygon() );
567  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
568 
569  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
570 
571  // We use the convex hull of the pad shape, because PnS knows
572  // only convex shapes.
573  std::vector<wxPoint> convex_hull;
574  BuildConvexHull( convex_hull, outline );
575 
576  for( unsigned ii = 0; ii < convex_hull.size(); ii++ )
577  shape->Append( convex_hull[ii] );
578 
579  solid->SetShape( shape );
580  }
581  else
582  {
583  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
584  {
585  if( orient == 90.0 || orient == 270.0 )
586  sz = VECTOR2I( sz.y, sz.x );
587 
588  switch( aPad->GetShape() )
589  {
590  case PAD_SHAPE_OVAL:
591  if( sz.x == sz.y )
592  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
593  else
594  {
595  VECTOR2I delta;
596 
597  if( sz.x > sz.y )
598  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
599  else
600  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
601 
602  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
603  std::min( sz.x, sz.y ) );
604  solid->SetShape( shape );
605  }
606  break;
607 
608  case PAD_SHAPE_RECT:
609  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
610  break;
611 
612  case PAD_SHAPE_TRAPEZOID:
613  {
614  wxPoint coords[4];
615  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
616  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
617 
618  for( int ii = 0; ii < 4; ii++ )
619  {
620  shape->Append( wx_c + coords[ii] );
621  }
622 
623  solid->SetShape( shape );
624  break;
625  }
626 
627  case PAD_SHAPE_ROUNDRECT:
628  {
629  SHAPE_POLY_SET outline;
630  const int segmentToCircleCount = 64;
631 
632  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
633 
634  // TransformRoundRectToPolygon creates only one convex polygon
635  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
636  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
637 
638  for( int ii = 0; ii < poly.PointCount(); ++ii )
639  {
640  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
641  }
642 
643  solid->SetShape( shape );
644  }
645  break;
646 
647  default:
648  wxLogTrace( "PNS", "unsupported pad shape" );
649  return nullptr;
650  }
651  }
652  else
653  {
654  switch( aPad->GetShape() )
655  {
656  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
657 
658  case PAD_SHAPE_OVAL:
659  if( sz.x == sz.y )
660  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
661  else
662  {
663  wxPoint start;
664  wxPoint end;
665  wxPoint corner;
666 
667  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
668 
669  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
670 
671  if( start.y == 0 )
672  corner = wxPoint( start.x, -( w / 2 ) );
673  else
674  corner = wxPoint( w / 2, start.y );
675 
676  RotatePoint( &start, aPad->GetOrientation() );
677  RotatePoint( &corner, aPad->GetOrientation() );
678  shape->Append( wx_c + corner );
679 
680  for( int rot = 100; rot <= 1800; rot += 100 )
681  {
682  wxPoint p( corner );
683  RotatePoint( &p, start, rot );
684  shape->Append( wx_c + p );
685  }
686 
687  if( end.y == 0 )
688  corner = wxPoint( end.x, w / 2 );
689  else
690  corner = wxPoint( -( w / 2 ), end.y );
691 
692  RotatePoint( &end, aPad->GetOrientation() );
693  RotatePoint( &corner, aPad->GetOrientation() );
694  shape->Append( wx_c + corner );
695 
696  for( int rot = 100; rot <= 1800; rot += 100 )
697  {
698  wxPoint p( corner );
699  RotatePoint( &p, end, rot );
700  shape->Append( wx_c + p );
701  }
702 
703  solid->SetShape( shape );
704  }
705  break;
706 
707  case PAD_SHAPE_RECT:
708  case PAD_SHAPE_TRAPEZOID:
709  {
710  wxPoint coords[4];
711  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
712 
713  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
714  for( int ii = 0; ii < 4; ii++ )
715  {
716  shape->Append( wx_c + coords[ii] );
717  }
718 
719  solid->SetShape( shape );
720  break;
721  }
722 
723  case PAD_SHAPE_ROUNDRECT:
724  {
725  SHAPE_POLY_SET outline;
726  const int segmentToCircleCount = 32;
727  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
728  segmentToCircleCount, 1.0 );
729 
730  // TransformRoundRectToPolygon creates only one convex polygon
731  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
732  SHAPE_CONVEX* shape = new SHAPE_CONVEX();
733 
734  for( int ii = 0; ii < poly.PointCount(); ++ii )
735  {
736  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
737  }
738 
739  solid->SetShape( shape );
740  break;
741  }
742 
743  default:
744  wxLogTrace( "PNS", "unsupported pad shape" );
745  return nullptr;
746  }
747  }
748  }
749  return solid;
750 }
751 
752 
753 std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
754 {
755  std::unique_ptr< PNS::SEGMENT > segment(
756  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
757  );
758 
759  segment->SetWidth( aTrack->GetWidth() );
760  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
761  segment->SetParent( aTrack );
762 
763  if( aTrack->IsLocked() )
764  segment->Mark( PNS::MK_LOCKED );
765 
766  return segment;
767 }
768 
769 
770 std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE::syncVia( VIA* aVia )
771 {
772  PCB_LAYER_ID top, bottom;
773  aVia->LayerPair( &top, &bottom );
774  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
775  aVia->GetPosition(),
776  LAYER_RANGE( top, bottom ),
777  aVia->GetWidth(),
778  aVia->GetDrillValue(),
779  aVia->GetNetCode(),
780  aVia->GetViaType() )
781  );
782 
783  via->SetParent( aVia );
784 
785  if( aVia->IsLocked() )
786  via->Mark( PNS::MK_LOCKED );
787 
788  return via;
789 }
790 
791 
793 {
794  SHAPE_POLY_SET poly;
795 
796  // TODO handle no-via restriction
797  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
798  return false;
799 
800  aZone->BuildSmoothedPoly( poly );
801  poly.CacheTriangulation();
802 
803  if( !poly.IsTriangulationUpToDate() )
804  {
805  wxString msg = wxString::Format( _( "Malformed keep-out zone at (%d, %d) "
806  "cannot be handled by the track layout tool.\n%s\n"
807  "Please verify it is not a self-intersecting polygon." ),
808  aZone->GetPosition().x, aZone->GetPosition().y, aZone->GetSelectMenuText() );
809 
810  KI_DIALOG dlg( nullptr, msg );
811  dlg.Type( KI_DIALOG::KD_WARNING ).Title( _( "Malformed keep-out zone" ) ).DoNotShowCheckbox();
812  dlg.ShowModal();
813 
814  return false;
815  }
816 
817  LSET layers = aZone->GetLayerSet();
818 
819  for( int layer = F_Cu; layer <= B_Cu; layer++ )
820  {
821  if ( ! layers[layer] )
822  continue;
823 
824  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
825  {
826  auto tri = poly.TriangulatedPolygon( outline );
827 
828  for( int i = 0; i < tri->GetTriangleCount(); i++)
829  {
830  VECTOR2I a, b, c;
831  tri->GetTriangle( i, a, b, c );
832  auto triShape = new SHAPE_CONVEX;
833 
834  triShape->Append( a );
835  triShape->Append( b );
836  triShape->Append( c );
837 
838  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
839 
840  solid->SetLayer( layer );
841  solid->SetNet( 0 );
842  solid->SetParent( aZone );
843  solid->SetShape( triShape );
844  solid->SetRoutable( false );
845 
846  aWorld->Add( std::move( solid ) );
847  }
848  }
849  }
850 
851  return true;
852 }
853 
855 {
856  std::vector<SHAPE_SEGMENT*> segs;
857 
858  if( aItem->GetLayer() != Edge_Cuts )
859  return false;
860 
861  switch( aItem->GetShape() )
862  {
863  case S_ARC:
864  {
865  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), (double) aItem->GetAngle() / 10.0 );
866 
867  auto l = arc.ConvertToPolyline();
868 
869  for( int i = 0; i < l.SegmentCount(); i++ )
870  {
871  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
872  segs.push_back( seg );
873  }
874 
875  break;
876  }
877 
878  case S_SEGMENT:
879  {
880  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() );
881  segs.push_back( seg );
882 
883  break;
884  }
885 
886  case S_CIRCLE:
887  {
888  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
889  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
890 
891  auto l = circle.ConvertToPolyline();
892 
893  for( int i = 0; i < l.SegmentCount(); i++ )
894  {
895  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
896  segs.push_back( seg );
897  }
898 
899  break;
900  }
901 
902  default:
903  break;
904  }
905 
906  for( auto seg : segs )
907  {
908  for( int layer = F_Cu; layer <= B_Cu; layer++ )
909  {
910  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
911 
912  solid->SetLayer( layer );
913  solid->SetNet( -1 );
914  solid->SetParent( nullptr );
915  solid->SetShape( seg->Clone() );
916  solid->SetRoutable( false );
917 
918  aWorld->Add( std::move( solid ) );
919  }
920 
921  delete seg;
922  }
923 
924  return true;
925 }
926 
928 {
929  m_board = aBoard;
930  wxLogTrace( "PNS", "m_board = %p", m_board );
931 }
932 
933 
935 {
936  int worstPadClearance = 0;
937 
938  if( !m_board )
939  {
940  wxLogTrace( "PNS", "No board attached, aborting sync." );
941  return;
942  }
943 
944  for( auto gitem : m_board->Drawings() )
945  {
946  if ( gitem->Type() == PCB_LINE_T )
947  {
948  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
949  }
950  }
951 
952  for( auto zone : m_board->Zones() )
953  {
954  syncZone( aWorld, zone );
955  }
956 
957  for( auto module : m_board->Modules() )
958  {
959  for( auto pad : module->Pads() )
960  {
961  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
962 
963  if( solid )
964  aWorld->Add( std::move( solid ) );
965 
966 
967  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
968  }
969  }
970 
971  for( auto t : m_board->Tracks() )
972  {
973  KICAD_T type = t->Type();
974 
975  if( type == PCB_TRACE_T ) {
976  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
977  if( segment ) {
978  aWorld->Add( std::move( segment ) );
979  }
980  } else if( type == PCB_VIA_T ) {
981  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
982  if( via ) {
983  aWorld->Add( std::move( via ) );
984  }
985  }
986  }
987 
988  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
989 
990  delete m_ruleResolver;
991  m_ruleResolver = new PNS_PCBNEW_RULE_RESOLVER( m_board, m_router );
992 
993  aWorld->SetRuleResolver( m_ruleResolver );
994  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
995 }
996 
997 
999 {
1000  for( auto item : m_hiddenItems )
1001  m_view->SetVisible( item, true );
1002 
1003  m_hiddenItems.clear();
1004 
1005  if( m_previewItems )
1006  {
1007  m_previewItems->FreeItems();
1008  m_view->Update( m_previewItems );
1009  }
1010 
1011  if( m_debugDecorator )
1012  m_debugDecorator->Clear();
1013 }
1014 
1015 
1016 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance )
1017 {
1018  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1019 
1020  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1021 
1022  if( aColor >= 0 )
1023  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1024 
1025  if( aClearance >= 0 )
1026  {
1027  pitem->SetClearance( aClearance );
1028 
1029  if( m_dispOptions )
1030  {
1031  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
1034  && clearanceDisp != PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS );
1035  }
1036  }
1037 
1038 
1039  m_previewItems->Add( pitem );
1040  m_view->Update( m_previewItems );
1041 }
1042 
1043 
1045 {
1046  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1047 
1048  if( parent )
1049  {
1050  if( m_view->IsVisible( parent ) )
1051  m_hiddenItems.insert( parent );
1052 
1053  m_view->SetVisible( parent, false );
1054  m_view->Update( parent, KIGFX::APPEARANCE );
1055  }
1056 }
1057 
1058 
1060 {
1061  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1062 
1063  if( parent )
1064  {
1065  m_commit->Remove( parent );
1066  }
1067 }
1068 
1069 
1071 {
1072  BOARD_CONNECTED_ITEM* newBI = NULL;
1073 
1074  switch( aItem->Kind() )
1075  {
1076  case PNS::ITEM::SEGMENT_T:
1077  {
1078  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1079  TRACK* track = new TRACK( m_board );
1080  const SEG& s = seg->Seg();
1081  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1082  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1083  track->SetWidth( seg->Width() );
1084  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1085  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1086  newBI = track;
1087  break;
1088  }
1089 
1090  case PNS::ITEM::VIA_T:
1091  {
1092  VIA* via_board = new VIA( m_board );
1093  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1094  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1095  via_board->SetWidth( via->Diameter() );
1096  via_board->SetDrill( via->Drill() );
1097  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1098  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1099  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1100  ToLAYER_ID( via->Layers().End() ) );
1101  newBI = via_board;
1102  break;
1103  }
1104 
1105  default:
1106  break;
1107  }
1108 
1109  if( newBI )
1110  {
1111  aItem->SetParent( newBI );
1112  newBI->ClearFlags();
1113 
1114  m_commit->Add( newBI );
1115  }
1116 }
1117 
1118 
1120 {
1121  EraseView();
1122  m_commit->Push( wxT( "Added a track" ) );
1123  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1124 }
1125 
1126 
1128 {
1129  wxLogTrace( "PNS", "SetView %p", aView );
1130 
1131  if( m_previewItems )
1132  {
1133  m_previewItems->FreeItems();
1134  delete m_previewItems;
1135  }
1136 
1137  m_view = aView;
1138  m_previewItems = new KIGFX::VIEW_GROUP( m_view );
1139  m_previewItems->SetLayer( LAYER_GP_OVERLAY ) ;
1140  m_view->Add( m_previewItems );
1141 
1142  delete m_debugDecorator;
1143  m_debugDecorator = new PNS_PCBNEW_DEBUG_DECORATOR();
1144  m_debugDecorator->SetView( m_view );
1145 }
1146 
1147 
1148 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1149 {
1150  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1151 }
1152 
1153 
1155 {
1156  return m_ruleResolver;
1157 }
1158 
1159 
1161 {
1162  m_router = aRouter;
1163 }
1164 
1165 
1167 {
1168  m_tool = aTool;
1169  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1170 }
1171 
1173 {
1174  m_dispOptions = aDispOptions;
1175 }
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:227
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
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:137
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:398
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:456
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
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:428
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
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
#define PNS_HULL_MARGIN
Class LINE.
Definition: pns_line.h:58
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
Class SHAPE_CONVEX.
Definition: shape_convex.h:42
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:317
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:163
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:206
const Vec & GetSize() const
Definition: box2.h:177
void HideItem(PNS::ITEM *aItem) override
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
void BuildConvexHull(std::vector< wxPoint > &aResult, const std::vector< wxPoint > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
Definition: convex_hull.cpp:87
const wxPoint GetPosition() const override
Function GetPosition.
Definition: class_zone.cpp:165
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:157
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:132
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:226
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
void Append(int aX, int aY)
Function Append()
Definition: shape_convex.h:151
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:250
VIATYPE_T GetViaType() const
Definition: class_track.h:455
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:395
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:532
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
Helper class to create more flexible dialogs, e.g:
Definition: confirm.h:47
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:187
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:427
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:252
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:245
Class SHAPE_LINE_CHAIN.
void RemoveItem(PNS::ITEM *aItem) override
int GetWidth() const
Definition: class_track.h:116
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
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:463
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
virtual void OverrideClearance(bool aEnable, int aNetA=0, int aNetB=0, int aClearance=0) override
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
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
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:249
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
virtual void UseDpGap(bool aUseDpGap) override
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
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:251
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:772
#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