26#include <magic_enum.hpp>
32#include <unordered_set>
57#include <google/protobuf/any.pb.h>
58#include <api/board/board_types.pb.h>
66 m_boundingBoxCacheTimeStamp( 0 ),
67 m_visibleBBoxCacheTimeStamp( 0 ),
68 m_textExcludedBBoxCacheTimeStamp( 0 ),
69 m_hullCacheTimeStamp( 0 ),
70 m_initial_comments( nullptr )
138 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
144 ptrMap[field] = newField;
145 Add( newField, ADD_MODE::APPEND );
151 PAD* newPad =
static_cast<PAD*
>(
pad->Clone() );
152 ptrMap[
pad ] = newPad;
153 Add( newPad, ADD_MODE::APPEND );
159 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
160 ptrMap[ zone ] = newZone;
161 Add( newZone, ADD_MODE::APPEND );
174 ptrMap[ item ] = newItem;
175 Add( newItem, ADD_MODE::APPEND );
182 ptrMap[
group ] = newGroup;
183 Add( newGroup, ADD_MODE::APPEND );
195 if( ptrMap.count( member ) )
196 newGroup->
AddItem( ptrMap[ member ] );
216 *
this = std::move( aFootprint );
226 item->SetParentGroup(
nullptr );
258 board->IncrementTimeStamp();
264 kiapi::board::types::FootprintInstance footprint;
267 footprint.mutable_position()->set_x_nm(
GetPosition().x );
268 footprint.mutable_position()->set_y_nm(
GetPosition().y );
270 footprint.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>(
GetLayer() ) );
271 footprint.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
272 : kiapi::common::types::LockedState::LS_UNLOCKED );
274 google::protobuf::Any buf;
276 buf.UnpackTo( footprint.mutable_reference_field() );
278 buf.UnpackTo( footprint.mutable_value_field() );
280 buf.UnpackTo( footprint.mutable_datasheet_field() );
282 buf.UnpackTo( footprint.mutable_description_field() );
284 kiapi::board::types::FootprintAttributes* attrs = footprint.mutable_attributes();
290 attrs->set_do_not_populate(
IsDNP() );
292 kiapi::board::types::Footprint* def = footprint.mutable_definition();
297 def->mutable_attributes()->set_keywords(
GetKeywords().ToStdString() );
301 kiapi::board::types::DesignRuleOverrides* overrides = def->mutable_overrides();
315 overrides->set_zone_connection(
321 kiapi::board::types::NetTieDefinition* netTie = def->add_net_ties();
322 wxStringTokenizer tokenizer(
group,
" " );
324 while( tokenizer.HasMoreTokens() )
325 netTie->add_pad_number( tokenizer.GetNextToken().ToStdString() );
330 def->add_private_layers(
331 ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
339 google::protobuf::Any* itemMsg = def->add_items();
340 item->Serialize( *itemMsg );
343 for(
const PAD* item :
Pads() )
345 google::protobuf::Any* itemMsg = def->add_items();
346 item->Serialize( *itemMsg );
351 google::protobuf::Any* itemMsg = def->add_items();
352 item->Serialize( *itemMsg );
357 google::protobuf::Any* itemMsg = def->add_items();
358 item->Serialize( *itemMsg );
363 aContainer.PackFrom( footprint );
369 kiapi::board::types::FootprintInstance footprint;
371 if( !aContainer.UnpackTo( &footprint ) )
377 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( footprint.layer() ) );
378 SetLocked( footprint.locked() == kiapi::common::types::LockedState::LS_LOCKED );
380 google::protobuf::Any buf;
381 kiapi::board::types::Field mandatoryField;
383 if( footprint.has_reference_field() )
385 mandatoryField = footprint.reference_field();
387 buf.PackFrom( mandatoryField );
391 if( footprint.has_value_field() )
393 mandatoryField = footprint.value_field();
394 mandatoryField.mutable_id()->set_id(
VALUE_FIELD );
395 buf.PackFrom( mandatoryField );
399 if( footprint.has_datasheet_field() )
401 mandatoryField = footprint.datasheet_field();
403 buf.PackFrom( mandatoryField );
407 if( footprint.has_description_field() )
409 mandatoryField = footprint.description_field();
411 buf.PackFrom( mandatoryField );
415 SetBoardOnly( footprint.attributes().not_in_schematic() );
419 SetDNP( footprint.attributes().do_not_populate() );
425 SetKeywords( footprint.definition().attributes().keywords() );
427 const kiapi::board::types::DesignRuleOverrides& overrides = footprint.overrides();
429 if( overrides.has_clearance() )
434 if( overrides.has_solder_mask_margin() )
439 if( overrides.has_solder_paste_margin() )
444 if( overrides.has_solder_paste_margin_ratio() )
451 for(
const kiapi::board::types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
455 for(
const std::string&
pad : netTieMsg.pad_number() )
456 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
464 for(
int layerMsg : footprint.definition().private_layers() )
466 auto layer =
static_cast<kiapi::board::types::BoardLayer
>( layerMsg );
467 privateLayers.set( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( layer ) );
485 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
494 if( item && item->Deserialize( itemMsg ) )
495 Add( item.release(), ADD_MODE::APPEND );
520 if( field->GetId() == aFieldId )
531 if( field->GetCanonicalName() == aFieldName )
540 if( aFieldName.empty() )
545 if( field->GetName() == aFieldName )
557 if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
558 return field->GetText();
561 return wxEmptyString;
571 if( !field->IsVisible() || field->GetText().IsEmpty() )
575 aVector.push_back( field );
593 if( aFieldName ==
m_fields[i]->GetName(
false ) )
613 switch( item->Type() )
623 if( aStyleShapes && !item->IsOnCopperLayer() )
638 std::vector< BOARD_ITEM* > item_list;
641 item_list.push_back( field );
644 item_list.push_back(
pad );
647 item_list.push_back( gr_item );
652 item_list.push_back(
group );
656 item_list.push_back( zone );
658 bool changed =
false;
664 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
677 m_pos = aOther.m_pos;
705 for(
PCB_FIELD* field : aOther.Fields() )
711 for(
PAD*
pad : aOther.Pads() )
714 aOther.Pads().clear();
719 for(
ZONE* item : aOther.Zones() )
727 item->SetNetCode( -1 );
730 aOther.Zones().clear();
735 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
738 aOther.GraphicalItems().clear();
746 aOther.Groups().clear();
757 aOther.Fields().clear();
758 aOther.Pads().clear();
759 aOther.Zones().clear();
760 aOther.GraphicalItems().clear();
761 aOther.m_initial_comments =
nullptr;
796 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
804 ptrMap[field] = newField;
814 ptrMap[
pad ] = newPad;
823 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
824 ptrMap[ zone ] = newZone;
840 ptrMap[ item ] = newItem;
853 newGroup->
AddItem( ptrMap[ member ] );
879 aVars->push_back( wxT(
"REFERENCE" ) );
880 aVars->push_back( wxT(
"VALUE" ) );
881 aVars->push_back( wxT(
"LAYER" ) );
882 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
883 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
884 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
885 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
886 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
887 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
896 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
901 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
906 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
911 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
916 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
921 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
922 || token->StartsWith( wxT(
"NET_NAME(" ) )
923 || token->StartsWith( wxT(
"NET_CLASS(" ) )
924 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
926 wxString padNumber = token->AfterFirst(
'(' );
927 padNumber = padNumber.BeforeLast(
')' );
931 if(
pad->GetNumber() == padNumber )
933 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
934 *token =
pad->GetShortNetname();
935 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
936 *token =
pad->GetNetname();
937 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
938 *token =
pad->GetNetClassName();
940 *token =
pad->GetPinFunction();
970 switch( aBoardItem->
Type() )
988 if( aMode == ADD_MODE::APPEND )
995 if( aMode == ADD_MODE::APPEND )
996 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
998 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1002 if( aMode == ADD_MODE::APPEND )
1003 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1009 if( aMode == ADD_MODE::APPEND )
1018 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1019 aBoardItem->
Type() );
1033 switch( aBoardItem->
Type() )
1039 if( *it == aBoardItem )
1059 if( *it == aBoardItem )
1069 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1071 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1083 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1095 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1107 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1108 aBoardItem->
Type() );
1139 switch(
pad->GetProperty() )
1141 case PAD_PROP::FIDUCIAL_GLBL:
1142 case PAD_PROP::FIDUCIAL_LOCAL:
1145 case PAD_PROP::HEATSINK:
1146 case PAD_PROP::CASTELLATED:
1149 case PAD_PROP::NONE:
1151 case PAD_PROP::TESTPOINT:
1155 switch(
pad->GetAttribute() )
1157 case PAD_ATTRIB::PTH:
1161 case PAD_ATTRIB::SMD:
1162 if(
pad->IsOnCopperLayer() )
1190 return _(
"Through hole" );
1192 return _(
"Other" );
1207 if(
dummy.IsFlipped() )
1211 bbox.
Merge(
pad->GetBoundingBox() );
1214 dummy.SetParent(
nullptr );
1215 dummy.SetParentGroup(
nullptr );
1229 std::vector<PCB_TEXT*> texts;
1236 if( aIncludeText && aIncludeInvisibleText )
1241 else if( aIncludeText )
1269 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1287 bbox.
Merge( item->GetBoundingBox() );
1293 if( !field->IsReference() && !field->IsValue() )
1294 texts.push_back( field );
1298 bbox.
Merge(
pad->GetBoundingBox() );
1301 bbox.
Merge( zone->GetBoundingBox() );
1306 if( aIncludeText || noDrawItems )
1315 if( aIncludeInvisibleText ||
text->IsVisible() )
1321 bool valueLayerIsVisible =
true;
1322 bool refLayerIsVisible =
true;
1340 if( (
Value().IsVisible() && valueLayerIsVisible )
1341 || aIncludeInvisibleText
1347 if( (
Reference().IsVisible() && refLayerIsVisible )
1348 || aIncludeInvisibleText
1357 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
1362 else if( aIncludeText )
1380 std::vector<PCB_TEXT*> texts;
1392 if( ( aLayers & item->GetLayerSet() ).none() )
1400 bbox.
Merge( item->GetBoundingBox() );
1405 if( ( aLayers &
pad->GetLayerSet() ).none() )
1408 bbox.
Merge(
pad->GetBoundingBox() );
1413 if( ( aLayers & zone->GetLayerSet() ).none() )
1416 bbox.
Merge( zone->GetBoundingBox() );
1462 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1489 std::vector<VECTOR2I> convex_hull;
1495 for(
const VECTOR2I& pt : convex_hull )
1519 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1521 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1523 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1526 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1535 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1536 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1540 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1542 if( !aStr->IsEmpty() )
1543 *aStr += wxT(
", " );
1552 addToken( &status,
_(
"Locked" ) );
1555 addToken( &status,
_(
"autoplaced" ) );
1558 addToken( &attrs,
_(
"not in schematic" ) );
1561 addToken( &attrs,
_(
"exclude from pos files" ) );
1564 addToken( &attrs,
_(
"exclude from BOM" ) );
1567 addToken( &attrs,
_(
"DNP" ) );
1569 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1571 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1575 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1577 aList.emplace_back( msg, msg2 );
1581 aList.emplace_back( msg, msg2 );
1589 if( board->IsFootprintHolder() )
1621 if(
pad->IsOnLayer( aLayer ) )
1627 if( zone->IsOnLayer( aLayer ) )
1633 if( field->IsOnLayer( aLayer ) )
1639 if( item->IsOnLayer( aLayer ) )
1651 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1657 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1663 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1664 && item->HitTest( aPosition, aAccuracy ) )
1676 std::vector<BOARD_ITEM*> items;
1680 if(
pad->IsOnLayer( aLayer ) )
1681 items.push_back(
pad );
1686 if( zone->IsOnLayer( aLayer ) )
1687 items.push_back( zone );
1692 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1693 items.push_back( item );
1702 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1704 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1711 return !items.empty() && aContained;
1730 BOX2I arect = aRect;
1750 if(
pad->HitTest( arect,
false, 0 ) )
1756 if( zone->HitTest( arect,
false, 0 ) )
1767 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1781 bool can_select = aSearchAfterMe ? false :
true;
1785 if( !can_select &&
pad == aSearchAfterMe )
1791 if( can_select &&
pad->GetNumber() == aPadNumber )
1804 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1807 if(
pad->HitTest( aPosition ) )
1824 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1836 std::set<wxString> usedNumbers;
1848 if(
pad->GetNumber().IsEmpty() )
1854 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1858 usedNumbers.insert(
pad->GetNumber() );
1873 if(
nullptr == a3DModel )
1883 const std::vector<KICAD_T>& aScanTypes )
1885#if 0 && defined(DEBUG)
1886 std::cout <<
GetClass().mb_str() <<
' ';
1889 bool drawingsScanned =
false;
1891 for(
KICAD_T scanType : aScanTypes )
1896 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
1897 return INSPECT_RESULT::QUIT;
1902 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1903 == INSPECT_RESULT::QUIT )
1905 return INSPECT_RESULT::QUIT;
1911 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
1912 == INSPECT_RESULT::QUIT )
1914 return INSPECT_RESULT::QUIT;
1920 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
1921 == INSPECT_RESULT::QUIT )
1923 return INSPECT_RESULT::QUIT;
1938 if( !drawingsScanned )
1940 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
1941 == INSPECT_RESULT::QUIT )
1943 return INSPECT_RESULT::QUIT;
1946 drawingsScanned =
true;
1952 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
1953 == INSPECT_RESULT::QUIT )
1955 return INSPECT_RESULT::QUIT;
1965 return INSPECT_RESULT::CONTINUE;
1973 if( reference.IsEmpty() )
1974 reference =
_(
"<no reference designator>" );
1976 return wxString::Format(
_(
"Footprint %s" ), reference );
1982 return BITMAPS::module;
2009 aFunction( drawing );
2011 catch( std::bad_function_call& )
2013 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2039 group->RunOnDescendants( aFunction, aDepth + 1 );
2044 aFunction( drawing );
2045 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2048 catch( std::bad_function_call& )
2050 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2063 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2084 bool f_silk =
false, b_silk =
false, non_silk =
false;
2088 if( item->GetLayer() ==
F_SilkS )
2090 else if( item->GetLayer() ==
B_SilkS )
2096 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2099 aLayers[ aCount++ ] =
F_SilkS;
2102 aLayers[ aCount++ ] =
B_SilkS;
2118 return std::numeric_limits<double>::max();
2130 return std::numeric_limits<double>::max();
2139 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
2144 return std::numeric_limits<double>::max();
2155 int biggest_clearance = board->GetMaxClearanceValue();
2156 area.
Inflate( biggest_clearance );
2167 if( aName.find_first_of( invalids ) != std::string::npos )
2181 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2182 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2185 return invalidCharsReadable;
2187 return invalidChars;
2193 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2207 EDA_ANGLE newOrientation = orientation + aAngle;
2214 field->KeepUpright( newOrientation );
2219 static_cast<PCB_TEXT*
>( item )->KeepUpright( newOrientation );
2231 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2266 field->Flip(
m_pos,
false );
2277 zone->Flip(
m_pos,
false );
2281 item->Flip(
m_pos,
false );
2284 if( aFlipLeftRight )
2304 field->EDA_TEXT::Offset(
delta );
2310 zone->Move(
delta );
2313 item->Move(
delta );
2341 field->Move( moveVector );
2345 pad->Move( moveVector );
2349 item->Move( moveVector );
2353 zone->Move( moveVector );
2413 switch( aItem->
Type() )
2417 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2420 if( aAddToFootprint )
2421 m_pads.push_back( new_pad );
2429 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2432 if( aAddToFootprint )
2433 m_zones.push_back( new_zone );
2435 new_item = new_zone;
2459 if( aAddToFootprint )
2462 new_item = new_text;
2471 if( aAddToFootprint )
2474 new_item = new_shape;
2483 if( aAddToFootprint )
2486 new_item = new_textbox;
2498 if( aAddToFootprint )
2501 new_item = dimension;
2509 if( aAddToFootprint )
2511 group->RunOnDescendants(
2530 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2540 std::set<wxString> usedNumbers;
2544 usedNumbers.insert(
pad->GetNumber() );
2551 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2554 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2605 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2609 return aPolySet.
Area();
2624 return markerShape.
Area();
2628 double combinedArea = 0.0;
2633 return combinedArea;
2663 case SHAPE_T::SEGMENT:
2665 case SHAPE_T::BEZIER:
2668 case SHAPE_T::RECTANGLE:
2669 case SHAPE_T::CIRCLE:
2684 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2685 return width * width;
2711 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2715 switch( item->
Type() )
2744 double footprintRegionArea =
polygonArea( footprintRegion );
2745 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2746 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2747 double ratio = ( coveredArea / footprintRegionArea );
2754 return std::min( ratio, 1.0 );
2760 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2781 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2786 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2820 std::vector<PCB_SHAPE*> list_front;
2821 std::vector<PCB_SHAPE*> list_back;
2822 std::map<int, int> front_width_histogram;
2823 std::map<int, int> back_width_histogram;
2830 list_back.push_back( shape );
2837 list_front.push_back( shape );
2842 if( !list_front.size() && !list_back.size() )
2849 true, aErrorHandler ) )
2857 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
2858 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2860 return a.second < b.second;
2863 if( max != front_width_histogram.end() )
2886 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
2887 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2889 return a.second < b.second;
2892 if( max != back_width_histogram.end() )
2913 std::map<wxString, int> padNumberToGroupIdxMap;
2916 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
2919 [&]( wxString aPad,
int aGroup )
2921 aPad.Trim(
true ).Trim(
false );
2923 if( !aPad.IsEmpty() )
2924 padNumberToGroupIdxMap[ aPad ] = aGroup;
2933 for( wxUniCharRef ch :
group )
2942 switch(
static_cast<unsigned char>( ch ) )
2949 processPad(
pad, ii );
2959 processPad(
pad, ii );
2962 return padNumberToGroupIdxMap;
2972 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
2973 std::vector<PAD*> otherPads;
2979 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
2980 otherPads.push_back(
pad );
2993 if( setAttr && likelyAttr && setAttr != likelyAttr )
2997 switch( likelyAttr )
3000 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3003 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3008 (aErrorHandler)( msg );
3014 const wxString& )>& aErrorHandler )
3016 if( aErrorHandler ==
nullptr )
3021 if(
pad->GetAttribute() == PAD_ATTRIB::PTH ||
pad->GetAttribute() == PAD_ATTRIB::NPTH )
3023 if(
pad->GetDrillSizeX() < 1 ||
pad->GetDrillSizeY() < 1 )
3027 if(
pad->GetAttribute() == PAD_ATTRIB::PTH )
3029 if( !
pad->IsOnCopperLayer() )
3041 std::shared_ptr<SHAPE_SEGMENT> hole =
pad->GetEffectiveHoleShape();
3054 if(
pad->GetAttribute() == PAD_ATTRIB::SMD )
3059 _(
"(SMD pad appears on both front and back copper)" ) );
3061 else if(
pad->IsOnLayer(
F_Cu ) )
3066 _(
"(SMD pad copper and mask layers don't match)" ) );
3071 _(
"(SMD pad copper and paste layers don't match)" ) );
3074 else if(
pad->IsOnLayer(
B_Cu ) )
3079 _(
"(SMD pad copper and mask layers don't match)" ) );
3084 _(
"(SMD pad copper and paste layers don't match)" ) );
3093 const VECTOR2I& )>& aErrorHandler )
3095 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3103 if( other ==
pad ||
pad->SameLogicalPadAs( other ) )
3116 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3119 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3121 checkedPairs[ { a, b } ] = 1;
3123 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3126 SHAPE* padShape =
pad->GetEffectiveShape().get();
3127 SHAPE* otherShape = other->GetEffectiveShape().get();
3129 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3130 aErrorHandler(
pad, other, pos );
3141 const VECTOR2I& )>& aErrorHandler )
3150 std::vector<BOARD_ITEM*> copperItems;
3154 if( item->IsOnCopperLayer() )
3155 copperItems.push_back( item );
3157 item->RunOnDescendants(
3161 copperItems.push_back( descendent );
3167 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3168 copperItems.push_back( zone );
3173 if( field->IsOnCopperLayer() )
3174 copperItems.push_back( field );
3184 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3188 if( item->IsOnLayer( layer ) )
3190 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3201 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3203 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3204 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3211 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3213 if( pads.size() > 1 )
3215 const PAD* firstPad = pads[0];
3216 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3218 for(
size_t ii = 1; ii < pads.size(); ++ii )
3220 const PAD* thisPad = pads[ii];
3221 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3223 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3232 if( item->HitTest( pos, 1 ) )
3234 shortingItem = item;
3240 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3242 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3253 std::set<wxString> padNumbers;
3258 for(
auto [ padNumber,
_ ] : ret )
3264 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3265 aErrorHandler( msg );
3267 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3269 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3270 aErrorHandler( msg );
3282 std::swap( *
this, *
image );
3290 image->RunOnChildren(
3302 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3317 return *
this == other;
3326 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3335 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3344 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3353 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3370 double similarity = 1.0;
3372 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3380 similarity *=
pad->Similarity( *otherPad );
3389 if( itemA->
Type() != itemB->
Type() )
3390 return itemA->
Type() < itemB->
Type();
3405 if( dwgA->
GetShape() != SHAPE_T::POLY )
3418 if( dwgA->
GetShape() == SHAPE_T::ARC )
3425 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3437 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3460 return itemA < itemB;
3488 return aFirst < aSecond;
3532 if( firstShape->VertexCount() != secondShape->VertexCount() )
3533 return firstShape->VertexCount() < secondShape->VertexCount();
3535 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3537 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3538 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3539 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3540 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3558 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3569 return aFirst < aSecond;
3574 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3575 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3576 bool aSkipNonPlatedPads )
const
3580 if( !
pad->FlashLayer( aLayer ) )
3583 VECTOR2I clearance( aClearance, aClearance );
3588 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3591 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3597 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3600 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3607 clearance.
x +=
pad->GetSolderMaskExpansion();
3608 clearance.
y +=
pad->GetSolderMaskExpansion();
3613 clearance +=
pad->GetSolderPasteMargin();
3626 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3627 &&
pad->GetShape() != PAD_SHAPE::CUSTOM )
3629 VECTOR2I dummySize =
pad->GetSize() + clearance + clearance;
3631 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3635 dummy.SetSize( dummySize );
3636 dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
3640 pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.
x, aMaxError, aErrorLoc );
3647 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3648 bool aIncludeText,
bool aIncludeShapes,
3649 bool aIncludePrivateItems )
const
3651 std::vector<const PCB_TEXT*> texts;
3658 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3663 texts.push_back(
text );
3674 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3680 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3693 if( field->GetLayer() == aLayer && field->IsVisible() )
3694 texts.push_back( field );
3699 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3709 if( zcMap.
Choices().GetCount() == 0 )
3711 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3712 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3713 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3714 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3715 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3716 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3721 if( layerEnum.
Choices().GetCount() == 0 )
3729 wxPGChoices fpLayers;
3742 layer->SetChoices( fpLayers );
3747 PROPERTY_DISPLAY::PT_DEGREE ) );
3749 const wxString groupFields =
_HKI(
"Fields" );
3768 const wxString groupAttributes =
_HKI(
"Attributes" );
3782 const wxString groupOverrides =
_HKI(
"Overrides" );
3785 _HKI(
"Exempt From Courtyard Requirement" ),
3789 _HKI(
"Clearance Override" ),
3791 PROPERTY_DISPLAY::PT_SIZE ),
3794 _HKI(
"Solderpaste Margin Override" ),
3796 PROPERTY_DISPLAY::PT_SIZE ),
3799 _HKI(
"Solderpaste Margin Ratio Override" ),
3802 PROPERTY_DISPLAY::PT_RATIO ),
3805 _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
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
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)
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
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
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
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...
PAD_DRILL_SHAPE_T GetDrillShape() const
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.
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.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
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 IsEmpty() const
Return true if the set is empty (no polygons at all)
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 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.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
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_PAD_TH_WITH_NO_HOLE
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.
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:
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
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
ZONE_CONNECTION
How pads are covered by copper in zone.