42#include <wx/tokenzr.h>
66constexpr double OCTAGON_CHAMFER_RATIO = 0.25;
88std::vector<VECTOR2I> parsePolyPad(
const std::string& aValue )
90 std::vector<VECTOR2I> pts;
91 wxStringTokenizer tokens( wxString( aValue ), wxS(
";" ), wxTOKEN_STRTOK );
93 while( tokens.HasMoreTokens() )
95 wxString pair = tokens.GetNextToken();
99 if( !pair.BeforeFirst(
',' ).ToLong( &x ) || !pair.AfterFirst(
',' ).ToLong( &y ) )
102 pts.emplace_back(
int( x ),
int( y ) );
133 m_board->GetDesignSettings().m_CopperEdgeClearance = 0;
136 m_board->m_LegacyDesignSettingsLoaded =
true;
142 bbox =
m_board->ComputeBoundingBox(
false );
152 return LAYER_FUNCTION::OTHER;
162 return f == LAYER_FUNCTION::COPPER_BOTTOM || f == LAYER_FUNCTION::COPPER_INSIDE
163 || f == LAYER_FUNCTION::COPPER_TOP;
170 wxString
text = aNetName;
171 text.Replace( wxS(
"\\" ), wxS(
"\\\\" ) );
172 text.Replace( wxS(
"'" ), wxS(
"\\\\'" ) );
173 text.Replace( wxS(
"\"" ), wxS(
"\\\"" ) );
174 return wxS(
"'" ) +
text + wxS(
"'" );
183 auto mostCommon = [](
const std::map<int, int>& aCounts )
185 return std::max_element( aCounts.begin(), aCounts.end(),
186 [](
const auto& a,
const auto& b )
188 return a.second < b.second;
192 std::map<int, int> boardCounts;
193 std::map<int, std::vector<wxString>> netsByClearance;
199 if( !item || item->
GetNetCode() <= 0 || counts.empty() )
202 netsByClearance[mostCommon( counts )].push_back( item->
GetNetname() );
204 for(
const auto& [
clearance, count] : counts )
208 if( boardCounts.empty() )
211 auto mm = [](
int aValue )
216 auto addRule = [&](
const wxString& aName,
int aClearance,
const wxString& aCondition )
218 m_designRules += wxString::Format( wxS(
"\n(rule \"%s\"\n (constraint clearance (min %s))\n"
219 " (condition \"%s\"))\n" ),
220 aName, mm( aClearance ), aCondition );
224 int base = mostCommon( boardCounts );
226 addRule( wxS(
"TARGET 3001! copper areas" ), base, wxS(
"A.Type == 'Zone'" ) );
228 for(
const auto& [
clearance, nets] : netsByClearance )
235 for(
const wxString&
name : nets )
237 if( !condition.IsEmpty() )
238 condition += wxS(
" || " );
243 addRule( wxS(
"TARGET 3001! copper areas to " ) + mm(
clearance ) + wxS(
" signals" ),
clearance,
244 wxS(
"A.Type == 'Zone' && (" ) + condition + wxS(
")" ) );
253 bool hasArea =
false;
256 for(
PCB_LAYER_ID layer : entry.pad->GetLayerSet().CuStack() )
262 joined |= entry.noAura.count( layer ) > 0;
275 std::vector<int>
top;
276 std::vector<int> inner;
277 std::vector<int> bottom;
283 case LAYER_FUNCTION::COPPER_TOP:
top.push_back( layer );
break;
284 case LAYER_FUNCTION::COPPER_INSIDE: inner.push_back( layer );
break;
285 case LAYER_FUNCTION::COPPER_BOTTOM: bottom.push_back( layer );
break;
298 THROW_IO_ERROR( wxString::Format(
_(
"TARGET 3001! board has %zu copper layers; at most %d are supported." ),
304 if( copperCount % 2 )
307 m_board->SetCopperLayerCount( copperCount );
337 std::optional<PCB_LAYER_ID> id;
341 case LAYER_FUNCTION::POSITION_BOTTOM:
id =
B_SilkS;
break;
342 case LAYER_FUNCTION::POSITION_TOP:
id =
F_SilkS;
break;
343 case LAYER_FUNCTION::NAMES_BOTTOM:
id =
B_SilkS;
break;
344 case LAYER_FUNCTION::NAMES_TOP:
id =
F_SilkS;
break;
345 case LAYER_FUNCTION::VALUES_BOTTOM:
id =
B_Fab;
break;
346 case LAYER_FUNCTION::VALUES_TOP:
id =
F_Fab;
break;
347 case LAYER_FUNCTION::MASK_BOTTOM:
id =
B_Mask;
break;
348 case LAYER_FUNCTION::MASK_TOP:
id =
F_Mask;
break;
349 case LAYER_FUNCTION::PASTE_BOTTOM:
id =
B_Paste;
break;
350 case LAYER_FUNCTION::PASTE_TOP:
id =
F_Paste;
break;
351 case LAYER_FUNCTION::GLUE_BOTTOM:
id =
B_Adhes;
break;
352 case LAYER_FUNCTION::GLUE_TOP:
id =
F_Adhes;
break;
354 case LAYER_FUNCTION::OUTLINE:
id =
Edge_Cuts;
break;
355 case LAYER_FUNCTION::DIMENSIONING:
id =
Dwgs_User;
break;
356 case LAYER_FUNCTION::DRILL_PLAN:
id =
Cmts_User;
break;
359 case LAYER_FUNCTION::AREA_BOTTOM:
360 case LAYER_FUNCTION::AREA_INSIDE:
361 case LAYER_FUNCTION::AREA_TOP:
362 case LAYER_FUNCTION::DELETION_BOTTOM:
363 case LAYER_FUNCTION::DELETION_INSIDE:
364 case LAYER_FUNCTION::DELETION_TOP:
365 case LAYER_FUNCTION::AIR_WIRES:
386 m_board->SetEnabledLayers( enabled );
387 m_board->SetVisibleLayers( enabled );
392 m_board->SetLayerName(
id, wxString::Format( wxS(
"Target layer %d" ), target ) );
414 case LAYER_FUNCTION::AREA_BOTTOM:
415 case LAYER_FUNCTION::AREA_INSIDE:
416 case LAYER_FUNCTION::AREA_TOP:
417 defaultCopper = aLayer + 2;
420 case LAYER_FUNCTION::DELETION_BOTTOM:
421 case LAYER_FUNCTION::DELETION_INSIDE:
422 case LAYER_FUNCTION::DELETION_TOP:
423 defaultCopper = aLayer + 1;
430 int copper =
m_project.layerAssociations[aLayer];
434 copper = defaultCopper;
445 for(
size_t i = 0; i <
m_project.signals.size(); i++ )
449 if( e.
type != ELEMENT_TYPE::SIGNAL || !e.
signal )
455 name = wxString::Format( wxS(
"Net-%zu" ), i + 1 );
459 name = wxString::Format( wxS(
"%s_%zu" ),
name, i + 1 );
470 auto it =
m_nets.find( aSignal );
471 return it ==
m_nets.end() ? nullptr : it->second;
491 if(
comp.packageItems.empty() )
494 const ELEMENT* placement = &
comp.packageItems.front();
496 if( placement->
type != ELEMENT_TYPE::PACKAGE || !placement->
package )
501 if( placementLayer != LAYER_FUNCTION::POSITION_TOP && placementLayer != LAYER_FUNCTION::POSITION_BOTTOM )
517 wxString reference =
ToWx(
comp.prefix ).Trim().Trim(
false );
518 uint16_t number =
comp.referenceExtension.value_or(
comp.referenceNumber );
530 if( &item != placement )
531 addItem( item, fp, fp,
false );
540 if( e.
type != ELEMENT_TYPE::SIGNAL || !e.
signal )
551 for(
int i = 0; i < polys.OutlineCount(); i++ )
558 shape->
SetNet(
net( uint16_t( key.first ) ) );
574 std::map<std::pair<uint16_t, PCB_LAYER_ID>,
SHAPE_POLY_SET> pours;
582 pours[{ area.signal, area.layer }].Append( area.outline );
585 for(
auto& [key, outline] : pours )
589 for(
int i = 0; i < outline.OutlineCount(); i++ )
613 for(
int i = 0; i < keepout.OutlineCount(); i++ )
637 case ELEMENT_TYPE::TRIANGLE:
647 case ELEMENT_TYPE::RECTANGLE:
651 VECTOR2D corners[4] = { { 0.0, 0.0 }, { double( r.
width ), 0.0 },
666 case ELEMENT_TYPE::DISC:
670 case ELEMENT_TYPE::LINE:
675 case ELEMENT_TYPE::FIDUCIAL:
681 case ELEMENT_TYPE::ARC:
685 int width = std::max( 1, a.
width );
688 if(
sweep >= 360.0 - 1e-6 )
694 auto onArc = [&](
double aDeg )
726 case ELEMENT_TYPE::LINE:
730 case ELEMENT_TYPE::ARC:
733 double start = std::fmod(
double( a.
startAngle ), 360.0 );
736 auto onArc = [&](
double aDeg )
743 for(
double axis = std::ceil( start / 90.0 ) * 90.0; axis <=
end; axis += 90.0 )
757 case ELEMENT_TYPE::TRIANGLE:
758 case ELEMENT_TYPE::RECTANGLE:
783 if( ( b.
flags & 1 ) && aElem.
type != ELEMENT_TYPE::TEXT )
786 if( aElem.
type == ELEMENT_TYPE::PAD )
789 addPad( aElem, aFootprint );
803 if( aElem.
type == ELEMENT_TYPE::TEXT )
820 bool isArea = f == LAYER_FUNCTION::AREA_BOTTOM || f == LAYER_FUNCTION::AREA_INSIDE
821 || f == LAYER_FUNCTION::AREA_TOP;
832 std::vector<PCB_LAYER_ID> layers;
838 layers.push_back( cu );
840 else if( std::optional<PCB_LAYER_ID> layer =
mapLayer( b.
layer ) )
842 layers.push_back( *layer );
847 if( aElem.
type == ELEMENT_TYPE::TEXT )
848 addText( aElem, aParent, aFootprint, layer );
850 addShape( aElem, aParent, aFootprint, aIsTrack, layer );
865 if( aElem.
type == ELEMENT_TYPE::LINE )
867 else if( aElem.
type == ELEMENT_TYPE::ARC )
869 else if( aElem.
type == ELEMENT_TYPE::SPLINE )
879 case ELEMENT_TYPE::LINE:
883 if( copper && aIsTrack && !aFootprint )
908 case ELEMENT_TYPE::ARC:
914 bool full =
sweep >= 360.0 - 1e-6;
939 if( copper && aIsTrack && !aFootprint )
964 case ELEMENT_TYPE::SPLINE:
988 case ELEMENT_TYPE::TRIANGLE:
989 case ELEMENT_TYPE::RECTANGLE:
990 case ELEMENT_TYPE::DISC:
996 if( copper && aIsTrack && !aFootprint && aElem.
type == ELEMENT_TYPE::TRIANGLE )
1004 if( aElem.
type == ELEMENT_TYPE::DISC )
1027 case ELEMENT_TYPE::FIDUCIAL:
1028 for( std::unique_ptr<PCB_SHAPE>& shape :
fiducialShapes( aElem, aParent ) )
1030 shape->SetLayer( aLayer );
1051 std::vector<std::unique_ptr<PCB_SHAPE>> shapes;
1053 auto circle = [&](
int aRadius,
int aWidth,
bool aFilled )
1055 std::unique_ptr<PCB_SHAPE> shape = std::make_unique<PCB_SHAPE>( aParent,
SHAPE_T::CIRCLE );
1056 shape->SetCenter(
toKi( b.
x, b.
y ) );
1057 shape->SetRadius( aRadius );
1059 shape->SetFilled( aFilled );
1060 shapes.push_back( std::move( shape ) );
1079 for(
double axis : { 0.0, 90.0 } )
1082 int32_t dx =
KiROUND( ring * cos( rad ) );
1083 int32_t dy =
KiROUND( ring * sin( rad ) );
1085 std::unique_ptr<PCB_SHAPE> arm = std::make_unique<PCB_SHAPE>( aParent,
SHAPE_T::SEGMENT );
1086 arm->SetStart(
toKi( b.
x + dx, b.
y + dy ) );
1087 arm->SetEnd(
toKi( b.
x - dx, b.
y - dy ) );
1089 shapes.push_back( std::move( arm ) );
1127 if( size.
x == size.
y )
1134 bool wide = size.
x > size.
y;
1138 int anchor = std::min( size.
x, size.
y );
1150 const std::string* prop = b.
FindProp(
"POLY_PAD" );
1151 std::vector<VECTOR2I> pts = prop ? parsePolyPad( *prop ) : std::vector<VECTOR2I>();
1153 if( pts.size() >= 3 )
1155 std::vector<VECTOR2I> local;
1158 local.emplace_back( pt.x, -pt.y );
1190 if(
const std::string* prop = b.
FindProp(
"RECT_ROUNDED" ) )
1191 wxString( *prop ).ToLong( &rounded );
1209 bool hasHole = src.
drill > 0;
1215 if(
const std::string* slot = b.
FindProp(
"SLOT_HOLE" ) )
1219 if( wxString( *slot ).ToLong( &length ) && length > src.
drill )
1234 pad->SetLayerSet( *padstack );
1242 pad->DeletePrimitivesList();
1250 pad->SetLayerSet( *padstack );
1256 LSET layers( { side } );
1260 else if( side ==
B_Cu )
1264 pad->SetLayerSet( layers );
1280 entry.noAura.insert( cu );
1282 else if(
const std::string* layers = b.
FindProp(
"NO_AURA" ) )
1284 wxStringTokenizer tokens( wxString::FromUTF8( *layers ), wxS(
"," ) );
1286 while( tokens.HasMoreTokens() )
1290 if( tokens.GetNextToken().Trim().Trim(
false ).ToLong( &layer ) &&
isCopper(
int( layer ) ) )
1292 if( std::optional<PCB_LAYER_ID> cu =
mapLayer(
int( layer ) ) )
1293 entry.noAura.insert( *cu );
1318 || ( f != LAYER_FUNCTION::DELETION_BOTTOM && f != LAYER_FUNCTION::DELETION_INSIDE
1319 && f != LAYER_FUNCTION::DELETION_TOP ) )
1335 const std::vector<TARGET3001::PADSTACK_DEF>& padstacks =
m_project.settings.padstacks;
1338 if( aLayer < TARGET3001::FIRST_PADSTACK_LAYER || index >= padstacks.size() )
1339 return std::nullopt;
1345 if( !padstacks[
index].onLayer[layer] )
1348 std::optional<PCB_LAYER_ID> mapped =
mapLayer( layer );
1353 layers.
set( *mapped );
1367 bool slotted = b.
FindProp(
"SLOT_HOLE" ) !=
nullptr;
1375 || ( padstack && ( *padstack & allCopper ) != allCopper ) )
1377 addPad( aElem,
nullptr );
1404 m_fonts.Apply( aText, aElem, 1 );
1412 if( std::optional<std::pair<int32_t, int32_t>>
end = b.
TextRightEnd() )
1429 if( aFootprint && t.
function == uint8_t( TEXT_FUNCTION::REFERENCE ) )
1436 if( aFootprint && t.
function == uint8_t( TEXT_FUNCTION::VALUE ) )
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
BASE_SET & set(size_t pos)
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false)=0
Adds an item to the container.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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 void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr size_type GetHeight() const
virtual void SetFilled(bool aFlag)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
virtual void SetTextPos(const VECTOR2I &aPoint)
void SetMirrored(bool isMirrored)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Handle the data for a net.
const wxString & GetNetname() const
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static LSET PTHMask()
layer set for a through hole pad
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
void SetMid(const VECTOR2I &aMid)
void SetCenter(const VECTOR2I &aCenter) override
void SetBezierC1(const VECTOR2I &aPt) override
void SetEnd(const VECTOR2I &aEnd) override
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
void SetBezierC2(const VECTOR2I &aPt) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) override
Set the three controlling points for an arc.
VECTOR2I GetTextPos() const override
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Convert the text to a polygonSet describing the actual character strokes (one per segment).
void SetTextAngle(const EDA_ANGLE &aAngle) override
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
virtual void SetWidth(int aWidth)
A pure virtual class used to derive REPORTER objects from.
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a set of closed polygons.
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)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Simple container to manage line stroke parameters.
static VECTOR2I BaselineShift(const EDA_TEXT &aText)
Offset in text units that moves aText so the baseline-left point of its first glyph lies on its posit...
TARGET3001::LAYER_FUNCTION LayerFunction(int aLayer) const
Function of a TARGET 3001! board layer in this project.
const TARGET3001::PROJECT & m_project
std::map< uint16_t, NETINFO_ITEM * > m_nets
by signal ID
std::vector< POUR_AREA > m_pourAreas
void addShape(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, bool aIsTrack, PCB_LAYER_ID aLayer)
Add the graphic or track form of aElem on one KiCad layer.
void addVia(const TARGET3001::ELEMENT &aElem)
std::map< int, SHAPE_POLY_SET > m_pourKeepouts
KiCad layer -> pour keepout.
void addFootprint(const TARGET3001::ELEMENT &aComponent)
std::vector< int > m_copperStack
TARGET layers, top to bottom.
void addItem(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, bool aIsTrack)
Add one board element to aParent; footprint items are passed with their footprint.
std::vector< std::unique_ptr< PCB_SHAPE > > fiducialShapes(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent) const
Strokes and discs that draw a fiducial mark, not yet assigned a layer.
std::optional< PCB_LAYER_ID > pourCopperLayer(int aLayer) const
Copper layer that an area or deletion layer applies to.
void buildAreaClearanceRules()
Clearance rules between copper areas and each signal's tracks and vias.
bool isCopper(int aLayer) const
NETINFO_ITEM * net(uint16_t aSignal) const
void addPad(const TARGET3001::ELEMENT &aElem, FOOTPRINT *aFootprint)
void connectAuraPads()
Connect pads to areas of their own signal the way their aura and NO_AURA layers do.
bool elementOutline(const TARGET3001::ELEMENT &aElem, SHAPE_POLY_SET &aOut) const
Outline of a filled element (rectangle, triangle, disc, stroked line or arc) in KiCad coordinates.
std::set< std::pair< uint16_t, PCB_LAYER_ID > > m_pourLayers
(signal, KiCad layer) holding an area
std::map< std::pair< int, int >, SHAPE_POLY_SET > m_copperFills
(net, KiCad layer) -> filled copper
std::map< uint16_t, std::map< int, int > > m_signalClearances
Track and via clearances counted per signal, then per clearance value.
TARGET3001_PCB_BUILDER(BOARD *aBoard, const TARGET3001::PROJECT &aProject, REPORTER *aReporter)
void addPadstackCuts(const BOARD_ITEM &aItem, int aPadstack)
Cut aItem, grown per layer, from the pours of the deletion layers padstack aPadstack lists.
std::optional< LSET > padstackLayers(int aLayer) const
Copper, mask and paste layers of the padstack a pad layer >= 101 selects.
void addText(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer)
void mergeContour(const TARGET3001::ELEMENT &aElem)
Grow the board contour box by the defining points of an element, ignoring line widths.
TARGET3001::FONTS m_fonts
void configureText(PCB_TEXT *aText, const TARGET3001::ELEMENT &aElem, PCB_LAYER_ID aLayer)
VECTOR2I toKi(int32_t aX, int32_t aY) const
std::optional< int > m_contourLayer
first TARGET layer holding the contour
std::optional< PCB_LAYER_ID > mapLayer(int aLayer) const
Copper or graphic layer for a board element, if KiCad has a place for it.
std::map< int, PCB_LAYER_ID > m_layerMap
bool m_contourCarvesNothing
a contour stroke has no clearance
std::vector< AURA_PAD > m_auraPads
Handle a list of polygons defining a copper zone.
void SetDoNotAllowPads(bool aEnable)
void SetLocalClearance(std::optional< int > aClearance)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
void SetIsRuleArea(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
void SetDoNotAllowVias(bool aEnable)
void SetNet(NETINFO_ITEM *aNetInfo) override
Override that drops aNetInfo when this zone is in copper-thieving fill mode.
void SetDoNotAllowFootprints(bool aEnable)
void SetDoNotAllowZoneFills(bool aEnable)
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void TransformRingToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arcs to multiple straight segments.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
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.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
PCB_LAYER_ID BoardLayerFromLegacyId(int aLegacyId)
Retrieve a layer ID from an integer converted from a legacy (pre-V9) enum value.
bool IsSolderMaskLayer(int aLayer)
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
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 ...
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
Converts aValue from internal units to a string appropriate for writing to file.
LAYER_FUNCTION
Board layer function codes stored per layer in the project header.
constexpr int FIRST_PADSTACK_LAYER
A pad on board layer FIRST_PADSTACK_LAYER + n takes its layers from project padstack n.
wxString PadNumber(const ELEMENT &aPad)
Number of a pad element in KiCad, its PADNAME when present, else its stored number.
constexpr int ALL_COPPER_LAYER
Board elements on this layer exist on every copper layer.
@ POLYGON
vertices in the POLY_PAD property
@ CROSSHAIR_RINGS
cross and rings at 1, 2/3 and 1/3 of the outer centreline radius
@ FILLED_CIRCLE
solid disc of the outer radius
wxString ToWx(const std::string &aRaw)
Convert a stored ANSI string to a wxString.
ELEMENT_TYPE
Element class tags as stored in the file.
constexpr int BOARD_LAYER_COUNT
Board layers 0..99 carry a per-project function; 100 and above have fixed meanings.
constexpr uint8_t NO_ASSOCIATION
Layer association value for a layer that belongs to no copper layer.
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
LINE_STYLE
Dashed line types.
Stroked arc or circle. The base position is the start point.
double Sweep() const
Counter-clockwise sweep in (0, 360]; equal angles give a full circle.
float startAngle
degrees, counter-clockwise from +X
Fields shared by every drawable element.
uint16_t signal
ID of the owning signal (a signal stores its own), 0 for none.
std::optional< std::pair< int32_t, int32_t > > TextRightEnd() const
Right end of right-aligned text from its ARXY property, in file coordinates.
const std::string * FindProp(const std::string &aKey) const
Return the value of the first property named aKey, if any.
One element of any class.
std::shared_ptr< COMPONENT > component
std::shared_ptr< SIGNAL > signal
std::shared_ptr< PACKAGE > package
uint8_t kind
FIDUCIAL_KIND.
uint8_t dashStyle
0 solid, 1 long dash, 2 dash-dot, 3 other, 4 short dash
Footprint placement. Pads and graphics of the footprint are stored in board coordinates.
Project padstack; the board layers a pad exists on and how far it grows on each.
std::array< bool, BOARD_LAYER_COUNT > onLayer
std::array< int32_t, BOARD_LAYER_COUNT > oversize
growth per side, nm
int32_t width
along the pad's own X axis before rotation
int32_t drill
0 for no hole
Filled rectangle anchored at a corner (the base position); sizes are signed.
Quadratic Bezier from the base position to the end point.
Filled triangle given by three absolute corners (the first is the base position).
constexpr int ALL_COPPER_LAYER
Board elements on this layer exist on every copper layer.
constexpr int BOARD_LAYER_COUNT
Board layers 0..99 carry a per-project function; 100 and above have fixed meanings.
constexpr uint8_t NO_ASSOCIATION
Layer association value for a layer that belongs to no copper layer.
static wxString ruleNetLiteral(const wxString &aNetName)
An expression string literal, whose only escape is \', inside a quoted rules file string.
wxString ToWx(const std::string &aRaw)
Convert a stored ANSI string to a wxString.
KIBIS top(path, &reporter)
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
static double sweep(float aStart, float aEnd)
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.
double DEG2RAD(double deg)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper