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