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_text_mod.h>
26 #include <class_edge_mod.h>
27 #include <class_track.h>
28 #include <class_zone.h>
29 #include <class_drawsegment.h>
30 #include <class_pcb_text.h>
31 #include <board_commit.h>
33 #include <geometry/convex_hull.h>
34 #include <confirm.h>
35 
36 #include <view/view.h>
37 #include <view/view_item.h>
38 #include <view/view_group.h>
40 
41 #include <pcb_painter.h>
42 
43 #include <geometry/shape.h>
45 #include <geometry/shape_rect.h>
46 #include <geometry/shape_circle.h>
47 #include <geometry/shape_arc.h>
48 
49 #include "tools/pcb_tool_base.h"
50 
51 #include "pns_kicad_iface.h"
52 #include "../../include/geometry/shape_simple.h"
53 #include "pns_routing_settings.h"
54 #include "pns_item.h"
55 #include "pns_solid.h"
56 #include "pns_segment.h"
57 #include "pns_node.h"
58 #include "pns_topology.h"
59 #include "pns_router.h"
60 #include "pns_debug_decorator.h"
61 #include "router_preview_item.h"
62 
64 
66 {
67 public:
68  PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER* aRouter );
69  virtual ~PNS_PCBNEW_RULE_RESOLVER();
70 
71  virtual bool CollideHoles( const PNS::ITEM* aA, const PNS::ITEM* aB,
72  bool aNeedMTV, VECTOR2I* aMTV ) const override;
73 
74  virtual int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const override;
75  virtual int Clearance( int aNetCode ) const override;
76  virtual int DpCoupledNet( int aNet ) override;
77  virtual int DpNetPolarity( int aNet ) override;
78  virtual bool DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN ) override;
79 
80  virtual wxString NetName( int aNet ) override;
81 
82 private:
84  {
87  int clearance;
88  };
89 
90  int holeRadius( const PNS::ITEM* aItem ) const;
91  int localPadClearance( const PNS::ITEM* aItem ) const;
92  int matchDpSuffix( const wxString& aNetName, wxString& aComplementNet, wxString& aBaseDpName );
93 
96 
97  std::vector<CLEARANCE_ENT> m_netClearanceCache;
98  std::unordered_map<const D_PAD*, int> m_localClearanceCache;
100 };
101 
102 
104  m_router( aRouter ),
105  m_board( aBoard )
106 {
107  PNS::NODE* world = m_router->GetWorld();
108 
109  PNS::TOPOLOGY topo( world );
111 
112  // Build clearance cache for net classes
113  for( unsigned int i = 0; i < m_board->GetNetCount(); i++ )
114  {
115  NETINFO_ITEM* ni = m_board->FindNet( i );
116 
117  if( ni == NULL )
118  continue;
119 
120  CLEARANCE_ENT ent;
121  ent.coupledNet = DpCoupledNet( i );
122 
123  wxString netClassName = ni->GetClassName();
124  NETCLASSPTR nc = m_board->GetDesignSettings().m_NetClasses.Find( netClassName );
125 
126  int clearance = nc->GetClearance();
127  ent.clearance = clearance;
128  ent.dpClearance = nc->GetDiffPairGap();
129  m_netClearanceCache[i] = ent;
130 
131  wxLogTrace( "PNS", "Add net %u netclass %s clearance %d Diff Pair clearance %d",
132  i, netClassName.mb_str(), clearance, ent.dpClearance );
133  }
134 
135  // Build clearance cache for pads
136  for( auto mod : m_board->Modules() )
137  {
138  auto moduleClearance = mod->GetLocalClearance();
139 
140  for( auto pad : mod->Pads() )
141  {
142  int padClearance = pad->GetLocalClearance();
143 
144  if( padClearance > 0 )
145  m_localClearanceCache[ pad ] = padClearance;
146 
147  else if( moduleClearance > 0 )
148  m_localClearanceCache[ pad ] = moduleClearance;
149  }
150  }
151 
152  auto defaultRule = m_board->GetDesignSettings().m_NetClasses.Find ("Default");
153 
154  if( defaultRule )
155  {
156  m_defaultClearance = defaultRule->GetClearance();
157  }
158  else
159  {
160  m_defaultClearance = Millimeter2iu(0.254);
161  }
162 }
163 
164 
166 {
167 }
168 
169 
171 {
172  if( aItem->Kind() == PNS::ITEM::SOLID_T )
173  {
174  const D_PAD* pad = dynamic_cast<const D_PAD*>( aItem->Parent() );
175 
176  if( pad && pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
177  return pad->GetDrillSize().x / 2;
178  }
179  else if( aItem->Kind() == PNS::ITEM::VIA_T )
180  {
181  const ::VIA* via = dynamic_cast<const ::VIA*>( aItem->Parent() );
182 
183  if( via )
184  return via->GetDrillValue() / 2;
185  }
186 
187  return 0;
188 }
189 
190 
192  bool aNeedMTV, VECTOR2I* aMTV ) const
193 {
194  VECTOR2I pos_a = aA->Shape()->Centre();
195  VECTOR2I pos_b = aB->Shape()->Centre();
196 
197  // Holes with identical locations are allowable
198  if( pos_a == pos_b )
199  return false;
200 
201  int radius_a = holeRadius( aA );
202  int radius_b = holeRadius( aB );
203 
204  // Do both objects have holes?
205  if( radius_a > 0 && radius_b > 0 )
206  {
207  int holeToHoleMin = m_board->GetDesignSettings().m_HoleToHoleMin;
208 
209  ecoord min_dist = holeToHoleMin + radius_a + radius_b;
210  ecoord min_dist_sq = min_dist * min_dist;
211 
212  const VECTOR2I delta = pos_b - pos_a;
213 
214  ecoord dist_sq = delta.SquaredEuclideanNorm();
215 
216  if( dist_sq < min_dist_sq )
217  {
218  if( aNeedMTV )
219  *aMTV = delta.Resize( min_dist - sqrt( dist_sq ) + 3 ); // fixme: apparent rounding error
220 
221  return true;
222  }
223  }
224 
225  return false;
226 }
227 
228 
230 {
231  if( !aItem->Parent() || aItem->Parent()->Type() != PCB_PAD_T )
232  return 0;
233 
234  const D_PAD* pad = static_cast<D_PAD*>( aItem->Parent() );
235 
236  auto i = m_localClearanceCache.find( pad );
237 
238  if( i == m_localClearanceCache.end() )
239  return 0;
240 
241  return i->second;
242 }
243 
244 
245 int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const
246 {
247  int net_a = aA->Net();
248  int cl_a = ( net_a >= 0 ? m_netClearanceCache[net_a].clearance : m_defaultClearance );
249  int net_b = aB->Net();
250  int cl_b = ( net_b >= 0 ? m_netClearanceCache[net_b].clearance : m_defaultClearance );
251 
252  // Pad clearance is 0 if the ITEM* is not a pad
253  int pad_a = localPadClearance( aA );
254  int pad_b = localPadClearance( aB );
255 
256  if( pad_a > 0 )
257  cl_a = pad_a;
258 
259  if( pad_b > 0 )
260  cl_b = pad_b;
261 
262  return std::max( cl_a, cl_b );
263 }
264 
265 
266 int PNS_PCBNEW_RULE_RESOLVER::Clearance( int aNetCode ) const
267 {
268  if( aNetCode > 0 && aNetCode < (int) m_netClearanceCache.size() )
269  return m_netClearanceCache[aNetCode].clearance;
270 
271  return m_defaultClearance;
272 }
273 
274 
275 int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( const wxString& aNetName, wxString& aComplementNet,
276  wxString& aBaseDpName )
277 {
278  int rv = 0;
279 
280  if( aNetName.EndsWith( "+" ) )
281  {
282  aComplementNet = "-";
283  rv = 1;
284  }
285  else if( aNetName.EndsWith( "P" ) )
286  {
287  aComplementNet = "N";
288  rv = 1;
289  }
290  else if( aNetName.EndsWith( "-" ) )
291  {
292  aComplementNet = "+";
293  rv = -1;
294  }
295  else if( aNetName.EndsWith( "N" ) )
296  {
297  aComplementNet = "P";
298  rv = -1;
299  }
300  // Match P followed by 2 digits
301  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "P" )
302  {
303  aComplementNet = "N" + aNetName.Right( 2 );
304  rv = 1;
305  }
306  // Match P followed by 1 digit
307  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "P" )
308  {
309  aComplementNet = "N" + aNetName.Right( 1 );
310  rv = 1;
311  }
312  // Match N followed by 2 digits
313  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "N" )
314  {
315  aComplementNet = "P" + aNetName.Right( 2 );
316  rv = -1;
317  }
318  // Match N followed by 1 digit
319  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "N" )
320  {
321  aComplementNet = "P" + aNetName.Right( 1 );
322  rv = -1;
323  }
324  if( rv != 0 )
325  {
326  aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
327  aComplementNet = aBaseDpName + aComplementNet;
328  }
329 
330  return rv;
331 }
332 
333 
335 {
336  wxString refName = m_board->FindNet( aNet )->GetNetname();
337  wxString dummy, coupledNetName;
338 
339  if( matchDpSuffix( refName, coupledNetName, dummy ) )
340  {
341  NETINFO_ITEM* net = m_board->FindNet( coupledNetName );
342 
343  if( !net )
344  return -1;
345 
346  return net->GetNet();
347  }
348 
349  return -1;
350 }
351 
352 
354 {
355  return m_board->FindNet( aNet )->GetNetname();
356 }
357 
358 
360 {
361  wxString refName = m_board->FindNet( aNet )->GetNetname();
362  wxString dummy1, dummy2;
363 
364  return matchDpSuffix( refName, dummy1, dummy2 );
365 }
366 
367 
368 bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN )
369 {
370  if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
371  return false;
372 
373  wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
374  wxString netNameN, netNameCoupled, netNameBase;
375 
376  int r = matchDpSuffix( netNameP, netNameCoupled, netNameBase );
377 
378  if( r == 0 )
379  return false;
380  else if( r == 1 )
381  {
382  netNameN = netNameCoupled;
383  }
384  else
385  {
386  netNameN = netNameP;
387  netNameP = netNameCoupled;
388  }
389 
390 // wxLogTrace( "PNS","p %s n %s base %s\n", (const char *)netNameP.c_str(), (const char *)netNameN.c_str(), (const char *)netNameBase.c_str() );
391 
392  NETINFO_ITEM* netInfoP = m_board->FindNet( netNameP );
393  NETINFO_ITEM* netInfoN = m_board->FindNet( netNameN );
394 
395  //wxLogTrace( "PNS","ip %p in %p\n", netInfoP, netInfoN);
396 
397  if( !netInfoP || !netInfoN )
398  return false;
399 
400  aNetP = netInfoP->GetNet();
401  aNetN = netInfoN->GetNet();
402 
403  return true;
404 }
405 
406 
408 {
409 public:
411  m_view( NULL ), m_items( NULL )
412  {
413  SetView( aView );
414  }
415 
417  {
418  Clear();
419  delete m_items;
420  }
421 
422  void SetView( KIGFX::VIEW* aView )
423  {
424  Clear();
425  delete m_items;
426  m_items = NULL;
427  m_view = aView;
428 
429  if( m_view == NULL )
430  return;
431 
434  m_view->Add( m_items );
435  }
436 
437  void AddPoint( VECTOR2I aP, int aColor ) override
438  {
440 
441  l.Append( aP - VECTOR2I( -50000, -50000 ) );
442  l.Append( aP + VECTOR2I( -50000, -50000 ) );
443 
444  AddLine( l, aColor, 10000 );
445 
446  l.Clear();
447  l.Append( aP - VECTOR2I( 50000, -50000 ) );
448  l.Append( aP + VECTOR2I( 50000, -50000 ) );
449 
450  AddLine( l, aColor, 10000 );
451  }
452 
453  void AddBox( BOX2I aB, int aColor ) override
454  {
456 
457  VECTOR2I o = aB.GetOrigin();
458  VECTOR2I s = aB.GetSize();
459 
460  l.Append( o );
461  l.Append( o.x + s.x, o.y );
462  l.Append( o.x + s.x, o.y + s.y );
463  l.Append( o.x, o.y + s.y );
464  l.Append( o );
465 
466  AddLine( l, aColor, 10000 );
467  }
468 
469  void AddSegment( SEG aS, int aColor ) override
470  {
472 
473  l.Append( aS.A );
474  l.Append( aS.B );
475 
476  AddLine( l, aColor, 10000 );
477  }
478 
479  void AddDirections( VECTOR2D aP, int aMask, int aColor ) override
480  {
481  BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );
482 
483  AddBox( b, aColor );
484  for( int i = 0; i < 8; i++ )
485  {
486  if( ( 1 << i ) & aMask )
487  {
489  AddSegment( SEG( aP, aP + v ), aColor );
490  }
491  }
492  }
493 
494  void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth ) override
495  {
496  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( NULL, m_view );
497 
498  pitem->Line( aLine, aWidth, aType );
499  m_items->Add( pitem ); // Should not be needed, as m_items has been passed as a parent group in alloc;
500  m_view->Update( m_items );
501  }
502 
503  void Clear() override
504  {
505  if( m_view && m_items )
506  {
507  m_items->FreeItems();
508  m_view->Update( m_items );
509  }
510  }
511 
512 private:
515 };
516 
517 
519 {
520  return m_debugDecorator;
521 }
522 
523 
525 {
526  m_ruleResolver = nullptr;
527  m_board = nullptr;
528  m_tool = nullptr;
529  m_view = nullptr;
530  m_previewItems = nullptr;
531  m_router = nullptr;
532  m_debugDecorator = nullptr;
533  m_dispOptions = nullptr;
534 }
535 
536 
538 {
539  delete m_ruleResolver;
540  delete m_debugDecorator;
541 
542  if( m_previewItems )
543  {
545  delete m_previewItems;
546  }
547 }
548 
549 
550 std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
551 {
552  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
553 
554  // ignore non-copper pads
555  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
556  return NULL;
557 
558  switch( aPad->GetAttribute() )
559  {
560  case PAD_ATTRIB_STANDARD:
561  break;
562 
563  case PAD_ATTRIB_SMD:
565  case PAD_ATTRIB_CONN:
566  {
567  LSET lmsk = aPad->GetLayerSet();
568  bool is_copper = false;
569 
570  for( int i = 0; i < MAX_CU_LAYERS; i++ )
571  {
572  if( lmsk[i] )
573  {
574  is_copper = true;
575 
577  layers = LAYER_RANGE( i );
578 
579  break;
580  }
581  }
582 
583  if( !is_copper )
584  return NULL;
585  }
586  break;
587 
588  default:
589  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
590  return NULL;
591  }
592 
593  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
594 
595  solid->SetLayers( layers );
596  solid->SetNet( aPad->GetNetCode() );
597  solid->SetParent( aPad );
598 
599  wxPoint wx_c = aPad->ShapePos();
600  wxSize wx_sz = aPad->GetSize();
601  wxPoint offset = aPad->GetOffset();
602 
603  VECTOR2I c( wx_c.x, wx_c.y );
604  VECTOR2I sz( wx_sz.x, wx_sz.y );
605 
606  RotatePoint( &offset, aPad->GetOrientation() );
607 
608  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
609  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
610 
611  double orient = aPad->GetOrientation() / 10.0;
612 
613  if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
614  {
615  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
616  }
617  else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
618  {
619  SHAPE_POLY_SET outline;
620  outline.Append( aPad->GetCustomShapeAsPolygon() );
621  aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );
622 
623  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
624 
625  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
626  shape->Append( *iter );
627 
628  solid->SetShape( shape );
629  }
630  else
631  {
632  if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
633  {
634  if( orient == 90.0 || orient == 270.0 )
635  sz = VECTOR2I( sz.y, sz.x );
636 
637  switch( aPad->GetShape() )
638  {
639  case PAD_SHAPE_OVAL:
640  if( sz.x == sz.y )
641  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
642  else
643  {
644  VECTOR2I delta;
645 
646  if( sz.x > sz.y )
647  delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
648  else
649  delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );
650 
651  SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
652  std::min( sz.x, sz.y ) );
653  solid->SetShape( shape );
654  }
655  break;
656 
657  case PAD_SHAPE_RECT:
658  solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
659  break;
660 
661  case PAD_SHAPE_TRAPEZOID:
662  {
663  wxPoint coords[4];
664  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
665  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
666 
667  for( int ii = 0; ii < 4; ii++ )
668  {
669  shape->Append( wx_c + coords[ii] );
670  }
671 
672  solid->SetShape( shape );
673  break;
674  }
675 
677  case PAD_SHAPE_ROUNDRECT:
678  {
679  SHAPE_POLY_SET outline;
680  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ) );
681 
682  // TransformRoundRectToPolygon creates only one convex polygon
683  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
684  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
685 
686  for( int ii = 0; ii < poly.PointCount(); ++ii )
687  shape->Append( poly.Point( ii ) );
688 
689  solid->SetShape( shape );
690  }
691  break;
692 
693  default:
694  wxLogTrace( "PNS", "unsupported pad shape" );
695  return nullptr;
696  }
697  }
698  else
699  {
700  switch( aPad->GetShape() )
701  {
702  // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above
703 
704  case PAD_SHAPE_OVAL:
705  if( sz.x == sz.y )
706  solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
707  else
708  {
709  wxPoint start;
710  wxPoint end;
711  wxPoint corner;
712 
713  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
714 
715  int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );
716 
717  if( start.y == 0 )
718  corner = wxPoint( start.x, -( w / 2 ) );
719  else
720  corner = wxPoint( w / 2, start.y );
721 
722  RotatePoint( &start, aPad->GetOrientation() );
723  RotatePoint( &corner, aPad->GetOrientation() );
724  shape->Append( wx_c + corner );
725 
726  for( int rot = 100; rot <= 1800; rot += 100 )
727  {
728  wxPoint p( corner );
729  RotatePoint( &p, start, rot );
730  shape->Append( wx_c + p );
731  }
732 
733  if( end.y == 0 )
734  corner = wxPoint( end.x, w / 2 );
735  else
736  corner = wxPoint( -( w / 2 ), end.y );
737 
738  RotatePoint( &end, aPad->GetOrientation() );
739  RotatePoint( &corner, aPad->GetOrientation() );
740  shape->Append( wx_c + corner );
741 
742  for( int rot = 100; rot <= 1800; rot += 100 )
743  {
744  wxPoint p( corner );
745  RotatePoint( &p, end, rot );
746  shape->Append( wx_c + p );
747  }
748 
749  solid->SetShape( shape );
750  }
751  break;
752 
753  case PAD_SHAPE_RECT:
754  case PAD_SHAPE_TRAPEZOID:
755  {
756  wxPoint coords[4];
757  aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
758 
759  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
760  for( int ii = 0; ii < 4; ii++ )
761  {
762  shape->Append( wx_c + coords[ii] );
763  }
764 
765  solid->SetShape( shape );
766  break;
767  }
768 
770  case PAD_SHAPE_ROUNDRECT:
771  {
772  SHAPE_POLY_SET outline;
773  aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ) );
774 
775  // TransformRoundRectToPolygon creates only one convex polygon
776  SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
777  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
778 
779  for( int ii = 0; ii < poly.PointCount(); ++ii )
780  {
781  shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
782  }
783 
784  solid->SetShape( shape );
785  break;
786  }
787 
788  default:
789  wxLogTrace( "PNS", "unsupported pad shape" );
790  return nullptr;
791  }
792  }
793  }
794  return solid;
795 }
796 
797 
798 std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
799 {
800  std::unique_ptr< PNS::SEGMENT > segment(
801  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
802  );
803 
804  segment->SetWidth( aTrack->GetWidth() );
805  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
806  segment->SetParent( aTrack );
807 
808  if( aTrack->IsLocked() )
809  segment->Mark( PNS::MK_LOCKED );
810 
811  return segment;
812 }
813 
814 
815 std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE::syncVia( VIA* aVia )
816 {
817  PCB_LAYER_ID top, bottom;
818  aVia->LayerPair( &top, &bottom );
819  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
820  aVia->GetPosition(),
821  LAYER_RANGE( top, bottom ),
822  aVia->GetWidth(),
823  aVia->GetDrillValue(),
824  aVia->GetNetCode(),
825  aVia->GetViaType() )
826  );
827 
828  via->SetParent( aVia );
829 
830  if( aVia->IsLocked() )
831  via->Mark( PNS::MK_LOCKED );
832 
833  return via;
834 }
835 
836 
838 {
839  SHAPE_POLY_SET poly;
840 
841  // TODO handle no-via restriction
842  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
843  return false;
844 
845  // Some intersecting zones, despite being on the same layer with the same net, cannot be
846  // merged due to other parameters such as fillet radius. The copper pour will end up
847  // effectively merged though, so we want to keep the corners of such intersections sharp.
848  std::set<VECTOR2I> colinearCorners;
849  aZone->GetColinearCorners( m_board, colinearCorners );
850 
851  aZone->BuildSmoothedPoly( poly, &colinearCorners );
852  poly.CacheTriangulation();
853 
854  if( !poly.IsTriangulationUpToDate() )
855  {
856  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
857  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
858  dlg.ShowDetailedText(
859  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
860  "Please verify it is not a self-intersecting polygon." ),
861  aZone->GetSelectMenuText( MILLIMETRES ) ) );
862  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
863  dlg.ShowModal();
864 
865  return false;
866  }
867 
868  LSET layers = aZone->GetLayerSet();
869 
870  for( int layer = F_Cu; layer <= B_Cu; layer++ )
871  {
872  if ( ! layers[layer] )
873  continue;
874 
875  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
876  {
877  auto tri = poly.TriangulatedPolygon( outline );
878 
879  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
880  {
881  VECTOR2I a, b, c;
882  tri->GetTriangle( i, a, b, c );
883  auto triShape = new SHAPE_SIMPLE;
884 
885  triShape->Append( a );
886  triShape->Append( b );
887  triShape->Append( c );
888 
889  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
890 
891  solid->SetLayer( layer );
892  solid->SetNet( -1 );
893  solid->SetParent( aZone );
894  solid->SetShape( triShape );
895  solid->SetRoutable( false );
896 
897  aWorld->Add( std::move( solid ) );
898  }
899  }
900  }
901 
902  return true;
903 }
904 
905 
907 {
908  if( !IsCopperLayer( aLayer ) )
909  return false;
910 
911  int textWidth = aText->GetThickness();
912  std::vector<wxPoint> textShape;
913 
914  aText->TransformTextShapeToSegmentList( textShape );
915 
916  if( textShape.size() < 2 )
917  return false;
918 
919  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
920  {
921  VECTOR2I start( textShape[jj] );
922  VECTOR2I end( textShape[jj+1] );
923  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
924 
925  solid->SetLayer( aLayer );
926  solid->SetNet( -1 );
927  solid->SetParent( nullptr );
928  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
929  solid->SetRoutable( false );
930 
931  aWorld->Add( std::move( solid ) );
932  }
933 
934  return true;
935 
936  /* A coarser (but faster) method:
937  *
938  SHAPE_POLY_SET outline;
939  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
940 
941  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
942 
943  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
944  shape->Append( *iter );
945 
946  solid->SetShape( shape );
947 
948  solid->SetLayer( aLayer );
949  solid->SetNet( -1 );
950  solid->SetParent( nullptr );
951  solid->SetRoutable( false );
952  aWorld->Add( std::move( solid ) );
953  return true;
954  */
955 }
956 
957 
959 {
960  std::vector<SHAPE_SEGMENT*> segs;
961 
962  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
963  return false;
964 
965  switch( aItem->GetShape() )
966  {
967  case S_ARC:
968  {
969  SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), aItem->GetAngle() / 10.0 );
970  auto l = arc.ConvertToPolyline();
971 
972  for( int i = 0; i < l.SegmentCount(); i++ )
973  {
974  SHAPE_SEGMENT* seg = new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() );
975  segs.push_back( seg );
976  }
977 
978  break;
979  }
980 
981  case S_SEGMENT:
982  segs.push_back(
983  new SHAPE_SEGMENT( aItem->GetStart(), aItem->GetEnd(), aItem->GetWidth() ) );
984 
985  break;
986 
987  case S_CIRCLE:
988  {
989  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
990  SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
991  auto l = circle.ConvertToPolyline();
992 
993  for( int i = 0; i < l.SegmentCount(); i++ )
994  segs.push_back( new SHAPE_SEGMENT( l.CSegment( i ), aItem->GetWidth() ) );
995 
996  break;
997  }
998 
999  case S_CURVE:
1000  {
1001  aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
1002  auto pts = aItem->GetBezierPoints();
1003 
1004  for( size_t ii = 1; ii < pts.size(); ii++ )
1005  {
1006  segs.push_back( new SHAPE_SEGMENT(
1007  VECTOR2I( pts[ii - 1] ), VECTOR2I( pts[ii] ), aItem->GetWidth() ) );
1008  }
1009  break;
1010  }
1011 
1012  case S_POLYGON:
1013  if( !aItem->IsPolygonFilled() )
1014  {
1015  auto poly = aItem->BuildPolyPointsList();
1016  for( size_t ii = 1; ii < poly.size(); ii++ )
1017  {
1018  segs.push_back( new SHAPE_SEGMENT(
1019  VECTOR2I( poly[ii - 1] ), VECTOR2I( poly[ii] ), aItem->GetWidth() ) );
1020  }
1021 
1022  segs.push_back( new SHAPE_SEGMENT(
1023  VECTOR2I( poly.back() ), VECTOR2I( poly.front() ), aItem->GetWidth() ) );
1024  }
1025  break;
1026 
1027  default:
1028  break;
1029  }
1030 
1031  for( auto seg : segs )
1032  {
1033  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
1034 
1035  if( aItem->GetLayer() == Edge_Cuts )
1036  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
1037  else
1038  solid->SetLayer( aItem->GetLayer() );
1039 
1040  solid->SetNet( -1 );
1041  solid->SetParent( nullptr );
1042  solid->SetShape( seg );
1043  solid->SetRoutable( false );
1044 
1045  aWorld->Add( std::move( solid ) );
1046  }
1047 
1048  return true;
1049 }
1050 
1051 
1053 {
1054  m_board = aBoard;
1055  wxLogTrace( "PNS", "m_board = %p", m_board );
1056 }
1057 
1058 
1060 {
1061  if( !m_view )
1062  return false;
1063 
1064  for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
1065  if( m_view->IsLayerVisible( i ) )
1066  return true;
1067 
1068  return false;
1069 }
1070 
1071 
1073 {
1074  int worstPadClearance = 0;
1075 
1076  if( !m_board )
1077  {
1078  wxLogTrace( "PNS", "No board attached, aborting sync." );
1079  return;
1080  }
1081 
1082  for( auto gitem : m_board->Drawings() )
1083  {
1084  if ( gitem->Type() == PCB_LINE_T )
1085  {
1086  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
1087  }
1088  else if( gitem->Type() == PCB_TEXT_T )
1089  {
1090  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
1091  }
1092  }
1093 
1094  for( auto zone : m_board->Zones() )
1095  {
1096  syncZone( aWorld, zone );
1097  }
1098 
1099  for( auto module : m_board->Modules() )
1100  {
1101  for( auto pad : module->Pads() )
1102  {
1103  if( auto solid = syncPad( pad ) )
1104  aWorld->Add( std::move( solid ) );
1105 
1106  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
1107  }
1108 
1109  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
1110  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
1111 
1112  if( module->IsNetTie() )
1113  continue;
1114 
1115  for( auto mgitem : module->GraphicalItems() )
1116  {
1117  if( mgitem->Type() == PCB_MODULE_EDGE_T )
1118  {
1119  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
1120  }
1121  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
1122  {
1123  syncTextItem( aWorld, dynamic_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
1124  }
1125  }
1126  }
1127 
1128  for( auto t : m_board->Tracks() )
1129  {
1130  KICAD_T type = t->Type();
1131 
1132  if( type == PCB_TRACE_T )
1133  {
1134  if( auto segment = syncTrack( t ) )
1135  aWorld->Add( std::move( segment ) );
1136  }
1137  else if( type == PCB_VIA_T )
1138  {
1139  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1140  aWorld->Add( std::move( via ) );
1141  }
1142  }
1143 
1144  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1145 
1146  delete m_ruleResolver;
1148 
1149  aWorld->SetRuleResolver( m_ruleResolver );
1150  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1151 }
1152 
1153 
1155 {
1156  for( auto item : m_hiddenItems )
1157  m_view->SetVisible( item, true );
1158 
1159  m_hiddenItems.clear();
1160 
1161  if( m_previewItems )
1162  {
1165  }
1166 
1167  if( m_debugDecorator )
1169 }
1170 
1171 
1172 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance, bool aEdit )
1173 {
1174  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1175 
1176  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1177 
1178  if( aColor >= 0 )
1179  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1180 
1181  if( aClearance >= 0 )
1182  {
1183  pitem->SetClearance( aClearance );
1184 
1185  if( m_dispOptions )
1186  {
1188  {
1190  pitem->ShowTrackClearance( false );
1191  pitem->ShowViaClearance( false );
1192  break;
1195  pitem->ShowTrackClearance( true );
1196  pitem->ShowViaClearance( true );
1197  break;
1198 
1200  pitem->ShowTrackClearance( !aEdit );
1201  pitem->ShowViaClearance( !aEdit );
1202  break;
1203 
1205  pitem->ShowTrackClearance( !aEdit );
1206  pitem->ShowViaClearance( false );
1207  break;
1208  }
1209  }
1210  }
1211 
1212 
1213  m_previewItems->Add( pitem );
1215 }
1216 
1217 
1219 {
1220  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1221 
1222  if( parent )
1223  {
1224  if( m_view->IsVisible( parent ) )
1225  m_hiddenItems.insert( parent );
1226 
1227  m_view->SetVisible( parent, false );
1228  m_view->Update( parent, KIGFX::APPEARANCE );
1229  }
1230 }
1231 
1232 
1234 {
1235  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1236 
1237  if( parent )
1238  {
1239  m_commit->Remove( parent );
1240  }
1241 }
1242 
1243 
1245 {
1246  BOARD_CONNECTED_ITEM* newBI = NULL;
1247 
1248  switch( aItem->Kind() )
1249  {
1250  case PNS::ITEM::SEGMENT_T:
1251  {
1252  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1253  TRACK* track = new TRACK( m_board );
1254  const SEG& s = seg->Seg();
1255  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1256  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1257  track->SetWidth( seg->Width() );
1258  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1259  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1260  newBI = track;
1261  break;
1262  }
1263 
1264  case PNS::ITEM::VIA_T:
1265  {
1266  VIA* via_board = new VIA( m_board );
1267  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1268  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1269  via_board->SetWidth( via->Diameter() );
1270  via_board->SetDrill( via->Drill() );
1271  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1272  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1273  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1274  ToLAYER_ID( via->Layers().End() ) );
1275  newBI = via_board;
1276  break;
1277  }
1278 
1279  default:
1280  break;
1281  }
1282 
1283  if( newBI )
1284  {
1285  aItem->SetParent( newBI );
1286  newBI->ClearFlags();
1287 
1288  m_commit->Add( newBI );
1289  }
1290 }
1291 
1292 
1294 {
1295  EraseView();
1296  m_commit->Push( _( "Added a track" ) );
1297  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1298 }
1299 
1300 
1302 {
1303  wxLogTrace( "PNS", "SetView %p", aView );
1304 
1305  if( m_previewItems )
1306  {
1308  delete m_previewItems;
1309  }
1310 
1311  m_view = aView;
1315 
1316  delete m_debugDecorator;
1319 }
1320 
1321 
1322 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1323 {
1324  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1325 }
1326 
1327 
1329 {
1330  return m_ruleResolver;
1331 }
1332 
1333 
1335 {
1336  m_router = aRouter;
1337 }
1338 
1339 
1341 {
1342  m_tool = aTool;
1343  m_commit.reset( new BOARD_COMMIT( m_tool ) );
1344 }
1345 
1347 {
1348  m_dispOptions = aDispOptions;
1349 }
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
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:77
void SetHostTool(PCB_TOOL_BASE *aTool)
Class ITEM.
Definition: pns_item.h:53
int localPadClearance(const PNS::ITEM *aItem) const
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
int holeRadius(const PNS::ITEM *aItem) const
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
Definition: pns_item.h:145
void SetView(KIGFX::VIEW *aView)
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox
Definition: confirm.cpp:53
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:140
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:347
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:320
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:932
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
extended_type SquaredEuclideanNorm() const
Function Squared Euclidean Norm computes the squared euclidean norm of the vector,...
Definition: vector2d.h:299
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
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) override
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:206
void ShowTrackClearance(bool aEnabled)
virtual VECTOR2I Centre() const
Function Centre()
Definition: shape.h:151
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:166
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:184
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:99
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:429
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
VECTOR2I::extended_type ecoord
Definition: pns_item.cpp:26
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:160
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:246
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
void GetColinearCorners(BOARD *aBoard, std::set< VECTOR2I > &colinearCorners)
Some intersecting zones, despite being on the same layer with the same net, cannot be merged due to o...
void SetParent(BOARD_CONNECTED_ITEM *aParent)
Definition: pns_item.h:144
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:120
VIATYPE_T ViaType() const
Definition: pns_via.h:110
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:197
int m_HoleToHoleMin
Min width of peninsula between two drilled holes.
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:1526
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
virtual const SHAPE * Shape() const
Function Shape()
Definition: pns_item.h:213
int Net() const
Definition: pns_item.h:148
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:293
virtual int DpCoupledNet(int aNet) override
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:412
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:426
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:559
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:346
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
bool SetNetCode(int aNetCode, bool aNoAssert=false)
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:1540
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:319
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
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:385
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:406
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
const wxSize & GetDrillSize() const
Definition: class_pad.h:290
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:358
void AddItem(PNS::ITEM *aItem) override
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:354
void SetView(KIGFX::VIEW *aView)
int matchDpSuffix(const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
currently selected items overlay
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
PCB_TOOL_BASE * m_tool
VECTOR2I::extended_type ecoord
const wxPoint & GetEnd() const
Definition: class_track.h:106
bool GetDoNotAllowTracks() const
Definition: class_zone.h:624
int ShowModal() override
Definition: confirm.cpp:95
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:266
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1486
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
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:284
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:131
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:145
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:590
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
Definition: pns_item.h:150
virtual bool CollideHoles(const PNS::ITEM *aA, const PNS::ITEM *aB, bool aNeedMTV, VECTOR2I *aMTV) const override
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
#define min(a, b)
Definition: auxiliary.h:85
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
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