mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 00:21:25 +00:00
Pull a little harder on the MANDATORY_FIELDs string.
We still conflate the fieldID, the position in the array of fields, and whether or not that means the field is mandatory. But this attempts to clean up *some* of that, without introducing too much risk.
This commit is contained in:
parent
d21eeb4249
commit
a0dd0485e9
common
eeschema
dialogs
dialog_change_symbols.cppdialog_lib_symbol_properties.cppdialog_sheet_properties.cppdialog_symbol_fields_table.cppdialog_symbol_properties.cppdialog_update_symbol_fields.cpp
eeschema_jobs_handler.cppfields_data_model.cppfields_grid_table.cpplib_symbol.cppnetlist_exporters
sch_field.cppsch_io
kicad_legacy
kicad_sexpr
sim
symbol_editor
tools
include
pcbnew
dialogs
footprint.cppnetlist_reader
pcb_field.cpppcb_field.hpcb_fields_grid_table.cpppcb_fields_grid_table.hpcb_io/kicad_sexpr
qa/tests/eeschema
@ -37,10 +37,6 @@ using namespace TFIELD_T;
|
||||
#define FOOTPRINT_CANONICAL "Footprint"
|
||||
#define DATASHEET_CANONICAL "Datasheet"
|
||||
#define DESCRIPTION_CANONICAL "Description"
|
||||
|
||||
// N.B. Do not change these values without transitioning the file format
|
||||
#define SHEET_NAME_CANONICAL "Sheetname"
|
||||
#define SHEET_FILE_CANONICAL "Sheetfile"
|
||||
#define USER_FIELD_CANONICAL "Field%d"
|
||||
|
||||
static wxString s_CanonicalReference( REFERENCE_CANONICAL );
|
||||
@ -48,37 +44,12 @@ static wxString s_CanonicalValue( VALUE_CANONICAL );
|
||||
static wxString s_CanonicalFootprint( FOOTPRINT_CANONICAL );
|
||||
static wxString s_CanonicalDatasheet( DATASHEET_CANONICAL );
|
||||
static wxString s_CanonicalDescription( DESCRIPTION_CANONICAL );
|
||||
static wxString s_CanonicalSheetName( SHEET_NAME_CANONICAL );
|
||||
static wxString s_CanonicalSheetFile( SHEET_FILE_CANONICAL );
|
||||
|
||||
|
||||
wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI, KICAD_T aParentType )
|
||||
wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI )
|
||||
{
|
||||
int mandatoryCount = 0;
|
||||
|
||||
if( aParentType == SCH_SYMBOL_T )
|
||||
mandatoryCount = SYMBOL_MANDATORY_FIELDS;
|
||||
else if( aParentType == SCH_SHEET_T )
|
||||
mandatoryCount = SHEET_MANDATORY_FIELDS;
|
||||
else if( aParentType == PCB_FOOTPRINT_T )
|
||||
mandatoryCount = FP_MANDATORY_FIELDS;
|
||||
else
|
||||
wxFAIL_MSG( "Unsupported field parentType" );
|
||||
|
||||
if( !aTranslateForHI )
|
||||
{
|
||||
if( aFieldNdx >= mandatoryCount )
|
||||
return wxString::Format( wxS( USER_FIELD_CANONICAL ), aFieldNdx );
|
||||
|
||||
if( aParentType == SCH_SHEET_T )
|
||||
{
|
||||
switch( aFieldNdx )
|
||||
{
|
||||
case SHEETNAME: return s_CanonicalSheetName;
|
||||
case SHEETFILENAME: return s_CanonicalSheetFile;
|
||||
}
|
||||
}
|
||||
|
||||
switch( aFieldNdx )
|
||||
{
|
||||
case REFERENCE_FIELD: return s_CanonicalReference; // The symbol reference, R1, C1, etc.
|
||||
@ -86,22 +57,11 @@ wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI, KICAD_T aPare
|
||||
case FOOTPRINT_FIELD: return s_CanonicalFootprint; // The footprint for use with Pcbnew
|
||||
case DATASHEET_FIELD: return s_CanonicalDatasheet; // Link to a datasheet for symbol
|
||||
case DESCRIPTION_FIELD: return s_CanonicalDescription; // The symbol description
|
||||
default: return GetUserFieldName( aFieldNdx, aTranslateForHI );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aFieldNdx >= mandatoryCount )
|
||||
return wxString::Format( _( USER_FIELD_CANONICAL ), aFieldNdx );
|
||||
|
||||
if( aParentType == SCH_FIELD_T )
|
||||
{
|
||||
switch( aFieldNdx )
|
||||
{
|
||||
case SHEETNAME: return _( SHEET_NAME_CANONICAL );
|
||||
case SHEETFILENAME: return _( SHEET_FILE_CANONICAL );
|
||||
}
|
||||
}
|
||||
|
||||
switch( aFieldNdx )
|
||||
{
|
||||
case REFERENCE_FIELD: return _( REFERENCE_CANONICAL ); // The symbol reference, R1, C1, etc.
|
||||
@ -109,10 +69,18 @@ wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI, KICAD_T aPare
|
||||
case FOOTPRINT_FIELD: return _( FOOTPRINT_CANONICAL ); // The footprint for use with Pcbnew
|
||||
case DATASHEET_FIELD: return _( DATASHEET_CANONICAL ); // Link to a datasheet for symbol
|
||||
case DESCRIPTION_FIELD: return _( DESCRIPTION_CANONICAL ); // The symbol description
|
||||
default: return GetUserFieldName( aFieldNdx, aTranslateForHI );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return wxEmptyString; // Shouldn't be possible to get here....
|
||||
|
||||
wxString GetUserFieldName( int aFieldNdx, bool aTranslateForHI )
|
||||
{
|
||||
if( !aTranslateForHI )
|
||||
return wxString::Format( wxS( USER_FIELD_CANONICAL ), aFieldNdx );
|
||||
else
|
||||
return wxString::Format( _( USER_FIELD_CANONICAL ), aFieldNdx );
|
||||
}
|
||||
|
||||
|
||||
@ -268,11 +236,9 @@ void TEMPLATES::resolveTemplates()
|
||||
void TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal )
|
||||
{
|
||||
// Ensure that the template fieldname does not match a fixed fieldname.
|
||||
// We use SCH_SYMBOL_T here as it contains a superset of SCH_SYMBOL_T's and PCB_FOOTPRINT_T's
|
||||
// field names.
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
if( GetCanonicalFieldName( i, SCH_SYMBOL_T ) == aFieldName.m_Name )
|
||||
if( GetCanonicalFieldName( i ) == aFieldName.m_Name )
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -101,9 +101,9 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_SYMBO
|
||||
m_matchSizer->SetEmptyCellSize( wxSize( 0, 0 ) );
|
||||
m_matchSizer->Layout();
|
||||
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
m_fieldsBox->Append( GetDefaultFieldName( i, DO_TRANSLATE, SCH_SYMBOL_T ) );
|
||||
m_fieldsBox->Append( GetDefaultFieldName( i, DO_TRANSLATE ) );
|
||||
|
||||
if( i == REFERENCE_FIELD )
|
||||
m_fieldsBox->Check( i, g_selectRefDes );
|
||||
@ -308,7 +308,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
fields.clear();
|
||||
symbol->GetFields( fields, false );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < fields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
|
||||
{
|
||||
if( !fields[i]->IsPrivate() )
|
||||
fieldNames.insert( fields[i]->GetName() );
|
||||
@ -324,7 +324,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
|
||||
flattenedSymbol->GetFields( libFields );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
{
|
||||
if( !libFields[i]->IsPrivate() )
|
||||
fieldNames.insert( libFields[i]->GetName() );
|
||||
@ -353,7 +353,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
|
||||
flattenedSymbol->GetFields( libFields );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
{
|
||||
if( !libFields[i]->IsPrivate() )
|
||||
fieldNames.insert( libFields[i]->GetName() );
|
||||
@ -384,7 +384,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
allChecked = false;
|
||||
}
|
||||
|
||||
for( unsigned ii = m_fieldsBox->GetCount() - 1; ii >= SYMBOL_MANDATORY_FIELDS; --ii )
|
||||
for( unsigned ii = m_fieldsBox->GetCount() - 1; ii >= MANDATORY_FIELDS; --ii )
|
||||
m_fieldsBox->Delete( ii );
|
||||
|
||||
for( const wxString& fieldName : fieldNames )
|
||||
@ -424,7 +424,7 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( m_fieldsBox->IsChecked( i ) )
|
||||
{
|
||||
if( i < SYMBOL_MANDATORY_FIELDS )
|
||||
if( i < MANDATORY_FIELDS )
|
||||
{
|
||||
SCH_FIELD dummy_field( nullptr, i );
|
||||
m_updateFields.insert( dummy_field.GetCanonicalName() );
|
||||
@ -673,7 +673,7 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
if( !doUpdate )
|
||||
continue;
|
||||
|
||||
if( i < SYMBOL_MANDATORY_FIELDS )
|
||||
if( i < MANDATORY_FIELDS )
|
||||
libField = symbol->GetLibSymbolRef()->GetFieldById( (int) i );
|
||||
else
|
||||
libField = symbol->GetLibSymbolRef()->FindField( field.GetName() );
|
||||
@ -740,7 +740,7 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
if( resetPositions )
|
||||
field.SetTextPos( symbol->GetPosition() + libField->GetTextPos() );
|
||||
}
|
||||
else if( i >= SYMBOL_MANDATORY_FIELDS && removeExtras )
|
||||
else if( i >= MANDATORY_FIELDS && removeExtras )
|
||||
{
|
||||
symbol->RemoveField( field.GetName() );
|
||||
i--;
|
||||
@ -750,7 +750,7 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
std::vector<SCH_FIELD*> libFields;
|
||||
symbol->GetLibSymbolRef()->GetFields( libFields );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
{
|
||||
const SCH_FIELD& libField = *libFields[i];
|
||||
|
||||
|
@ -321,10 +321,14 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::Validate()
|
||||
}
|
||||
|
||||
// Check for missing field names.
|
||||
for( int ii = SYMBOL_MANDATORY_FIELDS; ii < (int) m_fields->size(); ++ii )
|
||||
for( int ii = 0; ii < (int) m_fields->size(); ++ii )
|
||||
{
|
||||
SCH_FIELD& field = m_fields->at( ii );
|
||||
wxString fieldName = field.GetName( false );
|
||||
|
||||
if( field.IsMandatory() )
|
||||
continue;
|
||||
|
||||
wxString fieldName = field.GetName( false );
|
||||
|
||||
if( fieldName.IsEmpty() && !field.GetText().IsEmpty() )
|
||||
{
|
||||
@ -424,9 +428,13 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
||||
m_fields->at( ii ).SetId( ii );
|
||||
}
|
||||
|
||||
for( int ii = m_fields->GetNumberRows() - 1; ii >= SYMBOL_MANDATORY_FIELDS; ii-- )
|
||||
for( int ii = m_fields->GetNumberRows() - 1; ii >= 0; ii-- )
|
||||
{
|
||||
SCH_FIELD& field = m_fields->at( ii );
|
||||
SCH_FIELD& field = m_fields->at( ii );
|
||||
|
||||
if( field.IsMandatory() )
|
||||
continue;
|
||||
|
||||
const wxString& fieldName = field.GetCanonicalName();
|
||||
|
||||
if( field.GetText().IsEmpty() )
|
||||
@ -620,10 +628,10 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
|
||||
|
||||
for( int row : selectedRows )
|
||||
{
|
||||
if( row < SYMBOL_MANDATORY_FIELDS )
|
||||
if( row < MANDATORY_FIELDS )
|
||||
{
|
||||
DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
|
||||
SYMBOL_MANDATORY_FIELDS ) );
|
||||
MANDATORY_FIELDS ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -660,7 +668,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
|
||||
|
||||
int i = m_grid->GetGridCursorRow();
|
||||
|
||||
if( i > SYMBOL_MANDATORY_FIELDS )
|
||||
if( i > MANDATORY_FIELDS )
|
||||
{
|
||||
SCH_FIELD tmp = m_fields->at( (unsigned) i );
|
||||
m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
|
||||
@ -686,7 +694,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
|
||||
|
||||
int i = m_grid->GetGridCursorRow();
|
||||
|
||||
if( i >= SYMBOL_MANDATORY_FIELDS && i + 1 < m_fields->GetNumberRows() )
|
||||
if( i >= MANDATORY_FIELDS && i + 1 < m_fields->GetNumberRows() )
|
||||
{
|
||||
SCH_FIELD tmp = m_fields->at( (unsigned) i );
|
||||
m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
|
||||
|
@ -205,16 +205,19 @@ bool DIALOG_SHEET_PROPERTIES::Validate()
|
||||
return false;
|
||||
|
||||
// Check for missing field names.
|
||||
for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields->size(); ++i )
|
||||
for( size_t i = 0; i < m_fields->size(); ++i )
|
||||
{
|
||||
SCH_FIELD& field = m_fields->at( i );
|
||||
|
||||
if( field.IsMandatory() )
|
||||
continue;
|
||||
|
||||
if( field.GetName( false ).empty() && !field.GetText().empty() )
|
||||
{
|
||||
DisplayErrorMessage( this, _( "Fields must have a name." ) );
|
||||
|
||||
m_delayedFocusColumn = FDC_NAME;
|
||||
m_delayedFocusRow = i;
|
||||
m_delayedFocusRow = (int) i;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -244,11 +247,11 @@ static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
|
||||
|
||||
static bool positioningChanged( FIELDS_GRID_TABLE* a, std::vector<SCH_FIELD>& b )
|
||||
{
|
||||
for( size_t i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
if( positioningChanged( a->at( i ), b.at( i ) ) )
|
||||
return true;
|
||||
}
|
||||
if( positioningChanged( a->at( SHEETNAME ), b.at( SHEETNAME ) ) )
|
||||
return true;
|
||||
|
||||
if( positioningChanged( a->at( SHEETFILENAME ), b.at( SHEETFILENAME ) ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -743,7 +746,7 @@ void DIALOG_SHEET_PROPERTIES::OnAddField( wxCommandEvent& event )
|
||||
|
||||
int fieldID = m_fields->size();
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_sheet,
|
||||
GetDefaultFieldName( fieldID, DO_TRANSLATE, SCH_SHEET_T ) );
|
||||
SCH_SHEET::GetDefaultFieldName( fieldID, DO_TRANSLATE ) );
|
||||
|
||||
newField.SetTextAngle( m_fields->at( SHEETNAME ).GetTextAngle() );
|
||||
|
||||
|
@ -416,14 +416,12 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties( int aCol )
|
||||
attr->SetReadOnly();
|
||||
m_grid->SetColAttr( aCol, attr );
|
||||
}
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FOOTPRINT_FIELD,
|
||||
SCH_SYMBOL_T ) )
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FOOTPRINT_FIELD ) )
|
||||
{
|
||||
attr->SetEditor( new GRID_CELL_FPID_EDITOR( this, wxEmptyString ) );
|
||||
m_grid->SetColAttr( aCol, attr );
|
||||
}
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( DATASHEET_FIELD,
|
||||
SCH_SYMBOL_T ) )
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( DATASHEET_FIELD ) )
|
||||
{
|
||||
// set datasheet column viewer button
|
||||
attr->SetEditor( new GRID_CELL_URL_EDITOR( this, PROJECT_SCH::SchSearchS( &Prj() ),
|
||||
@ -683,7 +681,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::AddField( const wxString& aFieldName, const wxS
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||
{
|
||||
// Add mandatory fields first
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
bool show = false;
|
||||
bool groupBy = false;
|
||||
@ -702,8 +700,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||
break;
|
||||
}
|
||||
|
||||
AddField( GetCanonicalFieldName( i, SCH_SYMBOL_T ),
|
||||
GetDefaultFieldName( i, DO_TRANSLATE, SCH_SYMBOL_T ), show, groupBy );
|
||||
AddField( GetCanonicalFieldName( i ), GetDefaultFieldName( i, DO_TRANSLATE ), show,
|
||||
groupBy );
|
||||
}
|
||||
|
||||
// Generated fields present only in the fields table
|
||||
@ -717,7 +715,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||
{
|
||||
SCH_SYMBOL* symbol = m_symbolsList[ i ].GetSymbol();
|
||||
|
||||
for( int j = SYMBOL_MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
|
||||
for( int j = MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
|
||||
{
|
||||
if( !symbol->GetFields()[j].IsPrivate() )
|
||||
userFieldNames.insert( symbol->GetFields()[j].GetName() );
|
||||
@ -782,7 +780,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnRemoveField( wxCommandEvent& event )
|
||||
// Should never occur: "Remove Field..." button should be disabled if invalid selection
|
||||
// via OnFieldsCtrlSelectionChanged()
|
||||
wxCHECK_RET( row != -1, wxS( "Some user defined field must be selected first" ) );
|
||||
wxCHECK_RET( row >= SYMBOL_MANDATORY_FIELDS, wxS( "Mandatory fields cannot be removed" ) );
|
||||
wxCHECK_RET( row >= MANDATORY_FIELDS, wxS( "Mandatory fields cannot be removed" ) );
|
||||
|
||||
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
|
||||
wxString displayName = m_fieldsCtrl->GetTextValue( row, DISPLAY_NAME_COLUMN );
|
||||
@ -807,7 +805,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnRemoveField( wxCommandEvent& event )
|
||||
// Safe to decrement row index because we always have mandatory fields.
|
||||
m_fieldsCtrl->SelectRow( --row );
|
||||
|
||||
if( row < SYMBOL_MANDATORY_FIELDS )
|
||||
if( row < MANDATORY_FIELDS )
|
||||
{
|
||||
m_removeFieldButton->Enable( false );
|
||||
m_renameFieldButton->Enable( false );
|
||||
@ -830,7 +828,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnRenameField( wxCommandEvent& event )
|
||||
// Should never occur: "Rename Field..." button should be disabled if invalid selection
|
||||
// via OnFieldsCtrlSelectionChanged()
|
||||
wxCHECK_RET( row != -1, wxS( "Some user defined field must be selected first" ) );
|
||||
wxCHECK_RET( row >= SYMBOL_MANDATORY_FIELDS, wxS( "Mandatory fields cannot be renamed" ) );
|
||||
wxCHECK_RET( row >= MANDATORY_FIELDS, wxS( "Mandatory fields cannot be renamed" ) );
|
||||
wxCHECK_RET( !fieldName.IsEmpty(), wxS( "Field must have a name" ) );
|
||||
|
||||
int col = m_dataModel->GetFieldNameCol( fieldName );
|
||||
@ -896,7 +894,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnFieldsCtrlSelectionChanged( wxDataViewEvent&
|
||||
{
|
||||
int row = m_fieldsCtrl->GetSelectedRow();
|
||||
|
||||
if( row >= SYMBOL_MANDATORY_FIELDS )
|
||||
if( row >= MANDATORY_FIELDS )
|
||||
{
|
||||
m_removeFieldButton->Enable( true );
|
||||
m_renameFieldButton->Enable( true );
|
||||
|
@ -636,7 +636,7 @@ bool DIALOG_SYMBOL_PROPERTIES::Validate()
|
||||
return false;
|
||||
|
||||
// Check for missing field names.
|
||||
for( size_t i = SYMBOL_MANDATORY_FIELDS; i < m_fields->size(); ++i )
|
||||
for( size_t i = MANDATORY_FIELDS; i < m_fields->size(); ++i )
|
||||
{
|
||||
SCH_FIELD& field = m_fields->at( i );
|
||||
wxString fieldName = field.GetName( false );
|
||||
@ -840,8 +840,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
|
||||
|
||||
SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings();
|
||||
int fieldID = (int) m_fields->size();
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_symbol,
|
||||
GetDefaultFieldName( fieldID, DO_TRANSLATE, SCH_SYMBOL_T ) );
|
||||
SCH_FIELD newField( VECTOR2I(), fieldID, m_symbol, GetUserFieldName( fieldID, DO_TRANSLATE ) );
|
||||
|
||||
newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
|
||||
newField.SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
|
||||
@ -874,10 +873,10 @@ void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
|
||||
|
||||
for( int row : selectedRows )
|
||||
{
|
||||
if( row < SYMBOL_MANDATORY_FIELDS )
|
||||
if( row < MANDATORY_FIELDS )
|
||||
{
|
||||
DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
|
||||
SYMBOL_MANDATORY_FIELDS ) );
|
||||
MANDATORY_FIELDS ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -914,7 +913,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
|
||||
|
||||
int i = m_fieldsGrid->GetGridCursorRow();
|
||||
|
||||
if( i > SYMBOL_MANDATORY_FIELDS )
|
||||
if( i > MANDATORY_FIELDS )
|
||||
{
|
||||
SCH_FIELD tmp = m_fields->at( (unsigned) i );
|
||||
m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
|
||||
@ -941,7 +940,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
|
||||
|
||||
int i = m_fieldsGrid->GetGridCursorRow();
|
||||
|
||||
if( i >= SYMBOL_MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 )
|
||||
if( i >= MANDATORY_FIELDS && i < m_fieldsGrid->GetNumberRows() - 1 )
|
||||
{
|
||||
SCH_FIELD tmp = m_fields->at( (unsigned) i );
|
||||
m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
|
||||
|
@ -46,9 +46,9 @@ DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS( SYMBOL_EDIT_FRAME* aPa
|
||||
|
||||
m_parentSymbolReadOnly->SetValue( UnescapeString( m_symbol->GetParent().lock()->GetName() ) );
|
||||
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
m_fieldsBox->Append( GetDefaultFieldName( i, DO_TRANSLATE, SCH_SYMBOL_T ) );
|
||||
m_fieldsBox->Append( GetDefaultFieldName( i, DO_TRANSLATE ) );
|
||||
m_fieldsBox->Check( i, true );
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::updateFieldsList()
|
||||
|
||||
flattenedParent->GetFields( libFields );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
fieldNames.insert( libFields[i]->GetName() );
|
||||
|
||||
libFields.clear(); // flattenedPart is about to go out of scope...
|
||||
@ -96,19 +96,19 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::updateFieldsList()
|
||||
// Load non-mandatory fields from the editor symbol
|
||||
m_symbol->GetFields( libFields );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < libFields.size(); ++i )
|
||||
fieldNames.insert( libFields[i]->GetName() );
|
||||
|
||||
libFields.clear();
|
||||
|
||||
// Update the listbox widget
|
||||
for( unsigned i = m_fieldsBox->GetCount() - 1; i >= SYMBOL_MANDATORY_FIELDS; --i )
|
||||
for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELDS; --i )
|
||||
m_fieldsBox->Delete( i );
|
||||
|
||||
for( const wxString& fieldName : fieldNames )
|
||||
m_fieldsBox->Append( fieldName );
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < m_fieldsBox->GetCount(); ++i )
|
||||
m_fieldsBox->Check( i, true );
|
||||
}
|
||||
|
||||
|
@ -526,10 +526,10 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
||||
FIELDS_EDITOR_GRID_DATA_MODEL dataModel( referenceList );
|
||||
|
||||
// Mandatory fields + quantity virtual field first
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
dataModel.AddColumn( GetCanonicalFieldName( i, SCH_SYMBOL_T ),
|
||||
GetDefaultFieldName( i, DO_TRANSLATE, SCH_SYMBOL_T ), false );
|
||||
dataModel.AddColumn( GetCanonicalFieldName( i ), GetDefaultFieldName( i, DO_TRANSLATE ),
|
||||
false );
|
||||
}
|
||||
|
||||
// User field names in symbols second
|
||||
@ -539,7 +539,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
||||
{
|
||||
SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
|
||||
|
||||
for( int j = SYMBOL_MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
|
||||
for( int j = MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
|
||||
userFieldNames.insert( symbol->GetFields()[j].GetName() );
|
||||
}
|
||||
|
||||
|
@ -296,14 +296,14 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::SetValue( int aRow, int aCol, const wxString
|
||||
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsReference( int aCol )
|
||||
{
|
||||
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
|
||||
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( REFERENCE_FIELD, SCH_SYMBOL_T );
|
||||
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( REFERENCE_FIELD );
|
||||
}
|
||||
|
||||
|
||||
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsValue( int aCol )
|
||||
{
|
||||
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
|
||||
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( VALUE_FIELD, SCH_SYMBOL_T );
|
||||
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( VALUE_FIELD );
|
||||
}
|
||||
|
||||
|
||||
@ -417,7 +417,7 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
||||
const SCH_REFERENCE& rhRef )
|
||||
|
||||
{
|
||||
int refCol = GetFieldNameCol( GetCanonicalFieldName( REFERENCE_FIELD, SCH_SYMBOL_T ) );
|
||||
int refCol = GetFieldNameCol( GetCanonicalFieldName( REFERENCE_FIELD ) );
|
||||
bool matchFound = false;
|
||||
|
||||
if( refCol == -1 )
|
||||
@ -830,7 +830,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
|
||||
}
|
||||
}
|
||||
|
||||
for( int ii = symbol.GetFields().size() - 1; ii >= SYMBOL_MANDATORY_FIELDS; ii-- )
|
||||
for( int ii = symbol.GetFields().size() - 1; ii >= MANDATORY_FIELDS; ii-- )
|
||||
{
|
||||
if( fieldStore.count( symbol.GetFields()[ii].GetName() ) == 0 )
|
||||
{
|
||||
@ -915,7 +915,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyBomPreset( const BOM_PRESET& aPreset )
|
||||
int sortCol = GetFieldNameCol( aPreset.sortField );
|
||||
|
||||
if( sortCol == -1 )
|
||||
sortCol = GetFieldNameCol( GetCanonicalFieldName( REFERENCE_FIELD, SCH_SYMBOL_T ) );
|
||||
sortCol = GetFieldNameCol( GetCanonicalFieldName( REFERENCE_FIELD ) );
|
||||
|
||||
SetSorting( sortCol, aPreset.sortAsc );
|
||||
|
||||
|
@ -135,7 +135,7 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFra
|
||||
m_frame( aFrame ),
|
||||
m_dialog( aDialog ),
|
||||
m_parentType( SCH_SYMBOL_T ),
|
||||
m_mandatoryFieldCount( SYMBOL_MANDATORY_FIELDS ),
|
||||
m_mandatoryFieldCount( MANDATORY_FIELDS ),
|
||||
m_part( aSymbol ),
|
||||
m_symbolNetlist( netList( aSymbol ) ),
|
||||
m_fieldNameValidator( FIELD_NAME ),
|
||||
@ -154,7 +154,7 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFra
|
||||
m_frame( aFrame ),
|
||||
m_dialog( aDialog ),
|
||||
m_parentType( SCH_SYMBOL_T ),
|
||||
m_mandatoryFieldCount( SYMBOL_MANDATORY_FIELDS ),
|
||||
m_mandatoryFieldCount( MANDATORY_FIELDS ),
|
||||
m_part( aSymbol->GetLibSymbolRef().get() ),
|
||||
m_symbolNetlist( netList( aSymbol, aFrame->GetCurrentSheet() ) ),
|
||||
m_fieldNameValidator( FIELD_NAME ),
|
||||
@ -676,14 +676,14 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
|
||||
if( m_parentType == SCH_SYMBOL_T || m_parentType == LIB_SYMBOL_T )
|
||||
{
|
||||
if( aRow < m_mandatoryFieldCount )
|
||||
return GetDefaultFieldName( aRow, DO_TRANSLATE, SCH_SYMBOL_T );
|
||||
return GetDefaultFieldName( aRow, DO_TRANSLATE );
|
||||
else
|
||||
return field.GetName( false );
|
||||
}
|
||||
else if( m_parentType == SCH_SHEET_T )
|
||||
{
|
||||
if( aRow < m_mandatoryFieldCount )
|
||||
return GetDefaultFieldName( aRow, DO_TRANSLATE, SCH_SHEET_T );
|
||||
return SCH_SHEET::GetDefaultFieldName( aRow, DO_TRANSLATE );
|
||||
else
|
||||
return field.GetName( false );
|
||||
}
|
||||
|
@ -105,11 +105,11 @@ LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB*
|
||||
m_options = ENTRY_NORMAL;
|
||||
m_unitsLocked = false;
|
||||
|
||||
// Add the SYMBOL_MANDATORY_FIELDS in RAM only. These are assumed to be present
|
||||
// Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
|
||||
// when the field editors are invoked.
|
||||
m_drawings[SCH_FIELD_T].reserve( SYMBOL_MANDATORY_FIELDS );
|
||||
m_drawings[SCH_FIELD_T].reserve( MANDATORY_FIELDS );
|
||||
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; i++ )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; i++ )
|
||||
m_drawings[SCH_FIELD_T].push_back( new SCH_FIELD( this, i ) );
|
||||
|
||||
// Ensure reference and value fields are visible when creating a lib symbol
|
||||
@ -351,7 +351,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
|
||||
retv->SetLibId( m_libId );
|
||||
|
||||
// Now add the inherited part mandatory field (this) information.
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; i++ )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; i++ )
|
||||
{
|
||||
wxString tmp = GetFieldById( i )->GetText();
|
||||
|
||||
@ -813,7 +813,7 @@ void LIB_SYMBOL::RemoveDrawItem( SCH_ITEM* aItem )
|
||||
{
|
||||
wxASSERT( aItem != nullptr );
|
||||
|
||||
// none of the SYMBOL_MANDATORY_FIELDS may be removed in RAM, but they may be
|
||||
// none of the MANDATORY_FIELDS may be removed in RAM, but they may be
|
||||
// omitted when saving to disk.
|
||||
if( aItem->Type() == SCH_FIELD_T )
|
||||
{
|
||||
@ -1067,8 +1067,8 @@ void LIB_SYMBOL::SetFields( const std::vector<SCH_FIELD>& aFieldsList )
|
||||
|
||||
void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly )
|
||||
{
|
||||
// Grab the SYMBOL_MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int id = 0; id < SYMBOL_MANDATORY_FIELDS; ++id )
|
||||
// Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int id = 0; id < MANDATORY_FIELDS; ++id )
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( id );
|
||||
|
||||
@ -1100,8 +1100,8 @@ void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly )
|
||||
|
||||
void LIB_SYMBOL::CopyFields( std::vector<SCH_FIELD>& aList )
|
||||
{
|
||||
// Grab the SYMBOL_MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int id = 0; id < SYMBOL_MANDATORY_FIELDS; ++id )
|
||||
// Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int id = 0; id < MANDATORY_FIELDS; ++id )
|
||||
aList.push_back( *GetFieldById( id ) );
|
||||
|
||||
// Now grab all the rest of fields.
|
||||
@ -1248,7 +1248,7 @@ void LIB_SYMBOL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunctio
|
||||
int LIB_SYMBOL::UpdateFieldOrdinals()
|
||||
{
|
||||
int retv = 0;
|
||||
int lastOrdinal = SYMBOL_MANDATORY_FIELDS;
|
||||
int lastOrdinal = MANDATORY_FIELDS;
|
||||
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
@ -1273,7 +1273,7 @@ int LIB_SYMBOL::UpdateFieldOrdinals()
|
||||
|
||||
int LIB_SYMBOL::GetNextAvailableFieldId() const
|
||||
{
|
||||
int retv = SYMBOL_MANDATORY_FIELDS;
|
||||
int retv = MANDATORY_FIELDS;
|
||||
|
||||
while( GetFieldById( retv ) )
|
||||
retv += 1;
|
||||
|
@ -160,7 +160,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
description = candidate;
|
||||
|
||||
// All non-mandatory fields
|
||||
for( int ii = SYMBOL_MANDATORY_FIELDS; ii < symbol2->GetFieldCount(); ++ii )
|
||||
for( int ii = MANDATORY_FIELDS; ii < symbol2->GetFieldCount(); ++ii )
|
||||
{
|
||||
const SCH_FIELD& f = symbol2->GetFields()[ ii ];
|
||||
|
||||
@ -197,7 +197,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
else
|
||||
description = descriptionField->GetText();
|
||||
|
||||
for( int ii = SYMBOL_MANDATORY_FIELDS; ii < aSymbol->GetFieldCount(); ++ii )
|
||||
for( int ii = MANDATORY_FIELDS; ii < aSymbol->GetFieldCount(); ++ii )
|
||||
{
|
||||
const SCH_FIELD& f = aSymbol->GetFields()[ ii ];
|
||||
|
||||
@ -208,9 +208,9 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
}
|
||||
}
|
||||
|
||||
fields[GetCanonicalFieldName( FOOTPRINT_FIELD, SCH_SYMBOL_T )] = footprint;
|
||||
fields[GetCanonicalFieldName( DATASHEET_FIELD, SCH_SYMBOL_T )] = datasheet;
|
||||
fields[GetCanonicalFieldName( DESCRIPTION_FIELD, SCH_SYMBOL_T )] = description;
|
||||
fields[GetCanonicalFieldName( FOOTPRINT_FIELD )] = footprint;
|
||||
fields[GetCanonicalFieldName( DATASHEET_FIELD )] = datasheet;
|
||||
fields[GetCanonicalFieldName( DESCRIPTION_FIELD )] = description;
|
||||
|
||||
// Do not output field values blank in netlist:
|
||||
if( value.size() )
|
||||
@ -344,7 +344,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl )
|
||||
|
||||
std::vector<SCH_FIELD>& fields = symbol->GetFields();
|
||||
|
||||
for( size_t jj = SYMBOL_MANDATORY_FIELDS; jj < fields.size(); ++jj )
|
||||
for( size_t jj = MANDATORY_FIELDS; jj < fields.size(); ++jj )
|
||||
{
|
||||
xcomp->AddChild( xproperty = node( wxT( "property" ) ) );
|
||||
xproperty->AddAttribute( wxT( "name" ), fields[jj].GetCanonicalName() );
|
||||
|
@ -72,9 +72,9 @@ SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent,
|
||||
if( !aName.IsEmpty() )
|
||||
SetName( aName );
|
||||
else if( aParent && aParent->Type() == SCH_SYMBOL_T )
|
||||
SetName( GetDefaultFieldName( aFieldId, DO_TRANSLATE, SCH_SYMBOL_T ) );
|
||||
SetName( GetDefaultFieldName( aFieldId, DO_TRANSLATE ) );
|
||||
else if( aParent && aParent->Type() == SCH_SHEET_T )
|
||||
SetName( GetDefaultFieldName( aFieldId, DO_TRANSLATE, SCH_SHEET_T ) );
|
||||
SetName( SCH_SHEET::GetDefaultFieldName( aFieldId, DO_TRANSLATE ) );
|
||||
|
||||
SetTextPos( aPos );
|
||||
SetId( aFieldId ); // will also set the layer
|
||||
@ -1231,16 +1231,16 @@ wxString SCH_FIELD::GetName( bool aUseDefaultName ) const
|
||||
if( m_parent && ( m_parent->Type() == SCH_SYMBOL_T || m_parent->Type() == LIB_SYMBOL_T ) )
|
||||
{
|
||||
if( IsMandatory() )
|
||||
return GetCanonicalFieldName( m_id, SCH_SYMBOL_T );
|
||||
return GetCanonicalFieldName( m_id );
|
||||
else if( m_name.IsEmpty() && aUseDefaultName )
|
||||
return GetDefaultFieldName( m_id, !DO_TRANSLATE, SCH_SYMBOL_T );
|
||||
return GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
if( IsMandatory() )
|
||||
return GetCanonicalFieldName( m_id, SCH_SHEET_T );
|
||||
return SCH_SHEET::GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
else if( m_name.IsEmpty() && aUseDefaultName )
|
||||
return GetDefaultFieldName( m_id, !DO_TRANSLATE, SCH_SHEET_T );
|
||||
return SCH_SHEET::GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
{
|
||||
@ -1256,12 +1256,12 @@ wxString SCH_FIELD::GetCanonicalName() const
|
||||
if( m_parent && ( m_parent->Type() == SCH_SYMBOL_T || m_parent->Type() == LIB_SYMBOL_T ) )
|
||||
{
|
||||
if( IsMandatory() )
|
||||
return GetCanonicalFieldName( m_id, SCH_SYMBOL_T );
|
||||
return GetCanonicalFieldName( m_id );
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
if( IsMandatory() )
|
||||
return GetCanonicalFieldName( m_id, SCH_SHEET_T );
|
||||
return SCH_SHEET::GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
{
|
||||
@ -1509,7 +1509,7 @@ bool SCH_FIELD::IsMandatory() const
|
||||
if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
return m_id >= 0 && m_id < SHEET_MANDATORY_FIELDS;
|
||||
else
|
||||
return m_id >= 0 && m_id < SYMBOL_MANDATORY_FIELDS;
|
||||
return m_id >= 0 && m_id < MANDATORY_FIELDS;
|
||||
}
|
||||
|
||||
|
||||
@ -1590,7 +1590,7 @@ double SCH_FIELD::Similarity( const SCH_ITEM& aOther ) const
|
||||
if( GetId() != field.GetId() )
|
||||
{
|
||||
// We don't allow swapping of mandatory fields, so these cannot be the same item
|
||||
if( GetId() < SYMBOL_MANDATORY_FIELDS || field.GetId() < SYMBOL_MANDATORY_FIELDS )
|
||||
if( GetId() < MANDATORY_FIELDS || field.GetId() < MANDATORY_FIELDS )
|
||||
return 0.0;
|
||||
else
|
||||
similarity *= 0.5;
|
||||
|
@ -1302,7 +1302,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
// The first MANDATOR_FIELDS _must_ be constructed within the SCH_SYMBOL
|
||||
// constructor. This assert is simply here to guard against a change in that
|
||||
// constructor.
|
||||
wxASSERT( symbol->GetFieldCount() >= SYMBOL_MANDATORY_FIELDS );
|
||||
wxASSERT( symbol->GetFieldCount() >= MANDATORY_FIELDS );
|
||||
|
||||
// We need to check for an existing field by name that happens to have the same
|
||||
// name and index as any field that was made mandatory after this point, e.g. Description
|
||||
@ -1313,7 +1313,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
if( !existingField )
|
||||
{
|
||||
// Ignore the _supplied_ fieldNdx. It is not important anymore if within the
|
||||
// user defined fields region (i.e. >= SYMBOL_MANDATORY_FIELDS).
|
||||
// user defined fields region (i.e. >= MANDATORY_FIELDS).
|
||||
// We freely renumber the index to fit the next available field slot.
|
||||
index = symbol->GetFieldCount(); // new has this index after insertion
|
||||
|
||||
@ -1399,7 +1399,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
SCH_PARSE_ERROR( "symbol field orientation must be H or V", aReader, line );
|
||||
|
||||
if( name.IsEmpty() )
|
||||
name = GetDefaultFieldName( index, !DO_TRANSLATE, SCH_SYMBOL_T );
|
||||
name = GetDefaultFieldName( index, !DO_TRANSLATE );
|
||||
|
||||
field.SetName( name );
|
||||
}
|
||||
@ -1755,7 +1755,7 @@ void SCH_IO_KICAD_LEGACY::saveSymbol( SCH_SYMBOL* aSymbol )
|
||||
// Fixed fields:
|
||||
// Save mandatory fields even if they are blank,
|
||||
// because the visibility, size and orientation are set from library editor.
|
||||
for( unsigned i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( unsigned i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
saveField( &aSymbol->GetFields()[i] );
|
||||
|
||||
// User defined fields:
|
||||
@ -1763,7 +1763,7 @@ void SCH_IO_KICAD_LEGACY::saveSymbol( SCH_SYMBOL* aSymbol )
|
||||
// only in the dialog editors. No policy should be enforced here, simply
|
||||
// save all the user defined fields, they are present because a dialog editor
|
||||
// thought they should be. If you disagree, go fix the dialog editors.
|
||||
for( int i = SYMBOL_MANDATORY_FIELDS; i < aSymbol->GetFieldCount(); ++i )
|
||||
for( int i = MANDATORY_FIELDS; i < aSymbol->GetFieldCount(); ++i )
|
||||
saveField( &aSymbol->GetFields()[i] );
|
||||
|
||||
// Unit number, position, box ( old standard )
|
||||
@ -1808,7 +1808,7 @@ void SCH_IO_KICAD_LEGACY::saveField( SCH_FIELD* aField )
|
||||
aField->IsBold() ? 'B' : 'N' );
|
||||
|
||||
// Save field name, if the name is user definable
|
||||
if( aField->GetId() >= SYMBOL_MANDATORY_FIELDS )
|
||||
if( aField->GetId() >= MANDATORY_FIELDS )
|
||||
m_out->Print( 0, " %s", EscapedUTF8( aField->GetName() ).c_str() );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
@ -499,11 +499,11 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadAliases( std::unique_ptr<LIB_SYMBOL>& aS
|
||||
LIB_SYMBOL* newSymbol = new LIB_SYMBOL( newAliasName );
|
||||
|
||||
// Inherit the parent mandatory field attributes.
|
||||
for( int id = 0; id < SYMBOL_MANDATORY_FIELDS; ++id )
|
||||
for( int id = 0; id < MANDATORY_FIELDS; ++id )
|
||||
{
|
||||
SCH_FIELD* field = newSymbol->GetFieldById( id );
|
||||
|
||||
// the SYMBOL_MANDATORY_FIELDS are exactly that in RAM.
|
||||
// the MANDATORY_FIELDS are exactly that in RAM.
|
||||
wxASSERT( field );
|
||||
|
||||
SCH_FIELD* parentField = aSymbol->GetFieldById( id );
|
||||
@ -549,7 +549,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
|
||||
field = aSymbol->GetFieldById( id );
|
||||
|
||||
// this will fire only if somebody broke a constructor or editor.
|
||||
// SYMBOL_MANDATORY_FIELDS are always present in ram resident symbols, no
|
||||
// MANDATORY_FIELDS are always present in ram resident symbols, no
|
||||
// exceptions, and they always have their names set, even fixed fields.
|
||||
wxASSERT( field );
|
||||
}
|
||||
@ -662,12 +662,12 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
|
||||
}
|
||||
|
||||
// Fields in RAM must always have names.
|
||||
if( id >= 0 && id < SYMBOL_MANDATORY_FIELDS )
|
||||
if( id >= 0 && id < MANDATORY_FIELDS )
|
||||
{
|
||||
// Fields in RAM must always have names, because we are trying to get
|
||||
// less dependent on field ids and more dependent on names.
|
||||
// Plus assumptions are made in the field editors.
|
||||
field->SetName( GetCanonicalFieldName( id, SCH_SYMBOL_T ) );
|
||||
field->SetName( GetCanonicalFieldName( id ) );
|
||||
|
||||
// Ensure the VALUE field = the symbol name (can be not the case
|
||||
// with malformed libraries: edited by hand, or converted from other tools)
|
||||
@ -1525,14 +1525,14 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA
|
||||
// may have their own save policy so there is a separate loop for them.
|
||||
// Empty fields are saved, because the user may have set visibility,
|
||||
// size and orientation
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
saveField( fields[i], aFormatter );
|
||||
|
||||
// User defined fields:
|
||||
// may have their own save policy so there is a separate loop for them.
|
||||
int fieldId = SYMBOL_MANDATORY_FIELDS; // really wish this would go away.
|
||||
int fieldId = MANDATORY_FIELDS; // really wish this would go away.
|
||||
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < fields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
|
||||
{
|
||||
// There is no need to save empty fields, i.e. no reason to preserve field
|
||||
// names now that fields names come in dynamically through the template
|
||||
@ -1719,13 +1719,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField,
|
||||
|
||||
// Translated names were stored in legacy files, so it's important not to save the
|
||||
// default names as they weren't yet canonical.
|
||||
//
|
||||
// Legacy files only had symbol fields, so we don't have to worry about sheet or label
|
||||
// fields here.
|
||||
//
|
||||
if( id >= SYMBOL_MANDATORY_FIELDS
|
||||
if( id >= MANDATORY_FIELDS
|
||||
&& !aField->GetName().IsEmpty()
|
||||
&& aField->GetName() != GetDefaultFieldName( id, !DO_TRANSLATE, SCH_SYMBOL_T ) )
|
||||
&& aField->GetName() != GetUserFieldName( id, !DO_TRANSLATE ) )
|
||||
{
|
||||
aFormatter.Print( 0, " %s", EscapedUTF8( aField->GetName() ).c_str() );
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ void SCH_IO_KICAD_SEXPR::init( SCHEMATIC* aSchematic, const std::map<std::string
|
||||
m_schematic = aSchematic;
|
||||
m_cache = nullptr;
|
||||
m_out = nullptr;
|
||||
m_nextFreeFieldId = 100; // number arbitrarily > SYMBOL_MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
|
||||
m_nextFreeFieldId = 100; // number arbitrarily > MANDATORY_FIELDS or SHEET_MANDATORY_FIELDS
|
||||
}
|
||||
|
||||
|
||||
@ -741,7 +741,7 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aSymbol->m_Uuid );
|
||||
|
||||
m_nextFreeFieldId = SYMBOL_MANDATORY_FIELDS;
|
||||
m_nextFreeFieldId = MANDATORY_FIELDS;
|
||||
|
||||
for( SCH_FIELD& field : aSymbol->GetFields() )
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
|
||||
else
|
||||
aSymbol->GetEmbeddedFiles()->ClearEmbeddedFonts();
|
||||
|
||||
int nextFreeFieldId = SYMBOL_MANDATORY_FIELDS;
|
||||
int nextFreeFieldId = MANDATORY_FIELDS;
|
||||
std::vector<SCH_FIELD*> fields;
|
||||
std::string name = aFormatter.Quotew( aSymbol->GetLibId().GetLibItemName().wx_str() );
|
||||
std::string unitName = aSymbol->GetLibId().GetLibItemName();
|
||||
@ -408,10 +408,8 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField( SCH_FIELD* aField, OUTPUTFORMATTER
|
||||
|
||||
wxString fieldName = aField->GetName();
|
||||
|
||||
// We're in the library cache, which means this can't be a sheet or a label field.
|
||||
|
||||
if( aField->IsMandatory() )
|
||||
fieldName = GetCanonicalFieldName( aField->GetId(), SCH_SYMBOL_T );
|
||||
fieldName = GetCanonicalFieldName( aField->GetId() );
|
||||
|
||||
aFormatter.Print( "(property %s %s %s (at %s %s %g)",
|
||||
aField->IsPrivate() ? "private" : "",
|
||||
|
@ -314,7 +314,7 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi
|
||||
// Make sure the mandatory field IDs are reserved as already read,
|
||||
// the field parser will set the field IDs to the correct value if
|
||||
// the field name matches a mandatory field name
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; i++ )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; i++ )
|
||||
m_fieldIDsRead.insert( i );
|
||||
|
||||
token = NextTok();
|
||||
@ -957,7 +957,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
|
||||
wxString name;
|
||||
wxString value;
|
||||
auto field = std::make_unique<SCH_FIELD>( aSymbol.get(), SYMBOL_MANDATORY_FIELDS );
|
||||
auto field = std::make_unique<SCH_FIELD>( aSymbol.get(), MANDATORY_FIELDS );
|
||||
|
||||
// By default, fieds are visible.
|
||||
// Invisible fields have the hide style or keyword specified in file
|
||||
@ -989,9 +989,9 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
|
||||
// Correctly set the ID based on canonical (untranslated) field name
|
||||
// If ID is stored in the file (old versions), it will overwrite this
|
||||
for( int ii = 0; ii < SYMBOL_MANDATORY_FIELDS; ++ii )
|
||||
for( int ii = 0; ii < MANDATORY_FIELDS; ++ii )
|
||||
{
|
||||
if( !name.CmpNoCase( GetCanonicalFieldName( ii, SCH_SYMBOL_T ) ) )
|
||||
if( !name.CmpNoCase( GetCanonicalFieldName( ii ) ) )
|
||||
{
|
||||
field->SetId( ii );
|
||||
break;
|
||||
@ -1025,8 +1025,8 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
{
|
||||
int id = parseInt( "field ID" );
|
||||
|
||||
// Only set an ID that isn't a SYMBOL_MANDATORY_FIELDS ID
|
||||
if( id >= SYMBOL_MANDATORY_FIELDS )
|
||||
// Only set an ID that isn't a MANDATORY_FIELDS ID
|
||||
if( id >= MANDATORY_FIELDS )
|
||||
field->SetId( id );
|
||||
|
||||
NeedRIGHT();
|
||||
@ -1064,7 +1064,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
|
||||
// Due to an bug when in #LIB_SYMBOL::Flatten, duplicate ids slipped through when writing
|
||||
// files. This section replaces duplicate #SCH_FIELD indices on load.
|
||||
if( field->GetId() >= SYMBOL_MANDATORY_FIELDS && m_fieldIDsRead.count( field->GetId() ) )
|
||||
if( ( field->GetId() >= MANDATORY_FIELDS ) && m_fieldIDsRead.count( field->GetId() ) )
|
||||
{
|
||||
int nextAvailableId = field->GetId() + 1;
|
||||
|
||||
@ -2217,7 +2217,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
||||
int mandatoryFieldCount = 0;
|
||||
|
||||
if( aParent->Type() == SCH_SYMBOL_T )
|
||||
mandatoryFieldCount = SYMBOL_MANDATORY_FIELDS;
|
||||
mandatoryFieldCount = MANDATORY_FIELDS;
|
||||
else if( aParent->Type() == SCH_SHEET_T )
|
||||
mandatoryFieldCount = SHEET_MANDATORY_FIELDS;
|
||||
|
||||
@ -2232,9 +2232,9 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
||||
// If ID is stored in the file (old versions), it will overwrite this
|
||||
if( aParent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
for( int ii = 0; ii < SYMBOL_MANDATORY_FIELDS; ++ii )
|
||||
for( int ii = 0; ii < MANDATORY_FIELDS; ++ii )
|
||||
{
|
||||
if( name == GetCanonicalFieldName( ii, SCH_SYMBOL_T ) )
|
||||
if( name == GetCanonicalFieldName( ii ) )
|
||||
{
|
||||
field->SetId( ii );
|
||||
field->SetPrivate( false );
|
||||
@ -2246,7 +2246,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
||||
{
|
||||
for( int ii = 0; ii < SHEET_MANDATORY_FIELDS; ++ii )
|
||||
{
|
||||
if( name == GetDefaultFieldName( ii, !DO_TRANSLATE, SCH_SHEET_T ) )
|
||||
if( name == SCH_SHEET::GetDefaultFieldName( ii, !DO_TRANSLATE ) )
|
||||
{
|
||||
field->SetId( ii );
|
||||
field->SetPrivate( false );
|
||||
@ -2974,7 +2974,7 @@ SCH_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol()
|
||||
// Make sure the mandatory field IDs are reserved as already read,
|
||||
// the field parser will set the field IDs to the correct value if
|
||||
// the field name matches a mandatory field name
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; i++ )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; i++ )
|
||||
m_fieldIDsRead.insert( i );
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
@ -3258,8 +3258,7 @@ SCH_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol()
|
||||
break;
|
||||
}
|
||||
|
||||
if( ( field->GetId() >= SYMBOL_MANDATORY_FIELDS )
|
||||
&& m_fieldIDsRead.count( field->GetId() ) )
|
||||
if( ( field->GetId() >= MANDATORY_FIELDS ) && m_fieldIDsRead.count( field->GetId() ) )
|
||||
{
|
||||
int nextAvailableId = field->GetId() + 1;
|
||||
|
||||
|
@ -48,6 +48,37 @@
|
||||
#include <pgm_base.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
// N.B. Do not change these values without transitioning the file format
|
||||
#define SHEET_NAME_CANONICAL "Sheetname"
|
||||
#define SHEET_FILE_CANONICAL "Sheetfile"
|
||||
#define USER_FIELD_CANONICAL "Field%d"
|
||||
|
||||
static wxString s_CanonicalSheetName( SHEET_NAME_CANONICAL );
|
||||
static wxString s_CanonicalSheetFile( SHEET_FILE_CANONICAL );
|
||||
|
||||
const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx, bool aTranslated )
|
||||
{
|
||||
if( !aTranslated )
|
||||
{
|
||||
switch( aFieldNdx )
|
||||
{
|
||||
case SHEETNAME: return s_CanonicalSheetName;
|
||||
case SHEETFILENAME: return s_CanonicalSheetFile;
|
||||
default: return wxString::Format( wxS( USER_FIELD_CANONICAL ), aFieldNdx );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( aFieldNdx )
|
||||
{
|
||||
case SHEETNAME: return _( SHEET_NAME_CANONICAL );
|
||||
case SHEETFILENAME: return _( SHEET_FILE_CANONICAL );
|
||||
default: return wxString::Format( _( USER_FIELD_CANONICAL ), aFieldNdx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const VECTOR2I& aPos, VECTOR2I aSize ) :
|
||||
SCH_ITEM( aParent, SCH_SHEET_T ),
|
||||
m_excludedFromSim( false ),
|
||||
@ -65,18 +96,13 @@ SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const VECTOR2I& aPos, VECTOR2I aSize )
|
||||
m_backgroundColor = COLOR4D::UNSPECIFIED;
|
||||
m_fieldsAutoplaced = AUTOPLACE_AUTO;
|
||||
|
||||
for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
m_fields.emplace_back( aPos, i, this, GetDefaultFieldName( i, DO_TRANSLATE, SCH_SHEET_T ) );
|
||||
m_fields.back().SetVisible( true );
|
||||
m_fields.emplace_back( aPos, SHEETNAME, this, GetDefaultFieldName( SHEETNAME, DO_TRANSLATE ) );
|
||||
m_fields.back().SetVisible( true );
|
||||
m_fields.back().SetLayer( LAYER_SHEETNAME );
|
||||
|
||||
if( i == SHEETNAME )
|
||||
m_fields.back().SetLayer( LAYER_SHEETNAME );
|
||||
else if( i == SHEETFILENAME )
|
||||
m_fields.back().SetLayer( LAYER_SHEETFILENAME );
|
||||
else
|
||||
m_fields.back().SetLayer( LAYER_SHEETFIELDS );
|
||||
}
|
||||
m_fields.emplace_back( aPos, SHEETFILENAME, this, GetDefaultFieldName( SHEETFILENAME, DO_TRANSLATE ) );
|
||||
m_fields.back().SetVisible( true );
|
||||
m_fields.back().SetLayer( LAYER_SHEETNAME );
|
||||
|
||||
AutoplaceFields( nullptr, m_fieldsAutoplaced );
|
||||
}
|
||||
|
@ -40,6 +40,16 @@ class EDA_DRAW_FRAME;
|
||||
#define MIN_SHEET_HEIGHT 150 // Units are mils.
|
||||
|
||||
|
||||
enum SHEET_FIELD_TYPE
|
||||
{
|
||||
SHEETNAME = 0,
|
||||
SHEETFILENAME,
|
||||
|
||||
/// The first 2 are mandatory, and must be instantiated in SCH_SHEET
|
||||
SHEET_MANDATORY_FIELDS
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
|
||||
*/
|
||||
@ -456,6 +466,8 @@ public:
|
||||
void Show( int nestLevel, std::ostream& os ) const override;
|
||||
#endif
|
||||
|
||||
static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslated );
|
||||
|
||||
protected:
|
||||
friend SCH_SHEET_PATH;
|
||||
friend SCH_IO_KICAD_SEXPR_PARSER;
|
||||
|
@ -181,18 +181,19 @@ void SCH_SYMBOL::Init( const VECTOR2I& pos )
|
||||
// The rotation/mirror transformation matrix. pos normal
|
||||
m_transform = TRANSFORM();
|
||||
|
||||
// construct only the mandatory fields, which are the first 4 only.
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
m_fields.emplace_back( pos, i, this, GetCanonicalFieldName( i, SCH_SYMBOL_T ) );
|
||||
auto addField =
|
||||
[&]( int id, SCH_LAYER_ID layer )
|
||||
{
|
||||
m_fields.emplace_back( pos, id, this, GetCanonicalFieldName( id ) );
|
||||
m_fields.back().SetLayer( layer );
|
||||
};
|
||||
|
||||
if( i == REFERENCE_FIELD )
|
||||
m_fields.back().SetLayer( LAYER_REFERENCEPART );
|
||||
else if( i == VALUE_FIELD )
|
||||
m_fields.back().SetLayer( LAYER_VALUEPART );
|
||||
else
|
||||
m_fields.back().SetLayer( LAYER_FIELDS );
|
||||
}
|
||||
// construct only the mandatory fields
|
||||
addField( REFERENCE_FIELD, LAYER_REFERENCEPART );
|
||||
addField( VALUE_FIELD, LAYER_VALUEPART );
|
||||
addField( FOOTPRINT_FIELD, LAYER_FIELDS );
|
||||
addField( DATASHEET_FIELD, LAYER_FIELDS );
|
||||
addField( DESCRIPTION_FIELD, LAYER_FIELDS );
|
||||
|
||||
m_prefix = wxString( wxT( "U" ) );
|
||||
m_isInNetlist = true;
|
||||
@ -974,7 +975,7 @@ SCH_FIELD* SCH_SYMBOL::AddField( const SCH_FIELD& aField )
|
||||
|
||||
void SCH_SYMBOL::RemoveField( const wxString& aFieldName )
|
||||
{
|
||||
for( unsigned i = SYMBOL_MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||
for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||
{
|
||||
if( aFieldName == m_fields[i].GetName( false ) )
|
||||
{
|
||||
@ -988,7 +989,7 @@ void SCH_SYMBOL::RemoveField( const wxString& aFieldName )
|
||||
SCH_FIELD* SCH_SYMBOL::FindField( const wxString& aFieldName, bool aIncludeDefaultFields,
|
||||
bool aCaseInsensitive )
|
||||
{
|
||||
unsigned start = aIncludeDefaultFields ? 0 : SYMBOL_MANDATORY_FIELDS;
|
||||
unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
|
||||
|
||||
for( unsigned i = start; i < m_fields.size(); ++i )
|
||||
{
|
||||
@ -1356,10 +1357,10 @@ void SCH_SYMBOL::SwapData( SCH_ITEM* aItem )
|
||||
|
||||
void SCH_SYMBOL::GetContextualTextVars( wxArrayString* aVars ) const
|
||||
{
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
|
||||
|
||||
for( size_t i = SYMBOL_MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||
for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||
aVars->push_back( m_fields[i].GetName() );
|
||||
|
||||
aVars->push_back( wxT( "OP" ) );
|
||||
@ -1470,7 +1471,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i
|
||||
|
||||
wxString upperToken = token->Upper();
|
||||
|
||||
for( int i = 0; i < SYMBOL_MANDATORY_FIELDS; ++i )
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
wxString field = m_fields[i].GetCanonicalName();
|
||||
|
||||
@ -1493,7 +1494,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i
|
||||
}
|
||||
}
|
||||
|
||||
for( size_t i = SYMBOL_MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||
for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||
{
|
||||
wxString field = m_fields[ i ].GetName();
|
||||
|
||||
|
@ -474,7 +474,7 @@ void SIM_MODEL::WriteFields( std::vector<SCH_FIELD>& aFields ) const
|
||||
if( IsStoredInValue() )
|
||||
SetFieldValue( aFields, SIM_VALUE_FIELD, m_serializer->GenerateValue(), false );
|
||||
|
||||
int lastFreeId = SYMBOL_MANDATORY_FIELDS;
|
||||
int lastFreeId = MANDATORY_FIELDS;
|
||||
|
||||
// Search for the first available value:
|
||||
for( auto& fld : aFields )
|
||||
|
@ -433,11 +433,11 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol( const wxString& aInheritFrom )
|
||||
new_symbol.SetParent( parent );
|
||||
|
||||
// Inherit the parent mandatory field attributes.
|
||||
for( int id = 0; id < SYMBOL_MANDATORY_FIELDS; ++id )
|
||||
for( int id = 0; id < MANDATORY_FIELDS; ++id )
|
||||
{
|
||||
SCH_FIELD* field = new_symbol.GetFieldById( id );
|
||||
|
||||
// the SYMBOL_MANDATORY_FIELDS are exactly that in RAM.
|
||||
// the MANDATORY_FIELDS are exactly that in RAM.
|
||||
wxCHECK( field, /* void */ );
|
||||
|
||||
SCH_FIELD* parentField = parent->GetFieldById( id );
|
||||
|
@ -491,8 +491,8 @@ void BACK_ANNOTATE::applyChangelist()
|
||||
SCH_FIELD* symField = symbol->FindField( fpFieldName );
|
||||
|
||||
// Skip fields that are individually controlled
|
||||
if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD, PCB_FOOTPRINT_T )
|
||||
|| fpFieldName == GetCanonicalFieldName( VALUE_FIELD, PCB_FOOTPRINT_T ) )
|
||||
if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD )
|
||||
|| fpFieldName == GetCanonicalFieldName( VALUE_FIELD ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1774,7 +1774,7 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
|
||||
// Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
|
||||
if( parentType == SCH_SYMBOL_T && aField->IsMandatory() )
|
||||
{
|
||||
wxString fieldName = GetDefaultFieldName( aField->GetId(), DO_TRANSLATE, SCH_SYMBOL_T );
|
||||
wxString fieldName = GetDefaultFieldName( aField->GetId(), DO_TRANSLATE );
|
||||
caption.Printf( _( "Edit %s Field" ), TitleCaps( fieldName ) );
|
||||
}
|
||||
else if( parentType == SCH_SHEET_T && aField->IsMandatory() )
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user