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 )
1060 if( *it == aBoardItem )
1070 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1072 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1084 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1096 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1108 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1109 aBoardItem->
Type() );
1140 switch(
pad->GetProperty() )
1142 case PAD_PROP::FIDUCIAL_GLBL:
1143 case PAD_PROP::FIDUCIAL_LOCAL:
1146 case PAD_PROP::HEATSINK:
1147 case PAD_PROP::CASTELLATED:
1148 case PAD_PROP::MECHANICAL:
1151 case PAD_PROP::NONE:
1153 case PAD_PROP::TESTPOINT:
1157 switch(
pad->GetAttribute() )
1159 case PAD_ATTRIB::PTH:
1163 case PAD_ATTRIB::SMD:
1164 if(
pad->IsOnCopperLayer() )
1192 return _(
"Through hole" );
1194 return _(
"Other" );
1209 if(
dummy.IsFlipped() )
1213 bbox.
Merge(
pad->GetBoundingBox() );
1216 dummy.SetParent(
nullptr );
1217 dummy.SetParentGroup(
nullptr );
1231 std::vector<PCB_TEXT*> texts;
1238 if( aIncludeText && aIncludeInvisibleText )
1243 else if( aIncludeText )
1271 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1289 bbox.
Merge( item->GetBoundingBox() );
1295 if( !field->IsReference() && !field->IsValue() )
1296 texts.push_back( field );
1300 bbox.
Merge(
pad->GetBoundingBox() );
1303 bbox.
Merge( zone->GetBoundingBox() );
1308 if( aIncludeText || noDrawItems )
1317 if( aIncludeInvisibleText ||
text->IsVisible() )
1323 bool valueLayerIsVisible =
true;
1324 bool refLayerIsVisible =
true;
1342 if( (
Value().IsVisible() && valueLayerIsVisible )
1343 || aIncludeInvisibleText
1349 if( (
Reference().IsVisible() && refLayerIsVisible )
1350 || aIncludeInvisibleText
1359 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
1364 else if( aIncludeText )
1382 std::vector<PCB_TEXT*> texts;
1394 if( ( aLayers & item->GetLayerSet() ).none() )
1402 bbox.
Merge( item->GetBoundingBox() );
1407 if( ( aLayers &
pad->GetLayerSet() ).none() )
1410 bbox.
Merge(
pad->GetBoundingBox() );
1415 if( ( aLayers & zone->GetLayerSet() ).none() )
1418 bbox.
Merge( zone->GetBoundingBox() );
1464 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1491 std::vector<VECTOR2I> convex_hull;
1497 for(
const VECTOR2I& pt : convex_hull )
1521 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1523 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1525 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1528 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1537 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1538 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1542 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1544 if( !aStr->IsEmpty() )
1545 *aStr += wxT(
", " );
1554 addToken( &status,
_(
"Locked" ) );
1557 addToken( &status,
_(
"autoplaced" ) );
1560 addToken( &attrs,
_(
"not in schematic" ) );
1563 addToken( &attrs,
_(
"exclude from pos files" ) );
1566 addToken( &attrs,
_(
"exclude from BOM" ) );
1569 addToken( &attrs,
_(
"DNP" ) );
1571 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1573 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1577 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1579 aList.emplace_back( msg, msg2 );
1583 aList.emplace_back( msg, msg2 );
1591 if( board->IsFootprintHolder() )
1623 if(
pad->IsOnLayer( aLayer ) )
1629 if( zone->IsOnLayer( aLayer ) )
1635 if( field->IsOnLayer( aLayer ) )
1641 if( item->IsOnLayer( aLayer ) )
1653 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1659 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1665 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1666 && item->HitTest( aPosition, aAccuracy ) )
1678 std::vector<BOARD_ITEM*> items;
1682 if(
pad->IsOnLayer( aLayer ) )
1683 items.push_back(
pad );
1688 if( zone->IsOnLayer( aLayer ) )
1689 items.push_back( zone );
1694 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1695 items.push_back( item );
1704 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1706 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1713 return !items.empty() && aContained;
1732 BOX2I arect = aRect;
1752 if(
pad->HitTest( arect,
false, 0 ) )
1758 if( zone->HitTest( arect,
false, 0 ) )
1769 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1783 bool can_select = aSearchAfterMe ? false :
true;
1787 if( !can_select &&
pad == aSearchAfterMe )
1793 if( can_select &&
pad->GetNumber() == aPadNumber )
1806 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1809 if(
pad->HitTest( aPosition ) )
1819 std::vector<const PAD*> retv;
1823 if( ( aIgnore && aIgnore ==
pad ) || (
pad->GetNumber() != aPadNumber ) )
1826 retv.push_back(
pad );
1842 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1854 std::set<wxString> usedNumbers;
1866 if(
pad->GetNumber().IsEmpty() )
1872 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1876 usedNumbers.insert(
pad->GetNumber() );
1891 if(
nullptr == a3DModel )
1901 const std::vector<KICAD_T>& aScanTypes )
1903#if 0 && defined(DEBUG)
1904 std::cout <<
GetClass().mb_str() <<
' ';
1907 bool drawingsScanned =
false;
1909 for(
KICAD_T scanType : aScanTypes )
1914 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
1915 return INSPECT_RESULT::QUIT;
1920 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1921 == INSPECT_RESULT::QUIT )
1923 return INSPECT_RESULT::QUIT;
1929 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
1930 == INSPECT_RESULT::QUIT )
1932 return INSPECT_RESULT::QUIT;
1938 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
1939 == INSPECT_RESULT::QUIT )
1941 return INSPECT_RESULT::QUIT;
1956 if( !drawingsScanned )
1958 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
1959 == INSPECT_RESULT::QUIT )
1961 return INSPECT_RESULT::QUIT;
1964 drawingsScanned =
true;
1970 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
1971 == INSPECT_RESULT::QUIT )
1973 return INSPECT_RESULT::QUIT;
1983 return INSPECT_RESULT::CONTINUE;
1991 if( reference.IsEmpty() )
1992 reference =
_(
"<no reference designator>" );
1994 return wxString::Format(
_(
"Footprint %s" ), reference );
2000 return BITMAPS::module;
2027 aFunction( drawing );
2029 catch( std::bad_function_call& )
2031 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2057 group->RunOnDescendants( aFunction, aDepth + 1 );
2062 aFunction( drawing );
2063 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2066 catch( std::bad_function_call& )
2068 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2081 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2102 bool f_silk =
false, b_silk =
false, non_silk =
false;
2106 if( item->GetLayer() ==
F_SilkS )
2108 else if( item->GetLayer() ==
B_SilkS )
2114 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2117 aLayers[ aCount++ ] =
F_SilkS;
2120 aLayers[ aCount++ ] =
B_SilkS;
2136 return std::numeric_limits<double>::max();
2148 return std::numeric_limits<double>::max();
2157 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
2162 return std::numeric_limits<double>::max();
2173 int biggest_clearance = board->GetMaxClearanceValue();
2174 area.
Inflate( biggest_clearance );
2185 if( aName.find_first_of( invalids ) != std::string::npos )
2199 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2200 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2203 return invalidCharsReadable;
2205 return invalidChars;
2211 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2225 EDA_ANGLE newOrientation = orientation + aAngle;
2232 field->KeepUpright();
2237 static_cast<PCB_TEXT*
>( item )->KeepUpright();
2249 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2284 field->Flip(
m_pos,
false );
2295 zone->Flip(
m_pos,
false );
2299 item->Flip(
m_pos,
false );
2302 if( aFlipLeftRight )
2322 field->EDA_TEXT::Offset(
delta );
2328 zone->Move(
delta );
2331 item->Move(
delta );
2359 field->Move( moveVector );
2363 pad->Move( moveVector );
2367 item->Move( moveVector );
2371 zone->Move( moveVector );
2431 switch( aItem->
Type() )
2435 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2438 if( aAddToFootprint )
2439 m_pads.push_back( new_pad );
2447 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2450 if( aAddToFootprint )
2451 m_zones.push_back( new_zone );
2453 new_item = new_zone;
2477 if( aAddToFootprint )
2480 new_item = new_text;
2489 if( aAddToFootprint )
2492 new_item = new_shape;
2501 if( aAddToFootprint )
2504 new_item = new_textbox;
2516 if( aAddToFootprint )
2519 new_item = dimension;
2527 if( aAddToFootprint )
2529 group->RunOnDescendants(
2548 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2558 std::set<wxString> usedNumbers;
2562 usedNumbers.insert(
pad->GetNumber() );
2569 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2572 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2623 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2627 return aPolySet.
Area();
2642 return markerShape.
Area();
2646 double combinedArea = 0.0;
2651 return combinedArea;
2681 case SHAPE_T::SEGMENT:
2683 case SHAPE_T::BEZIER:
2686 case SHAPE_T::RECTANGLE:
2687 case SHAPE_T::CIRCLE:
2702 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2703 return width * width;
2729 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2733 switch( item->
Type() )
2762 double footprintRegionArea =
polygonArea( footprintRegion );
2763 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2764 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2765 double ratio = ( coveredArea / footprintRegionArea );
2772 return std::min( ratio, 1.0 );
2778 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2799 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2804 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2838 std::vector<PCB_SHAPE*> list_front;
2839 std::vector<PCB_SHAPE*> list_back;
2840 std::map<int, int> front_width_histogram;
2841 std::map<int, int> back_width_histogram;
2848 list_back.push_back( shape );
2855 list_front.push_back( shape );
2860 if( !list_front.size() && !list_back.size() )
2867 true, aErrorHandler ) )
2875 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
2876 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2878 return a.second < b.second;
2881 if( max != front_width_histogram.end() )
2904 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
2905 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2907 return a.second < b.second;
2910 if( max != back_width_histogram.end() )
2931 std::map<wxString, int> padNumberToGroupIdxMap;
2934 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
2937 [&]( wxString aPad,
int aGroup )
2939 aPad.Trim(
true ).Trim(
false );
2941 if( !aPad.IsEmpty() )
2942 padNumberToGroupIdxMap[ aPad ] = aGroup;
2951 for( wxUniCharRef ch :
group )
2960 switch(
static_cast<unsigned char>( ch ) )
2967 processPad(
pad, ii );
2977 processPad(
pad, ii );
2980 return padNumberToGroupIdxMap;
2990 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
2991 std::vector<PAD*> otherPads;
2997 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
2998 otherPads.push_back(
pad );
3011 if( setAttr && likelyAttr && setAttr != likelyAttr )
3015 switch( likelyAttr )
3018 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3021 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3026 (aErrorHandler)( msg );
3032 const wxString& )>& aErrorHandler )
3034 if( aErrorHandler ==
nullptr )
3039 if(
pad->GetAttribute() == PAD_ATTRIB::PTH ||
pad->GetAttribute() == PAD_ATTRIB::NPTH )
3041 if(
pad->GetDrillSizeX() < 1 ||
pad->GetDrillSizeY() < 1 )
3045 if(
pad->GetAttribute() == PAD_ATTRIB::PTH )
3047 if( !
pad->IsOnCopperLayer() )
3059 std::shared_ptr<SHAPE_SEGMENT> hole =
pad->GetEffectiveHoleShape();
3072 if(
pad->GetAttribute() == PAD_ATTRIB::SMD )
3077 _(
"(SMD pad appears on both front and back copper)" ) );
3079 else if(
pad->IsOnLayer(
F_Cu ) )
3084 _(
"(SMD pad copper and mask layers don't match)" ) );
3089 _(
"(SMD pad copper and paste layers don't match)" ) );
3092 else if(
pad->IsOnLayer(
B_Cu ) )
3097 _(
"(SMD pad copper and mask layers don't match)" ) );
3102 _(
"(SMD pad copper and paste layers don't match)" ) );
3111 const VECTOR2I& )>& aErrorHandler )
3113 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3121 if( other ==
pad ||
pad->SameLogicalPadAs( other ) )
3134 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3137 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3139 checkedPairs[ { a, b } ] = 1;
3141 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3144 SHAPE* padShape =
pad->GetEffectiveShape().get();
3145 SHAPE* otherShape = other->GetEffectiveShape().get();
3147 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3148 aErrorHandler(
pad, other, pos );
3159 const VECTOR2I& )>& aErrorHandler )
3168 std::vector<BOARD_ITEM*> copperItems;
3172 if( item->IsOnCopperLayer() )
3173 copperItems.push_back( item );
3175 item->RunOnDescendants(
3179 copperItems.push_back( descendent );
3185 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3186 copperItems.push_back( zone );
3191 if( field->IsOnCopperLayer() )
3192 copperItems.push_back( field );
3202 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3206 if( item->IsOnLayer( layer ) )
3208 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3219 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3221 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3222 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3229 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3231 if( pads.size() > 1 )
3233 const PAD* firstPad = pads[0];
3234 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3236 for(
size_t ii = 1; ii < pads.size(); ++ii )
3238 const PAD* thisPad = pads[ii];
3239 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3241 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3250 if( item->HitTest( pos, 1 ) )
3252 shortingItem = item;
3258 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3260 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3271 std::set<wxString> padNumbers;
3276 for(
auto [ padNumber,
_ ] : ret )
3282 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3283 aErrorHandler( msg );
3285 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3287 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3288 aErrorHandler( msg );
3300 std::swap( *
this, *
image );
3308 image->RunOnChildren(
3320 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3335 return *
this == other;
3344 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3353 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3362 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3371 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3388 double similarity = 1.0;
3390 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3398 similarity *=
pad->Similarity( *otherPad );
3407 if( itemA->
Type() != itemB->
Type() )
3408 return itemA->
Type() < itemB->
Type();
3423 if( dwgA->
GetShape() != SHAPE_T::POLY )
3436 if( dwgA->
GetShape() == SHAPE_T::ARC )
3443 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3455 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3478 return itemA < itemB;
3506 return aFirst < aSecond;
3550 if( firstShape->VertexCount() != secondShape->VertexCount() )
3551 return firstShape->VertexCount() < secondShape->VertexCount();
3553 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3555 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3556 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3557 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3558 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3576 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3587 return aFirst < aSecond;
3592 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3593 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3594 bool aSkipNonPlatedPads )
const
3598 if( !
pad->FlashLayer( aLayer ) )
3601 VECTOR2I clearance( aClearance, aClearance );
3606 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3609 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3615 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3618 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3625 clearance.
x +=
pad->GetSolderMaskExpansion();
3626 clearance.
y +=
pad->GetSolderMaskExpansion();
3631 clearance +=
pad->GetSolderPasteMargin();
3644 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3645 &&
pad->GetShape() != PAD_SHAPE::CUSTOM )
3647 VECTOR2I dummySize =
pad->GetSize() + clearance + clearance;
3649 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3653 dummy.SetSize( dummySize );
3654 dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
3658 pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.
x, aMaxError, aErrorLoc );
3665 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3666 bool aIncludeText,
bool aIncludeShapes,
3667 bool aIncludePrivateItems )
const
3669 std::vector<const PCB_TEXT*> texts;
3676 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3681 texts.push_back(
text );
3692 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3698 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3711 if( field->GetLayer() == aLayer && field->IsVisible() )
3712 texts.push_back( field );
3717 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3727 if( zcMap.
Choices().GetCount() == 0 )
3729 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3730 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3731 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3732 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3733 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3734 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3739 if( layerEnum.
Choices().GetCount() == 0 )
3747 wxPGChoices fpLayers;
3760 layer->SetChoices( fpLayers );
3765 PROPERTY_DISPLAY::PT_DEGREE ) );
3767 const wxString groupFields =
_HKI(
"Fields" );
3786 const wxString groupAttributes =
_HKI(
"Attributes" );
3800 const wxString groupOverrides =
_HKI(
"Overrides" );
3803 _HKI(
"Exempt From Courtyard Requirement" ),
3807 _HKI(
"Clearance Override" ),
3809 PROPERTY_DISPLAY::PT_SIZE ),
3812 _HKI(
"Solderpaste Margin Override" ),
3814 PROPERTY_DISPLAY::PT_SIZE ),
3817 _HKI(
"Solderpaste Margin Ratio Override" ),
3820 PROPERTY_DISPLAY::PT_RATIO ),
3823 _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...
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.
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.