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 )
145 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
151 ptrMap[field] = newField;
152 Add( newField, ADD_MODE::APPEND );
158 PAD* newPad =
static_cast<PAD*
>(
pad->Clone() );
159 ptrMap[
pad ] = newPad;
160 Add( newPad, ADD_MODE::APPEND );
166 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
167 ptrMap[ zone ] = newZone;
168 Add( newZone, ADD_MODE::APPEND );
181 ptrMap[ item ] = newItem;
182 Add( newItem, ADD_MODE::APPEND );
189 ptrMap[
group ] = newGroup;
190 Add( newGroup, ADD_MODE::APPEND );
202 if( ptrMap.count( member ) )
203 newGroup->
AddItem( ptrMap[ member ] );
226 *
this = std::move( aFootprint );
236 item->SetParentGroup(
nullptr );
268 board->IncrementTimeStamp();
275 types::FootprintInstance footprint;
278 footprint.mutable_position()->set_x_nm(
GetPosition().x );
279 footprint.mutable_position()->set_y_nm(
GetPosition().y );
281 footprint.set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>(
GetLayer() ) );
282 footprint.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
283 : kiapi::common::types::LockedState::LS_UNLOCKED );
285 google::protobuf::Any buf;
287 buf.UnpackTo( footprint.mutable_reference_field() );
289 buf.UnpackTo( footprint.mutable_value_field() );
291 buf.UnpackTo( footprint.mutable_datasheet_field() );
293 buf.UnpackTo( footprint.mutable_description_field() );
295 types::FootprintAttributes* attrs = footprint.mutable_attributes();
301 attrs->set_do_not_populate(
IsDNP() );
303 types::Footprint* def = footprint.mutable_definition();
308 def->mutable_attributes()->set_keywords(
GetKeywords().ToStdString() );
312 types::FootprintDesignRuleOverrides* overrides = def->mutable_overrides();
326 overrides->set_zone_connection(
331 types::NetTieDefinition* netTie = def->add_net_ties();
332 wxStringTokenizer tokenizer(
group,
" " );
334 while( tokenizer.HasMoreTokens() )
335 netTie->add_pad_number( tokenizer.GetNextToken().ToStdString() );
339 def->add_private_layers( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
346 google::protobuf::Any* itemMsg = def->add_items();
347 item->Serialize( *itemMsg );
350 for(
const PAD* item :
Pads() )
352 google::protobuf::Any* itemMsg = def->add_items();
353 item->Serialize( *itemMsg );
358 google::protobuf::Any* itemMsg = def->add_items();
359 item->Serialize( *itemMsg );
364 google::protobuf::Any* itemMsg = def->add_items();
365 item->Serialize( *itemMsg );
370 google::protobuf::Any* itemMsg = def->add_items();
371 types::Footprint3DModel modelMsg;
372 modelMsg.set_filename( model.m_Filename.ToUTF8() );
376 modelMsg.set_visible( model.m_Show );
377 modelMsg.set_opacity( model.m_Opacity );
378 itemMsg->PackFrom( modelMsg );
381 aContainer.PackFrom( footprint );
388 types::FootprintInstance footprint;
390 if( !aContainer.UnpackTo( &footprint ) )
396 SetLayer( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( footprint.layer() ) );
397 SetLocked( footprint.locked() == kiapi::common::types::LockedState::LS_LOCKED );
399 google::protobuf::Any buf;
400 types::Field mandatoryField;
402 if( footprint.has_reference_field() )
404 mandatoryField = footprint.reference_field();
406 buf.PackFrom( mandatoryField );
410 if( footprint.has_value_field() )
412 mandatoryField = footprint.value_field();
413 mandatoryField.mutable_id()->set_id(
VALUE_FIELD );
414 buf.PackFrom( mandatoryField );
418 if( footprint.has_datasheet_field() )
420 mandatoryField = footprint.datasheet_field();
422 buf.PackFrom( mandatoryField );
426 if( footprint.has_description_field() )
428 mandatoryField = footprint.description_field();
430 buf.PackFrom( mandatoryField );
434 SetBoardOnly( footprint.attributes().not_in_schematic() );
438 SetDNP( footprint.attributes().do_not_populate() );
444 SetKeywords( footprint.definition().attributes().keywords() );
446 const types::FootprintDesignRuleOverrides& overrides = footprint.overrides();
448 if( overrides.has_copper_clearance() )
453 if( overrides.has_solder_mask() && overrides.solder_mask().has_solder_mask_margin() )
458 if( overrides.has_solder_paste() )
460 const types::SolderPasteOverrides& pasteSettings = overrides.solder_paste();
462 if( pasteSettings.has_solder_paste_margin() )
467 if( pasteSettings.has_solder_paste_margin_ratio() )
475 for(
const types::NetTieDefinition& netTieMsg : footprint.definition().net_ties() )
479 for(
const std::string&
pad : netTieMsg.pad_number() )
480 group.Append( wxString::Format( wxT(
"%s " ),
pad ) );
488 for(
int layerMsg : footprint.definition().private_layers() )
490 auto layer =
static_cast<types::BoardLayer
>( layerMsg );
491 privateLayers.
set( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( layer ) );
509 for(
const google::protobuf::Any& itemMsg : footprint.definition().items() )
517 if( itemMsg.type_url() ==
"type.googleapis.com/kiapi.board.types.Footprint3DModel" )
519 types::Footprint3DModel modelMsg;
521 if( !itemMsg.UnpackTo( &modelMsg ) )
526 model.
m_Filename = wxString::FromUTF8( modelMsg.filename() );
527 model.
m_Show = modelMsg.visible();
533 Models().push_back( model );
537 wxLogTrace(
traceApi, wxString::Format( wxS(
"Attempting to unpack unknown type %s "
538 "from footprint message, skipping" ),
539 itemMsg.type_url() ) );
547 if( item && item->Deserialize( itemMsg ) )
548 Add( item.release(), ADD_MODE::APPEND );
571 if( field->GetId() == aFieldId )
582 if( field->GetCanonicalName() == aFieldName )
591 if( aFieldName.empty() )
596 if( field->GetName() == aFieldName )
608 if( aFieldName == field->GetName() || aFieldName == field->GetCanonicalName() )
609 return field->GetText();
612 return wxEmptyString;
628 if( !field->IsVisible() || field->GetText().IsEmpty() )
632 aVector.push_back( field );
650 if( aFieldName ==
m_fields[i]->GetName(
false ) )
670 switch( item->Type() )
680 if( aStyleShapes && !item->IsOnCopperLayer() )
695 std::vector< BOARD_ITEM* > item_list;
698 item_list.push_back( field );
701 item_list.push_back(
pad );
704 item_list.push_back( gr_item );
709 item_list.push_back(
group );
713 item_list.push_back( zone );
715 bool changed =
false;
721 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
734 m_pos = aOther.m_pos;
762 for(
PCB_FIELD* field : aOther.Fields() )
768 for(
PAD*
pad : aOther.Pads() )
771 aOther.Pads().clear();
776 for(
ZONE* item : aOther.Zones() )
784 item->SetNetCode( -1 );
787 aOther.Zones().clear();
792 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
795 aOther.GraphicalItems().clear();
803 aOther.Groups().clear();
814 aOther.Fields().clear();
815 aOther.Pads().clear();
816 aOther.Zones().clear();
817 aOther.GraphicalItems().clear();
818 aOther.m_initial_comments =
nullptr;
853 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
861 ptrMap[field] = newField;
871 ptrMap[
pad ] = newPad;
880 ZONE* newZone =
static_cast<ZONE*
>( zone->Clone() );
881 ptrMap[ zone ] = newZone;
897 ptrMap[ item ] = newItem;
910 newGroup->
AddItem( ptrMap[ member ] );
936 aVars->push_back( wxT(
"REFERENCE" ) );
937 aVars->push_back( wxT(
"VALUE" ) );
938 aVars->push_back( wxT(
"LAYER" ) );
939 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
940 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
941 aVars->push_back( wxT(
"SHORT_NET_NAME(<pad_number>)" ) );
942 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
943 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
944 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
953 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
958 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
963 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
968 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
973 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
978 else if( token->StartsWith( wxT(
"SHORT_NET_NAME(" ) )
979 || token->StartsWith( wxT(
"NET_NAME(" ) )
980 || token->StartsWith( wxT(
"NET_CLASS(" ) )
981 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
983 wxString padNumber = token->AfterFirst(
'(' );
984 padNumber = padNumber.BeforeLast(
')' );
988 if(
pad->GetNumber() == padNumber )
990 if( token->StartsWith( wxT(
"SHORT_NET_NAME" ) ) )
991 *token =
pad->GetShortNetname();
992 else if( token->StartsWith( wxT(
"NET_NAME" ) ) )
993 *token =
pad->GetNetname();
994 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
995 *token =
pad->GetNetClassVariableSubstitutionName();
997 *token =
pad->GetPinFunction();
1027 switch( aBoardItem->
Type() )
1045 if( aMode == ADD_MODE::APPEND )
1052 if( aMode == ADD_MODE::APPEND )
1053 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
1055 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
1059 if( aMode == ADD_MODE::APPEND )
1060 m_zones.push_back(
static_cast<ZONE*
>( aBoardItem ) );
1066 if( aMode == ADD_MODE::APPEND )
1075 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
1076 aBoardItem->
Type() );
1090 switch( aBoardItem->
Type() )
1096 if( *it == aBoardItem )
1117 if( *it == aBoardItem )
1127 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
1129 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
1141 if( *it ==
static_cast<ZONE*
>( aBoardItem ) )
1153 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
1165 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
1166 aBoardItem->
Type() );
1197 switch(
pad->GetProperty() )
1199 case PAD_PROP::FIDUCIAL_GLBL:
1200 case PAD_PROP::FIDUCIAL_LOCAL:
1203 case PAD_PROP::HEATSINK:
1204 case PAD_PROP::CASTELLATED:
1205 case PAD_PROP::MECHANICAL:
1208 case PAD_PROP::NONE:
1210 case PAD_PROP::TESTPOINT:
1214 switch(
pad->GetAttribute() )
1216 case PAD_ATTRIB::PTH:
1220 case PAD_ATTRIB::SMD:
1221 if(
pad->IsOnCopperLayer() )
1249 return _(
"Through hole" );
1251 return _(
"Other" );
1266 if(
dummy.IsFlipped() )
1270 bbox.
Merge(
pad->GetBoundingBox() );
1273 dummy.SetParent(
nullptr );
1274 dummy.SetParentGroup(
nullptr );
1319 std::vector<PCB_TEXT*> texts;
1341 texts.push_back(
static_cast<PCB_TEXT*
>( item ) );
1359 bbox.
Merge( item->GetBoundingBox() );
1365 if( !field->IsReference() && !field->IsValue() )
1366 texts.push_back( field );
1370 bbox.
Merge(
pad->GetBoundingBox() );
1373 bbox.
Merge( zone->GetBoundingBox() );
1378 if( aIncludeText || noDrawItems )
1387 if(
text->IsVisible() )
1393 bool valueLayerIsVisible =
true;
1394 bool refLayerIsVisible =
true;
1412 if( (
Value().IsVisible() && valueLayerIsVisible ) || noDrawItems )
1417 if( (
Reference().IsVisible() && refLayerIsVisible ) || noDrawItems )
1425 if( aIncludeText || noDrawItems )
1443 std::vector<PCB_TEXT*> texts;
1455 if( ( aLayers & item->GetLayerSet() ).none() )
1463 bbox.
Merge( item->GetBoundingBox() );
1468 if( ( aLayers &
pad->GetLayerSet() ).none() )
1471 bbox.
Merge(
pad->GetBoundingBox() );
1476 if( ( aLayers & zone->GetLayerSet() ).none() )
1479 bbox.
Merge( zone->GetBoundingBox() );
1516 pad->Padstack().ForEachUniqueLayer(
1530 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1557 std::vector<VECTOR2I> convex_hull;
1563 for(
const VECTOR2I& pt : convex_hull )
1587 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1589 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1591 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%zu" ), padCount ) );
1594 wxString::Format(
_(
"Keywords: %s" ),
GetKeywords() ) );
1603 case F_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Front" ) );
break;
1604 case B_Cu: aList.emplace_back(
_(
"Board Side" ),
_(
"Back (Flipped)" ) );
break;
1608 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1610 if( !aStr->IsEmpty() )
1611 *aStr += wxT(
", " );
1620 addToken( &status,
_(
"Locked" ) );
1623 addToken( &status,
_(
"autoplaced" ) );
1626 addToken( &attrs,
_(
"not in schematic" ) );
1629 addToken( &attrs,
_(
"exclude from pos files" ) );
1632 addToken( &attrs,
_(
"exclude from BOM" ) );
1635 addToken( &attrs,
_(
"DNP" ) );
1637 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1639 aList.emplace_back(
_(
"Rotation" ), wxString::Format( wxT(
"%.4g" ),
1648 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1650 aList.emplace_back( msg, msg2 );
1654 aList.emplace_back( msg, msg2 );
1662 if( board->IsFootprintHolder() )
1694 if(
pad->IsOnLayer( aLayer ) )
1700 if( zone->IsOnLayer( aLayer ) )
1706 if( field->IsOnLayer( aLayer ) )
1712 if( item->IsOnLayer( aLayer ) )
1724 if(
pad->IsOnLayer( aLayer ) &&
pad->HitTest( aPosition, aAccuracy ) )
1730 if( zone->IsOnLayer( aLayer ) && zone->HitTest( aPosition, aAccuracy ) )
1736 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer )
1737 && item->HitTest( aPosition, aAccuracy ) )
1749 std::vector<BOARD_ITEM*> items;
1753 if(
pad->IsOnLayer( aLayer ) )
1754 items.push_back(
pad );
1759 if( zone->IsOnLayer( aLayer ) )
1760 items.push_back( zone );
1765 if( item->Type() !=
PCB_TEXT_T && item->IsOnLayer( aLayer ) )
1766 items.push_back( item );
1775 if( !aContained && item->HitTest( aRect, aContained, aAccuracy ) )
1777 else if( aContained && !item->HitTest( aRect, aContained, aAccuracy ) )
1784 return !items.empty() && aContained;
1803 BOX2I arect = aRect;
1823 if(
pad->HitTest( arect,
false, 0 ) )
1829 if( zone->HitTest( arect,
false, 0 ) )
1840 if( item->Type() !=
PCB_TEXT_T && item->HitTest( arect,
false, 0 ) )
1854 bool can_select = aSearchAfterMe ? false :
true;
1858 if( !can_select &&
pad == aSearchAfterMe )
1864 if( can_select &&
pad->GetNumber() == aPadNumber )
1877 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1880 if(
pad->HitTest( aPosition ) )
1890 std::vector<const PAD*> retv;
1894 if( ( aIgnore && aIgnore ==
pad ) || (
pad->GetNumber() != aPadNumber ) )
1897 retv.push_back(
pad );
1913 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1925 std::set<wxString> usedNumbers;
1937 if(
pad->GetNumber().IsEmpty() )
1943 if(
pad->GetAttribute() == PAD_ATTRIB::NPTH )
1947 usedNumbers.insert(
pad->GetNumber() );
1962 if(
nullptr == a3DModel )
1972 const std::vector<KICAD_T>& aScanTypes )
1974#if 0 && defined(DEBUG)
1975 std::cout <<
GetClass().mb_str() <<
' ';
1978 bool drawingsScanned =
false;
1980 for(
KICAD_T scanType : aScanTypes )
1985 if( inspector(
this, testData ) == INSPECT_RESULT::QUIT )
1986 return INSPECT_RESULT::QUIT;
1991 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1992 == INSPECT_RESULT::QUIT )
1994 return INSPECT_RESULT::QUIT;
2000 if( IterateForward<ZONE*>(
m_zones, inspector, testData, { scanType } )
2001 == INSPECT_RESULT::QUIT )
2003 return INSPECT_RESULT::QUIT;
2009 if( IterateForward<PCB_FIELD*>(
m_fields, inspector, testData, { scanType } )
2010 == INSPECT_RESULT::QUIT )
2012 return INSPECT_RESULT::QUIT;
2027 if( !drawingsScanned )
2029 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
2030 == INSPECT_RESULT::QUIT )
2032 return INSPECT_RESULT::QUIT;
2035 drawingsScanned =
true;
2041 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
2042 == INSPECT_RESULT::QUIT )
2044 return INSPECT_RESULT::QUIT;
2054 return INSPECT_RESULT::CONTINUE;
2062 if( reference.IsEmpty() )
2063 reference =
_(
"<no reference designator>" );
2065 return wxString::Format(
_(
"Footprint %s" ), reference );
2071 return BITMAPS::module;
2098 aFunction( drawing );
2100 catch( std::bad_function_call& )
2102 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
2128 group->RunOnDescendants( aFunction, aDepth + 1 );
2133 aFunction( drawing );
2134 drawing->RunOnDescendants( aFunction, aDepth + 1 );
2137 catch( std::bad_function_call& )
2139 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnDescendants" ) );
2146 std::vector<int> layers;
2148 layers.reserve( 6 );
2154 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
2175 bool f_silk =
false, b_silk =
false, non_silk =
false;
2179 if( item->GetLayer() ==
F_SilkS )
2181 else if( item->GetLayer() ==
B_SilkS )
2187 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
2211 return std::numeric_limits<double>::max();
2223 return std::numeric_limits<double>::max();
2232 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
2237 return std::numeric_limits<double>::max();
2248 int biggest_clearance = board->GetMaxClearanceValue();
2249 area.
Inflate( biggest_clearance );
2260 if( aName.find_first_of( invalids ) != std::string::npos )
2274 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
2275 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
2278 return invalidCharsReadable;
2280 return invalidChars;
2286 if( aMoveVector.
x == 0 && aMoveVector.
y == 0 )
2300 EDA_ANGLE newOrientation = orientation + aAngle;
2307 field->KeepUpright();
2312 static_cast<PCB_TEXT*
>( item )->KeepUpright();
2323 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
2358 field->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2362 pad->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2369 zone->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2373 item->Flip(
m_pos, FLIP_DIRECTION::TOP_BOTTOM );
2376 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
2395 field->EDA_TEXT::Offset(
delta );
2401 zone->Move(
delta );
2404 item->Move(
delta );
2431 field->Move( moveVector );
2435 pad->Move( moveVector );
2439 item->Move( moveVector );
2443 zone->Move( moveVector );
2501 switch( aItem->
Type() )
2505 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
2508 if( aAddToFootprint )
2509 m_pads.push_back( new_pad );
2517 ZONE* new_zone =
new ZONE( *
static_cast<const ZONE*
>( aItem ) );
2520 if( aAddToFootprint )
2521 m_zones.push_back( new_zone );
2523 new_item = new_zone;
2545 if( aAddToFootprint )
2548 new_item = new_text;
2557 if( aAddToFootprint )
2560 new_item = new_shape;
2569 if( aAddToFootprint )
2572 new_item = new_textbox;
2584 if( aAddToFootprint )
2587 new_item = dimension;
2595 if( aAddToFootprint )
2597 group->RunOnDescendants(
2616 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2626 std::set<wxString> usedNumbers;
2630 usedNumbers.insert(
pad->GetNumber() );
2637 while( usedNumbers.count( wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2640 return wxString::Format( wxT(
"%s%d" ), prefix, num );
2691 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2695 return aPolySet.
Area();
2710 return markerShape.
Area();
2714 double combinedArea = 0.0;
2719 return combinedArea;
2749 case SHAPE_T::SEGMENT:
2751 case SHAPE_T::BEZIER:
2754 case SHAPE_T::RECTANGLE:
2755 case SHAPE_T::CIRCLE:
2770 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2771 return width * width;
2775 static_cast<const PAD*
>( aItem )->Padstack().ForEachUniqueLayer(
2807 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2811 switch( item->
Type() )
2842 double footprintRegionArea =
polygonArea( footprintRegion );
2843 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2844 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2845 double ratio = ( coveredArea / footprintRegionArea );
2852 return std::min( ratio, 1.0 );
2858 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2879 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2884 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2924 std::vector<PCB_SHAPE*> list_front;
2925 std::vector<PCB_SHAPE*> list_back;
2926 std::map<int, int> front_width_histogram;
2927 std::map<int, int> back_width_histogram;
2934 list_back.push_back( shape );
2941 list_front.push_back( shape );
2946 if( !list_front.size() && !list_back.size() )
2953 true, aErrorHandler ) )
2963 auto max = std::max_element( front_width_histogram.begin(), front_width_histogram.end(),
2964 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2966 return a.second < b.second;
2969 if( max != front_width_histogram.end() )
2992 auto max = std::max_element( back_width_histogram.begin(), back_width_histogram.end(),
2993 [](
const std::pair<int, int>& a,
const std::pair<int, int>& b )
2995 return a.second < b.second;
2998 if( max != back_width_histogram.end() )
3021 std::map<PCB_LAYER_ID, std::vector<PCB_SHAPE*>> layer_shapes;
3026 if( item->Type() != PCB_SHAPE_T )
3029 for( PCB_LAYER_ID layer : item->GetLayerSet() )
3030 layer_shapes[layer].push_back( static_cast<PCB_SHAPE*>( item ) );
3033 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3036 bool has_nettie =
false;
3038 auto it = map.find(
pad->GetNumber() );
3040 if( it == map.end() || it->second < 0 )
3043 for(
size_t jj = ii + 1; jj <
m_pads.size(); ++jj )
3047 auto it2 = map.find( other->
GetNumber() );
3049 if( it2 == map.end() || it2->second < 0 )
3052 if( it2->second == it->second )
3065 for(
auto& [ layer, shapes ] : layer_shapes )
3067 auto pad_shape =
pad->GetEffectiveShape( layer );
3069 for(
auto other_shape : shapes )
3071 auto shape = other_shape->GetEffectiveShape( layer );
3073 if( pad_shape->Collide( shape.get() ) )
3076 m_netTieCache[other_shape].insert( nettie.begin(), nettie.end() );
3086 std::map<wxString, int> padNumberToGroupIdxMap;
3089 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
3092 [&]( wxString aPad,
int aGroup )
3094 aPad.Trim(
true ).Trim(
false );
3096 if( !aPad.IsEmpty() )
3097 padNumberToGroupIdxMap[ aPad ] = aGroup;
3106 for( wxUniCharRef ch :
group )
3115 switch(
static_cast<unsigned char>( ch ) )
3122 processPad(
pad, ii );
3132 processPad(
pad, ii );
3135 return padNumberToGroupIdxMap;
3145 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
3146 std::vector<PAD*> otherPads;
3152 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
3153 otherPads.push_back(
pad );
3166 if( setAttr && likelyAttr && setAttr != likelyAttr )
3170 switch( likelyAttr )
3173 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
3176 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
3181 (aErrorHandler)( msg );
3187 const std::function<
void(
const PAD*,
int,
3188 const wxString& )>& aErrorHandler )
3190 if( aErrorHandler ==
nullptr )
3195 pad->CheckPad( aUnitsProvider,
3196 [&](
int errorCode,
const wxString& msg )
3198 aErrorHandler(
pad, errorCode, msg );
3206 const VECTOR2I& )>& aErrorHandler )
3208 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
3223 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
3226 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
3228 checkedPairs[ { a, b } ] = 1;
3230 if(
pad->HasDrilledHole() && other->HasDrilledHole() )
3234 if(
pad->GetPosition() == other->GetPosition() )
3240 std::shared_ptr<SHAPE_SEGMENT> holeA =
pad->GetEffectiveHoleShape();
3241 std::shared_ptr<SHAPE_SEGMENT> holeB = other->GetEffectiveHoleShape();
3243 if( holeA->Collide( holeB->GetSeg(), 0 ) )
3254 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
3258 for(
PCB_LAYER_ID l :
pad->Padstack().RelevantShapeLayers( other->Padstack() ) )
3260 SHAPE* padShape =
pad->GetEffectiveShape( l ).get();
3261 SHAPE* otherShape = other->GetEffectiveShape( l ).get();
3263 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
3276 const VECTOR2I& )>& aErrorHandler )
3285 std::vector<BOARD_ITEM*> copperItems;
3289 if( item->IsOnCopperLayer() )
3290 copperItems.push_back( item );
3292 item->RunOnDescendants(
3296 copperItems.push_back( descendent );
3302 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
3303 copperItems.push_back( zone );
3308 if( field->IsOnCopperLayer() )
3309 copperItems.push_back( field );
3319 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
3323 if( item->IsOnLayer( layer ) )
3325 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
3336 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
3338 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
3339 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
3346 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
3348 if( pads.size() > 1 )
3350 const PAD* firstPad = pads[0];
3351 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
3353 for(
size_t ii = 1; ii < pads.size(); ++ii )
3355 const PAD* thisPad = pads[ii];
3356 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
3358 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
3367 if( item->HitTest( pos, 1 ) )
3369 shortingItem = item;
3375 aErrorHandler( shortingItem, firstPad, thisPad, pos );
3377 aErrorHandler( firstPad, thisPad,
nullptr, pos );
3388 std::set<wxString> padNumbers;
3397 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
3398 aErrorHandler( msg );
3400 else if( !padNumbers.insert(
pad->GetNumber() ).second )
3402 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
3403 aErrorHandler( msg );
3415 std::swap( *
this, *
image );
3423 image->RunOnChildren(
3435 if(
pad->GetAttribute() != PAD_ATTRIB::SMD )
3450 return *
this == other;
3459 for(
size_t ii = 0; ii <
m_pads.size(); ++ii )
3468 for(
size_t ii = 0; ii <
m_drawings.size(); ++ii )
3477 for(
size_t ii = 0; ii <
m_zones.size(); ++ii )
3486 for(
size_t ii = 0; ii <
m_fields.size(); ++ii )
3503 double similarity = 1.0;
3512 similarity *=
pad->Similarity( *otherPad );
3521 if( itemA->
Type() != itemB->
Type() )
3522 return itemA->
Type() < itemB->
Type();
3537 if( dwgA->
GetShape() != SHAPE_T::POLY )
3550 if( dwgA->
GetShape() == SHAPE_T::ARC )
3557 else if( dwgA->
GetShape() == SHAPE_T::BEZIER )
3569 else if( dwgA->
GetShape() == SHAPE_T::POLY )
3592 return itemA < itemB;
3606 std::optional<bool> padCopperMatches;
3609 const PAD* checkPad = aFirst;
3622 padCopperMatches = aFirst->
GetSize( aLayer ).
x < aSecond->
GetSize( aLayer ).
x;
3624 padCopperMatches = aFirst->
GetSize( aLayer ).
y < aSecond->
GetSize( aLayer ).
y;
3626 padCopperMatches = aFirst->
GetShape( aLayer ) < aSecond->
GetShape( aLayer );
3629 if( padCopperMatches.has_value() )
3630 return *padCopperMatches;
3638 return aFirst < aSecond;
3643bool FOOTPRINT::cmp_padstack::operator()(
const PAD* aFirst,
const PAD* aSecond )
const
3683 if( firstShape->VertexCount() != secondShape->VertexCount() )
3684 return firstShape->VertexCount() < secondShape->VertexCount();
3686 for(
int ii = 0; ii < firstShape->VertexCount(); ++ii )
3688 if( firstShape->CVertex( ii ).x != secondShape->CVertex( ii ).x )
3689 return firstShape->CVertex( ii ).x < secondShape->CVertex( ii ).x;
3690 if( firstShape->CVertex( ii ).y != secondShape->CVertex( ii ).y )
3691 return firstShape->CVertex( ii ).y < secondShape->CVertex( ii ).y;
3710 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
3721 return aFirst < aSecond;
3726 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
3727 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
3728 bool aSkipNonPlatedPads )
const
3733 VECTOR2I clearance( aClearance, aClearance );
3738 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
3741 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
3747 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
3750 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
3757 clearance.
x +=
pad->GetSolderMaskExpansion( padLayer );
3758 clearance.
y +=
pad->GetSolderMaskExpansion( padLayer );
3763 clearance +=
pad->GetSolderPasteMargin( padLayer );
3776 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
3777 &&
pad->GetShape( padLayer ) != PAD_SHAPE::CUSTOM )
3779 VECTOR2I dummySize =
pad->GetSize( padLayer ) + clearance + clearance;
3781 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
3785 dummy.SetSize( padLayer, dummySize );
3786 dummy.TransformShapeToPolygon( aBuffer, padLayer, 0, aMaxError, aErrorLoc );
3790 pad->TransformShapeToPolygon( aBuffer, padLayer, clearance.
x, aMaxError,
3797 if( !
pad->FlashLayer( aLayer ) )
3802 pad->Padstack().ForEachUniqueLayer(
3805 processPad(
pad, l );
3810 processPad(
pad, aLayer );
3817 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
3818 bool aIncludeText,
bool aIncludeShapes,
3819 bool aIncludePrivateItems )
const
3821 std::vector<const PCB_TEXT*> texts;
3828 if( item->Type() ==
PCB_TEXT_T && aIncludeText )
3833 texts.push_back(
text );
3844 textbox->PCB_SHAPE::TransformShapeToPolygon( aBuffer, aLayer, 0, aError, aErrorLoc );
3850 if( item->Type() ==
PCB_SHAPE_T && aIncludeShapes )
3863 if( field->GetLayer() == aLayer && field->IsVisible() )
3864 texts.push_back( field );
3869 text->TransformTextToPolySet( aBuffer, aClearance, aError, aErrorLoc );
3876 using EMBEDDING_PERMISSION = OUTLINE_FONT::EMBEDDING_PERMISSION;
3878 std::set<OUTLINE_FONT*>
fonts;
3884 if(
auto* font =
text->GetFont(); font && !font->IsStroke() )
3886 auto* outline =
static_cast<OUTLINE_FONT*
>( font );
3887 auto permission = outline->GetEmbeddingPermission();
3889 if( permission == EMBEDDING_PERMISSION::EDITABLE
3890 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
3892 fonts.insert( outline );
3898 for(
auto* font :
fonts )
3913 return wxEmptyString;
3923 if( zcMap.
Choices().GetCount() == 0 )
3925 zcMap.
Undefined( ZONE_CONNECTION::INHERITED );
3926 zcMap.
Map( ZONE_CONNECTION::INHERITED,
_HKI(
"Inherited" ) )
3927 .
Map( ZONE_CONNECTION::NONE,
_HKI(
"None" ) )
3928 .
Map( ZONE_CONNECTION::THERMAL,
_HKI(
"Thermal reliefs" ) )
3929 .
Map( ZONE_CONNECTION::FULL,
_HKI(
"Solid" ) )
3930 .
Map( ZONE_CONNECTION::THT_THERMAL,
_HKI(
"Thermal reliefs for PTH" ) );
3935 if( layerEnum.
Choices().GetCount() == 0 )
3943 wxPGChoices fpLayers;
3956 layer->SetChoices( fpLayers );
3961 PROPERTY_DISPLAY::PT_DEGREE ) );
3963 const wxString groupFields =
_HKI(
"Fields" );
3989 const wxString groupAttributes =
_HKI(
"Attributes" );
4003 const wxString groupOverrides =
_HKI(
"Overrides" );
4006 _HKI(
"Exempt From Courtyard Requirement" ),
4010 _HKI(
"Clearance Override" ),
4012 PROPERTY_DISPLAY::PT_SIZE ),
4015 _HKI(
"Solderpaste Margin Override" ),
4017 PROPERTY_DISPLAY::PT_SIZE ),
4020 _HKI(
"Solderpaste Margin Ratio Override" ),
4023 PROPERTY_DISPLAY::PT_RATIO ),
4026 _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)
Loads a file from disk and adds it to the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
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.
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.
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 & SetIsHiddenFromPropertiesManager(bool aHide=true)
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 Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
virtual void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
double Area()
Return the area of this poly set.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union For aFastMode meaning, see function booleanOp.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
int TotalVertices() const
Return total number of vertices stored in the set.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
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 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
#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 conficting
@ LAYER_FOOTPRINTS_FR
show footprints on front
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
@ LAYER_FOOTPRINTS_BK
show footprints on back
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
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