50#include <backend/zint.h> 
   87    m_text.SetText( aNewText );
 
 
   99    return m_text.GetShownText( 
true );
 
 
  106    m_text.SetLayer( aLayer );
 
 
  114    m_text.SetTextSize( 
VECTOR2I( std::max( 1, aTextSize ), std::max( 1, aTextSize ) ) );
 
 
  123    return m_text.GetTextHeight();
 
 
  178    m_poly.RemoveAllContours();
 
  191        int tenPercent = ( minSide + 9 ) / 10; 
 
  192        int step01mm = std::max( 1, 
pcbIUScale.mmToIU( 0.1 ) );
 
  193        int tenPercentRounded = ( ( tenPercent + step01mm - 1 ) / step01mm ) * step01mm;
 
  219    m_poly.CacheTriangulation( 
false );
 
 
  247    textPoly.
Move( textPos );
 
 
  258    std::unique_ptr<zint_symbol, 
decltype( &ZBarcode_Delete )> symbol( ZBarcode_Create(), &ZBarcode_Delete );
 
  262        wxLogError( wxT( 
"Zint: failed to allocate symbol" ) );
 
  266    symbol->input_mode = UNICODE_MODE;
 
  267    symbol->show_hrt = 0; 
 
  272        symbol->symbology = BARCODE_CODE39;
 
  275        symbol->symbology = BARCODE_CODE128;
 
  278        symbol->symbology = BARCODE_QRCODE;
 
  282        symbol->symbology = BARCODE_MICROQR;
 
  286        symbol->symbology = BARCODE_DATAMATRIX;
 
  289        wxLogError( wxT( 
"Zint: invalid barcode type" ) );
 
  294    wxScopedCharBuffer utf8Text = 
text.ToUTF8();
 
  295    size_t length = utf8Text.length();
 
  296    unsigned char* dataPtr = 
reinterpret_cast<unsigned char*
>( utf8Text.data() );
 
  301    if( ZBarcode_Encode( symbol.get(), dataPtr, length ) )
 
  303        wxLogDebug( wxT( 
"Zint encode error: %s" ), wxString::FromUTF8( symbol->errtxt ) );
 
  307    if( ZBarcode_Buffer_Vector( symbol.get(), 0 ) ) 
 
  309        wxLogDebug( wxT( 
"Zint render error: %s" ), wxString::FromUTF8( symbol->errtxt ) );
 
  313    for( zint_vector_rect* rect = symbol->vector->rectangles; rect != 
nullptr; rect = rect->next )
 
  316        int x1 = 
KiROUND( rect->x * symbol->scale );
 
  317        int x2 = 
KiROUND( ( rect->x + rect->width ) * symbol->scale );
 
  318        int y1 = 
KiROUND( rect->y * symbol->scale );
 
  319        int y2 = 
KiROUND( ( rect->y + rect->height ) * symbol->scale );
 
  322        shapeline.
Append( x1, y1 );
 
  323        shapeline.
Append( x2, y1 );
 
  324        shapeline.
Append( x2, y2 );
 
  325        shapeline.
Append( x1, y2 );
 
  331    for( zint_vector_hexagon* hex = symbol->vector->hexagons; hex != 
nullptr; hex = hex->next )
 
  334        double r  = hex->diameter / 2.0; 
 
  339        double baseAngles[6] = { 90.0, 30.0, -30.0, -90.0, -150.0, 150.0 };
 
  340        double rot = 
static_cast<double>( hex->rotation );
 
  344        for( 
int k = 0; k < 6; ++k )
 
  346            double ang = ( baseAngles[k] + rot ) * 
M_PI / 180.0;
 
  347            int vx = 
KiROUND( cx + r * cos( ang ) );
 
  348            int vy = 
KiROUND( cy + r * sin( ang ) );
 
 
  372        aList.emplace_back( 
_( 
"Footprint" ), parentFP->
GetReference() );
 
  380        aList.emplace_back( 
_( 
"Status" ), 
_( 
"Locked" ) );
 
  384    aList.emplace_back( 
_( 
"Angle" ), wxString::Format( wxT( 
"%g" ), 
m_angle.AsDegrees() ) );
 
 
  399    return hulls.
Collide( aPosition );
 
 
  427    VECTOR2I newPosition = ( aTopLeft + aBotRight ) / 2;
 
  429    int newW = aBotRight.
x - aTopLeft.
x;
 
  430    int newH = aBotRight.
y - aTopLeft.
y;
 
  432    int minIU = std::max( 1, 
pcbIUScale.mmToIU( 0.01 ) );
 
  433    newW = std::max( newW, minIU );
 
  434    newH = std::max( newH, minIU );
 
  436    double scaleX = oldW ? 
static_cast<double>( newW ) / oldW : 1.0;
 
  437    double scaleY = oldH ? 
static_cast<double>( newH ) / oldH : 1.0;
 
 
  480                                           int aClearance, 
int aMaxError,
 
  481                                           ERROR_LOC aErrorLoc, 
bool ignoreLineWidth )
 const 
  486    if( aClearance == 0 )
 
 
  504    return std::make_shared<SHAPE_POLY_SET>( std::move( poly ) );
 
 
  509                                   int aMaxError, 
ERROR_LOC aErrorLoc )
 const 
  511    auto getBoundingHull =
 
  514                BOX2I    rect = aSource.BBox( aLocClearance );
 
  519                corners[1].
y = corners[0].
y;
 
  521                corners[2].
x = corners[1].
x;
 
  523                corners[3].
y = corners[2].
y;
 
  524                corners[3].
x = corners[0].
x;
 
  531                    aLocBuffer.
Append( corner.x, corner.y );
 
  538        getBoundingHull( aBuffer, 
m_textPoly, aClearance );
 
 
  614                 wxT( 
"Cannot swap data with non-barcode item." ) );
 
  618    std::swap( *
this, *other );
 
 
  632    double similarity = 0.0;
 
  633    const double weight = 1.0 / 6.0;
 
  636        similarity += weight;
 
  638        similarity += weight;
 
  640        similarity += weight;
 
  642        similarity += weight;
 
  644        similarity += weight;
 
  646        similarity += weight;
 
 
  661    if( ( diff = aBarcode->
GetText().Cmp( aOther->
GetText() ) ) != 0 )
 
  673    if( ( diff = (
int) aBarcode->
GetKind() - (
int) aOther->
GetKind() ) != 0 )
 
 
  708        const wxString groupBarcode = 
_HKI( 
"Barcode Properties" );
 
  711        if( kindMap.
Choices().GetCount() == 0 )
 
  722        if( eccMap.
Choices().GetCount() == 0 )
 
  735                        return bc->IsKnockout();
 
 
 
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
 
constexpr EDA_IU_SCALE pcbIUScale
 
constexpr int ARC_LOW_DEF
 
BITMAPS
A list of all bitmap identifiers.
 
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
 
Container for design settings for a BOARD object.
 
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
 
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
 
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
 
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
 
bool IsLocked() const override
 
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
 
FOOTPRINT * GetParentFootprint() const
 
virtual void CopyFrom(const BOARD_ITEM *aOther)
 
bool IsSideSpecific() const
 
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
 
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
 
constexpr size_type GetWidth() const
 
constexpr const Vec GetCenter() const
 
constexpr size_type GetHeight() const
 
constexpr coord_type GetLeft() const
 
constexpr bool Contains(const Vec &aPoint) const
 
constexpr const Vec & GetOrigin() const
 
constexpr coord_type GetRight() const
 
constexpr coord_type GetTop() const
 
constexpr bool Intersects(const BOX2< Vec > &aRect) const
 
constexpr coord_type GetBottom() const
 
The base class for create windows for drawing purpose.
 
KICAD_T Type() const
Returns the type of object.
 
virtual void SetParent(EDA_ITEM *aParent)
 
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
 
ENUM_MAP & Map(T aValue, const wxString &aName)
 
static ENUM_MAP< T > & Instance()
 
ENUM_MAP & Undefined(T aValue)
 
Class that other classes need to inherit from, in order to be inspectable.
 
void SetKind(BARCODE_T aKind)
 
void SetTextSize(int aTextSize)
Change the height of the human-readable text displayed below the barcode.
 
void ComputeTextPoly()
Generate the internal polygon representation for the human-readable text.
 
double GetOrientation() const
 
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
 
~PCB_BARCODE()
Destructor.
 
VECTOR2I m_pos
Position of the barcode.
 
const BOX2I GetBoundingBox() const override
Get the axis-aligned bounding box of the barcode including text.
 
void SetBarcodeErrorCorrection(BARCODE_ECC_T aErrorCorrection)
 
void SetRect(const VECTOR2I &aTopLeft, const VECTOR2I &aBotRight)
Set the bounding rectangle of the barcode.
 
virtual const BOX2I ViewBBox() const override
Get the bbox used for drawing/view culling, may include additional view-only extents.
 
SHAPE_POLY_SET m_textPoly
Human-readable text only (cached, centered/positioned)
 
EDA_ITEM * Clone() const override
Create a copy of this item.
 
void SetErrorCorrection(BARCODE_ECC_T aErrorCorrection)
Set the error correction level used for QR codes.
 
void SetBarcodeHeight(int aHeight)
 
void SetShowText(bool aShow)
 
SHAPE_POLY_SET m_poly
Full geometry (barcode + optional text or knockout)
 
SHAPE_POLY_SET m_symbolPoly
Barcode symbol only (cached, centered at origin)
 
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings, bool aCheckSide) override
 
void SetBarcodeText(const wxString &aText)
 
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Produce a short human-readable description of the item for UI lists.
 
void SetBarcodeKind(BARCODE_T aKind)
 
void GetBoundingHull(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
 
void AssembleBarcode()
Assemble the barcode polygon and text polygons into a single polygonal representation.
 
VECTOR2I GetPosition() const override
Get the position (center) of the barcode in internal units.
 
void SetPosition(const VECTOR2I &aPos) override
 
void SetOrientation(double aDegrees)
 
double Similarity(const BOARD_ITEM &aItem) const override
Compute a simple similarity score between this barcode and another board item.
 
int m_height
Barcode height.
 
void SetLayer(PCB_LAYER_ID aLayer) override
Set the drawing layer for the barcode and its text.
 
bool operator==(const BOARD_ITEM &aItem) const override
Equality comparison operator for board-level deduplication.
 
VECTOR2I m_margin
Margin around the barcode (only valid for knockout)
 
BOX2I m_bbox
BBox of m_poly (ie: barcode + text)
 
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate message panel information entries (e.g.
 
void SetBarcodeWidth(int aWidth)
 
bool IsKnockout() const override
 
int GetHeight() const
Get the barcode height (in internal units).
 
BITMAPS GetMenuImage() const override
Icon to show in context menus/toolbars for this item type.
 
wxString GetShownText() const
 
BARCODE_ECC_T m_errorCorrection
Error correction level for QR codes.
 
void SetIsKnockout(bool aEnable) override
 
static bool ClassOf(const EDA_ITEM *aItem)
Type-check helper.
 
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Hit-test a point against the barcode (text and symbol area).
 
PCB_BARCODE(BOARD_ITEM *aParent)
Construct a PCB_BARCODE.
 
int m_width
Barcode width.
 
void swapData(BOARD_ITEM *aImage) override
 
BARCODE_ECC_T GetErrorCorrection() const
 
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate the barcode around a given centre by the given angle.
 
static int Compare(const PCB_BARCODE *aBarcode, const PCB_BARCODE *aOther)
 
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 barcode (text + symbol shapes) to polygonal geometry suitable for filling/collision tests...
 
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipLeftRight) override
Flip the barcode horizontally or vertically around a centre point.
 
void ComputeBarcode()
Generate the internal polygon representation for the current barcode text, kind and error correction.
 
BARCODE_T GetKind() const
Returns the type of the barcode (QR, CODE_39, etc.).
 
int GetWidth() const
Get the barcode width (in internal units).
 
void SetText(const wxString &aText)
Set the barcode content text to encode.
 
void Move(const VECTOR2I &offset) override
Function Move.
 
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
 
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
 
Provide class metadata.Helper macro to map type hashes to names.
 
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
 
static PROPERTY_MANAGER & Instance()
 
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
 
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
 
Represent a set of closed polygons.
 
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
 
void Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
 
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
 
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
 
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.
 
int OutlineCount() const
Return the number of outlines in the set.
 
void Move(const VECTOR2I &aVector) override
 
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
 
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
 
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
 
@ CHAMFER_ACUTE_CORNERS
Acute angles are chamfered.
 
static constexpr EDA_ANGLE ANGLE_180
 
#define PCB_EDIT_FRAME_NAME
 
int GetPenSizeForNormal(int aTextSize)
 
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
 
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
 
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
 
PCB_LAYER_ID
A quick note on layer IDs:
 
This file contains miscellaneous commonly used macros and functions.
 
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
 
@ LEFT_RIGHT
Flip left to right (around the Y axis)
 
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
 
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
 
static struct PCB_BARCODE_DESC _PCB_BARCODE_DESC
 
BARCODE class definition.
 
#define IMPLEMENT_ENUM_TO_WXANY(type)
 
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
 
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.
 
constexpr auto to_underlying(E e) noexcept
 
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
 
VECTOR2< int32_t > VECTOR2I