KiCad PCB EDA Suite
class_board.cpp
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
10  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
11  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
12  *
13  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, you may find one here:
27  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
28  * or you may search the http://www.gnu.org website for the version 2 license,
29  * or you may write to the Free Software Foundation, Inc.,
30  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
31  */
32 
33 #include <algorithm>
34 #include <iterator>
35 #include <fctsys.h>
36 #include <common.h>
37 #include <kicad_string.h>
38 #include <pcb_base_frame.h>
39 #include <msgpanel.h>
40 #include <reporter.h>
41 #include <ratsnest_data.h>
42 #include <ratsnest_viewitem.h>
43 #include <ws_proxy_view_item.h>
44 #include <pcbnew.h>
45 #include <collectors.h>
46 #include <class_board.h>
47 #include <class_module.h>
48 #include <class_track.h>
49 #include <class_zone.h>
50 #include <class_marker_pcb.h>
51 #include <class_drawsegment.h>
52 #include <class_pcb_target.h>
54 #include <pgm_base.h>
55 #include <pcbnew_settings.h>
56 
62 {
63 public:
65  BOARD_ITEM( nullptr, NOT_USED )
66  {}
67 
68  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
69  {
70  return _( "(Deleted Item)" );
71  }
72 
73  wxString GetClass() const override
74  {
75  return wxT( "DELETED_BOARD_ITEM" );
76  }
77 
78  // pure virtuals:
79  const wxPoint GetPosition() const override { return wxPoint(); }
80  void SetPosition( const wxPoint& ) override {}
81  void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& aOffset ) override {}
82 
83 #if defined(DEBUG)
84  void Show( int , std::ostream& ) const override {}
85 #endif
86 };
87 
89 
90 
91 /* This is an odd place for this, but CvPcb won't link if it is
92  * in class_board_item.cpp like I first tried it.
93  */
95 
96 // Dummy settings used to initialize the board.
97 // This is needed because some APIs that make use of BOARD without the context of a frame or
98 // application, and so the BOARD needs to store a valid pointer to a PCBNEW_SETTINGS even if
99 // one hasn't been provided by the application.
101 
104  m_paper( PAGE_INFO::A4 ), m_NetInfo( this )
105 {
106  // we have not loaded a board yet, assume latest until then.
107  m_fileFormatVersionAtLoad = LEGACY_BOARD_FILE_VERSION;
108 
110 
111  m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the
112  // zone contour currently in progress
113 
114  BuildListOfNets(); // prepare pad and netlist containers.
115 
116  for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
117  {
118  m_Layer[layer].m_name = GetStandardLayerName( ToLAYER_ID( layer ) );
119 
120  if( IsCopperLayer( layer ) )
121  m_Layer[layer].m_type = LT_SIGNAL;
122  else
123  m_Layer[layer].m_type = LT_UNDEFINED;
124  }
125 
126  // Initialize default netclass.
127  NETCLASSPTR defaultClass = m_designSettings.GetDefault();
128  defaultClass->SetDescription( _( "This is the default net class." ) );
129  m_designSettings.SetCurrentNetClass( defaultClass->GetName() );
130 
131  // Set sensible initial values for custom track width & via size
136 
137  // Initialize ratsnest
138  m_connectivity.reset( new CONNECTIVITY_DATA() );
139 }
140 
141 
143 {
144  while( m_ZoneDescriptorList.size() )
145  {
146  ZONE_CONTAINER* area_to_remove = m_ZoneDescriptorList[0];
147  Delete( area_to_remove );
148  }
149 
150  // Clean up the owned elements
151  DeleteMARKERs();
153 
154  // Delete the modules
155  for( auto m : m_modules )
156  delete m;
157 
158  m_modules.clear();
159 
160  // Delete the tracks
161  for( auto t : m_tracks )
162  delete t;
163 
164  m_tracks.clear();
165 
166  // Delete the drawings
167  for (auto d : m_drawings )
168  delete d;
169 
170  m_drawings.clear();
171 
172  delete m_CurrentZoneContour;
174 }
175 
176 
178 {
179  GetConnectivity()->Build( this );
180 }
181 
182 
184 {
185  return ZeroOffset;
186 }
187 
188 
189 void BOARD::SetPosition( const wxPoint& aPos )
190 {
191  wxLogWarning( wxT( "This should not be called on the BOARD object") );
192 }
193 
194 
195 void BOARD::Move( const wxPoint& aMoveVector ) // overload
196 {
197  // @todo : anything like this elsewhere? maybe put into GENERAL_COLLECTOR class.
198  static const KICAD_T top_level_board_stuff[] = {
199  PCB_MARKER_T,
200  PCB_TEXT_T,
201  PCB_LINE_T,
203  PCB_TARGET_T,
204  PCB_VIA_T,
205  PCB_TRACE_T,
206  PCB_ARC_T,
207  // PCB_PAD_T, Can't be at board level
208  // PCB_MODULE_TEXT_T, Can't be at board level
209  PCB_MODULE_T,
211  EOT
212  };
213 
214  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
215  {
216  BOARD_ITEM* brd_item = (BOARD_ITEM*) item;
217 
218  // aMoveVector was snapshotted, don't need "data".
219  brd_item->Move( aMoveVector );
220 
222  };
223 
224  Visit( inspector, NULL, top_level_board_stuff );
225 }
226 
227 
228 TRACKS BOARD::TracksInNet( int aNetCode )
229 {
230  TRACKS ret;
231 
232  INSPECTOR_FUNC inspector = [aNetCode,&ret] ( EDA_ITEM* item, void* testData )
233  {
234  TRACK* t = (TRACK*) item;
235 
236  if( t->GetNetCode() == aNetCode )
237  ret.push_back( t );
238 
240  };
241 
242  // visit this BOARD's TRACKs and VIAs with above TRACK INSPECTOR which
243  // appends all in aNetCode to ret.
244  Visit( inspector, NULL, GENERAL_COLLECTOR::Tracks );
245 
246  return ret;
247 }
248 
249 
250 bool BOARD::SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer )
251 {
252  if( unsigned( aIndex ) < arrayDim( m_Layer ) )
253  {
254  m_Layer[ aIndex ] = aLayer;
255  return true;
256  }
257 
258  return false;
259 }
260 
261 
262 const PCB_LAYER_ID BOARD::GetLayerID( const wxString& aLayerName ) const
263 {
264 
265  // Look for the BOARD specific copper layer names
266  for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
267  {
268  if ( IsCopperLayer( layer ) && ( m_Layer[ layer ].m_name == aLayerName ) )
269  {
270  return ToLAYER_ID( layer );
271  }
272  }
273 
274  // Otherwise fall back to the system standard layer names
275  for( LAYER_NUM layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
276  {
277  if( GetStandardLayerName( ToLAYER_ID( layer ) ) == aLayerName )
278  {
279  return ToLAYER_ID( layer );
280  }
281  }
282 
283  return UNDEFINED_LAYER;
284 }
285 
286 const wxString BOARD::GetLayerName( PCB_LAYER_ID aLayer ) const
287 {
288  // All layer names are stored in the BOARD.
289  if( IsLayerEnabled( aLayer ) )
290  {
291  // Standard names were set in BOARD::BOARD() but they may be
292  // over-ridden by BOARD::SetLayerName().
293  // For copper layers, return the actual copper layer name,
294  // otherwise return the Standard English layer name.
295  if( IsCopperLayer( aLayer ) )
296  return m_Layer[aLayer].m_name;
297  }
298 
299  return GetStandardLayerName( aLayer );
300 }
301 
302 bool BOARD::SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName )
303 {
304  if( !IsCopperLayer( aLayer ) )
305  return false;
306 
307  if( aLayerName == wxEmptyString )
308  return false;
309 
310  // no quote chars in the name allowed
311  if( aLayerName.Find( wxChar( '"' ) ) != wxNOT_FOUND )
312  return false;
313 
314  wxString nameTemp = aLayerName;
315 
316  // replace any spaces with underscores before we do any comparing
317  nameTemp.Replace( wxT( " " ), wxT( "_" ) );
318 
319  if( IsLayerEnabled( aLayer ) )
320  {
321  m_Layer[aLayer].m_name = nameTemp;
322  return true;
323  }
324 
325  return false;
326 }
327 
328 
330 {
331  if( !IsCopperLayer( aLayer ) )
332  return LT_SIGNAL;
333 
334  //@@IMB: The original test was broken due to the discontinuity
335  // in the layer sequence.
336  if( IsLayerEnabled( aLayer ) )
337  return m_Layer[aLayer].m_type;
338 
339  return LT_SIGNAL;
340 }
341 
342 
343 bool BOARD::SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType )
344 {
345  if( !IsCopperLayer( aLayer ) )
346  return false;
347 
348  //@@IMB: The original test was broken due to the discontinuity
349  // in the layer sequence.
350  if( IsLayerEnabled( aLayer ) )
351  {
352  m_Layer[aLayer].m_type = aLayerType;
353  return true;
354  }
355 
356  return false;
357 }
358 
359 
360 const char* LAYER::ShowType( LAYER_T aType )
361 {
362  const char* cp;
363 
364  switch( aType )
365  {
366  default:
367  case LT_SIGNAL:
368  cp = "signal";
369  break;
370 
371  case LT_POWER:
372  cp = "power";
373  break;
374 
375  case LT_MIXED:
376  cp = "mixed";
377  break;
378 
379  case LT_JUMPER:
380  cp = "jumper";
381  break;
382  }
383 
384  return cp;
385 }
386 
387 
388 LAYER_T LAYER::ParseType( const char* aType )
389 {
390  if( strcmp( aType, "signal" ) == 0 )
391  return LT_SIGNAL;
392  else if( strcmp( aType, "power" ) == 0 )
393  return LT_POWER;
394  else if( strcmp( aType, "mixed" ) == 0 )
395  return LT_MIXED;
396  else if( strcmp( aType, "jumper" ) == 0 )
397  return LT_JUMPER;
398  else
399  return LT_UNDEFINED;
400 }
401 
402 
404 {
406 }
407 
408 
409 void BOARD::SetCopperLayerCount( int aCount )
410 {
412 }
413 
414 
416 {
418 }
419 
420 
422 {
424 }
425 
426 
427 void BOARD::SetEnabledLayers( LSET aLayerSet )
428 {
429  m_designSettings.SetEnabledLayers( aLayerSet );
430 }
431 
432 
433 void BOARD::SetVisibleLayers( LSET aLayerSet )
434 {
435  m_designSettings.SetVisibleLayers( aLayerSet );
436 }
437 
438 
439 void BOARD::SetVisibleElements( int aMask )
440 {
441  // Call SetElementVisibility for each item
442  // to ensure specific calculations that can be needed by some items,
443  // just changing the visibility flags could be not sufficient.
445  {
446  int item_mask = 1 << GAL_LAYER_INDEX( ii );
447  SetElementVisibility( ii, aMask & item_mask );
448  }
449 }
450 
451 
453 {
454  SetVisibleLayers( LSET().set() );
455 
456  // Call SetElementVisibility for each item,
457  // to ensure specific calculations that can be needed by some items
459  SetElementVisibility( ii, true );
460 }
461 
462 
464 {
466 }
467 
468 
470 {
471  return m_designSettings.IsElementVisible( aLayer );
472 }
473 
474 
475 void BOARD::SetElementVisibility( GAL_LAYER_ID aLayer, bool isEnabled )
476 {
477  m_designSettings.SetElementVisibility( aLayer, isEnabled );
478 
479  switch( aLayer )
480  {
481  case LAYER_RATSNEST:
482  {
483  // because we have a tool to show/hide ratsnest relative to a pad or a module
484  // so the hide/show option is a per item selection
485 
486  for( auto track : Tracks() )
487  track->SetLocalRatsnestVisible( isEnabled );
488 
489  for( auto mod : Modules() )
490  {
491  for( auto pad : mod->Pads() )
492  pad->SetLocalRatsnestVisible( isEnabled );
493  }
494 
495  for( int i = 0; i<GetAreaCount(); i++ )
496  {
497  auto zone = GetArea( i );
498  zone->SetLocalRatsnestVisible( isEnabled );
499  }
500 
501  break;
502  }
503 
504  default:
505  ;
506  }
507 }
508 
509 
511 {
512  switch( aLayer )
513  {
514  case F_Cu:
515  return IsElementVisible( LAYER_MOD_FR );
516 
517  case B_Cu:
518  return IsElementVisible( LAYER_MOD_BK );
519 
520  default:
521  wxFAIL_MSG( wxT( "BOARD::IsModuleLayerVisible() param error: bad layer" ) );
522  return true;
523  }
524 }
525 
526 
527 void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
528 {
529  if( aBoardItem == NULL )
530  {
531  wxFAIL_MSG( wxT( "BOARD::Add() param error: aBoardItem NULL" ) );
532  return;
533  }
534 
535  switch( aBoardItem->Type() )
536  {
537  case PCB_NETINFO_T:
538  m_NetInfo.AppendNet( (NETINFO_ITEM*) aBoardItem );
539  break;
540 
541  // this one uses a vector
542  case PCB_MARKER_T:
543  m_markers.push_back( (MARKER_PCB*) aBoardItem );
544  break;
545 
546  // this one uses a vector
547  case PCB_ZONE_AREA_T:
548  m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem );
549  break;
550 
551  case PCB_TRACE_T:
552  case PCB_VIA_T:
553  case PCB_ARC_T:
554 
555  // N.B. This inserts a small memory leak as we lose the
556  if( !IsCopperLayer( aBoardItem->GetLayer() ) )
557  {
558  wxFAIL_MSG( wxT( "BOARD::Add() Cannot place Track on non-copper layer" ) );
559  return;
560  }
561 
562  if( aMode == ADD_MODE::APPEND )
563  m_tracks.push_back( static_cast<TRACK*>( aBoardItem ) );
564  else
565  m_tracks.push_front( static_cast<TRACK*>( aBoardItem ) );
566 
567  break;
568 
569  case PCB_MODULE_T:
570  if( aMode == ADD_MODE::APPEND )
571  m_modules.push_back( (MODULE*) aBoardItem );
572  else
573  m_modules.push_front( (MODULE*) aBoardItem );
574 
575  break;
576 
577  case PCB_DIMENSION_T:
578  case PCB_LINE_T:
579  case PCB_TEXT_T:
580  case PCB_TARGET_T:
581  if( aMode == ADD_MODE::APPEND )
582  m_drawings.push_back( aBoardItem );
583  else
584  m_drawings.push_front( aBoardItem );
585 
586  break;
587 
588  // other types may use linked list
589  default:
590  {
591  wxString msg;
592  msg.Printf( wxT( "BOARD::Add() needs work: BOARD_ITEM type (%d) not handled" ),
593  aBoardItem->Type() );
594  wxFAIL_MSG( msg );
595  return;
596  }
597  break;
598  }
599 
600  aBoardItem->SetParent( this );
601  aBoardItem->ClearEditFlags();
602  m_connectivity->Add( aBoardItem );
603 }
604 
605 
606 void BOARD::Remove( BOARD_ITEM* aBoardItem )
607 {
608  // find these calls and fix them! Don't send me no stinking' NULL.
609  wxASSERT( aBoardItem );
610 
611  switch( aBoardItem->Type() )
612  {
613  case PCB_NETINFO_T:
614  {
615  NETINFO_ITEM* item = (NETINFO_ITEM*) aBoardItem;
616  m_NetInfo.RemoveNet( item );
617  break;
618  }
619 
620  case PCB_MARKER_T:
621 
622  // find the item in the vector, then remove it
623  for( unsigned i = 0; i<m_markers.size(); ++i )
624  {
625  if( m_markers[i] == (MARKER_PCB*) aBoardItem )
626  {
627  m_markers.erase( m_markers.begin() + i );
628  break;
629  }
630  }
631 
632  break;
633 
634  case PCB_ZONE_AREA_T: // this one uses a vector
635  // find the item in the vector, then delete then erase it.
636  for( unsigned i = 0; i<m_ZoneDescriptorList.size(); ++i )
637  {
638  if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem )
639  {
640  m_ZoneDescriptorList.erase( m_ZoneDescriptorList.begin() + i );
641  break;
642  }
643  }
644  break;
645 
646  case PCB_MODULE_T:
647  m_modules.erase( std::remove_if( m_modules.begin(), m_modules.end(),
648  [aBoardItem]( BOARD_ITEM* aItem )
649  {
650  return aItem == aBoardItem;
651  } ) );
652  break;
653 
654  case PCB_TRACE_T:
655  case PCB_ARC_T:
656  case PCB_VIA_T:
657  m_tracks.erase( std::remove_if( m_tracks.begin(), m_tracks.end(),
658  [aBoardItem]( BOARD_ITEM* aItem )
659  {
660  return aItem == aBoardItem;
661  } ) );
662  break;
663 
664  case PCB_DIMENSION_T:
665  case PCB_LINE_T:
666  case PCB_TEXT_T:
667  case PCB_TARGET_T:
668  m_drawings.erase( std::remove_if( m_drawings.begin(), m_drawings.end(),
669  [aBoardItem](BOARD_ITEM* aItem)
670  {
671  return aItem == aBoardItem;
672  } ) );
673  break;
674 
675  // other types may use linked list
676  default:
677  wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
678  }
679 
680  m_connectivity->Remove( aBoardItem );
681 }
682 
683 
684 wxString BOARD::GetSelectMenuText( EDA_UNITS aUnits ) const
685 {
686  return wxString::Format( _( "PCB" ) );
687 }
688 
689 
691 {
692  // the vector does not know how to delete the MARKER_PCB, it holds pointers
693  for( MARKER_PCB* marker : m_markers )
694  delete marker;
695 
696  m_markers.clear();
697 }
698 
699 
701 {
702  // the vector does not know how to delete the ZONE Outlines, it holds pointers
703  for( ZONE_CONTAINER* zone : m_ZoneDescriptorList )
704  delete zone;
705 
706  m_ZoneDescriptorList.clear();
707 }
708 
709 
711 {
712  if( aID == niluuid )
713  return nullptr;
714 
715  for( TRACK* track : Tracks() )
716  if( track->m_Uuid == aID )
717  return track;
718 
719  for( MODULE* module : Modules() )
720  {
721  if( module->m_Uuid == aID )
722  return module;
723 
724  for( D_PAD* pad : module->Pads() )
725  if( pad->m_Uuid == aID )
726  return pad;
727 
728  if( module->Reference().m_Uuid == aID )
729  return &module->Reference();
730 
731  if( module->Value().m_Uuid == aID )
732  return &module->Value();
733 
734  for( BOARD_ITEM* drawing : module->GraphicalItems() )
735  if( drawing->m_Uuid == aID )
736  return drawing;
737  }
738 
739  for( ZONE_CONTAINER* zone : Zones() )
740  if( zone->m_Uuid == aID )
741  return zone;
742 
743  for( BOARD_ITEM* drawing : Drawings() )
744  if( drawing->m_Uuid == aID )
745  return drawing;
746 
747  for( MARKER_PCB* marker : m_markers )
748  if( marker->m_Uuid == aID )
749  return marker;
750 
751  // Not found; weak reference has been deleted.
752  if( !g_DeletedItem )
754 
755  return g_DeletedItem;
756 }
757 
758 
759 unsigned BOARD::GetNodesCount( int aNet )
760 {
761  unsigned retval = 0;
762  for( auto mod : Modules() )
763  {
764  for( auto pad : mod->Pads() )
765  {
766  if( ( aNet == -1 && pad->GetNetCode() > 0 ) || aNet == pad->GetNetCode() )
767  retval++;
768  }
769  }
770 
771  return retval;
772 }
773 
774 
776 {
777  return m_connectivity->GetUnconnectedCount();
778 }
779 
780 
781 EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
782 {
783  EDA_RECT area;
784  LSET visible = GetVisibleLayers();
785  bool showInvisibleText = IsElementVisible( LAYER_MOD_TEXT_INVISIBLE )
786  && PgmOrNull() && !PgmOrNull()->m_Printing;
787 
788  // Check segments, dimensions, texts, and fiducials
789  for( auto item : m_drawings )
790  {
791  if( aBoardEdgesOnly && ( item->GetLayer() != Edge_Cuts ) )
792  continue;
793 
794  if( ( item->GetLayerSet() & visible ).any() )
795  area.Merge( item->GetBoundingBox() );
796  }
797 
798  // Check modules
799  for( auto module : m_modules )
800  {
801  if( !( module->GetLayerSet() & visible ).any() )
802  continue;
803 
804  if( aBoardEdgesOnly )
805  {
806  for( const auto edge : module->GraphicalItems() )
807  {
808  if( edge->GetLayer() == Edge_Cuts )
809  area.Merge( edge->GetBoundingBox() );
810  }
811  }
812  else
813  {
814  area.Merge( module->GetBoundingBox( showInvisibleText ) );
815  }
816  }
817 
818  if( !aBoardEdgesOnly )
819  {
820  // Check tracks
821  for( auto track : m_tracks )
822  {
823  if( ( track->GetLayerSet() & visible ).any() )
824  area.Merge( track->GetBoundingBox() );
825  }
826 
827  // Check zones
828  for( auto aZone : m_ZoneDescriptorList )
829  {
830  if( ( aZone->GetLayerSet() & visible ).any() )
831  area.Merge( aZone->GetBoundingBox() );
832  }
833  }
834 
835  return area;
836 }
837 
838 
839 void BOARD::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
840 {
841  wxString txt;
842  int viasCount = 0;
843  int trackSegmentsCount = 0;
844 
845  for( auto item : m_tracks )
846  {
847  if( item->Type() == PCB_VIA_T )
848  viasCount++;
849  else
850  trackSegmentsCount++;
851  }
852 
853  txt.Printf( wxT( "%d" ), GetPadCount() );
854  aList.emplace_back( _( "Pads" ), txt, DARKGREEN );
855 
856  txt.Printf( wxT( "%d" ), viasCount );
857  aList.emplace_back( _( "Vias" ), txt, DARKGREEN );
858 
859  txt.Printf( wxT( "%d" ), trackSegmentsCount );
860  aList.emplace_back( _( "Track Segments" ), txt, DARKGREEN );
861 
862  txt.Printf( wxT( "%d" ), GetNodesCount() );
863  aList.emplace_back( _( "Nodes" ), txt, DARKCYAN );
864 
865  txt.Printf( wxT( "%d" ), m_NetInfo.GetNetCount() - 1 /* Don't include "No Net" in count */ );
866  aList.emplace_back( _( "Nets" ), txt, RED );
867 
868  txt.Printf( wxT( "%d" ), GetConnectivity()->GetUnconnectedCount() );
869  aList.emplace_back( _( "Unrouted" ), txt, BLUE );
870 }
871 
872 
873 SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
874 {
875  KICAD_T stype;
877  const KICAD_T* p = scanTypes;
878  bool done = false;
879 
880 #if 0 && defined(DEBUG)
881  std::cout << GetClass().mb_str() << ' ';
882 #endif
883 
884  while( !done )
885  {
886  stype = *p;
887 
888  switch( stype )
889  {
890  case PCB_T:
891  result = inspector( this, testData ); // inspect me
892  // skip over any types handled in the above call.
893  ++p;
894  break;
895 
896  /* Instances of the requested KICAD_T live in a list, either one
897  * that I manage, or that my modules manage. If it's a type managed
898  * by class MODULE, then simply pass it on to each module's
899  * MODULE::Visit() function by way of the
900  * IterateForward( m_Modules, ... ) call.
901  */
902 
903  case PCB_MODULE_T:
904  case PCB_PAD_T:
905  case PCB_MODULE_TEXT_T:
906  case PCB_MODULE_EDGE_T:
907 
908  // this calls MODULE::Visit() on each module.
909  result = IterateForward<MODULE*>( m_modules, inspector, testData, p );
910 
911  // skip over any types handled in the above call.
912  for( ; ; )
913  {
914  switch( stype = *++p )
915  {
916  case PCB_MODULE_T:
917  case PCB_PAD_T:
918  case PCB_MODULE_TEXT_T:
919  case PCB_MODULE_EDGE_T:
920  continue;
921 
922  default:
923  ;
924  }
925 
926  break;
927  }
928 
929  break;
930 
931  case PCB_LINE_T:
932  case PCB_TEXT_T:
933  case PCB_DIMENSION_T:
934  case PCB_TARGET_T:
935  result = IterateForward<BOARD_ITEM*>( m_drawings, inspector, testData, p );
936 
937  // skip over any types handled in the above call.
938  for( ; ; )
939  {
940  switch( stype = *++p )
941  {
942  case PCB_LINE_T:
943  case PCB_TEXT_T:
944  case PCB_DIMENSION_T:
945  case PCB_TARGET_T:
946  continue;
947 
948  default:
949  ;
950  }
951 
952  break;
953  }
954 
955  ;
956  break;
957 
958 #if 0 // both these are on same list, so we must scan it twice in order
959  // to get VIA priority, using new #else code below.
960  // But we are not using separate lists for TRACKs and VIA, because
961  // items are ordered (sorted) in the linked
962  // list by netcode AND by physical distance:
963  // when created, if a track or via is connected to an existing track or
964  // via, it is put in linked list after this existing track or via
965  // So usually, connected tracks or vias are grouped in this list
966  // So the algorithm (used in ratsnest computations) which computes the
967  // track connectivity is faster (more than 100 time regarding to
968  // a non ordered list) because when it searches for a connection, first
969  // it tests the near (near in term of linked list) 50 items
970  // from the current item (track or via) in test.
971  // Usually, because of this sort, a connected item (if exists) is
972  // found.
973  // If not found (and only in this case) an exhaustive (and time
974  // consuming) search is made, but this case is statistically rare.
975  case PCB_VIA_T:
976  case PCB_TRACE_T:
977  case PCB_ARC_T:
978  result = IterateForward( m_Track, inspector, testData, p );
979 
980  // skip over any types handled in the above call.
981  for( ; ; )
982  {
983  switch( stype = *++p )
984  {
985  case PCB_VIA_T:
986  case PCB_TRACE_T:
987  case PCB_ARC_T:
988  continue;
989 
990  default:
991  ;
992  }
993 
994  break;
995  }
996 
997  break;
998 
999 #else
1000  case PCB_VIA_T:
1001  result = IterateForward<TRACK*>( m_tracks, inspector, testData, p );
1002  ++p;
1003  break;
1004 
1005  case PCB_TRACE_T:
1006  case PCB_ARC_T:
1007  result = IterateForward<TRACK*>( m_tracks, inspector, testData, p );
1008  ++p;
1009  break;
1010 #endif
1011 
1012  case PCB_MARKER_T:
1013 
1014  // MARKER_PCBS are in the m_markers std::vector
1015  for( unsigned i = 0; i<m_markers.size(); ++i )
1016  {
1017  result = m_markers[i]->Visit( inspector, testData, p );
1018 
1019  if( result == SEARCH_RESULT::QUIT )
1020  break;
1021  }
1022 
1023  ++p;
1024  break;
1025 
1026  case PCB_ZONE_AREA_T:
1027 
1028  // PCB_ZONE_AREA_T are in the m_ZoneDescriptorList std::vector
1029  for( unsigned i = 0; i< m_ZoneDescriptorList.size(); ++i )
1030  {
1031  result = m_ZoneDescriptorList[i]->Visit( inspector, testData, p );
1032 
1033  if( result == SEARCH_RESULT::QUIT )
1034  break;
1035  }
1036 
1037  ++p;
1038  break;
1039 
1040  default: // catch EOT or ANY OTHER type here and return.
1041  done = true;
1042  break;
1043  }
1044 
1045  if( result == SEARCH_RESULT::QUIT )
1046  break;
1047  }
1048 
1049  return result;
1050 }
1051 
1052 
1053 NETINFO_ITEM* BOARD::FindNet( int aNetcode ) const
1054 {
1055  // the first valid netcode is 1 and the last is m_NetInfo.GetCount()-1.
1056  // zero is reserved for "no connection" and is not actually a net.
1057  // NULL is returned for non valid netcodes
1058 
1059  wxASSERT( m_NetInfo.GetNetCount() > 0 );
1060 
1061  if( aNetcode == NETINFO_LIST::UNCONNECTED && m_NetInfo.GetNetCount() == 0 )
1062  return NETINFO_LIST::OrphanedItem();
1063  else
1064  return m_NetInfo.GetNetItem( aNetcode );
1065 }
1066 
1067 
1068 NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
1069 {
1070  return m_NetInfo.GetNetItem( aNetname );
1071 }
1072 
1073 
1074 MODULE* BOARD::FindModuleByReference( const wxString& aReference ) const
1075 {
1076  MODULE* found = nullptr;
1077 
1078  // search only for MODULES
1079  static const KICAD_T scanTypes[] = { PCB_MODULE_T, EOT };
1080 
1081  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
1082  {
1083  MODULE* module = (MODULE*) item;
1084 
1085  if( aReference == module->GetReference() )
1086  {
1087  found = module;
1088  return SEARCH_RESULT::QUIT;
1089  }
1090 
1091  return SEARCH_RESULT::CONTINUE;
1092  };
1093 
1094  // visit this BOARD with the above inspector
1095  BOARD* nonconstMe = (BOARD*) this;
1096  nonconstMe->Visit( inspector, NULL, scanTypes );
1097 
1098  return found;
1099 }
1100 
1101 
1103 {
1104  for( MODULE* module : m_modules )
1105  {
1106  if( module->GetPath() == aPath )
1107  return module;
1108  }
1109 
1110  return nullptr;
1111 }
1112 
1113 
1114 // The pad count for each netcode, stored in a buffer for a fast access.
1115 // This is needed by the sort function sortNetsByNodes()
1116 static std::vector<int> padCountListByNet;
1117 
1118 // Sort nets by decreasing pad count.
1119 // For same pad count, sort by alphabetic names
1120 static bool sortNetsByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
1121 {
1122  int countA = padCountListByNet[a->GetNet()];
1123  int countB = padCountListByNet[b->GetNet()];
1124 
1125  if( countA == countB )
1126  return a->GetNetname() < b->GetNetname();
1127  else
1128  return countB < countA;
1129 }
1130 
1131 // Sort nets by alphabetic names
1132 static bool sortNetsByNames( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
1133 {
1134  return a->GetNetname() < b->GetNetname();
1135 }
1136 
1137 int BOARD::SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
1138 {
1139  if( m_NetInfo.GetNetCount() == 0 )
1140  return 0;
1141 
1142  // Build the list
1143  std::vector <NETINFO_ITEM*> netBuffer;
1144 
1145  netBuffer.reserve( m_NetInfo.GetNetCount() );
1146  int max_netcode = 0;
1147 
1148  for( NETINFO_ITEM* net : m_NetInfo )
1149  {
1150  auto netcode = net->GetNet();
1151 
1152  if( netcode > 0 && net->IsCurrent() )
1153  {
1154  netBuffer.push_back( net );
1155  max_netcode = std::max( netcode, max_netcode);
1156  }
1157  }
1158 
1159  // sort the list
1160  if( aSortbyPadsCount )
1161  {
1162  // Build the pad count by net:
1163  padCountListByNet.clear();
1164  std::vector<D_PAD*> pads = GetPads();
1165 
1166  padCountListByNet.assign( max_netcode + 1, 0 );
1167 
1168  for( D_PAD* pad : pads )
1169  {
1170  int netCode = pad->GetNetCode();
1171 
1172  if( netCode >= 0 )
1173  padCountListByNet[ netCode ]++;
1174  }
1175 
1176  sort( netBuffer.begin(), netBuffer.end(), sortNetsByNodes );
1177  }
1178  else
1179  {
1180  sort( netBuffer.begin(), netBuffer.end(), sortNetsByNames );
1181  }
1182 
1183  for( NETINFO_ITEM* net : netBuffer )
1184  aNames.Add( UnescapeString( net->GetNetname() ) );
1185 
1186  return netBuffer.size();
1187 }
1188 
1189 
1191  PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer, int aNetCode )
1192 {
1193  if( aEndLayer < 0 )
1194  aEndLayer = aStartLayer;
1195 
1196  if( aEndLayer < aStartLayer )
1197  std::swap( aEndLayer, aStartLayer );
1198 
1199  for( ZONE_CONTAINER* area : m_ZoneDescriptorList )
1200  {
1201  if( area->GetLayer() < aStartLayer || area->GetLayer() > aEndLayer )
1202  continue;
1203 
1204  // In locate functions we must skip tagged items with BUSY flag set.
1205  if( area->GetState( BUSY ) )
1206  continue;
1207 
1208  if( aNetCode >= 0 && area->GetNetCode() != aNetCode )
1209  continue;
1210 
1211  if( area->HitTestFilledArea( aRefPos ) )
1212  return area;
1213  }
1214 
1215  return NULL;
1216 }
1217 
1218 
1220 {
1221  int error_count = 0;
1222 
1223  for( int ii = 0; ii < GetAreaCount(); ii++ )
1224  {
1225  ZONE_CONTAINER* it = GetArea( ii );
1226 
1227  if( !it->IsOnCopperLayer() )
1228  {
1230  continue;
1231  }
1232 
1233  if( it->GetNetCode() != 0 ) // i.e. if this zone is connected to a net
1234  {
1235  const NETINFO_ITEM* net = it->GetNet();
1236 
1237  if( net )
1238  {
1239  it->SetNetCode( net->GetNet() );
1240  }
1241  else
1242  {
1243  error_count++;
1244 
1245  // keep Net Name and set m_NetCode to -1 : error flag.
1246  it->SetNetCode( -1 );
1247  }
1248  }
1249  }
1250 
1251  return error_count;
1252 }
1253 
1254 
1255 D_PAD* BOARD::GetPad( const wxPoint& aPosition, LSET aLayerSet )
1256 {
1257  if( !aLayerSet.any() )
1258  aLayerSet = LSET::AllCuMask();
1259 
1260  for( auto module : m_modules )
1261  {
1262  D_PAD* pad = NULL;
1263 
1264  if( module->HitTest( aPosition ) )
1265  pad = module->GetPad( aPosition, aLayerSet );
1266 
1267  if( pad )
1268  return pad;
1269  }
1270 
1271  return NULL;
1272 }
1273 
1274 
1275 D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
1276 {
1277  const wxPoint& aPosition = aTrace->GetEndPoint( aEndPoint );
1278 
1279  LSET lset( aTrace->GetLayer() );
1280 
1281  return GetPad( aPosition, lset );
1282 }
1283 
1284 
1285 D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, LSET aLayerSet )
1286 {
1287  for( auto mod : Modules() )
1288  {
1289  for ( auto pad : mod->Pads() )
1290  {
1291  if( pad->GetPosition() != aPosition )
1292  continue;
1293 
1294  // Pad found, it must be on the correct layer
1295  if( ( pad->GetLayerSet() & aLayerSet ).any() )
1296  return pad;
1297  }
1298  }
1299 
1300  return nullptr;
1301 }
1302 
1303 
1304 D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerSet )
1305 {
1306  // Search aPadList for aPosition
1307  // aPadList is sorted by X then Y values, and a fast binary search is used
1308  int idxmax = aPadList.size()-1;
1309 
1310  int delta = aPadList.size();
1311 
1312  int idx = 0; // Starting index is the beginning of list
1313 
1314  while( delta )
1315  {
1316  // Calculate half size of remaining interval to test.
1317  // Ensure the computed value is not truncated (too small)
1318  if( (delta & 1) && ( delta > 1 ) )
1319  delta++;
1320 
1321  delta /= 2;
1322 
1323  D_PAD* pad = aPadList[idx];
1324 
1325  if( pad->GetPosition() == aPosition ) // candidate found
1326  {
1327  // The pad must match the layer mask:
1328  if( ( aLayerSet & pad->GetLayerSet() ).any() )
1329  return pad;
1330 
1331  // More than one pad can be at aPosition
1332  // search for a pad at aPosition that matched this mask
1333 
1334  // search next
1335  for( int ii = idx+1; ii <= idxmax; ii++ )
1336  {
1337  pad = aPadList[ii];
1338 
1339  if( pad->GetPosition() != aPosition )
1340  break;
1341 
1342  if( ( aLayerSet & pad->GetLayerSet() ).any() )
1343  return pad;
1344  }
1345  // search previous
1346  for( int ii = idx-1 ;ii >=0; ii-- )
1347  {
1348  pad = aPadList[ii];
1349 
1350  if( pad->GetPosition() != aPosition )
1351  break;
1352 
1353  if( ( aLayerSet & pad->GetLayerSet() ).any() )
1354  return pad;
1355  }
1356 
1357  // Not found:
1358  return 0;
1359  }
1360 
1361  if( pad->GetPosition().x == aPosition.x ) // Must search considering Y coordinate
1362  {
1363  if( pad->GetPosition().y < aPosition.y ) // Must search after this item
1364  {
1365  idx += delta;
1366 
1367  if( idx > idxmax )
1368  idx = idxmax;
1369  }
1370  else // Must search before this item
1371  {
1372  idx -= delta;
1373 
1374  if( idx < 0 )
1375  idx = 0;
1376  }
1377  }
1378  else if( pad->GetPosition().x < aPosition.x ) // Must search after this item
1379  {
1380  idx += delta;
1381 
1382  if( idx > idxmax )
1383  idx = idxmax;
1384  }
1385  else // Must search before this item
1386  {
1387  idx -= delta;
1388 
1389  if( idx < 0 )
1390  idx = 0;
1391  }
1392  }
1393 
1394  return NULL;
1395 }
1396 
1397 
1403 bool sortPadsByXthenYCoord( D_PAD* const & ref, D_PAD* const & comp )
1404 {
1405  if( ref->GetPosition().x == comp->GetPosition().x )
1406  return ref->GetPosition().y < comp->GetPosition().y;
1407  return ref->GetPosition().x < comp->GetPosition().x;
1408 }
1409 
1410 
1411 void BOARD::GetSortedPadListByXthenYCoord( std::vector<D_PAD*>& aVector, int aNetCode )
1412 {
1413  for ( auto mod : Modules() )
1414  {
1415  for ( auto pad : mod->Pads( ) )
1416  {
1417  if( aNetCode < 0 || pad->GetNetCode() == aNetCode )
1418  {
1419  aVector.push_back( pad );
1420  }
1421  }
1422  }
1423 
1424  std::sort( aVector.begin(), aVector.end(), sortPadsByXthenYCoord );
1425 }
1426 
1427 
1429 {
1430  GetConnectivity()->Remove( aPad );
1431  aPad->DeleteStructure();
1432 }
1433 
1434 
1435 std::tuple<int, double, double> BOARD::GetTrackLength( const TRACK& aTrack ) const
1436 {
1437  int count = 0;
1438  double length = 0.0;
1439  double package_length = 0.0;
1440 
1441  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, EOT };
1442  auto connectivity = GetBoard()->GetConnectivity();
1443 
1444  for( auto item : connectivity->GetConnectedItems(
1445  static_cast<const BOARD_CONNECTED_ITEM*>( &aTrack ), types ) )
1446  {
1447  count++;
1448 
1449  if( auto track = dyn_cast<TRACK*>( item ) )
1450  {
1451  bool inPad = false;
1452 
1453  for( auto pad_it : connectivity->GetConnectedPads( item ) )
1454  {
1455  auto pad = static_cast<D_PAD*>( pad_it );
1456 
1457  if( pad->HitTest( track->GetStart(), track->GetWidth() / 2 )
1458  && pad->HitTest( track->GetEnd(), track->GetWidth() / 2 ) )
1459  {
1460  inPad = true;
1461  break;
1462  }
1463  }
1464 
1465  if( !inPad )
1466  length += track->GetLength();
1467  }
1468  else if( auto pad = dyn_cast<D_PAD*>( item ) )
1469  package_length += pad->GetPadToDieLength();
1470  }
1471 
1472  return std::make_tuple( count, length, package_length );
1473 }
1474 
1475 
1476 MODULE* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
1477  bool aVisibleOnly, bool aIgnoreLocked )
1478 {
1479  MODULE* module = NULL;
1480  MODULE* alt_module = NULL;
1481  int min_dim = 0x7FFFFFFF;
1482  int alt_min_dim = 0x7FFFFFFF;
1483  bool current_layer_back = IsBackLayer( aActiveLayer );
1484 
1485  for( auto pt_module : m_modules )
1486  {
1487  // is the ref point within the module's bounds?
1488  if( !pt_module->HitTest( aPosition ) )
1489  continue;
1490 
1491  // if caller wants to ignore locked modules, and this one is locked, skip it.
1492  if( aIgnoreLocked && pt_module->IsLocked() )
1493  continue;
1494 
1495  PCB_LAYER_ID layer = pt_module->GetLayer();
1496 
1497  // Filter non visible modules if requested
1498  if( !aVisibleOnly || IsModuleLayerVisible( layer ) )
1499  {
1500  EDA_RECT bb = pt_module->GetFootprintRect();
1501 
1502  int offx = bb.GetX() + bb.GetWidth() / 2;
1503  int offy = bb.GetY() + bb.GetHeight() / 2;
1504 
1505  // off x & offy point to the middle of the box.
1506  int dist = ( aPosition.x - offx ) * ( aPosition.x - offx ) +
1507  ( aPosition.y - offy ) * ( aPosition.y - offy );
1508 
1509  if( current_layer_back == IsBackLayer( layer ) )
1510  {
1511  if( dist <= min_dim )
1512  {
1513  // better footprint shown on the active side
1514  module = pt_module;
1515  min_dim = dist;
1516  }
1517  }
1518  else if( aVisibleOnly && IsModuleLayerVisible( layer ) )
1519  {
1520  if( dist <= alt_min_dim )
1521  {
1522  // better footprint shown on the other side
1523  alt_module = pt_module;
1524  alt_min_dim = dist;
1525  }
1526  }
1527  }
1528  }
1529 
1530  if( module )
1531  {
1532  return module;
1533  }
1534 
1535  if( alt_module)
1536  {
1537  return alt_module;
1538  }
1539 
1540  return NULL;
1541 }
1542 
1543 std::list<ZONE_CONTAINER*> BOARD::GetZoneList( bool aIncludeZonesInFootprints )
1544 {
1545  std::list<ZONE_CONTAINER*> zones;
1546 
1547  for( int ii = 0; ii < GetAreaCount(); ii++ )
1548  {
1549  zones.push_back( GetArea( ii ) );
1550  }
1551 
1552  if( aIncludeZonesInFootprints )
1553  {
1554  for( MODULE* mod : m_modules )
1555  {
1556  for( MODULE_ZONE_CONTAINER* zone : mod->Zones() )
1557  {
1558  zones.push_back( zone );
1559  }
1560  }
1561  }
1562 
1563  return zones;
1564 }
1565 
1566 
1567 ZONE_CONTAINER* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
1568  wxPoint aStartPointPosition, ZONE_HATCH_STYLE aHatch )
1569 {
1570  ZONE_CONTAINER* new_area = InsertArea( aNetcode,
1571  m_ZoneDescriptorList.size( ) - 1,
1572  aLayer, aStartPointPosition.x,
1573  aStartPointPosition.y, aHatch );
1574 
1575  if( aNewZonesList )
1576  {
1577  ITEM_PICKER picker( new_area, UR_NEW );
1578  aNewZonesList->PushItem( picker );
1579  }
1580 
1581  return new_area;
1582 }
1583 
1584 
1585 void BOARD::RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to_remove )
1586 {
1587  if( area_to_remove == NULL )
1588  return;
1589 
1590  if( aDeletedList )
1591  {
1592  ITEM_PICKER picker( area_to_remove, UR_DELETED );
1593  aDeletedList->PushItem( picker );
1594  Remove( area_to_remove ); // remove from zone list, but does not delete it
1595  }
1596  else
1597  {
1598  Delete( area_to_remove );
1599  }
1600 }
1601 
1602 
1603 ZONE_CONTAINER* BOARD::InsertArea( int aNetcode, int aAreaIdx, PCB_LAYER_ID aLayer, int aCornerX,
1604  int aCornerY, ZONE_HATCH_STYLE aHatch )
1605 {
1606  ZONE_CONTAINER* new_area = (ZONE_CONTAINER*) this->Duplicate();
1607 
1608  new_area->SetNetCode( aNetcode );
1609  new_area->SetLayer( aLayer );
1610 
1611  if( aAreaIdx < (int) ( m_ZoneDescriptorList.size() - 1 ) )
1612  m_ZoneDescriptorList.insert( m_ZoneDescriptorList.begin() + aAreaIdx + 1, new_area );
1613  else
1614  m_ZoneDescriptorList.push_back( new_area );
1615 
1616  new_area->SetHatchStyle( (ZONE_HATCH_STYLE) aHatch );
1617 
1618  // Add the first corner to the new zone
1619  new_area->AppendCorner( wxPoint( aCornerX, aCornerY ), -1 );
1620 
1621  return new_area;
1622 }
1623 
1624 
1626 {
1627  // mark all areas as unmodified except this one, if modified
1628  for( ZONE_CONTAINER* zone : m_ZoneDescriptorList )
1629  zone->SetLocalFlags( 0 );
1630 
1631  aCurrArea->SetLocalFlags( 1 );
1632 
1633  if( aCurrArea->Outline()->IsSelfIntersecting() )
1634  {
1635  aCurrArea->UnHatch();
1636 
1637  // Normalize copied area and store resulting number of polygons
1638  int n_poly = aCurrArea->Outline()->NormalizeAreaOutlines();
1639 
1640  // If clipping has created some polygons, we must add these new copper areas.
1641  if( n_poly > 1 )
1642  {
1643  ZONE_CONTAINER* NewArea;
1644 
1645  // Move the newly created polygons to new areas, removing them from the current area
1646  for( int ip = 1; ip < n_poly; ip++ )
1647  {
1648  // Create new copper area and copy poly into it
1649  SHAPE_POLY_SET* new_p = new SHAPE_POLY_SET( aCurrArea->Outline()->UnitSet( ip ) );
1650  NewArea = AddArea( aNewZonesList, aCurrArea->GetNetCode(), aCurrArea->GetLayer(),
1651  wxPoint(0, 0), aCurrArea->GetHatchStyle() );
1652 
1653  // remove the poly that was automatically created for the new area
1654  // and replace it with a poly from NormalizeAreaOutlines
1655  delete NewArea->Outline();
1656  NewArea->SetOutline( new_p );
1657  NewArea->Hatch();
1658  NewArea->SetLocalFlags( 1 );
1659  }
1660 
1661  SHAPE_POLY_SET* new_p = new SHAPE_POLY_SET( aCurrArea->Outline()->UnitSet( 0 ) );
1662  delete aCurrArea->Outline();
1663  aCurrArea->SetOutline( new_p );
1664  }
1665  }
1666 
1667  aCurrArea->Hatch();
1668 
1669  return true;
1670 }
1671 
1672 
1673 /* Extracts the board outlines and build a closed polygon
1674  * from lines, arcs and circle items on edge cut layer
1675  * Any closed outline inside the main outline is a hole
1676  * All contours should be closed, i.e. are valid vertices for a closed polygon
1677  * return true if success, false if a contour is not valid
1678  */
1679 extern bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
1680  wxString* aErrorText, unsigned int aTolerance,
1681  wxPoint* aErrorLocation = nullptr );
1682 
1683 
1684 bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, wxString* aErrorText, wxPoint* aErrorLocation )
1685 {
1686 
1687  bool success = BuildBoardPolygonOutlines( this, aOutlines, aErrorText,
1688  GetDesignSettings().m_MaxError, aErrorLocation );
1689 
1690  // Make polygon strictly simple to avoid issues (especially in 3D viewer)
1692 
1693  return success;
1694 }
1695 
1696 
1697 const std::vector<D_PAD*> BOARD::GetPads()
1698 {
1699  std::vector<D_PAD*> allPads;
1700 
1701  for( MODULE* mod : Modules() )
1702  {
1703  for( D_PAD* pad : mod->Pads() )
1704  allPads.push_back( pad );
1705  }
1706 
1707  return allPads;
1708 }
1709 
1710 
1712 {
1713  unsigned retval = 0;
1714 
1715  for( auto mod : Modules() )
1716  retval += mod->Pads().size();
1717 
1718  return retval;
1719 }
1720 
1721 
1726 D_PAD* BOARD::GetPad( unsigned aIndex ) const
1727 {
1728  unsigned count = 0;
1729 
1730  for( auto mod : m_modules )
1731  {
1732  for( auto pad : mod->Pads() )
1733  {
1734  if( count == aIndex )
1735  return pad;
1736 
1737  count++;
1738  }
1739  }
1740 
1741  return nullptr;
1742 }
1743 
1744 
1745 const std::vector<BOARD_CONNECTED_ITEM*> BOARD::AllConnectedItems()
1746 {
1747  std::vector<BOARD_CONNECTED_ITEM*> items;
1748 
1749  for( auto track : Tracks() )
1750  {
1751  items.push_back( track );
1752  }
1753 
1754  for( auto mod : Modules() )
1755  {
1756  for( auto pad : mod->Pads() )
1757  {
1758  items.push_back( pad );
1759  }
1760  }
1761 
1762  for( int i = 0; i<GetAreaCount(); i++ )
1763  {
1764  auto zone = GetArea( i );
1765  items.push_back( zone );
1766  }
1767 
1768  return items;
1769 }
1770 
1771 
1773 {
1774  for( BOARD_CONNECTED_ITEM* item : AllConnectedItems() )
1775  item->SetNetCode( 0 );
1776 }
1777 
1778 
1779 void BOARD::MapNets( const BOARD* aDestBoard )
1780 {
1781  for( BOARD_CONNECTED_ITEM* item : AllConnectedItems() )
1782  {
1783  NETINFO_ITEM* netInfo = aDestBoard->FindNet( item->GetNetname() );
1784 
1785  if( netInfo )
1786  item->SetNetCode( netInfo->GetNet() );
1787  else
1788  item->SetNetCode( 0 );
1789  }
1790 }
1791 
1792 
1794 {
1795  for ( BOARD_CONNECTED_ITEM* item : AllConnectedItems() )
1796  {
1797  if( FindNet( item->GetNetCode() ) == nullptr )
1798  item->SetNetCode( NETINFO_LIST::ORPHANED );
1799  }
1800 }
bool IsElementVisible(GAL_LAYER_ID aElementCategory) const
Function IsElementVisible tests whether a given element category is visible.
MODULES m_modules
MODULES for components on the board, owned by pointer.
Definition: class_board.h:178
Definition: colors.h:57
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:686
EDA_UNITS
Definition: common.h:184
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
void SetCopperLayerCount(int aNewLayerCount)
Function SetCopperLayerCount do what its name says...
void BuildListOfNets()
Definition: class_board.h:692
void SetEnabledLayers(LSET aMask)
Function SetEnabledLayers changes the bit-mask of enabled layers.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
const PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Function GetLayerID returns the ID of a layer given by aLayerName.
MODULE * FindModuleByPath(const KIID_PATH &aPath) const
Function FindModuleByPath searches for a MODULE within this board with the given path.
Class that draws missing connections on a PCB.
void DeleteZONEOutlines()
Function DeleteZONEOutlines deletes ALL zone outlines from the board.
int GetNetCode() const
Function GetNetCode.
Definition: typeinfo.h:85
std::function< SEARCH_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Typedef INSPECTOR is used to inspect and possibly collect the (search) results of iterating over a li...
Definition: base_struct.h:83
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:313
static PCBNEW_SETTINGS dummyGeneralSettings
static const int dist[10][10]
Definition: ar_matrix.cpp:326
static NETINFO_ITEM * OrphanedItem()
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
Definition: netinfo.h:470
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
wxString m_name
The name of the layer, there should be no spaces in this name.
Definition: class_board.h:108
void PadDelete(D_PAD *aPad)
Function PadDelete deletes a given bad from the BOARD by removing it from its module and from the m_N...
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
void SetVisibleElements(int aMask)
Function SetVisibleElements is a proxy function that calls the correspondent function in m_BoardSetti...
const wxPoint GetPosition() const override
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
wxString GetClass() const override
Function GetClass returns the class name.
Definition: class_board.cpp:73
int GetX() const
Definition: eda_rect.h:111
D_PAD * GetPadFast(const wxPoint &aPosition, LSET aLayerMask)
Function GetPadFast return pad found at aPosition on aLayerMask using the fast search method.
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
void SetCustomViaDrill(int aDrill)
Function SetCustomViaDrill Sets custom size for via drill (i.e.
Class that computes missing connections on a PCB.
the 3d code uses this value
Definition: typeinfo.h:80
LAYER_T m_type
The type of the layer.
Definition: class_board.h:109
void GetSortedPadListByXthenYCoord(std::vector< D_PAD * > &aVector, int aNetCode=-1)
Function GetSortedPadListByXthenYCoord first empties then fills the vector with all pads and sorts th...
int NormalizeAreaOutlines()
Function NormalizeAreaOutlines Convert a self-intersecting polygon to one (or more) non self-intersec...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:213
ZONE_CONTAINER * m_CurrentZoneContour
zone contour currently in progress
Definition: class_board.h:256
int GetWidth() const
Definition: eda_rect.h:119
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:265
void DeleteStructure()
Function DeleteStructure deletes this object after removing from its parent if it has one.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
void SetCopperLayerCount(int aCount)
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void RemoveArea(PICKED_ITEMS_LIST *aDeletedList, ZONE_CONTAINER *area_to_remove)
Function RemoveArea remove copper area from net, and put it in a deleted list (if exists)
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
void SetHatchStyle(ZONE_HATCH_STYLE aStyle)
Definition: class_zone.h:543
const wxPoint GetPosition() const override
Definition: class_board.cpp:79
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
void SetVisibleAlls()
Function SetVisibleAlls changes the bit-mask of visible element categories and layers.
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:140
void SetPosition(const wxPoint &aPos) override
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
This is the end of the layers used for visibility bitmasks in Pcbnew There can be at most 32 layers a...
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Function SetLayerType changes the type of the layer given by aLayer.
NETINFO_LIST m_NetInfo
net info list (name, design constraints ..
Definition: class_board.h:201
A singleton item of this class is returned for a weak reference that no longer exists.
Definition: class_board.cpp:61
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
Function IsLayerEnabled is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:419
D_PAD * GetPad(unsigned aIndex) const
Function GetPad.
TRACKS m_tracks
TRACKS for traces on the board, owned by pointer.
Definition: class_board.h:181
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
BOARD_ITEM * GetItem(const KIID &aID)
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void SetOutline(SHAPE_POLY_SET *aOutline)
Definition: class_zone.h:268
void SetCustomViaSize(int aSize)
Function SetCustomViaSize Sets custom size for via diameter (i.e.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static wxPoint ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
Definitions for tracks, vias and zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:436
static const char * ShowType(LAYER_T aType)
Function ShowType converts a LAYER_T enum to a const char*.
ZONE_CONTAINER * HitTestForAnyFilledArea(const wxPoint &aRefPos, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer, int aNetCode)
Function HitTestForAnyFilledArea tests if the given wxPoint is within the bounds of a filled area of ...
void SetVisibleLayers(LSET aMask)
Function SetVisibleLayers changes the bit-mask of visible layers.
Classes used in Pcbnew, CvPcb and GerbView.
void AppendNet(NETINFO_ITEM *aNewElement)
Function AppendNet adds aNewElement to the end of the net list.
show modules on front
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:108
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: common.h:65
class MODULE, a footprint
Definition: typeinfo.h:89
Markers used to show a drc problem on boards.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_board.cpp:68
PCB_LAYER_ID
A quick note on layer IDs:
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
void RemoveNet(NETINFO_ITEM *aNet)
Function RemoveNet Removes a new from the net list.
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:919
LSET is a set of PCB_LAYER_IDs.
#define NULL
bool NormalizeAreaPolygon(PICKED_ITEMS_LIST *aNewZonesList, ZONE_CONTAINER *aCurrArea)
Function NormalizeAreaPolygon Process an area that has been modified, by normalizing its polygon agai...
unsigned GetNodesCount(int aNet=-1)
Function GetNodesCount.
MODULES & Modules()
Definition: class_board.h:229
void DeleteMARKERs()
Function DeleteMARKERs deletes ALL MARKERS from the board.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
SHAPE_POLY_SET.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
bool sortPadsByXthenYCoord(D_PAD *const &ref, D_PAD *const &comp)
Function SortPadsByXCoord is used by GetSortedPadListByXCoord to Sort a pad list by x coordinate valu...
LAYER_T
Enum LAYER_T gives the allowed types of layers, same as Specctra DSN spec.
Definition: class_board.h:68
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &aOffset) override
Function Print BOARD_ITEMs have their own color information.
Definition: class_board.cpp:81
void SetNetCode(int aNetCode)
Definition: netinfo.h:226
KIID niluuid(0)
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:446
unsigned GetUnconnectedNetCount() const
Function GetUnconnectedNetCount.
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Function SetLayerName changes the name of the layer given by aLayer.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:306
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Function SetLayerDescr returns the type of the copper layer given by aLayer.
ZONE_CONTAINER * InsertArea(int aNetcode, int aAreaIdx, PCB_LAYER_ID aLayer, int aCornerX, int aCornerY, ZONE_HATCH_STYLE aHatch)
Add a copper area to net, inserting after m_ZoneDescriptorList[aAreaIdx].
int SortedNetnamesList(wxArrayString &aNames, bool aSortbyPadsCount)
Function SortedNetnamesList.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:240
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:232
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Sets net using a net code.
Definition: colors.h:60
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
void SetPosition(const wxPoint &) override
Definition: class_board.cpp:80
int SetAreasNetCodesFromNetNames(void)
Function SetAreasNetCodesFromNetNames Set the .m_NetCode member of all copper areas,...
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, wxString *aErrorText=nullptr, wxPoint *aErrorLocation=nullptr)
Function GetBoardPolygonOutlines Extracts the board outlines and build a closed polygon from lines,...
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
ENDPOINT_T
Definition: class_track.h:54
MARKERS m_markers
MARKER_PCBs for clearance problems, owned by pointer.
Definition: class_board.h:172
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, wxString *aErrorText, unsigned int aTolerance, wxPoint *aErrorLocation=nullptr)
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
static LAYER_T ParseType(const char *aType)
Function ParseType converts a string to a LAYER_T.
int GetVisibleElements() const
Function GetVisibleElements is a proxy function that calls the correspondent function in m_BoardSetti...
DRAWINGS m_drawings
BOARD_ITEMs for drawings on the board, owned by pointer.
Definition: class_board.h:175
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
unsigned GetPadCount()
Function GetPadCount.
ZONE_HATCH_STYLE GetHatchStyle() const
Definition: class_zone.h:538
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void SetCustomTrackWidth(int aWidth)
Function SetCustomTrackWidth Sets custom width for track (i.e.
int GetHeight() const
Definition: eda_rect.h:120
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:466
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
static bool sortNetsByNames(const NETINFO_ITEM *a, const NETINFO_ITEM *b)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
TRACKS TracksInNet(int aNetCode)
Function TrackInNet collects all the TRACKs and VIAs that are members of a net given by aNetCode.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Function GetLayerType returns the type of the copper layer given by aLayer.
void Move(const wxPoint &aMoveVector) override
Function Move move this object.
const std::vector< D_PAD * > GetPads()
Function GetPads returns a reference to a list of all the pads.
int GetCurrentViaSize() const
Function GetCurrentViaSize.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
void MapNets(const BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
bool m_Printing
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
Definition: pgm_base.h:341
LSET GetVisibleLayers() const
Function GetVisibleLayers returns a bit-mask of all the layers that are visible.
ZONE_CONTAINERS & Zones()
Definition: class_board.h:243
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
see class PGM_BASE
int GetVisibleElements() const
Function GetVisibleElements returns a bit-mask of all the element categories that are visible.
void UnHatch()
Function UnHatch clears the zone's hatch.
Definition: class_zone.cpp:986
ZONE_HATCH_STYLE
Zone hatch styles.
Definition: zone_settings.h:45
SHAPE_POLY_SET UnitSet(int aPolygonIndex)
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
NETCLASSPTR GetDefault() const
Function GetDefault.
int m_fileFormatVersionAtLoad
the version loaded from the file
Definition: class_board.h:192
int GetNet() const
Function GetNet.
Definition: netinfo.h:224
LAYER holds information pertinent to a layer of a BOARD.
Definition: class_board.h:82
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
LSET GetEnabledLayers() const
Function GetEnabledLayers returns a bit-mask of all the layers that are enabled.
#define _(s)
Definition: 3d_actions.cpp:33
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
ZONE_CONTAINERS m_ZoneDescriptorList
edge zone descriptors, owned by pointer.
Definition: class_board.h:184
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:104
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SanitizeNetcodes()
LAYER m_Layer[PCB_LAYER_ID_COUNT]
Definition: class_board.h:186
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition: class_board.h:194
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone's...
int GetY() const
Definition: eda_rect.h:112
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
static bool sortNetsByNodes(const NETINFO_ITEM *a, const NETINFO_ITEM *b)
void SetLocalFlags(int aFlags)
Definition: class_zone.h:260
The common library.
MODULE_ZONE_CONTAINER is the same item as ZONE_CONTAINER, but with a specific type id ZONE_CONTAINER ...
Definition: class_zone.h:848
bool IsModuleLayerVisible(PCB_LAYER_ID aLayer)
Function IsModuleLayerVisible expects either of the two layers on which a module can reside,...
MODULE * FindModuleByReference(const wxString &aReference) const
Function FindModuleByReference searches for a MODULE within this board with the given reference desig...
wxString GetClass() const override
Function GetClass returns the class name.
Definition: class_board.h:836
void SetElementVisibility(GAL_LAYER_ID aElementCategory, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Function ComputeBoundingBox calculates the bounding box containing all board items (or board edge seg...
unsigned GetNetCount() const
Function GetNetCount.
Definition: netinfo.h:435
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the container and deletes it.
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: class_zone.cpp:927
PCB_TARGET class definition.
ZONE_CONTAINER * AddArea(PICKED_ITEMS_LIST *aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer, wxPoint aStartPointPosition, ZONE_HATCH_STYLE aHatch)
Function AddArea Add an empty copper area to board areas list.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static SEARCH_RESULT IterateForward(std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )
Definition: base_struct.h:399
BOARD_DESIGN_SETTINGS m_designSettings
Definition: class_board.h:196
Module description (excepted pads)
DELETED_BOARD_ITEM * g_DeletedItem
Definition: class_board.cpp:88
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:884
Abstract interface for BOARD_ITEMs capable of storing other items inside.
PGM_BASE * PgmOrNull()
similat to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
SEARCH_RESULT
Definition: base_struct.h:54
NETINFO_ITEM * GetNetItem(int aNetCode) const
Function GetItem.
const wxPoint GetPosition() const override
Definition: class_pad.h:241
std::tuple< int, double, double > GetTrackLength(const TRACK &aTrack) const
Returns data on the length and number of track segments connected to a given track.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void ClearEditFlags()
Definition: base_struct.h:275
Message panel definition file.
const wxPoint & GetEndPoint(ENDPOINT_T aEndPoint) const
Return the selected endpoint (start or end)
Definition: class_track.h:115
MODULE * GetFootprint(const wxPoint &aPosition, PCB_LAYER_ID aActiveLayer, bool aVisibleOnly, bool aIgnoreLocked=false)
Function GetFootprint get a footprint by its bounding rectangle at aPosition on aLayer.
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
static std::vector< int > padCountListByNet
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:462
int GetCopperLayerCount() const
Function GetCopperLayerCount.
DRAWINGS & Drawings()
Definition: class_board.h:238
void ClearAllNetCodes()
Function ClearAllNetCodes() Resets all items' netcodes to 0 (no net).
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void Remove(BOARD_ITEM *aBoardItem) override
Removes an item from the container.
TRACKS & Tracks()
Definition: class_board.h:220
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: class_zone.cpp:219
PCBNEW_SETTINGS * m_generalSettings
reference only; I have no ownership
Definition: class_board.h:197
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD_ITEM * Duplicate() const
Function Duplicate creates a copy of a BOARD_ITEM.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:622
std::list< ZONE_CONTAINER * > GetZoneList(bool aIncludeZonesInFootprints=false)
Function GetZoneList.
bool IsSelfIntersecting() const
Function IsSelfIntersecting Checks whether any of the polygons in the set is self intersecting.
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...