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::DesignRuleOverrides* 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::DesignRuleOverrides& overrides = footprint.overrides();
439 if( overrides.has_clearance() )
444 if( overrides.has_solder_mask_margin() )
449 if( overrides.has_solder_paste_margin() )
454 if( overrides.has_solder_paste_margin_ratio() )
461 for(
const kiapi::board::types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
465 for(
const std::string&
pad : netTieMsg.pad_number() )
466 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
474 for(
int layerMsg : footprint.definition().private_layers() )
476 auto layer =
static_cast<kiapi::board::types::BoardLayer
>( layerMsg );
477 privateLayers.
set( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
495 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
504 if( item && item->Deserialize( itemMsg ) )
505 Add( item.release(), ADD_MODE::APPEND );
530 if( field->GetId() == aFieldId )
541 if( field->GetCanonicalName() == aFieldName )
550 if( aFieldName.empty() )
555 if( field->GetName() == aFieldName )
567 if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
568 return field->GetText();
571 return wxEmptyString;
581 if( !field->IsVisible() || field->GetText().IsEmpty() )
585 aVector.push_back( field );
603 if( aFieldName ==
m_fields[i]->GetName(
false ) )
623 switch( item->Type() )
633 if( aStyleShapes && !item->IsOnCopperLayer() )
648 std::vector< BOARD_ITEM* > item_list;
651 item_list.push_back( field );
654 item_list.push_back(
pad );
657 item_list.push_back( gr_item );
662 item_list.push_back(
group );
666 item_list.push_back( zone );
668 bool changed =
false;
674 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
687 m_pos = aOther.m_pos;
715 for(
PCB_FIELD* field : aOther.Fields() )
721 for(
PAD*
pad : aOther.Pads() )
724 aOther.Pads().clear();
729 for(
ZONE* item : aOther.Zones() )
737 item->SetNetCode( -1 );
740 aOther.Zones().clear();
745 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
748 aOther.GraphicalItems().clear();
756 aOther.Groups().clear();
767 aOther.Fields().clear();
768 aOther.Pads().clear();
769 aOther.Zones().clear();
770 aOther.GraphicalItems().clear();
771 aOther.m_initial_comments =
nullptr;
806 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
814 ptrMap[field] = newField;
824 ptrMap[
pad ] = newPad;
833 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
834 ptrMap[ zone ] = newZone;
850 ptrMap[ item ] = newItem;
863 newGroup->
AddItem( ptrMap[ member ] );
889 aVars->push_back( wxT(
"REFERENCE" ) );
890 aVars->push_back( wxT(
"VALUE" ) );
891 aVars->push_back( wxT(
"LAYER" ) );
892 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
893 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
894 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
895 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
896 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
897 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
906 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
911 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
916 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
921 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
926 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
931 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
932 || token->StartsWith( wxT(
"NET_NAME(" ) )
933 || token->StartsWith( wxT(
"NET_CLASS(" ) )
934 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
936 wxString padNumber = token->AfterFirst(
'(' );
937 padNumber = padNumber.BeforeLast(
')' );
941 if(
pad->GetNumber() == padNumber )
943 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
944 *token =
pad->GetShortNetname();
945 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
946 *token =
pad->GetNetname();
947 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
948 *token =
pad->GetNetClassName();
950 *token =
pad->GetPinFunction();
980 switch( aBoardItem->
Type() )
998 if( aMode == ADD_MODE::APPEND )
1005 if( aMode == ADD_MODE::APPEND )
1006 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
1008 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1012 if( aMode == ADD_MODE::APPEND )
1013 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1019 if( aMode == ADD_MODE::APPEND )
1028 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1029 aBoardItem->
Type() );
1043 switch( aBoardItem->
Type() )
1049 if( *it == aBoardItem )
1070 if( *it == aBoardItem )
1080 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1082 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1094 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1106 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1118 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1119 aBoardItem->
Type() );
1150 switch(
pad->GetProperty() )
1152 case PAD_PROP::FIDUCIAL_GLBL:
1153 case PAD_PROP::FIDUCIAL_LOCAL:
1156 case PAD_PROP::HEATSINK:
1157 case PAD_PROP::CASTELLATED:
1158 case PAD_PROP::MECHANICAL:
1161 case PAD_PROP::NONE:
1163 case PAD_PROP::TESTPOINT:
1167 switch(
pad->GetAttribute() )
1169 case PAD_ATTRIB::PTH:
1173 case PAD_ATTRIB::SMD:
1174 if(
pad->IsOnCopperLayer() )
1202 return _(
"Through hole" );
1204 return _(
"Other" );
1219 if(
dummy.IsFlipped() )
1223 bbox.
Merge(
pad->GetBoundingBox() );
1226 dummy.SetParent(
nullptr );
1227 dummy.SetParentGroup(
nullptr );
1260 if( aIncludeText && aIncludeInvisibleText )
1265 else if( aIncludeText )
1277 std::vector<PCB_TEXT*> texts;
1299 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1317 bbox.
Merge( item->GetBoundingBox() );
1323 if( !field->IsReference() && !field->IsValue() )
1324 texts.push_back( field );
1328 bbox.
Merge(
pad->GetBoundingBox() );
1331 bbox.
Merge( zone->GetBoundingBox() );
1336 if( aIncludeText || noDrawItems )
1345 if( aIncludeInvisibleText ||
text->IsVisible() )
1351 bool valueLayerIsVisible =
true;
1352 bool refLayerIsVisible =
true;
1370 if( (
Value().IsVisible() && valueLayerIsVisible )
1371 || aIncludeInvisibleText
1377 if( (
Reference().IsVisible() && refLayerIsVisible )
1378 || aIncludeInvisibleText
1387 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
1392 else if( aIncludeText )
1410 std::vector<PCB_TEXT*> texts;
1422 if( ( aLayers & item->GetLayerSet() ).none() )
1430 bbox.
Merge( item->GetBoundingBox() );
1435 if( ( aLayers &
pad->GetLayerSet() ).none() )
1438 bbox.
Merge(
pad->GetBoundingBox() );
1443 if( ( aLayers & zone->GetLayerSet() ).none() )
1446 bbox.
Merge( zone->GetBoundingBox() );
1492 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1519 std::vector<VECTOR2I> convex_hull;
1525 for(
const VECTOR2I& pt : convex_hull )
1549 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1551 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1553 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1556 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1565 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1566 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1570 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1572 if( !aStr->IsEmpty() )
1573 *aStr += wxT(
", " );
1582 addToken( &status,
_(
"Locked" ) );
1585 addToken( &status,
_(
"autoplaced" ) );
1588 addToken( &attrs,
_(
"not in schematic" ) );
1591 addToken( &attrs,
_(
"exclude from pos files" ) );
1594 addToken( &attrs,
_(
"exclude from BOM" ) );
1597 addToken( &attrs,
_(
"DNP" ) );
1599 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1601 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();
2277 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2312 field->Flip(
m_pos,
false );
2323 zone->Flip(
m_pos,
false );
2327 item->Flip(
m_pos,
false );
2330 if( aFlipLeftRight )
2350 field->EDA_TEXT::Offset(
delta );
2356 zone->Move(
delta );
2359 item->Move(
delta );
2387 field->Move( moveVector );
2391 pad->Move( moveVector );
2395 item->Move( moveVector );
2399 zone->Move( moveVector );
2459 switch( aItem->
Type() )
2463 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2466 if( aAddToFootprint )
2467 m_pads.push_back( new_pad );
2475 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2478 if( aAddToFootprint )
2479 m_zones.push_back( new_zone );
2481 new_item = new_zone;
2505 if( aAddToFootprint )
2508 new_item = new_text;
2517 if( aAddToFootprint )
2520 new_item = new_shape;
2529 if( aAddToFootprint )
2532 new_item = new_textbox;
2544 if( aAddToFootprint )
2547 new_item = dimension;
2555 if( aAddToFootprint )
2557 group->RunOnDescendants(
2576 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2586 std::set<wxString> usedNumbers;
2590 usedNumbers.insert(
pad->GetNumber() );
2597 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2600 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2651 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2655 return aPolySet.
Area();
2670 return markerShape.
Area();
2674 double combinedArea = 0.0;
2679 return combinedArea;
2709 case SHAPE_T::SEGMENT:
2711 case SHAPE_T::BEZIER:
2714 case SHAPE_T::RECTANGLE:
2715 case SHAPE_T::CIRCLE:
2730 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2731 return width * width;
2757 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2761 switch( item->
Type() )
2792 double footprintRegionArea =
polygonArea( footprintRegion );
2793 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2794 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2795 double ratio = ( coveredArea / footprintRegionArea );
2802 return std::min( ratio, 1.0 );
2808 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2829 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2834 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2874 std::vector<PCB_SHAPE*> list_front;
2875 std::vector<PCB_SHAPE*> list_back;
2876 std::map<int, int> front_width_histogram;
2877 std::map<int, int> back_width_histogram;
2884 list_back.push_back( shape );
2891 list_front.push_back( shape );
2896 if( !list_front.size() && !list_back.size() )
2903 true, aErrorHandler ) )
2913 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
2914 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2916 return a.second < b.second;
2919 if( max != front_width_histogram.end() )
2942 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
2943 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2945 return a.second < b.second;
2948 if( max != back_width_histogram.end() )
2969 std::map<wxString, int> padNumberToGroupIdxMap;
2972 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
2975 [&]( wxString aPad,
int aGroup )
2977 aPad.Trim(
true ).Trim(
false );
2979 if( !aPad.IsEmpty() )
2980 padNumberToGroupIdxMap[ aPad ] = aGroup;
2989 for( wxUniCharRef ch :
group )
2998 switch(
static_cast<unsigned char>( ch ) )
3005 processPad(
pad, ii );
3015 processPad(
pad, ii );
3018 return padNumberToGroupIdxMap;
3028 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
3029 std::vector<PAD*> otherPads;
3035 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
3036 otherPads.push_back(
pad );
3049 if( setAttr && likelyAttr && setAttr != likelyAttr )
3053 switch( likelyAttr )
3056 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3059 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3064 (aErrorHandler)( msg );
3070 const std::function<
void(
const PAD*,
int,
3071 const wxString& )>& aErrorHandler )
3073 if( aErrorHandler ==
nullptr )
3078 pad->CheckPad( aUnitsProvider,
3079 [&](
int errorCode,
const wxString& msg )
3081 aErrorHandler(
pad, errorCode, msg );
3089 const VECTOR2I& )>& aErrorHandler )
3091 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3106 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3109 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3111 checkedPairs[ { a, b } ] = 1;
3113 if(
pad->HasDrilledHole() && other->HasDrilledHole() )
3117 if(
pad->GetPosition() == other->GetPosition() )
3123 std::shared_ptr<SHAPE_SEGMENT> holeA =
pad->GetEffectiveHoleShape();
3124 std::shared_ptr<SHAPE_SEGMENT> holeB = other->GetEffectiveHoleShape();
3126 if( holeA->Collide( holeB->GetSeg(), 0 ) )
3137 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3140 SHAPE* padShape =
pad->GetEffectiveShape().get();
3141 SHAPE* otherShape = other->GetEffectiveShape().get();
3143 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3155 const VECTOR2I& )>& aErrorHandler )
3164 std::vector<BOARD_ITEM*> copperItems;
3168 if( item->IsOnCopperLayer() )
3169 copperItems.push_back( item );
3171 item->RunOnDescendants(
3175 copperItems.push_back( descendent );
3181 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3182 copperItems.push_back( zone );
3187 if( field->IsOnCopperLayer() )
3188 copperItems.push_back( field );
3198 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3202 if( item->IsOnLayer( layer ) )
3204 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3215 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3217 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3218 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3225 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3227 if( pads.size() > 1 )
3229 const PAD* firstPad = pads[0];
3230 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3232 for(
size_t ii = 1; ii < pads.size(); ++ii )
3234 const PAD* thisPad = pads[ii];
3235 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3237 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3246 if( item->HitTest( pos, 1 ) )
3248 shortingItem = item;
3254 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3256 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3267 std::set<wxString> padNumbers;
3276 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3277 aErrorHandler( msg );
3279 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3281 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3282 aErrorHandler( msg );
3294 std::swap( *
this, *
image );
3302 image->RunOnChildren(
3314 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3329 return *
this == other;
3338 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3347 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3356 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3365 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3382 double similarity = 1.0;
3391 similarity *=
pad->Similarity( *otherPad );
3400 if( itemA->
Type() != itemB->
Type() )
3401 return itemA->
Type() < itemB->
Type();
3416 if( dwgA->
GetShape() != SHAPE_T::POLY )
3429 if( dwgA->
GetShape() == SHAPE_T::ARC )
3436 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3448 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3471 return itemA < itemB;
3499 return aFirst < aSecond;
3543 if( firstShape->VertexCount() != secondShape->VertexCount() )
3544 return firstShape->VertexCount() < secondShape->VertexCount();
3546 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3548 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3549 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3550 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3551 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3569 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3580 return aFirst < aSecond;
3585 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3586 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3587 bool aSkipNonPlatedPads )
const
3591 if( !
pad->FlashLayer( aLayer ) )
3594 VECTOR2I clearance( aClearance, aClearance );
3599 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3602 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3608 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3611 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3618 clearance.
x +=
pad->GetSolderMaskExpansion();
3619 clearance.
y +=
pad->GetSolderMaskExpansion();
3624 clearance +=
pad->GetSolderPasteMargin();
3637 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3638 &&
pad->GetShape() != PAD_SHAPE::CUSTOM )
3640 VECTOR2I dummySize =
pad->GetSize() + clearance + clearance;
3642 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3646 dummy.SetSize( dummySize );
3647 dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
3651 pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.
x, aMaxError, aErrorLoc );
3658 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3659 bool aIncludeText,
bool aIncludeShapes,
3660 bool aIncludePrivateItems )
const
3662 std::vector<const PCB_TEXT*> texts;
3669 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3674 texts.push_back(
text );
3685 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3691 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3704 if( field->GetLayer() == aLayer && field->IsVisible() )
3705 texts.push_back( field );
3710 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3717 using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
3719 std::set<OUTLINE_FONT*>
fonts;
3725 if(
auto* font =
text->GetFont(); font && !font->IsStroke() )
3727 auto* outline =
static_cast<OUTLINE_FONT*
>( font );
3728 auto permission = outline->GetEmbeddingPermission();
3730 if( permission == EMBEDDING_PERMISSION::EDITABLE
3731 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3733 fonts.insert( outline );
3739 for(
auto* font :
fonts )
3753 if( zcMap.
Choices().GetCount() == 0 )
3755 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3756 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3757 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3758 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3759 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3760 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3765 if( layerEnum.
Choices().GetCount() == 0 )
3773 wxPGChoices fpLayers;
3786 layer->SetChoices( fpLayers );
3791 PROPERTY_DISPLAY::PT_DEGREE ) );
3793 const wxString groupFields =
_HKI(
"Fields" );
3812 const wxString groupAttributes =
_HKI(
"Attributes" );
3826 const wxString groupOverrides =
_HKI(
"Overrides" );
3829 _HKI(
"Exempt From Courtyard Requirement" ),
3833 _HKI(
"Clearance Override" ),
3835 PROPERTY_DISPLAY::PT_SIZE ),
3838 _HKI(
"Solderpaste Margin Override" ),
3840 PROPERTY_DISPLAY::PT_SIZE ),
3843 _HKI(
"Solderpaste Margin Ratio Override" ),
3846 PROPERTY_DISPLAY::PT_RATIO ),
3849 _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.