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