31#include <unordered_set>
58 m_boundingBoxCacheTimeStamp( 0 ),
59 m_visibleBBoxCacheTimeStamp( 0 ),
60 m_textExcludedBBoxCacheTimeStamp( 0 ),
61 m_hullCacheTimeStamp( 0 ),
62 m_initial_comments( nullptr ),
63 m_courtyard_cache_timestamp( 0 )
116 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
130 PAD* newPad =
static_cast<PAD*
>(
pad->Clone() );
131 ptrMap[
pad ] = newPad;
139 ptrMap[ zone ] = newZone;
153 ptrMap[ item ] = newItem;
161 ptrMap[
group ] = newGroup;
174 if( ptrMap.count( member ) )
175 newGroup->
AddItem( ptrMap[ member ] );
196 *
this = std::move( aFootprint );
206 item->SetParentGroup(
nullptr );
235 board->IncrementTimeStamp();
242 std::vector< BOARD_ITEM* > item_list;
245 item_list.push_back(
m_value );
248 item_list.push_back(
pad );
251 item_list.push_back( gr_item );
256 item_list.push_back(
group );
260 item_list.push_back( zone );
262 bool changed =
false;
268 const_cast<KIID&
>( item->m_Uuid ) =
KIID();
281 m_pos = aOther.m_pos;
316 for(
PAD*
pad : aOther.Pads() )
319 aOther.Pads().clear();
324 for(
FP_ZONE* item : aOther.Zones() )
332 item->SetNetCode( -1 );
335 aOther.Zones().clear();
340 for(
BOARD_ITEM* item : aOther.GraphicalItems() )
343 aOther.GraphicalItems().clear();
351 aOther.Groups().clear();
355 m_doc = aOther.m_doc;
363 aOther.Pads().clear();
364 aOther.Zones().clear();
365 aOther.GraphicalItems().clear();
366 aOther.m_value =
nullptr;
367 aOther.m_reference =
nullptr;
368 aOther.m_initial_comments =
nullptr;
409 std::map<BOARD_ITEM*, BOARD_ITEM*> ptrMap;
417 ptrMap[
pad ] = newPad;
427 ptrMap[ zone ] = newZone;
443 ptrMap[ item ] = newItem;
456 newGroup->
AddItem( ptrMap[ member ] );
483 aVars->push_back( wxT(
"REFERENCE" ) );
484 aVars->push_back( wxT(
"VALUE" ) );
485 aVars->push_back( wxT(
"LAYER" ) );
486 aVars->push_back( wxT(
"FOOTPRINT_LIBRARY" ) );
487 aVars->push_back( wxT(
"FOOTPRINT_NAME" ) );
488 aVars->push_back( wxT(
"NET_NAME(<pad_number>)" ) );
489 aVars->push_back( wxT(
"NET_CLASS(<pad_number>)" ) );
490 aVars->push_back( wxT(
"PIN_NAME(<pad_number>)" ) );
499 if( token->IsSameAs( wxT(
"REFERENCE" ) ) )
504 else if( token->IsSameAs( wxT(
"VALUE" ) ) )
509 else if( token->IsSameAs( wxT(
"LAYER" ) ) )
514 else if( token->IsSameAs( wxT(
"FOOTPRINT_LIBRARY" ) ) )
519 else if( token->IsSameAs( wxT(
"FOOTPRINT_NAME" ) ) )
524 else if( token->StartsWith( wxT(
"NET_NAME(" ) )
525 || token->StartsWith( wxT(
"NET_CLASS(" ) )
526 || token->StartsWith( wxT(
"PIN_NAME(" ) ) )
528 wxString padNumber = token->AfterFirst(
'(' );
529 padNumber = padNumber.BeforeLast(
')' );
533 if(
pad->GetNumber() == padNumber )
535 if( token->StartsWith( wxT(
"NET_NAME" ) ) )
536 *token =
pad->GetNetname();
537 else if( token->StartsWith( wxT(
"NET_CLASS" ) ) )
538 *token =
pad->GetNetClassName();
540 *token =
pad->GetPinFunction();
570 switch( aBoardItem->
Type() )
593 m_pads.push_back(
static_cast<PAD*
>( aBoardItem ) );
595 m_pads.push_front(
static_cast<PAD*
>( aBoardItem ) );
615 msg.Printf( wxT(
"FOOTPRINT::Add() needs work: BOARD_ITEM type (%d) not handled" ),
616 aBoardItem->
Type() );
630 switch( aBoardItem->
Type() )
635 wxT(
"Please report this bug: Invalid remove operation on required text" ) );
648 if( *it == aBoardItem )
658 for(
auto it =
m_pads.begin(); it !=
m_pads.end(); ++it )
660 if( *it ==
static_cast<PAD*
>( aBoardItem ) )
672 if( *it ==
static_cast<FP_ZONE*
>( aBoardItem ) )
684 if( *it ==
static_cast<PCB_GROUP*
>( aBoardItem ) )
696 msg.Printf( wxT(
"FOOTPRINT::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
697 aBoardItem->
Type() );
728 switch(
pad->GetProperty() )
744 switch(
pad->GetAttribute() )
751 if(
pad->IsOnCopperLayer() )
777 return _(
"Through hole" );
794 if(
dummy.IsFlipped() )
798 bbox.
Merge(
pad->GetBoundingBox() );
800 dummy.SetParent(
nullptr );
819 if( aIncludeText && aIncludeInvisibleText )
824 else if( aIncludeText )
860 bbox.
Merge( item->GetBoundingBox() );
864 bbox.
Merge(
pad->GetBoundingBox() );
867 bbox.
Merge( zone->GetBoundingBox() );
872 if( aIncludeText || noDrawItems )
882 bbox.
Merge( item->GetBoundingBox() );
887 bool valueLayerIsVisible =
true;
888 bool refLayerIsVisible =
true;
907 || aIncludeInvisibleText
914 || aIncludeInvisibleText
923 if( ( aIncludeText && aIncludeInvisibleText ) || noDrawItems )
928 else if( aIncludeText )
983 const SHAPE_POLY_SET& layerPoly = *zone->GetFilledPolysList( layer );
1010 std::vector<VECTOR2I> convex_hull;
1016 for(
const VECTOR2I& pt : convex_hull )
1038 aList.emplace_back(
_(
"Library" ),
GetFPID().GetLibNickname().wx_str() );
1040 aList.emplace_back(
_(
"Footprint Name" ),
GetFPID().GetLibItemName().wx_str() );
1051 aList.emplace_back(
_(
"Board Side" ),
IsFlipped() ?
_(
"Back (Flipped)" ) :
_(
"Front" ) );
1053 auto addToken = []( wxString* aStr,
const wxString& aAttr )
1055 if( !aStr->IsEmpty() )
1056 *aStr += wxT(
", " );
1065 addToken( &status,
_(
"Locked" ) );
1068 addToken( &status,
_(
"autoplaced" ) );
1071 addToken( &attrs,
_(
"not in schematic" ) );
1074 addToken( &attrs,
_(
"exclude from pos files" ) );
1077 addToken( &attrs,
_(
"exclude from BOM" ) );
1079 aList.emplace_back(
_(
"Status: " ) + status,
_(
"Attributes:" ) + wxS(
" " ) + attrs );
1085 msg2.Printf(
_(
"3D-Shape: %s" ),
m_3D_Drawings.empty() ?
_(
"<none>" )
1087 aList.emplace_back( msg, msg2 );
1089 msg.Printf(
_(
"Doc: %s" ),
m_doc );
1091 aList.emplace_back( msg, msg2 );
1099 if( aIncludeCourtyards && courtyardLayers[aLayer] )
1109 if( !zone->IsOnLayer( aLayer ) )
1115 if( !item->IsOnLayer( aLayer ) )
1138 BOX2I arect = aRect;
1158 if(
pad->HitTest( arect,
false, 0 ) )
1164 if( zone->HitTest( arect,
false, 0 ) )
1174 && item->HitTest( arect,
false, 0 ) )
1190 bool can_select = aSearchAfterMe ? false :
true;
1194 if( !can_select &&
pad == aSearchAfterMe )
1200 if( can_select &&
pad->GetNumber() == aPadNumber )
1213 if( !(
pad->GetLayerSet() & aLayerMask ).any() )
1216 if(
pad->HitTest( aPosition ) )
1245 std::set<wxString> usedNumbers;
1257 if(
pad->GetNumber().IsEmpty() )
1267 usedNumbers.insert(
pad->GetNumber() );
1270 return usedNumbers.size();
1276 if(
nullptr == a3DModel )
1286 const std::vector<KICAD_T>& aScanTypes )
1288#if 0 && defined(DEBUG)
1289 std::cout <<
GetClass().mb_str() <<
' ';
1292 bool drawingsScanned =
false;
1294 for(
KICAD_T scanType : aScanTypes )
1305 if( IterateForward<PAD*>(
m_pads, inspector, testData, { scanType } )
1314 if( IterateForward<FP_ZONE*>(
m_fp_zones, inspector, testData, { scanType } )
1339 if( !drawingsScanned )
1341 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, aScanTypes )
1347 drawingsScanned =
true;
1353 if( IterateForward<PCB_GROUP*>(
m_fp_groups, inspector, testData, { scanType } )
1374 if( reference.IsEmpty() )
1375 reference =
_(
"<no reference designator>" );
1401 aFunction(
static_cast<FP_ZONE*
>( zone ) );
1407 aFunction(
static_cast<BOARD_ITEM*
>( drawing ) );
1412 catch( std::bad_function_call& )
1414 wxFAIL_MSG( wxT(
"Error running FOOTPRINT::RunOnChildren" ) );
1427 wxASSERT_MSG(
false, wxT(
"Illegal layer" ) );
1448 bool f_silk =
false, b_silk =
false, non_silk =
false;
1452 if( item->GetLayer() ==
F_SilkS )
1454 else if( item->GetLayer() ==
B_SilkS )
1460 if( ( f_silk || b_silk ) && !non_silk &&
m_pads.empty() )
1463 aLayers[ aCount++ ] =
F_SilkS;
1466 aLayers[ aCount++ ] =
B_SilkS;
1482 return std::numeric_limits<double>::max();
1494 return std::numeric_limits<double>::max();
1503 #define MINIMAL_ZOOM_LEVEL_FOR_VISIBILITY 1.5
1508 return std::numeric_limits<double>::max();
1523 area.
Inflate( biggest_clearance );
1534 if( aName.find_first_of( invalids ) != std::string::npos )
1548 static const wxChar invalidChars[] = wxT(
"%$<>\t\n\r\"\\/:");
1549 static const wxChar invalidCharsReadable[] = wxT(
"% $ < > 'tab' 'return' 'line feed' \\ \" / :");
1552 return invalidCharsReadable;
1554 return invalidChars;
1568 EDA_ANGLE newOrientation = orientation + aAngle;
1580 static_cast<FP_TEXT*
>( item )->KeepUpright( orientation, newOrientation );
1593 wxASSERT( aLayer ==
F_Cu || aLayer ==
B_Cu );
1631 zone->Flip(
m_pos,
false );
1640 switch( item->Type() )
1667 wxMessageBox(
wxString::Format( wxT(
"FOOTPRINT::Flip() error: Unknown Draw Type %d" ),
1668 (
int)item->Type() ) );
1674 if( aFlipLeftRight )
1701 zone->Move(
delta );
1705 switch( item->Type() )
1728 item->Move(
delta );
1732 wxMessageBox( wxT(
"Draw type undefined." ) );
1770 pad->SetPos0(
pad->GetPos0() + moveVector );
1771 pad->SetDrawCoord();
1777 switch( item->Type() )
1783 shape->
Move( moveVector );
1790 text->SetPos0(
text->GetPos0() + moveVector );
1791 text->SetDrawCoord();
1803 zone->Move( moveVector );
1829 pad->SetOrientation(
pad->GetOrientation() + angleChange );
1830 pad->SetDrawCoord();
1849 switch( item->Type() )
1853 static_cast<FP_SHAPE*
>( item )->SetDrawCoord();
1857 static_cast<FP_TEXT*
>( item )->SetDrawCoord();
1892 switch( aItem->
Type() )
1896 PAD* new_pad =
new PAD( *
static_cast<const PAD*
>( aItem ) );
1899 if( aAddToFootprint )
1900 m_pads.push_back( new_pad );
1911 if( aAddToFootprint )
1914 new_item = new_zone;
1925 new_text->
SetText( wxT(
"${REFERENCE}" ) );
1930 new_text->
SetText( wxT(
"${VALUE}" ) );
1934 if( aAddToFootprint )
1937 new_item = new_text;
1947 if( aAddToFootprint )
1950 new_item = new_shape;
1959 if( aAddToFootprint )
1962 new_item = new_textbox;
1974 if( aAddToFootprint )
1977 new_item = dimension;
1982 new_item =
static_cast<const PCB_GROUP*
>( aItem )->DeepDuplicate();
1991 wxFAIL_MSG( wxT(
"Duplication not supported for items of class " ) + aItem->
GetClass() );
2001 std::set<wxString> usedNumbers;
2005 usedNumbers.insert(
pad->GetNumber() );
2012 while( usedNumbers.count(
wxString::Format( wxT(
"%s%d" ), prefix, num ) ) )
2038 for(
int jj = 0; jj < aPolySet.
HoleCount( ii ); jj++ )
2042 return aPolySet.
Area();
2057 return markerShape.
Area();
2061 double combinedArea = 0.0;
2066 return combinedArea;
2117 double width =
static_cast<const PCB_TRACK*
>( aItem )->GetWidth();
2118 return width * width;
2144 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2148 switch( item->
Type() )
2183 double footprintRegionArea =
polygonArea( footprintRegion );
2184 double uncoveredRegionArea = footprintRegionArea -
polygonArea( coveredRegion );
2185 double coveredArea = footprintRegionArea - uncoveredRegionArea;
2186 double ratio = ( coveredArea / footprintRegionArea );
2193 return std::min( ratio, 1.0 );
2199 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
2220 shape->AddShape(
pad->GetEffectiveShape( aLayer, aFlash )->Clone() );
2225 shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() );
2256 std::vector<PCB_SHAPE*> list_front;
2257 std::vector<PCB_SHAPE*> list_back;
2262 list_back.push_back(
static_cast<PCB_SHAPE*
>( item ) );
2265 list_front.push_back(
static_cast<PCB_SHAPE*
>( item ) );
2268 if( !list_front.size() && !list_back.size() )
2275 true, aErrorHandler ) )
2288 true, aErrorHandler ) )
2304 std::map<wxString, int> padNumberToGroupIdxMap;
2307 padNumberToGroupIdxMap[
pad->GetNumber() ] = -1;
2310 [&]( wxString aPad,
int aGroup )
2312 aPad.Trim(
true ).Trim(
false );
2314 if( !aPad.IsEmpty() )
2315 padNumberToGroupIdxMap[ aPad ] = aGroup;
2324 for( wxUniCharRef ch :
group )
2333 switch(
static_cast<unsigned char>( ch ) )
2340 processPad(
pad, ii );
2350 processPad(
pad, ii );
2353 return padNumberToGroupIdxMap;
2363 int groupIdx = padToNetTieGroupMap[ aPad->
GetNumber() ];
2364 std::vector<PAD*> otherPads;
2370 if( padToNetTieGroupMap[
pad->GetNumber() ] == groupIdx )
2371 otherPads.push_back(
pad );
2384 if( setAttr && likelyAttr && setAttr != likelyAttr )
2388 switch( likelyAttr )
2391 msg.Printf(
_(
"(expected 'Through hole'; actual '%s')" ),
GetTypeName() );
2394 msg.Printf(
_(
"(expected 'SMD'; actual '%s')" ),
GetTypeName() );
2399 (aErrorHandler)( msg );
2405 const wxString& )>& aErrorHandler )
2407 if( aErrorHandler ==
nullptr )
2414 if(
pad->GetDrillSizeX() < 1 ||
pad->GetDrillSizeY() < 1 )
2420 if( !
pad->IsOnCopperLayer() )
2432 std::shared_ptr<SHAPE_SEGMENT> hole =
pad->GetEffectiveHoleShape();
2438 padOutline.
BooleanSubtract( holeOutline, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
2450 _(
"(SMD pad appears on both front and back copper)" ) );
2452 else if(
pad->IsOnLayer(
F_Cu ) )
2457 _(
"(SMD pad copper and mask layers don't match)" ) );
2462 _(
"(SMD pad copper and paste layers don't match)" ) );
2465 else if(
pad->IsOnLayer(
B_Cu ) )
2470 _(
"(SMD pad copper and mask layers don't match)" ) );
2475 _(
"(SMD pad copper and paste layers don't match)" ) );
2484 const VECTOR2I& )>& aErrorHandler )
2486 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
2494 if( other ==
pad ||
pad->SameLogicalPadAs( other ) )
2507 if(
static_cast<void*
>( a ) >
static_cast<void*
>( b ) )
2510 if( checkedPairs.find( { a, b } ) == checkedPairs.end() )
2512 checkedPairs[ { a, b } ] = 1;
2514 if(
pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
2517 SHAPE* padShape =
pad->GetEffectiveShape().get();
2518 SHAPE* otherShape = other->GetEffectiveShape().get();
2520 if( padShape->
Collide( otherShape, 0,
nullptr, &pos ) )
2521 aErrorHandler(
pad, other, pos );
2532 const VECTOR2I& )>& aErrorHandler )
2541 std::vector<BOARD_ITEM*> copperItems;
2545 if( item->IsOnCopperLayer() )
2546 copperItems.push_back( item );
2551 if( !zone->GetIsRuleArea() && zone->IsOnCopperLayer() )
2552 copperItems.push_back( zone );
2559 copperItems.push_back(
m_value );
2568 std::map<int, std::vector<const PAD*>> outlineIdxToPadsMap;
2572 if( item->IsOnLayer( layer ) )
2574 item->TransformShapeToPolygon( copperOutlines, layer, 0,
ARC_HIGH_DEF,
2585 for(
int ii = 0; ii < copperOutlines.
OutlineCount(); ++ii )
2587 if(
pad->GetEffectiveShape( layer )->Collide( &copperOutlines.
Outline( ii ), 0 ) )
2588 outlineIdxToPadsMap[ ii ].emplace_back(
pad );
2595 for(
const auto& [ outlineIdx, pads ] : outlineIdxToPadsMap )
2597 if( pads.size() > 1 )
2599 const PAD* firstPad = pads[0];
2600 int firstGroupIdx = padNumberToGroupIdxMap[ firstPad->
GetNumber() ];
2602 for(
size_t ii = 1; ii < pads.size(); ++ii )
2604 const PAD* thisPad = pads[ii];
2605 int thisGroupIdx = padNumberToGroupIdxMap[ thisPad->
GetNumber() ];
2607 if( thisGroupIdx < 0 || thisGroupIdx != firstGroupIdx )
2616 if( item->HitTest( pos, 1 ) )
2618 shortingItem = item;
2624 aErrorHandler( shortingItem, firstPad, thisPad, pos );
2626 aErrorHandler( firstPad, thisPad,
nullptr, pos );
2637 std::set<wxString> padNumbers;
2642 for(
auto [ padNumber,
_ ] : ret )
2648 msg.Printf(
_(
"(net-tie pad group contains unknown pad number %s)" ), padNumber );
2649 aErrorHandler( msg );
2651 else if( !padNumbers.insert(
pad->GetNumber() ).second )
2653 msg.Printf(
_(
"(pad %s appears in more than one net-tie pad group)" ), padNumber );
2654 aErrorHandler( msg );
2664 std::swap( *
this, *
static_cast<FOOTPRINT*
>( aImage ) );
2680#define TEST( a, b ) { if( a != b ) return a < b; }
2681#define TEST_PT( a, b ) { if( a.x != b.x ) return a.x < b.x; if( a.y != b.y ) return a.y < b.y; }
2712 for(
int ii = 0; ii < dwgA->
GetPolyShape().TotalVertices(); ++ii )
2721 return itemA < itemB;
2737 return aFirst < aSecond;
2748 for(
int ii = 0; ii < aFirst->
Outline()->TotalVertices(); ++ii )
2753 return aFirst < aSecond;
2761 int aClearance,
int aMaxError,
ERROR_LOC aErrorLoc,
2762 bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
2763 bool aSkipNonPlatedPads )
const
2767 if( !
pad->FlashLayer( aLayer ) )
2770 VECTOR2I clearance( aClearance, aClearance );
2775 if( aSkipPlatedPads &&
pad->FlashLayer(
F_Mask ) )
2778 if( aSkipNonPlatedPads && !
pad->FlashLayer(
F_Mask ) )
2784 if( aSkipPlatedPads &&
pad->FlashLayer(
B_Mask ) )
2787 if( aSkipNonPlatedPads && !
pad->FlashLayer(
B_Mask ) )
2794 clearance.
x +=
pad->GetSolderMaskExpansion();
2795 clearance.
y +=
pad->GetSolderMaskExpansion();
2800 clearance +=
pad->GetSolderPasteMargin();
2813 if( ( clearance.
x < 0 || clearance.
x != clearance.
y )
2816 VECTOR2I dummySize =
pad->GetSize() + clearance + clearance;
2818 if( dummySize.
x <= 0 || dummySize.
y <= 0 )
2822 dummy.SetSize( dummySize );
2823 dummy.TransformShapeToPolygon( aBuffer, aLayer, 0, aMaxError, aErrorLoc );
2827 pad->TransformShapeToPolygon( aBuffer, aLayer, clearance.
x, aMaxError, aErrorLoc );
2834 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
2835 bool aIncludeText,
bool aIncludeShapes,
2836 bool aIncludePrivateItems )
const
2838 std::vector<FP_TEXT*> texts;
2850 texts.push_back(
text );
2876 texts.push_back( &
Value() );
2880 text->TransformTextToPolySet( aBuffer, aLayer, aClearance, aError, aErrorLoc );
2890 if( zcMap.
Choices().GetCount() == 0 )
2902 if( layerEnum.
Choices().GetCount() == 0 )
2910 wxPGChoices fpLayers;
2923 layer->SetChoices( fpLayers );
2930 const wxString groupFootprint =
_HKI(
"Footprint Properties" );
2949 const wxString groupAttributes =
_HKI(
"Fabrication Attributes" );
2960 const wxString groupOverrides =
_HKI(
"Overrides" );
2963 _HKI(
"Exempt from courtyard requirement" ),
2975 _HKI(
"Solderpaste Margin Ratio Override" ),
2980 _HKI(
"Zone Connection Style" ),
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
BITMAPS
A list of all bitmap identifiers.
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
int GetBiggestClearanceValue() const
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.
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
bool Intersects(const BOX2< Vec > &aRect) const
coord_type GetHeight() const
coord_type GetWidth() const
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
virtual double OnePixelInIU() const =0
int GetCount() const
Return the number of objects in the list.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
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
SHAPE_POLY_SET & GetPolyShape()
virtual bool IsVisible() const
virtual void SetText(const wxString &aText)
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
wxString m_Filename
The 3D shape filename in 3D library.
const VECTOR2I & GetBezierC1_0() const
const VECTOR2I & GetEnd0() const
const VECTOR2I & GetBezierC2_0() const
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
VECTOR2I GetCenter0() const
const VECTOR2I & GetStart0() const
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
const BOX2I GetBoundingBox() const override
Set absolute coordinates.
const VECTOR2I & GetPos0() const
void SetType(TEXT_TYPE aType)
void SetDrawCoord()
Set relative coordinates.
void KeepUpright(const EDA_ANGLE &aOldOrientation, const EDA_ANGLE &aNewOrientation)
Called when rotating the parent footprint.
void SetPos0(const VECTOR2I &aPos)
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity during footprint flip.
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
TEXT_TYPE GetType() const
A specialization of ZONE for use in footprints.
Used when the right click button is pressed, or when the select tool is in effect.
const COLLECTORS_GUIDE * GetGuide() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
wxString GetUniStringLibId() const
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
static const int ORPHANED
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const wxString & GetNumber() const
VECTOR2I GetPosition() const override
PAD_SHAPE GetShape() const
const VECTOR2I & GetPos0() const
const VECTOR2I & GetSize() const
Object to handle a bitmap image that can be inserted in a PCB.
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
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.
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.
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 BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
@ CHAMFER_ACUTE_CORNERS
Acute angles are chamfered.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
double Area()
Count the number of arc shapes present.
void CacheTriangulation(bool aPartition=true, bool aSimplify=false)
Build a polygon triangulation, needed to draw a polygon on OpenGL and in some other calculations.
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
Delete aIdx-th polygon from the set.
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Simplify(POLYGON_MODE aFastMode)
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
int NewOutline()
Creates a new hole in a given outline.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void Move(const VECTOR2I &aVector) override
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
An abstract shape on 2D plane.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Handle a list of polygons defining a copper zone.
SHAPE_POLY_SET * Outline()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
unsigned GetAssignedPriority() const
This file is part of the common library.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
bool ConvertOutlineToPolygon(std::vector< PCB_SHAPE * > &aShapeList, SHAPE_POLY_SET &aPolygons, int aErrorMax, int aChainingEpsilon, bool aAllowDisjoint, OUTLINE_ERROR_HANDLER *aErrorHandler)
Function ConvertOutlineToPolygon Build a polygon (with holes) from a PCB_SHAPE list,...
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
@ DRCE_PAD_TH_WITH_NO_HOLE
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_0
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_VIEWER_MODAL
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Some functions to handle hotkeys in KiCad.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
@ LAYER_CONFLICTS_SHADOW
shadow layer for items flagged conficting
@ LAYER_MOD_FR
show footprints on front
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
@ LAYER_MOD_VALUES
show footprints values (when texts are visible)
@ LAYER_MOD_BK
show footprints on back
@ LAYER_MOD_REFERENCES
show footprints references (when texts are visible)
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ NPTH
like PAD_PTH, but not plated
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
@ NONE
no special fabrication property
@ TESTPOINT
a test point pad
@ CASTELLATED
a pad with a castellated through hole
@ BGA
Smd pad, used in BGA footprints.
#define NO_SETTER(owner, type)
@ PT_DEGREE
Angle expressed in degrees.
@ PT_SIZE
Size expressed in distance units (mm/inch)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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.
constexpr double IUTomm(int iu) const
constexpr int mmToIU(double mm) const
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
@ THERMAL
Use thermal relief for pads.
@ THT_THERMAL
Thermal relief only for THT pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper