26#include <magic_enum.hpp>
28#include <unordered_set>
61#include <google/protobuf/any.pb.h>
62#include <api/board/board_types.pb.h>
71 m_boundingBoxCacheTimeStamp( 0 ),
72 m_textExcludedBBoxCacheTimeStamp( 0 ),
73 m_hullCacheTimeStamp( 0 ),
74 m_initial_comments( nullptr ),
75 m_componentClass( nullptr )
145 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
151 ptrMap[field] = newField;
152 Add( newField, ADD_MODE::APPEND );
158 PAD* newPad =
static_cast<PAD*
>(
pad->Clone() );
159 ptrMap[
pad ] = newPad;
160 Add( newPad, ADD_MODE::APPEND );
166 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
167 ptrMap[ zone ] = newZone;
168 Add( newZone, ADD_MODE::APPEND );
181 ptrMap[ item ] = newItem;
182 Add( newItem, ADD_MODE::APPEND );
189 ptrMap[
group ] = newGroup;
190 Add( newGroup, ADD_MODE::APPEND );
202 if( ptrMap.count( member ) )
203 newGroup->
AddItem( ptrMap[ member ] );
226 *
this = std::move( aFootprint );
236 item->SetParentGroup(
nullptr );
268 board->IncrementTimeStamp();
275 types::FootprintInstance footprint;
278 footprint.mutable_position()->set_x_nm(
GetPosition().x );
279 footprint.mutable_position()->set_y_nm(
GetPosition().y );
281 footprint.set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>(
GetLayer() ) );
282 footprint.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
283 : kiapi::common::types::LockedState::LS_UNLOCKED );
285 google::protobuf::Any buf;
287 buf.UnpackTo( footprint.mutable_reference_field() );
289 buf.UnpackTo( footprint.mutable_value_field() );
291 buf.UnpackTo( footprint.mutable_datasheet_field() );
293 buf.UnpackTo( footprint.mutable_description_field() );
295 types::FootprintAttributes* attrs = footprint.mutable_attributes();
301 attrs->set_do_not_populate(
IsDNP() );
303 types::Footprint* def = footprint.mutable_definition();
308 def->mutable_attributes()->set_keywords(
GetKeywords().ToStdString() );
312 types::FootprintDesignRuleOverrides* overrides = def->mutable_overrides();
326 overrides->set_zone_connection(
331 types::NetTieDefinition* netTie = def->add_net_ties();
332 wxStringTokenizer tokenizer(
group,
" " );
334 while( tokenizer.HasMoreTokens() )
335 netTie->add_pad_number( tokenizer.GetNextToken().ToStdString() );
339 def->add_private_layers( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
346 google::protobuf::Any* itemMsg = def->add_items();
347 item->Serialize( *itemMsg );
350 for(
const PAD* item :
Pads() )
352 google::protobuf::Any* itemMsg = def->add_items();
353 item->Serialize( *itemMsg );
358 google::protobuf::Any* itemMsg = def->add_items();
359 item->Serialize( *itemMsg );
364 google::protobuf::Any* itemMsg = def->add_items();
365 item->Serialize( *itemMsg );
370 google::protobuf::Any* itemMsg = def->add_items();
371 types::Footprint3DModel modelMsg;
372 modelMsg.set_filename( model.m_Filename.ToUTF8() );
376 modelMsg.set_visible( model.m_Show );
377 modelMsg.set_opacity( model.m_Opacity );
378 itemMsg->PackFrom( modelMsg );
381 aContainer.PackFrom( footprint );
388 types::FootprintInstance footprint;
390 if( !aContainer.UnpackTo( &footprint ) )
396 SetLayer( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( footprint.layer() ) );
397 SetLocked( footprint.locked() == kiapi::common::types::LockedState::LS_LOCKED );
399 google::protobuf::Any buf;
400 types::Field mandatoryField;
402 if( footprint.has_reference_field() )
404 mandatoryField = footprint.reference_field();
406 buf.PackFrom( mandatoryField );
410 if( footprint.has_value_field() )
412 mandatoryField = footprint.value_field();
413 mandatoryField.mutable_id()->set_id(
VALUE_FIELD );
414 buf.PackFrom( mandatoryField );
418 if( footprint.has_datasheet_field() )
420 mandatoryField = footprint.datasheet_field();
422 buf.PackFrom( mandatoryField );
426 if( footprint.has_description_field() )
428 mandatoryField = footprint.description_field();
430 buf.PackFrom( mandatoryField );
434 SetBoardOnly( footprint.attributes().not_in_schematic() );
438 SetDNP( footprint.attributes().do_not_populate() );
444 SetKeywords( footprint.definition().attributes().keywords() );
446 const types::FootprintDesignRuleOverrides& overrides = footprint.overrides();
448 if( overrides.has_copper_clearance() )
453 if( overrides.has_solder_mask() && overrides.solder_mask().has_solder_mask_margin() )
458 if( overrides.has_solder_paste() )
460 const types::SolderPasteOverrides& pasteSettings = overrides.solder_paste();
462 if( pasteSettings.has_solder_paste_margin() )
467 if( pasteSettings.has_solder_paste_margin_ratio() )
475 for(
const types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
479 for(
const std::string&
pad : netTieMsg.pad_number() )
480 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
488 for(
int layerMsg : footprint.definition().private_layers() )
490 auto layer =
static_cast<types::BoardLayer
>( layerMsg );
491 privateLayers.
set( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
509 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
517 if( itemMsg.type_url() ==
"type.googleapis.com/kiapi.board.types.Footprint3DModel" )
519 types::Footprint3DModel modelMsg;
521 if( !itemMsg.UnpackTo( &modelMsg ) )
526 model.
m_Filename = wxString::FromUTF8( modelMsg.filename() );
527 model.
m_Show = modelMsg.visible();
533 Models().push_back( model );
537 wxLogTrace(
traceApi, wxString::Format( wxS(
"Attempting to unpack unknown type %s "
538 "from footprint message, skipping" ),
539 itemMsg.type_url() ) );
546 if( item && item->Deserialize( itemMsg ) )
547 Add( item.release(), ADD_MODE::APPEND );
570 if( field->GetId() == aFieldId )
581 if( field->GetCanonicalName() == aFieldName )
590 if( aFieldName.empty() )
595 if( field->GetName() == aFieldName )
607 if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
608 return field->GetText();
611 return wxEmptyString;
627 if( !field->IsVisible() || field->GetText().IsEmpty() )
631 aVector.push_back( field );
649 if( aFieldName ==
m_fields[i]->GetName(
false ) )
669 switch( item->Type() )
679 if( aStyleShapes && !item->IsOnCopperLayer() )
694 std::vector< BOARD_ITEM* > item_list;
697 item_list.push_back( field );
700 item_list.push_back(
pad );
703 item_list.push_back( gr_item );
708 item_list.push_back(
group );
712 item_list.push_back( zone );
714 bool changed =
false;
720 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
733 m_pos = aOther.m_pos;
761 for(
PCB_FIELD* field : aOther.Fields() )
767 for(
PAD*
pad : aOther.Pads() )
770 aOther.Pads().clear();
775 for(
ZONE* item : aOther.Zones() )
783 item->SetNetCode( -1 );
786 aOther.Zones().clear();
791 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
794 aOther.GraphicalItems().clear();
802 aOther.Groups().clear();
813 aOther.Fields().clear();
814 aOther.Pads().clear();
815 aOther.Zones().clear();
816 aOther.GraphicalItems().clear();
817 aOther.m_initial_comments =
nullptr;
852 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
860 ptrMap[field] = newField;
870 ptrMap[
pad ] = newPad;
879 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
880 ptrMap[ zone ] = newZone;
896 ptrMap[ item ] = newItem;
909 newGroup->
AddItem( ptrMap[ member ] );
935 aVars->push_back( wxT(
"REFERENCE" ) );
936 aVars->push_back( wxT(
"VALUE" ) );
937 aVars->push_back( wxT(
"LAYER" ) );
938 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
939 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
940 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
941 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
942 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
943 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
952 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
957 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
962 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
967 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
972 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
977 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
978 || token->StartsWith( wxT(
"NET_NAME(" ) )
979 || token->StartsWith( wxT(
"NET_CLASS(" ) )
980 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
982 wxString padNumber = token->AfterFirst(
'(' );
983 padNumber = padNumber.BeforeLast(
')' );
987 if(
pad->GetNumber() == padNumber )
989 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
990 *token =
pad->GetShortNetname();
991 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
992 *token =
pad->GetNetname();
993 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
994 *token =
pad->GetNetClassVariableSubstitutionName();
996 *token =
pad->GetPinFunction();
1026 switch( aBoardItem->
Type() )
1044 if( aMode == ADD_MODE::APPEND )
1051 if( aMode == ADD_MODE::APPEND )
1052 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
1054 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1058 if( aMode == ADD_MODE::APPEND )
1059 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1065 if( aMode == ADD_MODE::APPEND )
1074 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1075 aBoardItem->
Type() );
1089 switch( aBoardItem->
Type() )
1095 if( *it == aBoardItem )
1116 if( *it == aBoardItem )
1126 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1128 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1140 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1152 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1164 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1165 aBoardItem->
Type() );
1196 switch(
pad->GetProperty() )
1198 case PAD_PROP::FIDUCIAL_GLBL:
1199 case PAD_PROP::FIDUCIAL_LOCAL:
1202 case PAD_PROP::HEATSINK:
1203 case PAD_PROP::CASTELLATED:
1204 case PAD_PROP::MECHANICAL:
1207 case PAD_PROP::NONE:
1209 case PAD_PROP::TESTPOINT:
1213 switch(
pad->GetAttribute() )
1215 case PAD_ATTRIB::PTH:
1219 case PAD_ATTRIB::SMD:
1220 if(
pad->IsOnCopperLayer() )
1248 return _(
"Through hole" );
1250 return _(
"Other" );
1265 if(
dummy.IsFlipped() )
1269 bbox.
Merge(
pad->GetBoundingBox() );
1272 dummy.SetParent(
nullptr );
1273 dummy.SetParentGroup(
nullptr );
1318 std::vector<PCB_TEXT*> texts;
1340 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1358 bbox.
Merge( item->GetBoundingBox() );
1364 if( !field->IsReference() && !field->IsValue() )
1365 texts.push_back( field );
1369 bbox.
Merge(
pad->GetBoundingBox() );
1372 bbox.
Merge( zone->GetBoundingBox() );
1377 if( aIncludeText || noDrawItems )
1386 if(
text->IsVisible() )
1392 bool valueLayerIsVisible =
true;
1393 bool refLayerIsVisible =
true;
1411 if( (
Value().IsVisible() && valueLayerIsVisible ) || noDrawItems )
1416 if( (
Reference().IsVisible() && refLayerIsVisible ) || noDrawItems )
1424 if( aIncludeText || noDrawItems )
1442 std::vector<PCB_TEXT*> texts;
1454 if( ( aLayers & item->GetLayerSet() ).none() )
1462 bbox.
Merge( item->GetBoundingBox() );
1467 if( ( aLayers &
pad->GetLayerSet() ).none() )
1470 bbox.
Merge(
pad->GetBoundingBox() );
1475 if( ( aLayers & zone->GetLayerSet() ).none() )
1478 bbox.
Merge( zone->GetBoundingBox() );
1515 pad->Padstack().ForEachUniqueLayer(
1529 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1556 std::vector<VECTOR2I> convex_hull;
1562 for(
const VECTOR2I& pt : convex_hull )
1586 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1588 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1590 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1593 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1602 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1603 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1607 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1609 if( !aStr->IsEmpty() )
1610 *aStr += wxT(
", " );
1619 addToken( &status,
_(
"Locked" ) );
1622 addToken( &status,
_(
"autoplaced" ) );
1625 addToken( &attrs,
_(
"not in schematic" ) );
1628 addToken( &attrs,
_(
"exclude from pos files" ) );
1631 addToken( &attrs,
_(
"exclude from BOM" ) );
1634 addToken( &attrs,
_(
"DNP" ) );
1636 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1638 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1647 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1649 aList.emplace_back( msg, msg2 );
1653 aList.emplace_back( msg, msg2 );
1661 if( board->IsFootprintHolder() )
1693 if(
pad->IsOnLayer( aLayer ) )
1699 if( zone->IsOnLayer( aLayer ) )
1705 if( field->IsOnLayer( aLayer ) )
1711 if( item->IsOnLayer( aLayer ) )
1723 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1729 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1735 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1736 && item->HitTest( aPosition, aAccuracy ) )
1748 std::vector<BOARD_ITEM*> items;
1752 if(
pad->IsOnLayer( aLayer ) )
1753 items.push_back(
pad );
1758 if( zone->IsOnLayer( aLayer ) )
1759 items.push_back( zone );
1764 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1765 items.push_back( item );
1774 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1776 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1783 return !items.empty() && aContained;
1802 BOX2I arect = aRect;
1822 if(
pad->HitTest( arect,
false, 0 ) )
1828 if( zone->HitTest( arect,
false, 0 ) )
1839 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1853 bool can_select = aSearchAfterMe ? false :
true;
1857 if( !can_select &&
pad == aSearchAfterMe )
1863 if( can_select &&
pad->GetNumber() == aPadNumber )
1876 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1879 if(
pad->HitTest( aPosition ) )
1889 std::vector<const PAD*> retv;
1893 if( ( aIgnore && aIgnore ==
pad ) || (
pad->GetNumber() != aPadNumber ) )
1896 retv.push_back(
pad );
1912 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1924 std::set<wxString> usedNumbers;
1936 if(
pad->GetNumber().IsEmpty() )
1942 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1946 usedNumbers.insert(
pad->GetNumber() );
1961 if(
nullptr == a3DModel )
1971 const std::vector<KICAD_T>& aScanTypes )
1973#if 0 && defined(DEBUG)
1974 std::cout <<
GetClass().mb_str() <<
' ';
1977 bool drawingsScanned =
false;
1979 for(
KICAD_T scanType : aScanTypes )
1984 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
1985 return INSPECT_RESULT::QUIT;
1990 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1991 == INSPECT_RESULT::QUIT )
1993 return INSPECT_RESULT::QUIT;
1999 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
2000 == INSPECT_RESULT::QUIT )
2002 return INSPECT_RESULT::QUIT;
2008 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
2009 == INSPECT_RESULT::QUIT )
2011 return INSPECT_RESULT::QUIT;
2026 if( !drawingsScanned )
2028 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
2029 == INSPECT_RESULT::QUIT )
2031 return INSPECT_RESULT::QUIT;
2034 drawingsScanned =
true;
2040 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
2041 == INSPECT_RESULT::QUIT )
2043 return INSPECT_RESULT::QUIT;
2053 return INSPECT_RESULT::CONTINUE;
2061 if( reference.IsEmpty() )
2062 reference =
_(
"<no reference designator>" );
2064 return wxString::Format(
_(
"Footprint %s" ), reference );
2070 return BITMAPS::module;
2097 aFunction( drawing );
2099 catch( std::bad_function_call& )
2101 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2127 group->RunOnDescendants( aFunction, aDepth + 1 );
2132 aFunction( drawing );
2133 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2136 catch( std::bad_function_call& )
2138 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2145 std::vector<int> layers;
2147 layers.reserve( 6 );
2153 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2174 bool f_silk =
false, b_silk =
false, non_silk =
false;
2178 if( item->GetLayer() ==
F_SilkS )
2180 else if( item->GetLayer() ==
B_SilkS )
2186 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2210 return std::numeric_limits<double>::max();
2222 return std::numeric_limits<double>::max();
2231 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
2236 return std::numeric_limits<double>::max();
2247 int biggest_clearance = board->GetMaxClearanceValue();
2248 area.
Inflate( biggest_clearance );
2259 if( aName.find_first_of( invalids ) != std::string::npos )
2273 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2274 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2277 return invalidCharsReadable;
2279 return invalidChars;
2285 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2299 EDA_ANGLE newOrientation = orientation + aAngle;
2306 field->KeepUpright();
2311 static_cast<PCB_TEXT*
>( item )->KeepUpright();
2322 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2357 field->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2361 pad->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2368 zone->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2372 item->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2375 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
2394 field->EDA_TEXT::Offset(
delta );
2400 zone->Move(
delta );
2403 item->Move(
delta );
2430 field->Move( moveVector );
2434 pad->Move( moveVector );
2438 item->Move( moveVector );
2442 zone->Move( moveVector );
2500 switch( aItem->
Type() )
2504 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2507 if( aAddToFootprint )
2508 m_pads.push_back( new_pad );
2516 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2519 if( aAddToFootprint )
2520 m_zones.push_back( new_zone );
2522 new_item = new_zone;
2544 if( aAddToFootprint )
2547 new_item = new_text;
2556 if( aAddToFootprint )
2559 new_item = new_shape;
2568 if( aAddToFootprint )
2571 new_item = new_textbox;
2583 if( aAddToFootprint )
2586 new_item = dimension;
2594 if( aAddToFootprint )
2596 group->RunOnDescendants(
2615 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2625 std::set<wxString> usedNumbers;
2629 usedNumbers.insert(
pad->GetNumber() );
2636 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2639 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2690 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2694 return aPolySet.
Area();
2709 return markerShape.
Area();
2713 double combinedArea = 0.0;
2718 return combinedArea;
2748 case SHAPE_T::SEGMENT:
2750 case SHAPE_T::BEZIER:
2753 case SHAPE_T::RECTANGLE:
2754 case SHAPE_T::CIRCLE:
2769 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2770 return width * width;
2774 static_cast<const PAD*
>( aItem )->Padstack().ForEachUniqueLayer(
2806 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2810 switch( item->
Type() )
2841 double footprintRegionArea =
polygonArea( footprintRegion );
2842 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2843 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2844 double ratio = ( coveredArea / footprintRegionArea );
2851 return std::min( ratio, 1.0 );
2857 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2878 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2883 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2923 std::vector<PCB_SHAPE*> list_front;
2924 std::vector<PCB_SHAPE*> list_back;
2925 std::map<int, int> front_width_histogram;
2926 std::map<int, int> back_width_histogram;
2933 list_back.push_back( shape );
2940 list_front.push_back( shape );
2945 if( !list_front.size() && !list_back.size() )
2952 true, aErrorHandler ) )
2962 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
2963 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2965 return a.second < b.second;
2968 if( max != front_width_histogram.end() )
2991 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
2992 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2994 return a.second < b.second;
2997 if( max != back_width_histogram.end() )
3020 std::map<PCB_LAYER_ID, std::vector<PCB_SHAPE*>> layer_shapes;
3025 if( item->Type() != PCB_SHAPE_T )
3028 for( PCB_LAYER_ID layer : item->GetLayerSet() )
3029 layer_shapes[layer].push_back( static_cast<PCB_SHAPE*>( item ) );
3032 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3035 bool has_nettie =
false;
3037 auto it = map.find(
pad->GetNumber() );
3039 if( it == map.end() || it->second < 0 )
3042 for(
size_t jj = ii + 1; jj <
m_pads.size(); ++jj )
3046 auto it2 = map.find( other->
GetNumber() );
3048 if( it2 == map.end() || it2->second < 0 )
3051 if( it2->second == it->second )
3064 for(
auto& [ layer, shapes ] : layer_shapes )
3066 auto pad_shape =
pad->GetEffectiveShape( layer );
3068 for(
auto other_shape : shapes )
3070 auto shape = other_shape->GetEffectiveShape( layer );
3072 if( pad_shape->Collide( shape.get() ) )
3075 m_netTieCache[other_shape].insert( nettie.begin(), nettie.end() );
3085 std::map<wxString, int> padNumberToGroupIdxMap;
3088 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
3091 [&]( wxString aPad,
int aGroup )
3093 aPad.Trim(
true ).Trim(
false );
3095 if( !aPad.IsEmpty() )
3096 padNumberToGroupIdxMap[ aPad ] = aGroup;
3105 for( wxUniCharRef ch :
group )
3114 switch(
static_cast<unsigned char>( ch ) )
3121 processPad(
pad, ii );
3131 processPad(
pad, ii );
3134 return padNumberToGroupIdxMap;
3144 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
3145 std::vector<PAD*> otherPads;
3151 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
3152 otherPads.push_back(
pad );
3165 if( setAttr && likelyAttr && setAttr != likelyAttr )
3169 switch( likelyAttr )
3172 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3175 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3180 (aErrorHandler)( msg );
3186 const std::function<
void(
const PAD*,
int,
3187 const wxString& )>& aErrorHandler )
3189 if( aErrorHandler ==
nullptr )
3194 pad->CheckPad( aUnitsProvider,
3195 [&](
int errorCode,
const wxString& msg )
3197 aErrorHandler(
pad, errorCode, msg );
3205 const VECTOR2I& )>& aErrorHandler )
3207 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3222 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3225 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3227 checkedPairs[ { a, b } ] = 1;
3229 if(
pad->HasDrilledHole() && other->HasDrilledHole() )
3233 if(
pad->GetPosition() == other->GetPosition() )
3239 std::shared_ptr<SHAPE_SEGMENT> holeA =
pad->GetEffectiveHoleShape();
3240 std::shared_ptr<SHAPE_SEGMENT> holeB = other->GetEffectiveHoleShape();
3242 if( holeA->Collide( holeB->GetSeg(), 0 ) )
3253 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3257 for(
PCB_LAYER_ID l :
pad->Padstack().RelevantShapeLayers( other->Padstack() ) )
3259 SHAPE* padShape =
pad->GetEffectiveShape( l ).get();
3260 SHAPE* otherShape = other->GetEffectiveShape( l ).get();
3262 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3275 const VECTOR2I& )>& aErrorHandler )
3284 std::vector<BOARD_ITEM*> copperItems;
3288 if( item->IsOnCopperLayer() )
3289 copperItems.push_back( item );
3291 item->RunOnDescendants(
3295 copperItems.push_back( descendent );
3301 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3302 copperItems.push_back( zone );
3307 if( field->IsOnCopperLayer() )
3308 copperItems.push_back( field );
3318 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3322 if( item->IsOnLayer( layer ) )
3324 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3335 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3337 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3338 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3345 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3347 if( pads.size() > 1 )
3349 const PAD* firstPad = pads[0];
3350 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3352 for(
size_t ii = 1; ii < pads.size(); ++ii )
3354 const PAD* thisPad = pads[ii];
3355 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3357 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3366 if( item->HitTest( pos, 1 ) )
3368 shortingItem = item;
3374 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3376 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3387 std::set<wxString> padNumbers;
3396 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3397 aErrorHandler( msg );
3399 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3401 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3402 aErrorHandler( msg );
3414 std::swap( *
this, *
image );
3422 image->RunOnChildren(
3434 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3449 return *
this == other;
3458 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3467 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3476 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3485 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3502 double similarity = 1.0;
3511 similarity *=
pad->Similarity( *otherPad );
3520 if( itemA->
Type() != itemB->
Type() )
3521 return itemA->
Type() < itemB->
Type();
3536 if( dwgA->
GetShape() != SHAPE_T::POLY )
3549 if( dwgA->
GetShape() == SHAPE_T::ARC )
3556 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3568 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3591 return itemA < itemB;
3605 std::optional<bool> padCopperMatches;
3608 const PAD* checkPad = aFirst;
3621 padCopperMatches = aFirst->
GetSize( aLayer ).
x < aSecond->
GetSize( aLayer ).
x;
3623 padCopperMatches = aFirst->
GetSize( aLayer ).
y < aSecond->
GetSize( aLayer ).
y;
3625 padCopperMatches = aFirst->
GetShape( aLayer ) < aSecond->
GetShape( aLayer );
3628 if( padCopperMatches.has_value() )
3629 return *padCopperMatches;
3637 return aFirst < aSecond;
3642bool FOOTPRINT::cmp_padstack::operator()(
const PAD* aFirst,
const PAD* aSecond )
const
3682 if( firstShape->VertexCount() != secondShape->VertexCount() )
3683 return firstShape->VertexCount() < secondShape->VertexCount();
3685 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3687 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3688 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3689 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3690 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3709 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3720 return aFirst < aSecond;
3725 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3726 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3727 bool aSkipNonPlatedPads )
const
3732 VECTOR2I clearance( aClearance, aClearance );
3737 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3740 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3746 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3749 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3756 clearance.
x +=
pad->GetSolderMaskExpansion( padLayer );
3757 clearance.
y +=
pad->GetSolderMaskExpansion( padLayer );
3762 clearance +=
pad->GetSolderPasteMargin( padLayer );
3775 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3776 &&
pad->GetShape( padLayer ) != PAD_SHAPE::CUSTOM )
3778 VECTOR2I dummySize =
pad->GetSize( padLayer ) + clearance + clearance;
3780 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3784 dummy.SetSize( padLayer, dummySize );
3785 dummy.TransformShapeToPolygon( aBuffer, padLayer, 0, aMaxError, aErrorLoc );
3789 pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.
x, aMaxError,
3796 if( !
pad->FlashLayer( aLayer ) )
3801 pad->Padstack().ForEachUniqueLayer(
3804 processPad(
pad, l );
3809 processPad(
pad, aLayer );
3816 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3817 bool aIncludeText,
bool aIncludeShapes,
3818 bool aIncludePrivateItems )
const
3820 std::vector<const PCB_TEXT*> texts;
3827 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3832 texts.push_back(
text );
3843 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3849 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3862 if( field->GetLayer() == aLayer && field->IsVisible() )
3863 texts.push_back( field );
3868 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3875 using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
3877 std::set<OUTLINE_FONT*>
fonts;
3883 if(
auto* font =
text->GetFont(); font && !font->IsStroke() )
3885 auto* outline =
static_cast<OUTLINE_FONT*
>( font );
3886 auto permission = outline->GetEmbeddingPermission();
3888 if( permission == EMBEDDING_PERMISSION::EDITABLE
3889 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3891 fonts.insert( outline );
3897 for(
auto* font :
fonts )
3912 return wxEmptyString;
3922 if( zcMap.
Choices().GetCount() == 0 )
3924 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3925 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3926 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3927 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3928 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3929 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3934 if( layerEnum.
Choices().GetCount() == 0 )
3942 wxPGChoices fpLayers;
3955 layer->SetChoices( fpLayers );
3960 PROPERTY_DISPLAY::PT_DEGREE ) );
3962 const wxString groupFields =
_HKI(
"Fields" );
3988 const wxString groupAttributes =
_HKI(
"Attributes" );
4002 const wxString groupOverrides =
_HKI(
"Overrides" );
4005 _HKI(
"Exempt From Courtyard Requirement" ),
4009 _HKI(
"Clearance Override" ),
4011 PROPERTY_DISPLAY::PT_SIZE ),
4014 _HKI(
"Solderpaste Margin Override" ),
4016 PROPERTY_DISPLAY::PT_SIZE ),
4019 _HKI(
"Solderpaste Margin Ratio Override" ),
4022 PROPERTY_DISPLAY::PT_RATIO ),
4025 _HKI(
"Zone Connection Style" ),
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
BITMAPS
A list of all bitmap identifiers.
#define DEFAULT_COURTYARD_WIDTH
BASE_SET & set(size_t pos)
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
PCB_GROUP * GetParentGroup() const
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
VECTOR2I GetFPRelativePosition() const
BOARD_ITEM_CONTAINER * GetParent() const
virtual bool IsOnCopperLayer() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Information pertinent to a Pcbnew printed circuit board.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
constexpr void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
constexpr coord_type GetTop() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
virtual int Accuracy() const =0
int GetCount() const
Return the number of objects in the list.
const wxString & GetFullName() const
Fetches the full name of this component class.
wxString GetName() const
Fetches the display name of this component class.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void ClearEditFlags()
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
virtual wxString GetClass() const =0
Return the class name.
EDA_ITEM_FLAGS GetFlags() const
const VECTOR2I & GetBezierC2() const
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
const VECTOR2I & GetBezierC1() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Loads a file from disk and adds it to the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
wxString m_Filename
The 3D shape filename in 3D library.
bool m_Show
Include model in rendering.
Used when the right click button is pressed, or when the select tool is in effect.
const COLLECTORS_GUIDE * GetGuide() const
Class OUTLINE_FONT implements outline font drawing.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
std::string AsStdString() const
wxString GetUniStringLibId() const
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET SideSpecificMask()
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
int GetDrillSizeY() const
PAD_ATTRIB GetAttribute() const
const wxString & GetNumber() const
VECTOR2I GetPosition() const override
int GetDrillSizeX() const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
const PADSTACK & Padstack() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
PAD_DRILL_SHAPE GetDrillShape() const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
std::optional< int > GetLocalSolderMaskMargin() const
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
virtual bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetWidth() const override
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
STROKE_PARAMS GetStroke() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
bool IsVisible() const override
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
PROPERTY_BASE & SetIsHiddenFromPropertiesManager(bool aHide=true)
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
double Area(bool aAbsolute=true) const
Return the area of this chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
void SetWidth(int aWidth)
Set the width of all segments in the chain.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
virtual void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
double Area()
Return the area of this poly set.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union For aFastMode meaning, see function booleanOp.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
int TotalVertices() const
Return total number of vertices stored in the set.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the reference to aHole-th hole in the aIndex-th outline.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both)
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Handle a list of polygons defining a copper zone.
SHAPE_POLY_SET * Outline()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
unsigned GetAssignedPriority() const
This file is part of the common library.
bool ConvertOutlineToPolygon(std::vector< PCB_SHAPE * > &aShapeList, SHAPE_POLY_SET &aPolygons, int aErrorMax, int aChainingEpsilon, bool aAllowDisjoint, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons)
Build a polygon set with holes from a PCB_SHAPE list.
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
@ DRCE_DRILLED_HOLES_TOO_CLOSE
@ DRCE_DRILLED_HOLES_COLOCATED
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_180
const INSPECTOR_FUNC & INSPECTOR
#define COURTYARD_CONFLICT
temporary set when moving footprints having courtyard overlapping
#define MALFORMED_F_COURTYARD
#define MALFORMED_B_COURTYARD
#define STRUCT_DELETED
flag indication structures to be erased
#define MALFORMED_COURTYARDS
@ FRAME_FOOTPRINT_CHOOSER
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Some functions to handle hotkeys in KiCad.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
@ LAYER_FOOTPRINTS_FR
show footprints on front
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
@ LAYER_FOOTPRINTS_BK
show footprints on back
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API VECTOR3D UnpackVector3D(const types::Vector3D &aInput)
KICOMMON_API LIB_ID LibIdFromProto(const types::LibraryIdentifier &aId)
KICOMMON_API types::LibraryIdentifier LibIdToProto(const LIB_ID &aId)
KICOMMON_API void PackVector3D(types::Vector3D &aOutput, const VECTOR3D &aInput)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Class to handle a set of BOARD_ITEMs.
#define NO_SETTER(owner, type)
Collection of utility functions for component reference designators (refdes)
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.
wxString UnescapeString(const wxString &aSource)
constexpr double IUTomm(int iu) const
constexpr int mmToIU(double mm) const
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ DESCRIPTION_FIELD
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I