26#include <magic_enum.hpp>
28#include <unordered_set>
61#include <google/protobuf/any.pb.h>
62#include <api/board/board_types.pb.h>
71 m_boundingBoxCacheTimeStamp( 0 ),
72 m_textExcludedBBoxCacheTimeStamp( 0 ),
73 m_hullCacheTimeStamp( 0 ),
74 m_initial_comments( nullptr ),
75 m_componentClass( nullptr )
155 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
163 ptrMap[field] = newField;
164 Add( newField, ADD_MODE::APPEND );
175 PAD* newPad =
static_cast<PAD*
>(
pad->Clone() );
176 ptrMap[
pad ] = newPad;
177 Add( newPad, ADD_MODE::APPEND );
183 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
184 ptrMap[ zone ] = newZone;
185 Add( newZone, ADD_MODE::APPEND );
198 ptrMap[ item ] = newItem;
199 Add( newItem, ADD_MODE::APPEND );
206 ptrMap[
group ] = newGroup;
207 Add( newGroup, ADD_MODE::APPEND );
219 if( ptrMap.count( member ) )
220 newGroup->
AddItem( ptrMap[ member ] );
243 *
this = std::move( aFootprint );
253 item->SetParentGroup(
nullptr );
285 board->IncrementTimeStamp();
292 types::FootprintInstance footprint;
295 footprint.mutable_position()->set_x_nm(
GetPosition().x );
296 footprint.mutable_position()->set_y_nm(
GetPosition().y );
298 footprint.set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>(
GetLayer() ) );
299 footprint.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
300 : kiapi::common::types::LockedState::LS_UNLOCKED );
302 google::protobuf::Any buf;
304 buf.UnpackTo( footprint.mutable_reference_field() );
306 buf.UnpackTo( footprint.mutable_value_field() );
308 buf.UnpackTo( footprint.mutable_datasheet_field() );
310 buf.UnpackTo( footprint.mutable_description_field() );
312 types::FootprintAttributes* attrs = footprint.mutable_attributes();
318 attrs->set_do_not_populate(
IsDNP() );
320 types::Footprint* def = footprint.mutable_definition();
325 def->mutable_attributes()->set_keywords(
GetKeywords().ToStdString() );
329 types::FootprintDesignRuleOverrides* overrides = def->mutable_overrides();
343 overrides->set_zone_connection(
348 types::NetTieDefinition* netTie = def->add_net_ties();
349 wxStringTokenizer tokenizer(
group,
" " );
351 while( tokenizer.HasMoreTokens() )
352 netTie->add_pad_number( tokenizer.GetNextToken().ToStdString() );
356 def->add_private_layers( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
366 google::protobuf::Any* itemMsg = def->add_items();
367 item->Serialize( *itemMsg );
370 for(
const PAD* item :
Pads() )
372 google::protobuf::Any* itemMsg = def->add_items();
373 item->Serialize( *itemMsg );
378 google::protobuf::Any* itemMsg = def->add_items();
379 item->Serialize( *itemMsg );
384 google::protobuf::Any* itemMsg = def->add_items();
385 item->Serialize( *itemMsg );
390 google::protobuf::Any* itemMsg = def->add_items();
391 types::Footprint3DModel modelMsg;
392 modelMsg.set_filename( model.m_Filename.ToUTF8() );
396 modelMsg.set_visible( model.m_Show );
397 modelMsg.set_opacity( model.m_Opacity );
398 itemMsg->PackFrom( modelMsg );
401 aContainer.PackFrom( footprint );
408 types::FootprintInstance footprint;
410 if( !aContainer.UnpackTo( &footprint ) )
416 SetLayer( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( footprint.layer() ) );
417 SetLocked( footprint.locked() == kiapi::common::types::LockedState::LS_LOCKED );
419 google::protobuf::Any buf;
420 types::Field mandatoryField;
422 if( footprint.has_reference_field() )
424 mandatoryField = footprint.reference_field();
426 buf.PackFrom( mandatoryField );
430 if( footprint.has_value_field() )
432 mandatoryField = footprint.value_field();
433 mandatoryField.mutable_id()->set_id(
VALUE_FIELD );
434 buf.PackFrom( mandatoryField );
438 if( footprint.has_datasheet_field() )
440 mandatoryField = footprint.datasheet_field();
442 buf.PackFrom( mandatoryField );
446 if( footprint.has_description_field() )
448 mandatoryField = footprint.description_field();
450 buf.PackFrom( mandatoryField );
454 SetBoardOnly( footprint.attributes().not_in_schematic() );
458 SetDNP( footprint.attributes().do_not_populate() );
464 SetKeywords( footprint.definition().attributes().keywords() );
466 const types::FootprintDesignRuleOverrides& overrides = footprint.overrides();
468 if( overrides.has_copper_clearance() )
473 if( overrides.has_solder_mask() && overrides.solder_mask().has_solder_mask_margin() )
478 if( overrides.has_solder_paste() )
480 const types::SolderPasteOverrides& pasteSettings = overrides.solder_paste();
482 if( pasteSettings.has_solder_paste_margin() )
487 if( pasteSettings.has_solder_paste_margin_ratio() )
495 for(
const types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
499 for(
const std::string&
pad : netTieMsg.pad_number() )
500 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
508 for(
int layerMsg : footprint.definition().private_layers() )
510 auto layer =
static_cast<types::BoardLayer
>( layerMsg );
511 privateLayers.
set( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
529 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
537 if( itemMsg.type_url() ==
"type.googleapis.com/kiapi.board.types.Footprint3DModel" )
539 types::Footprint3DModel modelMsg;
541 if( !itemMsg.UnpackTo( &modelMsg ) )
546 model.
m_Filename = wxString::FromUTF8( modelMsg.filename() );
547 model.
m_Show = modelMsg.visible();
553 Models().push_back( model );
557 wxLogTrace(
traceApi, wxString::Format( wxS(
"Attempting to unpack unknown type %s "
558 "from footprint message, skipping" ),
559 itemMsg.type_url() ) );
567 if( item && item->Deserialize( itemMsg ) )
568 Add( item.release(), ADD_MODE::APPEND );
578 wxASSERT_MSG( field, wxT(
"Requesting a null field (likely FOOTPRINT)" ) );
587 wxASSERT_MSG( field, wxT(
"Requesting a null field (likely FOOTPRINT)" ) );
597 if( field && field->GetId() == aFieldId )
608 if( field && field->GetCanonicalName() == aFieldName )
617 if( aFieldName.empty() )
622 if( field && field->GetName() == aFieldName )
634 if( field && ( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() ) )
635 return field->GetText();
638 return wxEmptyString;
644 std::vector<PCB_FIELD*> fields;
656 if( !field->IsVisible() || field->GetText().IsEmpty() )
660 fields.push_back( field );
686 if( aFieldName ==
m_fields[i]->GetName(
false ) )
709 switch( item->Type() )
719 if( aStyleShapes && !item->IsOnCopperLayer() )
734 std::vector< BOARD_ITEM* > item_list;
739 item_list.push_back( field );
743 item_list.push_back(
pad );
746 item_list.push_back( gr_item );
751 item_list.push_back(
group );
755 item_list.push_back( zone );
757 bool changed =
false;
763 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
776 m_pos = aOther.m_pos;
804 for(
PCB_FIELD* field : aOther.m_fields )
815 for(
PAD*
pad : aOther.Pads() )
818 aOther.Pads().clear();
823 for(
ZONE* item : aOther.Zones() )
831 item->SetNetCode( -1 );
834 aOther.Zones().clear();
839 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
842 aOther.GraphicalItems().clear();
850 aOther.Groups().clear();
861 aOther.m_fields.clear();
862 aOther.Pads().clear();
863 aOther.Zones().clear();
864 aOther.GraphicalItems().clear();
865 aOther.m_initial_comments =
nullptr;
900 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
910 ptrMap[field] = newField;
925 ptrMap[
pad ] = newPad;
934 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
935 ptrMap[ zone ] = newZone;
951 ptrMap[ item ] = newItem;
964 newGroup->
AddItem( ptrMap[ member ] );
990 aVars->push_back( wxT(
"REFERENCE" ) );
991 aVars->push_back( wxT(
"VALUE" ) );
992 aVars->push_back( wxT(
"LAYER" ) );
993 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
994 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
995 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
996 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
997 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
998 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
1007 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
1012 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
1017 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
1022 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
1027 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
1032 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
1033 || token->StartsWith( wxT(
"NET_NAME(" ) )
1034 || token->StartsWith( wxT(
"NET_CLASS(" ) )
1035 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
1037 wxString padNumber = token->AfterFirst(
'(' );
1038 padNumber = padNumber.BeforeLast(
')' );
1042 if(
pad->GetNumber() == padNumber )
1044 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
1045 *token =
pad->GetShortNetname();
1046 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
1047 *token =
pad->GetNetname();
1048 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
1049 *token =
pad->GetNetClassName();
1051 *token =
pad->GetPinFunction();
1081 switch( aBoardItem->
Type() )
1099 if( aMode == ADD_MODE::APPEND )
1106 if( aMode == ADD_MODE::APPEND )
1107 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
1109 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1113 if( aMode == ADD_MODE::APPEND )
1114 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1120 if( aMode == ADD_MODE::APPEND )
1129 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1130 aBoardItem->
Type() );
1144 switch( aBoardItem->
Type() )
1150 if( *it == aBoardItem )
1171 if( *it == aBoardItem )
1181 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1183 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1195 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1207 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1219 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1220 aBoardItem->
Type() );
1251 switch(
pad->GetProperty() )
1253 case PAD_PROP::FIDUCIAL_GLBL:
1254 case PAD_PROP::FIDUCIAL_LOCAL:
1257 case PAD_PROP::HEATSINK:
1258 case PAD_PROP::CASTELLATED:
1259 case PAD_PROP::MECHANICAL:
1262 case PAD_PROP::NONE:
1264 case PAD_PROP::TESTPOINT:
1268 switch(
pad->GetAttribute() )
1270 case PAD_ATTRIB::PTH:
1274 case PAD_ATTRIB::SMD:
1275 if(
pad->IsOnCopperLayer() )
1303 return _(
"Through hole" );
1305 return _(
"Other" );
1320 if(
dummy.IsFlipped() )
1324 bbox.
Merge(
pad->GetBoundingBox() );
1327 dummy.SetParent(
nullptr );
1328 dummy.SetParentGroup(
nullptr );
1373 std::vector<PCB_TEXT*> texts;
1395 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1413 bbox.
Merge( item->GetBoundingBox() );
1419 if( field && !field->IsReference() && !field->IsValue() )
1420 texts.push_back( field );
1424 bbox.
Merge(
pad->GetBoundingBox() );
1427 bbox.
Merge( zone->GetBoundingBox() );
1432 if( aIncludeText || noDrawItems )
1441 if(
text->IsVisible() )
1447 bool valueLayerIsVisible =
true;
1448 bool refLayerIsVisible =
true;
1466 if( (
Value().IsVisible() && valueLayerIsVisible ) || noDrawItems )
1471 if( (
Reference().IsVisible() && refLayerIsVisible ) || noDrawItems )
1479 if( aIncludeText || noDrawItems )
1497 std::vector<PCB_TEXT*> texts;
1509 if( ( aLayers & item->GetLayerSet() ).none() )
1517 bbox.
Merge( item->GetBoundingBox() );
1522 if( ( aLayers &
pad->GetLayerSet() ).none() )
1525 bbox.
Merge(
pad->GetBoundingBox() );
1530 if( ( aLayers & zone->GetLayerSet() ).none() )
1533 bbox.
Merge( zone->GetBoundingBox() );
1570 pad->Padstack().ForEachUniqueLayer(
1584 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1611 std::vector<VECTOR2I> convex_hull;
1617 for(
const VECTOR2I& pt : convex_hull )
1641 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1643 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1645 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1648 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1657 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1658 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1662 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1664 if( !aStr->IsEmpty() )
1665 *aStr += wxT(
", " );
1674 addToken( &status,
_(
"Locked" ) );
1677 addToken( &status,
_(
"autoplaced" ) );
1680 addToken( &attrs,
_(
"not in schematic" ) );
1683 addToken( &attrs,
_(
"exclude from pos files" ) );
1686 addToken( &attrs,
_(
"exclude from BOM" ) );
1689 addToken( &attrs,
_(
"DNP" ) );
1691 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1693 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1702 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1704 aList.emplace_back( msg, msg2 );
1708 aList.emplace_back( msg, msg2 );
1716 if( board->IsFootprintHolder() )
1748 if(
pad->IsOnLayer( aLayer ) )
1754 if( zone->IsOnLayer( aLayer ) )
1760 if( field && field->IsOnLayer( aLayer ) )
1766 if( item->IsOnLayer( aLayer ) )
1778 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1784 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1790 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1791 && item->HitTest( aPosition, aAccuracy ) )
1803 std::vector<BOARD_ITEM*> items;
1807 if(
pad->IsOnLayer( aLayer ) )
1808 items.push_back(
pad );
1813 if( zone->IsOnLayer( aLayer ) )
1814 items.push_back( zone );
1819 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1820 items.push_back( item );
1829 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1831 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1838 return !items.empty() && aContained;
1857 BOX2I arect = aRect;
1877 if(
pad->HitTest( arect,
false, 0 ) )
1883 if( zone->HitTest( arect,
false, 0 ) )
1894 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1908 bool can_select = aSearchAfterMe ? false :
true;
1912 if( !can_select &&
pad == aSearchAfterMe )
1918 if( can_select &&
pad->GetNumber() == aPadNumber )
1931 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1934 if(
pad->HitTest( aPosition ) )
1944 std::vector<const PAD*> retv;
1948 if( ( aIgnore && aIgnore ==
pad ) || (
pad->GetNumber() != aPadNumber ) )
1951 retv.push_back(
pad );
1967 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1979 std::set<wxString> usedNumbers;
1991 if(
pad->GetNumber().IsEmpty() )
1997 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
2001 usedNumbers.insert(
pad->GetNumber() );
2016 if(
nullptr == a3DModel )
2026 const std::vector<KICAD_T>& aScanTypes )
2028#if 0 && defined(DEBUG)
2029 std::cout <<
GetClass().mb_str() <<
' ';
2032 bool drawingsScanned =
false;
2034 for(
KICAD_T scanType : aScanTypes )
2039 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
2040 return INSPECT_RESULT::QUIT;
2045 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
2046 == INSPECT_RESULT::QUIT )
2048 return INSPECT_RESULT::QUIT;
2054 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
2055 == INSPECT_RESULT::QUIT )
2057 return INSPECT_RESULT::QUIT;
2063 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
2064 == INSPECT_RESULT::QUIT )
2066 return INSPECT_RESULT::QUIT;
2081 if( !drawingsScanned )
2083 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
2084 == INSPECT_RESULT::QUIT )
2086 return INSPECT_RESULT::QUIT;
2089 drawingsScanned =
true;
2095 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
2096 == INSPECT_RESULT::QUIT )
2098 return INSPECT_RESULT::QUIT;
2108 return INSPECT_RESULT::CONTINUE;
2116 if( reference.IsEmpty() )
2117 reference =
_(
"<no reference designator>" );
2119 return wxString::Format(
_(
"Footprint %s" ), reference );
2125 return BITMAPS::module;
2155 aFunction( drawing );
2157 catch( std::bad_function_call& )
2159 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2188 group->RunOnDescendants( aFunction, aDepth + 1 );
2193 aFunction( drawing );
2194 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2197 catch( std::bad_function_call& )
2199 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2206 std::vector<int> layers;
2208 layers.reserve( 6 );
2214 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2235 bool f_silk =
false, b_silk =
false, non_silk =
false;
2239 if( item->GetLayer() ==
F_SilkS )
2241 else if( item->GetLayer() ==
B_SilkS )
2247 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2292 constexpr double MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY = 1.5;
2295 return MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY;
2308 int biggest_clearance = board->GetMaxClearanceValue();
2309 area.
Inflate( biggest_clearance );
2320 if( aName.find_first_of( invalids ) != std::string::npos )
2334 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2335 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2338 return invalidCharsReadable;
2340 return invalidChars;
2346 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2360 EDA_ANGLE newOrientation = orientation + aAngle;
2369 field->KeepUpright();
2375 static_cast<PCB_TEXT*
>( item )->KeepUpright();
2382 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2419 field->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2424 pad->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2431 zone->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2435 item->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2438 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
2460 field->EDA_TEXT::Offset(
delta );
2467 zone->Move(
delta );
2470 item->Move(
delta );
2504 field->Move( moveVector );
2509 pad->Move( moveVector );
2513 item->Move( moveVector );
2517 zone->Move( moveVector );
2587 switch( aItem->
Type() )
2591 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2594 if( aAddToFootprint )
2595 m_pads.push_back( new_pad );
2603 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2606 if( aAddToFootprint )
2607 m_zones.push_back( new_zone );
2609 new_item = new_zone;
2631 if( aAddToFootprint )
2634 new_item = new_text;
2643 if( aAddToFootprint )
2646 new_item = new_shape;
2655 if( aAddToFootprint )
2658 new_item = new_textbox;
2670 if( aAddToFootprint )
2673 new_item = dimension;
2681 if( aAddToFootprint )
2683 group->RunOnDescendants(
2702 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2712 std::set<wxString> usedNumbers;
2716 usedNumbers.insert(
pad->GetNumber() );
2723 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2726 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2777 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2781 return aPolySet.
Area();
2796 return markerShape.
Area();
2800 double combinedArea = 0.0;
2805 return combinedArea;
2835 case SHAPE_T::SEGMENT:
2837 case SHAPE_T::BEZIER:
2840 case SHAPE_T::RECTANGLE:
2841 case SHAPE_T::CIRCLE:
2856 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2857 return width * width;
2861 static_cast<const PAD*
>( aItem )->Padstack().ForEachUniqueLayer(
2893 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2897 switch( item->
Type() )
2928 double footprintRegionArea =
polygonArea( footprintRegion );
2929 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2930 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2931 double ratio = ( coveredArea / footprintRegionArea );
2938 return std::min( ratio, 1.0 );
2944 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2965 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2970 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
3010 std::vector<PCB_SHAPE*> list_front;
3011 std::vector<PCB_SHAPE*> list_back;
3012 std::map<int, int> front_width_histogram;
3013 std::map<int, int> back_width_histogram;
3020 list_back.push_back( shape );
3027 list_front.push_back( shape );
3032 if( !list_front.size() && !list_back.size() )
3039 true, aErrorHandler ) )
3049 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
3050 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
3052 return a.second < b.second;
3055 if( max != front_width_histogram.end() )
3078 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
3079 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
3081 return a.second < b.second;
3084 if( max != back_width_histogram.end() )
3107 std::map<PCB_LAYER_ID, std::vector<PCB_SHAPE*>> layer_shapes;
3112 if( item->Type() != PCB_SHAPE_T )
3115 for( PCB_LAYER_ID layer : item->GetLayerSet() )
3116 layer_shapes[layer].push_back( static_cast<PCB_SHAPE*>( item ) );
3119 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3122 bool has_nettie =
false;
3124 auto it = map.find(
pad->GetNumber() );
3126 if( it == map.end() || it->second < 0 )
3129 for(
size_t jj = ii + 1; jj <
m_pads.size(); ++jj )
3133 auto it2 = map.find( other->
GetNumber() );
3135 if( it2 == map.end() || it2->second < 0 )
3138 if( it2->second == it->second )
3151 for(
auto& [ layer, shapes ] : layer_shapes )
3153 auto pad_shape =
pad->GetEffectiveShape( layer );
3155 for(
auto other_shape : shapes )
3157 auto shape = other_shape->GetEffectiveShape( layer );
3159 if( pad_shape->Collide( shape.get() ) )
3162 m_netTieCache[other_shape].insert( nettie.begin(), nettie.end() );
3172 std::map<wxString, int> padNumberToGroupIdxMap;
3175 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
3178 [&]( wxString aPad,
int aGroup )
3180 aPad.Trim(
true ).Trim(
false );
3182 if( !aPad.IsEmpty() )
3183 padNumberToGroupIdxMap[ aPad ] = aGroup;
3192 for( wxUniCharRef ch :
group )
3201 switch(
static_cast<unsigned char>( ch ) )
3208 processPad(
pad, ii );
3218 processPad(
pad, ii );
3221 return padNumberToGroupIdxMap;
3231 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
3232 std::vector<PAD*> otherPads;
3238 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
3239 otherPads.push_back(
pad );
3252 if( setAttr && likelyAttr && setAttr != likelyAttr )
3256 switch( likelyAttr )
3259 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3262 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3267 (aErrorHandler)( msg );
3273 const std::function<
void(
const PAD*,
int,
3274 const wxString& )>& aErrorHandler )
3276 if( aErrorHandler ==
nullptr )
3281 pad->CheckPad( aUnitsProvider,
false,
3282 [&](
int errorCode,
const wxString& msg )
3284 aErrorHandler(
pad, errorCode, msg );
3292 const VECTOR2I& )>& aErrorHandler )
3294 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3309 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3312 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3314 checkedPairs[ { a, b } ] = 1;
3316 if(
pad->HasDrilledHole() && other->HasDrilledHole() )
3320 if(
pad->GetPosition() == other->GetPosition() )
3326 std::shared_ptr<SHAPE_SEGMENT> holeA =
pad->GetEffectiveHoleShape();
3327 std::shared_ptr<SHAPE_SEGMENT> holeB = other->GetEffectiveHoleShape();
3329 if( holeA->Collide( holeB->GetSeg(), 0 ) )
3340 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3344 for(
PCB_LAYER_ID l :
pad->Padstack().RelevantShapeLayers( other->Padstack() ) )
3346 SHAPE* padShape =
pad->GetEffectiveShape( l ).get();
3347 SHAPE* otherShape = other->GetEffectiveShape( l ).get();
3349 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3362 const VECTOR2I& )>& aErrorHandler )
3371 std::vector<BOARD_ITEM*> copperItems;
3375 if( item->IsOnCopperLayer() )
3376 copperItems.push_back( item );
3378 item->RunOnDescendants(
3382 copperItems.push_back( descendent );
3388 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3389 copperItems.push_back( zone );
3394 if( field && field->IsOnCopperLayer() )
3395 copperItems.push_back( field );
3405 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3409 if( item->IsOnLayer( layer ) )
3411 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3422 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3424 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3425 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3432 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3434 if( pads.size() > 1 )
3436 const PAD* firstPad = pads[0];
3437 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3439 for(
size_t ii = 1; ii < pads.size(); ++ii )
3441 const PAD* thisPad = pads[ii];
3442 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3444 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3453 if( item->HitTest( pos, 1 ) )
3455 shortingItem = item;
3461 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3463 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3474 std::set<wxString> padNumbers;
3483 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3484 aErrorHandler( msg );
3486 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3488 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3489 aErrorHandler( msg );
3501 std::swap( *
this, *
image );
3509 image->RunOnChildren(
3521 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3536 return *
this == other;
3545 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3554 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3563 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3572 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3592 double similarity = 1.0;
3601 similarity *=
pad->Similarity( *otherPad );
3610 if( itemA->
Type() != itemB->
Type() )
3611 return itemA->
Type() < itemB->
Type();
3626 if( dwgA->
GetShape() != SHAPE_T::POLY )
3639 if( dwgA->
GetShape() == SHAPE_T::ARC )
3646 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3658 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3681 return itemA < itemB;
3695 std::optional<bool> padCopperMatches;
3698 const PAD* checkPad = aFirst;
3711 padCopperMatches = aFirst->
GetSize( aLayer ).
x < aSecond->
GetSize( aLayer ).
x;
3713 padCopperMatches = aFirst->
GetSize( aLayer ).
y < aSecond->
GetSize( aLayer ).
y;
3715 padCopperMatches = aFirst->
GetShape( aLayer ) < aSecond->
GetShape( aLayer );
3718 if( padCopperMatches.has_value() )
3719 return *padCopperMatches;
3727 return aFirst < aSecond;
3732bool FOOTPRINT::cmp_padstack::operator()(
const PAD* aFirst,
const PAD* aSecond )
const
3772 if( firstShape->VertexCount() != secondShape->VertexCount() )
3773 return firstShape->VertexCount() < secondShape->VertexCount();
3775 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3777 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3778 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3779 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3780 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3799 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3810 return aFirst < aSecond;
3815 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3816 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3817 bool aSkipNonPlatedPads )
const
3822 VECTOR2I clearance( aClearance, aClearance );
3827 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3830 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3836 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3839 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3846 clearance.
x +=
pad->GetSolderMaskExpansion( padLayer );
3847 clearance.
y +=
pad->GetSolderMaskExpansion( padLayer );
3852 clearance +=
pad->GetSolderPasteMargin( padLayer );
3865 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3866 &&
pad->GetShape( padLayer ) != PAD_SHAPE::CUSTOM )
3868 VECTOR2I dummySize =
pad->GetSize( padLayer ) + clearance + clearance;
3870 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3874 dummy.SetSize( padLayer, dummySize );
3875 dummy.TransformShapeToPolygon( aBuffer, padLayer, 0, aMaxError, aErrorLoc );
3879 pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.
x, aMaxError,
3886 if( !
pad->FlashLayer( aLayer ) )
3891 pad->Padstack().ForEachUniqueLayer(
3894 processPad(
pad, l );
3899 processPad(
pad, aLayer );
3906 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3907 bool aIncludeText,
bool aIncludeShapes,
3908 bool aIncludePrivateItems )
const
3910 std::vector<const PCB_TEXT*> texts;
3917 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3922 texts.push_back(
text );
3933 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3939 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3952 if( field && field->GetLayer() == aLayer && field->IsVisible() )
3953 texts.push_back( field );
3958 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3965 using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
3967 std::set<OUTLINE_FONT*>
fonts;
3973 if(
auto* font =
text->GetFont(); font && !font->IsStroke() )
3975 auto* outline =
static_cast<OUTLINE_FONT*
>( font );
3976 auto permission = outline->GetEmbeddingPermission();
3978 if( permission == EMBEDDING_PERMISSION::EDITABLE
3979 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3981 fonts.insert( outline );
3995 for(
auto* font :
fonts )
4010 return wxEmptyString;
4020 if( zcMap.
Choices().GetCount() == 0 )
4022 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
4023 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
4024 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
4025 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
4026 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
4027 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
4032 if( layerEnum.
Choices().GetCount() == 0 )
4040 wxPGChoices fpLayers;
4053 layer->SetChoices( fpLayers );
4058 PROPERTY_DISPLAY::PT_DEGREE ) );
4060 const wxString groupFields =
_HKI(
"Fields" );
4085 const wxString groupAttributes =
_HKI(
"Attributes" );
4099 const wxString groupOverrides =
_HKI(
"Overrides" );
4102 _HKI(
"Exempt From Courtyard Requirement" ),
4106 _HKI(
"Clearance Override" ),
4108 PROPERTY_DISPLAY::PT_SIZE ),
4111 _HKI(
"Solderpaste Margin Override" ),
4113 PROPERTY_DISPLAY::PT_SIZE ),
4116 _HKI(
"Solderpaste Margin Ratio Override" ),
4119 PROPERTY_DISPLAY::PT_RATIO ),
4122 _HKI(
"Zone Connection Style" ),
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
BITMAPS
A list of all bitmap identifiers.
#define DEFAULT_COURTYARD_WIDTH
BASE_SET & set(size_t pos)
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
PCB_GROUP * GetParentGroup() const
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
VECTOR2I GetFPRelativePosition() const
BOARD_ITEM_CONTAINER * GetParent() const
virtual bool IsOnCopperLayer() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Information pertinent to a Pcbnew printed circuit board.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
constexpr void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
constexpr coord_type GetTop() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
virtual int Accuracy() const =0
int GetCount() const
Return the number of objects in the list.
const wxString & GetFullName() const
Fetches the full name of this component class.
wxString GetName() const
Fetches the display name of this component class.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void ClearEditFlags()
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
virtual wxString GetClass() const =0
Return the class name.
EDA_ITEM_FLAGS GetFlags() const
const VECTOR2I & GetBezierC2() const
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
const VECTOR2I & GetBezierC1() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
bool m_embedFonts
If set, fonts will be embedded in the element on save.
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
wxString m_Filename
The 3D shape filename in 3D library.
bool m_Show
Include model in rendering.
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.
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
std::string AsStdString() const
wxString GetUniStringLibId() const
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET SideSpecificMask()
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
int GetDrillSizeY() const
PAD_ATTRIB GetAttribute() const
const wxString & GetNumber() const
VECTOR2I GetPosition() const override
int GetDrillSizeX() const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
const PADSTACK & Padstack() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
PAD_DRILL_SHAPE GetDrillShape() const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
std::optional< int > GetLocalSolderMaskMargin() const
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
virtual bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetWidth() const override
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
STROKE_PARAMS GetStroke() const override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
bool IsVisible() const override
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
double Area(bool aAbsolute=true) const
Return the area of this chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
void SetWidth(int aWidth)
Set the width of all segments in the chain.
Represent a set of closed polygons.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
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 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()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the reference to aHole-th hole in the aIndex-th outline.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both)
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Handle a list of polygons defining a copper zone.
SHAPE_POLY_SET * Outline()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
unsigned GetAssignedPriority() const
This file is part of the common library.
bool ConvertOutlineToPolygon(std::vector< PCB_SHAPE * > &aShapeList, SHAPE_POLY_SET &aPolygons, int aErrorMax, int aChainingEpsilon, bool aAllowDisjoint, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons)
Build a polygon set with holes from a PCB_SHAPE list.
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
@ DRCE_DRILLED_HOLES_TOO_CLOSE
@ DRCE_DRILLED_HOLES_COLOCATED
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_180
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#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
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
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 conflicting.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API VECTOR3D UnpackVector3D(const types::Vector3D &aInput)
KICOMMON_API LIB_ID LibIdFromProto(const types::LibraryIdentifier &aId)
KICOMMON_API types::LibraryIdentifier LibIdToProto(const LIB_ID &aId)
KICOMMON_API void PackVector3D(types::Vector3D &aOutput, const VECTOR3D &aInput)
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