7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

REMOVED: Footprint field from footprints

This field was redundant (was generally set to the footprint's LIB_ID)
but also buggy (not guaranteed to contain the footprint's LIB_ID)
and confusing (not a way to change the footprint's LIB_ID).
This commit is contained in:
Jon Evans 2024-12-01 14:41:52 -05:00
parent 719f4eabd9
commit 9b1b318736
12 changed files with 18 additions and 66 deletions

View File

@ -392,9 +392,6 @@ void DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const
m_reset3DModels->GetValue(),
&updated );
// Update footprint field with the new FPID
newFootprint->Footprint().SetText( aNewFPID.Format() );
if( aFootprint == m_currentFootprint )
m_currentFootprint = newFootprint;

View File

@ -114,10 +114,6 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, PC
}
else
{
// Don't let users modify the library link, in the board editor
if( field->IsFootprint() && !m_frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
m_SingleLineText->SetEditable( false );
title = _( "Footprint Field Properties" );
m_TextLabel->SetLabel( _( "Text:" ) );
}

View File

@ -616,6 +616,12 @@ void FOOTPRINT::GetFields( std::vector<PCB_FIELD*>& aVector, bool aVisibleOnly )
{
for( PCB_FIELD* field : m_fields )
{
// FOOTPRINT field doesn't exist on FOOTPRINT, but it's kept in the m_fields vector
// for the moment so that the MANDATORY_FIELD ids line up with vector indices.
// This could be cleaned up by making m_fields a map in the future.
if( field->GetId() == FOOTPRINT_FIELD )
continue;
if( aVisibleOnly )
{
if( !field->IsVisible() || field->GetText().IsEmpty() )
@ -2532,8 +2538,6 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootpr
case VALUE_FIELD: new_text->SetText( wxT( "${VALUE}" ) ); break;
case DATASHEET_FIELD: new_text->SetText( wxT( "${DATASHEET}" ) ); break;
case FOOTPRINT_FIELD: new_text->SetText( wxT( "${FOOTPRINT}" ) ); break;
}
}

View File

@ -637,12 +637,10 @@ public:
/// read/write accessors:
PCB_FIELD& Value() { return *GetField( VALUE_FIELD ); }
PCB_FIELD& Reference() { return *GetField( REFERENCE_FIELD ); }
PCB_FIELD& Footprint() { return *GetField( FOOTPRINT_FIELD ); }
/// The const versions to keep the compiler happy.
const PCB_FIELD& Value() const { return *GetField( VALUE_FIELD ); }
const PCB_FIELD& Reference() const { return *GetField( REFERENCE_FIELD ); }
const PCB_FIELD& Footprint() const { return *GetField( FOOTPRINT_FIELD ); }
//-----<Fields>-----------------------------------------------------------

View File

@ -423,23 +423,6 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
// Test for footprint change. This is controlled by a separate flag, that will output
// its own message if the footprint is changed, so we just set the field here.
if( ( m_replaceFootprints || ( aPcbFootprint->GetAttributes() & FP_JUST_ADDED ) )
&& !m_isDryRun )
{
// Update FOOTPRINT_FIELD (if exists in the netlist)
try
{
aPcbFootprint->Footprint().SetText(
aNetlistComponent->GetFields()[GetCanonicalFieldName( FOOTPRINT_FIELD )] );
}
catch( ... )
{
// If not exist (old netlist), just skip it: What else?
}
}
// Test for time stamp change.
KIID_PATH new_path = aNetlistComponent->GetPath();
@ -474,8 +457,7 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
for( PCB_FIELD* field : aPcbFootprint->GetFields() )
{
// These fields are individually checked above
if( field->IsReference() || field->IsValue() || field->IsFootprint()
|| field->IsComponentClass() )
if( field->IsReference() || field->IsValue() || field->IsComponentClass() )
{
continue;
}

View File

@ -262,18 +262,6 @@ static struct PCB_FIELD_DESC
propMgr.InheritsAfter( TYPE_HASH( PCB_FIELD ), TYPE_HASH( PCB_TEXT ) );
propMgr.InheritsAfter( TYPE_HASH( PCB_FIELD ), TYPE_HASH( EDA_TEXT ) );
auto isNotFootprintFootprint =
[]( INSPECTABLE* aItem ) -> bool
{
if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( aItem ) )
return !field->IsFootprint();
return true;
};
propMgr.OverrideAvailability( TYPE_HASH( PCB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Text" ),
isNotFootprintFootprint );
// These properties, inherited from EDA_TEXT, have no sense for the board editor
propMgr.Mask( TYPE_HASH( PCB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
propMgr.Mask( TYPE_HASH( PCB_FIELD ), TYPE_HASH( EDA_TEXT ), _HKI( "Color" ) );

View File

@ -58,8 +58,6 @@ public:
return true;
else if( scanType == PCB_FIELD_LOCATE_VALUE_T && m_id == VALUE_FIELD )
return true;
else if( scanType == PCB_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT_FIELD )
return true;
else if( scanType == PCB_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET_FIELD )
return true;
}
@ -69,7 +67,6 @@ public:
bool IsReference() const { return m_id == REFERENCE_FIELD; }
bool IsValue() const { return m_id == VALUE_FIELD; }
bool IsFootprint() const { return m_id == FOOTPRINT_FIELD; }
bool IsDatasheet() const { return m_id == DATASHEET_FIELD; }
bool IsComponentClass() const { return GetName() == wxT( "Component Class" ); }

View File

@ -91,15 +91,6 @@ PCB_FIELDS_GRID_TABLE::PCB_FIELDS_GRID_TABLE( PCB_BASE_FRAME* aFrame, DIALOG_SHI
valueEditor->SetValidator( m_valueValidator );
m_valueAttr->SetEditor( valueEditor );
m_footprintAttr = new wxGridCellAttr;
if( !m_frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
m_footprintAttr->SetReadOnly( true );
GRID_CELL_FPID_EDITOR* fpIdEditor = new GRID_CELL_FPID_EDITOR( m_dialog, "" );
fpIdEditor->SetValidator( m_nonUrlValidator );
m_footprintAttr->SetEditor( fpIdEditor );
EMBEDDED_FILES* files = nullptr;
// In the case of the footprint editor, we need to distinguish between the footprint
@ -147,7 +138,6 @@ PCB_FIELDS_GRID_TABLE::~PCB_FIELDS_GRID_TABLE()
m_layerColAttr->DecRef();
m_referenceAttr->DecRef();
m_valueAttr->DecRef();
m_footprintAttr->DecRef();
m_urlAttr->DecRef();
m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &PCB_FIELDS_GRID_TABLE::onUnitsChanged, this );
@ -248,11 +238,6 @@ wxGridCellAttr* PCB_FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol,
m_valueAttr->IncRef();
return enhanceAttr( m_valueAttr, aRow, aCol, aKind );
}
else if( aRow == FOOTPRINT_FIELD )
{
m_footprintAttr->IncRef();
return enhanceAttr( m_footprintAttr, aRow, aCol, aKind );
}
else if( aRow == DATASHEET_FIELD )
{
m_urlAttr->IncRef();

View File

@ -101,7 +101,6 @@ private:
wxGridCellAttr* m_layerColAttr;
wxGridCellAttr* m_referenceAttr;
wxGridCellAttr* m_valueAttr;
wxGridCellAttr* m_footprintAttr;
wxGridCellAttr* m_urlAttr;
std::unique_ptr<NUMERIC_EVALUATOR> m_eval;

View File

@ -4557,8 +4557,17 @@ FOOTPRINT* PCB_IO_KICAD_SEXPR_PARSER::parseFOOTPRINT_unchecked( wxArrayString* a
}
PCB_FIELD* field = nullptr;
std::unique_ptr<PCB_FIELD> unusedField;
if( footprint->HasFieldByName( pName ) )
if( pName == "Footprint" )
{
// Until V9, footprints had a Footprint field that usually (but not always)
// duplicated the footprint's LIB_ID. In V9 this was removed. Parse it
// like any other, but don't add it to anything.
unusedField = std::make_unique<PCB_FIELD>( footprint.get(), 0 );
field = unusedField.get();
}
else if( footprint->HasFieldByName( pName ) )
{
field = footprint->GetFieldByName( pName );
field->SetText( pValue );

View File

@ -115,7 +115,7 @@ void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARA
{
PCB_FIELD* field = fp->GetFields().at( i );
if( field->IsReference() || field->IsValue() || field->IsFootprint() )
if( field->IsReference() || field->IsValue() )
continue;
if( field->GetText().IsEmpty() )

View File

@ -1167,9 +1167,6 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
fp->SetOrientation( ANGLE_0 );
fp->SetPosition( cursorPos );
// Fill this in since it won't be synced from a symbol
fp->GetField( FOOTPRINT_FIELD )->SetText( UnescapeString( fp->GetFPIDAsString() ) );
commit.Add( fp );
m_toolMgr->RunAction<EDA_ITEM*>( PCB_ACTIONS::selectItem, fp );