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_text_mod.h>
27 #include <class_edge_mod.h>
28 #include <class_track.h>
29 #include <class_zone.h>
30 #include <class_drawsegment.h>
31 #include <class_pcb_text.h>
32 #include <board_commit.h>
34 #include <geometry/convex_hull.h>
35 #include <confirm.h>
36 
37 #include <view/view.h>
38 #include <view/view_item.h>
39 #include <view/view_group.h>
41 
42 #include <pcb_painter.h>
43 
44 #include <geometry/shape.h>
46 #include <geometry/shape_rect.h>
47 #include <geometry/shape_circle.h>
48 #include <geometry/shape_arc.h>
49 #include <geometry/convex_hull.h>
50 
51 #include "tools/pcb_tool.h"
52 
53 #include "pns_kicad_iface.h"
54 
55 #include "../../include/geometry/shape_simple.h"
56 #include "pns_routing_settings.h"
57 #include "pns_sizes_settings.h"
58 #include "pns_item.h"
59 #include "pns_solid.h"
60 #include "pns_segment.h"
61 #include "pns_solid.h"
62 #include "pns_itemset.h"
63 #include "pns_node.h"
64 #include "pns_topology.h"
65 #include "pns_router.h"
66 #include "pns_debug_decorator.h"
67 #include "router_preview_item.h"
68 
70 {
71 public:
72  PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER* aRouter );
73  virtual ~PNS_PCBNEW_RULE_RESOLVER();
74 
75  virtual int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const override;
76  virtual int Clearance( int aNetCode ) const override;
77  virtual int DpCoupledNet( int aNet ) override;
78  virtual int DpNetPolarity( int aNet ) override;
79  virtual bool DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN ) override;
80  virtual wxString NetName( int aNet ) override;
81 
82 private:
84  {
87  int clearance;
88  };
89 
90  int localPadClearance( const PNS::ITEM* aItem ) const;
91  int matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName );
92 
95 
96  std::vector<CLEARANCE_ENT> m_netClearanceCache;
97  std::unordered_map<const D_PAD*, int> m_localClearanceCache;
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  ent.dpClearance = nc->GetDiffPairGap();
128  m_netClearanceCache[i] = ent;
129 
130  wxLogTrace( "PNS", "Add net %u netclass %s clearance %d Diff Pair clearance %d",
131  i, netClassName.mb_str(), clearance, ent.dpClearance );
132  }
133 
134  // Build clearance cache for pads
135  for( MODULE* mod = m_board->m_Modules; mod ; mod = mod->Next() )
136  {
137  auto moduleClearance = mod->GetLocalClearance();
138 
139  for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() )
140  {
141  int padClearance = pad->GetLocalClearance();
142 
143  if( padClearance > 0 )
144  m_localClearanceCache[ pad ] = padClearance;
145 
146  else if( moduleClearance > 0 )
147  m_localClearanceCache[ pad ] = moduleClearance;
148  }
149  }
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 
163 
165 {
166 }
167 
168 
170 {
171  if( !aItem->Parent() || aItem->Parent()->Type() != PCB_PAD_T )
172  return 0;
173 
174  const D_PAD* pad = static_cast<D_PAD*>( aItem->Parent() );
175 
176  auto i = m_localClearanceCache.find( pad );
177 
178  if( i == m_localClearanceCache.end() )
179  return 0;
180 
181  return i->second;
182 }
183 
184 
185 int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const
186 {
187  int net_a = aA->Net();
188  int cl_a = ( net_a >= 0 ? m_netClearanceCache[net_a].clearance : m_defaultClearance );
189  int net_b = aB->Net();
190  int cl_b = ( net_b >= 0 ? m_netClearanceCache[net_b].clearance : m_defaultClearance );
191 
192  // Pad clearance is 0 if the ITEM* is not a pad
193  int pad_a = localPadClearance( aA );
194  int pad_b = localPadClearance( aB );
195 
196  if( pad_a > 0 )
197  cl_a = pad_a;
198 
199  if( pad_b > 0 )
200  cl_b = pad_b;
201 
202  return std::max( cl_a, cl_b );
203 }
204 
205 
206 int PNS_PCBNEW_RULE_RESOLVER::Clearance( int aNetCode ) const
207 {
208  if( aNetCode > 0 && aNetCode < (int) m_netClearanceCache.size() )
209  return m_netClearanceCache[aNetCode].clearance;
210 
211  return m_defaultClearance;
212 }
213 
214 
215 int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName )
216 {
217  int rv = 0;
218 
219  if( aNetName.EndsWith( "+" ) )
220  {
221  aComplementNet = "-";
222  rv = 1;
223  }
224  else if( aNetName.EndsWith( "P" ) )
225  {
226  aComplementNet = "N";
227  rv = 1;
228  }
229  else if( aNetName.EndsWith( "-" ) )
230  {
231  aComplementNet = "+";
232  rv = -1;
233  }
234  else if( aNetName.EndsWith( "N" ) )
235  {
236  aComplementNet = "P";
237  rv = -1;
238  }
239  // Match P followed by 2 digits
240  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "P" )
241  {
242  aComplementNet = "N" + aNetName.Right( 2 );
243  rv = 1;
244  }
245  // Match P followed by 1 digit
246  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "P" )
247  {
248  aComplementNet = "N" + aNetName.Right( 1 );
249  rv = 1;
250  }
251  // Match N followed by 2 digits
252  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "N" )
253  {
254  aComplementNet = "P" + aNetName.Right( 2 );
255  rv = -1;
256  }
257  // Match N followed by 1 digit
258  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "N" )
259  {
260  aComplementNet = "P" + aNetName.Right( 1 );
261  rv = -1;
262  }
263  if( rv != 0 )
264  {
265  aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
266  aComplementNet = aBaseDpName + aComplementNet;
267  }
268 
269  return rv;
270 }
271 
272 
274 {
275  wxString refName = m_board->FindNet( aNet )->GetNetname();
276  wxString dummy, coupledNetName;
277 
278  if( matchDpSuffix( refName, coupledNetName, dummy ) )
279  {
280  NETINFO_ITEM* net = m_board->FindNet( coupledNetName );
281 
282  if( !net )
283  return -1;
284 
285  return net->GetNet();
286  }
287 
288  return -1;
289 }
290 
291 
293 {
294  return m_board->FindNet( aNet )->GetNetname();
295 }
296 
297 
299 {
300  wxString refName = m_board->FindNet( aNet )->GetNetname();
301  wxString dummy1, dummy2;
302 
303  return matchDpSuffix( refName, dummy1, dummy2 );
304 }
305 
306 
307 bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN )
308 {
309  if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
310  return false;
311 
312  wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
313  wxString netNameN, netNameCoupled, netNameBase;
314 
315  int r = matchDpSuffix( netNameP, netNameCoupled, netNameBase );
316 
317  if( r == 0 )
318  return false;
319  else if( r == 1 )
320  {
321  netNameN = netNameCoupled;
322  }
323  else
324  {
325  netNameN = netNameP;
326  netNameP = netNameCoupled;
327  }
328 
329 // wxLogTrace( "PNS","p %s n %s base %s\n", (const char *)netNameP.c_str(), (const char *)netNameN.c_str(), (const char *)netNameBase.c_str() );
330 
331  NETINFO_ITEM* netInfoP = m_board->FindNet( netNameP );
332  NETINFO_ITEM* netInfoN = m_board->FindNet( netNameN );
333 
334  //wxLogTrace( "PNS","ip %p in %p\n", netInfoP, netInfoN);
335 
336  if( !netInfoP || !netInfoN )
337  return false;
338 
339  aNetP = netInfoP->GetNet();
340  aNetN = netInfoN->GetNet();
341 
342  return true;
343 }
344 
345 
347 {
348 public:
349  PNS_PCBNEW_DEBUG_DECORATOR( KIGFX::VIEW* aView = NULL ): PNS::DEBUG_DECORATOR(),
350  m_view( NULL ), m_items( NULL )
351  {
352  SetView( aView );
353  }
354 
356  {
357  Clear();
358  delete m_items;
359  }
360 
361  void SetView( KIGFX::VIEW* aView )
362  {
363  Clear();
364  delete m_items;
365  m_items = NULL;
366  m_view = aView;
367 
368  if( m_view == NULL )
369  return;
370 
371  m_items = new KIGFX::VIEW_GROUP( m_view );
372  m_items->SetLayer( LAYER_SELECT_OVERLAY ) ;
373  m_view->Add( m_items );
374  }
375 
376  void AddPoint( VECTOR2I aP, int aColor ) override
377  {
379 
380  l.Append( aP - VECTOR2I( -50000, -50000 ) );
381  l.Append( aP + VECTOR2I( -50000, -50000 ) );
382 
383  AddLine( l, aColor, 10000 );
384 
385  l.Clear();
386  l.Append( aP - VECTOR2I( 50000, -50000 ) );
387  l.Append( aP + VECTOR2I( 50000, -50000 ) );
388 
389  AddLine( l, aColor, 10000 );
390  }
391 
392  void AddBox( BOX2I aB, int aColor ) override
393  {
395 
396  VECTOR2I o = aB.GetOrigin();
397  VECTOR2I s = aB.GetSize();
398 
399  l.Append( o );
400  l.Append( o.x + s.x, o.y );
401  l.Append( o.x + s.x, o.y + s.y );
402  l.Append( o.x, o.y + s.y );
403  l.Append( o );
404 
405  AddLine( l, aColor, 10000 );
406  }
407 
408  void AddSegment( SEG aS, int aColor ) override
409  {
411 
412  l.Append( aS.A );
413  l.Append( aS.B );
414 
415  AddLine( l, aColor, 10000 );
416  }
417 
418  void AddDirections( VECTOR2D aP, int aMask, int aColor ) override
419  {
420  BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );
421 
422  AddBox( b, aColor );
423  for( int i = 0; i < 8; i++ )
424  {
425  if( ( 1 << i ) & aMask )
426  {
428  AddSegment( SEG( aP, aP + v ), aColor );
429  }
430  }
431  }
432 
433  void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth ) override
434  {
435  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( NULL, m_view );
436 
437  pitem->Line( aLine, aWidth, aType );
438  m_items->Add( pitem ); // Should not be needed, as m_items has been passed as a parent group in alloc;
439  m_view->Update( m_items );
440  }
441 
442  void Clear() override
443  {
444  if( m_view && m_items )
445  {
446  m_items->FreeItems();
447  m_view->Update( m_items );
448  }
449  }
450 
451 private:
454 };
455 
456 
458 {
459  return m_debugDecorator;
460 }
461 
462 
464 {
465  m_ruleResolver = nullptr;
466  m_board = nullptr;
467  m_tool = nullptr;
468  m_view = nullptr;
469  m_previewItems = nullptr;
470  m_router = nullptr;
471  m_debugDecorator = nullptr;
472  m_dispOptions = nullptr;
473 }
474 
475 
477 {
478  delete m_ruleResolver;
479  delete m_debugDecorator;
480 
481  if( m_previewItems )
482  {
483  m_previewItems->FreeItems();
484  delete m_previewItems;
485  }
486 }
487 
488 
489 std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
490 {
491  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
492 
493  // ignore non-copper pads
494  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
495  return NULL;
496 
497  switch( aPad->GetAttribute() )
498  {
499  case PAD_ATTRIB_STANDARD:
500  break;
501 
502  case PAD_ATTRIB_SMD:
504  case PAD_ATTRIB_CONN:
505  {
506  LSET lmsk = aPad->GetLayerSet();
507  bool is_copper = false;
508 
509  for( int i = 0; i < MAX_CU_LAYERS; i++ )
510  {
511  if( lmsk[i] )
512  {
513  is_copper = true;
514 
516  layers = LAYER_RANGE( i );
517 
518  break;
519  }
520  }
521 
522  if( !is_copper )
523  return NULL;
524  }
525  break;
526 
527  default:
528  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
529  return NULL;
530  }
531 
532  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
533 
534  solid->SetLayers( layers );
535  solid->SetNet( aPad->GetNetCode() );
536  solid->SetParent( aPad );
537 
538  wxPoint wx_c = aPad->ShapePos();
539  wxSize wx_sz = aPad->GetSize();
540  wxPoint offset = aPad->GetOffset();
541 
542  VECTOR2I c( wx_c.x, wx_c.y );
543  VECTOR2I sz( wx_sz.x, wx_sz.y );
544 
545  RotatePoint( &offset, aPad->GetOrientation() );
546 
547  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
548  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
549 
550  double orient = aPad->GetOrientation() / 10.0;
551 
552  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
553  {
554  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
555  }
556  else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
557  {
558  SHAPE_POLY_SET outline;
559  outline.Append( aPad->GetCustomShapeAsPolygon() );
560  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
561 
562  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
563 
564  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
565  shape->Append( *iter );
566 
567  solid->SetShape( shape );
568  }
569  else
570  {
571  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
572  {
573  if( orient == 90.0 || orient == 270.0 )
574  sz = VECTOR2I( sz.y, sz.x );
575 
576  switch( aPad->GetShape() )
577  {
578  case PAD_SHAPE_OVAL:
579  if( sz.x == sz.y )
580  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
581  else
582  {
583  VECTOR2I delta;
584 
585  if( sz.x > sz.y )
586  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
587  else
588  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
589 
590  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
591  std::min( sz.x, sz.y ) );
592  solid->SetShape( shape );
593  }
594  break;
595 
596  case PAD_SHAPE_RECT:
597  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
598  break;
599 
600  case PAD_SHAPE_TRAPEZOID:
601  {
602  wxPoint coords[4];
603  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
604  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
605 
606  for( int ii = 0; ii < 4; ii++ )
607  {
608  shape->Append( wx_c + coords[ii] );
609  }
610 
611  solid->SetShape( shape );
612  break;
613  }
614 
615  case PAD_SHAPE_ROUNDRECT:
616  {
617  SHAPE_POLY_SET outline;
618  const int segmentToCircleCount = 64;
619 
620  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
621 
622  // TransformRoundRectToPolygon creates only one convex polygon
623  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
624  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
625 
626  for( int ii = 0; ii < poly.PointCount(); ++ii )
627  {
628  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
629  }
630 
631  solid->SetShape( shape );
632  }
633  break;
634 
635  default:
636  wxLogTrace( "PNS", "unsupported pad shape" );
637  return nullptr;
638  }
639  }
640  else
641  {
642  switch( aPad->GetShape() )
643  {
644  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
645 
646  case PAD_SHAPE_OVAL:
647  if( sz.x == sz.y )
648  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
649  else
650  {
651  wxPoint start;
652  wxPoint end;
653  wxPoint corner;
654 
655  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
656 
657  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
658 
659  if( start.y == 0 )
660  corner = wxPoint( start.x, -( w / 2 ) );
661  else
662  corner = wxPoint( w / 2, start.y );
663 
664  RotatePoint( &start, aPad->GetOrientation() );
665  RotatePoint( &corner, aPad->GetOrientation() );
666  shape->Append( wx_c + corner );
667 
668  for( int rot = 100; rot <= 1800; rot += 100 )
669  {
670  wxPoint p( corner );
671  RotatePoint( &p, start, rot );
672  shape->Append( wx_c + p );
673  }
674 
675  if( end.y == 0 )
676  corner = wxPoint( end.x, w / 2 );
677  else
678  corner = wxPoint( -( w / 2 ), end.y );
679 
680  RotatePoint( &end, aPad->GetOrientation() );
681  RotatePoint( &corner, aPad->GetOrientation() );
682  shape->Append( wx_c + corner );
683 
684  for( int rot = 100; rot <= 1800; rot += 100 )
685  {
686  wxPoint p( corner );
687  RotatePoint( &p, end, rot );
688  shape->Append( wx_c + p );
689  }
690 
691  solid->SetShape( shape );
692  }
693  break;
694 
695  case PAD_SHAPE_RECT:
696  case PAD_SHAPE_TRAPEZOID:
697  {
698  wxPoint coords[4];
699  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
700 
701  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
702  for( int ii = 0; ii < 4; ii++ )
703  {
704  shape->Append( wx_c + coords[ii] );
705  }
706 
707  solid->SetShape( shape );
708  break;
709  }
710 
711  case PAD_SHAPE_ROUNDRECT:
712  {
713  SHAPE_POLY_SET outline;
714  const int segmentToCircleCount = 32;
715  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
716  segmentToCircleCount, 1.0 );
717 
718  // TransformRoundRectToPolygon creates only one convex polygon
719  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
720  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
721 
722  for( int ii = 0; ii < poly.PointCount(); ++ii )
723  {
724  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
725  }
726 
727  solid->SetShape( shape );
728  break;
729  }
730 
731  default:
732  wxLogTrace( "PNS", "unsupported pad shape" );
733  return nullptr;
734  }
735  }
736  }
737  return solid;
738 }
739 
740 
741 std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
742 {
743  std::unique_ptr< PNS::SEGMENT > segment(
744  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
745  );
746 
747  segment->SetWidth( aTrack->GetWidth() );
748  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
749  segment->SetParent( aTrack );
750 
751  if( aTrack->IsLocked() )
752  segment->Mark( PNS::MK_LOCKED );
753 
754  return segment;
755 }
756 
757 
758 std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE::syncVia( VIA* aVia )
759 {
760  PCB_LAYER_ID top, bottom;
761  aVia->LayerPair( &top, &bottom );
762  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
763  aVia->GetPosition(),
764  LAYER_RANGE( top, bottom ),
765  aVia->GetWidth(),
766  aVia->GetDrillValue(),
767  aVia->GetNetCode(),
768  aVia->GetViaType() )
769  );
770 
771  via->SetParent( aVia );
772 
773  if( aVia->IsLocked() )
774  via->Mark( PNS::MK_LOCKED );
775 
776  return via;
777 }
778 
779 
781 {
782  SHAPE_POLY_SET poly;
783 
784  // TODO handle no-via restriction
785  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
786  return false;
787 
788  aZone->BuildSmoothedPoly( poly );
789  poly.CacheTriangulation();
790 
791  if( !poly.IsTriangulationUpToDate() )
792  {
793  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
794  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
795  dlg.ShowDetailedText(
796  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
797  "Please verify it is not a self-intersecting polygon." ),
798  aZone->GetSelectMenuText( MILLIMETRES ) ) );
799  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
800  dlg.ShowModal();
801 
802  return false;
803  }
804 
805  LSET layers = aZone->GetLayerSet();
806 
807  for( int layer = F_Cu; layer <= B_Cu; layer++ )
808  {
809  if ( ! layers[layer] )
810  continue;
811 
812  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
813  {
814  auto tri = poly.TriangulatedPolygon( outline );
815 
816  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
817  {
818  VECTOR2I a, b, c;
819  tri->GetTriangle( i, a, b, c );
820  auto triShape = new SHAPE_SIMPLE;
821 
822  triShape->Append( a );
823  triShape->Append( b );
824  triShape->Append( c );
825 
826  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
827 
828  solid->SetLayer( layer );
829  solid->SetNet( 0 );
830  solid->SetParent( aZone );
831  solid->SetShape( triShape );
832  solid->SetRoutable( false );
833 
834  aWorld->Add( std::move( solid ) );
835  }
836  }
837  }
838 
839  return true;
840 }
841 
842 
844 {
845  if( !IsCopperLayer( aLayer ) )
846  return false;
847 
848  int textWidth = aText->GetThickness();
849  std::vector<wxPoint> textShape;
850 
851  aText->TransformTextShapeToSegmentList( textShape );
852 
853  if( textShape.size() < 2 )
854  return false;
855 
856  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
857  {
858  VECTOR2I start( textShape[jj] );
859  VECTOR2I end( textShape[jj+1] );
860  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
861 
862  solid->SetLayer( aLayer );
863  solid->SetNet( -1 );
864  solid->SetParent( nullptr );
865  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
866  solid->SetRoutable( false );
867 
868  aWorld->Add( std::move( solid ) );
869  }
870 
871  return true;
872 
873  /* A coarser (but faster) method:
874  *
875  SHAPE_POLY_SET outline;
876  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
877 
878  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
879 
880  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
881  shape->Append( *iter );
882 
883  solid->SetShape( shape );
884 
885  solid->SetLayer( aLayer );
886  solid->SetNet( -1 );
887  solid->SetParent( nullptr );
888  solid->SetRoutable( false );
889  aWorld->Add( std::move( solid ) );
890  return true;
891  */
892 }
893 
894 
896 {
897  std::vector<SHAPE_SEGMENT*> segs;
898 
899  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
900  return false;
901 
902  switch( aItem->GetShape() )
903  {
904  case S_ARC:
905  {
906  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), (double) aItem->GetAngle() / 10.0 );
907 
908  auto l = arc.ConvertToPolyline();
909 
910  for( int i = 0; i < l.SegmentCount(); i++ )
911  {
912  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
913  segs.push_back( seg );
914  }
915 
916  break;
917  }
918 
919  case S_SEGMENT:
920  {
921  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() );
922  segs.push_back( seg );
923 
924  break;
925  }
926 
927  case S_CIRCLE:
928  {
929  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
930  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
931 
932  auto l = circle.ConvertToPolyline();
933 
934  for( int i = 0; i < l.SegmentCount(); i++ )
935  {
936  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT( l.CSegment(i), aItem->GetWidth() );
937  segs.push_back( seg );
938  }
939 
940  break;
941  }
942 
943  case S_CURVE:
944  {
945  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
946  wxPoint start_pt = aItem->GetBezierPoints()[0];
947 
948  for( unsigned int jj = 1; jj < aItem->GetBezierPoints().size(); jj++ )
949  {
950  wxPoint end_pt = aItem->GetBezierPoints()[jj];
951  SHAPE_SEGMENT *seg = new SHAPE_SEGMENT(
952  VECTOR2I( start_pt ), VECTOR2I( end_pt ), aItem->GetWidth() );
953  segs.push_back( seg );
954  start_pt = end_pt;
955  }
956  }
957  break;
958 
959  default:
960  break;
961  }
962 
963  for( auto seg : segs )
964  {
965  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
966 
967  if( aItem->GetLayer() == Edge_Cuts )
968  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
969  else
970  solid->SetLayer( aItem->GetLayer() );
971 
972  solid->SetNet( -1 );
973  solid->SetParent( nullptr );
974  solid->SetShape( seg );
975  solid->SetRoutable( false );
976 
977  aWorld->Add( std::move( solid ) );
978  }
979 
980  return true;
981 }
982 
984 {
985  m_board = aBoard;
986  wxLogTrace( "PNS", "m_board = %p", m_board );
987 }
988 
989 
991 {
992  int worstPadClearance = 0;
993 
994  if( !m_board )
995  {
996  wxLogTrace( "PNS", "No board attached, aborting sync." );
997  return;
998  }
999 
1000  for( auto gitem : m_board->Drawings() )
1001  {
1002  if ( gitem->Type() == PCB_LINE_T )
1003  {
1004  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1005  }
1006  else if( gitem->Type() == PCB_TEXT_T )
1007  {
1008  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1009  }
1010  }
1011 
1012  for( auto zone : m_board->Zones() )
1013  {
1014  syncZone( aWorld, zone );
1015  }
1016 
1017  for( auto module : m_board->Modules() )
1018  {
1019  for( auto pad : module->Pads() )
1020  {
1021  std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
1022 
1023  if( solid )
1024  aWorld->Add( std::move( solid ) );
1025 
1026 
1027  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1028  }
1029 
1030  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1031  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1032 
1033  if( module->IsNetTie() )
1034  continue;
1035 
1036  for( auto mgitem : module->GraphicalItems() )
1037  {
1038  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1039  {
1040  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1041  }
1042  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1043  {
1044  syncTextItem( aWorld, dynamic_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1045  }
1046  }
1047  }
1048 
1049  for( auto t : m_board->Tracks() )
1050  {
1051  KICAD_T type = t->Type();
1052 
1053  if( type == PCB_TRACE_T ) {
1054  std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
1055  if( segment ) {
1056  aWorld->Add( std::move( segment ) );
1057  }
1058  } else if( type == PCB_VIA_T ) {
1059  std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
1060  if( via ) {
1061  aWorld->Add( std::move( via ) );
1062  }
1063  }
1064  }
1065 
1066  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1067 
1068  delete m_ruleResolver;
1069  m_ruleResolver = new PNS_PCBNEW_RULE_RESOLVER( m_board, m_router );
1070 
1071  aWorld->SetRuleResolver( m_ruleResolver );
1072  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1073 }
1074 
1075 
1077 {
1078  for( auto item : m_hiddenItems )
1079  m_view->SetVisible( item, true );
1080 
1081  m_hiddenItems.clear();
1082 
1083  if( m_previewItems )
1084  {
1085  m_previewItems->FreeItems();
1086  m_view->Update( m_previewItems );
1087  }
1088 
1089  if( m_debugDecorator )
1090  m_debugDecorator->Clear();
1091 }
1092 
1093 
1094 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance )
1095 {
1096  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1097 
1098  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1099 
1100  if( aColor >= 0 )
1101  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1102 
1103  if( aClearance >= 0 )
1104  {
1105  pitem->SetClearance( aClearance );
1106 
1107  if( m_dispOptions )
1108  {
1109  auto clearanceDisp = m_dispOptions->m_ShowTrackClearanceMode;
1112  && clearanceDisp != PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS );
1113  }
1114  }
1115 
1116 
1117  m_previewItems->Add( pitem );
1118  m_view->Update( m_previewItems );
1119 }
1120 
1121 
1123 {
1124  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1125 
1126  if( parent )
1127  {
1128  if( m_view->IsVisible( parent ) )
1129  m_hiddenItems.insert( parent );
1130 
1131  m_view->SetVisible( parent, false );
1132  m_view->Update( parent, KIGFX::APPEARANCE );
1133  }
1134 }
1135 
1136 
1138 {
1139  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1140 
1141  if( parent )
1142  {
1143  m_commit->Remove( parent );
1144  }
1145 }
1146 
1147 
1149 {
1150  BOARD_CONNECTED_ITEM* newBI = NULL;
1151 
1152  switch( aItem->Kind() )
1153  {
1154  case PNS::ITEM::SEGMENT_T:
1155  {
1156  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1157  TRACK* track = new TRACK( m_board );
1158  const SEG& s = seg->Seg();
1159  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1160  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1161  track->SetWidth( seg->Width() );
1162  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1163  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1164  newBI = track;
1165  break;
1166  }
1167 
1168  case PNS::ITEM::VIA_T:
1169  {
1170  VIA* via_board = new VIA( m_board );
1171  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1172  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1173  via_board->SetWidth( via->Diameter() );
1174  via_board->SetDrill( via->Drill() );
1175  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1176  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1177  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1178  ToLAYER_ID( via->Layers().End() ) );
1179  newBI = via_board;
1180  break;
1181  }
1182 
1183  default:
1184  break;
1185  }
1186 
1187  if( newBI )
1188  {
1189  aItem->SetParent( newBI );
1190  newBI->ClearFlags();
1191 
1192  m_commit->Add( newBI );
1193  }
1194 }
1195 
1196 
1198 {
1199  EraseView();
1200  m_commit->Push( _( "Added a track" ) );
1201  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1202 }
1203 
1204 
1206 {
1207  wxLogTrace( "PNS", "SetView %p", aView );
1208 
1209  if( m_previewItems )
1210  {
1211  m_previewItems->FreeItems();
1212  delete m_previewItems;
1213  }
1214 
1215  m_view = aView;
1216  m_previewItems = new KIGFX::VIEW_GROUP( m_view );
1217  m_previewItems->SetLayer( LAYER_SELECT_OVERLAY ) ;
1218  m_view->Add( m_previewItems );
1219 
1220  delete m_debugDecorator;
1221  m_debugDecorator = new PNS_PCBNEW_DEBUG_DECORATOR();
1222  m_debugDecorator->SetView( m_view );
1223 }
1224 
1225 
1226 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1227 {
1228  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1229 }
1230 
1231 
1233 {
1234  return m_ruleResolver;
1235 }
1236 
1237 
1239 {
1240  m_router = aRouter;
1241 }
1242 
1243 
1245 {
1246  m_tool = aTool;
1247  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1248 }
1249 
1251 {
1252  m_dispOptions = aDispOptions;
1253 }
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:191
Class ITEM.
Definition: pns_item.h:53
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
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)
void DoNotShowCheckbox(wxString file, int line)
Shows the &#39;do not show again&#39; checkbox
Definition: confirm.cpp:60
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:146
Class NODE.
Definition: pns_node.h:136
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
TEXTE_PCB class definition.
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:458
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:44
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:430
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
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
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:135
void UpdateNet(int aNetCode) override
void AddBox(BOX2I aB, int aColor) override
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
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)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
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:187
void HideItem(PNS::ITEM *aItem) override
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
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...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
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
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
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:623
void SetMaxClearance(int aClearance)
Sets the worst-case clerance between any pair of items
Definition: pns_node.h:156
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:127
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.
Footprint text class description.
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:254
VIATYPE_T GetViaType() const
Definition: class_track.h:457
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:538
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.
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...
int Width() const
Definition: pns_segment.h:88
Bezier Curve.
int Start() const
Definition: pns_layerset.h:83
int GetNet() const
Function GetNet.
Definition: netinfo.h:231
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:429
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.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:36
const std::vector< wxPoint > & GetBezierPoints() const
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:626
ZONE_CONTAINERS & Zones()
Definition: class_board.h:256
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:170
DLIST< MODULE > m_Modules
Definition: class_board.h:248
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)
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment each segment is stored as 2 wxPoints: the starting point ...
Definition: eda_text.cpp:480
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:465
void SetView(KIGFX::VIEW *aView)
Usual pad.
Definition: pad_shapes.h:60
currently selected items overlay
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
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
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:517
int ShowModal() override
Definition: confirm.cpp:102
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
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:253
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:239
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:61
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
EDGE_MODULE class definition.
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:810
#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:255
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:779
#define min(a, b)
Definition: auxiliary.h:85
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=500.0) const
Constructs a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:208
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