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-2020 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_module.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/shape_simple.h>
50 
51 #include <memory>
52 
53 #include <advanced_config.h>
54 
55 #include "tools/pcb_tool_base.h"
56 
57 #include "pns_kicad_iface.h"
58 
59 #include "pns_arc.h"
60 #include "pns_routing_settings.h"
61 #include "pns_item.h"
62 #include "pns_solid.h"
63 #include "pns_segment.h"
64 #include "pns_node.h"
65 #include "pns_topology.h"
66 #include "pns_router.h"
67 #include "pns_debug_decorator.h"
68 #include "router_preview_item.h"
69 
71 
73 {
74 public:
75  PNS_PCBNEW_RULE_RESOLVER( BOARD* aBoard, PNS::ROUTER_IFACE* aRouterIface );
76  virtual ~PNS_PCBNEW_RULE_RESOLVER();
77 
78  virtual bool CollideHoles( const PNS::ITEM* aA, const PNS::ITEM* aB,
79  bool aNeedMTV, VECTOR2I* aMTV ) const override;
80 
81  virtual int Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const override;
82  virtual int Clearance( int aNetCode ) const override;
83  virtual int DpCoupledNet( int aNet ) override;
84  virtual int DpNetPolarity( int aNet ) override;
85  virtual bool DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN ) override;
86 
87  virtual wxString NetName( int aNet ) override;
88 
89 private:
91  {
94  int clearance;
95  };
96 
97  int holeRadius( const PNS::ITEM* aItem ) const;
98  int localPadClearance( const PNS::ITEM* aItem ) const;
99  int matchDpSuffix( const wxString& aNetName, wxString& aComplementNet, wxString& aBaseDpName );
100 
103 
104  std::vector<CLEARANCE_ENT> m_netClearanceCache;
105  std::unordered_map<const D_PAD*, int> m_localClearanceCache;
107 };
108 
109 
111  m_routerIface( aRouterIface ),
112  m_board( aBoard )
113 {
115 
116  // Build clearance cache for net classes
117  for( unsigned int i = 0; i < m_board->GetNetCount(); i++ )
118  {
119  NETINFO_ITEM* ni = m_board->FindNet( i );
120 
121  if( ni == NULL )
122  continue;
123 
124  CLEARANCE_ENT ent;
125  ent.coupledNet = DpCoupledNet( i );
126 
127  wxString netClassName = ni->GetClassName();
128  NETCLASSPTR nc = m_board->GetDesignSettings().GetNetClasses().Find( netClassName );
129 
130  int clearance = nc->GetClearance();
131  ent.clearance = clearance;
132  ent.dpClearance = nc->GetDiffPairGap();
133  m_netClearanceCache[i] = ent;
134 
135  wxLogTrace( "PNS", "Add net %u netclass %s clearance %d Diff Pair clearance %d",
136  i, netClassName.mb_str(), clearance, ent.dpClearance );
137  }
138 
139  // Build clearance cache for pads
140  for( auto mod : m_board->Modules() )
141  {
142  auto moduleClearance = mod->GetLocalClearance();
143 
144  for( auto pad : mod->Pads() )
145  {
146  int padClearance = pad->GetLocalClearance();
147 
148  if( padClearance > 0 )
149  m_localClearanceCache[ pad ] = padClearance;
150 
151  else if( moduleClearance > 0 )
152  m_localClearanceCache[ pad ] = moduleClearance;
153  }
154  }
155 
156  auto defaultRule = m_board->GetDesignSettings().GetNetClasses().Find ("Default");
157 
158  if( defaultRule )
159  {
160  m_defaultClearance = defaultRule->GetClearance();
161  }
162  else
163  {
165  }
166 }
167 
168 
170 {
171 }
172 
173 
175 {
176  if( aItem->Kind() == PNS::ITEM::SOLID_T )
177  {
178  const D_PAD* pad = dynamic_cast<const D_PAD*>( aItem->Parent() );
179 
180  if( pad && pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
181  return pad->GetDrillSize().x / 2;
182  }
183  else if( aItem->Kind() == PNS::ITEM::VIA_T )
184  {
185  const ::VIA* via = dynamic_cast<const ::VIA*>( aItem->Parent() );
186 
187  if( via )
188  return via->GetDrillValue() / 2;
189  }
190 
191  return 0;
192 }
193 
194 
196  bool aNeedMTV, VECTOR2I* aMTV ) const
197 {
198  VECTOR2I pos_a = aA->Shape()->Centre();
199  VECTOR2I pos_b = aB->Shape()->Centre();
200 
201  // Holes with identical locations are allowable
202  if( pos_a == pos_b )
203  return false;
204 
205  int radius_a = holeRadius( aA );
206  int radius_b = holeRadius( aB );
207 
208  // Do both objects have holes?
209  if( radius_a > 0 && radius_b > 0 )
210  {
211  int holeToHoleMin = m_board->GetDesignSettings().m_HoleToHoleMin;
212 
213  ecoord min_dist = holeToHoleMin + radius_a + radius_b;
214  ecoord min_dist_sq = min_dist * min_dist;
215 
216  const VECTOR2I delta = pos_b - pos_a;
217 
218  ecoord dist_sq = delta.SquaredEuclideanNorm();
219 
220  if( dist_sq == 0 || dist_sq < min_dist_sq )
221  {
222  if( aNeedMTV )
223  *aMTV = delta.Resize( min_dist - sqrt( dist_sq ) + 3 ); // fixme: apparent rounding error
224 
225  return true;
226  }
227  }
228 
229  return false;
230 }
231 
232 
234 {
235  if( !aItem->Parent() || aItem->Parent()->Type() != PCB_PAD_T )
236  return 0;
237 
238  const D_PAD* pad = static_cast<D_PAD*>( aItem->Parent() );
239 
240  auto i = m_localClearanceCache.find( pad );
241 
242  if( i == m_localClearanceCache.end() )
243  return 0;
244 
245  return i->second;
246 }
247 
248 
249 int PNS_PCBNEW_RULE_RESOLVER::Clearance( const PNS::ITEM* aA, const PNS::ITEM* aB ) const
250 {
251  int net_a = aA->Net();
252  int cl_a = Clearance( net_a );
253  int net_b = aB->Net();
254  int cl_b = Clearance( net_b );
255 
256  // Pad clearance is 0 if the ITEM* is not a pad
257  int pad_a = localPadClearance( aA );
258  int pad_b = localPadClearance( aB );
259 
260  if( pad_a > 0 )
261  cl_a = pad_a;
262 
263  if( pad_b > 0 )
264  cl_b = pad_b;
265 
266  return std::max( cl_a, cl_b );
267 }
268 
269 
270 int PNS_PCBNEW_RULE_RESOLVER::Clearance( int aNetCode ) const
271 {
272  if( aNetCode == 0 )
273  {
274  return m_defaultClearance;
275  }
276  else if( aNetCode > 0 && aNetCode < (int) m_netClearanceCache.size() )
277  {
278  return m_netClearanceCache[aNetCode].clearance;
279  }
280  else
281  {
282  wxFAIL_MSG( "PNS_PCBNEW_RULE_RESOLVER::Clearance: net not found in clearance cache." );
283  return m_defaultClearance;
284  }
285 }
286 
287 
288 int PNS_PCBNEW_RULE_RESOLVER::matchDpSuffix( const wxString& aNetName, wxString& aComplementNet,
289  wxString& aBaseDpName )
290 {
291  int rv = 0;
292 
293  if( aNetName.EndsWith( "+" ) )
294  {
295  aComplementNet = "-";
296  rv = 1;
297  }
298  else if( aNetName.EndsWith( "P" ) )
299  {
300  aComplementNet = "N";
301  rv = 1;
302  }
303  else if( aNetName.EndsWith( "-" ) )
304  {
305  aComplementNet = "+";
306  rv = -1;
307  }
308  else if( aNetName.EndsWith( "N" ) )
309  {
310  aComplementNet = "P";
311  rv = -1;
312  }
313  // Match P followed by 2 digits
314  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "P" )
315  {
316  aComplementNet = "N" + aNetName.Right( 2 );
317  rv = 1;
318  }
319  // Match P followed by 1 digit
320  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "P" )
321  {
322  aComplementNet = "N" + aNetName.Right( 1 );
323  rv = 1;
324  }
325  // Match N followed by 2 digits
326  else if( aNetName.Right( 2 ).IsNumber() && aNetName.Right( 3 ).Left( 1 ) == "N" )
327  {
328  aComplementNet = "P" + aNetName.Right( 2 );
329  rv = -1;
330  }
331  // Match N followed by 1 digit
332  else if( aNetName.Right( 1 ).IsNumber() && aNetName.Right( 2 ).Left( 1 ) == "N" )
333  {
334  aComplementNet = "P" + aNetName.Right( 1 );
335  rv = -1;
336  }
337  if( rv != 0 )
338  {
339  aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
340  aComplementNet = aBaseDpName + aComplementNet;
341  }
342 
343  return rv;
344 }
345 
346 
348 {
349  wxString refName = m_board->FindNet( aNet )->GetNetname();
350  wxString dummy, coupledNetName;
351 
352  if( matchDpSuffix( refName, coupledNetName, dummy ) )
353  {
354  NETINFO_ITEM* net = m_board->FindNet( coupledNetName );
355 
356  if( !net )
357  return -1;
358 
359  return net->GetNet();
360  }
361 
362  return -1;
363 }
364 
365 
367 {
368  return m_board->FindNet( aNet )->GetNetname();
369 }
370 
371 
373 {
374  wxString refName = m_board->FindNet( aNet )->GetNetname();
375  wxString dummy1, dummy2;
376 
377  return matchDpSuffix( refName, dummy1, dummy2 );
378 }
379 
380 
381 bool PNS_PCBNEW_RULE_RESOLVER::DpNetPair( PNS::ITEM* aItem, int& aNetP, int& aNetN )
382 {
383  if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
384  return false;
385 
386  wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
387  wxString netNameN, netNameCoupled, netNameBase;
388 
389  int r = matchDpSuffix( netNameP, netNameCoupled, netNameBase );
390 
391  if( r == 0 )
392  return false;
393  else if( r == 1 )
394  {
395  netNameN = netNameCoupled;
396  }
397  else
398  {
399  netNameN = netNameP;
400  netNameP = netNameCoupled;
401  }
402 
403 // wxLogTrace( "PNS","p %s n %s base %s\n", (const char *)netNameP.c_str(), (const char *)netNameN.c_str(), (const char *)netNameBase.c_str() );
404 
405  NETINFO_ITEM* netInfoP = m_board->FindNet( netNameP );
406  NETINFO_ITEM* netInfoN = m_board->FindNet( netNameN );
407 
408  //wxLogTrace( "PNS","ip %p in %p\n", netInfoP, netInfoN);
409 
410  if( !netInfoP || !netInfoN )
411  return false;
412 
413  aNetP = netInfoP->GetNet();
414  aNetN = netInfoN->GetNet();
415 
416  return true;
417 }
418 
419 
421 {
422 public:
424  m_view( NULL ), m_items( NULL )
425  {
426  SetView( aView );
427  }
428 
430  {
431  Clear();
432  delete m_items;
433  }
434 
435  void SetView( KIGFX::VIEW* aView )
436  {
437  Clear();
438  delete m_items;
439  m_items = NULL;
440  m_view = aView;
441 
442  if( m_view == NULL )
443  return;
444 
447  m_view->Add( m_items );
448  }
449 
450  void AddPoint( VECTOR2I aP, int aColor, const std::string aName = "") override
451  {
453 
454  l.Append( aP - VECTOR2I( -50000, -50000 ) );
455  l.Append( aP + VECTOR2I( -50000, -50000 ) );
456 
457  AddLine( l, aColor, 10000 );
458 
459  l.Clear();
460  l.Append( aP - VECTOR2I( 50000, -50000 ) );
461  l.Append( aP + VECTOR2I( 50000, -50000 ) );
462 
463  AddLine( l, aColor, 10000 );
464  }
465 
466  void AddBox( BOX2I aB, int aColor, const std::string aName = "" ) override
467  {
469 
470  VECTOR2I o = aB.GetOrigin();
471  VECTOR2I s = aB.GetSize();
472 
473  l.Append( o );
474  l.Append( o.x + s.x, o.y );
475  l.Append( o.x + s.x, o.y + s.y );
476  l.Append( o.x, o.y + s.y );
477  l.Append( o );
478 
479  AddLine( l, aColor, 10000 );
480  }
481 
482  void AddSegment( SEG aS, int aColor, const std::string aName = "") override
483  {
485 
486  l.Append( aS.A );
487  l.Append( aS.B );
488 
489  AddLine( l, aColor, 10000 );
490  }
491 
492  void AddDirections( VECTOR2D aP, int aMask, int aColor, const std::string aName = "") override
493  {
494  BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );
495 
496  AddBox( b, aColor );
497  for( int i = 0; i < 8; i++ )
498  {
499  if( ( 1 << i ) & aMask )
500  {
501  VECTOR2I v = DIRECTION_45( ( DIRECTION_45::Directions ) i ).ToVector() * 100000;
502  AddSegment( SEG( aP, aP + v ), aColor );
503  }
504  }
505  }
506 
507  void AddLine( const SHAPE_LINE_CHAIN& aLine, int aType, int aWidth, const std::string aName = "" ) override
508  {
509  if( !m_view )
510  return;
511 
513 
514  pitem->Line( aLine, aWidth, aType );
515  m_items->Add( pitem ); // Should not be needed, as m_items has been passed as a parent group in alloc;
516  m_view->Update( m_items );
517  }
518 
519  void Clear() override
520  {
521  if( m_view && m_items )
522  {
523  m_items->FreeItems();
524  m_view->Update( m_items );
525  }
526  }
527 
528 private:
531 };
532 
533 
535 {
536  return m_debugDecorator;
537 }
538 
539 
541 {
542  m_ruleResolver = nullptr;
543  m_board = nullptr;
544  m_world = nullptr;
545  m_debugDecorator = nullptr;
546 }
547 
548 
550 {
551  m_tool = nullptr;
552  m_view = nullptr;
553  m_previewItems = nullptr;
554  m_dispOptions = nullptr;
555 }
556 
557 
559 {
560 }
561 
562 
564 {
565  delete m_ruleResolver;
566  delete m_debugDecorator;
567 
568  if( m_previewItems )
569  {
571  delete m_previewItems;
572  }
573 }
574 
575 
576 std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( D_PAD* aPad )
577 {
578  LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
579 
580  // ignore non-copper pads
581  if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
582  return NULL;
583 
584  switch( aPad->GetAttribute() )
585  {
586  case PAD_ATTRIB_STANDARD:
587  break;
588 
589  case PAD_ATTRIB_SMD:
591  case PAD_ATTRIB_CONN:
592  {
593  LSET lmsk = aPad->GetLayerSet();
594  bool is_copper = false;
595 
596  for( int i = 0; i < MAX_CU_LAYERS; i++ )
597  {
598  if( lmsk[i] )
599  {
600  is_copper = true;
601 
603  layers = LAYER_RANGE( i );
604 
605  break;
606  }
607  }
608 
609  if( !is_copper )
610  return NULL;
611  }
612  break;
613 
614  default:
615  wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
616  return NULL;
617  }
618 
619  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
620 
621  solid->SetLayers( layers );
622  solid->SetNet( aPad->GetNetCode() );
623  solid->SetParent( aPad );
624  solid->SetPadToDie( aPad->GetPadToDieLength() );
625 
626  wxPoint wx_c = aPad->ShapePos();
627  wxSize wx_sz = aPad->GetSize();
628  wxPoint offset = aPad->GetOffset();
629 
630  VECTOR2I c( wx_c.x, wx_c.y );
631 
632  RotatePoint( &offset, aPad->GetOrientation() );
633 
634  solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
635  solid->SetOffset( VECTOR2I( offset.x, offset.y ) );
636 
637 
638  auto shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
639 
640  if( shapes && shapes->Size() == 1 )
641  {
642  solid->SetShape( shapes->Shapes()[0]->Clone() );
643  }
644  else
645  {
646  // JEY TODO:
647  // TOM TODO: move to SHAPE_COMPOUND...
648 
649  const std::shared_ptr<SHAPE_POLY_SET>& outline = aPad->GetEffectivePolygon();
650  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
651 
652  for( auto iter = outline->CIterate( 0 ); iter; iter++ )
653  shape->Append( *iter );
654 
655  solid->SetShape( shape );
656  }
657 
658  return solid;
659 }
660 
661 
662 std::unique_ptr<PNS::SEGMENT> PNS_KICAD_IFACE_BASE::syncTrack( TRACK* aTrack )
663 {
664  std::unique_ptr< PNS::SEGMENT > segment(
665  new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
666  );
667 
668  segment->SetWidth( aTrack->GetWidth() );
669  segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
670  segment->SetParent( aTrack );
671 
672  if( aTrack->IsLocked() )
673  segment->Mark( PNS::MK_LOCKED );
674 
675  return segment;
676 }
677 
678 
679 std::unique_ptr<PNS::ARC> PNS_KICAD_IFACE_BASE::syncArc( ARC* aArc )
680 {
681  std::unique_ptr< PNS::ARC > arc(
682  new PNS::ARC( SHAPE_ARC( aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(),
683  aArc->GetWidth() ), aArc->GetNetCode() )
684  );
685 
686  arc->SetLayers( LAYER_RANGE( aArc->GetLayer() ) );
687  arc->SetParent( aArc );
688 
689  if( aArc->IsLocked() )
690  arc->Mark( PNS::MK_LOCKED );
691 
692  return arc;
693 }
694 
695 
696 std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE_BASE::syncVia( VIA* aVia )
697 {
698  PCB_LAYER_ID top, bottom;
699  aVia->LayerPair( &top, &bottom );
700  std::unique_ptr<PNS::VIA> via( new PNS::VIA(
701  aVia->GetPosition(),
702  LAYER_RANGE( top, bottom ),
703  aVia->GetWidth(),
704  aVia->GetDrillValue(),
705  aVia->GetNetCode(),
706  aVia->GetViaType() )
707  );
708 
709  via->SetParent( aVia );
710 
711  if( aVia->IsLocked() )
712  via->Mark( PNS::MK_LOCKED );
713 
714  return via;
715 }
716 
717 
719 {
720  SHAPE_POLY_SET poly;
721 
722  // TODO handle no-via restriction
723  if( !aZone->GetIsKeepout() || !aZone->GetDoNotAllowTracks() )
724  return false;
725 
726  // Some intersecting zones, despite being on the same layer with the same net, cannot be
727  // merged due to other parameters such as fillet radius. The copper pour will end up
728  // effectively merged though, so we want to keep the corners of such intersections sharp.
729  std::set<VECTOR2I> colinearCorners;
730  aZone->GetColinearCorners( m_board, colinearCorners );
731 
732  aZone->BuildSmoothedPoly( poly, &colinearCorners );
733  poly.CacheTriangulation();
734 
735  if( !poly.IsTriangulationUpToDate() )
736  {
737  KIDIALOG dlg( nullptr, wxString::Format( _( "Malformed keep-out zone at (%d, %d)" ),
738  aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING );
739  dlg.ShowDetailedText(
740  wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n"
741  "Please verify it is not a self-intersecting polygon." ),
743  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
744  dlg.ShowModal();
745 
746  return false;
747  }
748 
749  LSET layers = aZone->GetLayerSet();
750 
751  for( int layer = F_Cu; layer <= B_Cu; layer++ )
752  {
753  if ( ! layers[layer] )
754  continue;
755 
756  for( int outline = 0; outline < poly.OutlineCount(); outline++ )
757  {
758  auto tri = poly.TriangulatedPolygon( outline );
759 
760  for( size_t i = 0; i < tri->GetTriangleCount(); i++)
761  {
762  VECTOR2I a, b, c;
763  tri->GetTriangle( i, a, b, c );
764  auto triShape = new SHAPE_SIMPLE;
765 
766  triShape->Append( a );
767  triShape->Append( b );
768  triShape->Append( c );
769 
770  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
771 
772  solid->SetLayer( layer );
773  solid->SetNet( -1 );
774  solid->SetParent( aZone );
775  solid->SetShape( triShape );
776  solid->SetRoutable( false );
777 
778  aWorld->Add( std::move( solid ) );
779  }
780  }
781  }
782 
783  return true;
784 }
785 
786 
788 {
789  if( !IsCopperLayer( aLayer ) )
790  return false;
791 
792  int textWidth = aText->GetEffectiveTextPenWidth();
793  std::vector<wxPoint> textShape;
794 
795  aText->TransformTextShapeToSegmentList( textShape );
796 
797  if( textShape.size() < 2 )
798  return false;
799 
800  for( size_t jj = 0; jj < textShape.size(); jj += 2 )
801  {
802  VECTOR2I start( textShape[jj] );
803  VECTOR2I end( textShape[jj+1] );
804  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
805 
806  solid->SetLayer( aLayer );
807  solid->SetNet( -1 );
808  solid->SetParent( nullptr );
809  solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
810  solid->SetRoutable( false );
811 
812  aWorld->Add( std::move( solid ) );
813  }
814 
815  return true;
816 
817  /* A coarser (but faster) method:
818  *
819  SHAPE_POLY_SET outline;
820  SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
821 
822  aText->TransformBoundingBoxWithClearanceToPolygon( &outline, 0 );
823 
824  for( auto iter = outline.CIterate( 0 ); iter; iter++ )
825  shape->Append( *iter );
826 
827  solid->SetShape( shape );
828 
829  solid->SetLayer( aLayer );
830  solid->SetNet( -1 );
831  solid->SetParent( nullptr );
832  solid->SetRoutable( false );
833  aWorld->Add( std::move( solid ) );
834  return true;
835  */
836 }
837 
838 
840 {
841  if( aItem->GetLayer() != Edge_Cuts && !IsCopperLayer( aItem->GetLayer() ) )
842  return false;
843 
844  // TODO: where do we handle filled polygons on copper layers?
845  if( aItem->GetShape() == S_POLYGON && aItem->IsPolygonFilled() )
846  return false;
847 
848  for( SHAPE* shape : aItem->MakeEffectiveShapes() )
849  {
850  std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
851 
852  if( aItem->GetLayer() == Edge_Cuts )
853  solid->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
854  else
855  solid->SetLayer( aItem->GetLayer() );
856 
857  solid->SetNet( -1 );
858  solid->SetParent( nullptr );
859  solid->SetShape( shape );
860  solid->SetRoutable( false );
861 
862  aWorld->Add( std::move( solid ) );
863  }
864 
865  return true;
866 }
867 
868 
870 {
871  m_board = aBoard;
872  wxLogTrace( "PNS", "m_board = %p", m_board );
873 }
874 
875 
877 {
878  if( !m_view )
879  return false;
880 
881  for( int i = aLayer.Start(); i <= aLayer.End(); i++ )
882  if( m_view->IsLayerVisible( i ) )
883  return true;
884 
885  return false;
886 }
887 
888 
890 {
891  // by default, all items are visible (new ones created by the router have parent == NULL as they have not been
892  // committed yet to the BOARD)
893  if( !m_view || !aItem->Parent() )
894  return true;
895 
896  auto item = aItem->Parent();
897  bool isOnVisibleLayer = true;
898 
900  {
901  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
902  int layers_count;
903  auto activeLayers = m_view->GetPainter()->GetSettings()->GetActiveLayers();
904 
905  isOnVisibleLayer = false;
906  item->ViewGetLayers( layers, layers_count );
907 
908  for( int i = 0; i < layers_count; ++i )
909  {
910  // Item is on at least one of the active layers
911  if( activeLayers.count( layers[i] ) > 0 )
912  {
913  isOnVisibleLayer = true;
914  break;
915  }
916  }
917  }
918 
919  if( m_view->IsVisible( item ) && isOnVisibleLayer
920  && item->ViewGetLOD( item->GetLayer(), m_view ) < m_view->GetScale() )
921  return true;
922 
923  // Items hidden in the router are not hidden on the board
924  if( m_hiddenItems.find( item ) != m_hiddenItems.end() )
925  return true;
926 
927  return false;
928 }
929 
930 
932 {
933  int worstPadClearance = 0;
934 
935  m_world = aWorld;
936 
937  if( !m_board )
938  {
939  wxLogTrace( "PNS", "No board attached, aborting sync." );
940  return;
941  }
942 
943  for( auto gitem : m_board->Drawings() )
944  {
945  if ( gitem->Type() == PCB_LINE_T )
946  {
947  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( gitem ) );
948  }
949  else if( gitem->Type() == PCB_TEXT_T )
950  {
951  syncTextItem( aWorld, static_cast<TEXTE_PCB*>( gitem ), gitem->GetLayer() );
952  }
953  }
954 
955  for( auto zone : m_board->Zones() )
956  {
957  syncZone( aWorld, zone );
958  }
959 
960  for( auto module : m_board->Modules() )
961  {
962  for( auto pad : module->Pads() )
963  {
964  if( auto solid = syncPad( pad ) )
965  aWorld->Add( std::move( solid ) );
966 
967  worstPadClearance = std::max( worstPadClearance, pad->GetLocalClearance() );
968  }
969 
970  syncTextItem( aWorld, &module->Reference(), module->Reference().GetLayer() );
971  syncTextItem( aWorld, &module->Value(), module->Value().GetLayer() );
972 
973  for( MODULE_ZONE_CONTAINER* zone : module->Zones() )
974  syncZone( aWorld, zone );
975 
976  if( module->IsNetTie() )
977  continue;
978 
979  for( auto mgitem : module->GraphicalItems() )
980  {
981  if( mgitem->Type() == PCB_MODULE_EDGE_T )
982  {
983  syncGraphicalItem( aWorld, static_cast<DRAWSEGMENT*>( mgitem ) );
984  }
985  else if( mgitem->Type() == PCB_MODULE_TEXT_T )
986  {
987  syncTextItem( aWorld, static_cast<TEXTE_MODULE*>( mgitem ), mgitem->GetLayer() );
988  }
989  }
990  }
991 
992  for( auto t : m_board->Tracks() )
993  {
994  KICAD_T type = t->Type();
995 
996  if( type == PCB_TRACE_T )
997  {
998  if( auto segment = syncTrack( t ) )
999  aWorld->Add( std::move( segment ) );
1000  }
1001  else if( type == PCB_ARC_T )
1002  {
1003  if( auto arc = syncArc( static_cast<ARC*>( t ) ) )
1004  aWorld->Add( std::move( arc ) );
1005  }
1006  else if( type == PCB_VIA_T )
1007  {
1008  if( auto via = syncVia( static_cast<VIA*>( t ) ) )
1009  aWorld->Add( std::move( via ) );
1010  }
1011  }
1012 
1013  int worstRuleClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
1014 
1015  delete m_ruleResolver;
1017 
1018  aWorld->SetRuleResolver( m_ruleResolver );
1019  aWorld->SetMaxClearance( 4 * std::max(worstPadClearance, worstRuleClearance ) );
1020 }
1021 
1022 
1024 {
1025  for( auto item : m_hiddenItems )
1026  m_view->SetVisible( item, true );
1027 
1028  m_hiddenItems.clear();
1029 
1030  if( m_previewItems )
1031  {
1034  }
1035 
1036  if( m_debugDecorator )
1038 }
1039 
1041 {
1042  m_debugDecorator = aDec;
1043 }
1044 
1045 void PNS_KICAD_IFACE::DisplayItem( const PNS::ITEM* aItem, int aColor, int aClearance, bool aEdit )
1046 {
1047  wxLogTrace( "PNS", "DisplayItem %p", aItem );
1048 
1049  ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( aItem, m_view );
1050 
1051  if( aColor >= 0 )
1052  pitem->SetColor( KIGFX::COLOR4D( aColor ) );
1053 
1054  if( aClearance >= 0 )
1055  {
1056  pitem->SetClearance( aClearance );
1057 
1059  {
1061  pitem->ShowTrackClearance( false );
1062  pitem->ShowViaClearance( false );
1063  break;
1066  pitem->ShowTrackClearance( true );
1067  pitem->ShowViaClearance( true );
1068  break;
1069 
1071  pitem->ShowTrackClearance( !aEdit );
1072  pitem->ShowViaClearance( !aEdit );
1073  break;
1074 
1076  pitem->ShowTrackClearance( !aEdit );
1077  pitem->ShowViaClearance( false );
1078  break;
1079  }
1080  }
1081 
1082 
1083  m_previewItems->Add( pitem );
1085 }
1086 
1087 
1089 {
1090  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1091 
1092  if( parent )
1093  {
1094  if( m_view->IsVisible( parent ) )
1095  m_hiddenItems.insert( parent );
1096 
1097  m_view->SetVisible( parent, false );
1098  m_view->Update( parent, KIGFX::APPEARANCE );
1099  }
1100 }
1101 
1102 
1104 {
1105 
1106 }
1107 
1108 
1110 {
1111  BOARD_CONNECTED_ITEM* parent = aItem->Parent();
1112 
1113  if ( aItem->OfKind(PNS::ITEM::SOLID_T) )
1114  {
1115  auto pad = static_cast<D_PAD*>( parent );
1116  auto pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1117 
1118  m_moduleOffsets[ pad ].p_old = pos;
1119  return;
1120  }
1121 
1122  if( parent )
1123  {
1124  m_commit->Remove( parent );
1125  }
1126 }
1127 
1128 
1130 {
1131 
1132 }
1133 
1134 
1136 {
1137  BOARD_CONNECTED_ITEM* newBI = NULL;
1138 
1139  switch( aItem->Kind() )
1140  {
1141  case PNS::ITEM::ARC_T:
1142  {
1143  auto arc = static_cast<PNS::ARC*>( aItem );
1144  ARC* new_arc = new ARC( m_board, static_cast<const SHAPE_ARC*>( arc->Shape() ) );
1145  new_arc->SetWidth( arc->Width() );
1146  new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
1147  new_arc->SetNetCode( std::max<int>( 0, arc->Net() ) );
1148  newBI = new_arc;
1149  break;
1150  }
1151 
1152  case PNS::ITEM::SEGMENT_T:
1153  {
1154  PNS::SEGMENT* seg = static_cast<PNS::SEGMENT*>( aItem );
1155  TRACK* track = new TRACK( m_board );
1156  const SEG& s = seg->Seg();
1157  track->SetStart( wxPoint( s.A.x, s.A.y ) );
1158  track->SetEnd( wxPoint( s.B.x, s.B.y ) );
1159  track->SetWidth( seg->Width() );
1160  track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
1161  track->SetNetCode( seg->Net() > 0 ? seg->Net() : 0 );
1162  newBI = track;
1163  break;
1164  }
1165 
1166  case PNS::ITEM::VIA_T:
1167  {
1168  VIA* via_board = new VIA( m_board );
1169  PNS::VIA* via = static_cast<PNS::VIA*>( aItem );
1170  via_board->SetPosition( wxPoint( via->Pos().x, via->Pos().y ) );
1171  via_board->SetWidth( via->Diameter() );
1172  via_board->SetDrill( via->Drill() );
1173  via_board->SetNetCode( via->Net() > 0 ? via->Net() : 0 );
1174  via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
1175  via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
1176  ToLAYER_ID( via->Layers().End() ) );
1177  newBI = via_board;
1178  break;
1179  }
1180 
1181  case PNS::ITEM::SOLID_T:
1182  {
1183  auto pad = static_cast<D_PAD*>( aItem->Parent() );
1184  auto pos = static_cast<PNS::SOLID*>( aItem )->Pos();
1185 
1186  m_moduleOffsets[ pad ].p_new = pos;
1187  return;
1188  }
1189 
1190  default:
1191  break;
1192  }
1193 
1194  if( newBI )
1195  {
1196  //newBI->SetLocalRatsnestVisible( m_dispOptions->m_ShowGlobalRatsnest );
1197  aItem->SetParent( newBI );
1198  newBI->ClearFlags();
1199 
1200  m_commit->Add( newBI );
1201  }
1202 }
1203 
1204 
1206 {
1207  std::set<MODULE*> processedMods;
1208 
1209  EraseView();
1210 
1211  for( auto mo : m_moduleOffsets )
1212  {
1213  auto offset = mo.second.p_new - mo.second.p_old;
1214  auto mod = mo.first->GetParent();
1215 
1216  VECTOR2I p_orig = mod->GetPosition();
1217  VECTOR2I p_new = p_orig + offset;
1218 
1219  if( processedMods.find( mod ) != processedMods.end() )
1220  continue;
1221 
1222  processedMods.insert( mod );
1223  m_commit->Modify( mod );
1224  mod->SetPosition( wxPoint( p_new.x, p_new.y ));
1225  }
1226 
1227  m_moduleOffsets.clear();
1228 
1229  m_commit->Push( _( "Interactive Router" ) );
1230  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1231 }
1232 
1233 
1235 {
1236  wxLogTrace( "PNS", "SetView %p", aView );
1237 
1238  if( m_previewItems )
1239  {
1241  delete m_previewItems;
1242  }
1243 
1244  m_view = aView;
1247 
1248  if(m_view)
1250 
1251  delete m_debugDecorator;
1252 
1253  auto dec = new PNS_PCBNEW_DEBUG_DECORATOR();
1254  m_debugDecorator = dec;
1255 
1256  if( ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
1257  dec->SetView( m_view );
1258 }
1259 
1260 
1261 void PNS_KICAD_IFACE::UpdateNet( int aNetCode )
1262 {
1263  wxLogTrace( "PNS", "Update-net %d", aNetCode );
1264 
1265 }
1266 
1268 {
1269  return m_ruleResolver;
1270 }
1271 
1272 
1274 {
1275  m_tool = aTool;
1276  m_commit = std::make_unique<BOARD_COMMIT>( m_tool );
1277 }
1278 
1280 {
1281  m_dispOptions = aDispOptions;
1282 }
bool IsLocked() const override
Function IsLocked.
Definition: class_track.h:138
Directions
Enum Directions Represents available directions - there are 8 of them, as on a rectilinear map (north...
Definition: direction45.h:46
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:712
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:77
void SetHostTool(PCB_TOOL_BASE *aTool)
std::unique_ptr< PNS::VIA > syncVia(VIA *aVia)
ITEM.
Definition: pns_item.h:53
int localPadClearance(const PNS::ITEM *aItem) const
void AddSegment(SEG aS, int aColor, const std::string aName="") override
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
void AddDirections(VECTOR2D aP, int aMask, int aColor, const std::string aName="") override
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
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...
SHAPE_SIMPLE.
Definition: shape_simple.h:42
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:146
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::RULE_RESOLVER * GetRuleResolver() override
std::unique_ptr< PNS::SOLID > syncPad(D_PAD *aPad)
NODE.
Definition: pns_node.h:145
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
TEXTE_PCB class definition.
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
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:417
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:114
int GetBiggestClearanceValue()
Function GetBiggestClearanceValue.
bool syncGraphicalItem(PNS::NODE *aWorld, DRAWSEGMENT *aItem)
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
const wxPoint & GetStart() const
Definition: class_track.h:118
STROKE_T GetShape() const
VIATYPE ViaType() const
Definition: pns_via.h:111
PNS::DEBUG_DECORATOR * m_debugDecorator
const VECTOR2I ToVector() const
Function ToVector()
Definition: direction45.h:269
int Width() const override
Definition: pns_segment.h:78
std::unordered_set< BOARD_CONNECTED_ITEM * > m_hiddenItems
void UpdateNet(int aNetCode) override
polygon (not yet used for tracks, but could be in microwave apps)
int GetPadToDieLength() const
Definition: class_pad.h:348
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
void SetClearance(int aClearance)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
bool SetNetCode(int aNetCode, bool aNoAssert)
Sets net using a net code.
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
extended_type SquaredEuclideanNorm() const
Function Squared Euclidean Norm computes the squared euclidean norm of the vector,...
Definition: vector2d.h:306
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
void SetDebugDecorator(PNS::DEBUG_DECORATOR *aDec)
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) override
No updates are required.
Definition: view_item.h:57
RULE_RESOLVER.
Definition: pns_node.h:57
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:83
void ShowTrackClearance(bool aEnabled)
virtual VECTOR2I Centre() const
Function Centre()
Definition: shape.h:173
PNS_PCBNEW_RULE_RESOLVER(BOARD *aBoard, PNS::ROUTER_IFACE *aRouterIface)
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void SetRuleResolver(RULE_RESOLVER *aFunc)
Assigns a clerance resolution function object
Definition: pns_node.h:171
void HideItem(PNS::ITEM *aItem) override
void AddBox(BOX2I aB, int aColor, const std::string aName="") override
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
const VECTOR2I & Pos() const
Definition: pns_via.h:100
PNS::ROUTER_IFACE * m_routerIface
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
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:338
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:706
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:157
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:111
int Start() const
Definition: pns_layerset.h:83
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: class_pad.cpp:216
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:165
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:113
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:284
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:145
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:121
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:197
LSET is a set of PCB_LAYER_IDs.
VIEW_ITEM class definition.
Footprint text class description.
const wxPoint & GetMid() const
Definition: class_track.h:298
#define NULL
unsigned GetNetCount() const
Function GetNetCount.
Definition: class_board.h:775
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:266
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1530
SHAPE_POLY_SET.
std::unique_ptr< BOARD_COMMIT > m_commit
virtual const SHAPE * Shape() const
Function Shape()
Definition: pns_item.h:214
int Net() const
Definition: pns_item.h:149
DIRECTION_45.
Definition: direction45.h:37
bool BuildSmoothedPoly(SHAPE_POLY_SET &aSmoothedPoly, std::set< VECTOR2I > *aPreserveCorners) const
Function GetSmoothedPoly returns a pointer to the corner-smoothed version of m_Poly.
const wxPoint & GetOffset() const
Definition: class_pad.h:233
VECTOR2I::extended_type ecoord
virtual int DpCoupledNet(int aNet) override
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:330
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:335
PNS::DEBUG_DECORATOR * GetDebugDecorator() override
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:583
void ShowViaClearance(bool aEnabled)
std::vector< CLEARANCE_ENT > m_netClearanceCache
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:231
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
NETCLASSES & GetNetClasses() const
KIGFX::VIEW_GROUP * m_previewItems
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.
SHAPE.
Definition: shape.h:74
bool syncZone(PNS::NODE *aWorld, ZONE_CONTAINER *aZone)
void SyncWorld(PNS::NODE *aWorld) override
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle),...
Definition: class_pad.cpp:225
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:1544
const std::set< unsigned int > GetActiveLayers() const
Function GetActiveLayers() Returns the set of currently active layers.
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
void SetColor(const KIGFX::COLOR4D &aColor)
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
void AddItem(PNS::ITEM *aItem) override
const PCB_DISPLAY_OPTIONS * m_dispOptions
void Commit() override
wxPoint GetPosition() const override
Definition: class_zone.cpp:202
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:713
void SetBoard(BOARD *aBoard)
void EraseView() override
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_zone.cpp:888
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Definition: seg.h:39
bool IsItemVisible(const PNS::ITEM *aItem) override
bool GetHighContrast() const
VECTOR2< T > Resize(T aNewLength) const
Function Resize returns a vector of the same direction, but length specified in aNewLength.
Definition: vector2d.h:392
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
std::unique_ptr< PNS::ARC > syncArc(ARC *aArc)
KIGFX::VIEW * m_view
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
int GetWidth() const
Definition: class_track.h:112
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:223
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
void AddPoint(VECTOR2I aP, int aColor, const std::string aName="") override
#define _(s)
Definition: 3d_actions.cpp:33
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:325
const wxSize & GetDrillSize() const
Definition: class_pad.h:230
VECTOR2I A
Definition: seg.h:47
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:133
wxPoint ShapePos() const
Definition: class_pad.cpp:563
void AddItem(PNS::ITEM *aItem) override
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:452
void SetView(KIGFX::VIEW *aView)
int matchDpSuffix(const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
VIATYPE GetViaType() const
Definition: class_track.h:378
currently selected items overlay
MODULE_ZONE_CONTAINER is the same item as ZONE_CONTAINER, but with a specific type id ZONE_CONTAINER ...
Definition: class_zone.h:957
PCB_TOOL_BASE * m_tool
VECTOR2I::extended_type ecoord
const wxPoint & GetEnd() const
Definition: class_track.h:115
bool GetDoNotAllowTracks() const
Definition: class_zone.h:716
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:123
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1490
void Clear()
Function Clear() Removes all points from the line chain.
void SetStart(const wxPoint &aStart)
Definition: class_track.h:117
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:350
const Vec & GetSize() const
Definition: box2.h:189
std::map< D_PAD *, OFFSET > m_moduleOffsets
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
virtual int Clearance(const PNS::ITEM *aA, const PNS::ITEM *aB) const override
const Vec & GetOrigin() const
Definition: box2.h:193
VIEW.
Definition: view.h:61
const wxSize & GetSize() const
Definition: class_pad.h:224
wxPoint GetPosition() const override
Definition: class_track.h:416
double GetScale() const
Function GetScale()
Definition: view.h:257
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
int Drill() const
Definition: pns_via.h:132
wxString GetClassName() const
Function GetClassName returns the class name.
Definition: netinfo.h:137
Push and Shove diff pair dimensions (gap) settings dialog.
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:379
static constexpr int Millimeter2iu(double mm)
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.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS *aDispOptions)
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:275
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:620
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:144
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
TRACKS & Tracks()
Definition: class_board.h:257
std::unique_ptr< PNS::SEGMENT > syncTrack(TRACK *aTrack)
LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
virtual bool CollideHoles(const PNS::ITEM *aA, const PNS::ITEM *aB, bool aNeedMTV, VECTOR2I *aMTV) const override
std::vector< SHAPE * > MakeEffectiveShapes() const
Makes a set of SHAPE objects representing the DRAWSEGMENT.
void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType, int aWidth, const std::string aName="") override
void RemoveItem(PNS::ITEM *aItem) override
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
VECTOR2I B
Definition: seg.h:48