73#define EXPORT_CUSTOM_PADS_CONVEX_HULL
92 errorText = ioe.
What();
101 SetStatusText( wxString(
_(
"BOARD exported OK." ) ) );
122 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
153static inline double scale(
int kicadDist )
156 return kicadDist / (
pcbIUScale.IU_PER_MM / 1000.0 );
161static inline double IU2um(
int kicadDist )
163 return kicadDist * ( 1000.0 /
pcbIUScale.IU_PER_MM );
167static inline double mapX(
int x )
173static inline double mapY(
int y )
200 return mapPt( fpRelative );
230 path->AppendPoint( aStart );
231 path->AppendPoint( aEnd );
232 path->SetLayerId( aLayerName );
245 std::string uniqifier;
256 int reportedLayers = 0;
257 std::vector<std::string> layerName( copperCount );
259 bool onAllCopperLayers = ( (aPad->
GetLayerSet() & all_cu) == all_cu );
261 if( onAllCopperLayers )
264 for(
int layer=0; layer < copperCount; ++layer )
268 if( onAllCopperLayers || aPad->
IsOnLayer( kilayer ) )
270 layerName[reportedLayers++] =
m_layerIds[layer];
272 if( !onAllCopperLayers )
276 else if( layer == copperCount - 1 )
279 uniqifier += char(
'0' + layer);
292 if( offset.
x || offset.
y )
294 dsnOffset =
mapPt( offset );
296 std::ostringstream oss;
297 oss.imbue( std::locale::classic() );
298 oss << std::fixed << std::setprecision( 6 )
299 <<
'[' << dsnOffset.
x <<
',' << dsnOffset.
y <<
']';
300 uniqifier += oss.str();
307 double diameter =
scale( padSize.
x );
309 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
313 padstack->
Append( shape );
319 circle->SetLayerId( layerName[ndx] );
320 circle->SetDiameter( diameter );
321 circle->SetVertex( dsnOffset );
324 std::ostringstream oss;
325 oss <<
"Round" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
326 <<
IU2um( padSize.
x ) <<
"_um";
334 double dx =
scale( padSize.
x ) / 2.0;
335 double dy =
scale( padSize.
y ) / 2.0;
337 POINT lowerLeft( -dx, -dy );
338 POINT upperRight( dx, dy );
340 lowerLeft += dsnOffset;
341 upperRight += dsnOffset;
343 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
347 padstack->
Append( shape );
357 std::ostringstream oss;
358 oss <<
"Rect" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
359 <<
IU2um( padSize.
x ) <<
"x" <<
IU2um( padSize.
y ) <<
"_um";
367 double dx =
scale( padSize.
x ) / 2.0;
368 double dy =
scale( padSize.
y ) / 2.0;
378 pstart =
POINT( -dr, 0.0 );
379 pstop =
POINT( dr, 0.0 );
386 pstart =
POINT( 0.0, -dr );
387 pstop =
POINT( 0.0, dr );
393 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
399 shape =
new SHAPE( padstack );
401 padstack->
Append( shape );
407 std::ostringstream oss;
408 oss <<
"Oval" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
409 <<
IU2um( padSize.
x ) <<
"x" <<
IU2um( padSize.
y ) <<
"_um";
417 double dx =
scale( padSize.
x ) / 2.0;
418 double dy =
scale( padSize.
y ) / 2.0;
426 POINT lowerLeft( -dx - ddy, -dy - ddx );
427 POINT upperLeft( -dx + ddy, +dy + ddx );
428 POINT upperRight( +dx - ddy, +dy - ddx );
429 POINT lowerRight( +dx + ddy, -dy + ddx );
431 lowerLeft += dsnOffset;
432 upperLeft += dsnOffset;
433 upperRight += dsnOffset;
434 lowerRight += dsnOffset;
436 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
440 padstack->
Append( shape );
443 PATH* polygon =
new PATH( shape, T_polygon );
456 std::ostringstream oss;
457 oss <<
"Trapz" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
458 <<
IU2um( padSize.
x ) <<
"x" <<
IU2um( padSize.
y ) <<
"_"
470 const int circleToSegmentsCount = 36;
482 double correctionFactor = cos(
M_PI / (
double) circleToSegmentsCount );
483 int extra_clearance =
KiROUND( rradius * ( 1.0 - correctionFactor ) );
485 psize.
x += extra_clearance * 2;
486 psize.
y += extra_clearance * 2;
487 rradius += extra_clearance;
497 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
501 padstack->
Append( shape );
504 PATH* polygon =
new PATH( shape, T_polygon );
513 for(
int idx = 0; idx < polygonal_shape.
PointCount(); idx++ )
521 first_corner = corner;
528 std::ostringstream oss;
529 oss <<
"RoundRect" << uniqifier <<
"Pad_"
530 << std::fixed << std::setprecision(6)
531 <<
IU2um( padSize.
x ) <<
'x'
532 <<
IU2um( padSize.
y ) <<
'_'
533 <<
IU2um( rradius ) <<
"_um_"
535 << std::hex << std::uppercase
544 std::vector<VECTOR2I> polygonal_shape;
548#ifdef EXPORT_CUSTOM_PADS_CONVEX_HULL
553 for(
int ii = 0; ii < p_outline.
PointCount(); ++ii )
554 polygonal_shape.push_back( wxPoint( p_outline.
CPoint( ii ) ) );
558 if( polygonal_shape.front() != polygonal_shape.back() )
559 polygonal_shape.push_back( polygonal_shape.front() );
561 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
565 padstack->
Append( shape );
568 PATH* polygon =
new PATH( shape, T_polygon );
574 for(
unsigned idx = 0; idx < polygonal_shape.size(); idx++ )
576 POINT corner(
scale( polygonal_shape[idx].x ),
scale( -polygonal_shape[idx].y ) );
586 std::ostringstream oss;
587 oss <<
"Cust" << uniqifier <<
"Pad_"
588 << std::fixed << std::setprecision(6)
589 <<
IU2um( padSize.
x ) <<
'x' <<
IU2um( padSize.
y ) <<
'_'
591 << polygonal_shape.size() <<
"_um_"
622 for(
int p = 0; p < fpItems.
GetCount(); ++p )
629 double diameter =
scale(
pad->GetDrillSize().x );
636 for(
int layer=0; layer<layerCount; ++layer )
640 image->m_keepouts.push_back( keepout );
646 circle->SetDiameter( diameter );
647 circle->SetVertex( vertex );
657 if( !mask_copper_layers.any() )
661 PADSTACKSET::iterator iter =
m_padstackset.find( *padstack );
667 padstack = (
PADSTACK*) *iter.base();
676 padNumber =
pad->GetNumber();
679 if( padNumber != wxEmptyString && pinmap.find( padNumber ) == pinmap.end() )
681 pinmap[ padNumber ] = 0;
685 int duplicates = ++pinmap[ padNumber ];
688 "@" + std::to_string( duplicates );
691 pin->m_kiNetCode =
pad->GetNetCode();
716 image->Append( outline );
721 path->SetAperture( 0 );
722 path->SetLayerId(
"signal" );
724 for(
int ii = 0; ii <
chain.PointCount(); ++ii )
727 path->AppendPoint(
mapPt( corner, aFootprint ) );
735 for(
int i = 0; i < fpItems.
GetCount(); ++i )
749 image->Append( outline );
754 path->SetLayerId(
"signal" );
764 image->Append( outline );
770 path->SetLayerId(
"signal" );
779 for(
int ii = 0; ii < polyline.
PointCount(); ++ii )
782 path->AppendPoint(
mapPt( corner, aFootprint ) );
792 image->Append( outline );
797 path->SetLayerId(
"signal" );
799 path->AppendPoint(
mapPt( corner, aFootprint ) );
802 path->AppendPoint(
mapPt( corner, aFootprint ) );
805 path->AppendPoint(
mapPt( corner, aFootprint ) );
808 path->AppendPoint(
mapPt( corner, aFootprint ) );
811 path->AppendPoint(
mapPt( corner, aFootprint ) );
823 image->Append( outline );
824 path =
new PATH( outline, T_polygon );
827 path->SetAperture( 0 );
828 path->SetLayerId(
"signal" );
836 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
839 path->AppendPoint(
mapPt( corner, aFootprint ) );
852 if( !zone->GetIsRuleArea() )
856 ZONE untransformedZone( *zone );
868 if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
869 keepout_type = T_keepout;
870 else if( zone->GetDoNotAllowVias() )
871 keepout_type = T_via_keepout;
872 else if( zone->GetDoNotAllowTracks() )
873 keepout_type = T_wire_keepout;
875 keepout_type = T_keepout;
884 image->m_keepouts.push_back( keepout );
886 PATH* mainPolygon =
new PATH( keepout, T_polygon );
893 bool is_first_point =
true;
896 for( iterator = untransformedZone.
IterateWithHoles(); iterator; iterator++ )
905 is_first_point =
false;
919 PATH* cutout =
nullptr;
920 bool isStartContour =
true;
923 for( iterator++; iterator; iterator++ )
927 is_first_point =
true;
928 window =
new WINDOW( keepout );
931 cutout =
new PATH( window, T_polygon );
950 is_first_point =
false;
967 int aTopLayer,
int aBotLayer )
971 double dsnDiameter =
scale( aCopperDiameter );
973 for(
int layer=aTopLayer; layer<=aBotLayer; ++layer )
977 padstack->
Append( shape );
983 circle->SetDiameter( dsnDiameter );
987 snprintf(
name,
sizeof(
name ),
"Via[%d-%d]_%.6g:%.6g_um",
988 aTopLayer, aBotLayer, dsnDiameter,
990 IU2um( aDrillDiameter ) );
1004 aVia->
LayerPair( &topLayerNum, &botLayerNum );
1009 if( topLayer > botLayer )
1010 std::swap( topLayer, botLayer );
1014 topLayer, botLayer );
1024 path->layer_id =
"pcb";
1028 for(
int ii = 0; ii < outline.
PointCount(); ii++ )
1043 PATH* poly_ko =
new PATH(
nullptr, T_polygon );
1047 m_pcb->m_structure->m_keepouts.push_back( keepout );
1051 for(
int jj = 0; jj < hole.
PointCount(); jj++ )
1080 if( footprint->GetReference() == wxEmptyString )
1082 THROW_IO_ERROR( wxString::Format(
_(
"Footprint with value of '%s' has an empty "
1083 "reference designator." ),
1084 footprint->GetValue() ) );
1090 if( !refpair.second )
1092 THROW_IO_ERROR( wxString::Format(
_(
"Multiple footprints have the reference "
1093 "designator '%s'." ),
1094 footprint->GetReference() ) );
1111 for(
int pcbNdx=0; pcbNdx<layerCount; ++pcbNdx )
1115 m_pcb->m_structure->m_layers.push_back( layer );
1124 case LT_SIGNAL: layerType = T_signal;
break;
1125 case LT_POWER: layerType = T_power;
break;
1129 case LT_MIXED: layerType = T_signal;
break;
1130 case LT_JUMPER: layerType = T_jumper;
break;
1137 property->name =
"index";
1138 property->value = std::to_string( pcbNdx );
1143 m_pcb->m_parser->space_in_quoted_tokens =
true;
1150 m_pcb->m_unit->units = T_um;
1151 m_pcb->m_resolution->units = T_um;
1152 m_pcb->m_resolution->value = 10;
1161 m_pcb->m_structure->SetBOUNDARY( boundary );
1168 int defaultTrackWidth = netSettings->GetDefaultNetclass()->GetTrackWidth();
1169 int defaultClearance = netSettings->GetDefaultNetclass()->GetClearance();
1174 std::snprintf( rule,
sizeof( rule ),
"(width %.6g)",
scale( defaultTrackWidth ) );
1175 rules.push_back( rule );
1177 std::snprintf( rule,
sizeof( rule ),
"(clearance %.6g)",
clearance );
1178 rules.push_back( rule );
1185 std::snprintf( rule,
sizeof( rule ),
"(clearance %.6g (type smd_smd))",
clearance );
1186 rules.push_back( rule );
1192 int netlessZones = 0;
1196 if( zone->GetIsRuleArea() )
1200 if( ! zone->IsOnCopperLayer() )
1211 m_pcb->m_structure->m_planes.push_back( plane );
1213 PATH* mainPolygon =
new PATH( plane, T_polygon );
1218 if( plane->
m_name.size() == 0 )
1225 no_net->
m_net_id =
"@:no_net_" + std::to_string( netlessZones++ );
1228 m_pcb->m_network->m_nets.push_back( no_net );
1239 bool is_first_point =
true;
1241 for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
1245 if( is_first_point )
1248 is_first_point =
false;
1262 WINDOW* window =
nullptr;
1263 PATH* cutout =
nullptr;
1265 bool isStartContour =
true;
1268 for( iterator++; iterator; iterator++ )
1270 if( isStartContour )
1272 is_first_point =
true;
1273 window =
new WINDOW( plane );
1276 cutout =
new PATH( window, T_polygon );
1290 if( is_first_point )
1293 is_first_point =
false;
1310 if( !zone->GetIsRuleArea() )
1318 if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
1319 keepout_type = T_keepout;
1320 else if( zone->GetDoNotAllowVias() )
1321 keepout_type = T_via_keepout;
1322 else if( zone->GetDoNotAllowTracks() )
1323 keepout_type = T_wire_keepout;
1325 keepout_type = T_keepout;
1334 m_pcb->m_structure->m_keepouts.push_back( keepout );
1336 PATH* mainPolygon =
new PATH( keepout, T_polygon );
1343 bool is_first_point =
true;
1346 for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
1350 if( is_first_point )
1353 is_first_point =
false;
1366 WINDOW* window =
nullptr;
1367 PATH* cutout =
nullptr;
1369 bool isStartContour =
true;
1372 for( iterator++; iterator; iterator++ )
1374 if( isStartContour )
1376 is_first_point =
true;
1377 window =
new WINDOW( keepout );
1380 cutout =
new PATH( window, T_polygon );
1392 if( is_first_point )
1395 is_first_point =
false;
1411 std::string componentId;
1412 int highestNetCode = 0;
1417 highestNetCode = std::max( highestNetCode, i->GetNetCode() );
1422 m_nets.resize( highestNetCode + 1,
nullptr );
1424 for(
unsigned i = 1 ; i <
m_nets.size(); ++i )
1429 if( i->GetNetCode() > 0 )
1430 m_nets[i->GetNetCode()]->m_net_id =
TO_UTF8( i->GetNetname() );
1439 componentId =
TO_UTF8( footprint->GetReference() );
1447 for(
unsigned p = 0; p <
image->m_pins.size(); ++p )
1450 int netcode =
pin->m_kiNetCode;
1478 comp->m_places.push_back( place );
1480 place->
SetRotation( footprint->GetOrientationDegrees() );
1486 if( footprint->GetFlag() )
1503 m_pcb->m_library->AddPadstack( padstack );
1507 for(
unsigned n = 1; n <
m_nets.size(); ++n )
1514 m_pcb->m_network->m_nets.push_back( net );
1521 std::unordered_map<wxString, NETCLASS*> netclassesInUse;
1525 NETCLASS* netclass = net->GetNetClass();
1532 if( !netclassesInUse.contains(
name ) )
1533 netclassesInUse[
name] = netclass;
1555 wxASSERT(
m_pcb->m_library->m_vias.size() == 0 );
1556 m_pcb->m_library->AppendVia(
via );
1562 for(
const auto& [
name, netclass] : netclassesInUse )
1564 via =
makeVia( netclass->GetViaDiameter(), netclass->GetViaDrill(),
1578 std::string netname;
1582 int old_netcode = -1;
1588 if( !track->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
1591 int netcode = track->GetNetCode();
1596 if( old_netcode != netcode
1597 || old_width != track->GetWidth()
1598 || old_layer != track->GetLayer()
1599 || (
path &&
path->points.back() !=
mapPt( track->GetStart() ) ) )
1601 old_width = track->GetWidth();
1602 old_layer = track->GetLayer();
1604 if( old_netcode != netcode )
1606 old_netcode = netcode;
1614 wiring->
wires.push_back( wire );
1617 if( track->IsLocked() )
1628 path->aperture_width =
scale( old_width );
1629 path->AppendPoint(
mapPt( track->GetStart() ) );
1633 path->AppendPoint(
mapPt( track->GetEnd() ) );
1646 int netcode =
via->GetNetCode();
1661 m_pcb->m_wiring->wire_vias.push_back( dsnVia );
1671 if(
via->IsLocked() )
1686 VIA* vias =
m_pcb->m_structure->m_via;
1688 for(
unsigned viaNdx = 0; viaNdx <
m_pcb->m_library->m_vias.size(); ++viaNdx )
1689 vias->
AppendVia(
m_pcb->m_library->m_vias[viaNdx].m_padstack_id.c_str() );
1695 exportNETCLASS( netSettings->GetDefaultNetclass().get(), aBoard );
1697 for(
const auto& [
name, netclass] : netclassesInUse )
1736 m_pcb->m_network->m_classes.push_back( clazz );
1742 if( net->GetNetClass()->GetName() == clazz->
m_class_id )
1750 std::snprintf(
text,
sizeof(
text ),
"(width %.6g)",
scale( trackWidth ) );
1770 snprintf(
text,
sizeof(
text ),
"(use_via \"%s\")",
via->GetPadstackId().c_str() );
1784 footprint->SetFlag( 0 );
1786 if( footprint->GetLayer() ==
B_Cu )
1789 footprint->SetFlag( 1 );
1807 if( footprint->GetFlag() )
1810 footprint->SetFlag( 0 );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Handles how to draw a screen (a board, a schematic ...)
bool IsContentModified() const
void SetContentModified(bool aModified=true)
std::shared_ptr< NET_SETTINGS > m_NetSettings
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
const ZONES & Zones() const
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
int GetCopperLayerCount() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, bool aInferOutlineIfNecessary, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
int GetCount() const
Return the number of objects in the list.
The <class_descriptor> in the specctra spec.
STRINGS m_circuit
circuit descriptor list
Implement a <component_descriptor> in the specctra dsn spec.
A <plane_descriptor> in the specctra dsn spec.
Used for <keepout_descriptor> and <plane_descriptor>.
void AddWindow(WINDOW *aWindow)
void SetShape(ELEM *aShape)
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
A <net_descriptor> in the DSN spec.
Hold either a via or a pad definition.
std::string m_padstack_id
void SetPadstackId(const char *aPadstackId)
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
void SetLayerId(const std::string &aLayerId)
void AppendPoint(const POINT &aPoint)
Implement a <placement_reference> in the specctra dsn spec.
void SetVertex(const POINT &aVertex)
void SetRotation(double aRotation)
std::string m_part_number
std::string m_component_id
reference designator
void SetLayerId(std::string &aLayerId)
void SetCorners(const POINT &aPoint0, const POINT &aPoint1)
STRINGS m_rules
rules are saved in std::string form.
A "(shape ..)" element in the specctra dsn spec.
A DSN data tree, usually coming from a DSN file.
int m_top_via_layer
specctra cu layers, 0 based index:
IMAGE * makeIMAGE(BOARD *aBoard, FOOTPRINT *aFootprint)
Allocates an I#MAGE on the heap and creates all the PINs according to the PADs in the FOOTPRINT.
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
std::map< int, PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
SHAPE_POLY_SET m_brd_outlines
void FlipFOOTPRINTs(BOARD *aBoard)
Flip the footprints which are on the back side of the board to the front.
STRINGS m_layerIds
indexed by PCB layer number
bool m_footprintsAreFlipped
void deleteNETs()
Delete all the NETs that may be in here.
void fillBOUNDARY(BOARD *aBoard, BOUNDARY *aBoundary)
Make the board perimeter for the DSN file by filling the BOUNDARY element in the specctra element tre...
PADSTACK * makePADSTACK(BOARD *aBoard, PAD *aPad)
Create a PADSTACK which matches the given pad.
void SetPCB(PCB *aPcb)
Delete any existing PCB and replaces it with the given one.
static PCB * MakePCB()
Make a PCB with all the default ELEMs and parts on the heap.
bool BuiltBoardOutlines(BOARD *aBoard)
Build the board outlines and store it in m_brd_outlines.
void exportNETCLASS(const NETCLASS *aNetClass, const BOARD *aBoard)
Export aNetClass to the DSN file.
PADSTACK * makeVia(int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer)
Make a round through hole PADSTACK using the given KiCad diameter in deci-mils.
std::map< PCB_LAYER_ID, int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
std::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
PADSTACKSET m_padstackset
void FromBOARD(BOARD *aBoard)
Add the entire BOARD to the PCB but does not write it out.
void RevertFOOTPRINTs(BOARD *aBoard)
Flip the footprints which were on the back side of the board back to the back.
A <via_descriptor> in the specctra dsn spec.
void AppendVia(const char *aViaName)
void SetShape(ELEM *aShape)
A <wire_via_descriptor> in the specctra dsn spec.
std::string m_padstack_id
A <wire_shape_descriptor> in the specctra dsn spec.
void SetShape(ELEM *aShape)
A <wiring_descriptor> in the specctra dsn spec.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSET is a set of PCB_LAYER_IDs.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
A collection of nets and the parameters used to route or test these nets.
int GetViaDiameter() const
static const char Default[]
the name of the default NETCLASS
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
int GetTrackWidth() const
Handle the data for a net.
const wxString & GetNetname() const
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Container for NETINFO_ITEM elements, which are the nets.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void MergePrimitivesAsPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
const VECTOR2I & GetDrillSize() const
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetOffset(PCB_LAYER_ID aLayer) const
int GetChamferPositions(PCB_LAYER_ID aLayer) const
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool ExportSpecctraFile(const wxString &aFullFilename)
Export the current BOARD to a specctra dsn file.
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.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
int GetWidth() const override
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Return the 2 layers used by the via (the via actually uses all layers between these 2 layers)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
bool IsEndContour() const
Represent a set of closed polygons.
ITERATOR_TEMPLATE< VECTOR2I > ITERATOR
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const std::vector< POLYGON > & CPolygons() const
const char * c_str() const
Handle a list of polygons defining a copper zone.
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
int ConvertArcToPolyline(SHAPE_LINE_CHAIN &aPolyline, VECTOR2I aCenter, int aRadius, const EDA_ANGLE &aStartAngleDeg, const EDA_ANGLE &aArcAngleDeg, double aAccuracy, ERROR_LOC aErrorLoc)
Generate a polyline to approximate a arc.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
static bool empty(const wxTextEntryBase *aCtrl)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
static constexpr EDA_ANGLE ANGLE_180
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
a few functions useful in geometry calculations.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
This source file implements export and import capabilities to the specctra dsn file format.
std::vector< std::string > STRINGS
std::map< wxString, int > PINMAP
data type used to ensure unique-ness of pin names, holding (wxString and int)
static double mapX(int x)
static double mapY(int y)
static double IU2um(int kicadDist)
static POINT mapPt(const VECTOR2I &pt)
Convert a KiCad point into a DSN file point.
static bool isRoundKeepout(PAD *aPad)
Decide if the pad is a copper-less through hole which needs to be made into a round keepout.
std::set< std::string > STRINGSET
static double scale(int kicadDist)
Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating point fo...
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
static PATH * makePath(const POINT &aStart, const POINT &aEnd, const std::string &aLayerName)
Create a PATH element with a single straight line, a pair of vertices.
std::pair< STRINGSET::iterator, bool > STRINGSET_PAIR
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ NET
This item represents a net.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
A <pin_reference> definition in the specctra dsn spec.
A point in the SPECCTRA DSN coordinate system.
void FixNegativeZero()
Change negative zero to positive zero in the IEEE floating point storage format.
A storage class for 128-bit hash value.
std::string ToString() const
const SHAPE_LINE_CHAIN chain
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
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.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< int32_t > VECTOR2I