Browse Source

Barcode knockout for zone filler.

Also adds GetMsgPanelInfo() implementation for barcodes.
pull/19/head
Jeff Young 3 months ago
parent
commit
1447f249bf
  1. 74
      pcbnew/pcb_barcode.cpp
  2. 11
      pcbnew/pcb_barcode.h
  3. 8
      pcbnew/zone_filler.cpp

74
pcbnew/pcb_barcode.cpp

@ -337,10 +337,15 @@ void PCB_BARCODE::ComputeBarcode()
symbol->input_mode = UNICODE_MODE; symbol->input_mode = UNICODE_MODE;
symbol->show_hrt = 0; // do not show HRT symbol->show_hrt = 0; // do not show HRT
switch( m_kind ) switch( m_kind )
{ {
case BARCODE_T::CODE_39: symbol->symbology = BARCODE_CODE39; break;
case BARCODE_T::CODE_128: symbol->symbology = BARCODE_CODE128; break;
case BARCODE_T::CODE_39:
symbol->symbology = BARCODE_CODE39;
break;
case BARCODE_T::CODE_128:
symbol->symbology = BARCODE_CODE128;
break;
case BARCODE_T::QR_CODE: case BARCODE_T::QR_CODE:
symbol->symbology = BARCODE_QRCODE; symbol->symbology = BARCODE_QRCODE;
symbol->option_1 = to_underlying( m_errorCorrection ); symbol->option_1 = to_underlying( m_errorCorrection );
@ -349,8 +354,12 @@ void PCB_BARCODE::ComputeBarcode()
symbol->symbology = BARCODE_MICROQR; symbol->symbology = BARCODE_MICROQR;
symbol->option_1 = to_underlying( m_errorCorrection ); symbol->option_1 = to_underlying( m_errorCorrection );
break; break;
case BARCODE_T::DATA_MATRIX: symbol->symbology = BARCODE_DATAMATRIX; break;
default: wxLogError( wxT( "Zint: invalid barcode type" ) ); return;
case BARCODE_T::DATA_MATRIX:
symbol->symbology = BARCODE_DATAMATRIX;
break;
default:
wxLogError( wxT( "Zint: invalid barcode type" ) );
return;
} }
wxString text = GetText(); wxString text = GetText();
@ -426,11 +435,26 @@ void PCB_BARCODE::ComputeBarcode()
} }
// see class_cotation.h
void PCB_BARCODE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void PCB_BARCODE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
// for now, display only the text within the BARCODE using class TEXTE_PCB.
m_text.GetMsgPanelInfo( aFrame, aList );
FOOTPRINT* parentFP = GetParentFootprint();
if( parentFP && aFrame->GetName() == PCB_EDIT_FRAME_NAME )
aList.emplace_back( _( "Footprint" ), parentFP->GetReference() );
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Barcode" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
aList.emplace_back( _( "Type" ), ENUM_MAP<BARCODE_T>::Instance().ToString( m_kind ) );
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
aList.emplace_back( _( "Status" ), _( "Locked" ) );
aList.emplace_back( _( "Layer" ), GetLayerName() );
aList.emplace_back( _( "Angle" ), wxString::Format( wxT( "%g" ), m_angle.AsDegrees() ) );
aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( m_text.GetTextHeight() ) );
} }
@ -566,6 +590,42 @@ std::shared_ptr<SHAPE> PCB_BARCODE::GetEffectiveShape( PCB_LAYER_ID aLayer, FLAS
} }
void PCB_BARCODE::GetBoundingHull( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aMaxError, ERROR_LOC aErrorLoc )
{
auto getBoundingHull =
[&]( const SHAPE_POLY_SET& aSource )
{
SHAPE_POLY_SET poly( aSource );
poly.Rotate( -m_angle, m_poly.BBox().GetCenter() );
BOX2I rect = poly.BBox( aClearance );
VECTOR2I corners[4];
corners[0].x = rect.GetOrigin().x;
corners[0].y = rect.GetOrigin().y;
corners[1].y = corners[0].y;
corners[1].x = rect.GetRight();
corners[2].x = corners[1].x;
corners[2].y = rect.GetBottom();
corners[3].y = corners[2].y;
corners[3].x = corners[0].x;
aBuffer.NewOutline();
for( VECTOR2I& corner : corners )
{
RotatePoint( corner, m_poly.BBox().GetCenter(), m_angle );
aBuffer.Append( corner.x, corner.y );
}
};
getBoundingHull( m_symbolPoly );
getBoundingHull( m_textPoly );
}
void PCB_BARCODE::SetErrorCorrection( BARCODE_ECC_T aErrorCorrection ) void PCB_BARCODE::SetErrorCorrection( BARCODE_ECC_T aErrorCorrection )
{ {
// Micro QR codes do not support High (H) error correction level // Micro QR codes do not support High (H) error correction level

11
pcbnew/pcb_barcode.h

@ -172,9 +172,15 @@ public:
// @copydoc BOARD_ITEM::GetEffectiveShape // @copydoc BOARD_ITEM::GetEffectiveShape
virtual std::shared_ptr<SHAPE>
GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
FLASHING aFlash = FLASHING::DEFAULT ) const override; FLASHING aFlash = FLASHING::DEFAULT ) const override;
/*
* Add two rectangular polygons separately bounding the barcode's symbol and the barcode's text.
*/
void GetBoundingHull( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
int aMaxError, ERROR_LOC aErrorLoc = ERROR_INSIDE );
/** /**
* Generate the internal polygon representation for the current barcode text, kind and error correction. * Generate the internal polygon representation for the current barcode text, kind and error correction.
* *
@ -412,7 +418,6 @@ public:
AssembleBarcode(); AssembleBarcode();
} }
private: private:
int m_width; ///< Barcode width int m_width; ///< Barcode width
int m_height; ///< Barcode height int m_height; ///< Barcode height

8
pcbnew/zone_filler.cpp

@ -52,6 +52,7 @@
#include "zone_filler.h" #include "zone_filler.h"
#include "project.h" #include "project.h"
#include "project/project_local_settings.h" #include "project/project_local_settings.h"
#include "pcb_barcode.h"
// Helper classes for connect_nearby_polys // Helper classes for connect_nearby_polys
class RESULTS class RESULTS
@ -1045,6 +1046,13 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap,
aIgnoreLineWidth ); aIgnoreLineWidth );
break; break;
case PCB_BARCODE_T:
{
PCB_BARCODE* barcode = static_cast<PCB_BARCODE*>( aItem );
barcode->GetBoundingHull( aHoles, aLayer, aGap, m_maxError, ERROR_OUTSIDE );
break;
}
case PCB_DIM_ALIGNED_T: case PCB_DIM_ALIGNED_T:
case PCB_DIM_LEADER_T: case PCB_DIM_LEADER_T:
case PCB_DIM_CENTER_T: case PCB_DIM_CENTER_T:

Loading…
Cancel
Save