diff --git a/api/proto/common/types/enums.proto b/api/proto/common/types/enums.proto index e4cd74fcaf..a140cad1f4 100644 --- a/api/proto/common/types/enums.proto +++ b/api/proto/common/types/enums.proto @@ -86,6 +86,7 @@ enum KiCadObjectType KOT_WSG_PAGE = 50; KOT_SCH_GROUP = 51; + KOT_PCB_BARCODE = 52; } // Mapped to GR_TEXT_H_ALIGN_T diff --git a/common/api/api_enums.cpp b/common/api/api_enums.cpp index df55cb0869..4b28f9cdaf 100644 --- a/common/api/api_enums.cpp +++ b/common/api/api_enums.cpp @@ -99,6 +99,7 @@ types::KiCadObjectType ToProtoEnum( KICAD_T aValue ) case PCB_FOOTPRINT_T: return types::KiCadObjectType::KOT_PCB_FOOTPRINT; case PCB_PAD_T: return types::KiCadObjectType::KOT_PCB_PAD; case PCB_SHAPE_T: return types::KiCadObjectType::KOT_PCB_SHAPE; + case PCB_BARCODE_T: return types::KiCadObjectType::KOT_PCB_BARCODE; case PCB_REFERENCE_IMAGE_T: return types::KiCadObjectType::KOT_PCB_REFERENCE_IMAGE; case PCB_FIELD_T: return types::KiCadObjectType::KOT_PCB_FIELD; case PCB_GENERATOR_T: return types::KiCadObjectType::KOT_PCB_GENERATOR; diff --git a/common/api/api_utils.cpp b/common/api/api_utils.cpp index b182ca2d6d..572a6fc9b8 100644 --- a/common/api/api_utils.cpp +++ b/common/api/api_utils.cpp @@ -39,6 +39,7 @@ KICOMMON_API std::optional TypeNameFromAny( const google::protobuf::Any { "type.googleapis.com/kiapi.board.types.BoardText", PCB_TEXT_T }, { "type.googleapis.com/kiapi.board.types.BoardTextBox", PCB_TEXTBOX_T }, { "type.googleapis.com/kiapi.board.types.BoardGraphicShape", PCB_SHAPE_T }, + { "type.googleapis.com/kiapi.board.types.Barcode", PCB_BARCODE_T }, { "type.googleapis.com/kiapi.board.types.Pad", PCB_PAD_T }, { "type.googleapis.com/kiapi.board.types.Zone", PCB_ZONE_T }, { "type.googleapis.com/kiapi.board.types.Dimension", PCB_DIMENSION_T }, diff --git a/common/hash_eda.cpp b/common/hash_eda.cpp index d0b52f237a..a7c9bcb128 100644 --- a/common/hash_eda.cpp +++ b/common/hash_eda.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -214,8 +215,25 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags ) if( aFlags & HASH_ROT ) hash_combine( ret, text->GetTextAngle().AsDegrees() ); - } + break; + } + + case PCB_BARCODE_T: + { + const PCB_BARCODE* barcode = static_cast( aItem ); + + ret = hash_board_item( barcode, aFlags ); + hash_combine( ret, barcode->GetWidth(), barcode->GetHeight() ); + hash_combine( ret, barcode->GetPosition().x, barcode->GetPosition().y ); + hash_combine( ret, barcode->GetMargin().x, barcode->GetMargin().y ); + hash_combine( ret, barcode->Text().GetText().ToStdString() ); + hash_combine( ret, barcode->Text().GetTextHeight() ); + hash_combine( ret, barcode->GetKind() ); + hash_combine( ret, barcode->GetAngle().AsDegrees() ); + hash_combine( ret, barcode->GetErrorCorrection() ); + break; + } case PCB_SHAPE_T: { diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 41b4c50ef8..e0f15d2891 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -779,6 +779,8 @@ public: bool m_StyleFPFields; bool m_StyleFPText; bool m_StyleFPShapes; + bool m_StyleFPDimensions; + bool m_StyleFPBarcodes; // Miscellaneous std::unique_ptr m_Pad_Master; // A dummy pad to store all default parameters diff --git a/include/board_item.h b/include/board_item.h index a82b8d44d9..b409b232b8 100644 --- a/include/board_item.h +++ b/include/board_item.h @@ -324,7 +324,7 @@ public: int GetMaxError() const; - virtual void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) { } + virtual void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) { } /** * Delete this object after removing from its parent if it has one. diff --git a/pcbnew/api/api_handler_pcb.cpp b/pcbnew/api/api_handler_pcb.cpp index 3e0a957e67..584ebb9789 100644 --- a/pcbnew/api/api_handler_pcb.cpp +++ b/pcbnew/api/api_handler_pcb.cpp @@ -519,8 +519,7 @@ HANDLER_RESULT API_HANDLER_PCB::handleCreateUpdateItemsIntern } -HANDLER_RESULT API_HANDLER_PCB::handleGetItems( - const HANDLER_CONTEXT& aCtx ) +HANDLER_RESULT API_HANDLER_PCB::handleGetItems( const HANDLER_CONTEXT& aCtx ) { if( std::optional busy = checkForBusy() ) return tl::unexpected( *busy ); @@ -592,6 +591,7 @@ HANDLER_RESULT API_HANDLER_PCB::handleGetItems( case PCB_SHAPE_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: + case PCB_BARCODE_T: { handledAnything = true; bool inserted = false; @@ -606,7 +606,7 @@ HANDLER_RESULT API_HANDLER_PCB::handleGetItems( } if( inserted ) - typesInserted.insert( PCB_SHAPE_T ); + typesInserted.insert( type ); break; } diff --git a/pcbnew/api/api_pcb_utils.cpp b/pcbnew/api/api_pcb_utils.cpp index 18c89e3d88..6cb797b186 100644 --- a/pcbnew/api/api_pcb_utils.cpp +++ b/pcbnew/api/api_pcb_utils.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ std::unique_ptr CreateItemForType( KICAD_T aType, BOARD_ITEM_CONTAIN case PCB_TEXT_T: return std::make_unique( aContainer ); case PCB_TEXTBOX_T: return std::make_unique( aContainer ); case PCB_SHAPE_T: return std::make_unique( aContainer ); + case PCB_BARCODE_T: return std::make_unique( aContainer ); case PCB_ZONE_T: return std::make_unique( aContainer ); case PCB_GROUP_T: return std::make_unique( aContainer ); case PCB_REFERENCE_IMAGE_T: return std::make_unique( aContainer ); diff --git a/pcbnew/autorouter/ar_autoplacer.cpp b/pcbnew/autorouter/ar_autoplacer.cpp index 469e89ed81..287f00046f 100644 --- a/pcbnew/autorouter/ar_autoplacer.cpp +++ b/pcbnew/autorouter/ar_autoplacer.cpp @@ -117,8 +117,8 @@ int AR_AUTOPLACER::genPlacementRoutingMatrix() case PCB_SHAPE_T: if( drawing->GetLayer() != Edge_Cuts ) { - m_matrix.TraceSegmentPcb( (PCB_SHAPE*) drawing, CELL_IS_HOLE | CELL_IS_EDGE, - m_matrix.m_GridRouting, AR_MATRIX::WRITE_CELL ); + m_matrix.TracePcbShape( (PCB_SHAPE*) drawing, CELL_IS_HOLE | CELL_IS_EDGE, + m_matrix.m_GridRouting, AR_MATRIX::WRITE_CELL ); } break; @@ -130,8 +130,10 @@ int AR_AUTOPLACER::genPlacementRoutingMatrix() // Initialize top layer. to the same value as the bottom layer if( m_matrix.m_BoardSide[AR_SIDE_TOP] ) + { memcpy( m_matrix.m_BoardSide[AR_SIDE_TOP], m_matrix.m_BoardSide[AR_SIDE_BOTTOM], nbCells * sizeof(AR_MATRIX::MATRIX_CELL) ); + } return 1; } diff --git a/pcbnew/autorouter/ar_matrix.cpp b/pcbnew/autorouter/ar_matrix.cpp index db2d6c8590..f3449885b7 100644 --- a/pcbnew/autorouter/ar_matrix.cpp +++ b/pcbnew/autorouter/ar_matrix.cpp @@ -758,8 +758,7 @@ void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, const } -void AR_MATRIX::TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin, - AR_MATRIX::CELL_OP op_logic ) +void AR_MATRIX::TracePcbShape( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic ) { int half_width = ( aShape->GetWidth() / 2 ) + aMargin; diff --git a/pcbnew/autorouter/ar_matrix.h b/pcbnew/autorouter/ar_matrix.h index 19dd5fbded..d5b8945627 100644 --- a/pcbnew/autorouter/ar_matrix.h +++ b/pcbnew/autorouter/ar_matrix.h @@ -109,7 +109,7 @@ public: DIST_CELL GetDist( int aRow, int aCol, int aSide ); void SetDist( int aRow, int aCol, int aSide, DIST_CELL ); - void TraceSegmentPcb( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic ); + void TracePcbShape( PCB_SHAPE* aShape, int aColor, int aMargin, AR_MATRIX::CELL_OP op_logic ); void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int marge, int aKeepOut, const LSET& aLayerMask ); diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index ce663634e6..86be02028b 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -1204,7 +1205,6 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity break; - case PCB_TRACE_T: case PCB_ARC_T: if( !IsCopperLayer( aBoardItem->GetLayer() ) ) @@ -1513,6 +1513,7 @@ void BOARD::RemoveAll( std::initializer_list aTypes ) case PCB_TEXTBOX_T: case PCB_TABLE_T: case PCB_TARGET_T: + case PCB_BARCODE_T: wxFAIL_MSG( wxT( "Use PCB_SHAPE_T to remove all graphics and text" ) ); break; @@ -2161,6 +2162,7 @@ INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: case PCB_TARGET_T: + case PCB_BARCODE_T: if( !footprintsScanned ) { if( IterateForward( m_footprints, inspector, testData, scanTypes ) @@ -3181,6 +3183,13 @@ bool BOARD::cmp_drawings::operator()( const BOARD_ITEM* aFirst, return PCB_TABLE::Compare( table, other ); } + else if( aFirst->Type() == PCB_BARCODE_T ) + { + const PCB_BARCODE* barcode = static_cast( aFirst ); + const PCB_BARCODE* other = static_cast( aSecond ); + + return PCB_BARCODE::Compare( barcode, other ); + } return aFirst->m_Uuid < aSecond->m_Uuid; } @@ -3239,6 +3248,13 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, break; } + case PCB_BARCODE_T: + { + const PCB_BARCODE* barcode = static_cast( item ); + barcode->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); + break; + } + case PCB_FIELD_T: case PCB_TEXT_T: { @@ -3250,10 +3266,8 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, case PCB_TEXTBOX_T: { const PCB_TEXTBOX* textbox = static_cast( item ); - // border - textbox->PCB_SHAPE::TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, - ERROR_INSIDE ); + textbox->PCB_SHAPE::TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); // text textbox->TransformTextToPolySet( aOutlines, 0, maxError, ERROR_INSIDE ); break; @@ -3262,7 +3276,6 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, case PCB_TABLE_T: { const PCB_TABLE* table = static_cast( item ); - table->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); break; } @@ -3274,7 +3287,6 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, case PCB_DIM_LEADER_T: { const PCB_DIMENSION_BASE* dim = static_cast( item ); - dim->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError, ERROR_INSIDE ); dim->TransformTextToPolySet( aOutlines, 0, maxError, ERROR_INSIDE ); break; diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index b6b2b7b630..3c3e3d2495 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -124,6 +124,8 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: m_StyleFPFields = false; m_StyleFPText = false; m_StyleFPShapes = false; + m_StyleFPDimensions = false; + m_StyleFPBarcodes = false; m_DimensionPrecision = DIM_PRECISION::X_XXXX; m_DimensionUnitsMode = DIM_UNITS_MODE::AUTOMATIC; @@ -856,6 +858,10 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std: &m_StyleFPText, false ) ); m_params.emplace_back( new PARAM( "defaults.apply_defaults_to_fp_shapes", &m_StyleFPShapes, false ) ); + m_params.emplace_back( new PARAM( "defaults.apply_defaults_to_fp_dimensions", + &m_StyleFPDimensions, false ) ); + m_params.emplace_back( new PARAM( "defaults.apply_defaults_to_fp_barcodes", + &m_StyleFPBarcodes, false ) ); m_params.emplace_back( new PARAM_SCALED( "defaults.zones.min_clearance", &m_defaultZoneSettings.m_ZoneClearance, pcbIUScale.mmToIU( ZONE_CLEARANCE_MM ), @@ -1059,6 +1065,8 @@ void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther ) m_StyleFPFields = aOther.m_StyleFPFields; m_StyleFPText = aOther.m_StyleFPText; m_StyleFPShapes = aOther.m_StyleFPShapes; + m_StyleFPDimensions = aOther.m_StyleFPDimensions; + m_StyleFPBarcodes = aOther.m_StyleFPBarcodes; } @@ -1158,9 +1166,11 @@ bool BOARD_DESIGN_SETTINGS::operator==( const BOARD_DESIGN_SETTINGS& aOther ) co if( *m_Pad_Master != *aOther.m_Pad_Master ) return false; if( m_defaultZoneSettings != aOther.m_defaultZoneSettings ) return false; - if( m_StyleFPFields != aOther.m_StyleFPFields ) return false; - if( m_StyleFPText != aOther.m_StyleFPText ) return false; - if( m_StyleFPShapes != aOther.m_StyleFPShapes ) return false; + if( m_StyleFPFields != aOther.m_StyleFPFields ) return false; + if( m_StyleFPText != aOther.m_StyleFPText ) return false; + if( m_StyleFPShapes != aOther.m_StyleFPShapes ) return false; + if( m_StyleFPDimensions != aOther.m_StyleFPDimensions ) return false; + if( m_StyleFPBarcodes != aOther.m_StyleFPBarcodes ) return false; return true; } diff --git a/pcbnew/board_item.cpp b/pcbnew/board_item.cpp index 134f0f43ae..813118323d 100644 --- a/pcbnew/board_item.cpp +++ b/pcbnew/board_item.cpp @@ -62,6 +62,7 @@ bool BOARD_ITEM::IsGroupableType() const case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_ZONE_T: + case PCB_BARCODE_T: return true; default: return false; diff --git a/pcbnew/dialogs/dialog_filter_selection.cpp b/pcbnew/dialogs/dialog_filter_selection.cpp index e21d0dee0d..79e314f32d 100644 --- a/pcbnew/dialogs/dialog_filter_selection.cpp +++ b/pcbnew/dialogs/dialog_filter_selection.cpp @@ -51,8 +51,8 @@ void DIALOG_FILTER_SELECTION::checkBoxClicked( wxCommandEvent& aEvent ) bool DIALOG_FILTER_SELECTION::TransferDataToWindow() { - m_Include_Modules->SetValue( m_options.includeModules ); - m_IncludeLockedModules->SetValue( m_options.includeLockedModules ); + m_Include_Modules->SetValue( m_options.includeFootprints ); + m_IncludeLockedModules->SetValue( m_options.includeLockedFootprints ); if( m_Include_Modules->GetValue() ) m_IncludeLockedModules->Enable(); @@ -164,8 +164,8 @@ bool DIALOG_FILTER_SELECTION::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; - m_options.includeModules = m_Include_Modules->GetValue(); - m_options.includeLockedModules = m_IncludeLockedModules->GetValue(); + m_options.includeFootprints = m_Include_Modules->GetValue(); + m_options.includeLockedFootprints = m_IncludeLockedModules->GetValue(); m_options.includeTracks = m_Include_Tracks->GetValue(); m_options.includeVias = m_Include_Vias->GetValue(); m_options.includeZones = m_Include_Zones->GetValue(); diff --git a/pcbnew/dialogs/dialog_filter_selection.h b/pcbnew/dialogs/dialog_filter_selection.h index 95319f0583..4dde284bee 100644 --- a/pcbnew/dialogs/dialog_filter_selection.h +++ b/pcbnew/dialogs/dialog_filter_selection.h @@ -35,8 +35,8 @@ public: */ struct OPTIONS { - bool includeModules = true; - bool includeLockedModules = true; + bool includeFootprints = true; + bool includeLockedFootprints = true; bool includeTracks = true; bool includeVias = true; bool includeZones = true; diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index da086fd3fb..7ccc145e10 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -686,7 +686,7 @@ void DIALOG_FOOTPRINT_PROPERTIES::OnAddField( wxCommandEvent& ) newField.SetVisible( false ); newField.SetLayer( m_footprint->GetLayer() == F_Cu ? F_Fab : B_Fab ); newField.SetFPRelativePosition( { 0, 0 } ); - newField.StyleFromSettings( m_frame->GetDesignSettings() ); + newField.StyleFromSettings( m_frame->GetDesignSettings(), true ); m_fields->push_back( newField ); diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index d9c5a4dc39..7be2c8bf32 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -311,6 +312,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B PCB_TEXT* text = dynamic_cast( aItem ); PCB_SHAPE* shape = dynamic_cast( aItem ); PCB_DIMENSION_BASE* dimension = dynamic_cast( aItem ); + PCB_BARCODE* barcode = dynamic_cast( aItem ); FOOTPRINT* parentFP = aItem->GetParentFootprint(); if( m_setToSpecifiedValues->GetValue() ) @@ -362,6 +364,14 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B } } + if( barcode ) + { + if( !m_textHeight.IsIndeterminate() ) + barcode->SetTextSize( m_textHeight.GetIntValue() ); + else if( !m_textWidth.IsIndeterminate() ) + barcode->SetTextSize( m_textWidth.GetIntValue() ); + } + if( field ) { if( m_visible->Get3StateValue() != wxCHK_UNDETERMINED ) @@ -384,35 +394,7 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B else { PCB_LAYER_ID layer = aItem->GetLayer(); - - if( text ) - { - text->SetTextSize( m_brdSettings->GetTextSize( layer ) ); - text->SetTextThickness( m_brdSettings->GetTextThickness( layer ) ); - text->SetItalic( m_brdSettings->GetTextItalic( layer ) ); - - if( parentFP ) - text->SetKeepUpright( m_brdSettings->GetTextUpright( layer ) ); - } - - if( shape ) - { - STROKE_PARAMS stroke = shape->GetStroke(); - stroke.SetWidth( m_brdSettings->GetLineThickness( layer ) ); - shape->SetStroke( stroke ); - } - - if( dimension ) - { - dimension->SetLineThickness( m_brdSettings->GetLineThickness( layer ) ); - dimension->SetUnitsMode( m_brdSettings->m_DimensionUnitsMode ); - dimension->SetUnitsFormat( m_brdSettings->m_DimensionUnitsFormat ); - dimension->SetPrecision( m_brdSettings->m_DimensionPrecision ); - dimension->SetSuppressZeroes( m_brdSettings->m_DimensionSuppressZeroes ); - dimension->SetTextPositionMode( m_brdSettings->m_DimensionTextPosition ); - dimension->SetKeepTextAligned( m_brdSettings->m_DimensionKeepTextAligned ); - dimension->Update(); // refresh text & geometry - } + aItem->StyleFromSettings( *m_brdSettings, false ); } } @@ -531,7 +513,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() if( m_footprintDimensions->GetValue() ) visitItem( commit, boardItem ); } - else if( itemType == PCB_SHAPE_T ) + else if( itemType == PCB_SHAPE_T || itemType == PCB_BARCODE_T ) { if( m_footprintGraphics->GetValue() ) visitItem( commit, boardItem ); @@ -556,7 +538,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() if( m_boardDimensions->GetValue() ) visitItem( commit, boardItem ); } - else if( itemType == PCB_SHAPE_T ) + else if( itemType == PCB_SHAPE_T || itemType == PCB_BARCODE_T ) { if( m_boardGraphics->GetValue() ) visitItem( commit, boardItem ); diff --git a/pcbnew/dialogs/panel_setup_formatting.cpp b/pcbnew/dialogs/panel_setup_formatting.cpp index 0b18c7cf60..f75dc3785f 100644 --- a/pcbnew/dialogs/panel_setup_formatting.cpp +++ b/pcbnew/dialogs/panel_setup_formatting.cpp @@ -57,6 +57,8 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow() m_styleFields->SetValue( bds.m_StyleFPFields ); m_styleText->SetValue( bds.m_StyleFPText ); m_styleShapes->SetValue( bds.m_StyleFPShapes ); + m_styleDimensions->SetValue( bds.m_StyleFPDimensions ); + m_styleBarcodes->SetValue( bds.m_StyleFPBarcodes ); return true; } @@ -76,6 +78,8 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() bds.m_StyleFPFields = m_styleFields->GetValue(); bds.m_StyleFPText = m_styleText->GetValue(); bds.m_StyleFPShapes = m_styleShapes->GetValue(); + bds.m_StyleFPDimensions = m_styleDimensions->GetValue(); + bds.m_StyleFPBarcodes = m_styleBarcodes->GetValue(); KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView(); @@ -107,4 +111,6 @@ void PANEL_SETUP_FORMATTING::ImportSettingsFrom( BOARD* aBoard ) m_styleFields->SetValue( aBoard->GetDesignSettings().m_StyleFPFields ); m_styleText->SetValue( aBoard->GetDesignSettings().m_StyleFPText ); m_styleShapes->SetValue( aBoard->GetDesignSettings().m_StyleFPShapes ); + m_styleDimensions->SetValue( aBoard->GetDesignSettings().m_StyleFPDimensions ); + m_styleBarcodes->SetValue( aBoard->GetDesignSettings().m_StyleFPBarcodes ); } diff --git a/pcbnew/dialogs/panel_setup_formatting_base.cpp b/pcbnew/dialogs/panel_setup_formatting_base.cpp index 3ab74e5eef..ad1136fba6 100644 --- a/pcbnew/dialogs/panel_setup_formatting_base.cpp +++ b/pcbnew/dialogs/panel_setup_formatting_base.cpp @@ -72,6 +72,12 @@ PANEL_SETUP_FORMATTING_BASE::PANEL_SETUP_FORMATTING_BASE( wxWindow* parent, wxWi m_styleShapes = new wxCheckBox( this, wxID_ANY, _("Apply board defaults to non-copper footprint shapes"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer3->Add( m_styleShapes, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_styleDimensions = new wxCheckBox( this, wxID_ANY, _("Apply board defaults to footprint dimensions"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_styleDimensions, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_styleBarcodes = new wxCheckBox( this, wxID_ANY, _("Apply board defaults to footprint barcodes"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_styleBarcodes, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bMargins->Add( bSizer3, 1, wxEXPAND|wxTOP|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/panel_setup_formatting_base.fbp b/pcbnew/dialogs/panel_setup_formatting_base.fbp index bc5d55986e..6a3347e679 100644 --- a/pcbnew/dialogs/panel_setup_formatting_base.fbp +++ b/pcbnew/dialogs/panel_setup_formatting_base.fbp @@ -859,6 +859,136 @@ + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Apply board defaults to footprint dimensions + + 0 + + + 0 + + 1 + m_styleDimensions + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Apply board defaults to footprint barcodes + + 0 + + + 0 + + 1 + m_styleBarcodes + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + diff --git a/pcbnew/dialogs/panel_setup_formatting_base.h b/pcbnew/dialogs/panel_setup_formatting_base.h index a48084aaea..ae6a527a9a 100644 --- a/pcbnew/dialogs/panel_setup_formatting_base.h +++ b/pcbnew/dialogs/panel_setup_formatting_base.h @@ -44,6 +44,8 @@ class PANEL_SETUP_FORMATTING_BASE : public wxPanel wxCheckBox* m_styleFields; wxCheckBox* m_styleText; wxCheckBox* m_styleShapes; + wxCheckBox* m_styleDimensions; + wxCheckBox* m_styleBarcodes; public: diff --git a/pcbnew/drc/drc_cache_generator.cpp b/pcbnew/drc/drc_cache_generator.cpp index f2d38f7386..1d12a92034 100644 --- a/pcbnew/drc/drc_cache_generator.cpp +++ b/pcbnew/drc/drc_cache_generator.cpp @@ -153,7 +153,8 @@ bool DRC_CACHE_GENERATOR::Run() PCB_SHAPE_T, PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TABLE_T, PCB_TABLECELL_T, - PCB_DIMENSION_T + PCB_DIMENSION_T, + PCB_BARCODE_T }; forEachGeometryItem( itemTypes, boardCopperLayers, countItems ); diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index f06a454b7a..1129267f79 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -1327,6 +1327,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO case PCB_PAD_T: mask = DRC_DISALLOW_PADS; break; case PCB_FOOTPRINT_T: mask = DRC_DISALLOW_FOOTPRINTS; break; case PCB_SHAPE_T: mask = DRC_DISALLOW_GRAPHICS; break; + case PCB_BARCODE_T: mask = DRC_DISALLOW_GRAPHICS; break; case PCB_FIELD_T: mask = DRC_DISALLOW_TEXTS; break; case PCB_TEXT_T: mask = DRC_DISALLOW_TEXTS; break; case PCB_TEXTBOX_T: mask = DRC_DISALLOW_TEXTS; break; diff --git a/pcbnew/drc/drc_test_provider_library_parity.cpp b/pcbnew/drc/drc_test_provider_library_parity.cpp index 5ac6caeb5e..32663bf407 100644 --- a/pcbnew/drc/drc_test_provider_library_parity.cpp +++ b/pcbnew/drc/drc_test_provider_library_parity.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -432,6 +433,34 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter ) } +bool barcodeNeedsUpdate( const PCB_BARCODE& curr_barcode, const PCB_BARCODE& ref_barcode ) +{ + REPORTER* aReporter = nullptr; + bool diff = false; + + TEST( curr_barcode.GetText(), ref_barcode.GetText(), + wxString::Format( _( "%s text differs." ), ITEM_DESC( &curr_barcode ) ) ); + + TEST_PT( curr_barcode.GetPosition(), ref_barcode.GetPosition(), + wxString::Format( _( "%s position differs." ), ITEM_DESC( &curr_barcode ) ) ); + + TEST( curr_barcode.GetWidth(), ref_barcode.GetWidth(), + wxString::Format( _( "%s width differs." ), ITEM_DESC( &curr_barcode ) ) ); + TEST( curr_barcode.GetHeight(), ref_barcode.GetHeight(), + wxString::Format( _( "%s height differs." ), ITEM_DESC( &curr_barcode ) ) ); + + TEST( curr_barcode.GetTextSize(), ref_barcode.GetTextSize(), + wxString::Format( _( "%s text size differs." ), ITEM_DESC( &curr_barcode ) ) ); + + TEST( (int) curr_barcode.GetKind(), (int) ref_barcode.GetKind(), + wxString::Format( _( "%s code differs." ), ITEM_DESC( &curr_barcode ) ) ); + TEST( (int) curr_barcode.GetErrorCorrection(), (int) ref_barcode.GetErrorCorrection(), + wxString::Format( _( "%s error correction level differs." ), ITEM_DESC( &curr_barcode ) ) ); + + return diff; +} + + bool shapeNeedsUpdate( const PCB_SHAPE& curr_shape, const PCB_SHAPE& ref_shape ) { // curr_shape and ref_shape are expected to be normalized, for a more reliable test. @@ -855,6 +884,46 @@ bool FOOTPRINT::FootprintNeedsUpdate( const FOOTPRINT* aLibFP, int aCompareFlags CHECKPOINT; + std::set aBarcodes; + std::copy_if( dummy.GraphicalItems().begin(), dummy.GraphicalItems().end(), + std::inserter( aBarcodes, aBarcodes.begin() ), + []( BOARD_ITEM* item ) + { + return item->Type() == PCB_BARCODE_T; + } ); + + std::set bBarcodes; + std::copy_if( aLibFP->GraphicalItems().begin(), aLibFP->GraphicalItems().end(), + std::inserter( bBarcodes, bBarcodes.begin() ), + []( BOARD_ITEM* item ) + { + return item->Type() == PCB_BARCODE_T; + } ); + + if( aBarcodes.size() != bBarcodes.size() ) + { + diff = true; + REPORT( _( "Barcode count differs." ) ); + } + else + { + for( auto aIt = aBarcodes.begin(), bIt = bBarcodes.begin(); aIt != aBarcodes.end(); aIt++, bIt++ ) + { + // aBarcodes and bBarcodes are the tested footprint PCB_BARCODE and the model PCB_BARCODE. + // These shapes are already normalized. + PCB_BARCODE* curr_barcode = static_cast( *aIt ); + PCB_BARCODE* test_barcode = static_cast( *bIt ); + + if( barcodeNeedsUpdate( *curr_barcode, *test_barcode ) ) + { + diff = true; + REPORT( wxString::Format( _( "%s differs." ), ITEM_DESC( *aIt ) ) ); + } + } + } + + CHECKPOINT; + std::set aPads( Pads().begin(), Pads().end() ); std::set bPads( aLibFP->Pads().begin(), aLibFP->Pads().end() ); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 3ebe7be87b..53d00073dc 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -150,6 +151,10 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) ShowGraphicItemPropertiesDialog( static_cast( aItem ) ); break; + case PCB_BARCODE_T: + ShowBarcodePropertiesDialog( static_cast( aItem ) ); + break; + case PCB_ZONE_T: Edit_Zone_Params( static_cast( aItem ) ); break; diff --git a/pcbnew/exporters/step/exporter_step.cpp b/pcbnew/exporters/step/exporter_step.cpp index d48bce9eea..c64ca2d0e6 100644 --- a/pcbnew/exporters/step/exporter_step.cpp +++ b/pcbnew/exporters/step/exporter_step.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -518,6 +519,7 @@ void EXPORTER_STEP::buildZones3DShape( VECTOR2D aOrigin ) bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOrigin ) { PCB_LAYER_ID pcblayer = aItem->GetLayer(); + int maxError = aItem->GetMaxError(); if( !m_layersToExport.Contains( pcblayer ) ) return false; @@ -544,8 +546,8 @@ bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOri if( lineStyle == LINE_STYLE::SOLID ) { - graphic->TransformShapeToPolySet( m_poly_shapes[pcblayer][graphic->GetNetname()], - pcblayer, 0, graphic->GetMaxError(), ERROR_INSIDE ); + graphic->TransformShapeToPolySet( m_poly_shapes[pcblayer][graphic->GetNetname()], pcblayer, 0, + maxError, ERROR_INSIDE ); } else { @@ -563,7 +565,7 @@ bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOri { SHAPE_SEGMENT seg( a, b, graphic->GetWidth() ); seg.TransformToPolygon( m_poly_shapes[pcblayer][graphic->GetNetname()], - graphic->GetMaxError(), ERROR_INSIDE ); + maxError, ERROR_INSIDE ); } ); } @@ -577,15 +579,13 @@ bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOri if( m_params.m_ExportSoldermask && graphic->IsOnLayer( F_Mask ) ) { graphic->TransformShapeToPolygon( m_poly_shapes[F_Mask][wxEmptyString], F_Mask, - graphic->GetSolderMaskExpansion(), graphic->GetMaxError(), - ERROR_INSIDE ); + graphic->GetSolderMaskExpansion(), maxError, ERROR_INSIDE ); } if( m_params.m_ExportSoldermask && graphic->IsOnLayer( B_Mask ) ) { graphic->TransformShapeToPolygon( m_poly_shapes[B_Mask][wxEmptyString], B_Mask, - graphic->GetSolderMaskExpansion(), graphic->GetMaxError(), - ERROR_INSIDE ); + graphic->GetSolderMaskExpansion(), maxError, ERROR_INSIDE ); } break; @@ -595,8 +595,16 @@ bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOri { PCB_TEXT* text = static_cast( aItem ); - text->TransformTextToPolySet( m_poly_shapes[pcblayer][wxEmptyString], 0, text->GetMaxError(), - ERROR_INSIDE ); + text->TransformTextToPolySet( m_poly_shapes[pcblayer][wxEmptyString], 0, maxError, ERROR_INSIDE ); + break; + } + + case PCB_BARCODE_T: + { + PCB_BARCODE* barcode = static_cast( aItem ); + + barcode->TransformShapeToPolySet( m_poly_shapes[pcblayer][wxEmptyString], pcblayer, 0, maxError, + ERROR_INSIDE ); break; } @@ -607,13 +615,12 @@ bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOri // border if( textbox->IsBorderEnabled() ) { - textbox->PCB_SHAPE::TransformShapeToPolygon( m_poly_shapes[pcblayer][wxEmptyString], - pcblayer, 0, textbox->GetMaxError(), ERROR_INSIDE ); + textbox->PCB_SHAPE::TransformShapeToPolygon( m_poly_shapes[pcblayer][wxEmptyString], pcblayer, 0, + maxError, ERROR_INSIDE ); } // text - textbox->TransformTextToPolySet( m_poly_shapes[pcblayer][wxEmptyString], 0, textbox->GetMaxError(), - ERROR_INSIDE ); + textbox->TransformTextToPolySet( m_poly_shapes[pcblayer][wxEmptyString], 0, maxError, ERROR_INSIDE ); break; } @@ -623,16 +630,14 @@ bool EXPORTER_STEP::buildGraphic3DShape( BOARD_ITEM* aItem, const VECTOR2D& aOri for( PCB_TABLECELL* cell : table->GetCells() ) { - cell->TransformTextToPolySet( m_poly_shapes[pcblayer][wxEmptyString], 0, cell->GetMaxError(), - ERROR_INSIDE ); + cell->TransformTextToPolySet( m_poly_shapes[pcblayer][wxEmptyString], 0, maxError, ERROR_INSIDE ); } table->DrawBorders( [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke ) { SHAPE_SEGMENT seg( ptA, ptB, stroke.GetWidth() ); - seg.TransformToPolygon( m_poly_shapes[pcblayer][wxEmptyString], table->GetMaxError(), - ERROR_INSIDE ); + seg.TransformToPolygon( m_poly_shapes[pcblayer][wxEmptyString], maxError, ERROR_INSIDE ); } ); break; diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 45b0a3594b..629ce457ce 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -691,12 +692,12 @@ int FOOTPRINT::GetNextFieldOrdinal() const void FOOTPRINT::ApplyDefaultSettings( const BOARD& board, bool aStyleFields, bool aStyleText, - bool aStyleShapes ) + bool aStyleShapes, bool aStyleDimensions, bool aStyleBarcodes ) { if( aStyleFields ) { for( PCB_FIELD* field : m_fields ) - field->StyleFromSettings( board.GetDesignSettings() ); + field->StyleFromSettings( board.GetDesignSettings(), true ); } for( BOARD_ITEM* item : m_drawings ) @@ -706,16 +707,31 @@ void FOOTPRINT::ApplyDefaultSettings( const BOARD& board, bool aStyleFields, boo case PCB_TEXT_T: case PCB_TEXTBOX_T: if( aStyleText ) - item->StyleFromSettings( board.GetDesignSettings() ); + item->StyleFromSettings( board.GetDesignSettings(), true ); break; case PCB_SHAPE_T: if( aStyleShapes && !item->IsOnCopperLayer() ) - item->StyleFromSettings( board.GetDesignSettings() ); + item->StyleFromSettings( board.GetDesignSettings(), true ); break; + case PCB_DIM_ALIGNED_T: + case PCB_DIM_LEADER_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_RADIAL_T: + case PCB_DIM_ORTHOGONAL_T: + if( aStyleDimensions ) + item->StyleFromSettings( board.GetDesignSettings(), true ); + + break; + + case PCB_BARCODE_T: + if( aStyleBarcodes ) + item->StyleFromSettings( board.GetDesignSettings(), true ); + break; + default: break; } @@ -2284,6 +2300,7 @@ INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_SHAPE_T: + case PCB_BARCODE_T: case PCB_TEXTBOX_T: case PCB_TABLE_T: case PCB_TABLECELL_T: @@ -2823,6 +2840,18 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( bool addToParentGroup, BOARD_COMMIT* aComm break; } + case PCB_BARCODE_T: + { + PCB_BARCODE* new_barcode = new PCB_BARCODE( *static_cast( aItem ) ); + const_cast( new_barcode->m_Uuid ) = KIID(); + + if( addToFootprint ) + Add( new_barcode ); + + new_item = new_barcode; + break; + } + case PCB_REFERENCE_IMAGE_T: { PCB_REFERENCE_IMAGE* new_image = new PCB_REFERENCE_IMAGE( *static_cast( aItem ) ); @@ -3102,6 +3131,7 @@ double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_SHAPE_T: + case PCB_BARCODE_T: case PCB_TRACE_T: case PCB_ARC_T: case PCB_VIA_T: @@ -3175,6 +3205,8 @@ std::shared_ptr FOOTPRINT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHI { if( item->Type() == PCB_SHAPE_T ) shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() ); + else if( item->Type() == PCB_BARCODE_T ) + shape->AddShape( item->GetEffectiveShape( aLayer, aFlash )->Clone() ); } } @@ -4230,6 +4262,14 @@ void FOOTPRINT::TransformFPShapesToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_I if( aLayer != UNDEFINED_LAYER && shape->GetLayer() == aLayer ) shape->TransformShapeToPolySet( aBuffer, aLayer, 0, aError, aErrorLoc ); } + + if( item->Type() == PCB_BARCODE_T && aIncludeShapes ) + { + const PCB_BARCODE* barcode = static_cast( item ); + + if( aLayer != UNDEFINED_LAYER && barcode->GetLayer() == aLayer ) + barcode->TransformShapeToPolySet( aBuffer, aLayer, 0, aError, aErrorLoc ); + } } if( aIncludeText ) diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h index 32085a0ce9..c6805d6505 100644 --- a/pcbnew/footprint.h +++ b/pcbnew/footprint.h @@ -748,7 +748,7 @@ public: * the correct default text properties. */ void ApplyDefaultSettings( const BOARD& board, bool aStyleFields, bool aStyleText, - bool aStyleShapes ); + bool aStyleShapes, bool aStyleDimensions, bool aStyleBarcodes ); struct FP_UNIT_INFO { diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 437789cb12..1da18564e7 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -924,7 +924,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew ) BOARD_DESIGN_SETTINGS& bds = m_pcb->GetDesignSettings(); newFootprint->ApplyDefaultSettings( *m_pcb, bds.m_StyleFPFields, bds.m_StyleFPText, - bds.m_StyleFPShapes ); + bds.m_StyleFPShapes, bds.m_StyleFPDimensions, + bds.m_StyleFPBarcodes ); if( sourceFootprint ) // this is an update command { diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index fb8277fa03..4704c587dd 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -269,7 +269,8 @@ FOOTPRINT* PCB_BASE_FRAME::loadFootprint( const LIB_ID& aFootprintId ) BOARD_DESIGN_SETTINGS& bds = m_pcb->GetDesignSettings(); footprint->ApplyDefaultSettings( *m_pcb, bds.m_StyleFPFields, bds.m_StyleFPText, - bds.m_StyleFPShapes ); + bds.m_StyleFPShapes, bds.m_StyleFPDimensions, + bds.m_StyleFPBarcodes ); } } diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index a066434449..9bfdd6ac97 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -567,7 +567,7 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint, newField->Rotate( aPcbFootprint->GetPosition(), aPcbFootprint->GetOrientation() ); if( m_frame ) - newField->StyleFromSettings( m_frame->GetDesignSettings() ); + newField->StyleFromSettings( m_frame->GetDesignSettings(), true ); } } } diff --git a/pcbnew/pcb_barcode.cpp b/pcbnew/pcb_barcode.cpp index c2dec351f8..6cb1020b8c 100644 --- a/pcbnew/pcb_barcode.cpp +++ b/pcbnew/pcb_barcode.cpp @@ -113,6 +113,8 @@ void PCB_BARCODE::SetTextSize( int aTextSize ) { m_text.SetTextSize( VECTOR2I( std::max( 1, aTextSize ), std::max( 1, aTextSize ) ) ); m_text.SetTextThickness( std::max( 1, GetPenSizeForNormal( m_text.GetTextHeight() ) ) ); + + AssembleBarcode( false, true ); } @@ -155,9 +157,15 @@ void PCB_BARCODE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) } +void PCB_BARCODE::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) +{ + SetTextSize( settings.GetTextSize( GetLayer() ).y ); +} + + void PCB_BARCODE::AssembleBarcode( bool aRebuildBarcode, bool aRebuildText ) { - // if( aRebuildBarcode ) + if( aRebuildBarcode ) ComputeBarcode(); // Scale the symbol polygon to the desired barcode width/height (property values) and center it at m_pos @@ -165,7 +173,7 @@ void PCB_BARCODE::AssembleBarcode( bool aRebuildBarcode, bool aRebuildText ) SetRect( m_pos - VECTOR2I( m_width / 2, m_height / 2 ), m_pos + VECTOR2I( m_width / 2, m_height / 2 ) ); - // if( aRebuildText ) + if( aRebuildText ) ComputeTextPoly(); // Build full m_poly from symbol + optional text, then apply knockout if requested @@ -365,10 +373,10 @@ void PCB_BARCODE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() == 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( _( "Barcode" ), ENUM_MAP::Instance().ToString( m_kind ) ); - aList.emplace_back( _( "Type" ), ENUM_MAP::Instance().ToString( m_kind ) ); + // Don't use GetShownText() here; we want to show the user the variable references + aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() ) aList.emplace_back( _( "Status" ), _( "Locked" ) ); @@ -454,7 +462,7 @@ const BOX2I PCB_BARCODE::GetBoundingBox() const wxString PCB_BARCODE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const { - return wxString::Format( _( "BARCODE \"%s\" on %s" ), GetText(), GetLayerName() ); + return wxString::Format( _( "Barcode '%s' on %s" ), GetText(), GetLayerName() ); } @@ -560,14 +568,14 @@ void PCB_BARCODE::SetKind( BARCODE_T aKind ) void PCB_BARCODE::SetBarcodeErrorCorrection( BARCODE_ECC_T aErrorCorrection ) { SetErrorCorrection( aErrorCorrection ); - AssembleBarcode( true, true ); + AssembleBarcode( true, false ); } void PCB_BARCODE::SetBarcodeKind( BARCODE_T aKind ) { SetKind( aKind ); - AssembleBarcode( true, true ); + AssembleBarcode( true, false ); } @@ -620,6 +628,38 @@ double PCB_BARCODE::Similarity( const BOARD_ITEM& aItem ) const return similarity; } +int PCB_BARCODE::Compare( const PCB_BARCODE* aBarcode, const PCB_BARCODE* aOther ) +{ + int diff; + + if( ( diff = aBarcode->GetPosition().x - aOther->GetPosition().x ) != 0 ) + return diff; + + if( ( diff = aBarcode->GetPosition().y - aOther->GetPosition().y ) != 0 ) + return diff; + + if( ( diff = aBarcode->GetText().Cmp( aOther->GetText() ) != 0 ) ) + return diff; + + if( ( diff = aBarcode->GetWidth() - aOther->GetWidth() ) != 0 ) + return diff; + + if( ( diff = aBarcode->GetHeight() - aOther->GetHeight() ) != 0 ) + return diff; + + if( ( diff = aBarcode->GetTextSize() - aOther->GetTextSize() ) != 0 ) + return diff; + + if( ( diff = (int) aBarcode->GetKind() - (int) aOther->GetKind() ) != 0 ) + return diff; + + if( ( diff = (int) aBarcode->GetErrorCorrection() - (int) aOther->GetErrorCorrection() ) != 0 ) + return diff; + + return 0; +} + + bool PCB_BARCODE::operator==( const BOARD_ITEM& aItem ) const { if( !ClassOf( &aItem ) ) diff --git a/pcbnew/pcb_barcode.h b/pcbnew/pcb_barcode.h index caa111a358..8a50c7cb54 100644 --- a/pcbnew/pcb_barcode.h +++ b/pcbnew/pcb_barcode.h @@ -193,7 +193,7 @@ public: * Assemble the barcode polygon and text polygons into a single polygonal representation. * Optionally apply a knockout and margins. */ - void AssembleBarcode( bool aRebuildBarcode = false, bool aRebuildText = false ); + void AssembleBarcode( bool aRebuildBarcode, bool aRebuildText ); /** * Set the barcode content text to encode. @@ -239,6 +239,8 @@ public: */ void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipLeftRight ) override; + void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) override; + /** * Get the centre of the barcode (alias for GetPosition). */ @@ -329,6 +331,8 @@ public: */ double Similarity( const BOARD_ITEM& aItem ) const override; + static int Compare( const PCB_BARCODE* aBarcode, const PCB_BARCODE* aOther ); + /** * Equality comparison operator for board-level deduplication. * @@ -353,12 +357,12 @@ public: BARCODE_ECC_T GetErrorCorrection() const { return m_errorCorrection; } void SetBarcodeErrorCorrection( BARCODE_ECC_T aErrorCorrection ); // Includes re-compute - void SetBarcodeText( const wxString& aText ) { SetText( aText ); AssembleBarcode( true, true ); } + void SetBarcodeText( const wxString& aText ) { SetText( aText ); AssembleBarcode( false, true ); } void SetShowText( bool aShow ) { m_text.SetVisible( aShow ); AssembleBarcode( false, true ); } bool GetShowText() const { return m_text.IsVisible(); } - void SetBarcodeWidth( int aWidth ) { m_width = aWidth; AssembleBarcode( false, true ); } - void SetBarcodeHeight( int aHeight ) { m_height = aHeight; AssembleBarcode( false, true ); } + void SetBarcodeWidth( int aWidth ) { m_width = aWidth; AssembleBarcode( true, true ); } + void SetBarcodeHeight( int aHeight ) { m_height = aHeight; AssembleBarcode( true, true ); } EDA_ANGLE GetAngle() const { return m_angle; } double GetOrientation() const { return m_angle.AsDegrees(); } @@ -380,21 +384,21 @@ public: { aX = std::max( pcbIUScale.mmToIU( 1 ), aX ); m_margin.x = aX; - AssembleBarcode(); + AssembleBarcode( false, false ); } void SetMarginY( int aY ) { aY = std::max( pcbIUScale.mmToIU( 1 ), aY ); m_margin.y = aY; - AssembleBarcode(); + AssembleBarcode( false, false ); } bool IsKnockout() const override { return BOARD_ITEM::IsKnockout(); } void SetIsKnockout( bool aEnable ) override { BOARD_ITEM::SetIsKnockout( aEnable ); - AssembleBarcode(); + AssembleBarcode( false, false ); } private: diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index a9de8411ba..89662c888b 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -335,6 +335,7 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector aItems, PCB_LAYER_ID case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: + case PCB_BARCODE_T: case PCB_TRACE_T: case PCB_ARC_T: case PCB_DIM_ALIGNED_T: diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 874210c858..37641570b7 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -599,6 +600,23 @@ void PCB_DIMENSION_BASE::Mirror( const VECTOR2I& axis_pos, FLIP_DIRECTION aFlipD } +void PCB_DIMENSION_BASE::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) +{ + PCB_TEXT::StyleFromSettings( settings, aCheckSide ); + + SetLineThickness( settings.GetLineThickness( m_layer ) ); + SetUnitsMode( settings.m_DimensionUnitsMode ); + SetUnitsFormat( settings.m_DimensionUnitsFormat ); + SetPrecision( settings.m_DimensionPrecision ); + SetSuppressZeroes( settings.m_DimensionSuppressZeroes ); + SetTextPositionMode( settings.m_DimensionTextPosition ); + SetKeepTextAligned( settings.m_DimensionKeepTextAligned ); + + Update(); // refresh text & geometry + +} + + void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { diff --git a/pcbnew/pcb_dimension.h b/pcbnew/pcb_dimension.h index 1a14b17441..6ce60cc293 100644 --- a/pcbnew/pcb_dimension.h +++ b/pcbnew/pcb_dimension.h @@ -270,6 +270,8 @@ public: int GetLineThickness() const { return m_lineThickness; } void SetLineThickness( int aWidth ) { m_lineThickness = aWidth; } + void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) override; + /** * @return a list of line segments that make up this dimension (for drawing, plotting, etc). */ diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp index 62221c9d0b..70f85d2c14 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp @@ -4857,7 +4857,7 @@ FOOTPRINT* PCB_IO_KICAD_SEXPR_PARSER::parseFOOTPRINT_unchecked( wxArrayString* a field->SetLayer( footprint->GetLayer() == F_Cu ? F_Fab : B_Fab ); if( m_board ) // can be null when reading a lib - field->StyleFromSettings( m_board->GetDesignSettings() ); + field->StyleFromSettings( m_board->GetDesignSettings(), true ); } // Hide the field by default if it is a legacy field that did not have diff --git a/pcbnew/pcb_io/odbpp/odb_feature.cpp b/pcbnew/pcb_io/odbpp/odb_feature.cpp index e665d1c840..dbdb7dd3bd 100644 --- a/pcbnew/pcb_io/odbpp/odb_feature.cpp +++ b/pcbnew/pcb_io/odbpp/odb_feature.cpp @@ -787,7 +787,12 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vectorIsBackLayer( GetLayer() ) ); - else - SetMirrored( IsBackLayer( GetLayer() ) ); + if( GetParentFootprint() ) + SetKeepUpright( settings.GetTextUpright( GetLayer() ) ); + + if( aCheckSide ) + { + if( BOARD* board = GetBoard() ) + SetMirrored( board->IsBackLayer( GetLayer() ) ); + else + SetMirrored( IsBackLayer( GetLayer() ) ); + } } diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index d3b15f596b..e5ad09c77c 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -70,7 +70,7 @@ public: void Serialize( google::protobuf::Any &aContainer ) const override; bool Deserialize( const google::protobuf::Any &aContainer ) override; - void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override; + void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) override; /** * Called when rotating the parent footprint. diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index 320cf8cdbb..2f1d4c5af4 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -170,19 +170,24 @@ bool PCB_TEXTBOX::Deserialize( const google::protobuf::Any &aContainer ) } -void PCB_TEXTBOX::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) +void PCB_TEXTBOX::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) { - PCB_SHAPE::StyleFromSettings( settings ); + PCB_SHAPE::StyleFromSettings( settings, aCheckSide ); SetTextSize( settings.GetTextSize( GetLayer() ) ); SetTextThickness( settings.GetTextThickness( GetLayer() ) ); SetItalic( settings.GetTextItalic( GetLayer() ) ); - SetKeepUpright( settings.GetTextUpright( GetLayer() ) ); - if( BOARD* board = GetBoard() ) - SetMirrored( board->IsBackLayer( GetLayer() ) ); - else - SetMirrored( IsBackLayer( GetLayer() ) ); + if( GetParentFootprint() ) + SetKeepUpright( settings.GetTextUpright( GetLayer() ) ); + + if( aCheckSide ) + { + if( BOARD* board = GetBoard() ) + SetMirrored( board->IsBackLayer( GetLayer() ) ); + else + SetMirrored( IsBackLayer( GetLayer() ) ); + } } diff --git a/pcbnew/pcb_textbox.h b/pcbnew/pcb_textbox.h index f885a2d6a8..dbfad6e483 100644 --- a/pcbnew/pcb_textbox.h +++ b/pcbnew/pcb_textbox.h @@ -77,7 +77,7 @@ public: void SetRight( int aVal ) override; void SetBottom( int aVal ) override; - void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) override; + void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide ) override; int GetLegacyTextMargin() const; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index dc1be9331c..d4097c81a2 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -506,12 +506,8 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItem( const BOARD_ITEM* item ) } case PCB_BARCODE_T: - { - const PCB_BARCODE* barCode = static_cast( item ); - PlotBarCode( barCode ); - + PlotBarCode( static_cast( item ) ); break; - } case PCB_TABLE_T: { @@ -696,6 +692,10 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) break; } + case PCB_BARCODE_T: + PlotBarCode( static_cast( item ) ); + break; + case PCB_TABLE_T: { const PCB_TABLE* table = static_cast( item ); diff --git a/pcbnew/tools/array_tool.cpp b/pcbnew/tools/array_tool.cpp index 2533528551..4fbbab13e8 100644 --- a/pcbnew/tools/array_tool.cpp +++ b/pcbnew/tools/array_tool.cpp @@ -286,6 +286,7 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent ) { case PCB_FOOTPRINT_T: case PCB_SHAPE_T: + case PCB_BARCODE_T: case PCB_REFERENCE_IMAGE_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index f4804ae244..1c0cf2d5a0 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -275,7 +276,8 @@ bool CONVERT_TOOL::Init() PCB_SHAPE_LOCATE_ARC_T, PCB_SHAPE_LOCATE_BEZIER_T, PCB_FIELD_T, - PCB_TEXT_T }; + PCB_TEXT_T, + PCB_BARCODE_T }; static const std::vector trackTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T }; @@ -900,6 +902,19 @@ SHAPE_POLY_SET CONVERT_TOOL::makePolysFromClosedGraphics( const std::deque( item ); + + if( aStrategy == BOUNDING_HULL ) + barcode->GetBoundingHull( poly, UNDEFINED_LAYER, 0, barcode->GetMaxError(), ERROR_INSIDE ); + else + barcode->TransformShapeToPolySet( poly, UNDEFINED_LAYER, 0, barcode->GetMaxError(), ERROR_INSIDE ); + + barcode->SetFlags( SKIP_STRUCT ); + break; + } + case PCB_PAD_T: { PAD* pad = static_cast( item ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 28322ebd53..384caf97b5 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -2881,6 +2881,7 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut ) case PCB_TEXT_T: case PCB_SHAPE_T: case PCB_TEXTBOX_T: + case PCB_BARCODE_T: case PCB_TABLE_T: case PCB_REFERENCE_IMAGE_T: case PCB_DIMENSION_T: diff --git a/pcbnew/tools/multichannel_tool.cpp b/pcbnew/tools/multichannel_tool.cpp index 9d6a27ddf9..1bfb8d47ae 100644 --- a/pcbnew/tools/multichannel_tool.cpp +++ b/pcbnew/tools/multichannel_tool.cpp @@ -244,7 +244,7 @@ bool MULTICHANNEL_TOOL::findOtherItemsInRuleArea( RULE_AREA* aRuleArea, std::set group->RunOnChildren( [&]( BOARD_ITEM* aItem ) { - if( aItem->IsType( { PCB_ZONE_T, PCB_SHAPE_T, PCB_DIMENSION_T } ) ) + if( aItem->IsType( { PCB_ZONE_T, PCB_SHAPE_T, PCB_BARCODE_T, PCB_DIMENSION_T } ) ) { ctx.SetItems( aItem, aItem ); LIBEVAL::VALUE* val = ucode.Run( &ctx ); diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 7423a45d3f..7be5b7b346 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -1203,6 +1203,7 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) case PCB_TEXTBOX_T: case PCB_TABLE_T: case PCB_SHAPE_T: + case PCB_BARCODE_T: case PCB_DIM_ALIGNED_T: case PCB_DIM_CENTER_T: case PCB_DIM_LEADER_T: @@ -1223,7 +1224,7 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent ) } // NB: PCB_SHAPE_T actually removes everything in Drawings() (including PCB_TEXTs, - // PCB_TABLES, dimensions, etc.), not just PCB_SHAPEs.) + // PCB_TABLEs, PCB_BARCODEs, dimensions, etc.), not just PCB_SHAPEs.) clipBoard->RemoveAll( { PCB_SHAPE_T } ); clipBoard->Visit( diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index 4a04e3495f..c4953d4e74 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -103,7 +103,8 @@ std::optional GetBoardIntersectable( const BOARD_ITEM& aItem return refImage.GetBoundingBox(); } - default: break; + default: + break; } return std::nullopt; @@ -799,6 +800,7 @@ GRID_HELPER_GRIDS PCB_GRID_HELPER::GetItemGrid( const EDA_ITEM* aItem ) const case PCB_DIMENSION_T: case PCB_REFERENCE_IMAGE_T: case PCB_TEXTBOX_T: + case PCB_BARCODE_T: return GRID_GRAPHICS; case PCB_TRACE_T: diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index b6c16bf5e4..55039ec918 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -831,7 +831,7 @@ public: m_barcode.SetRect( newTL, newBR ); - m_barcode.AssembleBarcode( false, true ); + m_barcode.AssembleBarcode( true, true ); } private: diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 170a6e2925..bcf93cf721 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -2686,8 +2686,8 @@ static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard { const FOOTPRINT& footprint = static_cast( aItem ); - return aFilterOptions.includeModules && ( aFilterOptions.includeLockedModules - || !footprint.IsLocked() ); + return aFilterOptions.includeFootprints && ( aFilterOptions.includeLockedFootprints + || !footprint.IsLocked() ); } case PCB_TRACE_T: @@ -2820,6 +2820,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->otherItems = true; + return false; } } @@ -2836,6 +2837,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->footprints = true; + return false; } @@ -2846,6 +2848,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->pads = true; + return false; } @@ -2857,6 +2860,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->tracks = true; + return false; } @@ -2867,6 +2871,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->vias = true; + return false; } @@ -2886,6 +2891,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, else aRejected->zones = true; } + return false; } @@ -2904,6 +2910,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->graphics = true; + return false; } @@ -2914,6 +2921,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->graphics = true; + return false; } @@ -2922,6 +2930,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->text = true; + return false; } @@ -2946,6 +2955,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->dimensions = true; + return false; } @@ -2956,16 +2966,19 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect, { if( aRejected ) aRejected->points = true; + return false; } break; + case PCB_BARCODE_T: default: if( !m_filter.otherItems ) { if( aRejected ) aRejected->otherItems = true; + return false; } } @@ -3284,6 +3297,12 @@ bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibili break; + case PCB_BARCODE_T: + if( !layerVisible( aItem->GetLayer() ) ) + return false; + + break; + case PCB_TEXTBOX_T: case PCB_TABLE_T: if( !layerVisible( aItem->GetLayer() ) ) @@ -3799,7 +3818,8 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector static std::vector singleLayerSilkTypes = { PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TABLE_T, PCB_TABLECELL_T, - PCB_SHAPE_T }; + PCB_SHAPE_T, + PCB_BARCODE_T }; if( ADVANCED_CFG::GetCfg().m_PcbSelectionVisibilityRatio != 1.0 ) pruneObscuredSelectionCandidates( aCollector ); diff --git a/pcbnew/tools/pcb_tool_utils.cpp b/pcbnew/tools/pcb_tool_utils.cpp index 6094721c47..1f38410c22 100644 --- a/pcbnew/tools/pcb_tool_utils.cpp +++ b/pcbnew/tools/pcb_tool_utils.cpp @@ -34,16 +34,25 @@ std::optional GetBoardItemWidth( const BOARD_ITEM& aItem ) case PCB_SHAPE_T: { const PCB_SHAPE& shape = static_cast( aItem ); - return shape.GetWidth(); + + if( shape.GetShape() == SHAPE_T::SEGMENT ) + return shape.GetWidth(); + + if( shape.GetWidth() && !shape.IsSolidFill() ) + return shape.GetWidth(); + + break; } case PCB_TRACE_T: + case PCB_ARC_T: { const PCB_TRACK& track = static_cast( aItem ); return track.GetWidth(); } - default: break; + default: + break; } return std::nullopt; diff --git a/qa/pcbnew_utils/board_test_utils.cpp b/qa/pcbnew_utils/board_test_utils.cpp index 22c1e1c5d9..34850d14cb 100644 --- a/qa/pcbnew_utils/board_test_utils.cpp +++ b/qa/pcbnew_utils/board_test_utils.cpp @@ -471,6 +471,10 @@ void CheckFootprint( const FOOTPRINT* expected, const FOOTPRINT* fp ) // TODO break; + case PCB_BARCODE_T: + // TODO + break; + default: BOOST_ERROR( "KICAD_T not known" ); break; diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index 65becdf2b2..d441fd3004 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -145,7 +145,7 @@ DIALOG_FILTER_SELECTION::DIALOG_FILTER_SELECTION( PCB_BASE_FRAME* aParent, OPTIO m_options( aOptions ) { // silence another compiler warning about m_options not being used - if( m_options.includeModules ) + if( m_options.includeFootprints ) { } } diff --git a/qa/tests/pcbnew/test_board_item.cpp b/qa/tests/pcbnew/test_board_item.cpp index 5f3d02aae5..00bbd9f726 100644 --- a/qa/tests/pcbnew/test_board_item.cpp +++ b/qa/tests/pcbnew/test_board_item.cpp @@ -82,6 +82,7 @@ public: case PCB_PAD_T: return new PAD( &m_footprint ); case PCB_FIELD_T: return new PCB_FIELD( &m_footprint, FIELD_T::USER ); case PCB_SHAPE_T: return new PCB_SHAPE( &m_board ); + case PCB_BARCODE_T: { PCB_BARCODE* barcode = new PCB_BARCODE( &m_board ); @@ -89,6 +90,7 @@ public: barcode->AssembleBarcode( true, true ); return barcode; } + case PCB_TEXT_T: return new PCB_TEXT( &m_board ); case PCB_TEXTBOX_T: return new PCB_TEXTBOX( &m_board ); case PCB_TABLECELL_T: return new PCB_TABLECELL( &m_board );