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_base.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:
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 
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  {
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 
616  case PAD_SHAPE_ROUNDRECT:
617  {
618  SHAPE_POLY_SET outline;
619  const int segmentToCircleCount = 64;
620 
621  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );
622 
623  // TransformRoundRectToPolygon creates only one convex polygon
624  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
625  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
626 
627  for( int ii = 0; ii < poly.PointCount(); ++ii )
628  shape->Append( poly.Point( ii ) );
629 
630  solid->SetShape( shape );
631  }
632  break;
633 
634  default:
635  wxLogTrace( "PNS", "unsupported pad shape" );
636  return nullptr;
637  }
638  }
639  else
640  {
641  switch( aPad->GetShape() )
642  {
643  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
644 
645  case PAD_SHAPE_OVAL:
646  if( sz.x == sz.y )
647  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
648  else
649  {
650  wxPoint start;
651  wxPoint end;
652  wxPoint corner;
653 
654  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
655 
656  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
657 
658  if( start.y == 0 )
659  corner = wxPoint( start.x, -( w / 2 ) );
660  else
661  corner = wxPoint( w / 2, start.y );
662 
663  RotatePoint( &start, aPad->GetOrientation() );
664  RotatePoint( &corner, aPad->GetOrientation() );
665  shape->Append( wx_c + corner );
666 
667  for( int rot = 100; rot <= 1800; rot += 100 )
668  {
669  wxPoint p( corner );
670  RotatePoint( &p, start, rot );
671  shape->Append( wx_c + p );
672  }
673 
674  if( end.y == 0 )
675  corner = wxPoint( end.x, w / 2 );
676  else
677  corner = wxPoint( -( w / 2 ), end.y );
678 
679  RotatePoint( &end, aPad->GetOrientation() );
680  RotatePoint( &corner, aPad->GetOrientation() );
681  shape->Append( wx_c + corner );
682 
683  for( int rot = 100; rot <= 1800; rot += 100 )
684  {
685  wxPoint p( corner );
686  RotatePoint( &p, end, rot );
687  shape->Append( wx_c + p );
688  }
689 
690  solid->SetShape( shape );
691  }
692  break;
693 
694  case PAD_SHAPE_RECT:
695  case PAD_SHAPE_TRAPEZOID:
696  {
697  wxPoint coords[4];
698  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
699 
700  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
701  for( int ii = 0; ii < 4; ii++ )
702  {
703  shape->Append( wx_c + coords[ii] );
704  }
705 
706  solid->SetShape( shape );
707  break;
708  }
709 
711  case PAD_SHAPE_ROUNDRECT:
712  {
713  SHAPE_POLY_SET outline;
714  const int segmentToCircleCount = ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF;
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(), aItem->GetAngle() / 10.0 );
907  auto l = arc.ConvertToPolyline();
908 
909  for( int i = 0; i < l.SegmentCount(); i++ )
910  {
911  SHAPE_SEGMENT* seg = new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() );
912  segs.push_back( seg );
913  }
914 
915  break;
916  }
917 
918  case S_SEGMENT:
919  segs.push_back(
920  new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() ) );
921 
922  break;
923 
924  case S_CIRCLE:
925  {
926  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
927  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
928  auto l = circle.ConvertToPolyline();
929 
930  for( int i = 0; i < l.SegmentCount(); i++ )
931  segs.push_back( new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() ) );
932 
933  break;
934  }
935 
936  case S_CURVE:
937  {
938  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
939  auto pts = aItem->GetBezierPoints();
940 
941  for( size_t ii = 1; ii < pts.size(); ii++ )
942  {
943  segs.push_back( new SHAPE_SEGMENT(
944  VECTOR2I( pts[ii - 1] ), VECTOR2I( pts[ii] ), aItem->GetWidth() ) );
945  }
946  break;
947  }
948 
949  case S_POLYGON:
950  if( !aItem->IsPolygonFilled() )
951  {
952  auto poly = aItem->BuildPolyPointsList();
953  for( size_t ii = 1; ii < poly.size(); ii++ )
954  {
955  segs.push_back( new SHAPE_SEGMENT(
956  VECTOR2I( poly[ii - 1] ), VECTOR2I( poly[ii] ), aItem->GetWidth() ) );
957  }
958 
959  segs.push_back( new SHAPE_SEGMENT(
960  VECTOR2I( poly.back() ), VECTOR2I( poly.front() ), aItem->GetWidth() ) );
961  }
962  break;
963 
964  default:
965  break;
966  }
967 
968  for( auto seg : segs )
969  {
970  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
971 
972  if( aItem->GetLayer() == Edge_Cuts )
973  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
974  else
975  solid->SetLayer( aItem->GetLayer() );
976 
977  solid->SetNet( -1 );
978  solid->SetParent( nullptr );
979  solid->SetShape( seg );
980  solid->SetRoutable( false );
981 
982  aWorld->Add( std::move( solid ) );
983  }
984 
985  return true;
986 }
987 
989 {
990  m_board = aBoard;
991  wxLogTrace( "PNS", "m_board = %p", m_board );
992 }
993 
994 
996 {
997  int worstPadClearance = 0;
998 
999  if( !m_board )
1000  {
1001  wxLogTrace( "PNS", "No board attached, aborting sync." );
1002  return;
1003  }
1004 
1005  for( auto gitem : m_board->Drawings() )
1006  {
1007  if ( gitem->Type() == PCB_LINE_T )
1008  {
1009  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1010  }
1011  else if( gitem->Type() == PCB_TEXT_T )
1012  {
1013  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1014  }
1015  }
1016 
1017  for( auto zone : m_board->Zones() )
1018  {
1019  syncZone( aWorld, zone );
1020  }
1021 
1022  for( auto module : m_board->Modules() )
1023  {
1024  for( auto pad : module->Pads() )
1025  {
1026  if( auto solid = syncPad( pad ) )
1027  aWorld->Add( std::move( solid ) );
1028 
1029  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1030  }
1031 
1032  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1033  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1034 
1035  if( module->IsNetTie() )
1036  continue;
1037 
1038  for( auto mgitem : module->GraphicalItems() )
1039  {
1040  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1041  {
1042  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1043  }
1044  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1045  {
1046  syncTextItem( aWorld, dynamic_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1047  }
1048  }
1049  }
1050 
1051  for( auto t : m_board->Tracks() )
1052  {
1053  KICAD_T type = t->Type();
1054 
1055  if( type == PCB_TRACE_T )
1056  {
1057  if( auto segment = syncTrack( t ) )
1058  aWorld->Add( std::move( segment ) );
1059  }
1060  else if( type == PCB_VIA_T )
1061  {
1062  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1063  aWorld->Add( std::move( via ) );
1064  }
1065  }
1066 
1067  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1068 
1069  delete m_ruleResolver;
1071 
1072  aWorld->SetRuleResolver( m_ruleResolver );
1073  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1074 }
1075 
1076 
1078 {
1079  for( auto item : m_hiddenItems )
1080  m_view->SetVisible( item, true );
1081 
1082  m_hiddenItems.clear();
1083 
1084  if( m_previewItems )
1085  {
1088  }
1089 
1090  if( m_debugDecorator )
1092 }
1093 
1094 
1095 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance, bool aEdit )
1096 {
1097  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1098 
1099  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1100 
1101  if( aColor >= 0 )
1102  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1103 
1104  if( aClearance >= 0 )
1105  {
1106  pitem->SetClearance( aClearance );
1107 
1108  if( m_dispOptions )
1109  {
1111  {
1113  pitem->ShowTrackClearance( false );
1114  pitem->ShowViaClearance( false );
1115  break;
1118  pitem->ShowTrackClearance( true );
1119  pitem->ShowViaClearance( true );
1120  break;
1121 
1123  pitem->ShowTrackClearance( !aEdit );
1124  pitem->ShowViaClearance( !aEdit );
1125  break;
1126 
1128  pitem->ShowTrackClearance( !aEdit );
1129  pitem->ShowViaClearance( false );
1130  break;
1131  }
1132  }
1133  }
1134 
1135 
1136  m_previewItems->Add( pitem );
1138 }
1139 
1140 
1142 {
1143  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1144 
1145  if( parent )
1146  {
1147  if( m_view->IsVisible( parent ) )
1148  m_hiddenItems.insert( parent );
1149 
1150  m_view->SetVisible( parent, false );
1151  m_view->Update( parent, KIGFX::APPEARANCE );
1152  }
1153 }
1154 
1155 
1157 {
1158  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1159 
1160  if( parent )
1161  {
1162  m_commit->Remove( parent );
1163  }
1164 }
1165 
1166 
1168 {
1169  BOARD_CONNECTED_ITEM* newBI = NULL;
1170 
1171  switch( aItem->Kind() )
1172  {
1173  case PNS::ITEM::SEGMENT_T:
1174  {
1175  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1176  TRACK* track = new TRACK( m_board );
1177  const SEG& s = seg->Seg();
1178  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1179  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1180  track->SetWidth( seg->Width() );
1181  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1182  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1183  newBI = track;
1184  break;
1185  }
1186 
1187  case PNS::ITEM::VIA_T:
1188  {
1189  VIA* via_board = new VIA( m_board );
1190  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1191  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1192  via_board->SetWidth( via->Diameter() );
1193  via_board->SetDrill( via->Drill() );
1194  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1195  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1196  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1197  ToLAYER_ID( via->Layers().End() ) );
1198  newBI = via_board;
1199  break;
1200  }
1201 
1202  default:
1203  break;
1204  }
1205 
1206  if( newBI )
1207  {
1208  aItem->SetParent( newBI );
1209  newBI->ClearFlags();
1210 
1211  m_commit->Add( newBI );
1212  }
1213 }
1214 
1215 
1217 {
1218  EraseView();
1219  m_commit->Push( _( "Added a track" ) );
1220  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1221 }
1222 
1223 
1225 {
1226  wxLogTrace( "PNS", "SetView %p", aView );
1227 
1228  if( m_previewItems )
1229  {
1231  delete m_previewItems;
1232  }
1233 
1234  m_view = aView;
1238 
1239  delete m_debugDecorator;
1242 }
1243 
1244 
1245 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1246 {
1247  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1248 }
1249 
1250 
1252 {
1253  return m_ruleResolver;
1254 }
1255 
1256 
1258 {
1259  m_router = aRouter;
1260 }
1261 
1262 
1264 {
1265  m_tool = aTool;
1266  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1267 }
1268 
1270 {
1271  m_dispOptions = aDispOptions;
1272 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:148
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:676
void SetHostTool(PCB_TOOL_BASE *aTool)
Class ITEM.
Definition: pns_item.h:53
int localPadClearance(const PNS::ITEM *aItem) const
int matchDpSuffix(wxString aNetName, wxString &aComplementNet, wxString &aBaseDpName)
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
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...
Class SHAPE_SIMPLE.
Definition: shape_simple.h:42
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:159
void SetView(KIGFX::VIEW *aView)
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox
Definition: confirm.cpp:61
int GetNetCode() const
Function GetNetCode.
virtual bool DpNetPair(PNS::ITEM *aItem, int &aNetP, int &aNetN) override
int OutlineCount() const
Returns the number of outlines in the set
PNS_PCBNEW_DEBUG_DECORATOR * m_debugDecorator
Class NODE.
Definition: pns_node.h:136
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:141
TEXTE_PCB class definition.
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:438
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:66
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:411
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:129
const wxPoint GetCenter() const override
Function GetCenter()
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
const wxPoint & GetStart() const
Definition: class_track.h:133
STROKE_T GetShape() const
void AddPoint(VECTOR2I aP, int aColor) override
const VECTOR2I ToVector() const
Function ToVector()
Definition: direction45.h:298
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
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...
Class BOARD to handle a board.
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
void UpdateNet(int aNetCode) override
polygon (not yet used for tracks, but could be in microwave apps)
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:62
void SetClearance(int aClearance)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
Classes to handle copper zones.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
usual segment : line with rounded ends
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const std::vector< wxPoint > & GetBezierPoints() const
No updates are required.
Definition: view_item.h:55
Class RULE_RESOLVER.
Definition: pns_node.h:56
PNS_PCBNEW_DEBUG_DECORATOR(KIGFX::VIEW *aView=NULL)
void Line(const SHAPE_LINE_CHAIN &aLine, int aWidth=0, int aStyle=0)
const SEG & Seg() const
Definition: pns_segment.h:93
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
void ShowTrackClearance(bool aEnabled)
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:162
void HideItem(PNS::ITEM *aItem) override
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
int PointCount() const
Function PointCount()
const wxPoint GetPosition() const override
Definition: class_zone.cpp:179
PNS::DEBUG_DECORATOR * GetDebugDecorator() override
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
PCB_DISPLAY_OPTIONS * m_dispOptions
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
const VECTOR2I & Pos() const
Definition: pns_via.h:88
static const int delta[8][2]
Definition: solve.cpp:112
bool IsTriangulationUpToDate() const
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:417
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
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
void SetWidth(int aWidth)
Definition: class_track.h:126
int Start() const
Definition: pns_layerset.h:83
virtual int DpNetPolarity(int aNet) override
int End() const
Definition: pns_layerset.h:88
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:128
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:243
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
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:
int Diameter() const
Definition: pns_via.h:109
VIATYPE_T ViaType() const
Definition: pns_via.h:99
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:197
int Width() const
Definition: pns_segment.h:88
Class LSET is a set of PCB_LAYER_IDs.
VIEW_ITEM class definition.
Footprint text class description.
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:252
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:777
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1525
Class SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
std::unique_ptr< BOARD_COMMIT > m_commit
int Net() const
Function Net()
Definition: pns_item.h:179
Class DIRECTION_45.
Definition: direction45.h:36
Arcs (with rounded ends)
const wxPoint & GetOffset() const
Definition: class_pad.h:280
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:414
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:496
void ShowViaClearance(bool aEnabled)
std::vector< CLEARANCE_ENT > m_netClearanceCache
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:235
VIATYPE_T GetViaType() const
Definition: class_track.h:437
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
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.
KIGFX::VIEW_GROUP * m_previewItems
const wxPoint & GetArcStart() const
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.
Bezier Curve.
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1539
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:63
void SetColor(const KIGFX::COLOR4D &aColor)
PNS::ROUTER * m_router
const wxPoint GetPosition() const override
Definition: class_track.h:410
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void Commit() override
int GetWidth() const
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:651
PNS::RULE_RESOLVER * GetRuleResolver() override
void EraseView() override
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:36
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,...
double GetAngle() const
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly if it exists,...
KIGFX::VIEW * m_view
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
void SyncWorld(PNS::NODE *aWorld) override
ZONE_CONTAINERS & Zones()
Definition: class_board.h:254
int GetWidth() const
Definition: class_track.h:127
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
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...
int GetNet() const
Function GetNet.
Definition: netinfo.h:227
#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
virtual wxString NetName(int aNet) override
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:394
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0,...
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
size_t i
Definition: json11.cpp:597
VECTOR2I A
Definition: seg.h:44
wxPoint ShapePos() const
Definition: class_pad.cpp:562
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:346
void AddItem(PNS::ITEM *aItem) override
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:445
void SetView(KIGFX::VIEW *aView)
currently selected items overlay
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
PCB_TOOL_BASE * m_tool
const wxPoint & GetEnd() const
Definition: class_track.h:130
bool GetDoNotAllowTracks() const
Definition: class_zone.h:654
int ShowModal() override
Definition: confirm.cpp:103
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:122
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1485
void Clear()
Function Clear() Removes all points from the line chain.
void SetStart(const wxPoint &aStart)
Definition: class_track.h:132
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:251
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType, int aWidth) override
const Vec & GetSize() const
Definition: box2.h:187
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:218
Module description (excepted pads)
void AddDirections(VECTOR2D aP, int aMask, int aColor) override
virtual int Clearance(const PNS::ITEM *aA, const PNS::ITEM *aB) const override
const Vec & GetOrigin() const
Definition: box2.h:191
Class VIEW.
Definition: view.h:61
const wxSize & GetSize() const
Definition: class_pad.h:271
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
void SetDisplayOptions(PCB_DISPLAY_OPTIONS *aDispOptions)
int Drill() const
Definition: pns_via.h:120
wxString GetClassName() const
Function GetClassName returns the class name.
Definition: netinfo.h:131
void AddSegment(SEG aS, int aColor) override
Push and Shove diff pair dimensions (gap) settings dialog.
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:240
#define ARC_APPROX_SEGMENTS_COUNT_HIGH_DEF
Definition: pcbnew.h:42
NODE * GetWorld() const
Definition: pns_router.h:143
void SetBoard(BOARD *aBoard)
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsPolygonFilled() const
Polygonal shape is not always filled.
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
void DisplayItem(const PNS::ITEM *aItem, int aColor=0, int aClearance=0, bool aEdit=false) override
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:595
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:151
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
#define mod(a, n)
Definition: greymap.cpp:24
PNS_PCBNEW_RULE_RESOLVER(BOARD *aBoard, PNS::ROUTER *aRouter)
Class LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:214
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:253
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#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:45