26#include <magic_enum.hpp>
28#include <unordered_set>
61#include <google/protobuf/any.pb.h>
62#include <api/board/board_types.pb.h>
70 m_boundingBoxCacheTimeStamp( 0 ),
71 m_textExcludedBBoxCacheTimeStamp( 0 ),
72 m_hullCacheTimeStamp( 0 ),
73 m_initial_comments( nullptr ),
74 m_componentClass( nullptr )
144 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
150 ptrMap[field] = newField;
151 Add( newField, ADD_MODE::APPEND );
157 PAD* newPad =
static_cast<PAD*
>(
pad->Clone() );
158 ptrMap[
pad ] = newPad;
159 Add( newPad, ADD_MODE::APPEND );
165 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
166 ptrMap[ zone ] = newZone;
167 Add( newZone, ADD_MODE::APPEND );
180 ptrMap[ item ] = newItem;
181 Add( newItem, ADD_MODE::APPEND );
188 ptrMap[
group ] = newGroup;
189 Add( newGroup, ADD_MODE::APPEND );
201 if( ptrMap.count( member ) )
202 newGroup->
AddItem( ptrMap[ member ] );
225 *
this = std::move( aFootprint );
235 item->SetParentGroup(
nullptr );
267 board->IncrementTimeStamp();
273 kiapi::board::types::FootprintInstance footprint;
276 footprint.mutable_position()->set_x_nm(
GetPosition().x );
277 footprint.mutable_position()->set_y_nm(
GetPosition().y );
279 footprint.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>(
GetLayer() ) );
280 footprint.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
281 : kiapi::common::types::LockedState::LS_UNLOCKED );
283 google::protobuf::Any buf;
285 buf.UnpackTo( footprint.mutable_reference_field() );
287 buf.UnpackTo( footprint.mutable_value_field() );
289 buf.UnpackTo( footprint.mutable_datasheet_field() );
291 buf.UnpackTo( footprint.mutable_description_field() );
293 kiapi::board::types::FootprintAttributes* attrs = footprint.mutable_attributes();
299 attrs->set_do_not_populate(
IsDNP() );
301 kiapi::board::types::Footprint* def = footprint.mutable_definition();
306 def->mutable_attributes()->set_keywords(
GetKeywords().ToStdString() );
310 kiapi::board::types::FootprintDesignRuleOverrides* overrides = def->mutable_overrides();
324 overrides->set_zone_connection(
330 kiapi::board::types::NetTieDefinition* netTie = def->add_net_ties();
331 wxStringTokenizer tokenizer(
group,
" " );
333 while( tokenizer.HasMoreTokens() )
334 netTie->add_pad_number( tokenizer.GetNextToken().ToStdString() );
339 def->add_private_layers(
340 ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
348 google::protobuf::Any* itemMsg = def->add_items();
349 item->Serialize( *itemMsg );
352 for(
const PAD* item :
Pads() )
354 google::protobuf::Any* itemMsg = def->add_items();
355 item->Serialize( *itemMsg );
360 google::protobuf::Any* itemMsg = def->add_items();
361 item->Serialize( *itemMsg );
366 google::protobuf::Any* itemMsg = def->add_items();
367 item->Serialize( *itemMsg );
372 aContainer.PackFrom( footprint );
378 kiapi::board::types::FootprintInstance footprint;
380 if( !aContainer.UnpackTo( &footprint ) )
386 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( footprint.layer() ) );
387 SetLocked( footprint.locked() == kiapi::common::types::LockedState::LS_LOCKED );
389 google::protobuf::Any buf;
390 kiapi::board::types::Field mandatoryField;
392 if( footprint.has_reference_field() )
394 mandatoryField = footprint.reference_field();
396 buf.PackFrom( mandatoryField );
400 if( footprint.has_value_field() )
402 mandatoryField = footprint.value_field();
403 mandatoryField.mutable_id()->set_id(
VALUE_FIELD );
404 buf.PackFrom( mandatoryField );
408 if( footprint.has_datasheet_field() )
410 mandatoryField = footprint.datasheet_field();
412 buf.PackFrom( mandatoryField );
416 if( footprint.has_description_field() )
418 mandatoryField = footprint.description_field();
420 buf.PackFrom( mandatoryField );
424 SetBoardOnly( footprint.attributes().not_in_schematic() );
428 SetDNP( footprint.attributes().do_not_populate() );
434 SetKeywords( footprint.definition().attributes().keywords() );
436 const kiapi::board::types::FootprintDesignRuleOverrides& overrides = footprint.overrides();
438 if( overrides.has_copper_clearance() )
443 if( overrides.has_solder_mask() && overrides.solder_mask().has_solder_mask_margin() )
448 if( overrides.has_solder_paste() )
450 const kiapi::board::types::SolderPasteOverrides& pasteSettings = overrides.solder_paste();
452 if( pasteSettings.has_solder_paste_margin() )
457 if( pasteSettings.has_solder_paste_margin_ratio() )
465 for(
const kiapi::board::types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
469 for(
const std::string&
pad : netTieMsg.pad_number() )
470 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
478 for(
int layerMsg : footprint.definition().private_layers() )
480 auto layer =
static_cast<kiapi::board::types::BoardLayer
>( layerMsg );
481 privateLayers.
set( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
499 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
508 if( item && item->Deserialize( itemMsg ) )
509 Add( item.release(), ADD_MODE::APPEND );
534 if( field->GetId() == aFieldId )
545 if( field->GetCanonicalName() == aFieldName )
554 if( aFieldName.empty() )
559 if( field->GetName() == aFieldName )
571 if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
572 return field->GetText();
575 return wxEmptyString;
585 if( !field->IsVisible() || field->GetText().IsEmpty() )
589 aVector.push_back( field );
607 if( aFieldName ==
m_fields[i]->GetName(
false ) )
627 switch( item->Type() )
637 if( aStyleShapes && !item->IsOnCopperLayer() )
652 std::vector< BOARD_ITEM* > item_list;
655 item_list.push_back( field );
658 item_list.push_back(
pad );
661 item_list.push_back( gr_item );
666 item_list.push_back(
group );
670 item_list.push_back( zone );
672 bool changed =
false;
678 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
691 m_pos = aOther.m_pos;
719 for(
PCB_FIELD* field : aOther.Fields() )
725 for(
PAD*
pad : aOther.Pads() )
728 aOther.Pads().clear();
733 for(
ZONE* item : aOther.Zones() )
741 item->SetNetCode( -1 );
744 aOther.Zones().clear();
749 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
752 aOther.GraphicalItems().clear();
760 aOther.Groups().clear();
771 aOther.Fields().clear();
772 aOther.Pads().clear();
773 aOther.Zones().clear();
774 aOther.GraphicalItems().clear();
775 aOther.m_initial_comments =
nullptr;
810 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
818 ptrMap[field] = newField;
828 ptrMap[
pad ] = newPad;
837 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
838 ptrMap[ zone ] = newZone;
854 ptrMap[ item ] = newItem;
867 newGroup->
AddItem( ptrMap[ member ] );
893 aVars->push_back( wxT(
"REFERENCE" ) );
894 aVars->push_back( wxT(
"VALUE" ) );
895 aVars->push_back( wxT(
"LAYER" ) );
896 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
897 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
898 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
899 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
900 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
901 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
910 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
915 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
920 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
925 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
930 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
935 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
936 || token->StartsWith( wxT(
"NET_NAME(" ) )
937 || token->StartsWith( wxT(
"NET_CLASS(" ) )
938 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
940 wxString padNumber = token->AfterFirst(
'(' );
941 padNumber = padNumber.BeforeLast(
')' );
945 if(
pad->GetNumber() == padNumber )
947 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
948 *token =
pad->GetShortNetname();
949 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
950 *token =
pad->GetNetname();
951 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
952 *token =
pad->GetNetClassVariableSubstitutionName();
954 *token =
pad->GetPinFunction();
984 switch( aBoardItem->
Type() )
1002 if( aMode == ADD_MODE::APPEND )
1009 if( aMode == ADD_MODE::APPEND )
1010 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
1012 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1016 if( aMode == ADD_MODE::APPEND )
1017 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1023 if( aMode == ADD_MODE::APPEND )
1032 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1033 aBoardItem->
Type() );
1047 switch( aBoardItem->
Type() )
1053 if( *it == aBoardItem )
1074 if( *it == aBoardItem )
1084 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1086 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1098 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1110 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1122 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1123 aBoardItem->
Type() );
1154 switch(
pad->GetProperty() )
1156 case PAD_PROP::FIDUCIAL_GLBL:
1157 case PAD_PROP::FIDUCIAL_LOCAL:
1160 case PAD_PROP::HEATSINK:
1161 case PAD_PROP::CASTELLATED:
1162 case PAD_PROP::MECHANICAL:
1165 case PAD_PROP::NONE:
1167 case PAD_PROP::TESTPOINT:
1171 switch(
pad->GetAttribute() )
1173 case PAD_ATTRIB::PTH:
1177 case PAD_ATTRIB::SMD:
1178 if(
pad->IsOnCopperLayer() )
1206 return _(
"Through hole" );
1208 return _(
"Other" );
1223 if(
dummy.IsFlipped() )
1227 bbox.
Merge(
pad->GetBoundingBox() );
1230 dummy.SetParent(
nullptr );
1231 dummy.SetParentGroup(
nullptr );
1276 std::vector<PCB_TEXT*> texts;
1298 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1316 bbox.
Merge( item->GetBoundingBox() );
1322 if( !field->IsReference() && !field->IsValue() )
1323 texts.push_back( field );
1327 bbox.
Merge(
pad->GetBoundingBox() );
1330 bbox.
Merge( zone->GetBoundingBox() );
1335 if( aIncludeText || noDrawItems )
1344 if(
text->IsVisible() )
1350 bool valueLayerIsVisible =
true;
1351 bool refLayerIsVisible =
true;
1369 if( (
Value().IsVisible() && valueLayerIsVisible ) || noDrawItems )
1374 if( (
Reference().IsVisible() && refLayerIsVisible ) || noDrawItems )
1382 if( aIncludeText || noDrawItems )
1400 std::vector<PCB_TEXT*> texts;
1412 if( ( aLayers & item->GetLayerSet() ).none() )
1420 bbox.
Merge( item->GetBoundingBox() );
1425 if( ( aLayers &
pad->GetLayerSet() ).none() )
1428 bbox.
Merge(
pad->GetBoundingBox() );
1433 if( ( aLayers & zone->GetLayerSet() ).none() )
1436 bbox.
Merge( zone->GetBoundingBox() );
1473 pad->Padstack().ForEachUniqueLayer(
1487 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1514 std::vector<VECTOR2I> convex_hull;
1520 for(
const VECTOR2I& pt : convex_hull )
1544 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1546 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1548 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1551 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1560 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1561 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1565 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1567 if( !aStr->IsEmpty() )
1568 *aStr += wxT(
", " );
1577 addToken( &status,
_(
"Locked" ) );
1580 addToken( &status,
_(
"autoplaced" ) );
1583 addToken( &attrs,
_(
"not in schematic" ) );
1586 addToken( &attrs,
_(
"exclude from pos files" ) );
1589 addToken( &attrs,
_(
"exclude from BOM" ) );
1592 addToken( &attrs,
_(
"DNP" ) );
1594 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1596 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1605 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1607 aList.emplace_back( msg, msg2 );
1611 aList.emplace_back( msg, msg2 );
1619 if( board->IsFootprintHolder() )
1651 if(
pad->IsOnLayer( aLayer ) )
1657 if( zone->IsOnLayer( aLayer ) )
1663 if( field->IsOnLayer( aLayer ) )
1669 if( item->IsOnLayer( aLayer ) )
1681 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1687 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1693 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1694 && item->HitTest( aPosition, aAccuracy ) )
1706 std::vector<BOARD_ITEM*> items;
1710 if(
pad->IsOnLayer( aLayer ) )
1711 items.push_back(
pad );
1716 if( zone->IsOnLayer( aLayer ) )
1717 items.push_back( zone );
1722 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1723 items.push_back( item );
1732 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1734 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1741 return !items.empty() && aContained;
1760 BOX2I arect = aRect;
1780 if(
pad->HitTest( arect,
false, 0 ) )
1786 if( zone->HitTest( arect,
false, 0 ) )
1797 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1811 bool can_select = aSearchAfterMe ? false :
true;
1815 if( !can_select &&
pad == aSearchAfterMe )
1821 if( can_select &&
pad->GetNumber() == aPadNumber )
1834 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1837 if(
pad->HitTest( aPosition ) )
1847 std::vector<const PAD*> retv;
1851 if( ( aIgnore && aIgnore ==
pad ) || (
pad->GetNumber() != aPadNumber ) )
1854 retv.push_back(
pad );
1870 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1882 std::set<wxString> usedNumbers;
1894 if(
pad->GetNumber().IsEmpty() )
1900 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1904 usedNumbers.insert(
pad->GetNumber() );
1919 if(
nullptr == a3DModel )
1929 const std::vector<KICAD_T>& aScanTypes )
1931#if 0 && defined(DEBUG)
1932 std::cout <<
GetClass().mb_str() <<
' ';
1935 bool drawingsScanned =
false;
1937 for(
KICAD_T scanType : aScanTypes )
1942 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
1943 return INSPECT_RESULT::QUIT;
1948 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1949 == INSPECT_RESULT::QUIT )
1951 return INSPECT_RESULT::QUIT;
1957 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
1958 == INSPECT_RESULT::QUIT )
1960 return INSPECT_RESULT::QUIT;
1966 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
1967 == INSPECT_RESULT::QUIT )
1969 return INSPECT_RESULT::QUIT;
1984 if( !drawingsScanned )
1986 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
1987 == INSPECT_RESULT::QUIT )
1989 return INSPECT_RESULT::QUIT;
1992 drawingsScanned =
true;
1998 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
1999 == INSPECT_RESULT::QUIT )
2001 return INSPECT_RESULT::QUIT;
2011 return INSPECT_RESULT::CONTINUE;
2019 if( reference.IsEmpty() )
2020 reference =
_(
"<no reference designator>" );
2022 return wxString::Format(
_(
"Footprint %s" ), reference );
2028 return BITMAPS::module;
2055 aFunction( drawing );
2057 catch( std::bad_function_call& )
2059 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2085 group->RunOnDescendants( aFunction, aDepth + 1 );
2090 aFunction( drawing );
2091 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2094 catch( std::bad_function_call& )
2096 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2109 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2130 bool f_silk =
false, b_silk =
false, non_silk =
false;
2134 if( item->GetLayer() ==
F_SilkS )
2136 else if( item->GetLayer() ==
B_SilkS )
2142 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2145 aLayers[ aCount++ ] =
F_SilkS;
2148 aLayers[ aCount++ ] =
B_SilkS;
2164 return std::numeric_limits<double>::max();
2176 return std::numeric_limits<double>::max();
2185 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
2190 return std::numeric_limits<double>::max();
2201 int biggest_clearance = board->GetMaxClearanceValue();
2202 area.
Inflate( biggest_clearance );
2213 if( aName.find_first_of( invalids ) != std::string::npos )
2227 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2228 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2231 return invalidCharsReadable;
2233 return invalidChars;
2239 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2253 EDA_ANGLE newOrientation = orientation + aAngle;
2260 field->KeepUpright();
2265 static_cast<PCB_TEXT*
>( item )->KeepUpright();
2276 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2311 field->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2315 pad->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2322 zone->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2326 item->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2329 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
2348 field->EDA_TEXT::Offset(
delta );
2354 zone->Move(
delta );
2357 item->Move(
delta );
2384 field->Move( moveVector );
2388 pad->Move( moveVector );
2392 item->Move( moveVector );
2396 zone->Move( moveVector );
2454 switch( aItem->
Type() )
2458 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2461 if( aAddToFootprint )
2462 m_pads.push_back( new_pad );
2470 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2473 if( aAddToFootprint )
2474 m_zones.push_back( new_zone );
2476 new_item = new_zone;
2500 if( aAddToFootprint )
2503 new_item = new_text;
2512 if( aAddToFootprint )
2515 new_item = new_shape;
2524 if( aAddToFootprint )
2527 new_item = new_textbox;
2539 if( aAddToFootprint )
2542 new_item = dimension;
2550 if( aAddToFootprint )
2552 group->RunOnDescendants(
2571 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2581 std::set<wxString> usedNumbers;
2585 usedNumbers.insert(
pad->GetNumber() );
2592 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2595 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2646 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2650 return aPolySet.
Area();
2665 return markerShape.
Area();
2669 double combinedArea = 0.0;
2674 return combinedArea;
2704 case SHAPE_T::SEGMENT:
2706 case SHAPE_T::BEZIER:
2709 case SHAPE_T::RECTANGLE:
2710 case SHAPE_T::CIRCLE:
2725 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2726 return width * width;
2730 static_cast<const PAD*
>( aItem )->Padstack().ForEachUniqueLayer(
2762 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2766 switch( item->
Type() )
2797 double footprintRegionArea =
polygonArea( footprintRegion );
2798 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2799 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2800 double ratio = ( coveredArea / footprintRegionArea );
2807 return std::min( ratio, 1.0 );
2813 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2834 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2839 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2879 std::vector<PCB_SHAPE*> list_front;
2880 std::vector<PCB_SHAPE*> list_back;
2881 std::map<int, int> front_width_histogram;
2882 std::map<int, int> back_width_histogram;
2889 list_back.push_back( shape );
2896 list_front.push_back( shape );
2901 if( !list_front.size() && !list_back.size() )
2908 true, aErrorHandler ) )
2918 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
2919 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2921 return a.second < b.second;
2924 if( max != front_width_histogram.end() )
2947 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
2948 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2950 return a.second < b.second;
2953 if( max != back_width_histogram.end() )
2974 std::map<wxString, int> padNumberToGroupIdxMap;
2977 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
2980 [&]( wxString aPad,
int aGroup )
2982 aPad.Trim(
true ).Trim(
false );
2984 if( !aPad.IsEmpty() )
2985 padNumberToGroupIdxMap[ aPad ] = aGroup;
2994 for( wxUniCharRef ch :
group )
3003 switch(
static_cast<unsigned char>( ch ) )
3010 processPad(
pad, ii );
3020 processPad(
pad, ii );
3023 return padNumberToGroupIdxMap;
3033 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
3034 std::vector<PAD*> otherPads;
3040 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
3041 otherPads.push_back(
pad );
3054 if( setAttr && likelyAttr && setAttr != likelyAttr )
3058 switch( likelyAttr )
3061 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3064 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3069 (aErrorHandler)( msg );
3075 const std::function<
void(
const PAD*,
int,
3076 const wxString& )>& aErrorHandler )
3078 if( aErrorHandler ==
nullptr )
3083 pad->CheckPad( aUnitsProvider,
3084 [&](
int errorCode,
const wxString& msg )
3086 aErrorHandler(
pad, errorCode, msg );
3094 const VECTOR2I& )>& aErrorHandler )
3096 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3111 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3114 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3116 checkedPairs[ { a, b } ] = 1;
3118 if(
pad->HasDrilledHole() && other->HasDrilledHole() )
3122 if(
pad->GetPosition() == other->GetPosition() )
3128 std::shared_ptr<SHAPE_SEGMENT> holeA =
pad->GetEffectiveHoleShape();
3129 std::shared_ptr<SHAPE_SEGMENT> holeB = other->GetEffectiveHoleShape();
3131 if( holeA->Collide( holeB->GetSeg(), 0 ) )
3142 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3146 for(
PCB_LAYER_ID l :
pad->Padstack().RelevantShapeLayers( other->Padstack() ) )
3148 SHAPE* padShape =
pad->GetEffectiveShape( l ).get();
3149 SHAPE* otherShape = other->GetEffectiveShape( l ).get();
3151 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3164 const VECTOR2I& )>& aErrorHandler )
3173 std::vector<BOARD_ITEM*> copperItems;
3177 if( item->IsOnCopperLayer() )
3178 copperItems.push_back( item );
3180 item->RunOnDescendants(
3184 copperItems.push_back( descendent );
3190 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3191 copperItems.push_back( zone );
3196 if( field->IsOnCopperLayer() )
3197 copperItems.push_back( field );
3207 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3211 if( item->IsOnLayer( layer ) )
3213 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3224 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3226 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3227 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3234 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3236 if( pads.size() > 1 )
3238 const PAD* firstPad = pads[0];
3239 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3241 for(
size_t ii = 1; ii < pads.size(); ++ii )
3243 const PAD* thisPad = pads[ii];
3244 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3246 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3255 if( item->HitTest( pos, 1 ) )
3257 shortingItem = item;
3263 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3265 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3276 std::set<wxString> padNumbers;
3285 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3286 aErrorHandler( msg );
3288 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3290 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3291 aErrorHandler( msg );
3303 std::swap( *
this, *
image );
3311 image->RunOnChildren(
3323 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3338 return *
this == other;
3347 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3356 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3365 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3374 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3391 double similarity = 1.0;
3400 similarity *=
pad->Similarity( *otherPad );
3409 if( itemA->
Type() != itemB->
Type() )
3410 return itemA->
Type() < itemB->
Type();
3425 if( dwgA->
GetShape() != SHAPE_T::POLY )
3438 if( dwgA->
GetShape() == SHAPE_T::ARC )
3445 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3457 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3480 return itemA < itemB;
3494 std::optional<bool> padCopperMatches;
3497 const PAD* checkPad = aFirst;
3510 padCopperMatches = aFirst->
GetSize( aLayer ).
x < aSecond->
GetSize( aLayer ).
x;
3512 padCopperMatches = aFirst->
GetSize( aLayer ).
y < aSecond->
GetSize( aLayer ).
y;
3514 padCopperMatches = aFirst->
GetShape( aLayer ) < aSecond->
GetShape( aLayer );
3517 if( padCopperMatches.has_value() )
3518 return *padCopperMatches;
3526 return aFirst < aSecond;
3531bool FOOTPRINT::cmp_padstack::operator()(
const PAD* aFirst,
const PAD* aSecond )
const
3571 if( firstShape->VertexCount() != secondShape->VertexCount() )
3572 return firstShape->VertexCount() < secondShape->VertexCount();
3574 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3576 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3577 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3578 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3579 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3598 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3609 return aFirst < aSecond;
3614 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3615 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3616 bool aSkipNonPlatedPads )
const
3621 VECTOR2I clearance( aClearance, aClearance );
3626 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3629 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3635 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3638 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3645 clearance.
x +=
pad->GetSolderMaskExpansion( padLayer );
3646 clearance.
y +=
pad->GetSolderMaskExpansion( padLayer );
3651 clearance +=
pad->GetSolderPasteMargin( padLayer );
3664 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3665 &&
pad->GetShape( padLayer ) != PAD_SHAPE::CUSTOM )
3667 VECTOR2I dummySize =
pad->GetSize( padLayer ) + clearance + clearance;
3669 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3673 dummy.SetSize( padLayer, dummySize );
3674 dummy.TransformShapeToPolygon( aBuffer, padLayer, 0, aMaxError, aErrorLoc );
3678 pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.
x, aMaxError,
3685 if( !
pad->FlashLayer( aLayer ) )
3690 pad->Padstack().ForEachUniqueLayer(
3693 processPad(
pad, l );
3698 processPad(
pad, aLayer );
3705 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3706 bool aIncludeText,
bool aIncludeShapes,
3707 bool aIncludePrivateItems )
const
3709 std::vector<const PCB_TEXT*> texts;
3716 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3721 texts.push_back(
text );
3732 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3738 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3751 if( field->GetLayer() == aLayer && field->IsVisible() )
3752 texts.push_back( field );
3757 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3764 using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
3766 std::set<OUTLINE_FONT*>
fonts;
3772 if(
auto* font =
text->GetFont(); font && !font->IsStroke() )
3774 auto* outline =
static_cast<OUTLINE_FONT*
>( font );
3775 auto permission = outline->GetEmbeddingPermission();
3777 if( permission == EMBEDDING_PERMISSION::EDITABLE
3778 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3780 fonts.insert( outline );
3786 for(
auto* font :
fonts )
3801 return wxEmptyString;
3811 if( zcMap.
Choices().GetCount() == 0 )
3813 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3814 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3815 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3816 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3817 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3818 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3823 if( layerEnum.
Choices().GetCount() == 0 )
3831 wxPGChoices fpLayers;
3844 layer->SetChoices( fpLayers );
3849 PROPERTY_DISPLAY::PT_DEGREE ) );
3851 const wxString groupFields =
_HKI(
"Fields" );
3877 const wxString groupAttributes =
_HKI(
"Attributes" );
3891 const wxString groupOverrides =
_HKI(
"Overrides" );
3894 _HKI(
"Exempt From Courtyard Requirement" ),
3898 _HKI(
"Clearance Override" ),
3900 PROPERTY_DISPLAY::PT_SIZE ),
3903 _HKI(
"Solderpaste Margin Override" ),
3905 PROPERTY_DISPLAY::PT_SIZE ),
3908 _HKI(
"Solderpaste Margin Ratio Override" ),
3911 PROPERTY_DISPLAY::PT_RATIO ),
3914 _HKI(
"Zone Connection Style" ),
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
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)
wxString m_Filename
The 3D shape filename in 3D library.
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
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.
std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
types::LibraryIdentifier LibIdToProto(const LIB_ID &aId)
LIB_ID LibIdFromProto(const types::LibraryIdentifier &aId)
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
ZONE_CONNECTION
How pads are covered by copper in zone.