70#define EXPORT_CUSTOM_PADS_CONVEX_HULL
89 errorText = ioe.
What();
98 SetStatusText( wxString(
_(
"BOARD exported OK." ) ) );
119 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
150static inline double scale(
int kicadDist )
158static inline double IU2um(
int kicadDist )
164static inline double mapX(
int x )
170static inline double mapY(
int y )
197 return mapPt( fpRelative );
206 if( aPad->
GetShape() == PAD_SHAPE::CIRCLE )
226 path->AppendPoint( aStart );
227 path->AppendPoint( aEnd );
228 path->SetLayerId( aLayerName.c_str() );
241 std::string uniqifier;
248 int reportedLayers = 0;
255 bool onAllCopperLayers = ( (aPad->
GetLayerSet() & all_cu) == all_cu );
257 if( onAllCopperLayers )
262 for(
int layer=0; layer<copperCount; ++layer )
266 if( onAllCopperLayers || aPad->
IsOnLayer( kilayer ) )
268 layerName[reportedLayers++] =
m_layerIds[layer].c_str();
270 if( !onAllCopperLayers )
274 else if( layer == copperCount - 1 )
277 uniqifier += char(
'0' + layer);
290 dsnOffset =
mapPt( offset );
292 std::ostringstream oss;
293 oss.imbue( std::locale::classic() );
294 oss << std::fixed << std::setprecision( 6 )
295 <<
'[' << dsnOffset.
x <<
',' << dsnOffset.
y <<
']';
296 uniqifier += oss.str();
301 case PAD_SHAPE::CIRCLE:
305 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
309 padstack->
Append( shape );
320 std::ostringstream oss;
321 oss <<
"Round" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
328 case PAD_SHAPE::RECTANGLE:
333 POINT lowerLeft( -dx, -dy );
334 POINT upperRight( dx, dy );
336 lowerLeft += dsnOffset;
337 upperRight += dsnOffset;
339 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
343 padstack->
Append( shape );
353 std::ostringstream oss;
354 oss <<
"Rect" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
361 case PAD_SHAPE::OVAL:
374 pstart =
POINT( -dr, 0.0 );
375 pstop =
POINT( dr, 0.0 );
382 pstart =
POINT( 0.0, -dr );
383 pstop =
POINT( 0.0, dr );
389 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
395 shape =
new SHAPE( padstack );
397 padstack->
Append( shape );
400 path->aperture_width = 2.0 * radius;
403 std::ostringstream oss;
404 oss <<
"Oval" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
411 case PAD_SHAPE::TRAPEZOID:
420 POINT lowerLeft( -dx - ddy, -dy - ddx );
421 POINT upperLeft( -dx + ddy, +dy + ddx );
422 POINT upperRight( +dx - ddy, +dy - ddx );
423 POINT lowerRight( +dx + ddy, -dy + ddx );
425 lowerLeft += dsnOffset;
426 upperLeft += dsnOffset;
427 upperRight += dsnOffset;
428 lowerRight += dsnOffset;
430 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
434 padstack->
Append( shape );
437 PATH* polygon =
new PATH( shape, T_polygon );
450 std::ostringstream oss;
451 oss <<
"Trapz" << uniqifier <<
"Pad_" << std::fixed << std::setprecision(6)
460 case PAD_SHAPE::CHAMFERED_RECT:
461 case PAD_SHAPE::ROUNDRECT:
464 const int circleToSegmentsCount = 36;
476 double correctionFactor = cos( M_PI / (
double) circleToSegmentsCount );
477 int extra_clearance =
KiROUND( rradius * ( 1.0 - correctionFactor ) );
479 psize.
x += extra_clearance * 2;
480 psize.
y += extra_clearance * 2;
481 rradius += extra_clearance;
482 bool doChamfer = aPad->
GetShape() == PAD_SHAPE::CHAMFERED_RECT;
492 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
496 padstack->
Append( shape );
499 PATH* polygon =
new PATH( shape, T_polygon );
508 for(
int idx = 0; idx < polygonal_shape.
PointCount(); idx++ )
516 first_corner = corner;
523 std::ostringstream oss;
524 oss <<
"RoundRect" << uniqifier <<
"Pad_"
525 << std::fixed << std::setprecision(6)
528 <<
IU2um( rradius ) <<
"_um_"
530 << std::hex << std::uppercase
537 case PAD_SHAPE::CUSTOM:
539 std::vector<VECTOR2I> polygonal_shape;
543#ifdef EXPORT_CUSTOM_PADS_CONVEX_HULL
548 for(
int ii = 0; ii < p_outline.
PointCount(); ++ii )
549 polygonal_shape.push_back( wxPoint( p_outline.
CPoint( ii ) ) );
553 if( polygonal_shape.front() != polygonal_shape.back() )
554 polygonal_shape.push_back( polygonal_shape.front() );
556 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
560 padstack->
Append( shape );
563 PATH* polygon =
new PATH( shape, T_polygon );
569 for(
unsigned idx = 0; idx < polygonal_shape.size(); idx++ )
571 POINT corner(
scale( polygonal_shape[idx].x ),
scale( -polygonal_shape[idx].y ) );
581 std::ostringstream oss;
582 oss <<
"Cust" << uniqifier <<
"Pad_"
583 << std::fixed << std::setprecision(6)
586 << polygonal_shape.size() <<
"_um_"
617 for(
int p = 0; p < fpItems.
GetCount(); ++p )
624 double diameter =
scale(
pad->GetDrillSize().x );
631 for(
int layer=0; layer<layerCount; ++layer )
635 image->m_keepouts.push_back( keepout );
652 if( !mask_copper_layers.
any() )
656 PADSTACKSET::iterator iter =
m_padstackset.find( *padstack );
662 padstack = (
PADSTACK*) *iter.base();
671 padNumber =
pad->GetNumber();
674 if( padNumber != wxEmptyString && pinmap.find( padNumber ) == pinmap.end() )
676 pinmap[ padNumber ] = 0;
680 int duplicates = ++pinmap[ padNumber ];
683 "@" + std::to_string( duplicates );
686 pin->m_kiNetCode =
pad->GetNetCode();
704 for(
int i = 0; i < fpItems.
GetCount(); ++i )
712 case SHAPE_T::SEGMENT:
715 image->Append( outline );
720 path->SetLayerId(
"signal" );
725 case SHAPE_T::CIRCLE:
730 image->Append( outline );
736 path->SetLayerId(
"signal" );
745 for(
int ii = 0; ii < polyline.
PointCount(); ++ii )
748 path->AppendPoint(
mapPt( corner, aFootprint ) );
754 case SHAPE_T::RECTANGLE:
758 image->Append( outline );
763 path->SetLayerId(
"signal" );
765 path->AppendPoint(
mapPt( corner, aFootprint ) );
768 path->AppendPoint(
mapPt( corner, aFootprint ) );
771 path->AppendPoint(
mapPt( corner, aFootprint ) );
774 path->AppendPoint(
mapPt( corner, aFootprint ) );
785 image->Append( outline );
789 path->SetAperture( 0 );
790 path->SetLayerId(
"signal" );
810 arcAngle = -arcAngle;
829 for(
int ii = polyline.
PointCount() - 1; ii >= 0; --ii )
847 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
850 path->AppendPoint(
mapPt( corner, aFootprint ) );
863 if( !zone->GetIsRuleArea() )
867 ZONE untransformedZone( *zone );
879 if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
880 keepout_type = T_keepout;
881 else if( zone->GetDoNotAllowVias() )
882 keepout_type = T_via_keepout;
883 else if( zone->GetDoNotAllowTracks() )
884 keepout_type = T_wire_keepout;
886 keepout_type = T_keepout;
892 for(
int layer = 0; layer < copperCount; layer++ )
894 if( layer == copperCount-1 )
901 image->m_keepouts.push_back( keepout );
903 PATH* mainPolygon =
new PATH( keepout, T_polygon );
910 bool is_first_point =
true;
913 for( iterator = untransformedZone.
IterateWithHoles(); iterator; iterator++ )
915 VECTOR2I point( iterator->x, iterator->y );
922 is_first_point =
false;
936 PATH* cutout =
nullptr;
937 bool isStartContour =
true;
940 for( iterator++; iterator; iterator++ )
944 is_first_point =
true;
945 window =
new WINDOW( keepout );
948 cutout =
new PATH( window, T_polygon );
960 VECTOR2I point( iterator->x, iterator->y );
967 is_first_point =
false;
984 int aTopLayer,
int aBotLayer )
988 double dsnDiameter =
scale( aCopperDiameter );
990 for(
int layer=aTopLayer; layer<=aBotLayer; ++layer )
994 padstack->
Append( shape );
1004 snprintf(
name,
sizeof(
name ),
"Via[%d-%d]_%.6g:%.6g_um",
1005 aTopLayer, aBotLayer, dsnDiameter,
1007 IU2um( aDrillDiameter ) );
1021 aVia->
LayerPair( &topLayerNum, &botLayerNum );
1026 if( topLayer > botLayer )
1027 std::swap( topLayer, botLayer );
1039 path->layer_id =
"pcb";
1043 for(
int ii = 0; ii < outline.
PointCount(); ii++ )
1058 PATH* poly_ko =
new PATH(
nullptr, T_polygon );
1066 for(
int jj = 0; jj < hole.
PointCount(); jj++ )
1095 if( footprint->GetReference() == wxEmptyString )
1097 THROW_IO_ERROR( wxString::Format(
_(
"Footprint with value of '%s' has an empty "
1098 "reference designator." ),
1099 footprint->GetValue() ) );
1105 if( !refpair.second )
1107 THROW_IO_ERROR( wxString::Format(
_(
"Multiple footprints have the reference "
1108 "designator '%s'." ),
1109 footprint->GetReference() ) );
1126 for(
int pcbNdx=0; pcbNdx<layerCount; ++pcbNdx )
1139 case LT_SIGNAL: layerType = T_signal;
break;
1140 case LT_POWER: layerType = T_power;
break;
1144 case LT_MIXED: layerType = T_signal;
break;
1145 case LT_JUMPER: layerType = T_jumper;
break;
1152 property->name =
"index";
1153 property->value = std::to_string( pcbNdx );
1183 int defaultTrackWidth = netSettings->GetDefaultNetclass()->GetTrackWidth();
1184 int defaultClearance = netSettings->GetDefaultNetclass()->GetClearance();
1185 double clearance =
scale( defaultClearance );
1189 std::snprintf( rule,
sizeof( rule ),
"(width %.6g)",
scale( defaultTrackWidth ) );
1190 rules.push_back( rule );
1192 std::snprintf( rule,
sizeof( rule ),
"(clearance %.6g)", clearance );
1193 rules.push_back( rule );
1201 double default_smd = clearance;
1203 if( default_smd <= 6.0 )
1206 std::snprintf( rule,
sizeof( rule ),
"(clearance %.6g (type default_smd))", default_smd );
1208 rules.push_back( rule );
1213 clearance =
scale( defaultClearance ) / 4;
1215 std::snprintf( rule,
sizeof( rule ),
"(clearance %.6g (type smd_smd))", clearance );
1216 rules.push_back( rule );
1222 int netlessZones = 0;
1226 if( zone->GetIsRuleArea() )
1230 if( ! zone->IsOnCopperLayer() )
1237 for(
int layer = 0; layer < copperCount; layer++ )
1239 if( layer == copperCount-1 )
1249 PATH* mainPolygon =
new PATH( plane, T_polygon );
1254 if( plane->
m_name.size() == 0 )
1261 no_net->
m_net_id =
"@:no_net_" + std::to_string( netlessZones++ );
1275 bool is_first_point =
true;
1277 for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
1279 VECTOR2I point( iterator->x, iterator->y );
1281 if( is_first_point )
1284 is_first_point =
false;
1298 WINDOW* window =
nullptr;
1299 PATH* cutout =
nullptr;
1301 bool isStartContour =
true;
1304 for( iterator++; iterator; iterator++ )
1306 if( isStartContour )
1308 is_first_point =
true;
1309 window =
new WINDOW( plane );
1312 cutout =
new PATH( window, T_polygon );
1324 VECTOR2I point( iterator->x, iterator->y );
1326 if( is_first_point )
1329 is_first_point =
false;
1346 if( !zone->GetIsRuleArea() )
1354 if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
1355 keepout_type = T_keepout;
1356 else if( zone->GetDoNotAllowVias() )
1357 keepout_type = T_via_keepout;
1358 else if( zone->GetDoNotAllowTracks() )
1359 keepout_type = T_wire_keepout;
1361 keepout_type = T_keepout;
1367 for(
int layer = 0; layer < copperCount; layer++ )
1369 if( layer == copperCount - 1 )
1378 PATH* mainPolygon =
new PATH( keepout, T_polygon );
1385 bool is_first_point =
true;
1388 for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
1390 VECTOR2I point( iterator->x, iterator->y );
1392 if( is_first_point )
1395 is_first_point =
false;
1408 WINDOW* window =
nullptr;
1409 PATH* cutout =
nullptr;
1411 bool isStartContour =
true;
1414 for( iterator++; iterator; iterator++ )
1416 if( isStartContour )
1418 is_first_point =
true;
1419 window =
new WINDOW( keepout );
1422 cutout =
new PATH( window, T_polygon );
1432 VECTOR2I point( iterator->x, iterator->y );
1434 if( is_first_point )
1437 is_first_point =
false;
1453 std::string componentId;
1454 int highestNetCode = 0;
1459 highestNetCode = std::max( highestNetCode, i->GetNetCode() );
1464 m_nets.resize( highestNetCode + 1,
nullptr );
1466 for(
unsigned i = 1 ; i <
m_nets.size(); ++i )
1471 if( i->GetNetCode() > 0 )
1472 m_nets[i->GetNetCode()]->m_net_id =
TO_UTF8( i->GetNetname() );
1481 componentId =
TO_UTF8( footprint->GetReference() );
1489 for(
unsigned p = 0; p <
image->m_pins.size(); ++p )
1492 int netcode =
pin->m_kiNetCode;
1522 place->
SetRotation( footprint->GetOrientationDegrees() );
1528 if( footprint->GetFlag() )
1549 for(
unsigned n = 1; n <
m_nets.size(); ++n )
1588 for(
const auto& [
name, netclass] : netSettings->GetNetclasses() )
1590 via =
makeVia( netclass->GetViaDiameter(), netclass->GetViaDrill(),
1604 std::string netname;
1608 int old_netcode = -1;
1614 if( !track->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
1617 int netcode = track->GetNetCode();
1622 if( old_netcode != netcode
1623 || old_width != track->GetWidth()
1624 || old_layer != track->GetLayer()
1625 || (
path &&
path->points.back() !=
mapPt( track->GetStart() ) ) )
1627 old_width = track->GetWidth();
1628 old_layer = track->GetLayer();
1630 if( old_netcode != netcode )
1632 old_netcode = netcode;
1640 wiring->
wires.push_back( wire );
1643 if( track->IsLocked() )
1648 int kiLayer = track->GetLayer();
1654 path->aperture_width =
scale( old_width );
1655 path->AppendPoint(
mapPt( track->GetStart() ) );
1659 path->AppendPoint(
mapPt( track->GetEnd() ) );
1672 int netcode =
via->GetNetCode();
1697 if(
via->IsLocked() )
1722 for(
const auto& [
name, netclass] : netSettings->GetNetclasses() )
1769 if( net->GetNetClass()->GetVariableSubstitutionName() == clazz->
m_class_id )
1776 int trackWidth = aNetClass->GetTrackWidth();
1777 std::snprintf(
text,
sizeof(
text ),
"(width %.6g)",
scale( trackWidth ) );
1781 int clearance = aNetClass->GetClearance();
1782 std::snprintf(
text,
sizeof(
text ),
"(clearance %.6g)",
scale( clearance ) );
1795 snprintf(
text,
sizeof(
text),
"(use_via %s)",
via->GetPadstackId().c_str() );
1809 footprint->SetFlag( 0 );
1811 if( footprint->GetLayer() ==
B_Cu )
1813 footprint->Flip( footprint->GetPosition(),
false );
1814 footprint->SetFlag( 1 );
1832 if( footprint->GetFlag() )
1834 footprint->Flip( footprint->GetPosition(),
false );
1835 footprint->SetFlag( 0 );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
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.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, 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...
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
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
size_type GetHeight() const
size_type GetWidth() const
int GetCount() const
Return the number of objects in the list.
void SetLayerId(const char *aLayerId)
void SetVertex(const POINT &aVertex)
void SetDiameter(double aDiameter)
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
PADSTACK * LookupVia(PADSTACK *aVia)
Add the via only if one exactly like it does not already exist in the padstack container.
void AppendVia(PADSTACK *aVia)
Add aVia to the internal via container.
IMAGE * LookupIMAGE(IMAGE *aImage)
Add the image only if one exactly like it does not already exist in the image container.
void AddPadstack(PADSTACK *aPadstack)
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)
bool space_in_quoted_tokens
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
void SetLayerId(const char *aLayerId)
void AppendPoint(const POINT &aPoint)
COMPONENT * LookupCOMPONENT(const std::string &imageName)
Look up a COMPONENT by name.
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 SetCorners(const POINT &aPoint0, const POINT &aPoint1)
void SetLayerId(const char *aLayerId)
A <rule_descriptor> in the specctra dsn spec.
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...
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.
std::vector< PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
bool BuiltBoardOutlines(BOARD *aBoard)
Build the board outlines and store it in m_brd_outlines.
std::vector< int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
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::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
PADSTACKSET m_padstackset
void exportNETCLASS(const std::shared_ptr< NETCLASS > &aNetClass, BOARD *aBoard)
Export aNetClass to the DSN file.
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.
void SetBOUNDARY(BOUNDARY *aBoundary)
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.
EDA_ANGLE GetArcAngle() const
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.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const char Default[]
the name of the default NETCLASS
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.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
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
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
int GetRoundRectCornerRadius() const
const VECTOR2I & GetOffset() const
const VECTOR2I & GetDelta() const
PAD_SHAPE GetShape() const
int GetChamferPositions() const
const VECTOR2I & GetSize() const
double GetChamferRectRatio() 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.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetWidth() const override
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.
void Clear()
Remove all points from the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
bool IsEndContour() const
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
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 OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) 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 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 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
a few functions useful in geometry calculations.
#define THROW_IO_ERROR(msg)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
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
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)
#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
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
constexpr ret_type KiROUND(fp_type v, bool aQuiet=false)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< int32_t > VECTOR2I