26#include <magic_enum.hpp>
28#include <unordered_set>
62#include <google/protobuf/any.pb.h>
63#include <api/board/board_types.pb.h>
71 m_boundingBoxCacheTimeStamp( 0 ),
72 m_visibleBBoxCacheTimeStamp( 0 ),
73 m_textExcludedBBoxCacheTimeStamp( 0 ),
74 m_hullCacheTimeStamp( 0 ),
75 m_initial_comments( 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();
274 kiapi::board::types::FootprintInstance footprint;
277 footprint.mutable_position()->set_x_nm(
GetPosition().x );
278 footprint.mutable_position()->set_y_nm(
GetPosition().y );
280 footprint.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>(
GetLayer() ) );
281 footprint.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
282 : kiapi::common::types::LockedState::LS_UNLOCKED );
284 google::protobuf::Any buf;
286 buf.UnpackTo( footprint.mutable_reference_field() );
288 buf.UnpackTo( footprint.mutable_value_field() );
290 buf.UnpackTo( footprint.mutable_datasheet_field() );
292 buf.UnpackTo( footprint.mutable_description_field() );
294 kiapi::board::types::FootprintAttributes* attrs = footprint.mutable_attributes();
300 attrs->set_do_not_populate(
IsDNP() );
302 kiapi::board::types::Footprint* def = footprint.mutable_definition();
307 def->mutable_attributes()->set_keywords(
GetKeywords().ToStdString() );
311 kiapi::board::types::FootprintDesignRuleOverrides* overrides = def->mutable_overrides();
325 overrides->set_zone_connection(
331 kiapi::board::types::NetTieDefinition* netTie = def->add_net_ties();
332 wxStringTokenizer tokenizer(
group,
" " );
334 while( tokenizer.HasMoreTokens() )
335 netTie->add_pad_number( tokenizer.GetNextToken().ToStdString() );
340 def->add_private_layers(
341 ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
349 google::protobuf::Any* itemMsg = def->add_items();
350 item->Serialize( *itemMsg );
353 for(
const PAD* item :
Pads() )
355 google::protobuf::Any* itemMsg = def->add_items();
356 item->Serialize( *itemMsg );
361 google::protobuf::Any* itemMsg = def->add_items();
362 item->Serialize( *itemMsg );
367 google::protobuf::Any* itemMsg = def->add_items();
368 item->Serialize( *itemMsg );
373 aContainer.PackFrom( footprint );
379 kiapi::board::types::FootprintInstance footprint;
381 if( !aContainer.UnpackTo( &footprint ) )
387 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( footprint.layer() ) );
388 SetLocked( footprint.locked() == kiapi::common::types::LockedState::LS_LOCKED );
390 google::protobuf::Any buf;
391 kiapi::board::types::Field mandatoryField;
393 if( footprint.has_reference_field() )
395 mandatoryField = footprint.reference_field();
397 buf.PackFrom( mandatoryField );
401 if( footprint.has_value_field() )
403 mandatoryField = footprint.value_field();
404 mandatoryField.mutable_id()->set_id(
VALUE_FIELD );
405 buf.PackFrom( mandatoryField );
409 if( footprint.has_datasheet_field() )
411 mandatoryField = footprint.datasheet_field();
413 buf.PackFrom( mandatoryField );
417 if( footprint.has_description_field() )
419 mandatoryField = footprint.description_field();
421 buf.PackFrom( mandatoryField );
425 SetBoardOnly( footprint.attributes().not_in_schematic() );
429 SetDNP( footprint.attributes().do_not_populate() );
435 SetKeywords( footprint.definition().attributes().keywords() );
437 const kiapi::board::types::FootprintDesignRuleOverrides& overrides = footprint.overrides();
439 if( overrides.has_copper_clearance() )
444 if( overrides.has_solder_mask() && overrides.solder_mask().has_solder_mask_margin() )
449 if( overrides.has_solder_paste() )
451 const kiapi::board::types::SolderPasteOverrides& pasteSettings = overrides.solder_paste();
453 if( pasteSettings.has_solder_paste_margin() )
458 if( pasteSettings.has_solder_paste_margin_ratio() )
466 for(
const kiapi::board::types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
470 for(
const std::string&
pad : netTieMsg.pad_number() )
471 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
479 for(
int layerMsg : footprint.definition().private_layers() )
481 auto layer =
static_cast<kiapi::board::types::BoardLayer
>( layerMsg );
482 privateLayers.
set( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
500 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
509 if( item && item->Deserialize( itemMsg ) )
510 Add( item.release(), ADD_MODE::APPEND );
535 if( field->GetId() == aFieldId )
546 if( field->GetCanonicalName() == aFieldName )
555 if( aFieldName.empty() )
560 if( field->GetName() == aFieldName )
572 if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
573 return field->GetText();
576 return wxEmptyString;
586 if( !field->IsVisible() || field->GetText().IsEmpty() )
590 aVector.push_back( field );
608 if( aFieldName ==
m_fields[i]->GetName(
false ) )
628 switch( item->Type() )
638 if( aStyleShapes && !item->IsOnCopperLayer() )
653 std::vector< BOARD_ITEM* > item_list;
656 item_list.push_back( field );
659 item_list.push_back(
pad );
662 item_list.push_back( gr_item );
667 item_list.push_back(
group );
671 item_list.push_back( zone );
673 bool changed =
false;
679 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
692 m_pos = aOther.m_pos;
720 for(
PCB_FIELD* field : aOther.Fields() )
726 for(
PAD*
pad : aOther.Pads() )
729 aOther.Pads().clear();
734 for(
ZONE* item : aOther.Zones() )
742 item->SetNetCode( -1 );
745 aOther.Zones().clear();
750 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
753 aOther.GraphicalItems().clear();
761 aOther.Groups().clear();
772 aOther.Fields().clear();
773 aOther.Pads().clear();
774 aOther.Zones().clear();
775 aOther.GraphicalItems().clear();
776 aOther.m_initial_comments =
nullptr;
811 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
819 ptrMap[field] = newField;
829 ptrMap[
pad ] = newPad;
838 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
839 ptrMap[ zone ] = newZone;
855 ptrMap[ item ] = newItem;
868 newGroup->
AddItem( ptrMap[ member ] );
894 aVars->push_back( wxT(
"REFERENCE" ) );
895 aVars->push_back( wxT(
"VALUE" ) );
896 aVars->push_back( wxT(
"LAYER" ) );
897 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
898 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
899 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
900 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
901 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
902 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
911 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
916 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
921 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
926 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
931 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
936 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
937 || token->StartsWith( wxT(
"NET_NAME(" ) )
938 || token->StartsWith( wxT(
"NET_CLASS(" ) )
939 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
941 wxString padNumber = token->AfterFirst(
'(' );
942 padNumber = padNumber.BeforeLast(
')' );
946 if(
pad->GetNumber() == padNumber )
948 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
949 *token =
pad->GetShortNetname();
950 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
951 *token =
pad->GetNetname();
952 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
953 *token =
pad->GetNetClassVariableSubstitutionName();
955 *token =
pad->GetPinFunction();
985 switch( aBoardItem->
Type() )
1003 if( aMode == ADD_MODE::APPEND )
1010 if( aMode == ADD_MODE::APPEND )
1011 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
1013 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1017 if( aMode == ADD_MODE::APPEND )
1018 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1024 if( aMode == ADD_MODE::APPEND )
1033 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1034 aBoardItem->
Type() );
1048 switch( aBoardItem->
Type() )
1054 if( *it == aBoardItem )
1075 if( *it == aBoardItem )
1085 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1087 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1099 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1111 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1123 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1124 aBoardItem->
Type() );
1155 switch(
pad->GetProperty() )
1157 case PAD_PROP::FIDUCIAL_GLBL:
1158 case PAD_PROP::FIDUCIAL_LOCAL:
1161 case PAD_PROP::HEATSINK:
1162 case PAD_PROP::CASTELLATED:
1163 case PAD_PROP::MECHANICAL:
1166 case PAD_PROP::NONE:
1168 case PAD_PROP::TESTPOINT:
1172 switch(
pad->GetAttribute() )
1174 case PAD_ATTRIB::PTH:
1178 case PAD_ATTRIB::SMD:
1179 if(
pad->IsOnCopperLayer() )
1207 return _(
"Through hole" );
1209 return _(
"Other" );
1224 if(
dummy.IsFlipped() )
1228 bbox.
Merge(
pad->GetBoundingBox() );
1231 dummy.SetParent(
nullptr );
1232 dummy.SetParentGroup(
nullptr );
1265 if( aIncludeText && aIncludeInvisibleText )
1270 else if( aIncludeText )
1282 std::vector<PCB_TEXT*> texts;
1304 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1322 bbox.
Merge( item->GetBoundingBox() );
1328 if( !field->IsReference() && !field->IsValue() )
1329 texts.push_back( field );
1333 bbox.
Merge(
pad->GetBoundingBox() );
1336 bbox.
Merge( zone->GetBoundingBox() );
1341 if( aIncludeText || noDrawItems )
1350 if( aIncludeInvisibleText ||
text->IsVisible() )
1356 bool valueLayerIsVisible =
true;
1357 bool refLayerIsVisible =
true;
1375 if( (
Value().IsVisible() && valueLayerIsVisible )
1376 || aIncludeInvisibleText
1382 if( (
Reference().IsVisible() && refLayerIsVisible )
1383 || aIncludeInvisibleText
1392 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
1397 else if( aIncludeText )
1415 std::vector<PCB_TEXT*> texts;
1427 if( ( aLayers & item->GetLayerSet() ).none() )
1435 bbox.
Merge( item->GetBoundingBox() );
1440 if( ( aLayers &
pad->GetLayerSet() ).none() )
1443 bbox.
Merge(
pad->GetBoundingBox() );
1448 if( ( aLayers & zone->GetLayerSet() ).none() )
1451 bbox.
Merge( zone->GetBoundingBox() );
1497 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1524 std::vector<VECTOR2I> convex_hull;
1530 for(
const VECTOR2I& pt : convex_hull )
1554 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1556 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1558 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1561 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1570 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1571 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1575 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1577 if( !aStr->IsEmpty() )
1578 *aStr += wxT(
", " );
1587 addToken( &status,
_(
"Locked" ) );
1590 addToken( &status,
_(
"autoplaced" ) );
1593 addToken( &attrs,
_(
"not in schematic" ) );
1596 addToken( &attrs,
_(
"exclude from pos files" ) );
1599 addToken( &attrs,
_(
"exclude from BOM" ) );
1602 addToken( &attrs,
_(
"DNP" ) );
1604 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1606 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1610 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1612 aList.emplace_back( msg, msg2 );
1616 aList.emplace_back( msg, msg2 );
1624 if( board->IsFootprintHolder() )
1656 if(
pad->IsOnLayer( aLayer ) )
1662 if( zone->IsOnLayer( aLayer ) )
1668 if( field->IsOnLayer( aLayer ) )
1674 if( item->IsOnLayer( aLayer ) )
1686 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1692 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1698 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1699 && item->HitTest( aPosition, aAccuracy ) )
1711 std::vector<BOARD_ITEM*> items;
1715 if(
pad->IsOnLayer( aLayer ) )
1716 items.push_back(
pad );
1721 if( zone->IsOnLayer( aLayer ) )
1722 items.push_back( zone );
1727 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1728 items.push_back( item );
1737 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1739 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1746 return !items.empty() && aContained;
1765 BOX2I arect = aRect;
1785 if(
pad->HitTest( arect,
false, 0 ) )
1791 if( zone->HitTest( arect,
false, 0 ) )
1802 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1816 bool can_select = aSearchAfterMe ? false :
true;
1820 if( !can_select &&
pad == aSearchAfterMe )
1826 if( can_select &&
pad->GetNumber() == aPadNumber )
1839 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1842 if(
pad->HitTest( aPosition ) )
1852 std::vector<const PAD*> retv;
1856 if( ( aIgnore && aIgnore ==
pad ) || (
pad->GetNumber() != aPadNumber ) )
1859 retv.push_back(
pad );
1875 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1887 std::set<wxString> usedNumbers;
1899 if(
pad->GetNumber().IsEmpty() )
1905 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1909 usedNumbers.insert(
pad->GetNumber() );
1924 if(
nullptr == a3DModel )
1934 const std::vector<KICAD_T>& aScanTypes )
1936#if 0 && defined(DEBUG)
1937 std::cout <<
GetClass().mb_str() <<
' ';
1940 bool drawingsScanned =
false;
1942 for(
KICAD_T scanType : aScanTypes )
1947 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
1948 return INSPECT_RESULT::QUIT;
1953 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1954 == INSPECT_RESULT::QUIT )
1956 return INSPECT_RESULT::QUIT;
1962 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
1963 == INSPECT_RESULT::QUIT )
1965 return INSPECT_RESULT::QUIT;
1971 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
1972 == INSPECT_RESULT::QUIT )
1974 return INSPECT_RESULT::QUIT;
1989 if( !drawingsScanned )
1991 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
1992 == INSPECT_RESULT::QUIT )
1994 return INSPECT_RESULT::QUIT;
1997 drawingsScanned =
true;
2003 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
2004 == INSPECT_RESULT::QUIT )
2006 return INSPECT_RESULT::QUIT;
2016 return INSPECT_RESULT::CONTINUE;
2024 if( reference.IsEmpty() )
2025 reference =
_(
"<no reference designator>" );
2027 return wxString::Format(
_(
"Footprint %s" ), reference );
2033 return BITMAPS::module;
2060 aFunction( drawing );
2062 catch( std::bad_function_call& )
2064 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2090 group->RunOnDescendants( aFunction, aDepth + 1 );
2095 aFunction( drawing );
2096 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2099 catch( std::bad_function_call& )
2101 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2114 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2135 bool f_silk =
false, b_silk =
false, non_silk =
false;
2139 if( item->GetLayer() ==
F_SilkS )
2141 else if( item->GetLayer() ==
B_SilkS )
2147 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2150 aLayers[ aCount++ ] =
F_SilkS;
2153 aLayers[ aCount++ ] =
B_SilkS;
2169 return std::numeric_limits<double>::max();
2181 return std::numeric_limits<double>::max();
2190 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
2195 return std::numeric_limits<double>::max();
2206 int biggest_clearance = board->GetMaxClearanceValue();
2207 area.
Inflate( biggest_clearance );
2218 if( aName.find_first_of( invalids ) != std::string::npos )
2232 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2233 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2236 return invalidCharsReadable;
2238 return invalidChars;
2244 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2258 EDA_ANGLE newOrientation = orientation + aAngle;
2265 field->KeepUpright();
2270 static_cast<PCB_TEXT*
>( item )->KeepUpright();
2282 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2317 field->Flip(
m_pos,
false );
2328 zone->Flip(
m_pos,
false );
2332 item->Flip(
m_pos,
false );
2335 if( aFlipLeftRight )
2355 field->EDA_TEXT::Offset(
delta );
2361 zone->Move(
delta );
2364 item->Move(
delta );
2392 field->Move( moveVector );
2396 pad->Move( moveVector );
2400 item->Move( moveVector );
2404 zone->Move( moveVector );
2464 switch( aItem->
Type() )
2468 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2471 if( aAddToFootprint )
2472 m_pads.push_back( new_pad );
2480 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2483 if( aAddToFootprint )
2484 m_zones.push_back( new_zone );
2486 new_item = new_zone;
2510 if( aAddToFootprint )
2513 new_item = new_text;
2522 if( aAddToFootprint )
2525 new_item = new_shape;
2534 if( aAddToFootprint )
2537 new_item = new_textbox;
2549 if( aAddToFootprint )
2552 new_item = dimension;
2560 if( aAddToFootprint )
2562 group->RunOnDescendants(
2581 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2591 std::set<wxString> usedNumbers;
2595 usedNumbers.insert(
pad->GetNumber() );
2602 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2605 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2656 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2660 return aPolySet.
Area();
2675 return markerShape.
Area();
2679 double combinedArea = 0.0;
2684 return combinedArea;
2714 case SHAPE_T::SEGMENT:
2716 case SHAPE_T::BEZIER:
2719 case SHAPE_T::RECTANGLE:
2720 case SHAPE_T::CIRCLE:
2735 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2736 return width * width;
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() ) )
3145 SHAPE* padShape =
pad->GetEffectiveShape().get();
3146 SHAPE* otherShape = other->GetEffectiveShape().get();
3148 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3160 const VECTOR2I& )>& aErrorHandler )
3169 std::vector<BOARD_ITEM*> copperItems;
3173 if( item->IsOnCopperLayer() )
3174 copperItems.push_back( item );
3176 item->RunOnDescendants(
3180 copperItems.push_back( descendent );
3186 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3187 copperItems.push_back( zone );
3192 if( field->IsOnCopperLayer() )
3193 copperItems.push_back( field );
3203 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3207 if( item->IsOnLayer( layer ) )
3209 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3220 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3222 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3223 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3230 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3232 if( pads.size() > 1 )
3234 const PAD* firstPad = pads[0];
3235 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3237 for(
size_t ii = 1; ii < pads.size(); ++ii )
3239 const PAD* thisPad = pads[ii];
3240 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3242 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3251 if( item->HitTest( pos, 1 ) )
3253 shortingItem = item;
3259 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3261 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3272 std::set<wxString> padNumbers;
3281 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3282 aErrorHandler( msg );
3284 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3286 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3287 aErrorHandler( msg );
3299 std::swap( *
this, *
image );
3307 image->RunOnChildren(
3319 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3334 return *
this == other;
3343 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3352 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3361 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3370 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3387 double similarity = 1.0;
3396 similarity *=
pad->Similarity( *otherPad );
3405 if( itemA->
Type() != itemB->
Type() )
3406 return itemA->
Type() < itemB->
Type();
3421 if( dwgA->
GetShape() != SHAPE_T::POLY )
3434 if( dwgA->
GetShape() == SHAPE_T::ARC )
3441 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3453 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3476 return itemA < itemB;
3504 return aFirst < aSecond;
3548 if( firstShape->VertexCount() != secondShape->VertexCount() )
3549 return firstShape->VertexCount() < secondShape->VertexCount();
3551 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3553 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3554 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3555 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3556 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3574 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3585 return aFirst < aSecond;
3590 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3591 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3592 bool aSkipNonPlatedPads )
const
3596 if( !
pad->FlashLayer( aLayer ) )
3599 VECTOR2I clearance( aClearance, aClearance );
3604 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3607 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3613 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3616 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3623 clearance.
x +=
pad->GetSolderMaskExpansion();
3624 clearance.
y +=
pad->GetSolderMaskExpansion();
3629 clearance +=
pad->GetSolderPasteMargin();
3642 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3643 &&
pad->GetShape() != PAD_SHAPE::CUSTOM )
3645 VECTOR2I dummySize =
pad->GetSize() + clearance + clearance;
3647 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3651 dummy.SetSize( dummySize );
3652 dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
3656 pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.
x, aMaxError, aErrorLoc );
3663 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3664 bool aIncludeText,
bool aIncludeShapes,
3665 bool aIncludePrivateItems )
const
3667 std::vector<const PCB_TEXT*> texts;
3674 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3679 texts.push_back(
text );
3690 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3696 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3709 if( field->GetLayer() == aLayer && field->IsVisible() )
3710 texts.push_back( field );
3715 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3722 using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
3724 std::set<OUTLINE_FONT*>
fonts;
3730 if(
auto* font =
text->GetFont(); font && !font->IsStroke() )
3732 auto* outline =
static_cast<OUTLINE_FONT*
>( font );
3733 auto permission = outline->GetEmbeddingPermission();
3735 if( permission == EMBEDDING_PERMISSION::EDITABLE
3736 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3738 fonts.insert( outline );
3744 for(
auto* font :
fonts )
3758 if( zcMap.
Choices().GetCount() == 0 )
3760 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3761 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3762 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3763 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3764 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3765 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3770 if( layerEnum.
Choices().GetCount() == 0 )
3778 wxPGChoices fpLayers;
3791 layer->SetChoices( fpLayers );
3796 PROPERTY_DISPLAY::PT_DEGREE ) );
3798 const wxString groupFields =
_HKI(
"Fields" );
3817 const wxString groupAttributes =
_HKI(
"Attributes" );
3831 const wxString groupOverrides =
_HKI(
"Overrides" );
3834 _HKI(
"Exempt From Courtyard Requirement" ),
3838 _HKI(
"Clearance Override" ),
3840 PROPERTY_DISPLAY::PT_SIZE ),
3843 _HKI(
"Solderpaste Margin Override" ),
3845 PROPERTY_DISPLAY::PT_SIZE ),
3848 _HKI(
"Solderpaste Margin Ratio Override" ),
3851 PROPERTY_DISPLAY::PT_RATIO ),
3854 _HKI(
"Zone Connection Style" ),
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
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=std::numeric_limits< size_t >::max(), bool value=true)
bool test(size_t pos) const
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
size_type GetHeight() const
const Vec GetCenter() const
bool Intersects(const BOX2< Vec > &aRect) const
coord_type GetTop() const
size_type GetWidth() const
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
coord_type GetBottom() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
virtual int Accuracy() const =0
int GetCount() const
Return the number of objects in the list.
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()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET SideSpecificMask()
static const wxChar * 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...
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
int GetSolderMaskExpansion() const
int GetDrillSizeY() const
PAD_ATTRIB GetAttribute() const
const wxString & GetNumber() const
VECTOR2I GetPosition() const override
int GetDrillSizeX() const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
PAD_DRILL_SHAPE GetDrillShape() const
VECTOR2I GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
std::optional< int > GetLocalSolderMaskMargin() const
const VECTOR2I & GetSize() 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.
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.
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...
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
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.
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
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
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 ...
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.