PCB: introduce PCB_FIELD_T

This commit is contained in:
Mike Williams 2023-06-06 11:09:34 -04:00
parent a859b25d2c
commit 37837dc392
40 changed files with 102 additions and 31 deletions

View File

@ -599,6 +599,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item ); addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
addText( static_cast<PCB_TEXT*>( item ), layerContainer, item ); addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
break; break;
@ -645,6 +646,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE ); item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* text = static_cast<PCB_TEXT*>( item ); PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
@ -918,6 +920,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item ); addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
addText( static_cast<PCB_TEXT*>( item ), layerContainer, item ); addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
break; break;
@ -954,6 +957,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE ); item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* text = static_cast<PCB_TEXT*>( item ); PCB_TEXT* text = static_cast<PCB_TEXT*>( item );

View File

@ -333,6 +333,7 @@ static struct EDA_ITEM_DESC
.Map( PCB_PAD_T, _HKI( "Pad" ) ) .Map( PCB_PAD_T, _HKI( "Pad" ) )
.Map( PCB_SHAPE_T, _HKI( "Graphic" ) ) .Map( PCB_SHAPE_T, _HKI( "Graphic" ) )
.Map( PCB_BITMAP_T, _HKI( "Bitmap" ) ) .Map( PCB_BITMAP_T, _HKI( "Bitmap" ) )
.Map( PCB_FIELD_T, _HKI( "Field" ) )
.Map( PCB_TEXT_T, _HKI( "Text" ) ) .Map( PCB_TEXT_T, _HKI( "Text" ) )
.Map( PCB_TEXTBOX_T, _HKI( "Text Box" ) ) .Map( PCB_TEXTBOX_T, _HKI( "Text Box" ) )
.Map( PCB_TRACE_T, _HKI( "Track" ) ) .Map( PCB_TRACE_T, _HKI( "Track" ) )

View File

@ -101,6 +101,7 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
} }
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aItem ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aItem );

View File

@ -87,6 +87,7 @@ enum KICAD_T
PCB_PAD_T, ///< class PAD, a pad in a footprint PCB_PAD_T, ///< class PAD, a pad in a footprint
PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers
PCB_BITMAP_T, ///< class PCB_BITMAP, bitmap on a layer 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_TEXT_T, ///< class PCB_TEXT, text on a layer
PCB_TEXTBOX_T, ///< class PCB_TEXTBOX, wrapped 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) PCB_TRACE_T, ///< class PCB_TRACK, a track segment (segment on a copper layer)

View File

@ -855,6 +855,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
case PCB_DIM_LEADER_T: case PCB_DIM_LEADER_T:
case PCB_SHAPE_T: case PCB_SHAPE_T:
case PCB_BITMAP_T: case PCB_BITMAP_T:
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
case PCB_TARGET_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_DIM_LEADER_T:
case PCB_SHAPE_T: case PCB_SHAPE_T:
case PCB_BITMAP_T: case PCB_BITMAP_T:
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
case PCB_TARGET_T: case PCB_TARGET_T:
@ -1435,6 +1437,7 @@ INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData,
case PCB_PAD_T: case PCB_PAD_T:
case PCB_SHAPE_T: case PCB_SHAPE_T:
case PCB_BITMAP_T: case PCB_BITMAP_T:
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
case PCB_DIM_ALIGNED_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<const PCB_SHAPE*>( aSecond ); const PCB_SHAPE* other = static_cast<const PCB_SHAPE*>( aSecond );
return shape->Compare( other ); 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<const PCB_TEXT*>( aFirst ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aFirst );
const PCB_TEXT* other = static_cast<const PCB_TEXT*>( aSecond ); const PCB_TEXT* other = static_cast<const PCB_TEXT*>( aSecond );
@ -2379,6 +2382,7 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer,
break; break;
} }
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );

View File

@ -53,6 +53,7 @@ const std::vector<KICAD_T> GENERAL_COLLECTOR::AllBoardItems = {
PCB_TRACE_T, // in m_tracks PCB_TRACE_T, // in m_tracks
PCB_ARC_T, // in m_tracks PCB_ARC_T, // in m_tracks
PCB_PAD_T, // in footprints PCB_PAD_T, // in footprints
PCB_FIELD_T, // in footprints
PCB_FOOTPRINT_T, // in m_footprints PCB_FOOTPRINT_T, // in m_footprints
PCB_GROUP_T, // in m_groups PCB_GROUP_T, // in m_groups
PCB_ZONE_T // in m_zones PCB_ZONE_T // in m_zones
@ -95,6 +96,7 @@ const std::vector<KICAD_T> GENERAL_COLLECTOR::PadsOrTracks = {
const std::vector<KICAD_T> GENERAL_COLLECTOR::FootprintItems = { const std::vector<KICAD_T> GENERAL_COLLECTOR::FootprintItems = {
PCB_MARKER_T, PCB_MARKER_T,
PCB_FIELD_T,
PCB_TEXT_T, PCB_TEXT_T,
PCB_TEXTBOX_T, PCB_TEXTBOX_T,
PCB_SHAPE_T, PCB_SHAPE_T,
@ -265,6 +267,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
case PCB_TARGET_T: case PCB_TARGET_T:
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
if( item->GetParentFootprint() ) if( item->GetParentFootprint() )
{ {

View File

@ -278,6 +278,7 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
TO_UTF8( pad->GetNumber() ) ); TO_UTF8( pad->GetNumber() ) );
} }
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem ); PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem );

View File

@ -274,6 +274,12 @@ void DIALOG_FIND::search( bool aDirection )
m_hitList.push_back( fp ); m_hitList.push_back( fp );
} }
} }
for( PCB_FIELD* field : fp->Fields() )
{
if( field->Matches( m_frame->GetFindReplaceData(), nullptr ) )
m_hitList.push_back( fp );
}
} }
} }

View File

@ -521,7 +521,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
{ {
KICAD_T itemType = boardItem->Type(); 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() ) if( m_otherFields->GetValue() )
visitItem( commit, boardItem ); visitItem( commit, boardItem );

View File

@ -137,7 +137,7 @@ bool DRC_CACHE_GENERATOR::Run()
PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
PCB_PAD_T, PCB_PAD_T,
PCB_SHAPE_T, PCB_SHAPE_T,
PCB_TEXT_T, PCB_TEXTBOX_T, PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T,
PCB_DIMENSION_T PCB_DIMENSION_T
}; };

View File

@ -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_PAD_T: mask = DRC_DISALLOW_PADS; break;
case PCB_FOOTPRINT_T: mask = DRC_DISALLOW_FOOTPRINTS; break; case PCB_FOOTPRINT_T: mask = DRC_DISALLOW_FOOTPRINTS; break;
case PCB_SHAPE_T: mask = DRC_DISALLOW_GRAPHICS; 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_TEXT_T: mask = DRC_DISALLOW_TEXTS; break;
case PCB_TEXTBOX_T: mask = DRC_DISALLOW_TEXTS; break; case PCB_TEXTBOX_T: mask = DRC_DISALLOW_TEXTS; break;

View File

@ -115,8 +115,11 @@ public:
{ {
wxCHECK( aTargetLayer != UNDEFINED_LAYER, /* void */ ); wxCHECK( aTargetLayer != UNDEFINED_LAYER, /* void */ );
if( aItem->Type() == PCB_TEXT_T && !static_cast<PCB_TEXT*>( aItem )->IsVisible() ) if( ( aItem->Type() == PCB_FIELD_T || aItem->Type() == PCB_TEXT_T )
&& !static_cast<PCB_TEXT*>( aItem )->IsVisible() )
{
return; return;
}
std::vector<const SHAPE*> subshapes; std::vector<const SHAPE*> subshapes;
std::shared_ptr<SHAPE> shape = aItem->GetEffectiveShape( aRefLayer ); std::shared_ptr<SHAPE> shape = aItem->GetEffectiveShape( aRefLayer );

View File

@ -247,7 +247,7 @@ int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector<KICAD_T>& aTypes,
for( FOOTPRINT* footprint : brd->Footprints() ) for( FOOTPRINT* footprint : brd->Footprints() )
{ {
if( typeMask[ PCB_TEXT_T ] ) if( typeMask[PCB_FIELD_T] )
{ {
if( ( footprint->Reference().GetLayerSet() & aLayers ).any() ) 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 ); return wxString::Format( aFormatString, aSource, constraint_str, actual_str );
} }

View File

@ -193,7 +193,7 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
auto checkTextOnEdgeCuts = auto checkTextOnEdgeCuts =
[&]( BOARD_ITEM* item ) [&]( 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 ) || BaseType( item->Type() ) == PCB_DIMENSION_T )
{ {
if( item->GetLayer() == Edge_Cuts ) if( item->GetLayer() == Edge_Cuts )

View File

@ -261,6 +261,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars()
int items = 0; int items = 0;
static const std::vector<KICAD_T> itemTypes = { static const std::vector<KICAD_T> itemTypes = {
PCB_FIELD_T,
PCB_TEXT_T, PCB_TEXT_T,
PCB_TEXTBOX_T, PCB_TEXTBOX_T,
PCB_DIMENSION_T PCB_DIMENSION_T

View File

@ -113,7 +113,7 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run()
PCB_FOOTPRINT_T, PCB_FOOTPRINT_T,
PCB_PAD_T, PCB_PAD_T,
PCB_SHAPE_T, PCB_SHAPE_T,
PCB_TEXT_T, PCB_TEXTBOX_T, PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T,
PCB_DIMENSION_T PCB_DIMENSION_T
}; };

View File

@ -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 } ) for( PCB_LAYER_ID layer : { F_Mask, B_Mask } )
{ {

View File

@ -22,6 +22,7 @@
*/ */
#include <macros.h> #include <macros.h>
#include <pcb_field.h>
#include <pcb_text.h> #include <pcb_text.h>
#include <pcb_textbox.h> #include <pcb_textbox.h>
#include <drc/drc_engine.h> #include <drc/drc_engine.h>
@ -255,7 +256,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
return true; return true;
}; };
static const std::vector<KICAD_T> itemTypes = { PCB_TEXT_T, PCB_TEXTBOX_T }; static const std::vector<KICAD_T> itemTypes = { PCB_FIELD_T, PCB_TEXT_T, PCB_TEXTBOX_T };
forEachGeometryItem( itemTypes, LSET::AllLayersMask(), forEachGeometryItem( itemTypes, LSET::AllLayersMask(),
[&]( BOARD_ITEM* item ) -> bool [&]( BOARD_ITEM* item ) -> bool
@ -275,6 +276,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_FIELD_T: text = static_cast<PCB_FIELD*>( item ); break;
case PCB_TEXT_T: text = static_cast<PCB_TEXT*>( item ); break; case PCB_TEXT_T: text = static_cast<PCB_TEXT*>( item ); break;
case PCB_TEXTBOX_T: text = static_cast<PCB_TEXTBOX*>( item ); break; case PCB_TEXTBOX_T: text = static_cast<PCB_TEXTBOX*>( item ); break;
default: UNIMPLEMENTED_FOR( item->GetClass() ); break; default: UNIMPLEMENTED_FOR( item->GetClass() ); break;

View File

@ -125,6 +125,7 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
ShowBitmapPropertiesDialog( aItem); ShowBitmapPropertiesDialog( aItem);
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
ShowTextPropertiesDialog( static_cast<PCB_TEXT*>( aItem ) ); ShowTextPropertiesDialog( static_cast<PCB_TEXT*>( aItem ) );
break; break;

View File

@ -695,6 +695,7 @@ void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectiv
{ {
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
if( dynamic_cast<PCB_FIELD*>( aBoardItem ) != nullptr ) if( dynamic_cast<PCB_FIELD*>( aBoardItem ) != nullptr )
@ -1478,16 +1479,16 @@ INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData,
break; break;
case PCB_TEXT_T: case PCB_FIELD_T:
if( inspector( &Reference(), testData ) == INSPECT_RESULT::QUIT ) if( inspector( &Reference(), testData ) == INSPECT_RESULT::QUIT )
return INSPECT_RESULT::QUIT; return INSPECT_RESULT::QUIT;
if( inspector( &Value(), testData ) == INSPECT_RESULT::QUIT ) if( inspector( &Value(), testData ) == INSPECT_RESULT::QUIT )
return INSPECT_RESULT::QUIT; return INSPECT_RESULT::QUIT;
// Intentionally fall through since m_Drawings can hold PCB_TEXT_T also break;
KI_FALLTHROUGH;
case PCB_TEXT_T:
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:
@ -1956,6 +1957,7 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootpr
break; break;
} }
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* new_text = new PCB_TEXT( *static_cast<const PCB_TEXT*>( aItem ) ); PCB_TEXT* new_text = new PCB_TEXT( *static_cast<const PCB_TEXT*>( aItem ) );
@ -2111,7 +2113,7 @@ double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLEC
poly = footprint->GetBoundingHull(); 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<const PCB_TEXT*>( aItem ); const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aItem );
@ -2187,6 +2189,7 @@ double FOOTPRINT::CoverageRatio( const GENERAL_COLLECTOR& aCollector ) const
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
case PCB_SHAPE_T: case PCB_SHAPE_T:

View File

@ -203,6 +203,7 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
GetCanvas()->Refresh(); GetCanvas()->Refresh();
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
ShowTextPropertiesDialog( static_cast<PCB_TEXT*>( aItem ) ); ShowTextPropertiesDialog( static_cast<PCB_TEXT*>( aItem ) );
break; break;

View File

@ -1332,9 +1332,9 @@ FOOTPRINT* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName, b
footprint->SetValue( footprintName ); footprint->SetValue( footprintName );
footprint->RunOnChildren( 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<PCB_TEXT*>( aChild ); PCB_TEXT* textItem = static_cast<PCB_TEXT*>( aChild );
PCB_LAYER_ID layer = textItem->GetLayer(); PCB_LAYER_ID layer = textItem->GetLayer();

View File

@ -203,7 +203,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
BOARD_ITEM* copy = nullptr; BOARD_ITEM* copy = nullptr;
if( item->Type() == PCB_TEXT_T ) if( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T )
{ {
copy = static_cast<BOARD_ITEM*>( item->Clone() ); copy = static_cast<BOARD_ITEM*>( item->Clone() );

View File

@ -439,6 +439,7 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
return; return;
case PCB_SHAPE_T: case PCB_SHAPE_T:
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
case PCB_TRACE_T: case PCB_TRACE_T:

View File

@ -1728,6 +1728,7 @@ void PCB_EDIT_FRAME::ShowFindDialog()
findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() ); findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() ); findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() );

View File

@ -48,6 +48,7 @@ bool PCB_GROUP::IsGroupableType( KICAD_T aType )
case PCB_PAD_T: case PCB_PAD_T:
case PCB_SHAPE_T: case PCB_SHAPE_T:
case PCB_BITMAP_T: case PCB_BITMAP_T:
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
case PCB_GROUP_T: case PCB_GROUP_T:

View File

@ -569,6 +569,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
draw( static_cast<const PCB_BITMAP*>( item ), aLayer ); draw( static_cast<const PCB_BITMAP*>( item ), aLayer );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
draw( static_cast<const PCB_TEXT*>( item ), aLayer ); draw( static_cast<const PCB_TEXT*>( item ), aLayer );
break; break;

View File

@ -876,6 +876,12 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
if( itemplotter.GetPlotValue() && footprint->Value().IsOnLayer( layer ) ) if( itemplotter.GetPlotValue() && footprint->Value().IsOnLayer( layer ) )
plotFPTextItem( footprint->Value() ); plotFPTextItem( footprint->Value() );
for( const PCB_FIELD* field : footprint->Fields() )
{
if( field->IsOnLayer( layer ) )
plotFPTextItem( static_cast<const PCB_TEXT&>( *field ) );
}
for( const BOARD_ITEM* item : footprint->GraphicalItems() ) for( const BOARD_ITEM* item : footprint->GraphicalItems() )
{ {
if( item->IsOnLayer( layer ) ) if( item->IsOnLayer( layer ) )

View File

@ -519,6 +519,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
break; break;
} }
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
// Plotted in PlotFootprintTextItems() // Plotted in PlotFootprintTextItems()
break; break;

View File

@ -365,6 +365,7 @@ void PCB_PLUGIN::Format( const BOARD_ITEM* aItem, int aNestLevel ) const
format( static_cast<const PAD*>( aItem ), aNestLevel ); format( static_cast<const PAD*>( aItem ), aNestLevel );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
format( static_cast<const PCB_TEXT*>( aItem ), aNestLevel ); format( static_cast<const PCB_TEXT*>( aItem ), aNestLevel );
break; break;

View File

@ -1565,6 +1565,9 @@ void PNS_KICAD_IFACE_BASE::SyncWorld( PNS::NODE *aWorld )
for( ZONE* zone : footprint->Zones() ) for( ZONE* zone : footprint->Zones() )
syncZone( aWorld, zone, boardOutline ); syncZone( aWorld, zone, boardOutline );
for( PCB_FIELD* field : footprint->Fields() )
syncTextItem( aWorld, static_cast<PCB_TEXT*>( field ), field->GetLayer() );
for( BOARD_ITEM* item : footprint->GraphicalItems() ) for( BOARD_ITEM* item : footprint->GraphicalItems() )
{ {
if( item->Type() == PCB_SHAPE_T || item->Type() == PCB_TEXTBOX_T ) if( item->Type() == PCB_SHAPE_T || item->Type() == PCB_TEXTBOX_T )

View File

@ -282,6 +282,7 @@ bool ROUTER::isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aStartItem,
} }
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
failureReason = _( "Cannot start routing from a text item." ); failureReason = _( "Cannot start routing from a text item." );

View File

@ -1294,7 +1294,7 @@ int BOARD_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
r->Flush(); 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" ) ); r = dialog->AddHTMLPage( _( "Text Size" ) );
reportHeader( _( "Text height resolution for:" ), item, r ); reportHeader( _( "Text height resolution for:" ), item, r );

View File

@ -236,7 +236,7 @@ bool CONVERT_TOOL::Init()
auto shapes = S_C::OnlyTypes( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_RECT_T, 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_CIRCLE_T, PCB_SHAPE_LOCATE_ARC_T,
PCB_SHAPE_LOCATE_BEZIER_T, PCB_SHAPE_LOCATE_BEZIER_T,
PCB_TEXT_T } ) PCB_FIELD_T, PCB_TEXT_T } )
&& P_S_C::SameLayer(); && P_S_C::SameLayer();
auto graphicToTrack = S_C::OnlyTypes( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_ARC_T } ); 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::deque<EDA_I
item->SetFlags( SKIP_STRUCT ); item->SetFlags( SKIP_STRUCT );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* text = static_cast<PCB_TEXT*>( item ); PCB_TEXT* text = static_cast<PCB_TEXT*>( item );

View File

@ -2929,7 +2929,8 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
{ {
continue; // check against children, but not against footprint itself continue; // check against children, but not against footprint itself
} }
else if( item->Type() == PCB_TEXT_T && !static_cast<PCB_TEXT*>( item )->IsVisible() ) else if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T )
&& !static_cast<PCB_TEXT*>( item )->IsVisible() )
{ {
continue; // ignore hidden items continue; // ignore hidden items
} }

View File

@ -1574,6 +1574,7 @@ static void mirrorPadY( PAD& aPad, const VECTOR2I& aMirrorPoint )
const std::vector<KICAD_T> EDIT_TOOL::MirrorableItems = { const std::vector<KICAD_T> EDIT_TOOL::MirrorableItems = {
PCB_SHAPE_T, PCB_SHAPE_T,
PCB_FIELD_T,
PCB_TEXT_T, PCB_TEXT_T,
PCB_TEXTBOX_T, PCB_TEXTBOX_T,
PCB_ZONE_T, PCB_ZONE_T,
@ -1641,6 +1642,7 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
static_cast<ZONE*>( item )->Mirror( mirrorPoint, mirrorLeftRight ); static_cast<ZONE*>( item )->Mirror( mirrorPoint, mirrorLeftRight );
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
static_cast<PCB_TEXT*>( item )->Mirror( mirrorPoint, mirrorAroundXaxis ); static_cast<PCB_TEXT*>( item )->Mirror( mirrorPoint, mirrorAroundXaxis );
break; break;
@ -1789,6 +1791,7 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
switch( static_cast<PCB_TEXT*>( board_item )->GetType() ) switch( static_cast<PCB_TEXT*>( 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 ) if( bItem->GetParent() && bItem->GetParent()->Type() == PCB_FOOTPRINT_T )
{ {
// Silently ignore delete of Reference or Value if they happen to be // Just make fields invisible if they happen to be in group.
// in group. if( bItem->Type() == PCB_FIELD_T )
if( bItem->Type() == PCB_TEXT_T )
{ {
PCB_TEXT* textItem = static_cast<PCB_TEXT*>( bItem ); m_commit->Modify( bItem->GetParent() );
static_cast<PCB_FIELD*>( 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 ) else if( bItem->Type() == PCB_PAD_T )
{ {
@ -2193,6 +2196,11 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{ {
switch( orig_item->Type() ) 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_FOOTPRINT_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_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 // We can't copy both a footprint and its text in the same operation, so if
// both are selected, remove the text // 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 ); aCollector.Remove( item );
}
} }
}, },

View File

@ -834,6 +834,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos
break; break;
} }
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
if( aFrom && aSelectionFilter && !aSelectionFilter->text ) if( aFrom && aSelectionFilter && !aSelectionFilter->text )
break; break;

View File

@ -2095,6 +2095,7 @@ static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard
else else
return aFilterOptions.includeItemsOnTechLayers; return aFilterOptions.includeItemsOnTechLayers;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
return aFilterOptions.includePcbTexts; return aFilterOptions.includePcbTexts;
@ -2234,6 +2235,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
case PCB_TEXTBOX_T: case PCB_TEXTBOX_T:
if( !m_filter.text ) if( !m_filter.text )
@ -2487,6 +2489,7 @@ bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibili
break; break;
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
text = static_cast<const PCB_TEXT*>( aItem ); text = static_cast<const PCB_TEXT*>( aItem );
@ -2771,6 +2774,7 @@ int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aIt
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem ); PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem );
@ -2885,8 +2889,9 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector
BOARD_ITEM* item = aCollector[i]; BOARD_ITEM* item = aCollector[i];
KICAD_T type = item->Type(); KICAD_T type = item->Type();
if( ( type == PCB_TEXT_T || type == PCB_TEXTBOX_T || type == PCB_SHAPE_T ) if( ( type == PCB_FIELD_T || type == PCB_TEXT_T || type == PCB_TEXTBOX_T
&& silkLayers[item->GetLayer()] ) || type == PCB_SHAPE_T )
&& silkLayers[item->GetLayer()] )
{ {
preferred.insert( item ); preferred.insert( item );
} }

View File

@ -157,8 +157,10 @@ int PCB_VIEWER_TOOLS::TextOutlines( const TOOL_EVENT& aEvent )
for( FOOTPRINT* fp : board()->Footprints() ) for( FOOTPRINT* fp : board()->Footprints() )
{ {
view()->Update( &fp->Reference(), KIGFX::REPAINT ); for( PCB_FIELD* field : fp->Fields() )
view()->Update( &fp->Value(), KIGFX::REPAINT ); {
view()->Update( field, KIGFX::REPAINT );
}
for( BOARD_ITEM* item : fp->GraphicalItems() ) for( BOARD_ITEM* item : fp->GraphicalItems() )
{ {

View File

@ -815,6 +815,7 @@ void ZONE_FILLER::addKnockout( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aGap,
{ {
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case PCB_FIELD_T:
case PCB_TEXT_T: case PCB_TEXT_T:
{ {
PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem ); PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem );