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( auto mod : m_board->Modules() )
136  {
137  auto moduleClearance = mod->GetLocalClearance();
138 
139  for( auto pad : mod->Pads() )
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  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ) );
620 
621  // TransformRoundRectToPolygon creates only one convex polygon
622  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
623  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
624 
625  for( int ii = 0; ii < poly.PointCount(); ++ii )
626  shape->Append( poly.Point( ii ) );
627 
628  solid->SetShape( shape );
629  }
630  break;
631 
632  default:
633  wxLogTrace( "PNS", "unsupported pad shape" );
634  return nullptr;
635  }
636  }
637  else
638  {
639  switch( aPad->GetShape() )
640  {
641  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
642 
643  case PAD_SHAPE_OVAL:
644  if( sz.x == sz.y )
645  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
646  else
647  {
648  wxPoint start;
649  wxPoint end;
650  wxPoint corner;
651 
652  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
653 
654  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
655 
656  if( start.y == 0 )
657  corner = wxPoint( start.x, -( w / 2 ) );
658  else
659  corner = wxPoint( w / 2, start.y );
660 
661  RotatePoint( &start, aPad->GetOrientation() );
662  RotatePoint( &corner, aPad->GetOrientation() );
663  shape->Append( wx_c + corner );
664 
665  for( int rot = 100; rot <= 1800; rot += 100 )
666  {
667  wxPoint p( corner );
668  RotatePoint( &p, start, rot );
669  shape->Append( wx_c + p );
670  }
671 
672  if( end.y == 0 )
673  corner = wxPoint( end.x, w / 2 );
674  else
675  corner = wxPoint( -( w / 2 ), end.y );
676 
677  RotatePoint( &end, aPad->GetOrientation() );
678  RotatePoint( &corner, aPad->GetOrientation() );
679  shape->Append( wx_c + corner );
680 
681  for( int rot = 100; rot <= 1800; rot += 100 )
682  {
683  wxPoint p( corner );
684  RotatePoint( &p, end, rot );
685  shape->Append( wx_c + p );
686  }
687 
688  solid->SetShape( shape );
689  }
690  break;
691 
692  case PAD_SHAPE_RECT:
693  case PAD_SHAPE_TRAPEZOID:
694  {
695  wxPoint coords[4];
696  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
697 
698  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
699  for( int ii = 0; ii < 4; ii++ )
700  {
701  shape->Append( wx_c + coords[ii] );
702  }
703 
704  solid->SetShape( shape );
705  break;
706  }
707 
709  case PAD_SHAPE_ROUNDRECT:
710  {
711  SHAPE_POLY_SET outline;
712  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ) );
713 
714  // TransformRoundRectToPolygon creates only one convex polygon
715  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
716  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
717 
718  for( int ii = 0; ii < poly.PointCount(); ++ii )
719  {
720  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
721  }
722 
723  solid->SetShape( shape );
724  break;
725  }
726 
727  default:
728  wxLogTrace( "PNS", "unsupported pad shape" );
729  return nullptr;
730  }
731  }
732  }
733  return solid;
734 }
735 
736 
737 std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
738 {
739  std::unique_ptr< PNS::SEGMENT > segment(
740  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
741  );
742 
743  segment->SetWidth( aTrack->GetWidth() );
744  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
745  segment->SetParent( aTrack );
746 
747  if( aTrack->IsLocked() )
748  segment->Mark( PNS::MK_LOCKED );
749 
750  return segment;
751 }
752 
753 
754 std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE::syncVia( VIA* aVia )
755 {
756  PCB_LAYER_ID top, bottom;
757  aVia->LayerPair( &top, &bottom );
758  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
759  aVia->GetPosition(),
760  LAYER_RANGE( top, bottom ),
761  aVia->GetWidth(),
762  aVia->GetDrillValue(),
763  aVia->GetNetCode(),
764  aVia->GetViaType() )
765  );
766 
767  via->SetParent( aVia );
768 
769  if( aVia->IsLocked() )
770  via->Mark( PNS::MK_LOCKED );
771 
772  return via;
773 }
774 
775 
777 {
778  SHAPE_POLY_SET poly;
779 
780  // TODO handle no-via restriction
781  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
782  return false;
783 
784  // Some intersecting zones, despite being on the same layer with the same net, cannot be
785  // merged due to other parameters such as fillet radius. The copper pour will end up
786  // effectively merged though, so we want to keep the corners of such intersections sharp.
787  std::set<VECTOR2I> colinearCorners;
788  aZone->GetColinearCorners( m_board, colinearCorners );
789 
790  aZone->BuildSmoothedPoly( poly, &colinearCorners );
791  poly.CacheTriangulation();
792 
793  if( !poly.IsTriangulationUpToDate() )
794  {
795  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
796  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
797  dlg.ShowDetailedText(
798  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
799  "Please verify it is not a self-intersecting polygon." ),
800  aZone->GetSelectMenuText( MILLIMETRES ) ) );
801  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
802  dlg.ShowModal();
803 
804  return false;
805  }
806 
807  LSET layers = aZone->GetLayerSet();
808 
809  for( int layer = F_Cu; layer <= B_Cu; layer++ )
810  {
811  if ( ! layers[layer] )
812  continue;
813 
814  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
815  {
816  auto tri = poly.TriangulatedPolygon( outline );
817 
818  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
819  {
820  VECTOR2I a, b, c;
821  tri->GetTriangle( i, a, b, c );
822  auto triShape = new SHAPE_SIMPLE;
823 
824  triShape->Append( a );
825  triShape->Append( b );
826  triShape->Append( c );
827 
828  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
829 
830  solid->SetLayer( layer );
831  solid->SetNet( -1 );
832  solid->SetParent( aZone );
833  solid->SetShape( triShape );
834  solid->SetRoutable( false );
835 
836  aWorld->Add( std::move( solid ) );
837  }
838  }
839  }
840 
841  return true;
842 }
843 
844 
846 {
847  if( !IsCopperLayer( aLayer ) )
848  return false;
849 
850  int textWidth = aText->GetThickness();
851  std::vector<wxPoint> textShape;
852 
853  aText->TransformTextShapeToSegmentList( textShape );
854 
855  if( textShape.size() < 2 )
856  return false;
857 
858  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
859  {
860  VECTOR2I start( textShape[jj] );
861  VECTOR2I end( textShape[jj+1] );
862  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
863 
864  solid->SetLayer( aLayer );
865  solid->SetNet( -1 );
866  solid->SetParent( nullptr );
867  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
868  solid->SetRoutable( false );
869 
870  aWorld->Add( std::move( solid ) );
871  }
872 
873  return true;
874 
875  /* A coarser (but faster) method:
876  *
877  SHAPE_POLY_SET outline;
878  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
879 
880  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
881 
882  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
883  shape->Append( *iter );
884 
885  solid->SetShape( shape );
886 
887  solid->SetLayer( aLayer );
888  solid->SetNet( -1 );
889  solid->SetParent( nullptr );
890  solid->SetRoutable( false );
891  aWorld->Add( std::move( solid ) );
892  return true;
893  */
894 }
895 
896 
898 {
899  std::vector<SHAPE_SEGMENT*> segs;
900 
901  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
902  return false;
903 
904  switch( aItem->GetShape() )
905  {
906  case S_ARC:
907  {
908  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), aItem->GetAngle() / 10.0 );
909  auto l = arc.ConvertToPolyline();
910 
911  for( int i = 0; i < l.SegmentCount(); i++ )
912  {
913  SHAPE_SEGMENT* seg = new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() );
914  segs.push_back( seg );
915  }
916 
917  break;
918  }
919 
920  case S_SEGMENT:
921  segs.push_back(
922  new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() ) );
923 
924  break;
925 
926  case S_CIRCLE:
927  {
928  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
929  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
930  auto l = circle.ConvertToPolyline();
931 
932  for( int i = 0; i < l.SegmentCount(); i++ )
933  segs.push_back( new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() ) );
934 
935  break;
936  }
937 
938  case S_CURVE:
939  {
940  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
941  auto pts = aItem->GetBezierPoints();
942 
943  for( size_t ii = 1; ii < pts.size(); ii++ )
944  {
945  segs.push_back( new SHAPE_SEGMENT(
946  VECTOR2I( pts[ii - 1] ), VECTOR2I( pts[ii] ), aItem->GetWidth() ) );
947  }
948  break;
949  }
950 
951  case S_POLYGON:
952  if( !aItem->IsPolygonFilled() )
953  {
954  auto poly = aItem->BuildPolyPointsList();
955  for( size_t ii = 1; ii < poly.size(); ii++ )
956  {
957  segs.push_back( new SHAPE_SEGMENT(
958  VECTOR2I( poly[ii - 1] ), VECTOR2I( poly[ii] ), aItem->GetWidth() ) );
959  }
960 
961  segs.push_back( new SHAPE_SEGMENT(
962  VECTOR2I( poly.back() ), VECTOR2I( poly.front() ), aItem->GetWidth() ) );
963  }
964  break;
965 
966  default:
967  break;
968  }
969 
970  for( auto seg : segs )
971  {
972  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
973 
974  if( aItem->GetLayer() == Edge_Cuts )
975  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
976  else
977  solid->SetLayer( aItem->GetLayer() );
978 
979  solid->SetNet( -1 );
980  solid->SetParent( nullptr );
981  solid->SetShape( seg );
982  solid->SetRoutable( false );
983 
984  aWorld->Add( std::move( solid ) );
985  }
986 
987  return true;
988 }
989 
991 {
992  m_board = aBoard;
993  wxLogTrace( "PNS", "m_board = %p", m_board );
994 }
995 
996 
998 {
999  int worstPadClearance = 0;
1000 
1001  if( !m_board )
1002  {
1003  wxLogTrace( "PNS", "No board attached, aborting sync." );
1004  return;
1005  }
1006 
1007  for( auto gitem : m_board->Drawings() )
1008  {
1009  if ( gitem->Type() == PCB_LINE_T )
1010  {
1011  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1012  }
1013  else if( gitem->Type() == PCB_TEXT_T )
1014  {
1015  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1016  }
1017  }
1018 
1019  for( auto zone : m_board->Zones() )
1020  {
1021  syncZone( aWorld, zone );
1022  }
1023 
1024  for( auto module : m_board->Modules() )
1025  {
1026  for( auto pad : module->Pads() )
1027  {
1028  if( auto solid = syncPad( pad ) )
1029  aWorld->Add( std::move( solid ) );
1030 
1031  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1032  }
1033 
1034  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1035  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1036 
1037  if( module->IsNetTie() )
1038  continue;
1039 
1040  for( auto mgitem : module->GraphicalItems() )
1041  {
1042  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1043  {
1044  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1045  }
1046  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1047  {
1048  syncTextItem( aWorld, dynamic_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1049  }
1050  }
1051  }
1052 
1053  for( auto t : m_board->Tracks() )
1054  {
1055  KICAD_T type = t->Type();
1056 
1057  if( type == PCB_TRACE_T )
1058  {
1059  if( auto segment = syncTrack( t ) )
1060  aWorld->Add( std::move( segment ) );
1061  }
1062  else if( type == PCB_VIA_T )
1063  {
1064  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1065  aWorld->Add( std::move( via ) );
1066  }
1067  }
1068 
1069  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1070 
1071  delete m_ruleResolver;
1073 
1074  aWorld->SetRuleResolver( m_ruleResolver );
1075  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1076 }
1077 
1078 
1080 {
1081  for( auto item : m_hiddenItems )
1082  m_view->SetVisible( item, true );
1083 
1084  m_hiddenItems.clear();
1085 
1086  if( m_previewItems )
1087  {
1090  }
1091 
1092  if( m_debugDecorator )
1094 }
1095 
1096 
1097 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance, bool aEdit )
1098 {
1099  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1100 
1101  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1102 
1103  if( aColor >= 0 )
1104  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1105 
1106  if( aClearance >= 0 )
1107  {
1108  pitem->SetClearance( aClearance );
1109 
1110  if( m_dispOptions )
1111  {
1113  {
1115  pitem->ShowTrackClearance( false );
1116  pitem->ShowViaClearance( false );
1117  break;
1120  pitem->ShowTrackClearance( true );
1121  pitem->ShowViaClearance( true );
1122  break;
1123 
1125  pitem->ShowTrackClearance( !aEdit );
1126  pitem->ShowViaClearance( !aEdit );
1127  break;
1128 
1130  pitem->ShowTrackClearance( !aEdit );
1131  pitem->ShowViaClearance( false );
1132  break;
1133  }
1134  }
1135  }
1136 
1137 
1138  m_previewItems->Add( pitem );
1140 }
1141 
1142 
1144 {
1145  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1146 
1147  if( parent )
1148  {
1149  if( m_view->IsVisible( parent ) )
1150  m_hiddenItems.insert( parent );
1151 
1152  m_view->SetVisible( parent, false );
1153  m_view->Update( parent, KIGFX::APPEARANCE );
1154  }
1155 }
1156 
1157 
1159 {
1160  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1161 
1162  if( parent )
1163  {
1164  m_commit->Remove( parent );
1165  }
1166 }
1167 
1168 
1170 {
1171  BOARD_CONNECTED_ITEM* newBI = NULL;
1172 
1173  switch( aItem->Kind() )
1174  {
1175  case PNS::ITEM::SEGMENT_T:
1176  {
1177  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1178  TRACK* track = new TRACK( m_board );
1179  const SEG& s = seg->Seg();
1180  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1181  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1182  track->SetWidth( seg->Width() );
1183  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1184  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1185  newBI = track;
1186  break;
1187  }
1188 
1189  case PNS::ITEM::VIA_T:
1190  {
1191  VIA* via_board = new VIA( m_board );
1192  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1193  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1194  via_board->SetWidth( via->Diameter() );
1195  via_board->SetDrill( via->Drill() );
1196  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1197  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1198  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1199  ToLAYER_ID( via->Layers().End() ) );
1200  newBI = via_board;
1201  break;
1202  }
1203 
1204  default:
1205  break;
1206  }
1207 
1208  if( newBI )
1209  {
1210  aItem->SetParent( newBI );
1211  newBI->ClearFlags();
1212 
1213  m_commit->Add( newBI );
1214  }
1215 }
1216 
1217 
1219 {
1220  EraseView();
1221  m_commit->Push( _( "Added a track" ) );
1222  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1223 }
1224 
1225 
1227 {
1228  wxLogTrace( "PNS", "SetView %p", aView );
1229 
1230  if( m_previewItems )
1231  {
1233  delete m_previewItems;
1234  }
1235 
1236  m_view = aView;
1240 
1241  delete m_debugDecorator;
1244 }
1245 
1246 
1247 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1248 {
1249  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1250 }
1251 
1252 
1254 {
1255  return m_ruleResolver;
1256 }
1257 
1258 
1260 {
1261  m_router = aRouter;
1262 }
1263 
1264 
1266 {
1267  m_tool = aTool;
1268  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1269 }
1270 
1272 {
1273  m_dispOptions = aDispOptions;
1274 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:124
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:57
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:60
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:339
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:312
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:105
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:109
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...
Definition: class_zone.cpp:920
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...
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 BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aError=ARC_HIGH_DEF) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape,...
void SetClearance(int aClearance)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
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:229
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:172
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
bool IsTriangulationUpToDate() const
void GetColinearCorners(BOARD *aBoard, std::set< VECTOR2I > &aCorners)
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
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:419
Definitions for tracks, vias and 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:102
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:109
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:234
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.
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:779
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
MODULES & Modules()
Definition: class_board.h:236
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
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, std::set< VECTOR2I > *aPreserveCorners) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly.
Arcs (with rounded ends)
const wxPoint & GetOffset() const
Definition: class_pad.h:283
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:416
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:527
void ShowViaClearance(bool aEnabled)
std::vector< CLEARANCE_ENT > m_netClearanceCache
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:233
VIATYPE_T GetViaType() const
Definition: class_track.h:338
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
#define _(s)
const wxPoint GetPosition() const override
Definition: class_track.h:311
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:621
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
double GetAngle() const
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:250
int GetWidth() const
Definition: class_track.h:103
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 to draw a dummy shape when a LIB_PART is not found in library.
int GetNet() const
Function GetNet.
Definition: netinfo.h:225
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
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:396
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:570
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:348
void AddItem(PNS::ITEM *aItem) override
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:346
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:106
bool GetDoNotAllowTracks() const
Definition: class_zone.h:624
int ShowModal() override
Definition: confirm.cpp:102
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:253
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:108
VECTOR2I & Point(int aIndex)
Function Point()
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
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:221
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:274
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
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
DRAWINGS & Drawings()
Definition: class_board.h:245
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)
TRACKS & Tracks()
Definition: class_board.h:227
Class LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:214
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
#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