diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index a577c16eab..c5257a2e22 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -599,6 +599,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) addShape( static_cast( item ), layerContainer, item ); break; + case PCB_FIELD_T: case PCB_TEXT_T: addText( static_cast( item ), layerContainer, item ); break; @@ -645,6 +646,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE ); break; + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* text = static_cast( item ); @@ -918,6 +920,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) addShape( static_cast( item ), layerContainer, item ); break; + case PCB_FIELD_T: case PCB_TEXT_T: addText( static_cast( item ), layerContainer, item ); break; @@ -954,6 +957,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE ); break; + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* text = static_cast( item ); diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 6ef3c199f4..6bf64b0d60 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -333,6 +333,7 @@ static struct EDA_ITEM_DESC .Map( PCB_PAD_T, _HKI( "Pad" ) ) .Map( PCB_SHAPE_T, _HKI( "Graphic" ) ) .Map( PCB_BITMAP_T, _HKI( "Bitmap" ) ) + .Map( PCB_FIELD_T, _HKI( "Field" ) ) .Map( PCB_TEXT_T, _HKI( "Text" ) ) .Map( PCB_TEXTBOX_T, _HKI( "Text Box" ) ) .Map( PCB_TRACE_T, _HKI( "Track" ) ) diff --git a/common/hash_eda.cpp b/common/hash_eda.cpp index e51c046706..3992dcf2b8 100644 --- a/common/hash_eda.cpp +++ b/common/hash_eda.cpp @@ -101,6 +101,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags ) } break; + case PCB_FIELD_T: case PCB_TEXT_T: { const PCB_TEXT* text = static_cast( aItem ); diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index ef275b73ea..4a1149a667 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -87,6 +87,7 @@ enum KICAD_T PCB_PAD_T, ///< class PAD, a pad in a footprint PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers PCB_BITMAP_T, ///< class PCB_BITMAP, bitmap on a layer + PCB_FIELD_T, ///< class PCB_FIELD, text associated with a footprint property PCB_TEXT_T, ///< class PCB_TEXT, text on a layer PCB_TEXTBOX_T, ///< class PCB_TEXTBOX, wrapped text on a layer PCB_TRACE_T, ///< class PCB_TRACK, a track segment (segment on a copper layer) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index a98ea661c4..96a7b45546 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -855,6 +855,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity case PCB_DIM_LEADER_T: case PCB_SHAPE_T: case PCB_BITMAP_T: + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_TARGET_T: @@ -968,6 +969,7 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode ) case PCB_DIM_LEADER_T: case PCB_SHAPE_T: case PCB_BITMAP_T: + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_TARGET_T: @@ -1435,6 +1437,7 @@ INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, case PCB_PAD_T: case PCB_SHAPE_T: case PCB_BITMAP_T: + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_DIM_ALIGNED_T: @@ -2307,7 +2310,7 @@ bool BOARD::cmp_drawings::operator()( const BOARD_ITEM* aFirst, const PCB_SHAPE* other = static_cast( aSecond ); return shape->Compare( other ); } - else if( aFirst->Type() == PCB_TEXT_T ) + else if( aFirst->Type() == PCB_TEXT_T || aFirst->Type() == PCB_FIELD_T ) { const PCB_TEXT* text = static_cast( aFirst ); const PCB_TEXT* other = static_cast( aSecond ); @@ -2379,6 +2382,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, break; } + case PCB_FIELD_T: case PCB_TEXT_T: { const PCB_TEXT* text = static_cast( item ); diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 0ecf0ed7e5..5f3b0a63f4 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -53,6 +53,7 @@ const std::vector GENERAL_COLLECTOR::AllBoardItems = { PCB_TRACE_T, // in m_tracks PCB_ARC_T, // in m_tracks PCB_PAD_T, // in footprints + PCB_FIELD_T, // in footprints PCB_FOOTPRINT_T, // in m_footprints PCB_GROUP_T, // in m_groups PCB_ZONE_T // in m_zones @@ -95,6 +96,7 @@ const std::vector GENERAL_COLLECTOR::PadsOrTracks = { const std::vector GENERAL_COLLECTOR::FootprintItems = { PCB_MARKER_T, + PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_SHAPE_T, @@ -265,6 +267,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) case PCB_TARGET_T: break; + case PCB_FIELD_T: case PCB_TEXT_T: if( item->GetParentFootprint() ) { diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index af041da7b2..9a54313eb1 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -278,6 +278,7 @@ std::string FormatProbeItem( BOARD_ITEM* aItem ) TO_UTF8( pad->GetNumber() ) ); } + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* text = static_cast( aItem ); diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp index 076f9046b5..5af309c440 100644 --- a/pcbnew/dialogs/dialog_find.cpp +++ b/pcbnew/dialogs/dialog_find.cpp @@ -274,6 +274,12 @@ void DIALOG_FIND::search( bool aDirection ) m_hitList.push_back( fp ); } } + + for( PCB_FIELD* field : fp->Fields() ) + { + if( field->Matches( m_frame->GetFindReplaceData(), nullptr ) ) + m_hitList.push_back( fp ); + } } } diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index 32df5611bf..dcc5e6b923 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -521,7 +521,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() { KICAD_T itemType = boardItem->Type(); - if( itemType == PCB_TEXT_T || itemType == PCB_TEXTBOX_T ) + if( itemType == PCB_FIELD_T || itemType == PCB_TEXT_T || itemType == PCB_TEXTBOX_T ) { if( m_otherFields->GetValue() ) visitItem( commit, boardItem ); diff --git a/pcbnew/drc/drc_cache_generator.cpp b/pcbnew/drc/drc_cache_generator.cpp index 96e08035cc..c4185e1ba2 100644 --- a/pcbnew/drc/drc_cache_generator.cpp +++ b/pcbnew/drc/drc_cache_generator.cpp @@ -137,7 +137,7 @@ bool DRC_CACHE_GENERATOR::Run() PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, PCB_SHAPE_T, - PCB_TEXT_T, PCB_TEXTBOX_T, + PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_DIMENSION_T }; diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 1a03926dc3..7a76270887 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -1123,6 +1123,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_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_rtree.h b/pcbnew/drc/drc_rtree.h index 4b51812824..cf4a3b1b17 100644 --- a/pcbnew/drc/drc_rtree.h +++ b/pcbnew/drc/drc_rtree.h @@ -115,8 +115,11 @@ public: { wxCHECK( aTargetLayer != UNDEFINED_LAYER, /* void */ ); - if( aItem->Type() == PCB_TEXT_T && !static_cast( aItem )->IsVisible() ) + if( ( aItem->Type() == PCB_FIELD_T || aItem->Type() == PCB_TEXT_T ) + && !static_cast( aItem )->IsVisible() ) + { return; + } std::vector subshapes; std::shared_ptr shape = aItem->GetEffectiveShape( aRefLayer ); diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index 81ef62a1ee..6aedc3e3c2 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -247,7 +247,7 @@ int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector& aTypes, for( FOOTPRINT* footprint : brd->Footprints() ) { - if( typeMask[ PCB_TEXT_T ] ) + if( typeMask[PCB_FIELD_T] ) { if( ( footprint->Reference().GetLayerSet() & aLayers ).any() ) { @@ -369,4 +369,4 @@ wxString DRC_TEST_PROVIDER::formatMsg( const wxString& aFormatString, const wxSt } return wxString::Format( aFormatString, aSource, constraint_str, actual_str ); -} \ No newline at end of file +} diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index 6fe9ed26e8..c6ea429b3a 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -193,7 +193,7 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run() auto checkTextOnEdgeCuts = [&]( BOARD_ITEM* item ) { - if( item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T + if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T || BaseType( item->Type() ) == PCB_DIMENSION_T ) { if( item->GetLayer() == Edge_Cuts ) diff --git a/pcbnew/drc/drc_test_provider_misc.cpp b/pcbnew/drc/drc_test_provider_misc.cpp index b4fd1b50a0..bb8f765371 100644 --- a/pcbnew/drc/drc_test_provider_misc.cpp +++ b/pcbnew/drc/drc_test_provider_misc.cpp @@ -261,6 +261,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars() int items = 0; static const std::vector itemTypes = { + PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_DIMENSION_T diff --git a/pcbnew/drc/drc_test_provider_physical_clearance.cpp b/pcbnew/drc/drc_test_provider_physical_clearance.cpp index e9104130c6..fa85b2f2fe 100644 --- a/pcbnew/drc/drc_test_provider_physical_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_physical_clearance.cpp @@ -113,7 +113,7 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run() PCB_FOOTPRINT_T, PCB_PAD_T, PCB_SHAPE_T, - PCB_TEXT_T, PCB_TEXTBOX_T, + PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_DIMENSION_T }; diff --git a/pcbnew/drc/drc_test_provider_solder_mask.cpp b/pcbnew/drc/drc_test_provider_solder_mask.cpp index b658dbbbf6..5051ffd21f 100644 --- a/pcbnew/drc/drc_test_provider_solder_mask.cpp +++ b/pcbnew/drc/drc_test_provider_solder_mask.cpp @@ -159,7 +159,7 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::addItemToRTrees( BOARD_ITEM* aItem ) } } } - else if( aItem->Type() == PCB_TEXT_T ) + else if( aItem->Type() == PCB_FIELD_T || aItem->Type() == PCB_TEXT_T ) { for( PCB_LAYER_ID layer : { F_Mask, B_Mask } ) { diff --git a/pcbnew/drc/drc_test_provider_text_dims.cpp b/pcbnew/drc/drc_test_provider_text_dims.cpp index 351a7dfd4b..5d0290b618 100644 --- a/pcbnew/drc/drc_test_provider_text_dims.cpp +++ b/pcbnew/drc/drc_test_provider_text_dims.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -255,7 +256,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() return true; }; - static const std::vector itemTypes = { PCB_TEXT_T, PCB_TEXTBOX_T }; + static const std::vector itemTypes = { PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T }; forEachGeometryItem( itemTypes, LSET::AllLayersMask(), [&]( BOARD_ITEM* item ) -> bool @@ -275,6 +276,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() switch( item->Type() ) { + case PCB_FIELD_T: text = static_cast( item ); break; case PCB_TEXT_T: text = static_cast( item ); break; case PCB_TEXTBOX_T: text = static_cast( item ); break; default: UNIMPLEMENTED_FOR( item->GetClass() ); break; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 189f0a2365..c3668826be 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -125,6 +125,7 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) ShowBitmapPropertiesDialog( aItem); break; + case PCB_FIELD_T: case PCB_TEXT_T: ShowTextPropertiesDialog( static_cast( aItem ) ); break; diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 9c6dd87dd0..fa88987483 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -695,6 +695,7 @@ void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectiv { switch( aBoardItem->Type() ) { + case PCB_FIELD_T: case PCB_TEXT_T: if( dynamic_cast( aBoardItem ) != nullptr ) @@ -1478,16 +1479,16 @@ INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, break; - case PCB_TEXT_T: + case PCB_FIELD_T: if( inspector( &Reference(), testData ) == INSPECT_RESULT::QUIT ) return INSPECT_RESULT::QUIT; if( inspector( &Value(), testData ) == INSPECT_RESULT::QUIT ) return INSPECT_RESULT::QUIT; - // Intentionally fall through since m_Drawings can hold PCB_TEXT_T also - KI_FALLTHROUGH; + break; + case PCB_TEXT_T: case PCB_DIM_ALIGNED_T: case PCB_DIM_LEADER_T: case PCB_DIM_CENTER_T: @@ -1956,6 +1957,7 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootpr break; } + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* new_text = new PCB_TEXT( *static_cast( aItem ) ); @@ -2111,7 +2113,7 @@ double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLEC poly = footprint->GetBoundingHull(); } - else if( aItem->Type() == PCB_TEXT_T ) + else if( aItem->Type() == PCB_FIELD_T || aItem->Type() == PCB_TEXT_T ) { const PCB_TEXT* text = static_cast( aItem ); @@ -2187,6 +2189,7 @@ double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const switch( item->Type() ) { + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_SHAPE_T: diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 280dbdf9d9..ef1209b07a 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -203,6 +203,7 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) GetCanvas()->Refresh(); break; + case PCB_FIELD_T: case PCB_TEXT_T: ShowTextPropertiesDialog( static_cast( aItem ) ); break; diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 8f5a408a0b..667bb8104f 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -1332,9 +1332,9 @@ FOOTPRINT* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName, b footprint->SetValue( footprintName ); footprint->RunOnChildren( - [&] ( BOARD_ITEM* aChild ) + [&]( BOARD_ITEM* aChild ) { - if( aChild->Type() == PCB_TEXT_T ) + if( aChild->Type() == PCB_FIELD_T || aChild->Type() == PCB_TEXT_T ) { PCB_TEXT* textItem = static_cast( aChild ); PCB_LAYER_ID layer = textItem->GetLayer(); diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index c5bdfba139..7712a91cac 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -203,7 +203,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri BOARD_ITEM* item = static_cast( i ); BOARD_ITEM* copy = nullptr; - if( item->Type() == PCB_TEXT_T ) + if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T ) { copy = static_cast( item->Clone() ); diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 0110d955e2..0b34adedcd 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -439,6 +439,7 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector aItems, PCB_LAYER_ID return; case PCB_SHAPE_T: + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_TRACE_T: diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index bb22880b40..c27a32866d 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1728,6 +1728,7 @@ void PCB_EDIT_FRAME::ShowFindDialog() findString = UnescapeString( static_cast( front )->GetValue() ); break; + case PCB_FIELD_T: case PCB_TEXT_T: findString = UnescapeString( static_cast( front )->GetText() ); diff --git a/pcbnew/pcb_group.cpp b/pcbnew/pcb_group.cpp index 9d00aba827..5b7828f19d 100644 --- a/pcbnew/pcb_group.cpp +++ b/pcbnew/pcb_group.cpp @@ -48,6 +48,7 @@ bool PCB_GROUP::IsGroupableType( KICAD_T aType ) case PCB_PAD_T: case PCB_SHAPE_T: case PCB_BITMAP_T: + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: case PCB_GROUP_T: diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index b40c4bae62..e466616e39 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -569,6 +569,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) draw( static_cast( item ), aLayer ); break; + case PCB_FIELD_T: case PCB_TEXT_T: draw( static_cast( item ), aLayer ); break; diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 207566750e..0ad6bc1987 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -876,6 +876,12 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, if( itemplotter.GetPlotValue() && footprint->Value().IsOnLayer( layer ) ) plotFPTextItem( footprint->Value() ); + for( const PCB_FIELD* field : footprint->Fields() ) + { + if( field->IsOnLayer( layer ) ) + plotFPTextItem( static_cast( *field ) ); + } + for( const BOARD_ITEM* item : footprint->GraphicalItems() ) { if( item->IsOnLayer( layer ) ) diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 19a4f481b4..4e8bbf6a4f 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -519,6 +519,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) break; } + case PCB_FIELD_T: case PCB_TEXT_T: // Plotted in PlotFootprintTextItems() break; diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 53d8a34928..c6aa5dc634 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -365,6 +365,7 @@ void PCB_PLUGIN::Format( const BOARD_ITEM* aItem, int aNestLevel ) const format( static_cast( aItem ), aNestLevel ); break; + case PCB_FIELD_T: case PCB_TEXT_T: format( static_cast( aItem ), aNestLevel ); break; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index b19a8c4ecb..59a6960c98 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1565,6 +1565,9 @@ void PNS_KICAD_IFACE_BASE::SyncWorld( PNS::NODE *aWorld ) for( ZONE* zone : footprint->Zones() ) syncZone( aWorld, zone, boardOutline ); + for( PCB_FIELD* field : footprint->Fields() ) + syncTextItem( aWorld, static_cast( field ), field->GetLayer() ); + for( BOARD_ITEM* item : footprint->GraphicalItems() ) { if( item->Type() == PCB_SHAPE_T || item->Type() == PCB_TEXTBOX_T ) diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index d4d38541ee..704fec85c6 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -282,6 +282,7 @@ bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aStartItem, } break; + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: failureReason = _( "Cannot start routing from a text item." ); diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 9e99a712dc..6cf17f92fa 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -1294,7 +1294,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent ) r->Flush(); } - if( item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T ) + if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T || item->Type() == PCB_TEXTBOX_T ) { r = dialog->AddHTMLPage( _( "Text Size" ) ); reportHeader( _( "Text height resolution for:" ), item, r ); diff --git a/pcbnew/tools/convert_tool.cpp b/pcbnew/tools/convert_tool.cpp index f23fa81f90..7af79d94af 100644 --- a/pcbnew/tools/convert_tool.cpp +++ b/pcbnew/tools/convert_tool.cpp @@ -236,7 +236,7 @@ bool CONVERT_TOOL::Init() auto shapes = S_C::OnlyTypes( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_RECT_T, PCB_SHAPE_LOCATE_CIRCLE_T, PCB_SHAPE_LOCATE_ARC_T, PCB_SHAPE_LOCATE_BEZIER_T, - PCB_TEXT_T } ) + PCB_FIELD_T, PCB_TEXT_T } ) && P_S_C::SameLayer(); auto graphicToTrack = S_C::OnlyTypes( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_ARC_T } ); @@ -783,6 +783,7 @@ SHAPE_POLY_SET CONVERT_TOOL::makePolysFromClosedGraphics( const std::dequeSetFlags( SKIP_STRUCT ); break; + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* text = static_cast( item ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index a0d9d6c16a..f3ce71f2d8 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -2929,7 +2929,8 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) { continue; // check against children, but not against footprint itself } - else if( item->Type() == PCB_TEXT_T && !static_cast( item )->IsVisible() ) + else if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T ) + && !static_cast( item )->IsVisible() ) { continue; // ignore hidden items } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 67c475559e..b9ee7f1b38 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1574,6 +1574,7 @@ static void mirrorPadY( PAD& aPad, const VECTOR2I& aMirrorPoint ) const std::vector EDIT_TOOL::MirrorableItems = { PCB_SHAPE_T, + PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_ZONE_T, @@ -1641,6 +1642,7 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) static_cast( item )->Mirror( mirrorPoint, mirrorLeftRight ); break; + case PCB_FIELD_T: case PCB_TEXT_T: static_cast( item )->Mirror( mirrorPoint, mirrorAroundXaxis ); break; @@ -1789,6 +1791,7 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut ) switch( item->Type() ) { + case PCB_FIELD_T: case PCB_TEXT_T: switch( static_cast( board_item )->GetType() ) { @@ -1900,14 +1903,14 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut ) { if( bItem->GetParent() && bItem->GetParent()->Type() == PCB_FOOTPRINT_T ) { - // Silently ignore delete of Reference or Value if they happen to be - // in group. - if( bItem->Type() == PCB_TEXT_T ) + // Just make fields invisible if they happen to be in group. + if( bItem->Type() == PCB_FIELD_T ) { - PCB_TEXT* textItem = static_cast( bItem ); + m_commit->Modify( bItem->GetParent() ); + static_cast( board_item )->SetVisible( false ); + getView()->Update( board_item ); - if( textItem->GetType() != PCB_TEXT::TEXT_is_DIVERS ) - return; + return; } else if( bItem->Type() == PCB_PAD_T ) { @@ -2193,6 +2196,11 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) { switch( orig_item->Type() ) { + case PCB_FIELD_T: + // Todo: these should probably be duplicated into new text items that + // have variables that reference the field values + + break; case PCB_FOOTPRINT_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: @@ -2459,8 +2467,11 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent ) // We can't copy both a footprint and its text in the same operation, so if // both are selected, remove the text - if( item->Type() == PCB_TEXT_T && aCollector.HasItem( item->GetParentFootprint() ) ) + if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T ) + && aCollector.HasItem( item->GetParentFootprint() ) ) + { aCollector.Remove( item ); + } } }, diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index 5399eef884..c3d048cfd9 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -834,6 +834,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos break; } + case PCB_FIELD_T: case PCB_TEXT_T: if( aFrom && aSelectionFilter && !aSelectionFilter->text ) break; diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 38afcfaacb..9440179437 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -2095,6 +2095,7 @@ static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard else return aFilterOptions.includeItemsOnTechLayers; + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: return aFilterOptions.includePcbTexts; @@ -2234,6 +2235,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect break; + case PCB_FIELD_T: case PCB_TEXT_T: case PCB_TEXTBOX_T: if( !m_filter.text ) @@ -2487,6 +2489,7 @@ bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibili break; + case PCB_FIELD_T: case PCB_TEXT_T: text = static_cast( aItem ); @@ -2771,6 +2774,7 @@ int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aIt switch( aItem->Type() ) { + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* text = static_cast( aItem ); @@ -2885,8 +2889,9 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector BOARD_ITEM* item = aCollector[i]; KICAD_T type = item->Type(); - if( ( type == PCB_TEXT_T || type == PCB_TEXTBOX_T || type == PCB_SHAPE_T ) - && silkLayers[item->GetLayer()] ) + if( ( type == PCB_FIELD_T || type == PCB_TEXT_T || type == PCB_TEXTBOX_T + || type == PCB_SHAPE_T ) + && silkLayers[item->GetLayer()] ) { preferred.insert( item ); } diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 300da6327f..630cbcc8ff 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -157,8 +157,10 @@ int PCB_VIEWER_TOOLS::TextOutlines( const TOOL_EVENT& aEvent ) for( FOOTPRINT* fp : board()->Footprints() ) { - view()->Update( &fp->Reference(), KIGFX::REPAINT ); - view()->Update( &fp->Value(), KIGFX::REPAINT ); + for( PCB_FIELD* field : fp->Fields() ) + { + view()->Update( field, KIGFX::REPAINT ); + } for( BOARD_ITEM* item : fp->GraphicalItems() ) { diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 7e5ad98c70..1d4a518f69 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -815,6 +815,7 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap, { switch( aItem->Type() ) { + case PCB_FIELD_T: case PCB_TEXT_T: { PCB_TEXT* text = static_cast( aItem );