57 const VECTOR2I& aCenter, uint64_t aWidth,
91 int stroke_width = aShape.
GetWidth();
127 if( stroke_width > 0 )
131 for(
size_t ii = 0; ii < corners.size(); ++ii )
132 AddFeatureLine( corners[ii], corners[( ii + 1 ) % corners.size()], stroke_width );
140 int soldermask_min_thickness = 0;
145 soldermask_min_thickness = stroke_width;
147 int maxError =
m_board->GetDesignSettings().m_MaxError;
150 if( soldermask_min_thickness == 0 )
165 poly_set.
Deflate( soldermask_min_thickness / 2 - 1,
179 if( stroke_width != 0 )
181 for(
int jj = 0; jj < poly_set.
COutline( ii ).SegmentCount(); ++jj )
193 for(
int jj = 0; jj < poly_set.
COutline( ii ).SegmentCount(); ++jj )
216 for(
size_t i = 0; i < points.size() - 1; i++ )
228 int maxError =
m_board->GetDesignSettings().m_MaxError;
234 chain.SetClosed(
true );
246 if( stroke_width > 0 )
248 for(
int ii = 0; ii <
chain.SegmentCount(); ++ii )
250 const SEG& seg =
chain.CSegment( ii );
260 int maxError =
m_board->GetDesignSettings().m_MaxError;
267 for(
int ii = 0; ii <
chain.SegmentCount(); ++ii )
269 const SEG& seg =
chain.CSegment( ii );
277 wxLogError( wxT(
"Unknown shape when adding ODB++ layer feature" ) );
283 for(
int ii = 0; ii < aShape.
GetHatching().OutlineCount(); ++ii )
307 int maxError =
m_board->GetDesignSettings().m_MaxError;
317 int mask_clearance = expansion.
x;
339 if( mask_clearance > 0 )
371 int shorterSide = std::min( plotSize.
x, plotSize.
y );
425 default: wxLogError( wxT(
"Unknown pad type" ) );
break;
438 wxLogError( wxT(
"Failed to get subnet track data" ) );
442 auto subnet = iter->second;
447 shape.
SetStart( track->GetStart() );
448 shape.
SetEnd( track->GetEnd() );
449 shape.
SetWidth( track->GetWidth() );
452 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER,
m_layerName,
464 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER,
m_layerName,
487 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::HOLE,
m_layerName,
498 ODB_ATTR::GEOMETRY{
"VIA_RoundD" + std::to_string( via->GetWidth( aLayer ) ) } );
505 subnet->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER,
m_layerName,
513 ODB_ATTR::GEOMETRY{
"VIA_RoundD" + std::to_string( via->GetWidth( aLayer ) ) } );
531 wxLogError( wxT(
"Failed to get subnet plane data" ) );
535 iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER,
m_layerName,
548 text_item =
static_cast<EDA_TEXT*
>( tmp_text );
550 text_item =
static_cast<EDA_TEXT*
>( tmp_textbox );
555 auto plot_text = [&](
const VECTOR2I& aPos,
const wxString& aTextString,
564 if( penWidth == 0 && attributes.
m_Bold )
569 penWidth = -penWidth;
573 std::list<VECTOR2I> pts;
575 auto push_pts = [&]()
587 shape.
SetEnd( pts.back() );
592 ODB_ATTR::STRING{ aTextString.ToStdString() } );
596 for(
auto it = pts.begin(); std::next( it ) != pts.end(); ++it )
598 auto it2 = std::next( it );
608 ODB_ATTR::STRING{ aTextString.ToStdString() } );
623 if( aPt1 == pts.back() )
624 pts.push_back( aPt2 );
625 else if( aPt2 == pts.front() )
626 pts.push_front( aPt1 );
627 else if( aPt1 == pts.front() )
628 pts.push_front( aPt2 );
629 else if( aPt2 == pts.back() )
630 pts.push_back( aPt1 );
634 pts.push_back( aPt1 );
635 pts.push_back( aPt2 );
640 pts.push_back( aPt1 );
641 pts.push_back( aPt2 );
647 if( aPoly.PointCount() < 3 )
660 ODB_ATTR::STRING{ aTextString.ToStdString() } );
665 aFont->Draw( &callback_gal, aTextString, aPos, aAttributes, aFontMetrics );
671 bool isKnockout =
false;
674 isKnockout =
static_cast<PCB_TEXT*
>( item )->IsKnockout();
676 isKnockout =
static_cast<PCB_TEXTBOX*
>( item )->IsKnockout();
682 if( shownText.IsEmpty() )
697 text->TransformTextToPolySet( finalpolyset, 0,
m_board->GetDesignSettings().m_MaxError,
701 for(
int ii = 0; ii < finalpolyset.
OutlineCount(); ++ii )
708 ODB_ATTR::STRING{ shownText.ToStdString() } );
714 std::vector<VECTOR2I> positions;
715 wxArrayString strings_list;
717 positions.reserve( strings_list.Count() );
721 for(
unsigned ii = 0; ii < strings_list.Count(); ii++ )
723 wxString& txt = strings_list.Item( ii );
724 plot_text( positions[ii], txt, attrs, font, fontMetrics );
729 plot_text( pos, shownText, attrs, font, fontMetrics );
740 auto add_pad = [&](
PAD*
pad )
746 wxLogError( wxT(
"Failed to get subnet top data" ) );
756 iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER,
m_layerName,
773 if(
pad->GetDrillSizeX() ==
pad->GetDrillSizeY() )
787 iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::HOLE,
m_layerName,
806 switch( item->Type() )
811 add_track(
static_cast<PCB_TRACK*
>( item ) );
819 add_pad(
static_cast<PAD*
>( item ) );
823 add_shape(
static_cast<PCB_SHAPE*
>( item ) );
834 if(
static_cast<PCB_TEXTBOX*
>( item )->IsBorderEnabled() )
906 ost <<
"#\n#Num Features\n#" << std::endl;
912 ost <<
"#\n#Layer features\n#" << std::endl;
916 feat->WriteFeatures( ost );
924 ost <<
"#\n#Num Features\n#" << std::endl;
930 ost <<
"#\n#Feature symbol names\n#" << std::endl;
934 ost <<
"$" << n <<
" " <<
name << std::endl;
939 ost <<
"#\n#Layer features\n#" << std::endl;
943 feat->WriteFeatures( ost );
1008 if( !aPolygon.empty() && aPolygon[0].PointCount() >= 3 )
1010 m_surfaces = std::make_unique<ODB_SURFACE_DATA>( aPolygon );
1011 if( aFillType != FILL_T::NO_FILL )
1013 m_surfaces->AddPolygonHoles( aPolygon );
1035 const std::vector<VECTOR2I>& pts = aPolygon[0].CPoints();
1044 m_polygons.at( 0 ).emplace_back( pts.back() );
1046 for(
size_t jj = 0; jj < pts.size(); ++jj )
1048 m_polygons.at( 0 ).emplace_back( pts.at( jj ) );
1056 for(
size_t ii = 1; ii < aPolygon.size(); ++ii )
1058 wxCHECK2( aPolygon[ii].PointCount() >= 3,
continue );
1060 const std::vector<VECTOR2I>& hole = aPolygon[ii].CPoints();
1072 m_polygons.at( ii ).emplace_back( hole.back() );
1074 for(
size_t jj = 0; jj < hole.size(); ++jj )
1076 m_polygons.at( ii ).emplace_back( hole[jj] );
1088 if( contour.empty() )
1091 ost <<
"OB " <<
ODB::AddXY( contour.back().m_end ).first <<
" "
1092 <<
ODB::AddXY( contour.back().m_end ).second <<
" ";
1100 for(
const auto& line : contour )
1103 ost <<
"OS " <<
ODB::AddXY( line.m_end ).first <<
" "
1104 <<
ODB::AddXY( line.m_end ).second << std::endl;
1106 ost <<
"OC " <<
ODB::AddXY( line.m_end ).first <<
" "
1108 <<
" " <<
ODB::AddXY( line.m_center ).second <<
" "
1111 ost <<
"OE" << std::endl;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void WriteAttributes(std::ostream &ost, const std::string &prefix="") const
void AddSystemAttribute(Tr &r, Ta v)
void WriteAttributes(std::ostream &ost) const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
FOOTPRINT * GetParentFootprint() const
int GetEllipseMinorRadius() const
const VECTOR2I & GetEllipseCenter() const
const SHAPE_POLY_SET & GetHatching() const
EDA_ANGLE GetEllipseEndAngle() const
int GetEllipseMajorRadius() const
int GetRectangleWidth() const
SHAPE_POLY_SET & GetPolyShape()
EDA_ANGLE GetEllipseRotation() const
bool IsHatchedFill() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
std::vector< VECTOR2I > GetRectCorners() const
EDA_ANGLE GetEllipseStartAngle() const
const std::vector< VECTOR2I > & GetBezierPoints() const
void SetEnd(const VECTOR2I &aEnd)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
int GetRectangleHeight() const
bool IsClockwiseArc() const
void SetWidth(int aWidth)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const VECTOR2I & GetTextPos() const
bool IsMultilineAllowed() const
virtual bool IsVisible() const
virtual EDA_ANGLE GetDrawRotation() const
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
const TEXT_ATTRIBUTES & GetAttributes() const
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
void GetLinePositions(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
void AddPadShape(const PAD &aPad, PCB_LAYER_ID aLayer)
void AddShape(const PCB_SHAPE &aShape, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
uint32_t AddRectSymbol(const wxString &aWidth, const wxString &aHeight)
void AddVia(const PCB_VIA *aVia, PCB_LAYER_ID aLayer)
PCB_IO_ODBPP * GetODBPlugin()
void InitFeatureList(PCB_LAYER_ID aLayer, std::vector< BOARD_ITEM * > &aItems)
void AddFeatureLine(const VECTOR2I &aStart, const VECTOR2I &aEnd, uint64_t aWidth)
void AddFeatureArc(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, uint64_t aWidth, ODB_DIRECTION aDirection)
std::map< uint32_t, wxString > m_allSymMap
void GenerateFeatureFile(std::ostream &ost) const
void AddViaDrillHole(const PCB_VIA *aVia, PCB_LAYER_ID aLayer)
void AddPadCircle(const VECTOR2I &aCenter, uint64_t aDiameter, const EDA_ANGLE &aAngle, bool aMirror, double aResize=1.0)
void AddFeatureSurface(const SHAPE_POLY_SET::POLYGON &aPolygon, FILL_T aFillType=FILL_T::FILLED_SHAPE)
uint32_t AddRoundRectSymbol(const wxString &aWidth, const wxString &aHeight, const wxString &aRadius)
uint32_t AddOvalSymbol(const wxString &aWidth, const wxString &aHeight)
void GenerateProfileFeatures(std::ostream &ost) const
std::list< std::unique_ptr< ODB_FEATURE > > m_featuresList
void AddFeature(Args &&... args)
uint32_t AddCircleSymbol(const wxString &aDiameter)
uint32_t AddChamferRectSymbol(const wxString &aWidth, const wxString &aHeight, const wxString &aRadius, int aPositions)
uint32_t AddRoundDonutSymbol(const wxString &aOuterDim, const wxString &aInnerDim)
bool AddContour(const SHAPE_POLY_SET &aPolySet, int aOutline=0, FILL_T aFillType=FILL_T::FILLED_SHAPE)
FONT is an abstract base class for both outline and stroke fonts.
LSET is a set of PCB_LAYER_IDs.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
std::pair< wxString, wxString > m_end
std::pair< wxString, wxString > m_start
virtual void WriteRecordContent(std::ostream &ost) override
ODB_DIRECTION m_direction
std::pair< wxString, wxString > m_center
virtual void WriteRecordContent(std::ostream &ost)=0
virtual void WriteFeatures(std::ostream &ost)
virtual FEATURE_TYPE GetFeatureType()=0
ODB_FEATURE(uint32_t aIndex)
virtual void WriteRecordContent(std::ostream &ost) override
std::pair< wxString, wxString > m_start
std::pair< wxString, wxString > m_end
virtual void WriteRecordContent(std::ostream &ost) override
std::pair< wxString, wxString > m_center
void WriteData(std::ostream &ost) const
std::vector< std::vector< SURFACE_LINE > > m_polygons
ODB_SURFACE_DATA(const SHAPE_POLY_SET::POLYGON &aPolygon)
void AddPolygonHoles(const SHAPE_POLY_SET::POLYGON &aPolygon)
std::unique_ptr< ODB_SURFACE_DATA > m_surfaces
virtual void WriteRecordContent(std::ostream &ost) override
ODB_SURFACE(uint32_t aIndex, const SHAPE_POLY_SET::POLYGON &aPolygon, FILL_T aFillType=FILL_T::FILLED_SHAPE)
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
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
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
int GetChamferPositions(PCB_LAYER_ID aLayer) const
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetMid() const
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > & GetPlaneSubnetMap()
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > & GetViaTraceSubnetMap()
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > & GetPadSubnetMap()
static std::string m_unitsStr
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int GetWidth() const override
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
virtual int GetWidth() const
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
const PADSTACK & Padstack() const
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
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.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
int OutlineCount() const
Return the number of outlines in the set.
void InflateWithLinkedHoles(int aFactor, CORNER_STRATEGY aCornerStrategy, int aMaxError)
Perform outline inflation/deflation, using round corners.
void Move(const VECTOR2I &aVector) override
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
SHAPE_POLY_SET CloneDropTriangulation() const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Simple container to manage line stroke parameters.
Handle a list of polygons defining a copper zone.
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
@ ROUND_ALL_CORNERS
All angles are rounded.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
@ FILLED_SHAPE
Fill with object color.
int GetPenSizeForBold(int aTextSize)
PCB_LAYER_ID
A quick note on layer IDs:
std::pair< wxString, wxString > AddXY(const VECTOR2I &aVec)
wxString Double2String(double aVal)
wxString SymDouble2String(double aVal)
VECTOR2I GetShapePosition(const PCB_SHAPE &aShape)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ PTH
Plated through hole pad.
std::vector< FAB_LAYER_COLOR > dummy
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
std::vector< std::vector< std::string > > table
const SHAPE_LINE_CHAIN chain
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I