Get rid of assumptions about field order.
This commit is contained in:
@@ -37,6 +37,9 @@ using namespace TFIELD_T;
|
||||
#define FOOTPRINT_CANONICAL "Footprint"
|
||||
#define DATASHEET_CANONICAL "Datasheet"
|
||||
#define DESCRIPTION_CANONICAL "Description"
|
||||
#define SHEET_NAME_CANONICAL "Sheetname"
|
||||
#define SHEET_FILE_CANONICAL "Sheetfile"
|
||||
#define INTERSHEET_REFS_CANONICAL "Intersheetrefs"
|
||||
#define USER_FIELD_CANONICAL "Field%d"
|
||||
|
||||
static wxString s_CanonicalReference( REFERENCE_CANONICAL );
|
||||
@@ -44,32 +47,41 @@ 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 );
|
||||
static wxString s_CanonicalIntersheetRefs( INTERSHEET_REFS_CANONICAL );
|
||||
|
||||
|
||||
wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI )
|
||||
wxString GetDefaultFieldName( FIELD_T aFieldId, bool aTranslateForHI )
|
||||
{
|
||||
if( !aTranslateForHI )
|
||||
{
|
||||
switch( aFieldNdx )
|
||||
switch( aFieldId )
|
||||
{
|
||||
case REFERENCE_FIELD: return s_CanonicalReference; // The symbol reference, R1, C1, etc.
|
||||
case VALUE_FIELD: return s_CanonicalValue; // The symbol value
|
||||
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 );
|
||||
case FIELD_T::REFERENCE: return s_CanonicalReference; // The symbol reference, R1, C1, etc.
|
||||
case FIELD_T::VALUE: return s_CanonicalValue; // The symbol value
|
||||
case FIELD_T::FOOTPRINT: return s_CanonicalFootprint; // The footprint for use with Pcbnew
|
||||
case FIELD_T::DATASHEET: return s_CanonicalDatasheet; // Link to a datasheet for symbol
|
||||
case FIELD_T::DESCRIPTION: return s_CanonicalDescription; // The symbol description
|
||||
case FIELD_T::SHEET_NAME: return s_CanonicalSheetName;
|
||||
case FIELD_T::SHEET_FILENAME: return s_CanonicalSheetFile;
|
||||
case FIELD_T::INTERSHEET_REFS: return s_CanonicalIntersheetRefs;
|
||||
default: return GetUserFieldName( 42, aTranslateForHI );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( aFieldNdx )
|
||||
switch( aFieldId )
|
||||
{
|
||||
case REFERENCE_FIELD: return _( REFERENCE_CANONICAL ); // The symbol reference, R1, C1, etc.
|
||||
case VALUE_FIELD: return _( VALUE_CANONICAL ); // The symbol value
|
||||
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 );
|
||||
case FIELD_T::REFERENCE: return _( REFERENCE_CANONICAL ); // The symbol reference, R1, C1, etc.
|
||||
case FIELD_T::VALUE: return _( VALUE_CANONICAL ); // The symbol value
|
||||
case FIELD_T::FOOTPRINT: return _( FOOTPRINT_CANONICAL ); // The footprint for use with Pcbnew
|
||||
case FIELD_T::DATASHEET: return _( DATASHEET_CANONICAL ); // Link to a datasheet for symbol
|
||||
case FIELD_T::DESCRIPTION: return _( DESCRIPTION_CANONICAL ); // The symbol description
|
||||
case FIELD_T::SHEET_NAME: return _( SHEET_NAME_CANONICAL );
|
||||
case FIELD_T::SHEET_FILENAME: return _( SHEET_FILE_CANONICAL );
|
||||
case FIELD_T::INTERSHEET_REFS: return _( INTERSHEET_REFS_CANONICAL );
|
||||
default: return GetUserFieldName( 42, aTranslateForHI );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,7 +248,7 @@ void TEMPLATES::resolveTemplates()
|
||||
void TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal )
|
||||
{
|
||||
// Ensure that the template fieldname does not match a fixed fieldname.
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
if( GetCanonicalFieldName( fieldId ) == aFieldName.m_Name )
|
||||
return;
|
||||
|
||||
+26
-92
@@ -53,32 +53,6 @@ FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) :
|
||||
}
|
||||
|
||||
|
||||
FILE_NAME_WITH_PATH_CHAR_VALIDATOR::FILE_NAME_WITH_PATH_CHAR_VALIDATOR( wxString* aValue ) :
|
||||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST | wxFILTER_EMPTY, aValue )
|
||||
{
|
||||
// The Windows (DOS) file system forbidden characters already include the forbidden
|
||||
// file name characters for both Posix and OSX systems. The characters *?|"<> are
|
||||
// illegal and filtered by the validator, but /\: are valid (\ and : only on Windows.
|
||||
wxString illegalChars = wxFileName::GetForbiddenChars( wxPATH_DOS );
|
||||
wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST );
|
||||
wxArrayString illegalCharList;
|
||||
|
||||
for( unsigned i = 0; i < illegalChars.size(); i++ )
|
||||
{
|
||||
if( illegalChars[i] == '/' )
|
||||
continue;
|
||||
|
||||
#if defined (__WINDOWS__)
|
||||
if( illegalChars[i] == '\\' || illegalChars[i] == ':' )
|
||||
continue;
|
||||
#endif
|
||||
illegalCharList.Add( wxString( illegalChars[i] ) );
|
||||
}
|
||||
|
||||
SetExcludes( illegalCharList );
|
||||
}
|
||||
|
||||
|
||||
ENV_VAR_NAME_VALIDATOR::ENV_VAR_NAME_VALIDATOR( wxString* aValue ) :
|
||||
wxTextValidator()
|
||||
{
|
||||
@@ -191,57 +165,6 @@ void ENV_VAR_NAME_VALIDATOR::OnTextChanged( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
bool REGEX_VALIDATOR::Validate( wxWindow* aParent )
|
||||
{
|
||||
// If window is disabled, simply return
|
||||
if( !m_validatorWindow->IsEnabled() )
|
||||
return true;
|
||||
|
||||
wxTextEntry* const textEntry = GetTextEntry();
|
||||
|
||||
if( !textEntry )
|
||||
return false;
|
||||
|
||||
bool valid = true;
|
||||
const wxString& value = textEntry->GetValue();
|
||||
|
||||
if( m_regEx.Matches( value ) )
|
||||
{
|
||||
size_t start, len;
|
||||
m_regEx.GetMatch( &start, &len );
|
||||
|
||||
if( start != 0 || len != value.Length() ) // whole string must match
|
||||
valid = false;
|
||||
}
|
||||
else // no match at all
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if( !valid )
|
||||
{
|
||||
m_validatorWindow->SetFocus();
|
||||
DisplayErrorMessage( aParent, wxString::Format( _( "Incorrect value: %s" ), value ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void REGEX_VALIDATOR::compileRegEx( const wxString& aRegEx, int aFlags )
|
||||
{
|
||||
if( !m_regEx.Compile( aRegEx, aFlags ) )
|
||||
{
|
||||
throw std::runtime_error( "REGEX_VALIDATOR: Invalid regular expression: "
|
||||
+ aRegEx.ToStdString() );
|
||||
}
|
||||
|
||||
m_regExString = aRegEx;
|
||||
m_regExFlags = aFlags;
|
||||
}
|
||||
|
||||
|
||||
NETNAME_VALIDATOR::NETNAME_VALIDATOR( wxString *aVal ) :
|
||||
wxTextValidator(),
|
||||
m_allowSpaces( false )
|
||||
@@ -310,18 +233,19 @@ void KIUI::ValidatorTransferToWindowWithoutEvents( wxValidator& aValidator )
|
||||
}
|
||||
|
||||
|
||||
FIELD_VALIDATOR::FIELD_VALIDATOR( int aFieldId, wxString* aValue ) :
|
||||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ), m_fieldId( aFieldId )
|
||||
FIELD_VALIDATOR::FIELD_VALIDATOR( FIELD_T aFieldId, wxString* aValue ) :
|
||||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ),
|
||||
m_fieldId( aFieldId )
|
||||
{
|
||||
// Fields cannot contain carriage returns, line feeds, or tabs.
|
||||
wxString excludes( wxT( "\r\n\t" ) );
|
||||
|
||||
// The reference and sheet name fields cannot contain spaces.
|
||||
if( aFieldId == REFERENCE_FIELD )
|
||||
if( aFieldId == FIELD_T::REFERENCE )
|
||||
{
|
||||
excludes += wxT( " " );
|
||||
}
|
||||
else if( m_fieldId == SHEETNAME_V )
|
||||
else if( m_fieldId == FIELD_T::SHEET_NAME )
|
||||
{
|
||||
excludes += wxT( "/" );
|
||||
}
|
||||
@@ -329,7 +253,9 @@ FIELD_VALIDATOR::FIELD_VALIDATOR( int aFieldId, wxString* aValue ) :
|
||||
long style = GetStyle();
|
||||
|
||||
// The reference, sheetname and sheetfilename fields cannot be empty.
|
||||
if( aFieldId == REFERENCE_FIELD || aFieldId == SHEETNAME_V || aFieldId == SHEETFILENAME_V )
|
||||
if( aFieldId == FIELD_T::REFERENCE
|
||||
|| aFieldId == FIELD_T::SHEET_NAME
|
||||
|| aFieldId == FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
style |= wxFILTER_EMPTY;
|
||||
}
|
||||
@@ -340,7 +266,8 @@ FIELD_VALIDATOR::FIELD_VALIDATOR( int aFieldId, wxString* aValue ) :
|
||||
|
||||
|
||||
FIELD_VALIDATOR::FIELD_VALIDATOR( const FIELD_VALIDATOR& aValidator ) :
|
||||
wxTextValidator( aValidator ), m_fieldId( aValidator.m_fieldId )
|
||||
wxTextValidator( aValidator ),
|
||||
m_fieldId( aValidator.m_fieldId )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -367,7 +294,14 @@ bool FIELD_VALIDATOR::DoValidate( const wxString& aValue, wxWindow* aParent )
|
||||
wxString msg;
|
||||
|
||||
if( HasFlag( wxFILTER_EMPTY ) && aValue.empty() )
|
||||
msg.Printf( _( "The value of the field cannot be empty." ) );
|
||||
{
|
||||
switch( m_fieldId )
|
||||
{
|
||||
case FIELD_T::SHEET_NAME: msg = _( "A sheet must have a name." ); break;
|
||||
case FIELD_T::SHEET_FILENAME: msg = _( "A sheet must have a file specified." ); break;
|
||||
default: msg = _( "The value of the field cannot be empty." ); break;
|
||||
}
|
||||
}
|
||||
|
||||
if( HasFlag( wxFILTER_EXCLUDE_CHAR_LIST ) && ContainsExcludedCharacters( aValue ) )
|
||||
{
|
||||
@@ -414,27 +348,27 @@ bool FIELD_VALIDATOR::DoValidate( const wxString& aValue, wxWindow* aParent )
|
||||
|
||||
switch( m_fieldId )
|
||||
{
|
||||
case REFERENCE_FIELD:
|
||||
case FIELD_T::REFERENCE:
|
||||
msg.Printf( _( "The reference designator cannot contain %s character(s)." ), badChars );
|
||||
break;
|
||||
|
||||
case VALUE_FIELD:
|
||||
case FIELD_T::VALUE:
|
||||
msg.Printf( _( "The value field cannot contain %s character(s)." ), badChars );
|
||||
break;
|
||||
|
||||
case FOOTPRINT_FIELD:
|
||||
case FIELD_T::FOOTPRINT:
|
||||
msg.Printf( _( "The footprint field cannot contain %s character(s)." ), badChars );
|
||||
break;
|
||||
|
||||
case DATASHEET_FIELD:
|
||||
case FIELD_T::DATASHEET:
|
||||
msg.Printf( _( "The datasheet field cannot contain %s character(s)." ), badChars );
|
||||
break;
|
||||
|
||||
case SHEETNAME_V:
|
||||
case FIELD_T::SHEET_NAME:
|
||||
msg.Printf( _( "The sheet name cannot contain %s character(s)." ), badChars );
|
||||
break;
|
||||
|
||||
case SHEETFILENAME_V:
|
||||
case FIELD_T::SHEET_FILENAME:
|
||||
msg.Printf( _( "The sheet filename cannot contain %s character(s)." ), badChars );
|
||||
break;
|
||||
|
||||
@@ -443,11 +377,11 @@ bool FIELD_VALIDATOR::DoValidate( const wxString& aValue, wxWindow* aParent )
|
||||
break;
|
||||
};
|
||||
}
|
||||
else if( m_fieldId == REFERENCE_FIELD && aValue.Contains( wxT( "${" ) ) )
|
||||
else if( m_fieldId == FIELD_T::REFERENCE && aValue.Contains( wxT( "${" ) ) )
|
||||
{
|
||||
msg.Printf( _( "The reference designator cannot contain text variable references" ) );
|
||||
}
|
||||
else if( m_fieldId == REFERENCE_FIELD && UTIL::GetRefDesPrefix( aValue ).IsEmpty() )
|
||||
else if( m_fieldId == FIELD_T::REFERENCE && UTIL::GetRefDesPrefix( aValue ).IsEmpty() )
|
||||
{
|
||||
msg.Printf( _( "References must start with a letter." ) );
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ std::unordered_set<SCH_SYMBOL*> getInferredSymbols( const EE_SELECTION& aSelecti
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD && field->GetParent()->Type() == SCH_SYMBOL_T )
|
||||
if( field->GetId() == FIELD_T::REFERENCE && field->GetParent()->Type() == SCH_SYMBOL_T )
|
||||
symbols.insert( static_cast<SCH_SYMBOL*>( field->GetParent() ) );
|
||||
|
||||
break;
|
||||
|
||||
@@ -301,7 +301,7 @@ void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems,
|
||||
case SCH_SYMBOL_T:
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
||||
wxString ref = symbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
wxString ref = symbol->GetField( FIELD_T::REFERENCE )->GetText();
|
||||
|
||||
parts.push_back( wxT( "F" ) + EscapeString( ref, CTX_IPC ) );
|
||||
break;
|
||||
|
||||
@@ -308,15 +308,14 @@ void SCH_EDIT_FRAME::SaveSheetAsDesignBlock( const wxString& aLibraryName,
|
||||
blk.SetLibId( LIB_ID( aLibraryName, fn.GetName() ) );
|
||||
|
||||
// Copy all fields from the sheet to the design block
|
||||
std::vector<SCH_FIELD>& shFields = aSheetPath.Last()->GetFields();
|
||||
nlohmann::ordered_map<wxString, wxString> dbFields;
|
||||
|
||||
for( int i = 0; i < (int) shFields.size(); i++ )
|
||||
for( SCH_FIELD& field : aSheetPath.Last()->GetFields() )
|
||||
{
|
||||
if( i == SHEETNAME || i == SHEETFILENAME )
|
||||
if( field.IsMandatory() )
|
||||
continue;
|
||||
|
||||
dbFields[shFields[i].GetCanonicalName()] = shFields[i].GetText();
|
||||
dbFields[field.GetCanonicalName()] = field.GetText();
|
||||
}
|
||||
|
||||
blk.SetFields( dbFields );
|
||||
|
||||
@@ -79,8 +79,7 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_SYMBO
|
||||
|
||||
m_newId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
|
||||
m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) );
|
||||
m_specifiedValue->ChangeValue(
|
||||
UnescapeString( m_symbol->GetField( VALUE_FIELD )->GetText() ) );
|
||||
m_specifiedValue->ChangeValue( UnescapeString( m_symbol->GetField( FIELD_T::VALUE )->GetText() ) );
|
||||
m_specifiedId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
|
||||
}
|
||||
else
|
||||
@@ -101,16 +100,20 @@ 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 < MANDATORY_FIELD_COUNT; ++i )
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
m_fieldsBox->Append( GetDefaultFieldName( i, DO_TRANSLATE ) );
|
||||
int listIdx = m_fieldsBox->GetCount();
|
||||
|
||||
if( i == REFERENCE_FIELD )
|
||||
m_fieldsBox->Check( i, g_selectRefDes );
|
||||
else if( i == VALUE_FIELD )
|
||||
m_fieldsBox->Check( i, g_selectValue );
|
||||
m_fieldsBox->Append( GetDefaultFieldName( fieldId, DO_TRANSLATE ) );
|
||||
|
||||
if( fieldId == FIELD_T::REFERENCE )
|
||||
m_fieldsBox->Check( listIdx, g_selectRefDes );
|
||||
else if( fieldId == FIELD_T::VALUE )
|
||||
m_fieldsBox->Check( listIdx, g_selectValue );
|
||||
else
|
||||
m_fieldsBox->Check( i, true );
|
||||
m_fieldsBox->Check( listIdx, true );
|
||||
|
||||
m_mandatoryFieldListIndexes[fieldId] = listIdx;
|
||||
}
|
||||
|
||||
m_messagePanel->SetLazyUpdate( true );
|
||||
@@ -221,8 +224,8 @@ void DIALOG_CHANGE_SYMBOLS::onNewLibIDKillFocus( wxFocusEvent& event )
|
||||
|
||||
DIALOG_CHANGE_SYMBOLS::~DIALOG_CHANGE_SYMBOLS()
|
||||
{
|
||||
g_selectRefDes = m_fieldsBox->IsChecked( REFERENCE_FIELD );
|
||||
g_selectValue = m_fieldsBox->IsChecked( VALUE_FIELD );
|
||||
g_selectRefDes = m_fieldsBox->IsChecked( m_mandatoryFieldListIndexes[FIELD_T::REFERENCE] );
|
||||
g_selectValue = m_fieldsBox->IsChecked( m_mandatoryFieldListIndexes[FIELD_T::VALUE] );
|
||||
|
||||
g_removeExtraFields[ (int) m_mode ] = m_removeExtraBox->GetValue();
|
||||
g_resetEmptyFields[ (int) m_mode ] = m_resetEmptyFields->GetValue();
|
||||
@@ -286,9 +289,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
wxCHECK( frame, /* void */ );
|
||||
|
||||
// Load non-mandatory fields from all matching symbols and their library symbols
|
||||
std::vector<SCH_FIELD*> fields;
|
||||
std::vector<SCH_FIELD*> libFields;
|
||||
std::set<wxString> fieldNames;
|
||||
std::set<wxString> fieldNames;
|
||||
|
||||
for( SCH_SHEET_PATH& instance : frame->Schematic().Hierarchy() )
|
||||
{
|
||||
@@ -305,13 +306,10 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
if( !isMatch( symbol, &instance ) )
|
||||
continue;
|
||||
|
||||
fields.clear();
|
||||
symbol->GetFields( fields, false );
|
||||
|
||||
for( SCH_FIELD* field : fields )
|
||||
for( SCH_FIELD& field : symbol->GetFields() )
|
||||
{
|
||||
if( !field->IsMandatory() && !field->IsPrivate() )
|
||||
fieldNames.insert( field->GetName() );
|
||||
if( !field.IsMandatory() && !field.IsPrivate() )
|
||||
fieldNames.insert( field.GetName() );
|
||||
}
|
||||
|
||||
if( m_mode == MODE::UPDATE && symbol->GetLibId().IsValid() )
|
||||
@@ -321,16 +319,15 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
if( libSymbol )
|
||||
{
|
||||
std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
|
||||
std::vector<SCH_FIELD*> orderedLibFields;
|
||||
|
||||
flattenedSymbol->GetFields( libFields );
|
||||
flattenedSymbol->GetFields( orderedLibFields );
|
||||
|
||||
for( SCH_FIELD* libField : libFields )
|
||||
for( SCH_FIELD* libField : orderedLibFields )
|
||||
{
|
||||
if( !libField->IsMandatory() && !libField->IsPrivate() )
|
||||
fieldNames.insert( libField->GetName() );
|
||||
}
|
||||
|
||||
libFields.clear(); // flattenedSymbol is about to go out of scope...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,16 +347,15 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
if( libSymbol )
|
||||
{
|
||||
std::unique_ptr<LIB_SYMBOL> flattenedSymbol = libSymbol->Flatten();
|
||||
std::vector<SCH_FIELD*> orderedLibFields;
|
||||
|
||||
flattenedSymbol->GetFields( libFields );
|
||||
flattenedSymbol->GetFields( orderedLibFields );
|
||||
|
||||
for( SCH_FIELD* libField : libFields )
|
||||
for( SCH_FIELD* libField : orderedLibFields )
|
||||
{
|
||||
if( !libField->IsMandatory() && !libField->IsPrivate() )
|
||||
fieldNames.insert( libField->GetName() );
|
||||
}
|
||||
|
||||
libFields.clear(); // flattenedSymbol is about to go out of scope...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,17 +371,35 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
|
||||
|
||||
bool allChecked = true;
|
||||
|
||||
for( unsigned ii = 0; ii < m_fieldsBox->GetCount(); ++ii )
|
||||
for( int ii = 0; ii < (int) m_fieldsBox->GetCount(); ++ii )
|
||||
{
|
||||
if( ii == REFERENCE_FIELD || ii == VALUE_FIELD )
|
||||
continue;
|
||||
|
||||
if( !m_fieldsBox->IsChecked( ii ) )
|
||||
if( !m_fieldsBox->IsChecked( ii )
|
||||
&& ii != m_mandatoryFieldListIndexes[FIELD_T::REFERENCE]
|
||||
&& ii != m_mandatoryFieldListIndexes[FIELD_T::VALUE] )
|
||||
{
|
||||
allChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
for( unsigned ii = m_fieldsBox->GetCount() - 1; ii >= MANDATORY_FIELD_COUNT; --ii )
|
||||
auto isMandatoryField =
|
||||
[&]( int listbox_idx )
|
||||
{
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
if( m_mandatoryFieldListIndexes[fieldId] == listbox_idx )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
for( int ii = (int) m_fieldsBox->GetCount() - 1; ii >= 0; --ii )
|
||||
{
|
||||
if( isMandatoryField( ii ) )
|
||||
continue;
|
||||
|
||||
m_fieldsBox->Delete( ii );
|
||||
}
|
||||
|
||||
for( const wxString& fieldName : fieldNames )
|
||||
{
|
||||
@@ -420,15 +434,16 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent )
|
||||
// for mandatory fields
|
||||
m_updateFields.clear();
|
||||
|
||||
for( unsigned i = 0; i < m_fieldsBox->GetCount(); ++i )
|
||||
for( unsigned ii = 0; ii < m_fieldsBox->GetCount(); ++ii )
|
||||
{
|
||||
if( m_fieldsBox->IsChecked( i ) )
|
||||
{
|
||||
if( i < MANDATORY_FIELD_COUNT )
|
||||
m_updateFields.insert( GetCanonicalFieldName( i ) );
|
||||
else
|
||||
m_updateFields.insert( m_fieldsBox->GetString( i ) );
|
||||
}
|
||||
if( m_fieldsBox->IsChecked( ii ) )
|
||||
m_updateFields.insert( m_fieldsBox->GetString( ii ) );
|
||||
}
|
||||
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
if( m_fieldsBox->IsChecked( m_mandatoryFieldListIndexes[fieldId] ) )
|
||||
m_updateFields.insert( GetCanonicalFieldName( fieldId ) );
|
||||
}
|
||||
|
||||
if( processMatchingSymbols( &commit) )
|
||||
@@ -464,7 +479,7 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInsta
|
||||
else if( m_matchByValue->GetValue() )
|
||||
{
|
||||
return WildCompareString( m_specifiedValue->GetValue(),
|
||||
UnescapeString( aSymbol->GetField( VALUE_FIELD )->GetText() ),
|
||||
UnescapeString( aSymbol->GetField( FIELD_T::VALUE )->GetText() ),
|
||||
false );
|
||||
}
|
||||
else if( m_matchById )
|
||||
@@ -655,9 +670,9 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
bool resetEffects = m_resetFieldEffects->GetValue();
|
||||
bool resetPositions = m_resetFieldPositions->GetValue();
|
||||
|
||||
for( unsigned i = 0; i < symbol->GetFields().size(); ++i )
|
||||
for( int ii = (int) symbol->GetFields().size() - 1; ii >= 0; ii-- )
|
||||
{
|
||||
SCH_FIELD& field = symbol->GetFields()[i];
|
||||
SCH_FIELD& field = symbol->GetFields()[ii];
|
||||
SCH_FIELD* libField = nullptr;
|
||||
bool doUpdate = field.IsPrivate();
|
||||
|
||||
@@ -668,10 +683,10 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
if( !doUpdate )
|
||||
continue;
|
||||
|
||||
if( i < MANDATORY_FIELD_COUNT )
|
||||
libField = symbol->GetLibSymbolRef()->GetFieldById( (int) i );
|
||||
if( field.IsMandatory() )
|
||||
libField = symbol->GetLibSymbolRef()->GetField( field.GetId() );
|
||||
else
|
||||
libField = symbol->GetLibSymbolRef()->FindField( field.GetName() );
|
||||
libField = symbol->GetLibSymbolRef()->GetField( field.GetName() );
|
||||
|
||||
if( libField )
|
||||
{
|
||||
@@ -682,7 +697,7 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
|
||||
if( resetText )
|
||||
{
|
||||
if( i == REFERENCE_FIELD )
|
||||
if( field.GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
wxString prefix = UTIL::GetRefDesPrefix( libField->GetText() );
|
||||
|
||||
@@ -699,16 +714,11 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
symbol->SetRef( &instance, ref );
|
||||
}
|
||||
}
|
||||
else if( i == VALUE_FIELD )
|
||||
else if( field.GetId() == FIELD_T::VALUE )
|
||||
{
|
||||
if( ( symbol->IsPower() && m_resetCustomPower->IsChecked() )
|
||||
|| !symbol->IsPower() )
|
||||
if( !symbol->IsPower() || m_resetCustomPower->IsChecked() )
|
||||
symbol->SetValueFieldText( UnescapeString( libField->GetText() ) );
|
||||
}
|
||||
else if( i == FOOTPRINT_FIELD )
|
||||
{
|
||||
symbol->SetFootprintFieldText( libField->GetText() );
|
||||
}
|
||||
else
|
||||
{
|
||||
field.SetText( libField->GetText() );
|
||||
@@ -735,10 +745,9 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
if( resetPositions )
|
||||
field.SetTextPos( symbol->GetPosition() + libField->GetTextPos() );
|
||||
}
|
||||
else if( i >= MANDATORY_FIELD_COUNT && removeExtras )
|
||||
else if( !field.IsMandatory() && removeExtras )
|
||||
{
|
||||
symbol->RemoveField( field.GetName() );
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,11 +762,10 @@ int DIALOG_CHANGE_SYMBOLS::processSymbols( SCH_COMMIT* aCommit,
|
||||
if( !alg::contains( m_updateFields, libField->GetCanonicalName() ) )
|
||||
continue;
|
||||
|
||||
if( !symbol->FindField( libField->GetName(), false ) )
|
||||
if( !symbol->GetField( libField->GetName() ) )
|
||||
{
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), symbol->GetNextFieldId(), symbol,
|
||||
libField->GetCanonicalName() );
|
||||
SCH_FIELD* schField = symbol->AddField( newField );
|
||||
SCH_FIELD* schField = symbol->AddField( SCH_FIELD( { 0, 0 }, FIELD_T::USER, symbol,
|
||||
libField->GetName() ) );
|
||||
|
||||
// Careful: the visible bit and position are also set by SetAttributes()
|
||||
schField->SetAttributes( *libField );
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <lib_id.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <template_fieldnames.h>
|
||||
|
||||
|
||||
class SCH_SYMBOL;
|
||||
@@ -90,11 +91,15 @@ private:
|
||||
wxString getSymbolReferences( SCH_SYMBOL& aSymbol, const LIB_ID& aNewId,
|
||||
const wxString* aOldLibLinkName = nullptr );
|
||||
|
||||
private:
|
||||
SCH_SYMBOL* m_symbol;
|
||||
MODE m_mode;
|
||||
|
||||
/// Set of field names that should have values updated.
|
||||
std::set<wxString> m_updateFields;
|
||||
std::set<wxString> m_updateFields;
|
||||
|
||||
/// Index in the list control for each mandatory FIELD_T type
|
||||
std::map<FIELD_T, int> m_mandatoryFieldListIndexes;
|
||||
};
|
||||
|
||||
#endif // _DIALOG_CHANGE_SYMBOLS_H_
|
||||
|
||||
@@ -760,7 +760,7 @@ bool DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow()
|
||||
m_isModified = true;
|
||||
|
||||
candidate.m_Screen->Remove( candidate.m_Symbol );
|
||||
SCH_FIELD* value = candidate.m_Symbol->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* value = candidate.m_Symbol->GetField( FIELD_T::VALUE );
|
||||
|
||||
// If value is a proxy for the itemName then make sure it gets updated
|
||||
if( getName( candidate.m_Symbol->GetLibId() ) == value->GetText() )
|
||||
|
||||
@@ -149,13 +149,12 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
|
||||
m_isVisible = aField->IsVisible();
|
||||
|
||||
m_isSheetFilename = false;
|
||||
m_fieldId = aField->GetId();
|
||||
|
||||
if( aField->GetParent() && aField->GetParent()->Type() == LIB_SYMBOL_T )
|
||||
{
|
||||
const LIB_SYMBOL* symbol = static_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
|
||||
|
||||
m_fieldId = aField->GetId();
|
||||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
@@ -186,8 +185,6 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
|
||||
const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( aField->GetParentSymbol() );
|
||||
SCH_SHEET_PATH sheetPath = static_cast<SCH_EDIT_FRAME*>( aParent )->GetCurrentSheet();
|
||||
|
||||
m_fieldId = aField->GetId();
|
||||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
@@ -225,31 +222,14 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
|
||||
|
||||
m_netlist = netlist;
|
||||
}
|
||||
else if( aField->GetParent() && aField->GetParent()->Type() == SCH_SHEET_T )
|
||||
{
|
||||
switch( aField->GetId() )
|
||||
{
|
||||
case SHEETNAME:
|
||||
m_fieldId = SHEETNAME_V;
|
||||
break;
|
||||
|
||||
case SHEETFILENAME:
|
||||
m_isSheetFilename = true;
|
||||
m_fieldId = SHEETFILENAME_V;
|
||||
m_note->SetLabel( wxString::Format( m_note->GetLabel(),
|
||||
_( "Sheet filename can only be modified in Sheet Properties "
|
||||
"dialog." ) ) );
|
||||
m_note->Show( true );
|
||||
break;
|
||||
|
||||
default:
|
||||
m_fieldId = SHEETUSERFIELD_V;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( aField->GetParent() && aField->GetParent()->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
|
||||
if( aField->GetId() == FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
m_fieldId = LABELUSERFIELD_V;
|
||||
m_isSheetFilename = true;
|
||||
m_note->SetLabel( wxString::Format( m_note->GetLabel(),
|
||||
_( "Sheet filename can only be modified in Sheet "
|
||||
"Properties dialog." ) ) );
|
||||
m_note->Show( true );
|
||||
}
|
||||
|
||||
m_textLabel->SetLabel( aField->GetName() + wxS( ":" ) );
|
||||
@@ -294,11 +274,11 @@ void DIALOG_FIELD_PROPERTIES::init()
|
||||
|
||||
// Predefined fields cannot contain some chars and cannot be empty, so they need a
|
||||
// SCH_FIELD_VALIDATOR (m_StyledTextCtrl cannot use a SCH_FIELD_VALIDATOR).
|
||||
if( m_fieldId == REFERENCE_FIELD
|
||||
|| m_fieldId == FOOTPRINT_FIELD
|
||||
|| m_fieldId == DATASHEET_FIELD
|
||||
|| m_fieldId == SHEETNAME_V
|
||||
|| m_fieldId == SHEETFILENAME_V )
|
||||
if( m_fieldId == FIELD_T::REFERENCE
|
||||
|| m_fieldId == FIELD_T::FOOTPRINT
|
||||
|| m_fieldId == FIELD_T::DATASHEET
|
||||
|| m_fieldId == FIELD_T::SHEET_NAME
|
||||
|| m_fieldId == FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
m_TextCtrl->SetValidator( FIELD_VALIDATOR( m_fieldId, &m_text ) );
|
||||
SetInitialFocus( m_TextCtrl );
|
||||
@@ -313,9 +293,8 @@ void DIALOG_FIELD_PROPERTIES::init()
|
||||
}
|
||||
|
||||
// Show the unit selector for reference fields on multi-unit symbols
|
||||
bool showUnitSelector = m_fieldId == REFERENCE_FIELD
|
||||
bool showUnitSelector = m_fieldId == FIELD_T::REFERENCE
|
||||
&& m_field->GetParentSymbol()
|
||||
&& m_field->GetParentSymbol()->Type() == SCH_SYMBOL_T
|
||||
&& m_field->GetParentSymbol()->IsMulti();
|
||||
|
||||
m_unitLabel->Show( showUnitSelector );
|
||||
@@ -323,7 +302,7 @@ void DIALOG_FIELD_PROPERTIES::init()
|
||||
|
||||
// Show the footprint selection dialog if this is the footprint field.
|
||||
m_TextValueSelectButton->SetBitmap( KiBitmapBundle( BITMAPS::small_library ) );
|
||||
m_TextValueSelectButton->Show( m_fieldId == FOOTPRINT_FIELD );
|
||||
m_TextValueSelectButton->Show( m_fieldId == FIELD_T::FOOTPRINT );
|
||||
|
||||
m_TextCtrl->Enable( true );
|
||||
|
||||
@@ -387,13 +366,13 @@ void DIALOG_FIELD_PROPERTIES::OnSetFocusText( wxFocusEvent& event )
|
||||
// Note that we can't do this on OSX as it tends to provoke Apple's
|
||||
// "[NSAlert runModal] may not be invoked inside of transaction begin/commit pair"
|
||||
// bug. See: https://bugs.launchpad.net/kicad/+bug/1837225
|
||||
if( m_fieldId == REFERENCE_FIELD || m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
|
||||
if( m_fieldId == FIELD_T::REFERENCE || m_fieldId == FIELD_T::VALUE || m_fieldId == FIELD_T::SHEET_NAME )
|
||||
m_TextCtrl->Update();
|
||||
#endif
|
||||
|
||||
if( m_fieldId == REFERENCE_FIELD )
|
||||
if( m_fieldId == FIELD_T::REFERENCE )
|
||||
KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_TextCtrl ) );
|
||||
else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
|
||||
else if( m_fieldId == FIELD_T::VALUE || m_fieldId == FIELD_T::SHEET_NAME )
|
||||
m_TextCtrl->SetSelection( -1, -1 );
|
||||
|
||||
m_firstFocus = false;
|
||||
@@ -506,7 +485,7 @@ bool DIALOG_FIELD_PROPERTIES::TransferDataFromWindow()
|
||||
else if( m_StyledTextCtrl->IsShown() )
|
||||
m_text = UnescapeString( m_StyledTextCtrl->GetValue() );
|
||||
|
||||
if( m_fieldId == SHEETFILENAME_V )
|
||||
if( m_fieldId == FIELD_T::SHEET_FILENAME )
|
||||
m_text = EnsureFileExtension( m_text, FILEEXT::KiCadSchematicFileExtension );
|
||||
|
||||
m_position = VECTOR2I( m_posX.GetIntValue(), m_posY.GetIntValue() );
|
||||
@@ -583,18 +562,13 @@ void DIALOG_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* aFiel
|
||||
{
|
||||
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
|
||||
SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
|
||||
int fieldType = aField->GetId();
|
||||
|
||||
if( parent && parent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
|
||||
|
||||
if( fieldType == REFERENCE_FIELD )
|
||||
if( m_fieldId == FIELD_T::REFERENCE )
|
||||
symbol->SetRef( aSheetPath, m_text );
|
||||
else if( fieldType == VALUE_FIELD )
|
||||
symbol->SetValueFieldText( m_text );
|
||||
else if( fieldType == FOOTPRINT_FIELD )
|
||||
symbol->SetFootprintFieldText( m_text );
|
||||
|
||||
// Set the unit selection in multiple units per package
|
||||
if( m_unitChoice->IsShown() )
|
||||
@@ -606,7 +580,7 @@ void DIALOG_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* aFiel
|
||||
}
|
||||
else if( parent && parent->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
if( aField->GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
if( m_fieldId == FIELD_T::INTERSHEET_REFS )
|
||||
{
|
||||
if( m_visible->GetValue() != parent->Schematic()->Settings().m_IntersheetRefsShow )
|
||||
{
|
||||
@@ -637,7 +611,7 @@ void DIALOG_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* aFiel
|
||||
// Changing a sheetname need to update the hierarchy navigator
|
||||
bool needUpdateHierNav = false;
|
||||
|
||||
if( parent && parent->Type() == SCH_SHEET_T && fieldType == SHEETNAME )
|
||||
if( m_fieldId == FIELD_T::SHEET_NAME )
|
||||
needUpdateHierNav = m_text != aField->GetText();
|
||||
|
||||
aField->SetText( m_text );
|
||||
@@ -665,9 +639,9 @@ void DIALOG_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* aFiel
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
|
||||
|
||||
if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
|
||||
|| fieldType == FOOTPRINT_FIELD
|
||||
|| fieldType == DATASHEET_FIELD ) )
|
||||
if( symbol->IsAnnotated( aSheetPath ) && ( m_fieldId == FIELD_T::VALUE
|
||||
|| m_fieldId == FIELD_T::FOOTPRINT
|
||||
|| m_fieldId == FIELD_T::DATASHEET ) )
|
||||
{
|
||||
wxString ref = symbol->GetRef( aSheetPath );
|
||||
int unit = symbol->GetUnit();
|
||||
@@ -683,14 +657,7 @@ void DIALOG_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* aFiel
|
||||
for( SCH_SYMBOL* otherUnit : otherUnits )
|
||||
{
|
||||
aCommit->Modify( otherUnit, screen );
|
||||
|
||||
if( fieldType == VALUE_FIELD )
|
||||
otherUnit->SetValueFieldText( m_text );
|
||||
else if( fieldType == FOOTPRINT_FIELD )
|
||||
otherUnit->SetFootprintFieldText( m_text );
|
||||
else
|
||||
otherUnit->GetField( (MANDATORY_FIELD_T) fieldType )->SetText( m_text );
|
||||
|
||||
otherUnit->GetField( m_fieldId )->SetText( m_text );
|
||||
editFrame->UpdateItem( otherUnit, false, true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ protected:
|
||||
UNIT_BINDER m_posY;
|
||||
UNIT_BINDER m_textSize;
|
||||
|
||||
int m_fieldId;
|
||||
FIELD_T m_fieldId;
|
||||
wxString m_text;
|
||||
KIFONT::FONT* m_font;
|
||||
bool m_isItalic;
|
||||
|
||||
@@ -421,16 +421,18 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( SCH_COMMIT* aCommit,
|
||||
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
|
||||
|
||||
if( m_references->GetValue() )
|
||||
processItem( aCommit, aSheetPath, symbol->GetField( REFERENCE_FIELD ) );
|
||||
processItem( aCommit, aSheetPath, symbol->GetField( FIELD_T::REFERENCE ) );
|
||||
|
||||
if( m_values->GetValue() )
|
||||
processItem( aCommit, aSheetPath, symbol->GetField( VALUE_FIELD ) );
|
||||
processItem( aCommit, aSheetPath, symbol->GetField( FIELD_T::VALUE ) );
|
||||
|
||||
if( m_otherFields->GetValue() )
|
||||
{
|
||||
for( int i = 2; i < symbol->GetFieldCount(); ++i )
|
||||
for( SCH_FIELD& field : symbol->GetFields() )
|
||||
{
|
||||
SCH_FIELD& field = symbol->GetFields()[i];
|
||||
if( field.GetId() == FIELD_T::REFERENCE || field.GetId() == FIELD_T::VALUE )
|
||||
continue;
|
||||
|
||||
const wxString& fieldName = field.GetName();
|
||||
|
||||
if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty()
|
||||
@@ -449,13 +451,13 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( SCH_COMMIT* aCommit,
|
||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
|
||||
|
||||
if( m_sheetTitles->GetValue() )
|
||||
processItem( aCommit, aSheetPath, &sheet->GetFields()[SHEETNAME] );
|
||||
processItem( aCommit, aSheetPath, sheet->GetField( FIELD_T::SHEET_NAME ) );
|
||||
|
||||
if( m_sheetFields->GetValue() )
|
||||
{
|
||||
for( SCH_FIELD& field : sheet->GetFields() )
|
||||
{
|
||||
if( field.GetId() == SHEETNAME )
|
||||
if( field.GetId() == FIELD_T::SHEET_NAME )
|
||||
continue;
|
||||
|
||||
const wxString& fieldName = field.GetName();
|
||||
|
||||
@@ -287,8 +287,10 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow()
|
||||
// Ensure the symbol has the Power (i.e. equivalent to a global label
|
||||
// before adding its value in list
|
||||
if( power->IsSymbolLikePowerGlobalLabel() )
|
||||
existingLabels.insert(
|
||||
UnescapeString( power->GetField( VALUE_FIELD )->GetText() ) );
|
||||
{
|
||||
const SCH_FIELD* valueField = power->GetField( FIELD_T::VALUE );
|
||||
existingLabels.insert( UnescapeString( valueField->GetText() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,7 +473,7 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow()
|
||||
{
|
||||
field.SetLayer( LAYER_NETCLASS_REFS );
|
||||
}
|
||||
else if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
else if( field.GetId() == FIELD_T::INTERSHEET_REFS )
|
||||
{
|
||||
if( field.IsVisible() != m_Parent->Schematic().Settings().m_IntersheetRefsShow )
|
||||
{
|
||||
@@ -523,6 +525,14 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow()
|
||||
}
|
||||
}
|
||||
|
||||
int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
|
||||
|
||||
for( SCH_FIELD& field : *m_fields )
|
||||
{
|
||||
if( !field.IsMandatory() )
|
||||
field.SetOrdinal( ordinal++ );
|
||||
}
|
||||
|
||||
m_currentLabel->SetFields( *m_fields );
|
||||
|
||||
if( m_shapeSizer->AreAnyItemsShown() )
|
||||
@@ -622,20 +632,20 @@ void DIALOG_LABEL_PROPERTIES::OnAddField( wxCommandEvent& event )
|
||||
if( !m_grid->CommitPendingChanges() )
|
||||
return;
|
||||
|
||||
int fieldID = (int) m_fields->size();
|
||||
wxString fieldName;
|
||||
wxString fieldName = wxT( "Netclass" );
|
||||
|
||||
if( (int) fieldID == m_currentLabel->GetMandatoryFieldCount()
|
||||
|| m_fields->at( m_fields->size()-1 ).GetCanonicalName() == wxT( "Netclass" ) )
|
||||
for( SCH_FIELD& field : *m_fields )
|
||||
{
|
||||
fieldName = wxT( "Netclass" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = SCH_LABEL_BASE::GetDefaultFieldName( fieldName, true );
|
||||
if( field.GetId() != FIELD_T::INTERSHEET_REFS && field.GetName() != wxT( "Netclass" ) )
|
||||
{
|
||||
fieldName = wxEmptyString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_currentLabel, fieldName );
|
||||
fieldName = SCH_LABEL_BASE::GetDefaultFieldName( fieldName, true );
|
||||
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), FIELD_T::USER, m_currentLabel, fieldName );
|
||||
|
||||
if( m_fields->size() > 0 )
|
||||
{
|
||||
|
||||
@@ -65,8 +65,8 @@ DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
|
||||
wxCommandEvent dummyEvent;
|
||||
onParentSymbolSelect( dummyEvent );
|
||||
|
||||
m_textName->SetValidator( FIELD_VALIDATOR( VALUE_FIELD ) );
|
||||
m_textReference->SetValidator( FIELD_VALIDATOR( REFERENCE_FIELD ) );
|
||||
m_textName->SetValidator( FIELD_VALIDATOR( FIELD_T::VALUE ) );
|
||||
m_textReference->SetValidator( FIELD_VALIDATOR( FIELD_T::REFERENCE ) );
|
||||
|
||||
if( !aInheritFromSymbolName.IsEmpty() )
|
||||
{
|
||||
|
||||
@@ -74,7 +74,8 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a
|
||||
|
||||
// Give a bit more room for combobox editors
|
||||
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
|
||||
m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_libEntry, m_embeddedFiles->GetLocalFiles() );
|
||||
m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_libEntry,
|
||||
m_embeddedFiles->GetLocalFiles() );
|
||||
m_grid->SetTable( m_fields );
|
||||
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this, aLibEntry,
|
||||
[&]( wxCommandEvent& aEvent )
|
||||
@@ -83,11 +84,14 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a
|
||||
} ) );
|
||||
m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
||||
|
||||
// Load the FIELDS_GRID_TABLE
|
||||
m_libEntry->CopyFields( *m_fields );
|
||||
|
||||
// Show/hide columns according to the user's preference
|
||||
SYMBOL_EDITOR_SETTINGS* cfg = m_Parent->GetSettings();
|
||||
m_grid->ShowHideColumns( cfg->m_EditSymbolVisibleColumns );
|
||||
|
||||
m_SymbolNameCtrl->SetValidator( FIELD_VALIDATOR( VALUE_FIELD ) );
|
||||
m_SymbolNameCtrl->SetValidator( FIELD_VALIDATOR( FIELD_T::VALUE ) );
|
||||
|
||||
// Configure button logos
|
||||
m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
||||
@@ -173,9 +177,6 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
// Push a copy of each field into m_updateFields
|
||||
m_libEntry->CopyFields( *m_fields );
|
||||
|
||||
std::set<wxString> defined;
|
||||
|
||||
for( SCH_FIELD& field : *m_fields )
|
||||
@@ -197,7 +198,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
if( defined.count( templateFieldname.m_Name ) <= 0 )
|
||||
{
|
||||
SCH_FIELD field( VECTOR2I( 0, 0 ), -1, m_libEntry, templateFieldname.m_Name );
|
||||
SCH_FIELD field( { 0, 0 }, FIELD_T::USER, m_libEntry, templateFieldname.m_Name );
|
||||
field.SetVisible( templateFieldname.m_Visible );
|
||||
m_fields->push_back( field );
|
||||
m_addedTemplateFields.insert( templateFieldname.m_Name );
|
||||
@@ -299,20 +300,24 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::Validate()
|
||||
if( !m_grid->CommitPendingChanges() )
|
||||
return false;
|
||||
|
||||
// Alias symbol reference can be empty because it inherits from the parent symbol.
|
||||
if( m_libEntry->IsRoot()
|
||||
&& UTIL::GetRefDesPrefix( m_fields->at( REFERENCE_FIELD ).GetText() ).IsEmpty() )
|
||||
// Symbol reference can be empty because it inherits from the parent symbol.
|
||||
if( m_libEntry->IsRoot() )
|
||||
{
|
||||
if( m_NoteBook->GetSelection() != 0 )
|
||||
m_NoteBook->SetSelection( 0 );
|
||||
SCH_FIELD* field = m_fields->GetField( FIELD_T::REFERENCE );
|
||||
|
||||
m_delayedErrorMessage = _( "References must start with a letter." );
|
||||
m_delayedFocusGrid = m_grid;
|
||||
m_delayedFocusColumn = FDC_VALUE;
|
||||
m_delayedFocusRow = REFERENCE_FIELD;
|
||||
m_delayedFocusPage = 0;
|
||||
if( UTIL::GetRefDesPrefix( field->GetText() ).IsEmpty() )
|
||||
{
|
||||
if( m_NoteBook->GetSelection() != 0 )
|
||||
m_NoteBook->SetSelection( 0 );
|
||||
|
||||
return false;
|
||||
m_delayedErrorMessage = _( "References must start with a letter." );
|
||||
m_delayedFocusGrid = m_grid;
|
||||
m_delayedFocusColumn = FDC_VALUE;
|
||||
m_delayedFocusRow = m_fields->GetFieldRow( FIELD_T::REFERENCE );
|
||||
m_delayedFocusPage = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for missing field names.
|
||||
@@ -414,12 +419,19 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
||||
|
||||
// The Y axis for components in lib is from bottom to top while the screen axis is top
|
||||
// to bottom: we must change the y coord sign when writing back to the library
|
||||
for( int ii = 0; ii < (int) m_fields->size(); ++ii )
|
||||
for( SCH_FIELD& field : *m_fields )
|
||||
{
|
||||
VECTOR2I pos = m_fields->at( ii ).GetPosition();
|
||||
VECTOR2I pos = field.GetPosition();
|
||||
pos.y = -pos.y;
|
||||
m_fields->at( ii ).SetPosition( pos );
|
||||
m_fields->at( ii ).SetId( ii );
|
||||
field.SetPosition( pos );
|
||||
}
|
||||
|
||||
int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
|
||||
|
||||
for( SCH_FIELD& field : *m_fields )
|
||||
{
|
||||
if( !field.IsMandatory() )
|
||||
field.SetOrdinal( ordinal++ );
|
||||
}
|
||||
|
||||
for( int ii = m_fields->GetNumberRows() - 1; ii >= 0; ii-- )
|
||||
@@ -554,7 +566,10 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
|
||||
void DIALOG_LIB_SYMBOL_PROPERTIES::OnSymbolNameText( wxCommandEvent& event )
|
||||
{
|
||||
if( m_OptionPower->IsChecked() )
|
||||
m_grid->SetCellValue( VALUE_FIELD, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
|
||||
{
|
||||
m_grid->SetCellValue( m_fields->GetFieldRow( FIELD_T::VALUE ), FDC_VALUE,
|
||||
m_SymbolNameCtrl->GetValue() );
|
||||
}
|
||||
|
||||
OnModify();
|
||||
}
|
||||
@@ -587,8 +602,8 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
|
||||
return;
|
||||
|
||||
SYMBOL_EDITOR_SETTINGS* settings = m_Parent->GetSettings();
|
||||
int fieldID = (int) m_fields->size();
|
||||
SCH_FIELD newField( m_libEntry, fieldID );
|
||||
SCH_FIELD newField( m_libEntry, FIELD_T::USER,
|
||||
GetUserFieldName( m_fields->size(), DO_TRANSLATE ) );
|
||||
|
||||
newField.SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
|
||||
schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
|
||||
@@ -861,7 +876,8 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
int row = m_grid->GetGridCursorRow();
|
||||
int col = m_grid->GetGridCursorCol();
|
||||
|
||||
if( row == VALUE_FIELD && col == FDC_VALUE && m_OptionPower->IsChecked() )
|
||||
if( row == m_fields->GetFieldRow( FIELD_T::VALUE ) && col == FDC_VALUE
|
||||
&& m_OptionPower->IsChecked() )
|
||||
{
|
||||
wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
|
||||
m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
|
||||
|
||||
@@ -222,7 +222,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
|
||||
if( eachSymbol->GetLibId().Format() != UTF8( selected_part.GetRequestedName() ) )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* valueField = eachSymbol->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* valueField = eachSymbol->GetField( FIELD_T::VALUE );
|
||||
|
||||
data.clear();
|
||||
data.push_back( eachSymbol->GetRef( m_currentSheet ) );
|
||||
|
||||
@@ -61,11 +61,11 @@ DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S
|
||||
m_sourceSheetFilename( aSourceSheetFilename ),
|
||||
m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ),
|
||||
m_dummySheet( *aSheet ),
|
||||
m_dummySheetNameField( VECTOR2I( -1, -1 ), SHEETNAME, &m_dummySheet )
|
||||
m_dummySheetNameField( VECTOR2I( -1, -1 ), FIELD_T::SHEET_NAME, &m_dummySheet )
|
||||
{
|
||||
m_sheet = aSheet;
|
||||
m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_sheet );
|
||||
m_delayedFocusRow = SHEETNAME;
|
||||
m_delayedFocusRow = 0;
|
||||
m_delayedFocusColumn = FDC_VALUE;
|
||||
|
||||
// Give a bit more room for combobox editors
|
||||
@@ -245,13 +245,19 @@ static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
|
||||
}
|
||||
|
||||
|
||||
static bool positioningChanged( FIELDS_GRID_TABLE* a, std::vector<SCH_FIELD>& b )
|
||||
static bool positioningChanged( FIELDS_GRID_TABLE* a, SCH_SHEET* b )
|
||||
{
|
||||
if( positioningChanged( a->at( SHEETNAME ), b.at( SHEETNAME ) ) )
|
||||
if( positioningChanged( a->GetField( FIELD_T::SHEET_NAME ),
|
||||
b->GetField( FIELD_T::SHEET_NAME ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( positioningChanged( a->at( SHEETFILENAME ), b.at( SHEETFILENAME ) ) )
|
||||
if( positioningChanged( a->GetField( FIELD_T::SHEET_FILENAME ),
|
||||
b->GetField( FIELD_T::SHEET_FILENAME ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -268,7 +274,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
|
||||
*m_isUndoable = true;
|
||||
|
||||
// Sheet file names can be relative or absolute.
|
||||
wxString sheetFileName = m_fields->at( SHEETFILENAME ).GetText();
|
||||
wxString sheetFileName = m_fields->GetField( FIELD_T::SHEET_FILENAME )->GetText();
|
||||
|
||||
// Ensure filepath is not empty. (In normal use will be caught by grid validators,
|
||||
// but unedited data from existing files can be bad.)
|
||||
@@ -296,7 +302,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
|
||||
// Inside Eeschema, filenames are stored using unix notation
|
||||
newRelativeFilename.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
|
||||
wxString oldFilename = m_sheet->GetFields()[ SHEETFILENAME ].GetText();
|
||||
wxString oldFilename = m_sheet->GetField( FIELD_T::SHEET_FILENAME )->GetText();
|
||||
oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
|
||||
bool filename_changed = oldFilename != newRelativeFilename;
|
||||
@@ -338,7 +344,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
|
||||
"\n to relative path: '%s'",
|
||||
tmp.GetPath(),
|
||||
fn.GetPath() );
|
||||
m_fields->at( SHEETFILENAME ).SetText( fn.GetFullPath() );
|
||||
m_fields->GetField( FIELD_T::SHEET_FILENAME )->SetText( fn.GetFullPath() );
|
||||
newRelativeFilename = fn.GetFullPath();
|
||||
}
|
||||
}
|
||||
@@ -348,7 +354,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
|
||||
if( clearFileName )
|
||||
currentScreen->SetFileName( wxEmptyString );
|
||||
else
|
||||
m_fields->at( SHEETFILENAME ).SetText( oldFilename );
|
||||
FindField( *m_fields, FIELD_T::SHEET_FILENAME )->SetText( oldFilename );
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -365,7 +371,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
|
||||
repairedList.BuildSheetList( &m_frame->Schematic().Root(), true );
|
||||
}
|
||||
|
||||
wxString newSheetname = m_fields->at( SHEETNAME ).GetText();
|
||||
wxString newSheetname = m_fields->GetField( FIELD_T::SHEET_NAME )->GetText();
|
||||
|
||||
if( ( newSheetname != m_sheet->GetName() ) && m_updateHierarchyNavigator )
|
||||
*m_updateHierarchyNavigator = true;
|
||||
@@ -373,13 +379,13 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
|
||||
if( newSheetname.IsEmpty() )
|
||||
newSheetname = _( "Untitled Sheet" );
|
||||
|
||||
m_fields->at( SHEETNAME ).SetText( newSheetname );
|
||||
m_fields->GetField( FIELD_T::SHEET_NAME )->SetText( newSheetname );
|
||||
|
||||
// change all field positions from relative to absolute
|
||||
for( SCH_FIELD& m_field : *m_fields)
|
||||
m_field.Offset( m_sheet->GetPosition() );
|
||||
|
||||
if( positioningChanged( m_fields, m_sheet->GetFields() ) )
|
||||
if( positioningChanged( m_fields, m_sheet ) )
|
||||
m_sheet->SetFieldsAutoplaced( AUTOPLACE_NONE );
|
||||
|
||||
for( int ii = m_fields->GetNumberRows() - 1; ii >= 0; ii-- )
|
||||
@@ -648,8 +654,8 @@ bool DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged( const wxString& aNewFilena
|
||||
{
|
||||
// Create a temporary sheet for recursion testing to prevent a possible recursion error.
|
||||
std::unique_ptr< SCH_SHEET> tmpSheet = std::make_unique<SCH_SHEET>( &schematic );
|
||||
tmpSheet->GetFields()[SHEETNAME] = m_fields->at( SHEETNAME );
|
||||
tmpSheet->GetFields()[SHEETFILENAME].SetText( sheetFileName.GetFullPath() );
|
||||
*tmpSheet->GetField( FIELD_T::SHEET_NAME ) = m_fields->GetField( FIELD_T::SHEET_NAME );
|
||||
tmpSheet->GetField( FIELD_T::SHEET_FILENAME )->SetText( sheetFileName.GetFullPath() );
|
||||
tmpSheet->SetScreen( useScreen );
|
||||
|
||||
// No need to check for valid library IDs if we are using an existing screen.
|
||||
@@ -711,28 +717,8 @@ void DIALOG_SHEET_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
|
||||
bool success = true;
|
||||
wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
|
||||
wxControl* control = editor->GetControl();
|
||||
wxTextEntry* textControl = dynamic_cast<wxTextEntry*>( control );
|
||||
|
||||
// Short-circuit the validator's more generic "can't be empty" message for the
|
||||
// two mandatory fields:
|
||||
if( event.GetRow() == SHEETNAME && event.GetCol() == FDC_VALUE )
|
||||
{
|
||||
if( textControl && textControl->IsEmpty() )
|
||||
{
|
||||
wxMessageBox( _( "A sheet must have a name." ) );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
else if( event.GetRow() == SHEETFILENAME && event.GetCol() == FDC_VALUE && textControl )
|
||||
{
|
||||
if( textControl->IsEmpty() )
|
||||
{
|
||||
wxMessageBox( _( "A sheet must have a file specified." ) );
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( success && control && control->GetValidator() )
|
||||
if( control && control->GetValidator() )
|
||||
success = control->GetValidator()->Validate( control );
|
||||
|
||||
if( !success )
|
||||
@@ -751,11 +737,10 @@ void DIALOG_SHEET_PROPERTIES::OnAddField( wxCommandEvent& event )
|
||||
if( !m_grid->CommitPendingChanges() )
|
||||
return;
|
||||
|
||||
int fieldID = m_fields->size();
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_sheet,
|
||||
SCH_SHEET::GetDefaultFieldName( fieldID, DO_TRANSLATE ) );
|
||||
SCH_FIELD newField( { 0, 0 }, FIELD_T::SHEET_USER, m_sheet,
|
||||
GetUserFieldName( (int) m_fields->size(), DO_TRANSLATE ) );
|
||||
|
||||
newField.SetTextAngle( m_fields->at( SHEETNAME ).GetTextAngle() );
|
||||
newField.SetTextAngle( m_fields->GetField( FIELD_T::SHEET_NAME )->GetTextAngle() );
|
||||
|
||||
m_fields->push_back( newField );
|
||||
|
||||
@@ -891,12 +876,13 @@ void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
}
|
||||
|
||||
// Propagate changes in sheetname to displayed hierarchical path
|
||||
int sheetnameRow = m_fields->GetFieldRow( FIELD_T::SHEET_NAME );
|
||||
wxString path = m_frame->GetCurrentSheet().PathHumanReadable( false );
|
||||
|
||||
if( path.Last() != '/' )
|
||||
path.Append( '/' );
|
||||
|
||||
wxGridCellEditor* editor = m_grid->GetCellEditor( SHEETNAME, FDC_VALUE );
|
||||
wxGridCellEditor* editor = m_grid->GetCellEditor( sheetnameRow, FDC_VALUE );
|
||||
wxControl* control = editor->GetControl();
|
||||
wxTextEntry* textControl = dynamic_cast<wxTextEntry*>( control );
|
||||
wxString sheetName;
|
||||
@@ -904,7 +890,7 @@ void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
if( textControl )
|
||||
sheetName = textControl->GetValue();
|
||||
else
|
||||
sheetName = m_grid->GetCellValue( SHEETNAME, FDC_VALUE );
|
||||
sheetName = m_grid->GetCellValue( sheetnameRow, FDC_VALUE );
|
||||
|
||||
m_dummySheet.SetFields( *m_fields );
|
||||
m_dummySheetNameField.SetText( sheetName );
|
||||
|
||||
@@ -178,43 +178,27 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
|
||||
|
||||
WX_STRING_REPORTER reporter;
|
||||
|
||||
auto setFieldValue =
|
||||
[&]( const wxString& aFieldName, const wxString& aValue )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.GetName() == aFieldName )
|
||||
{
|
||||
field.SetText( aValue );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_fields.emplace_back( &m_symbol, -1, aFieldName );
|
||||
m_fields.back().SetText( aValue );
|
||||
};
|
||||
|
||||
// Infer RLC and VI models if they aren't specified
|
||||
if( SIM_MODEL::InferSimModel( m_symbol, &m_fields, false, SIM_VALUE_GRAMMAR::NOTATION::SI,
|
||||
&deviceType, &modelType, &modelParams, &pinMap ) )
|
||||
{
|
||||
setFieldValue( SIM_DEVICE_FIELD, deviceType );
|
||||
SetFieldValue( m_fields, SIM_DEVICE_FIELD, deviceType.ToStdString() );
|
||||
|
||||
if( !modelType.IsEmpty() )
|
||||
setFieldValue( SIM_DEVICE_SUBTYPE_FIELD, modelType );
|
||||
SetFieldValue( m_fields, SIM_DEVICE_SUBTYPE_FIELD, modelType.ToStdString() );
|
||||
|
||||
setFieldValue( SIM_PARAMS_FIELD, modelParams );
|
||||
SetFieldValue( m_fields, SIM_PARAMS_FIELD, modelParams.ToStdString() );
|
||||
|
||||
setFieldValue( SIM_PINS_FIELD, pinMap );
|
||||
SetFieldValue( m_fields, SIM_PINS_FIELD, pinMap.ToStdString() );
|
||||
|
||||
storeInValue = true;
|
||||
|
||||
// In case the storeInValue checkbox is turned off (if it's left on then we'll overwrite
|
||||
// this field with the actual value):
|
||||
m_fields[ VALUE_FIELD ].SetText( wxT( "${SIM.PARAMS}" ) );
|
||||
FindField( m_fields, FIELD_T::VALUE )->SetText( wxT( "${SIM.PARAMS}" ) );
|
||||
}
|
||||
|
||||
std::string libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
wxString libraryFilename = GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
|
||||
if( libraryFilename != "" )
|
||||
{
|
||||
@@ -236,7 +220,7 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string modelName = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD );
|
||||
std::string modelName = GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD );
|
||||
int modelIdx = m_modelListBox->FindString( modelName );
|
||||
|
||||
if( modelIdx == wxNOT_FOUND )
|
||||
@@ -275,8 +259,7 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
|
||||
|
||||
for( const std::pair<std::string, std::string>& strs : ibismodel->GetIbisPins() )
|
||||
{
|
||||
if( strs.first
|
||||
== SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY_IBIS::PIN_FIELD ) )
|
||||
if( strs.first == GetFieldValue( &m_fields, SIM_LIBRARY_IBIS::PIN_FIELD ) )
|
||||
{
|
||||
auto ibisLibrary = static_cast<const SIM_LIBRARY_IBIS*>( library() );
|
||||
|
||||
@@ -291,11 +274,10 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
|
||||
{
|
||||
onPinCombobox( dummyEvent ); // refresh list of models
|
||||
|
||||
m_pinModelCombobox->SetStringSelection(
|
||||
SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY_IBIS::MODEL_FIELD ) );
|
||||
m_pinModelCombobox->SetStringSelection( GetFieldValue( &m_fields, SIM_LIBRARY_IBIS::MODEL_FIELD ) );
|
||||
}
|
||||
|
||||
if( SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY_IBIS::DIFF_FIELD ) == "1" )
|
||||
if( GetFieldValue( &m_fields, SIM_LIBRARY_IBIS::DIFF_FIELD ) == "1" )
|
||||
{
|
||||
ibismodel->SwitchSingleEndedDiff( true );
|
||||
m_differentialCheckbox->SetValue( true );
|
||||
@@ -308,8 +290,8 @@ bool DIALOG_SIM_MODEL<T>::TransferDataToWindow()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( !SIM_MODEL::GetFieldValue( &m_fields, SIM_DEVICE_FIELD ).empty()
|
||||
|| !SIM_MODEL::GetFieldValue( &m_fields, SIM_DEVICE_SUBTYPE_FIELD ).empty() )
|
||||
else if( !GetFieldValue( &m_fields, SIM_DEVICE_FIELD ).empty()
|
||||
|| !GetFieldValue( &m_fields, SIM_DEVICE_SUBTYPE_FIELD ).empty() )
|
||||
{
|
||||
// The model is sourced from the instance.
|
||||
m_rbBuiltinModel->SetValue( true );
|
||||
@@ -382,11 +364,11 @@ bool DIALOG_SIM_MODEL<T>::TransferDataFromWindow()
|
||||
if( m_modelListBox->GetSelection() >= 0 )
|
||||
name = m_modelListBox->GetStringSelection().ToStdString();
|
||||
else if( dynamic_cast<SIM_MODEL_SPICE_FALLBACK*>( &model ) )
|
||||
name = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD, false );
|
||||
name = GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD, false );
|
||||
}
|
||||
|
||||
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY::LIBRARY_FIELD, path, false );
|
||||
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY::NAME_FIELD, name, false );
|
||||
SetFieldValue( m_fields, SIM_LIBRARY::LIBRARY_FIELD, path, false );
|
||||
SetFieldValue( m_fields, SIM_LIBRARY::NAME_FIELD, name, false );
|
||||
|
||||
if( isIbisLoaded() )
|
||||
{
|
||||
@@ -411,9 +393,9 @@ bool DIALOG_SIM_MODEL<T>::TransferDataFromWindow()
|
||||
if( ibismodel->CanDifferential() && m_differentialCheckbox->GetValue() )
|
||||
differential = "1";
|
||||
|
||||
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY_IBIS::PIN_FIELD, pins );
|
||||
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY_IBIS::MODEL_FIELD, modelName );
|
||||
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY_IBIS::DIFF_FIELD, differential );
|
||||
SetFieldValue( m_fields, SIM_LIBRARY_IBIS::PIN_FIELD, pins );
|
||||
SetFieldValue( m_fields, SIM_LIBRARY_IBIS::MODEL_FIELD, modelName );
|
||||
SetFieldValue( m_fields, SIM_LIBRARY_IBIS::DIFF_FIELD, differential );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +465,7 @@ void DIALOG_SIM_MODEL<T>::updateWidgets()
|
||||
updateModelCodeTab( model );
|
||||
updatePinAssignments( model, model != m_prevModel );
|
||||
|
||||
std::string ref = SIM_MODEL::GetFieldValue( &m_fields, SIM_REFERENCE_FIELD );
|
||||
std::string ref = GetFieldValue( &m_fields, SIM_REFERENCE_FIELD );
|
||||
|
||||
m_modelPanel->Layout();
|
||||
m_pinAssignmentsPanel->Layout();
|
||||
@@ -724,7 +706,7 @@ void DIALOG_SIM_MODEL<T>::updateModelCodeTab( SIM_MODEL* aModel )
|
||||
item.modelName = m_modelListBox->GetStringSelection();
|
||||
|
||||
if( m_rbBuiltinModel->GetValue() || item.modelName == "" )
|
||||
item.modelName = m_fields.at( REFERENCE_FIELD ).GetText();
|
||||
item.modelName = GetFieldValue( &m_fields, FIELD_T::REFERENCE );
|
||||
|
||||
text << aModel->SpiceGenerator().Preview( item );
|
||||
|
||||
@@ -841,7 +823,7 @@ bool DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aLibraryPath, REPORTER& a
|
||||
if( aReporter.HasMessageOfSeverity( RPT_SEVERITY_UNDEFINED | RPT_SEVERITY_ERROR ) )
|
||||
return false;
|
||||
|
||||
std::string modelName = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD );
|
||||
std::string modelName = GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD );
|
||||
|
||||
for( const auto& [baseModelName, baseModel] : library()->GetModels() )
|
||||
{
|
||||
|
||||
@@ -125,7 +125,7 @@ LIB_ID DIALOG_SYMBOL_CHOOSER::GetSelectedLibId( int* aUnit ) const
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::pair<int, wxString>> DIALOG_SYMBOL_CHOOSER::GetFields() const
|
||||
std::vector<std::pair<FIELD_T, wxString>> DIALOG_SYMBOL_CHOOSER::GetFields() const
|
||||
{
|
||||
return m_chooserPanel->GetFields();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define DIALOG_SYMBOL_CHOOSER_H
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <template_fieldnames.h>
|
||||
#include <symbol_library_common.h>
|
||||
#include <symbol_tree_model_adapter.h>
|
||||
#include <footprint_info.h>
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
*
|
||||
* @return vector of pairs; each.first = field ID, each.second = new value.
|
||||
*/
|
||||
std::vector<std::pair<int, wxString>> GetFields() const;
|
||||
std::vector<std::pair<FIELD_T, wxString>> GetFields() const;
|
||||
|
||||
public:
|
||||
static std::mutex g_Mutex;
|
||||
|
||||
@@ -89,13 +89,15 @@ public:
|
||||
protected:
|
||||
void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) override
|
||||
{
|
||||
if( m_grid->GetGridCursorCol() == FOOTPRINT_FIELD )
|
||||
int col = m_grid->GetGridCursorCol();
|
||||
|
||||
if( m_dataModel->GetColFieldName( col ) == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
|
||||
{
|
||||
menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
|
||||
_( "Browse for footprint" ) );
|
||||
menu.AppendSeparator();
|
||||
}
|
||||
else if( m_grid->GetGridCursorCol() == DATASHEET_FIELD )
|
||||
else if( m_dataModel->GetColFieldName( col ) == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
|
||||
{
|
||||
menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
|
||||
_( "Show datasheet in browser" ) );
|
||||
@@ -107,24 +109,26 @@ protected:
|
||||
|
||||
void doPopupSelection( wxCommandEvent& event ) override
|
||||
{
|
||||
int row = m_grid->GetGridCursorRow();
|
||||
int col = m_grid->GetGridCursorCol();
|
||||
|
||||
if( event.GetId() == MYID_SELECT_FOOTPRINT )
|
||||
{
|
||||
// pick a footprint using the footprint picker.
|
||||
wxString fpid = m_grid->GetCellValue( m_grid->GetGridCursorRow(), FOOTPRINT_FIELD );
|
||||
wxString fpid = m_grid->GetCellValue( row, col );
|
||||
|
||||
if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true,
|
||||
m_dlg ) )
|
||||
{
|
||||
if( frame->ShowModal( &fpid, m_dlg ) )
|
||||
m_grid->SetCellValue( m_grid->GetGridCursorRow(), FOOTPRINT_FIELD, fpid );
|
||||
m_grid->SetCellValue( row, col, fpid );
|
||||
|
||||
frame->Destroy();
|
||||
}
|
||||
}
|
||||
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
||||
{
|
||||
wxString datasheet_uri = m_grid->GetCellValue( m_grid->GetGridCursorRow(),
|
||||
DATASHEET_FIELD );
|
||||
wxString datasheet_uri = m_grid->GetCellValue( row, col );
|
||||
GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj(),
|
||||
PROJECT_SCH::SchSearchS( &m_dlg->Prj() ) );
|
||||
}
|
||||
@@ -137,7 +141,7 @@ protected:
|
||||
{
|
||||
// Pop-up column order is the order of the shown fields, not the
|
||||
// fieldsCtrl order
|
||||
int col = event.GetId() - GRIDTRICKS_FIRST_SHOWHIDE;
|
||||
col = event.GetId() - GRIDTRICKS_FIRST_SHOWHIDE;
|
||||
|
||||
bool show = !m_dataModel->GetShowColumn( col );
|
||||
|
||||
@@ -145,7 +149,7 @@ protected:
|
||||
// and finding the matching field name
|
||||
wxString fieldName = m_dataModel->GetColFieldName( col );
|
||||
|
||||
for( int row = 0; row < m_fieldsCtrl->GetItemCount(); row++ )
|
||||
for( row = 0; row < m_fieldsCtrl->GetItemCount(); row++ )
|
||||
{
|
||||
if( m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN ) == fieldName )
|
||||
{
|
||||
@@ -189,9 +193,6 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent,
|
||||
m_removeFieldButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
||||
m_renameFieldButton->SetBitmap( KiBitmapBundle( BITMAPS::small_edit ) );
|
||||
|
||||
m_removeFieldButton->Enable( false );
|
||||
m_renameFieldButton->Enable( false );
|
||||
|
||||
m_bomPresetsLabel->SetFont( KIUI::GetInfoFont( this ) );
|
||||
m_labelBomExportPresets->SetFont( KIUI::GetInfoFont( this ) );
|
||||
|
||||
@@ -417,12 +418,12 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties( int aCol )
|
||||
attr->SetReadOnly();
|
||||
m_dataModel->SetColAttr( attr, aCol );
|
||||
}
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FOOTPRINT_FIELD ) )
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
|
||||
{
|
||||
attr->SetEditor( new GRID_CELL_FPID_EDITOR( this, wxEmptyString ) );
|
||||
m_dataModel->SetColAttr( attr, aCol );
|
||||
}
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( DATASHEET_FIELD ) )
|
||||
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
|
||||
{
|
||||
// set datasheet column viewer button
|
||||
attr->SetEditor( new GRID_CELL_URL_EDITOR( this, PROJECT_SCH::SchSearchS( &Prj() ),
|
||||
@@ -677,18 +678,20 @@ void DIALOG_SYMBOL_FIELDS_TABLE::AddField( const wxString& aFieldName, const wxS
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||
{
|
||||
auto addMandatoryField =
|
||||
[&]( int fieldId, bool show, bool groupBy )
|
||||
[&]( FIELD_T fieldId, bool show, bool groupBy )
|
||||
{
|
||||
m_mandatoryFieldListIndexes[fieldId] = m_fieldsCtrl->GetItemCount();
|
||||
|
||||
AddField( GetCanonicalFieldName( fieldId ),
|
||||
GetDefaultFieldName( fieldId, DO_TRANSLATE ), show, groupBy );
|
||||
};
|
||||
|
||||
// Add mandatory fields first show groupBy
|
||||
addMandatoryField( REFERENCE_FIELD, true, true );
|
||||
addMandatoryField( VALUE_FIELD, true, true );
|
||||
addMandatoryField( FOOTPRINT_FIELD, true, true );
|
||||
addMandatoryField( DATASHEET_FIELD, true, false );
|
||||
addMandatoryField( DESCRIPTION_FIELD, false, false );
|
||||
// Add mandatory fields first show groupBy
|
||||
addMandatoryField( FIELD_T::REFERENCE, true, true );
|
||||
addMandatoryField( FIELD_T::VALUE, true, true );
|
||||
addMandatoryField( FIELD_T::FOOTPRINT, true, true );
|
||||
addMandatoryField( FIELD_T::DATASHEET, true, false );
|
||||
addMandatoryField( FIELD_T::DESCRIPTION, false, false );
|
||||
|
||||
// Generated fields present only in the fields table
|
||||
AddField( FIELDS_EDITOR_GRID_DATA_MODEL::QUANTITY_VARIABLE, _( "Qty" ), true, false );
|
||||
@@ -763,10 +766,21 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnRemoveField( wxCommandEvent& event )
|
||||
int col = -1;
|
||||
int row = m_fieldsCtrl->GetSelectedRow();
|
||||
|
||||
// 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 >= MANDATORY_FIELD_COUNT, wxS( "Mandatory fields cannot be removed" ) );
|
||||
if( row == -1 )
|
||||
{
|
||||
wxBell();
|
||||
return;
|
||||
}
|
||||
|
||||
for( FIELD_T id : MANDATORY_FIELDS )
|
||||
{
|
||||
if( m_mandatoryFieldListIndexes[id] == row )
|
||||
{
|
||||
DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
|
||||
(int) m_mandatoryFieldListIndexes.size() ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
|
||||
wxString displayName = m_fieldsCtrl->GetTextValue( row, DISPLAY_NAME_COLUMN );
|
||||
@@ -791,12 +805,6 @@ 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 < MANDATORY_FIELD_COUNT )
|
||||
{
|
||||
m_removeFieldButton->Enable( false );
|
||||
m_renameFieldButton->Enable( false );
|
||||
}
|
||||
|
||||
wxGridTableMessage msg( m_dataModel, wxGRIDTABLE_NOTIFY_COLS_DELETED, col, 1 );
|
||||
|
||||
m_grid->ProcessTableMessage( msg );
|
||||
@@ -809,13 +817,23 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnRemoveField( wxCommandEvent& event )
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnRenameField( wxCommandEvent& event )
|
||||
{
|
||||
int row = m_fieldsCtrl->GetSelectedRow();
|
||||
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
|
||||
|
||||
// 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 >= MANDATORY_FIELD_COUNT, wxS( "Mandatory fields cannot be renamed" ) );
|
||||
wxCHECK_RET( !fieldName.IsEmpty(), wxS( "Field must have a name" ) );
|
||||
if( row == -1 )
|
||||
{
|
||||
wxBell();
|
||||
return;
|
||||
}
|
||||
|
||||
for( FIELD_T id : MANDATORY_FIELDS )
|
||||
{
|
||||
if( m_mandatoryFieldListIndexes[id] == row )
|
||||
{
|
||||
wxBell();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
|
||||
|
||||
int col = m_dataModel->GetFieldNameCol( fieldName );
|
||||
wxCHECK_RET( col != -1, wxS( "Existing field name missing from data model" ) );
|
||||
@@ -876,23 +894,6 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnFilterMouseMoved( wxMouseEvent& aEvent )
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnFieldsCtrlSelectionChanged( wxDataViewEvent& event )
|
||||
{
|
||||
int row = m_fieldsCtrl->GetSelectedRow();
|
||||
|
||||
if( row >= MANDATORY_FIELD_COUNT )
|
||||
{
|
||||
m_removeFieldButton->Enable( true );
|
||||
m_renameFieldButton->Enable( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_removeFieldButton->Enable( false );
|
||||
m_renameFieldButton->Enable( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled( wxDataViewEvent& event )
|
||||
{
|
||||
wxDataViewItem item = event.GetItem();
|
||||
|
||||
@@ -91,7 +91,6 @@ private:
|
||||
void OnOk( wxCommandEvent& aEvent ) override;
|
||||
void OnFilterText( wxCommandEvent& aEvent ) override;
|
||||
void OnFilterMouseMoved( wxMouseEvent& event ) override;
|
||||
void OnFieldsCtrlSelectionChanged( wxDataViewEvent& event ) override;
|
||||
|
||||
void OnOutputFileBrowseClicked( wxCommandEvent& event ) override;
|
||||
void OnPageChanged( wxNotebookEvent& event ) override;
|
||||
@@ -152,6 +151,10 @@ private:
|
||||
wxArrayString m_bomFmtPresetMRU;
|
||||
|
||||
SCH_EDIT_FRAME* m_parent;
|
||||
|
||||
// Index in the fields list control for each MANDATORY_FIELD type
|
||||
std::map<FIELD_T, int> m_mandatoryFieldListIndexes;
|
||||
|
||||
int m_fieldNameColWidth;
|
||||
int m_labelColWidth;
|
||||
int m_showColWidth;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
|
||||
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
@@ -358,7 +358,6 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnClose ) );
|
||||
m_nbPages->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnPageChanged ), NULL, this );
|
||||
m_fieldsCtrl->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnColumnItemToggled ), NULL, this );
|
||||
m_fieldsCtrl->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnFieldsCtrlSelectionChanged ), NULL, this );
|
||||
m_fieldsCtrl->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnSizeFieldList ), NULL, this );
|
||||
m_addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnAddField ), NULL, this );
|
||||
m_renameFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRenameField ), NULL, this );
|
||||
@@ -397,7 +396,6 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::~DIALOG_SYMBOL_FIELDS_TABLE_BASE()
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnClose ) );
|
||||
m_nbPages->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnPageChanged ), NULL, this );
|
||||
m_fieldsCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnColumnItemToggled ), NULL, this );
|
||||
m_fieldsCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnFieldsCtrlSelectionChanged ), NULL, this );
|
||||
m_fieldsCtrl->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnSizeFieldList ), NULL, this );
|
||||
m_addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnAddField ), NULL, this );
|
||||
m_renameFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRenameField ), NULL, this );
|
||||
|
||||
@@ -1,34 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="17"/>
|
||||
<FileVersion major="1" minor="18"/>
|
||||
<object class="Project" expanded="true">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
<property name="disconnect_events">1</property>
|
||||
<property name="disconnect_mode">source_name</property>
|
||||
<property name="disconnect_php_events">0</property>
|
||||
<property name="disconnect_python_events">0</property>
|
||||
<property name="cpp_class_decoration"></property>
|
||||
<property name="cpp_disconnect_events">1</property>
|
||||
<property name="cpp_event_generation">connect</property>
|
||||
<property name="cpp_help_provider">none</property>
|
||||
<property name="cpp_namespace"></property>
|
||||
<property name="cpp_precompiled_header"></property>
|
||||
<property name="cpp_use_array_enum">0</property>
|
||||
<property name="cpp_use_enum">0</property>
|
||||
<property name="embedded_files_path">res</property>
|
||||
<property name="encoding">UTF-8</property>
|
||||
<property name="event_generation">connect</property>
|
||||
<property name="file">dialog_symbol_fields_table_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="lua_skip_events">1</property>
|
||||
<property name="lua_ui_table">UI</property>
|
||||
<property name="name">dialog_symbol_fields_table_base</property>
|
||||
<property name="namespace"></property>
|
||||
<property name="path">.</property>
|
||||
<property name="precompiled_header"></property>
|
||||
<property name="php_disconnect_events">0</property>
|
||||
<property name="php_disconnect_mode">source_name</property>
|
||||
<property name="php_skip_events">1</property>
|
||||
<property name="python_disconnect_events">0</property>
|
||||
<property name="python_disconnect_mode">source_name</property>
|
||||
<property name="python_image_path_wrapper_function_name"></property>
|
||||
<property name="python_indent_with_spaces"></property>
|
||||
<property name="python_skip_events">1</property>
|
||||
<property name="relative_path">1</property>
|
||||
<property name="skip_lua_events">1</property>
|
||||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<property name="use_native_eol">0</property>
|
||||
<object class="Dialog" expanded="true">
|
||||
<property name="aui_managed">0</property>
|
||||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||
@@ -72,10 +74,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmapsize"></property>
|
||||
@@ -131,10 +133,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -192,10 +194,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -251,10 +253,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -330,7 +332,6 @@
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnDataViewListCtrlItemValueChanged">OnColumnItemToggled</event>
|
||||
<event name="OnDataViewListCtrlSelectionChanged">OnFieldsCtrlSelectionChanged</event>
|
||||
<event name="OnSize">OnSizeFieldList</event>
|
||||
</object>
|
||||
</object>
|
||||
@@ -352,10 +353,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -427,10 +428,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -512,10 +513,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -598,10 +599,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -657,10 +658,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -719,10 +720,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -786,10 +787,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -856,10 +857,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="cancel_button">1</property>
|
||||
@@ -924,10 +925,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -983,10 +984,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1049,10 +1050,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1115,10 +1116,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1174,10 +1175,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1240,10 +1241,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1299,10 +1300,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -1376,10 +1377,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="autosize_cols">0</property>
|
||||
<property name="autosize_rows">0</property>
|
||||
<property name="best_size"></property>
|
||||
@@ -1470,10 +1471,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1545,10 +1546,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1607,10 +1608,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1673,10 +1674,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1739,10 +1740,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1805,10 +1806,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1867,10 +1868,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1932,10 +1933,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -1997,10 +1998,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2072,10 +2073,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2160,10 +2161,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2225,10 +2226,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2252,7 +2253,7 @@
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="maxlength">0</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">60,-1</property>
|
||||
@@ -2294,10 +2295,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2359,10 +2360,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2386,7 +2387,7 @@
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="maxlength">0</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">60,-1</property>
|
||||
@@ -2428,10 +2429,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2493,10 +2494,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2520,7 +2521,7 @@
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="maxlength">0</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">60,-1</property>
|
||||
@@ -2562,10 +2563,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2627,10 +2628,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2654,7 +2655,7 @@
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="maxlength">0</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">60,-1</property>
|
||||
@@ -2696,10 +2697,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2765,10 +2766,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2834,10 +2835,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2896,10 +2897,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -2961,10 +2962,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -3040,10 +3041,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -3102,10 +3103,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -3167,10 +3168,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -3256,10 +3257,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -3328,10 +3329,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -3408,10 +3409,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
@@ -3435,7 +3436,7 @@
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="maxlength">0</property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
@@ -3497,10 +3498,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
@@ -3572,10 +3573,10 @@
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
|
||||
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
@@ -112,7 +112,6 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
|
||||
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void OnPageChanged( wxNotebookEvent& event ) { event.Skip(); }
|
||||
virtual void OnColumnItemToggled( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnFieldsCtrlSelectionChanged( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnSizeFieldList( wxSizeEvent& event ) { event.Skip(); }
|
||||
virtual void OnAddField( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRenameField( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
@@ -396,9 +396,11 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
|
||||
Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
|
||||
Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
|
||||
|
||||
QueueEvent( new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
|
||||
wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
|
||||
evt->SetClientData( new VECTOR2I( REFERENCE_FIELD, FDC_VALUE ) );
|
||||
wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
|
||||
evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
|
||||
QueueEvent( evt );
|
||||
evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
|
||||
evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
|
||||
QueueEvent( evt );
|
||||
|
||||
finishDialogSettings();
|
||||
@@ -446,9 +448,9 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
std::set<wxString> defined;
|
||||
|
||||
// Push a copy of each field into m_updateFields
|
||||
for( int i = 0; i < m_symbol->GetFieldCount(); ++i )
|
||||
for( SCH_FIELD& srcField : m_symbol->GetFields() )
|
||||
{
|
||||
SCH_FIELD field( m_symbol->GetFields()[i] );
|
||||
SCH_FIELD field( srcField );
|
||||
|
||||
// change offset to be symbol-relative
|
||||
field.Offset( -m_symbol->GetPosition() );
|
||||
@@ -465,7 +467,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
if( defined.count( templateFieldname.m_Name ) <= 0 )
|
||||
{
|
||||
SCH_FIELD field( VECTOR2I( 0, 0 ), -1, m_symbol, templateFieldname.m_Name );
|
||||
SCH_FIELD field( { 0, 0 }, FIELD_T::USER, m_symbol, templateFieldname.m_Name );
|
||||
field.SetVisible( templateFieldname.m_Visible );
|
||||
m_fields->push_back( field );
|
||||
}
|
||||
@@ -743,15 +745,24 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
||||
fields.push_back( field );
|
||||
}
|
||||
|
||||
int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
|
||||
|
||||
for( SCH_FIELD& field : fields )
|
||||
{
|
||||
if( !field.IsMandatory() )
|
||||
field.SetOrdinal( ordinal++ );
|
||||
}
|
||||
|
||||
// Reference has a specific initialization, depending on the current active sheet
|
||||
// because for a given symbol, in a complex hierarchy, there are more than one
|
||||
// reference.
|
||||
m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
|
||||
m_symbol->SetRef( &GetParent()->GetCurrentSheet(),
|
||||
m_fields->GetField( FIELD_T::REFERENCE )->GetText() );
|
||||
|
||||
// Similar for Value and Footprint, except that the GUI behavior is that they are kept
|
||||
// in sync between multiple instances.
|
||||
m_symbol->SetValueFieldText( m_fields->at( VALUE_FIELD ).GetText() );
|
||||
m_symbol->SetFootprintFieldText( m_fields->at( FOOTPRINT_FIELD ).GetText() );
|
||||
m_symbol->SetValueFieldText( m_fields->GetField( FIELD_T::VALUE )->GetText() );
|
||||
m_symbol->SetFootprintFieldText( m_fields->GetField( FIELD_T::FOOTPRINT )->GetText() );
|
||||
|
||||
m_symbol->SetExcludedFromSim( m_cbExcludeFromSim->IsChecked() );
|
||||
m_symbol->SetExcludedFromBOM( m_cbExcludeFromBom->IsChecked() );
|
||||
@@ -824,8 +835,13 @@ void DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
|
||||
|
||||
void DIALOG_SYMBOL_PROPERTIES::OnGridEditorShown( wxGridEvent& aEvent )
|
||||
{
|
||||
if( aEvent.GetRow() == REFERENCE_FIELD && aEvent.GetCol() == FDC_VALUE )
|
||||
QueueEvent( new wxCommandEvent( SYMBOL_DELAY_SELECTION ) );
|
||||
if( m_fields->at( aEvent.GetRow() ).GetId() == FIELD_T::REFERENCE
|
||||
&& aEvent.GetCol() == FDC_VALUE )
|
||||
{
|
||||
wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
|
||||
evt->SetClientData( new VECTOR2I( aEvent.GetRow(), aEvent.GetCol() ) );
|
||||
QueueEvent( evt );
|
||||
}
|
||||
|
||||
m_editorShown = true;
|
||||
}
|
||||
@@ -843,10 +859,10 @@ void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
|
||||
return;
|
||||
|
||||
SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings();
|
||||
int fieldID = (int) m_fields->size();
|
||||
SCH_FIELD newField( VECTOR2I(), fieldID, m_symbol, GetUserFieldName( fieldID, DO_TRANSLATE ) );
|
||||
SCH_FIELD newField( { 0, 0 }, FIELD_T::USER, m_symbol,
|
||||
GetUserFieldName( (int) m_fields->size(), DO_TRANSLATE ) );
|
||||
|
||||
newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
|
||||
newField.SetTextAngle( m_fields->GetField( FIELD_T::REFERENCE )->GetTextAngle() );
|
||||
newField.SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
|
||||
newField.SetVisible( false );
|
||||
|
||||
@@ -1103,8 +1119,12 @@ void DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus( wxCommandEvent& event )
|
||||
|
||||
void DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection( wxCommandEvent& event )
|
||||
{
|
||||
VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
|
||||
|
||||
wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
|
||||
|
||||
// Handle a delayed selection
|
||||
wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( REFERENCE_FIELD, FDC_VALUE );
|
||||
wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( loc->x, loc->y );
|
||||
|
||||
if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
|
||||
KIUI::SelectReferenceNumber( txt );
|
||||
|
||||
@@ -46,10 +46,11 @@ 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 < MANDATORY_FIELD_COUNT; ++i )
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
m_fieldsBox->Append( GetDefaultFieldName( i, DO_TRANSLATE ) );
|
||||
m_fieldsBox->Check( i, true );
|
||||
m_mandatoryFieldListIndexes[fieldId] = m_fieldsBox->GetCount();
|
||||
m_fieldsBox->Append( GetDefaultFieldName( fieldId, DO_TRANSLATE ) );
|
||||
m_fieldsBox->Check( m_fieldsBox->GetCount() - 1, true );
|
||||
}
|
||||
|
||||
updateFieldsList();
|
||||
@@ -105,17 +106,35 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::updateFieldsList()
|
||||
fieldNames.insert( libField->GetName() );
|
||||
}
|
||||
|
||||
auto isMandatoryField =
|
||||
[&]( int listbox_idx )
|
||||
{
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
if( m_mandatoryFieldListIndexes[fieldId] == listbox_idx )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
libFields.clear();
|
||||
|
||||
// Update the listbox widget
|
||||
for( unsigned i = m_fieldsBox->GetCount() - 1; i >= MANDATORY_FIELD_COUNT; --i )
|
||||
m_fieldsBox->Delete( i );
|
||||
for( int i = (int) m_fieldsBox->GetCount() - 1; i >= 0; --i )
|
||||
{
|
||||
if( !isMandatoryField( i ) )
|
||||
m_fieldsBox->Delete( i );
|
||||
}
|
||||
|
||||
for( const wxString& fieldName : fieldNames )
|
||||
m_fieldsBox->Append( fieldName );
|
||||
|
||||
for( unsigned i = MANDATORY_FIELD_COUNT; i < m_fieldsBox->GetCount(); ++i )
|
||||
m_fieldsBox->Check( i, true );
|
||||
for( int i = 0; i < (int) m_fieldsBox->GetCount(); ++i )
|
||||
{
|
||||
if( !isMandatoryField( i ) )
|
||||
m_fieldsBox->Check( i, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +179,10 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
|
||||
|
||||
if( alg::contains( m_updateFields, field.GetName() ) )
|
||||
{
|
||||
parentField = flattenedParent->FindField( field.GetName() );
|
||||
if( field.IsMandatory() )
|
||||
parentField = flattenedParent->GetField( field.GetId() );
|
||||
else
|
||||
parentField = flattenedParent->GetField( field.GetName() );
|
||||
|
||||
if( parentField )
|
||||
{
|
||||
@@ -202,7 +224,6 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
|
||||
}
|
||||
|
||||
std::vector<SCH_FIELD*> parentFields;
|
||||
int idx = result.size();
|
||||
|
||||
flattenedParent->GetFields( parentFields );
|
||||
|
||||
@@ -211,9 +232,9 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent )
|
||||
if( !alg::contains( m_updateFields, parentField->GetName() ) )
|
||||
continue;
|
||||
|
||||
if( !m_symbol->FindField( parentField->GetName() ) )
|
||||
if( !m_symbol->GetField( parentField->GetName() ) )
|
||||
{
|
||||
result.emplace_back( m_symbol, idx++ );
|
||||
result.emplace_back( m_symbol, FIELD_T::USER );
|
||||
SCH_FIELD* newField = &result.back();
|
||||
|
||||
newField->SetName( parentField->GetCanonicalName() );
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <dialog_update_symbol_fields_base.h>
|
||||
#include <set>
|
||||
#include <template_fieldnames.h>
|
||||
|
||||
class LIB_ID;
|
||||
class LIB_SYMBOL;
|
||||
@@ -56,11 +57,15 @@ protected:
|
||||
private:
|
||||
void updateFieldsList();
|
||||
|
||||
private:
|
||||
SYMBOL_EDIT_FRAME* m_editFrame;
|
||||
LIB_SYMBOL* m_symbol;
|
||||
|
||||
/// Set of field names that should have values updated.
|
||||
std::set<wxString> m_updateFields;
|
||||
std::set<wxString> m_updateFields;
|
||||
|
||||
/// Index in the list control for each MANDATORY_FIELD type
|
||||
std::map<FIELD_T, int> m_mandatoryFieldListIndexes;
|
||||
};
|
||||
|
||||
#endif // DIALOG_UPDATE_SYMBOL_FIELDS_H
|
||||
|
||||
@@ -441,12 +441,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
|
||||
addItem( symbol );
|
||||
}
|
||||
|
||||
SCH_SHEET* s = new SCH_SHEET(
|
||||
/* aParent */ nullptr,
|
||||
/* aPosition */ MILS_POINT( 4000, 1300 ),
|
||||
/* aSize */ VECTOR2I( schIUScale.MilsToIU( 800 ), schIUScale.MilsToIU( 1300 ) ) );
|
||||
s->GetFields().at( SHEETNAME ).SetText( wxT( "SHEET" ) );
|
||||
s->GetFields().at( SHEETFILENAME ).SetText( _( "/path/to/sheet" ) );
|
||||
SCH_SHEET* s = new SCH_SHEET( nullptr, MILS_POINT( 4000, 1300 ), MILS_POINT( 800, 1300 ) );
|
||||
s->GetField( FIELD_T::SHEET_NAME )->SetText( wxT( "SHEET" ) );
|
||||
s->GetField( FIELD_T::SHEET_FILENAME )->SetText( _( "/path/to/sheet" ) );
|
||||
s->AutoplaceFields( nullptr, AUTOPLACE_AUTO );
|
||||
addItem( s );
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
||||
FIELDS_EDITOR_GRID_DATA_MODEL dataModel( referenceList, nullptr );
|
||||
|
||||
// Mandatory fields + quantity virtual field first
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
dataModel.AddColumn( GetCanonicalFieldName( fieldId ),
|
||||
GetDefaultFieldName( fieldId, DO_TRANSLATE ), false );
|
||||
|
||||
@@ -58,7 +58,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::updateDataStoreSymbolField( const SCH_SYMBOL
|
||||
{
|
||||
m_dataStore[aSymbol.m_Uuid][aFieldName] = getAttributeValue( aSymbol, aFieldName );
|
||||
}
|
||||
else if( const SCH_FIELD* field = aSymbol.GetFieldByName( aFieldName ) )
|
||||
else if( const SCH_FIELD* field = aSymbol.GetField( aFieldName ) )
|
||||
{
|
||||
if( field->IsPrivate() )
|
||||
{
|
||||
@@ -178,7 +178,7 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( int aRow, int aCol )
|
||||
wxGridCellAttr* FIELDS_EDITOR_GRID_DATA_MODEL::GetAttr( int aRow, int aCol,
|
||||
wxGridCellAttr::wxAttrKind aKind )
|
||||
{
|
||||
if( GetColFieldName( aCol ) == GetCanonicalFieldName( DATASHEET_FIELD )
|
||||
if( GetColFieldName( aCol ) == GetCanonicalFieldName( FIELD_T::DATASHEET )
|
||||
|| IsURL( GetValue( m_rows[aRow], aCol ) ) )
|
||||
{
|
||||
if( m_urlEditor )
|
||||
@@ -324,14 +324,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 );
|
||||
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( FIELD_T::REFERENCE );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( FIELD_T::VALUE );
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::cmp( const DATA_MODEL_ROW& lhGroup,
|
||||
wxString lhs = dataModel->GetValue( lhGroup, sortCol ).Trim( true ).Trim( false );
|
||||
wxString rhs = dataModel->GetValue( rhGroup, sortCol ).Trim( true ).Trim( false );
|
||||
|
||||
if( lhs == rhs || sortCol == REFERENCE_FIELD )
|
||||
if( lhs == rhs || dataModel->ColIsReference( sortCol ) )
|
||||
{
|
||||
wxString lhRef = lhGroup.m_Refs[0].GetRef() + lhGroup.m_Refs[0].GetRefNumber();
|
||||
wxString rhRef = rhGroup.m_Refs[0].GetRef() + rhGroup.m_Refs[0].GetRefNumber();
|
||||
@@ -445,7 +445,7 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
||||
const SCH_REFERENCE& rhRef )
|
||||
|
||||
{
|
||||
int refCol = GetFieldNameCol( GetCanonicalFieldName( REFERENCE_FIELD ) );
|
||||
int refCol = GetFieldNameCol( GetCanonicalFieldName( FIELD_T::REFERENCE ) );
|
||||
bool matchFound = false;
|
||||
|
||||
if( refCol == -1 )
|
||||
@@ -516,7 +516,7 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
||||
wxString FIELDS_EDITOR_GRID_DATA_MODEL::getFieldShownText( const SCH_REFERENCE& aRef,
|
||||
const wxString& aFieldName )
|
||||
{
|
||||
SCH_FIELD* field = aRef.GetSymbol()->GetFieldByName( aFieldName );
|
||||
SCH_FIELD* field = aRef.GetSymbol()->GetField( aFieldName );
|
||||
|
||||
if( field )
|
||||
{
|
||||
@@ -809,7 +809,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData( SCH_COMMIT& aCommit )
|
||||
if( IsTextVar( srcName ) )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* destField = symbol.FindField( srcName );
|
||||
SCH_FIELD* destField = symbol.GetField( srcName );
|
||||
|
||||
if( destField && destField->IsPrivate() )
|
||||
{
|
||||
@@ -828,13 +828,13 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData( SCH_COMMIT& aCommit )
|
||||
if( createField )
|
||||
{
|
||||
const VECTOR2I symbolPos = symbol.GetPosition();
|
||||
destField = symbol.AddField( SCH_FIELD( symbolPos, -1, &symbol, srcName ) );
|
||||
destField = symbol.AddField( SCH_FIELD( symbolPos, FIELD_T::USER, &symbol, srcName ) );
|
||||
}
|
||||
|
||||
if( !destField )
|
||||
continue;
|
||||
|
||||
if( destField->GetId() == REFERENCE_FIELD )
|
||||
if( destField->GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
// Reference is not editable from this dialog
|
||||
continue;
|
||||
@@ -928,7 +928,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 ) );
|
||||
sortCol = GetFieldNameCol( GetCanonicalFieldName( FIELD_T::REFERENCE ) );
|
||||
|
||||
SetSorting( sortCol, aPreset.sortAsc );
|
||||
|
||||
|
||||
@@ -138,12 +138,12 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFra
|
||||
m_part( aSymbol ),
|
||||
m_files( aFiles ),
|
||||
m_symbolNetlist( netList( aSymbol ) ),
|
||||
m_fieldNameValidator( FIELD_NAME ),
|
||||
m_referenceValidator( REFERENCE_FIELD ),
|
||||
m_valueValidator( VALUE_FIELD ),
|
||||
m_urlValidator( FIELD_VALUE ),
|
||||
m_nonUrlValidator( FIELD_VALUE ),
|
||||
m_filepathValidator( SHEETFILENAME )
|
||||
m_fieldNameValidator( FIELD_T::USER ),
|
||||
m_referenceValidator( FIELD_T::REFERENCE ),
|
||||
m_valueValidator( FIELD_T::VALUE ),
|
||||
m_urlValidator( FIELD_T::USER ),
|
||||
m_nonUrlValidator( FIELD_T::USER ),
|
||||
m_filepathValidator( FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
initGrid( aGrid );
|
||||
}
|
||||
@@ -157,12 +157,12 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFra
|
||||
m_part( aSymbol->GetLibSymbolRef().get() ),
|
||||
m_files( aFiles ),
|
||||
m_symbolNetlist( netList( aSymbol, aFrame->GetCurrentSheet() ) ),
|
||||
m_fieldNameValidator( FIELD_NAME ),
|
||||
m_referenceValidator( REFERENCE_FIELD ),
|
||||
m_valueValidator( VALUE_FIELD ),
|
||||
m_urlValidator( FIELD_VALUE ),
|
||||
m_nonUrlValidator( FIELD_VALUE ),
|
||||
m_filepathValidator( SHEETFILENAME )
|
||||
m_fieldNameValidator( FIELD_T::USER ),
|
||||
m_referenceValidator( FIELD_T::REFERENCE ),
|
||||
m_valueValidator( FIELD_T::VALUE ),
|
||||
m_urlValidator( FIELD_T::USER ),
|
||||
m_nonUrlValidator( FIELD_T::USER ),
|
||||
m_filepathValidator( FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
initGrid( aGrid );
|
||||
}
|
||||
@@ -175,12 +175,12 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFra
|
||||
m_parentType( SCH_SHEET_T ),
|
||||
m_part( nullptr ),
|
||||
m_files( nullptr ),
|
||||
m_fieldNameValidator( FIELD_NAME ),
|
||||
m_referenceValidator( SHEETNAME_V ),
|
||||
m_valueValidator( VALUE_FIELD ),
|
||||
m_urlValidator( FIELD_VALUE ),
|
||||
m_nonUrlValidator( FIELD_VALUE ),
|
||||
m_filepathValidator( SHEETFILENAME_V )
|
||||
m_fieldNameValidator( FIELD_T::USER ),
|
||||
m_referenceValidator( FIELD_T::SHEET_NAME ),
|
||||
m_valueValidator( FIELD_T::VALUE ),
|
||||
m_urlValidator( FIELD_T::USER ),
|
||||
m_nonUrlValidator( FIELD_T::USER ),
|
||||
m_filepathValidator( FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
initGrid( aGrid );
|
||||
}
|
||||
@@ -192,12 +192,12 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFra
|
||||
m_dialog( aDialog ),
|
||||
m_parentType( SCH_LABEL_LOCATE_ANY_T ),
|
||||
m_part( nullptr ),
|
||||
m_fieldNameValidator( FIELD_NAME ),
|
||||
m_referenceValidator( 0 ),
|
||||
m_valueValidator( 0 ),
|
||||
m_urlValidator( FIELD_VALUE ),
|
||||
m_nonUrlValidator( FIELD_VALUE ),
|
||||
m_filepathValidator( 0 )
|
||||
m_fieldNameValidator( FIELD_T::USER ),
|
||||
m_referenceValidator( FIELD_T::USER ),
|
||||
m_valueValidator( FIELD_T::USER ),
|
||||
m_urlValidator( FIELD_T::USER ),
|
||||
m_nonUrlValidator( FIELD_T::USER ),
|
||||
m_filepathValidator( FIELD_T::USER )
|
||||
{
|
||||
initGrid( aGrid );
|
||||
}
|
||||
@@ -249,8 +249,8 @@ void FIELDS_GRID_TABLE::initGrid( WX_GRID* aGrid )
|
||||
GRID_CELL_STC_EDITOR* valueEditor = new GRID_CELL_STC_EDITOR( true,
|
||||
[this]( wxStyledTextEvent& aEvent, SCINTILLA_TRICKS* aScintillaTricks )
|
||||
{
|
||||
SCH_FIELD& valueField = static_cast<SCH_FIELD&>( this->at( VALUE_FIELD ) );
|
||||
valueField.OnScintillaCharAdded( aScintillaTricks, aEvent );
|
||||
SCH_FIELD* valueField = this->GetField( FIELD_T::VALUE );
|
||||
valueField->OnScintillaCharAdded( aScintillaTricks, aEvent );
|
||||
} );
|
||||
|
||||
m_valueAttr->SetEditor( valueEditor );
|
||||
@@ -548,17 +548,17 @@ wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::
|
||||
}
|
||||
|
||||
case FDC_VALUE:
|
||||
if( m_parentType == SCH_SYMBOL_T && field.GetId() == REFERENCE_FIELD )
|
||||
if( field.GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
m_referenceAttr->IncRef();
|
||||
return enhanceAttr( m_referenceAttr, aRow, aCol, aKind );
|
||||
}
|
||||
else if( m_parentType == SCH_SYMBOL_T && field.GetId() == VALUE_FIELD )
|
||||
else if( field.GetId() == FIELD_T::VALUE )
|
||||
{
|
||||
m_valueAttr->IncRef();
|
||||
return enhanceAttr( m_valueAttr, aRow, aCol, aKind );
|
||||
}
|
||||
else if( m_parentType == SCH_SYMBOL_T && field.GetId() == FOOTPRINT_FIELD )
|
||||
else if( field.GetId() == FIELD_T::FOOTPRINT )
|
||||
{
|
||||
// Power symbols have do not appear in the board, so don't allow
|
||||
// a footprint (m_part can be nullptr when loading a old schematic
|
||||
@@ -574,17 +574,17 @@ wxGridCellAttr* FIELDS_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::
|
||||
return enhanceAttr( m_footprintAttr, aRow, aCol, aKind );
|
||||
}
|
||||
}
|
||||
else if( m_parentType == SCH_SYMBOL_T && field.GetId() == DATASHEET_FIELD )
|
||||
else if( field.GetId() == FIELD_T::DATASHEET )
|
||||
{
|
||||
m_urlAttr->IncRef();
|
||||
return enhanceAttr( m_urlAttr, aRow, aCol, aKind );
|
||||
}
|
||||
else if( m_parentType == SCH_SHEET_T && field.GetId() == SHEETNAME )
|
||||
else if( field.GetId() == FIELD_T::SHEET_NAME )
|
||||
{
|
||||
m_referenceAttr->IncRef();
|
||||
return enhanceAttr( m_referenceAttr, aRow, aCol, aKind );
|
||||
}
|
||||
else if( m_parentType == SCH_SHEET_T && field.GetId() == SHEETFILENAME )
|
||||
else if( field.GetId() == FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
m_filepathAttr->IncRef();
|
||||
return enhanceAttr( m_filepathAttr, aRow, aCol, aKind );
|
||||
@@ -678,28 +678,16 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol )
|
||||
case FDC_NAME:
|
||||
// Use default field names for mandatory and system fields because they are translated
|
||||
// according to the current locale
|
||||
if( m_parentType == SCH_SYMBOL_T || m_parentType == LIB_SYMBOL_T )
|
||||
{
|
||||
if( field.IsMandatory() )
|
||||
return GetDefaultFieldName( aRow, DO_TRANSLATE );
|
||||
else
|
||||
return field.GetName( false );
|
||||
}
|
||||
else if( m_parentType == SCH_SHEET_T )
|
||||
{
|
||||
if( field.IsMandatory() )
|
||||
return SCH_SHEET::GetDefaultFieldName( field.GetId(), DO_TRANSLATE );
|
||||
else
|
||||
return field.GetName( false );
|
||||
}
|
||||
else if( m_parentType == SCH_LABEL_LOCATE_ANY_T )
|
||||
if( m_parentType == SCH_LABEL_LOCATE_ANY_T )
|
||||
{
|
||||
return SCH_LABEL_BASE::GetDefaultFieldName( field.GetCanonicalName(), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( wxS( "Unhandled field owner type." ) );
|
||||
return field.GetName( false );
|
||||
if( field.IsMandatory() )
|
||||
return GetDefaultFieldName( field.GetId(), DO_TRANSLATE );
|
||||
else
|
||||
return field.GetName( false );
|
||||
}
|
||||
|
||||
case FDC_VALUE:
|
||||
@@ -833,11 +821,11 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
|
||||
|
||||
case FDC_VALUE:
|
||||
{
|
||||
if( m_parentType == SCH_SHEET_T && field.GetId() == SHEETFILENAME )
|
||||
if( m_parentType == SCH_SHEET_T && field.GetId() == FIELD_T::SHEET_FILENAME )
|
||||
{
|
||||
value = EnsureFileExtension( value, FILEEXT::KiCadSchematicFileExtension );
|
||||
}
|
||||
else if( m_parentType == LIB_SYMBOL_T && field.GetId() == VALUE_FIELD )
|
||||
else if( m_parentType == LIB_SYMBOL_T && field.GetId() == FIELD_T::VALUE )
|
||||
{
|
||||
value = EscapeString( value, CTX_LIBID );
|
||||
}
|
||||
@@ -1039,6 +1027,30 @@ bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* FIELDS_GRID_TABLE::GetField( FIELD_T aFieldId )
|
||||
{
|
||||
for( SCH_FIELD& field : *this )
|
||||
{
|
||||
if( field.GetId() == aFieldId )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
int FIELDS_GRID_TABLE::GetFieldRow( FIELD_T aFieldId )
|
||||
{
|
||||
for( int ii = 0; ii < (int) this->size(); ++ii )
|
||||
{
|
||||
if( this->at( ii ).GetId() == aFieldId )
|
||||
return ii;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void FIELDS_GRID_TABLE::DetachFields()
|
||||
{
|
||||
for( SCH_FIELD& field : *this )
|
||||
@@ -1046,17 +1058,25 @@ void FIELDS_GRID_TABLE::DetachFields()
|
||||
}
|
||||
|
||||
|
||||
int FIELDS_GRID_TRICKS::getFieldRow( FIELD_T aFieldId )
|
||||
{
|
||||
return static_cast<FIELDS_GRID_TABLE*>( m_grid->GetTable() )->GetFieldRow( aFieldId );
|
||||
}
|
||||
|
||||
|
||||
void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
|
||||
{
|
||||
if( m_grid->GetGridCursorRow() == FOOTPRINT_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE
|
||||
&& !m_grid->IsReadOnly( FOOTPRINT_FIELD, FDC_VALUE ) )
|
||||
if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::FOOTPRINT )
|
||||
&& m_grid->GetGridCursorCol() == FDC_VALUE
|
||||
&& !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
|
||||
{
|
||||
menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
|
||||
_( "Browse for footprint" ) );
|
||||
menu.AppendSeparator();
|
||||
}
|
||||
else if( m_grid->GetGridCursorRow() == DATASHEET_FIELD
|
||||
&& m_grid->GetGridCursorCol() == FDC_VALUE )
|
||||
else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
|
||||
&& m_grid->GetGridCursorCol() == FDC_VALUE
|
||||
&& !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
|
||||
{
|
||||
menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
|
||||
_( "Show datasheet in browser" ) );
|
||||
@@ -1072,19 +1092,19 @@ void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
|
||||
if( event.GetId() == MYID_SELECT_FOOTPRINT )
|
||||
{
|
||||
// pick a footprint using the footprint picker.
|
||||
wxString fpid = m_grid->GetCellValue( FOOTPRINT_FIELD, FDC_VALUE );
|
||||
wxString fpid = m_grid->GetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE );
|
||||
|
||||
if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_dlg ) )
|
||||
{
|
||||
if( frame->ShowModal( &fpid, m_dlg ) )
|
||||
m_grid->SetCellValue( FOOTPRINT_FIELD, FDC_VALUE, fpid );
|
||||
m_grid->SetCellValue( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE, fpid );
|
||||
|
||||
frame->Destroy();
|
||||
}
|
||||
}
|
||||
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
||||
{
|
||||
wxString datasheet_uri = m_grid->GetCellValue( DATASHEET_FIELD, FDC_VALUE );
|
||||
wxString datasheet_uri = m_grid->GetCellValue( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE );
|
||||
|
||||
GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj(),
|
||||
PROJECT_SCH::SchSearchS( &m_dlg->Prj() ), m_files );
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
{}
|
||||
|
||||
protected:
|
||||
int getFieldRow( FIELD_T aFieldId );
|
||||
|
||||
void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) override;
|
||||
void doPopupSelection( wxCommandEvent& event ) override;
|
||||
|
||||
@@ -119,6 +121,9 @@ public:
|
||||
wxString StringFromBool( bool aValue ) const;
|
||||
bool BoolFromString( const wxString& aValue ) const;
|
||||
|
||||
SCH_FIELD* GetField( FIELD_T aFieldId );
|
||||
int GetFieldRow( FIELD_T aFieldId );
|
||||
|
||||
void DetachFields();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -174,7 +174,7 @@ protected:
|
||||
|
||||
switch( aField.GetId() )
|
||||
{
|
||||
case DATASHEET_FIELD:
|
||||
case FIELD_T::DATASHEET:
|
||||
text = m_symbol->GetDatasheetField().GetShownText( false );
|
||||
|
||||
if( text.IsEmpty() || text == wxT( "~" ) )
|
||||
@@ -196,11 +196,11 @@ protected:
|
||||
|
||||
break;
|
||||
|
||||
case VALUE_FIELD:
|
||||
case FIELD_T::VALUE:
|
||||
// showing the value just repeats the name, so that's not much use...
|
||||
return wxEmptyString;
|
||||
|
||||
case REFERENCE_FIELD:
|
||||
case FIELD_T::REFERENCE:
|
||||
text = aField.GetFullText( m_unit > 0 ? m_unit : 1 );
|
||||
fieldhtml.Replace( wxS( "__VALUE__" ), EscapeHTML( text ) );
|
||||
break;
|
||||
@@ -237,7 +237,7 @@ protected:
|
||||
|
||||
for( const SCH_FIELD* parentField : parentFields )
|
||||
{
|
||||
if( m_symbol->FindField( parentField->GetCanonicalName() ) )
|
||||
if( m_symbol->GetField( parentField->GetCanonicalName() ) )
|
||||
continue;
|
||||
|
||||
fieldtable += GetHtmlFieldRow( *parentField );
|
||||
|
||||
+88
-137
@@ -59,7 +59,7 @@ std::vector<SEARCH_TERM> LIB_SYMBOL::GetSearchTerms()
|
||||
terms.emplace_back( SEARCH_TERM( GetKeyWords(), 1 ) );
|
||||
terms.emplace_back( SEARCH_TERM( GetDescription(), 1 ) );
|
||||
|
||||
wxString footprint = GetFootprintField().GetText();
|
||||
wxString footprint = GetFootprint();
|
||||
|
||||
if( !footprint.IsEmpty() )
|
||||
terms.emplace_back( SEARCH_TERM( GetFootprintField().GetText(), 1 ) );
|
||||
@@ -105,23 +105,20 @@ LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB*
|
||||
m_options = ENTRY_NORMAL;
|
||||
m_unitsLocked = false;
|
||||
|
||||
// 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( MANDATORY_FIELD_COUNT );
|
||||
auto addField =
|
||||
[&]( FIELD_T id, bool visible )
|
||||
{
|
||||
SCH_FIELD* field = new SCH_FIELD( this, id );
|
||||
field->SetVisible( visible );
|
||||
m_drawings[SCH_FIELD_T].push_back( field );
|
||||
};
|
||||
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
m_drawings[SCH_FIELD_T].push_back( new SCH_FIELD( this, fieldId ) );
|
||||
|
||||
// Ensure reference and value fields are visible when creating a lib symbol
|
||||
// whatever the SCH_FIELD Ctor default value is.
|
||||
GetReferenceField().SetVisible( true );
|
||||
GetValueField().SetVisible( true );
|
||||
|
||||
// Set visibilty to false for these other mandatory fields (at lest for now)
|
||||
// whatever the SCH_FIELD Ctor default value is.
|
||||
GetFootprintField().SetVisible( false );
|
||||
GetDatasheetField().SetVisible( false );
|
||||
GetDescriptionField().SetVisible( false );
|
||||
// construct only the mandatory fields
|
||||
addField( FIELD_T::REFERENCE, true );
|
||||
addField( FIELD_T::VALUE, true );
|
||||
addField( FIELD_T::FOOTPRINT, false );
|
||||
addField( FIELD_T::DATASHEET, false );
|
||||
addField( FIELD_T::DESCRIPTION, false );
|
||||
|
||||
SetName( aName );
|
||||
|
||||
@@ -355,31 +352,26 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
|
||||
retv->m_name = m_name;
|
||||
retv->SetLibId( m_libId );
|
||||
|
||||
// Now add the inherited part mandatory field (this) information.
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
// Overwrite parent's mandatory fields for fields which are defined in this.
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
wxString tmp = GetFieldById( fieldId )->GetText();
|
||||
|
||||
// If the field isn't defined then inherit the parent field value.
|
||||
if( tmp.IsEmpty() )
|
||||
retv->GetFieldById( fieldId )->SetText( retv->GetFieldById( fieldId )->GetText() );
|
||||
else
|
||||
*retv->GetFieldById( fieldId ) = *GetFieldById( fieldId );
|
||||
if( !GetField( fieldId )->GetText().IsEmpty() )
|
||||
*retv->GetField( fieldId ) = *GetField( fieldId );
|
||||
}
|
||||
|
||||
// Grab all the rest of derived symbol fields.
|
||||
for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
const SCH_FIELD* aliasField = static_cast<const SCH_FIELD*>( &item );
|
||||
const SCH_FIELD* field = static_cast<const SCH_FIELD*>( &item );
|
||||
|
||||
// Mandatory fields were already resolved.
|
||||
if( aliasField->IsMandatory() )
|
||||
if( field->IsMandatory() )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* newField = new SCH_FIELD( *aliasField );
|
||||
SCH_FIELD* newField = new SCH_FIELD( *field );
|
||||
newField->SetParent( retv.get() );
|
||||
|
||||
SCH_FIELD* parentField = retv->FindField( aliasField->GetName() );
|
||||
SCH_FIELD* parentField = retv->GetField( field->GetName() );
|
||||
|
||||
if( !parentField ) // Derived symbol field does not exist in parent symbol.
|
||||
{
|
||||
@@ -399,7 +391,6 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
|
||||
retv->SetExcludedFromBOM( parent->GetExcludedFromBOM() );
|
||||
retv->SetExcludedFromBoard( parent->GetExcludedFromBoard() );
|
||||
|
||||
retv->UpdateFieldOrdinals();
|
||||
retv->m_parent.reset();
|
||||
}
|
||||
else
|
||||
@@ -507,7 +498,7 @@ bool LIB_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
|
||||
{
|
||||
const SCH_FIELD& field = static_cast<const SCH_FIELD&>( item );
|
||||
|
||||
if( field.GetId() == FOOTPRINT_FIELD )
|
||||
if( field.GetId() == FIELD_T::FOOTPRINT )
|
||||
footprint = field.GetShownText( nullptr, false, aDepth + 1 );
|
||||
|
||||
if( token->IsSameAs( field.GetCanonicalName().Upper() )
|
||||
@@ -977,12 +968,11 @@ void LIB_SYMBOL::SetFields( const std::vector<SCH_FIELD>& aFieldsList )
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly )
|
||||
void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly ) const
|
||||
{
|
||||
// Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( fieldId );
|
||||
const SCH_FIELD* field = static_cast<const SCH_FIELD*>( &item );
|
||||
|
||||
if( aVisibleOnly )
|
||||
{
|
||||
@@ -990,50 +980,35 @@ void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly )
|
||||
continue;
|
||||
}
|
||||
|
||||
aList.push_back( field );
|
||||
aList.push_back( const_cast<SCH_FIELD*>( field ) );
|
||||
}
|
||||
|
||||
// Now grab all the rest of fields.
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
|
||||
|
||||
if( aVisibleOnly )
|
||||
{
|
||||
if( !field->IsVisible() || field->GetText().IsEmpty() )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !field->IsMandatory() )
|
||||
aList.push_back( field );
|
||||
}
|
||||
std::sort( aList.begin(), aList.end(),
|
||||
[]( SCH_FIELD* lhs, SCH_FIELD* rhs )
|
||||
{
|
||||
return lhs->GetOrdinal() < rhs->GetOrdinal();
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::CopyFields( std::vector<SCH_FIELD>& aList )
|
||||
{
|
||||
// Grab the MANDATORY_FIELDS first, in expected order given by enum MANDATORY_FIELD_T
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
aList.push_back( *GetFieldById( fieldId ) );
|
||||
std::vector<SCH_FIELD*> orderedFields;
|
||||
|
||||
// Now grab all the rest of fields.
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
|
||||
GetFields( orderedFields );
|
||||
|
||||
if( !field->IsMandatory() )
|
||||
aList.push_back( *field );
|
||||
}
|
||||
for( SCH_FIELD* field : orderedFields )
|
||||
aList.emplace_back( *field );
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const
|
||||
const SCH_FIELD* LIB_SYMBOL::GetField( FIELD_T aFieldType ) const
|
||||
{
|
||||
for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD* field = ( SCH_FIELD* ) &item;
|
||||
const SCH_FIELD* field = static_cast<const SCH_FIELD*>( &item );
|
||||
|
||||
if( field->GetId() == aId )
|
||||
if( field->GetId() == aFieldType )
|
||||
return field;
|
||||
}
|
||||
|
||||
@@ -1041,84 +1016,97 @@ SCH_FIELD* LIB_SYMBOL::GetFieldById( int aId ) const
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensitive )
|
||||
SCH_FIELD* LIB_SYMBOL::GetField( FIELD_T aFieldType )
|
||||
{
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
if( aCaseInsensitive )
|
||||
{
|
||||
if( static_cast<SCH_FIELD*>( &item )->GetCanonicalName().Upper() == aFieldName.Upper() )
|
||||
return static_cast<SCH_FIELD*>( &item );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( static_cast<SCH_FIELD*>( &item )->GetCanonicalName() == aFieldName )
|
||||
return static_cast<SCH_FIELD*>( &item );
|
||||
}
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
|
||||
|
||||
if( field->GetId() == aFieldType )
|
||||
return field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
const SCH_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName,
|
||||
bool aCaseInsensitive ) const
|
||||
const SCH_FIELD* LIB_SYMBOL::GetField( const wxString& aFieldName ) const
|
||||
{
|
||||
for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
const SCH_FIELD& field = static_cast<const SCH_FIELD&>( item );
|
||||
|
||||
if( aCaseInsensitive )
|
||||
{
|
||||
if( field.GetCanonicalName().Upper() == aFieldName.Upper() )
|
||||
return &field;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( field.GetCanonicalName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD& LIB_SYMBOL::GetValueField() const
|
||||
SCH_FIELD* LIB_SYMBOL::GetField( const wxString& aFieldName )
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( VALUE_FIELD );
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD& field = static_cast<SCH_FIELD&>( item );
|
||||
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* LIB_SYMBOL::FindFieldCaseInsensitive( const wxString& aFieldName )
|
||||
{
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD& field = static_cast<SCH_FIELD&>( item );
|
||||
|
||||
if( field.GetCanonicalName().IsSameAs( aFieldName, false ) )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
const SCH_FIELD& LIB_SYMBOL::GetValueField() const
|
||||
{
|
||||
const SCH_FIELD* field = GetField( FIELD_T::VALUE );
|
||||
wxASSERT( field != nullptr );
|
||||
return *field;
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD& LIB_SYMBOL::GetReferenceField() const
|
||||
const SCH_FIELD& LIB_SYMBOL::GetReferenceField() const
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( REFERENCE_FIELD );
|
||||
const SCH_FIELD* field = GetField( FIELD_T::REFERENCE );
|
||||
wxASSERT( field != nullptr );
|
||||
return *field;
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD& LIB_SYMBOL::GetFootprintField() const
|
||||
const SCH_FIELD& LIB_SYMBOL::GetFootprintField() const
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( FOOTPRINT_FIELD );
|
||||
const SCH_FIELD* field = GetField( FIELD_T::FOOTPRINT );
|
||||
wxASSERT( field != nullptr );
|
||||
return *field;
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD& LIB_SYMBOL::GetDatasheetField() const
|
||||
const SCH_FIELD& LIB_SYMBOL::GetDatasheetField() const
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( DATASHEET_FIELD );
|
||||
const SCH_FIELD* field = GetField( FIELD_T::DATASHEET );
|
||||
wxASSERT( field != nullptr );
|
||||
return *field;
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD& LIB_SYMBOL::GetDescriptionField() const
|
||||
const SCH_FIELD& LIB_SYMBOL::GetDescriptionField() const
|
||||
{
|
||||
SCH_FIELD* field = GetFieldById( DESCRIPTION_FIELD );
|
||||
const SCH_FIELD* field = GetField( FIELD_T::DESCRIPTION );
|
||||
wxASSERT( field != nullptr );
|
||||
return *field;
|
||||
}
|
||||
@@ -1126,7 +1114,7 @@ SCH_FIELD& LIB_SYMBOL::GetDescriptionField() const
|
||||
|
||||
wxString LIB_SYMBOL::GetPrefix()
|
||||
{
|
||||
wxString refDesignator = GetFieldById( REFERENCE_FIELD )->GetText();
|
||||
wxString refDesignator = GetField( FIELD_T::REFERENCE )->GetText();
|
||||
|
||||
refDesignator.Replace( wxS( "~" ), wxS( " " ) );
|
||||
|
||||
@@ -1157,43 +1145,6 @@ void LIB_SYMBOL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunctio
|
||||
}
|
||||
|
||||
|
||||
int LIB_SYMBOL::UpdateFieldOrdinals()
|
||||
{
|
||||
int retv = 0;
|
||||
int lastOrdinal = MANDATORY_FIELD_COUNT;
|
||||
|
||||
for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
|
||||
|
||||
// Mandatory fields were already resolved always have the same ordinal values.
|
||||
if( field->IsMandatory() )
|
||||
continue;
|
||||
|
||||
if( field->GetId() != lastOrdinal )
|
||||
{
|
||||
field->SetId( lastOrdinal );
|
||||
retv += 1;
|
||||
}
|
||||
|
||||
lastOrdinal += 1;
|
||||
}
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
||||
int LIB_SYMBOL::GetNextAvailableFieldId() const
|
||||
{
|
||||
int retv = MANDATORY_FIELD_COUNT;
|
||||
|
||||
while( GetFieldById( retv ) )
|
||||
retv += 1;
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
for( SCH_ITEM& item : m_drawings )
|
||||
@@ -1618,9 +1569,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
int tmp = 0;
|
||||
|
||||
if( aField->IsMandatory() )
|
||||
bField = aRhs.GetFieldById( aField->GetId() );
|
||||
bField = aRhs.GetField( aField->GetId() );
|
||||
else
|
||||
bField = aRhs.FindField( aField->GetName() );
|
||||
bField = aRhs.GetField( aField->GetName() );
|
||||
|
||||
if( !bField )
|
||||
tmp = 1;
|
||||
|
||||
+22
-35
@@ -292,12 +292,15 @@ public:
|
||||
void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
|
||||
|
||||
/**
|
||||
* Return a list of fields within this symbol.
|
||||
* Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
|
||||
*
|
||||
* @param aList - List to add fields to
|
||||
* @param aList is the vector to populate.
|
||||
*/
|
||||
void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) override;
|
||||
void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
|
||||
|
||||
/**
|
||||
* Create a copy of the SCH_FIELDs, sorted in ordinal order.
|
||||
*/
|
||||
void CopyFields( std::vector<SCH_FIELD>& aList );
|
||||
|
||||
/**
|
||||
@@ -308,40 +311,35 @@ public:
|
||||
void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
|
||||
|
||||
/**
|
||||
* Find a field within this symbol matching \a aFieldName and returns it
|
||||
* or NULL if not found.
|
||||
* @param aFieldName is the name of the field to find.
|
||||
* @param aCaseInsensitive ignore the filed name case if true.
|
||||
*
|
||||
* @return the field if found or NULL if the field was not found.
|
||||
* Find a field within this symbol matching \a aFieldName; return nullptr if not found.
|
||||
*/
|
||||
SCH_FIELD* FindField( const wxString& aFieldName, bool aCaseInsensitive = false );
|
||||
SCH_FIELD* GetField( const wxString& aFieldName );
|
||||
const SCH_FIELD* GetField( const wxString& aFieldName ) const;
|
||||
|
||||
const SCH_FIELD* FindField( const wxString& aFieldName,
|
||||
bool aCaseInsensitive = false ) const;
|
||||
SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
|
||||
|
||||
/**
|
||||
* Return pointer to the requested field.
|
||||
*
|
||||
* @param aId - Id of field to return.
|
||||
* @return The field if found, otherwise NULL.
|
||||
*/
|
||||
SCH_FIELD* GetFieldById( int aId ) const;
|
||||
const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
|
||||
SCH_FIELD* GetField( FIELD_T aFieldType );
|
||||
|
||||
/** Return reference to the value field. */
|
||||
SCH_FIELD& GetValueField() const;
|
||||
SCH_FIELD& GetValueField() { return *GetField( FIELD_T::VALUE ); }
|
||||
const SCH_FIELD& GetValueField() const;
|
||||
|
||||
/** Return reference to the reference designator field. */
|
||||
SCH_FIELD& GetReferenceField() const;
|
||||
SCH_FIELD& GetReferenceField() { return *GetField( FIELD_T::REFERENCE ); }
|
||||
const SCH_FIELD& GetReferenceField() const;
|
||||
|
||||
/** Return reference to the footprint field */
|
||||
SCH_FIELD& GetFootprintField() const;
|
||||
SCH_FIELD& GetFootprintField() { return *GetField( FIELD_T::FOOTPRINT ); }
|
||||
const SCH_FIELD& GetFootprintField() const;
|
||||
|
||||
/** Return reference to the datasheet field. */
|
||||
SCH_FIELD& GetDatasheetField() const;
|
||||
SCH_FIELD& GetDatasheetField() { return *GetField( FIELD_T::DATASHEET ); }
|
||||
const SCH_FIELD& GetDatasheetField() const;
|
||||
|
||||
/** Return reference to the description field. */
|
||||
SCH_FIELD& GetDescriptionField() const;
|
||||
SCH_FIELD& GetDescriptionField() {return *GetField( FIELD_T::DESCRIPTION ); }
|
||||
const SCH_FIELD& GetDescriptionField() const;
|
||||
|
||||
wxString GetPrefix();
|
||||
|
||||
@@ -373,17 +371,6 @@ public:
|
||||
|
||||
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
|
||||
|
||||
/**
|
||||
* Order optional field indices.
|
||||
*
|
||||
* It's possible when calling #LIB_SYMBOL::Flatten that there can be gaps and/or duplicate
|
||||
* optional field indices. This method correctly orders the indices so there are no gaps
|
||||
* and/or duplicate indices.
|
||||
*/
|
||||
int UpdateFieldOrdinals();
|
||||
|
||||
int GetNextAvailableFieldId() const;
|
||||
|
||||
/**
|
||||
* Resolve any references to system tokens supported by the symbol.
|
||||
*
|
||||
|
||||
@@ -630,7 +630,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::getGroupField( int aGroupIndex, const wxArray
|
||||
|
||||
for( const wxString& field : aFieldArray )
|
||||
{
|
||||
if( SCH_FIELD* fld = sym->FindField( field, true, true ) )
|
||||
if( SCH_FIELD* fld = sym->FindFieldCaseInsensitive( field ) )
|
||||
{
|
||||
wxString fieldText = fld->GetShownText( &sheetPath, true );
|
||||
|
||||
@@ -651,7 +651,7 @@ wxString NETLIST_EXPORTER_ALLEGRO::getGroupField( int aGroupIndex, const wxArray
|
||||
|
||||
for( const wxString& field : aFieldArray )
|
||||
{
|
||||
if( SCH_FIELD* fld = sym->GetLibSymbolRef()->FindField( field, true ) )
|
||||
if( SCH_FIELD* fld = sym->GetLibSymbolRef()->FindFieldCaseInsensitive( field ) )
|
||||
{
|
||||
wxString fieldText = fld->GetShownText( false, 0 );
|
||||
|
||||
|
||||
@@ -184,9 +184,10 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
|
||||
|
||||
for( const SCH_FIELD& field : symbol->GetFields() )
|
||||
{
|
||||
spiceItem.fields.emplace_back( VECTOR2I(), -1, symbol, field.GetName() );
|
||||
spiceItem.fields.emplace_back( VECTOR2I(), FIELD_T::USER, symbol,
|
||||
field.GetName() );
|
||||
|
||||
if( field.GetId() == REFERENCE_FIELD )
|
||||
if( field.GetId() == FIELD_T::REFERENCE )
|
||||
spiceItem.fields.back().SetText( symbol->GetRef( &sheet ) );
|
||||
else
|
||||
spiceItem.fields.back().SetText( field.GetShownText( &sheet, false ) );
|
||||
@@ -488,7 +489,7 @@ void NETLIST_EXPORTER_SPICE::readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& a
|
||||
void NETLIST_EXPORTER_SPICE::getNodePattern( SPICE_ITEM& aItem,
|
||||
std::vector<std::string>& aModifiers )
|
||||
{
|
||||
std::string input = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_NODES_FORMAT_FIELD, true );
|
||||
std::string input = GetFieldValue( &aItem.fields, SIM_NODES_FORMAT_FIELD, true );
|
||||
|
||||
if( input == "" )
|
||||
return;
|
||||
|
||||
@@ -145,16 +145,16 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
|
||||
// Datasheet
|
||||
candidate = m_resolveTextVars
|
||||
? symbol2->GetField( DATASHEET_FIELD )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( DATASHEET_FIELD )->GetText();
|
||||
? symbol2->GetField( FIELD_T::DATASHEET )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( FIELD_T::DATASHEET )->GetText();
|
||||
|
||||
if( !candidate.IsEmpty() && ( unit < minUnit || datasheet.IsEmpty() ) )
|
||||
datasheet = candidate;
|
||||
|
||||
// Description
|
||||
candidate = m_resolveTextVars
|
||||
? symbol2->GetField( DESCRIPTION_FIELD )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( DESCRIPTION_FIELD )->GetText();
|
||||
? symbol2->GetField( FIELD_T::DESCRIPTION )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( FIELD_T::DESCRIPTION )->GetText();
|
||||
|
||||
if( !candidate.IsEmpty() && ( unit < minUnit || description.IsEmpty() ) )
|
||||
description = candidate;
|
||||
@@ -183,8 +183,8 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
value = aSymbol->GetValue( m_resolveTextVars, &aSheet, false );
|
||||
footprint = aSymbol->GetFootprintFieldText( m_resolveTextVars, &aSheet, false );
|
||||
|
||||
SCH_FIELD* datasheetField = aSymbol->GetField( DATASHEET_FIELD );
|
||||
SCH_FIELD* descriptionField = aSymbol->GetField( DESCRIPTION_FIELD );
|
||||
SCH_FIELD* datasheetField = aSymbol->GetField( FIELD_T::DATASHEET );
|
||||
SCH_FIELD* descriptionField = aSymbol->GetField( FIELD_T::DESCRIPTION );
|
||||
|
||||
// Datasheet
|
||||
if( m_resolveTextVars )
|
||||
@@ -210,9 +210,9 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
}
|
||||
}
|
||||
|
||||
fields[GetCanonicalFieldName( FOOTPRINT_FIELD )] = footprint;
|
||||
fields[GetCanonicalFieldName( DATASHEET_FIELD )] = datasheet;
|
||||
fields[GetCanonicalFieldName( DESCRIPTION_FIELD )] = description;
|
||||
fields[GetCanonicalFieldName( FIELD_T::FOOTPRINT )] = footprint;
|
||||
fields[GetCanonicalFieldName( FIELD_T::DATASHEET )] = datasheet;
|
||||
fields[GetCanonicalFieldName( FIELD_T::DESCRIPTION )] = description;
|
||||
|
||||
// Do not output field values blank in netlist:
|
||||
if( value.size() )
|
||||
|
||||
@@ -590,7 +590,7 @@ void SCH_COMMIT::Revert()
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item->GetParent() );
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD )
|
||||
if( field->GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
// Lazy eval of sheet list; this is expensive even when unsorted
|
||||
if( sheets.empty() )
|
||||
|
||||
@@ -1274,7 +1274,7 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
|
||||
case SCH_SYMBOL_T:
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
|
||||
findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
|
||||
findString = UnescapeString( symbol->GetField( FIELD_T::VALUE )->GetText() );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+87
-211
@@ -44,11 +44,10 @@
|
||||
static const std::vector<KICAD_T> labelTypes = { SCH_LABEL_LOCATE_ANY_T };
|
||||
|
||||
|
||||
SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent,
|
||||
const wxString& aName ) :
|
||||
SCH_ITEM( aParent, SCH_FIELD_T ),
|
||||
SCH_FIELD::SCH_FIELD() :
|
||||
SCH_ITEM( nullptr, SCH_FIELD_T ),
|
||||
EDA_TEXT( schIUScale, wxEmptyString ),
|
||||
m_id( 0 ),
|
||||
m_id( FIELD_T::USER ),
|
||||
m_showName( false ),
|
||||
m_allowAutoPlace( true ),
|
||||
m_isNamedVariable( false ),
|
||||
@@ -57,27 +56,34 @@ SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent,
|
||||
m_renderCacheValid( false ),
|
||||
m_lastResolvedColor( COLOR4D::UNSPECIFIED )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, FIELD_T aFieldId, SCH_ITEM* aParent,
|
||||
const wxString& aName ) :
|
||||
SCH_FIELD()
|
||||
{
|
||||
m_parent = aParent;
|
||||
|
||||
if( !aName.IsEmpty() )
|
||||
SetName( aName );
|
||||
else if( aParent && aParent->Type() == SCH_SYMBOL_T )
|
||||
else
|
||||
SetName( GetDefaultFieldName( aFieldId, DO_TRANSLATE ) );
|
||||
else if( aParent && aParent->Type() == SCH_SHEET_T )
|
||||
SetName( SCH_SHEET::GetDefaultFieldName( aFieldId, DO_TRANSLATE ) );
|
||||
|
||||
SetTextPos( aPos );
|
||||
SetId( aFieldId ); // will also set the layer
|
||||
setId( aFieldId ); // will also set the layer
|
||||
SetVisible( true );
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD::SCH_FIELD( SCH_ITEM* aParent, int aFieldId, const wxString& aName ) :
|
||||
SCH_FIELD::SCH_FIELD( SCH_ITEM* aParent, FIELD_T aFieldId, const wxString& aName ) :
|
||||
SCH_FIELD( VECTOR2I(), aFieldId, aParent, aName )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD::SCH_FIELD( SCH_TEXT* aText ) :
|
||||
SCH_FIELD( VECTOR2I(), INVALID_FIELD, nullptr, wxEmptyString )
|
||||
SCH_FIELD( VECTOR2I(), FIELD_T::USER, nullptr, wxEmptyString )
|
||||
{
|
||||
SCH_ITEM::operator=( *aText );
|
||||
EDA_TEXT::operator=( *aText );
|
||||
@@ -90,6 +96,7 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
|
||||
{
|
||||
m_private = aField.m_private;
|
||||
m_id = aField.m_id;
|
||||
m_ordinal = aField.m_ordinal;
|
||||
m_name = aField.m_name;
|
||||
m_showName = aField.m_showName;
|
||||
m_allowAutoPlace = aField.m_allowAutoPlace;
|
||||
@@ -120,6 +127,7 @@ SCH_FIELD& SCH_FIELD::operator=( const SCH_FIELD& aField )
|
||||
|
||||
m_private = aField.m_private;
|
||||
m_id = aField.m_id;
|
||||
m_ordinal = aField.m_ordinal;
|
||||
m_name = aField.m_name;
|
||||
m_showName = aField.m_showName;
|
||||
m_allowAutoPlace = aField.m_allowAutoPlace;
|
||||
@@ -156,47 +164,10 @@ void SCH_FIELD::Copy( SCH_FIELD* aTarget ) const
|
||||
}
|
||||
|
||||
|
||||
void SCH_FIELD::SetId( int aId )
|
||||
void SCH_FIELD::setId( FIELD_T aId )
|
||||
{
|
||||
m_id = aId;
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
switch( m_id )
|
||||
{
|
||||
case SHEETNAME: SetLayer( LAYER_SHEETNAME ); break;
|
||||
case SHEETFILENAME: SetLayer( LAYER_SHEETFILENAME ); break;
|
||||
default: SetLayer( LAYER_SHEETFIELDS ); break;
|
||||
}
|
||||
}
|
||||
else if( m_parent && ( m_parent->Type() == SCH_SYMBOL_T || m_parent->Type() == LIB_SYMBOL_T ) )
|
||||
{
|
||||
switch( m_id )
|
||||
{
|
||||
case REFERENCE_FIELD: SetLayer( LAYER_REFERENCEPART ); break;
|
||||
case VALUE_FIELD: SetLayer( LAYER_VALUEPART ); break;
|
||||
default: SetLayer( LAYER_FIELDS ); break;
|
||||
}
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
{
|
||||
// We can't use defined IDs for labels because there can be multiple net class
|
||||
// assignments.
|
||||
|
||||
if( GetCanonicalName() == wxT( "Netclass" )
|
||||
|| GetCanonicalName() == wxT( "Component Class" ) )
|
||||
{
|
||||
SetLayer( LAYER_NETCLASS_REFS );
|
||||
}
|
||||
else if( GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
{
|
||||
SetLayer( LAYER_INTERSHEET_REFS );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLayer( LAYER_FIELDS );
|
||||
}
|
||||
}
|
||||
SetLayer( GetDefaultLayer() );
|
||||
}
|
||||
|
||||
|
||||
@@ -297,27 +268,19 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING: the IDs of FIELDS and SHEETS overlap, so one must check *both* the
|
||||
// id and the parent's type.
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
|
||||
if( m_id == FIELD_T::REFERENCE && aPath )
|
||||
{
|
||||
SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
|
||||
|
||||
if( m_id == REFERENCE_FIELD && aPath )
|
||||
{
|
||||
// For more than one part per package, we must add the part selection
|
||||
// A, B, ... or 1, 2, .. to the reference.
|
||||
if( parentSymbol->GetUnitCount() > 1 )
|
||||
text << parentSymbol->SubReference( parentSymbol->GetUnitSelection( aPath ) );
|
||||
}
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
if( m_id == SHEETFILENAME && aAllowExtraText && !IsNameShown() )
|
||||
text = _( "File:" ) + wxS( " " ) + text;
|
||||
// For more than one part per package, we must add the part selection
|
||||
// A, B, ... or 1, 2, .. to the reference.
|
||||
if( parentSymbol && parentSymbol->GetUnitCount() > 1 )
|
||||
text << parentSymbol->SubReference( parentSymbol->GetUnitSelection( aPath ) );
|
||||
}
|
||||
|
||||
if( m_id == FIELD_T::SHEET_FILENAME && aAllowExtraText && !IsNameShown() )
|
||||
text = _( "File:" ) + wxS( " " ) + text;
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -333,7 +296,7 @@ wxString SCH_FIELD::GetShownText( bool aAllowExtraText, int aDepth ) const
|
||||
|
||||
wxString SCH_FIELD::GetFullText( int unit ) const
|
||||
{
|
||||
if( GetId() != REFERENCE_FIELD )
|
||||
if( GetId() != FIELD_T::REFERENCE )
|
||||
return GetText();
|
||||
|
||||
wxString text = GetText();
|
||||
@@ -480,29 +443,25 @@ std::vector<int> SCH_FIELD::ViewGetLayers() const
|
||||
|
||||
SCH_LAYER_ID SCH_FIELD::GetDefaultLayer() const
|
||||
{
|
||||
if( m_parent && ( m_parent->Type() == LIB_SYMBOL_T || m_parent->Type() == SCH_SYMBOL_T ) )
|
||||
if( m_parent && m_parent->Type() == SCH_LABEL_T )
|
||||
{
|
||||
if( m_id == REFERENCE_FIELD )
|
||||
return LAYER_REFERENCEPART;
|
||||
else if( m_id == VALUE_FIELD )
|
||||
return LAYER_VALUEPART;
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
if( m_id == SHEETNAME )
|
||||
return LAYER_SHEETNAME;
|
||||
else if( m_id == SHEETFILENAME )
|
||||
return LAYER_SHEETFILENAME;
|
||||
else
|
||||
return LAYER_SHEETFIELDS;
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_LABEL_T )
|
||||
{
|
||||
if( GetCanonicalName() == wxT( "Netclass" ) )
|
||||
if( GetCanonicalName() == wxT( "Netclass" )
|
||||
|| GetCanonicalName() == wxT( "Component Class" ) )
|
||||
{
|
||||
return LAYER_NETCLASS_REFS;
|
||||
}
|
||||
}
|
||||
|
||||
return LAYER_FIELDS;
|
||||
switch( m_id )
|
||||
{
|
||||
case FIELD_T::REFERENCE: return LAYER_REFERENCEPART;
|
||||
case FIELD_T::VALUE: return LAYER_VALUEPART;
|
||||
case FIELD_T::SHEET_NAME: return LAYER_SHEETNAME;
|
||||
case FIELD_T::SHEET_FILENAME: return LAYER_SHEETFILENAME;
|
||||
case FIELD_T::SHEET_USER: return LAYER_SHEETFIELDS;
|
||||
case FIELD_T::INTERSHEET_REFS: return LAYER_INTERSHEET_REFS;
|
||||
default: return LAYER_FIELDS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -693,17 +652,18 @@ bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) co
|
||||
if( !IsVisible() && !searchHiddenFields )
|
||||
return false;
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SYMBOL_T && m_id == REFERENCE_FIELD )
|
||||
if( m_id == FIELD_T::REFERENCE )
|
||||
{
|
||||
if( searchAndReplace && !replaceReferences )
|
||||
return false;
|
||||
|
||||
SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
|
||||
wxASSERT( parentSymbol );
|
||||
wxASSERT( aAuxData );
|
||||
|
||||
// Take sheet path into account which effects the reference field and the unit for
|
||||
// symbols with multiple parts.
|
||||
if( aAuxData )
|
||||
if( parentSymbol && aAuxData )
|
||||
{
|
||||
SCH_SHEET_PATH* sheet = (SCH_SHEET_PATH*) aAuxData;
|
||||
text = parentSymbol->GetRef( sheet );
|
||||
@@ -840,17 +800,9 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks,
|
||||
|
||||
bool SCH_FIELD::IsReplaceable() const
|
||||
{
|
||||
if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
// See comments in SCH_FIELD::Replace(), below.
|
||||
if( m_id == SHEETFILENAME )
|
||||
return false;
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
if( m_id == 0 /* IntersheetRefs */ )
|
||||
return false;
|
||||
}
|
||||
// See comments in SCH_FIELD::Replace(), below.
|
||||
if( m_id == FIELD_T::SHEET_FILENAME || m_id == FIELD_T::INTERSHEET_REFS )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -872,67 +824,32 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
|
||||
wxString text;
|
||||
bool isReplaced = false;
|
||||
|
||||
if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
|
||||
if( m_id == FIELD_T::REFERENCE && m_parent && m_parent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
|
||||
|
||||
switch( m_id )
|
||||
{
|
||||
case REFERENCE_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
|
||||
if( !replaceReferences )
|
||||
return false;
|
||||
|
||||
if( !replaceReferences )
|
||||
return false;
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
|
||||
|
||||
text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
|
||||
|
||||
break;
|
||||
|
||||
case VALUE_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
|
||||
|
||||
text = parentSymbol->GetField( VALUE_FIELD )->GetText();
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
parentSymbol->SetValueFieldText( text );
|
||||
|
||||
break;
|
||||
|
||||
case FOOTPRINT_FIELD:
|
||||
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
|
||||
|
||||
text = parentSymbol->GetField( FOOTPRINT_FIELD )->GetText();
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
parentSymbol->SetFootprintFieldText( text );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
isReplaced = EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
if( isReplaced )
|
||||
parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
else
|
||||
{
|
||||
isReplaced = EDA_TEXT::Replace( aSearchData );
|
||||
|
||||
if( m_id == SHEETFILENAME && isReplaced )
|
||||
if( m_id == FIELD_T::SHEET_FILENAME && isReplaced )
|
||||
{
|
||||
// If we allowed this we'd have a bunch of work to do here, including warning
|
||||
// about it not being undoable, checking for recursive hierarchies, reloading
|
||||
// sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow().
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isReplaced = EDA_TEXT::Replace( aSearchData );
|
||||
}
|
||||
|
||||
return isReplaced;
|
||||
}
|
||||
@@ -1144,56 +1061,30 @@ void SCH_FIELD::SetText( const wxString& aText )
|
||||
|
||||
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 );
|
||||
else if( m_name.IsEmpty() && aUseDefaultName )
|
||||
return GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
if( IsMandatory() )
|
||||
return SCH_SHEET::GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
else if( m_name.IsEmpty() && aUseDefaultName )
|
||||
return SCH_SHEET::GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
{
|
||||
if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName );
|
||||
}
|
||||
|
||||
return m_name;
|
||||
if( IsMandatory() )
|
||||
return GetCanonicalFieldName( m_id );
|
||||
else if( m_name.IsEmpty() && aUseDefaultName )
|
||||
return GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
else
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
if( IsMandatory() )
|
||||
return SCH_SHEET::GetDefaultFieldName( m_id, !DO_TRANSLATE );
|
||||
}
|
||||
else if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
if( m_parent && m_parent->IsType( labelTypes ) )
|
||||
{
|
||||
// These should be stored in canonical format, but just in case:
|
||||
if( m_name == _( "Net Class" ) || m_name == wxT( "Net Class" ) )
|
||||
{
|
||||
return wxT( "Netclass" );
|
||||
}
|
||||
else if( m_name == _( "Sheet References" )
|
||||
|| m_name == wxT( "Sheet References" )
|
||||
|| m_name == wxT( "Intersheet References" ) )
|
||||
{
|
||||
return wxT( "Intersheetrefs" );
|
||||
}
|
||||
}
|
||||
|
||||
if( IsMandatory() )
|
||||
return GetCanonicalFieldName( m_id );
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
@@ -1204,10 +1095,10 @@ BITMAPS SCH_FIELD::GetMenuImage() const
|
||||
{
|
||||
switch( m_id )
|
||||
{
|
||||
case REFERENCE_FIELD: return BITMAPS::edit_comp_ref;
|
||||
case VALUE_FIELD: return BITMAPS::edit_comp_value;
|
||||
case FOOTPRINT_FIELD: return BITMAPS::edit_comp_footprint;
|
||||
default: return BITMAPS::text;
|
||||
case FIELD_T::REFERENCE: return BITMAPS::edit_comp_ref;
|
||||
case FIELD_T::VALUE: return BITMAPS::edit_comp_value;
|
||||
case FIELD_T::FOOTPRINT: return BITMAPS::edit_comp_footprint;
|
||||
default: return BITMAPS::text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1422,29 +1313,14 @@ VECTOR2I SCH_FIELD::GetParentPosition() const
|
||||
|
||||
bool SCH_FIELD::IsMandatory() const
|
||||
{
|
||||
if( !m_parent )
|
||||
return false;
|
||||
|
||||
switch( m_parent->Type() )
|
||||
{
|
||||
case SCH_SHEET_T:
|
||||
return m_id == SHEETNAME
|
||||
|| m_id == SHEETFILENAME;
|
||||
|
||||
case SCH_SYMBOL_T:
|
||||
case LIB_SYMBOL_T:
|
||||
return m_id == REFERENCE_FIELD
|
||||
|| m_id == VALUE_FIELD
|
||||
|| m_id == FOOTPRINT_FIELD
|
||||
|| m_id == DATASHEET_FIELD
|
||||
|| m_id == DESCRIPTION_FIELD;
|
||||
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
return m_id == INTERSHEET_REFS;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return m_id == FIELD_T::REFERENCE
|
||||
|| m_id == FIELD_T::VALUE
|
||||
|| m_id == FIELD_T::FOOTPRINT
|
||||
|| m_id == FIELD_T::DATASHEET
|
||||
|| m_id == FIELD_T::DESCRIPTION
|
||||
|| m_id == FIELD_T::SHEET_NAME
|
||||
|| m_id == FIELD_T::SHEET_FILENAME
|
||||
|| m_id == FIELD_T::INTERSHEET_REFS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1577,7 +1453,7 @@ int SCH_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
if( IsMandatory() )
|
||||
{
|
||||
if( m_id != tmp->m_id )
|
||||
return m_id - tmp->m_id;
|
||||
return (int) m_id - (int) tmp->m_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1590,15 +1466,15 @@ int SCH_FIELD::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
|
||||
else // assume we're sorting
|
||||
{
|
||||
if( m_id != tmp->m_id )
|
||||
return m_id - tmp->m_id;
|
||||
return (int) m_id - (int) tmp->m_id;
|
||||
}
|
||||
|
||||
bool ignoreFieldText = false;
|
||||
|
||||
if( m_id == REFERENCE_FIELD && !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) )
|
||||
if( m_id == FIELD_T::REFERENCE && !( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::EQUALITY ) )
|
||||
ignoreFieldText = true;
|
||||
|
||||
if( m_id == VALUE_FIELD && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
|
||||
if( m_id == FIELD_T::VALUE && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) )
|
||||
ignoreFieldText = true;
|
||||
|
||||
if( !ignoreFieldText )
|
||||
|
||||
+120
-37
@@ -38,24 +38,15 @@ class SCH_EDIT_FRAME;
|
||||
class SCH_TEXT;
|
||||
|
||||
|
||||
/**
|
||||
* Instances are attached to a symbol or sheet and provide a place for the symbol's value,
|
||||
* reference designator, footprint, , a sheet's name, filename, and user definable name-value
|
||||
* pairs of arbitrary purpose.
|
||||
*
|
||||
* - Field 0 is reserved for the symbol reference.
|
||||
* - Field 1 is reserved for the symbol value.
|
||||
* - Field 2 is reserved for the symbol footprint.
|
||||
* - Field 3 is reserved for the symbol data sheet file.
|
||||
* - Field 4 and higher are user definable.
|
||||
*/
|
||||
class SCH_FIELD : public SCH_ITEM, public EDA_TEXT
|
||||
{
|
||||
public:
|
||||
SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent,
|
||||
SCH_FIELD(); // For std::map::operator[]
|
||||
|
||||
SCH_FIELD( const VECTOR2I& aPos, FIELD_T aFieldId, SCH_ITEM* aParent,
|
||||
const wxString& aName = wxEmptyString );
|
||||
|
||||
SCH_FIELD( SCH_ITEM* aParent, int aFieldId = INVALID_FIELD,
|
||||
SCH_FIELD( SCH_ITEM* aParent, FIELD_T aFieldId = FIELD_T::USER,
|
||||
const wxString& aName = wxEmptyString );
|
||||
|
||||
SCH_FIELD( SCH_TEXT* aText );
|
||||
@@ -84,13 +75,13 @@ public:
|
||||
|
||||
for( KICAD_T scanType : aScanTypes )
|
||||
{
|
||||
if( scanType == SCH_FIELD_LOCATE_REFERENCE_T && m_id == REFERENCE_FIELD )
|
||||
if( scanType == SCH_FIELD_LOCATE_REFERENCE_T && m_id == FIELD_T::REFERENCE )
|
||||
return true;
|
||||
else if ( scanType == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE_FIELD )
|
||||
else if ( scanType == SCH_FIELD_LOCATE_VALUE_T && m_id == FIELD_T::VALUE )
|
||||
return true;
|
||||
else if ( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT_FIELD )
|
||||
else if ( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FIELD_T::FOOTPRINT )
|
||||
return true;
|
||||
else if ( scanType == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET_FIELD )
|
||||
else if ( scanType == SCH_FIELD_LOCATE_DATASHEET_T && m_id == FIELD_T::DATASHEET )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -104,7 +95,7 @@ public:
|
||||
|
||||
bool IsHypertext() const override
|
||||
{
|
||||
if( GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
if( m_id == FIELD_T::INTERSHEET_REFS )
|
||||
return true;
|
||||
|
||||
return IsURL( GetShownText( false ) );
|
||||
@@ -113,10 +104,9 @@ public:
|
||||
void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
|
||||
|
||||
/**
|
||||
* Return the field name (not translated)..
|
||||
* Return the field name (not translated).
|
||||
*
|
||||
* @param aUseDefaultName When true return the default field name if the field name is
|
||||
* empty. Otherwise the default field name is returned.
|
||||
* @param aUseDefaultName If true return the default field name if the field name is empty.
|
||||
* @return the name of the field.
|
||||
*/
|
||||
wxString GetName( bool aUseDefaultName = true ) const;
|
||||
@@ -131,23 +121,22 @@ public:
|
||||
|
||||
void SetText( const wxString& aText ) override;
|
||||
|
||||
/**
|
||||
* Get the initial name of the field set at creation (or set by SetName()).
|
||||
*
|
||||
* This is the raw field name with no translation and no change.
|
||||
*/
|
||||
const wxString& GetInternalName() { return m_name; }
|
||||
FIELD_T GetId() const { return m_id; }
|
||||
|
||||
int GetId() const { return m_id; }
|
||||
|
||||
void SetId( int aId );
|
||||
int GetOrdinal() const
|
||||
{
|
||||
return IsMandatory() ? (int) m_id : m_ordinal;
|
||||
}
|
||||
void SetOrdinal( int aOrdinal )
|
||||
{
|
||||
m_id = FIELD_T::USER;
|
||||
m_ordinal = aOrdinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields name as displayed on the schematic or
|
||||
* in the symbol fields table.
|
||||
*
|
||||
* This is either the same as GetName() or if the field has a variable for name, the
|
||||
* variable name with the ${} stripped.
|
||||
* Get the field's name as displayed on the schematic or in the symbol fields table. This is
|
||||
* either the same as GetName() or if the field has a variable for name, the variable name
|
||||
* with the ${} stripped.
|
||||
*/
|
||||
wxString GetShownName() const;
|
||||
wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
|
||||
@@ -321,6 +310,8 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
friend class SCH_IO_KICAD_SEXPR_PARSER;
|
||||
|
||||
KIFONT::FONT* getDrawFont() const override;
|
||||
|
||||
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
||||
@@ -339,9 +330,11 @@ protected:
|
||||
*/
|
||||
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
||||
private:
|
||||
int m_id; ///< Field index, @see enum MANDATORY_FIELD_T
|
||||
void setId( FIELD_T aId );
|
||||
|
||||
private:
|
||||
FIELD_T m_id; ///< Field id, @see enum FIELD_T
|
||||
int m_ordinal; ///< Sort order for non-mandatory fields
|
||||
wxString m_name;
|
||||
|
||||
bool m_showName; ///< Render the field name in addition to its value
|
||||
@@ -360,4 +353,94 @@ private:
|
||||
};
|
||||
|
||||
|
||||
inline const SCH_FIELD* FindField( const std::vector<SCH_FIELD>& aFields, FIELD_T aFieldId )
|
||||
{
|
||||
for( const SCH_FIELD& field : aFields )
|
||||
{
|
||||
if( field.GetId() == aFieldId )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
inline SCH_FIELD* FindField( std::vector<SCH_FIELD>& aFields, FIELD_T aFieldId )
|
||||
{
|
||||
auto& constFields = const_cast<const std::vector<SCH_FIELD>&>( aFields );
|
||||
return const_cast<SCH_FIELD*>( FindField( constFields, aFieldId ) );
|
||||
}
|
||||
|
||||
|
||||
inline const SCH_FIELD* FindField( const std::vector<SCH_FIELD>& aFields,
|
||||
const wxString& aFieldName )
|
||||
{
|
||||
for( const SCH_FIELD& field : aFields )
|
||||
{
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
inline SCH_FIELD* FindField( std::vector<SCH_FIELD>& aFields, const wxString& aFieldName )
|
||||
{
|
||||
auto& constFields = const_cast<const std::vector<SCH_FIELD>&>( aFields );
|
||||
return const_cast<SCH_FIELD*>( FindField( constFields, aFieldName ) );
|
||||
}
|
||||
|
||||
|
||||
inline wxString GetFieldValue( const std::vector<SCH_FIELD>* aFields, FIELD_T aFieldType )
|
||||
{
|
||||
if( !aFields )
|
||||
return wxEmptyString;
|
||||
|
||||
if( const SCH_FIELD* field = FindField( *aFields, aFieldType ) )
|
||||
return field->GetText();
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
inline std::string GetFieldValue( const std::vector<SCH_FIELD>* aFields,
|
||||
const wxString& aFieldName, bool aResolve = false )
|
||||
{
|
||||
if( aFields )
|
||||
return "";
|
||||
|
||||
if( const SCH_FIELD* field = FindField( *aFields, aFieldName ) )
|
||||
return ( aResolve ? field->GetShownText( false ) : field->GetText() ).ToStdString();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
inline void SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString& aFieldName,
|
||||
const std::string& aValue, bool aIsVisible = true )
|
||||
{
|
||||
if( aValue == "" )
|
||||
{
|
||||
alg::delete_if( aFields, [&]( const SCH_FIELD& field )
|
||||
{
|
||||
return field.GetName() == aFieldName;
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
if( SCH_FIELD* field = FindField( aFields, aFieldName ) )
|
||||
{
|
||||
field->SetText( aValue );
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_ITEM* parent = static_cast<SCH_ITEM*>( aFields.at( 0 ).GetParent() );
|
||||
aFields.emplace_back( VECTOR2I(), FIELD_T::USER, parent, aFieldName );
|
||||
aFields.back().SetText( aValue );
|
||||
aFields.back().SetVisible( aIsVisible );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* CLASS_SCH_FIELD_H */
|
||||
|
||||
@@ -1456,7 +1456,7 @@ void SCH_IO_ALTIUM::ParseComponent( int aIndex, const std::map<wxString, wxStrin
|
||||
// component->SetOrientation( elem.orientation );
|
||||
symbol->SetLibId( libId );
|
||||
symbol->SetUnit( std::max( 0, elem.currentpartid ) );
|
||||
symbol->GetField( DESCRIPTION_FIELD )->SetText( elem.componentdescription );
|
||||
symbol->GetField( FIELD_T::DESCRIPTION )->SetText( elem.componentdescription );
|
||||
|
||||
SCH_SCREEN* screen = getCurrentScreen();
|
||||
wxCHECK( screen, /* void */ );
|
||||
@@ -3628,12 +3628,12 @@ void SCH_IO_ALTIUM::ParsePowerPort( const std::map<wxString, wxString>& aPropert
|
||||
// each symbol has its own powerSymbolIt for now
|
||||
SCH_SYMBOL* symbol = new SCH_SYMBOL();
|
||||
symbol->SetRef( &m_sheetPath, "#PWR?" );
|
||||
symbol->GetField( REFERENCE_FIELD )->SetVisible( false );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->SetVisible( false );
|
||||
symbol->SetValueFieldText( elem.text );
|
||||
symbol->SetLibId( libId );
|
||||
symbol->SetLibSymbol( new LIB_SYMBOL( *libSymbol ) );
|
||||
|
||||
SCH_FIELD* valueField = symbol->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* valueField = symbol->GetField( FIELD_T::VALUE );
|
||||
valueField->SetVisible( elem.showNetName );
|
||||
|
||||
// TODO: Why do I need to set this a second time?
|
||||
@@ -3778,6 +3778,9 @@ void SCH_IO_ALTIUM::ParsePortHelper( const ASCH_PORT& aElem )
|
||||
}
|
||||
#else
|
||||
label = new SCH_GLOBALLABEL( position, aElem.Name );
|
||||
|
||||
// Default "Sheet References" field should be hidden, at least for now
|
||||
label->GetField( INTERSHEET_REFS )->SetVisible( false );
|
||||
#endif
|
||||
|
||||
switch( aElem.IOtype )
|
||||
@@ -3816,11 +3819,6 @@ void SCH_IO_ALTIUM::ParsePortHelper( const ASCH_PORT& aElem )
|
||||
}
|
||||
|
||||
label->AutoplaceFields( screen, AUTOPLACE_AUTO );
|
||||
|
||||
// Default "Sheet References" field should be hidden, at least for now
|
||||
if( label->GetFields().size() > 0 )
|
||||
label->GetFields()[0].SetVisible( false );
|
||||
|
||||
label->SetFlags( IS_NEW );
|
||||
|
||||
screen->Append( label );
|
||||
@@ -4076,12 +4074,12 @@ void SCH_IO_ALTIUM::ParseSheetName( const std::map<wxString, wxString>& aPropert
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_FIELD& sheetNameField = sheetIt->second->GetFields()[SHEETNAME];
|
||||
SCH_FIELD* sheetNameField = sheetIt->second->GetField( FIELD_T::SHEET_NAME );
|
||||
|
||||
sheetNameField.SetPosition( elem.location + m_sheetOffset );
|
||||
sheetNameField.SetText( elem.text );
|
||||
sheetNameField.SetVisible( !elem.isHidden );
|
||||
SetTextPositioning( &sheetNameField, ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT, elem.orientation );
|
||||
sheetNameField->SetPosition( elem.location + m_sheetOffset );
|
||||
sheetNameField->SetText( elem.text );
|
||||
sheetNameField->SetVisible( !elem.isHidden );
|
||||
SetTextPositioning( sheetNameField, ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT, elem.orientation );
|
||||
}
|
||||
|
||||
|
||||
@@ -4099,14 +4097,14 @@ void SCH_IO_ALTIUM::ParseFileName( const std::map<wxString, wxString>& aProperti
|
||||
return;
|
||||
}
|
||||
|
||||
SCH_FIELD& filenameField = sheetIt->second->GetFields()[SHEETFILENAME];
|
||||
SCH_FIELD* filenameField = sheetIt->second->GetField( FIELD_T::SHEET_FILENAME );
|
||||
|
||||
filenameField.SetPosition( elem.location + m_sheetOffset );
|
||||
filenameField->SetPosition( elem.location + m_sheetOffset );
|
||||
|
||||
// Keep the filename of the Altium file until after the file is actually loaded.
|
||||
filenameField.SetText( elem.text );
|
||||
filenameField.SetVisible( !elem.isHidden );
|
||||
SetTextPositioning( &filenameField, ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT, elem.orientation );
|
||||
filenameField->SetText( elem.text );
|
||||
filenameField->SetVisible( !elem.isHidden );
|
||||
SetTextPositioning( filenameField, ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT, elem.orientation );
|
||||
}
|
||||
|
||||
|
||||
@@ -4120,7 +4118,7 @@ void SCH_IO_ALTIUM::ParseDesignator( const std::map<wxString, wxString>& aProper
|
||||
{
|
||||
// TODO: e.g. can depend on Template (RECORD=39
|
||||
m_errorMessages.emplace( wxString::Format( wxT( "Designator's owner (%d) not found." ),
|
||||
elem.ownerindex ),
|
||||
elem.ownerindex ),
|
||||
RPT_SEVERITY_DEBUG );
|
||||
return;
|
||||
}
|
||||
@@ -4140,10 +4138,10 @@ void SCH_IO_ALTIUM::ParseDesignator( const std::map<wxString, wxString>& aProper
|
||||
// I have examples with this criteria fully incorrect.
|
||||
bool visible = !emptyRef;
|
||||
|
||||
symbol->GetField( VALUE_FIELD )->SetVisible( visible );
|
||||
symbol->GetField( REFERENCE_FIELD )->SetVisible( visible );
|
||||
symbol->GetField( FIELD_T::VALUE )->SetVisible( visible );
|
||||
|
||||
SCH_FIELD* field = symbol->GetField( REFERENCE_FIELD );
|
||||
SCH_FIELD* field = symbol->GetField( FIELD_T::REFERENCE );
|
||||
field->SetVisible( visible );
|
||||
field->SetPosition( elem.location + m_sheetOffset );
|
||||
SetTextPositioning( field, elem.justification, elem.orientation );
|
||||
}
|
||||
@@ -4253,11 +4251,10 @@ void SCH_IO_ALTIUM::ParseParameter( const std::map<wxString, wxString>& aPropert
|
||||
|
||||
if( upperName == "COMMENT" )
|
||||
{
|
||||
field = symbol->GetField( VALUE_FIELD );
|
||||
field = symbol->GetField( FIELD_T::VALUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
int fieldIdx = symbol->GetNextFieldId();
|
||||
wxString fieldName = elem.name.Upper();
|
||||
|
||||
if( fieldName.IsEmpty() )
|
||||
@@ -4268,9 +4265,8 @@ void SCH_IO_ALTIUM::ParseParameter( const std::map<wxString, wxString>& aPropert
|
||||
{
|
||||
fieldName = wxString::Format( "ALTIUM_UNNAMED_%d", disambiguate++ );
|
||||
|
||||
if( !symbol->FindField( fieldName ) )
|
||||
if( !symbol->GetField( fieldName ) )
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else if( fieldName == "VALUE" )
|
||||
@@ -4278,7 +4274,7 @@ void SCH_IO_ALTIUM::ParseParameter( const std::map<wxString, wxString>& aPropert
|
||||
fieldName = "ALTIUM_VALUE";
|
||||
}
|
||||
|
||||
field = symbol->AddField( SCH_FIELD( VECTOR2I(), fieldIdx, symbol, fieldName ) );
|
||||
field = symbol->AddField( SCH_FIELD( { 0, 0 }, FIELD_T::USER, symbol, fieldName ) );
|
||||
}
|
||||
|
||||
wxString kicadText = AltiumSchSpecialStringsToKiCadVariables( elem.text, variableMap );
|
||||
@@ -4328,7 +4324,6 @@ void SCH_IO_ALTIUM::ParseLibParameter( const std::map<wxString, wxString>& aProp
|
||||
}
|
||||
else
|
||||
{
|
||||
int fieldIdx = libSymbol->GetNextAvailableFieldId();
|
||||
wxString fieldNameStem = elem.name;
|
||||
wxString fieldName = fieldNameStem;
|
||||
int disambiguate = 1;
|
||||
@@ -4346,10 +4341,10 @@ void SCH_IO_ALTIUM::ParseLibParameter( const std::map<wxString, wxString>& aProp
|
||||
}
|
||||
|
||||
// Avoid adding duplicate fields
|
||||
while( libSymbol->FindField( fieldName ) )
|
||||
while( libSymbol->GetField( fieldName ) )
|
||||
fieldName = wxString::Format( "%s_%d", fieldNameStem, disambiguate++ );
|
||||
|
||||
SCH_FIELD* new_field = new SCH_FIELD( libSymbol, fieldIdx, fieldName );
|
||||
SCH_FIELD* new_field = new SCH_FIELD( libSymbol, FIELD_T::USER, fieldName );
|
||||
libSymbol->AddField( new_field );
|
||||
field = new_field;
|
||||
}
|
||||
@@ -4411,8 +4406,7 @@ void SCH_IO_ALTIUM::ParseImplementation( const std::map<wxString, wxString>& aPr
|
||||
LIB_ID fpLibId = AltiumToKiCadLibID( libName, elem.name );
|
||||
|
||||
symbol->SetFPFilters( fpFilters );
|
||||
SCH_FIELD& footprintField = symbol->GetFootprintField();
|
||||
footprintField.SetText( fpLibId.Format() );
|
||||
symbol->GetField( FIELD_T::FOOTPRINT )->SetText( fpLibId.Format() );
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -773,7 +773,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
|
||||
if( copy )
|
||||
delete kiSym;
|
||||
|
||||
SCH_FIELD* refField = symbol->GetField( REFERENCE_FIELD );
|
||||
SCH_FIELD* refField = symbol->GetField( FIELD_T::REFERENCE );
|
||||
|
||||
sym.ComponentRef.Designator.Replace( wxT( "\n" ), wxT( "\\n" ) );
|
||||
sym.ComponentRef.Designator.Replace( wxT( "\r" ), wxT( "\\r" ) );
|
||||
@@ -785,12 +785,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
|
||||
|
||||
if( sym.HasPartRef )
|
||||
{
|
||||
SCH_FIELD* partField = symbol->FindField( PartNameFieldName );
|
||||
SCH_FIELD* partField = symbol->GetField( PartNameFieldName );
|
||||
|
||||
if( !partField )
|
||||
{
|
||||
partField = symbol->AddField( SCH_FIELD( VECTOR2I(), symbol->GetNextFieldId(),
|
||||
symbol, PartNameFieldName ) );
|
||||
partField = symbol->AddField( SCH_FIELD( { 0, 0 }, FIELD_T::USER, symbol,
|
||||
PartNameFieldName ) );
|
||||
}
|
||||
|
||||
wxASSERT( partField->GetName() == PartNameFieldName );
|
||||
@@ -813,13 +813,12 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
|
||||
if( attrVal.HasLocation )
|
||||
{
|
||||
wxString attrName = getAttributeName( attrVal.AttributeID );
|
||||
SCH_FIELD* attrField = symbol->FindField( attrName );
|
||||
SCH_FIELD* attrField = symbol->GetField( attrName );
|
||||
|
||||
if( !attrField )
|
||||
{
|
||||
attrField = symbol->AddField( SCH_FIELD( VECTOR2I(),
|
||||
symbol->GetNextFieldId(),
|
||||
symbol, attrName ) );
|
||||
attrField = symbol->AddField( SCH_FIELD( { 0, 0 }, FIELD_T::USER, symbol,
|
||||
attrName ) );
|
||||
}
|
||||
|
||||
wxASSERT( attrField->GetName() == attrName );
|
||||
@@ -1123,7 +1122,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
|
||||
|
||||
if( m_powerSymMap.find( netTerm.SymbolID ) != m_powerSymMap.end() )
|
||||
{
|
||||
SCH_FIELD* val = m_powerSymMap.at( netTerm.SymbolID )->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* val = m_powerSymMap.at( netTerm.SymbolID )->GetField( FIELD_T::VALUE );
|
||||
val->SetText( netName );
|
||||
val->SetBold( false );
|
||||
val->SetVisible( false );
|
||||
@@ -1594,13 +1593,10 @@ CADSTAR_SCH_ARCHIVE_LOADER::addNewFieldToSymbol( const wxString& aF
|
||||
std::unique_ptr<LIB_SYMBOL>& aKiCadSymbol )
|
||||
{
|
||||
// First Check if field already exists
|
||||
SCH_FIELD* existingField = aKiCadSymbol->FindField( aFieldName );
|
||||
|
||||
if( existingField != nullptr )
|
||||
if( SCH_FIELD* existingField = aKiCadSymbol->GetField( aFieldName ) )
|
||||
return existingField;
|
||||
|
||||
SCH_FIELD* newfield = new SCH_FIELD( aKiCadSymbol.get(),
|
||||
aKiCadSymbol->GetNextAvailableFieldId(), aFieldName );
|
||||
SCH_FIELD* newfield = new SCH_FIELD( aKiCadSymbol.get(), FIELD_T::USER, aFieldName );
|
||||
newfield->SetVisible( false );
|
||||
aKiCadSymbol->AddField( newfield );
|
||||
/*
|
||||
@@ -1881,9 +1877,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolGateAndPartFields( const SYMDEF_ID& a
|
||||
tempSymbol->GetValueField().SetVisible( false );
|
||||
|
||||
|
||||
SCH_FIELD* partNameField = tempSymbol->FindField( PartNameFieldName );
|
||||
|
||||
if( partNameField )
|
||||
if( SCH_FIELD* partNameField = tempSymbol->GetField( PartNameFieldName ) )
|
||||
partNameField->SetText( EscapeFieldText( aCadstarPart.Name ) );
|
||||
|
||||
const POINT& symDefOrigin = Library.SymbolDefinitions.at( aSymdefID ).Origin;
|
||||
@@ -1927,7 +1921,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymbolGateAndPartFields( const SYMDEF_ID& a
|
||||
return;
|
||||
}
|
||||
|
||||
bool attrIsNew = tempSymbol->FindField( attrName ) == nullptr;
|
||||
bool attrIsNew = tempSymbol->GetField( attrName ) == nullptr;
|
||||
SCH_FIELD* attrField = addNewFieldToSymbol( attrName, tempSymbol );
|
||||
|
||||
wxASSERT( attrField->GetName() == attrName );
|
||||
@@ -2489,10 +2483,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( const LAYER_ID&
|
||||
|
||||
wxString name = Sheets.SheetNames.at( aCadstarSheetID );
|
||||
|
||||
SCH_FIELD& sheetNameField = sheet->GetFields()[SHEETNAME];
|
||||
SCH_FIELD& filenameField = sheet->GetFields()[SHEETFILENAME];
|
||||
|
||||
sheetNameField.SetText( name );
|
||||
sheet->GetField( FIELD_T::SHEET_NAME )->SetText( name );
|
||||
|
||||
int sheetNum = getSheetNumber( aCadstarSheetID );
|
||||
wxString loadedFilename = wxFileName( Filename ).GetName();
|
||||
@@ -2501,7 +2492,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets( const LAYER_ID&
|
||||
ReplaceIllegalFileNameChars( &filename );
|
||||
filename += wxT( "." ) + wxString( FILEEXT::KiCadSchematicFileExtension );
|
||||
|
||||
filenameField.SetText( filename );
|
||||
sheet->GetField( FIELD_T::SHEET_FILENAME )->SetText( filename );
|
||||
|
||||
wxFileName fn( m_schematic->Prj().GetProjectPath() + filename );
|
||||
sheet->GetScreen()->SetFileName( fn.GetFullPath() );
|
||||
|
||||
@@ -632,7 +632,7 @@ std::unique_ptr<LIB_SYMBOL> SCH_IO_DATABASE::loadSymbolFromRow( const wxString&
|
||||
}
|
||||
else
|
||||
{
|
||||
field = new SCH_FIELD( nullptr, symbol->GetNextAvailableFieldId() );
|
||||
field = new SCH_FIELD( nullptr, FIELD_T::USER );
|
||||
field->SetName( mapping.name_wx );
|
||||
isNew = true;
|
||||
fieldsMap[mapping.name_wx] = field;
|
||||
|
||||
@@ -784,7 +784,7 @@ void SCH_IO_EAGLE::loadSchematic( const ESCHEMATIC& aSchematic )
|
||||
|
||||
// Instantiate the missing symbol unit
|
||||
int unit = unitEntry.first;
|
||||
const wxString reference = origSymbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
const wxString reference = origSymbol->GetField( FIELD_T::REFERENCE )->GetText();
|
||||
std::unique_ptr<SCH_SYMBOL> symbol( (SCH_SYMBOL*) origSymbol->Duplicate() );
|
||||
|
||||
symbol->SetUnitSelection( &sheetpath, unit );
|
||||
@@ -1817,7 +1817,7 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
if( !package.IsEmpty() )
|
||||
{
|
||||
wxString footprint = m_schematic->Prj().GetProjectName() + wxT( ":" ) + package;
|
||||
symbol->GetField( FOOTPRINT_FIELD )->SetText( footprint );
|
||||
symbol->GetField( FIELD_T::FOOTPRINT )->SetText( footprint );
|
||||
}
|
||||
|
||||
if( aInstance->rot )
|
||||
@@ -1831,11 +1831,17 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
std::vector<SCH_FIELD*> partFields;
|
||||
part->GetFields( partFields );
|
||||
|
||||
for( const SCH_FIELD* field : partFields )
|
||||
for( const SCH_FIELD* partField : partFields )
|
||||
{
|
||||
symbol->GetFieldById( field->GetId() )->ImportValues( *field );
|
||||
symbol->GetFieldById( field->GetId() )->SetTextPos( (VECTOR2I)symbol->GetPosition()
|
||||
+ field->GetTextPos() );
|
||||
SCH_FIELD* symbolField;
|
||||
|
||||
if( partField->IsMandatory() )
|
||||
symbolField = symbol->GetField( partField->GetId() );
|
||||
else
|
||||
symbolField = symbol->GetField( partField->GetName() );
|
||||
|
||||
symbolField->ImportValues( *partField );
|
||||
symbolField->SetTextPos( symbol->GetPosition() + partField->GetTextPos() );
|
||||
}
|
||||
|
||||
// If there is no footprint assigned, then prepend the reference value
|
||||
@@ -1857,10 +1863,10 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
if( aInstance->part.find_first_not_of( wxT( "#" ) ) != 0 )
|
||||
reference.Prepend( wxT( "UNK" ) );
|
||||
|
||||
SCH_FIELD* referenceField = symbol->GetField( REFERENCE_FIELD );
|
||||
SCH_FIELD* referenceField = symbol->GetField( FIELD_T::REFERENCE );
|
||||
referenceField->SetText( reference );
|
||||
|
||||
SCH_FIELD* valueField = symbol->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* valueField = symbol->GetField( FIELD_T::VALUE );
|
||||
bool userValue = m_userValue.at( libIdSymbolName );
|
||||
|
||||
if( part->GetUnitCount() > 1 )
|
||||
@@ -1883,13 +1889,12 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
|
||||
for( const auto& [ attrName, attr ] : epart->attributes )
|
||||
{
|
||||
VECTOR2I newFieldPosition( 0, 0 );
|
||||
SCH_FIELD* lastField = symbol->GetFieldById( symbol->GetFieldCount() - 1 );
|
||||
VECTOR2I newFieldPosition( 0, 0 );
|
||||
|
||||
if( lastField )
|
||||
newFieldPosition = lastField->GetPosition();
|
||||
if( !symbol->GetFields().empty() )
|
||||
newFieldPosition = symbol->GetFields().back().GetPosition();
|
||||
|
||||
SCH_FIELD newField( newFieldPosition, symbol->GetNextFieldId(), symbol.get() );
|
||||
SCH_FIELD newField( newFieldPosition, FIELD_T::USER, symbol.get() );
|
||||
|
||||
newField.SetName( attrName );
|
||||
|
||||
@@ -1903,7 +1908,7 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
|
||||
for( const auto& [variantName, variant] : epart->variants )
|
||||
{
|
||||
SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) );
|
||||
SCH_FIELD* field = symbol->AddField( *symbol->GetField( FIELD_T::VALUE ) );
|
||||
field->SetName( wxT( "VARIANT_" ) + variant->name );
|
||||
|
||||
if( variant->value )
|
||||
@@ -1922,17 +1927,17 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
|
||||
if( eattr->name.Lower() == wxT( "name" ) )
|
||||
{
|
||||
field = symbol->GetField( REFERENCE_FIELD );
|
||||
field = symbol->GetField( FIELD_T::REFERENCE );
|
||||
nameAttributeFound = true;
|
||||
}
|
||||
else if( eattr->name.Lower() == wxT( "value" ) )
|
||||
{
|
||||
field = symbol->GetField( VALUE_FIELD );
|
||||
field = symbol->GetField( FIELD_T::VALUE );
|
||||
valueAttributeFound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
field = symbol->FindField( eattr->name );
|
||||
field = symbol->GetField( eattr->name );
|
||||
|
||||
if( field )
|
||||
field->SetVisible( false );
|
||||
@@ -1964,8 +1969,8 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
// Use the instance attribute to determine the reference and value field visibility.
|
||||
if( aInstance->smashed && aInstance->smashed.Get() )
|
||||
{
|
||||
symbol->GetField( VALUE_FIELD )->SetVisible( valueAttributeFound );
|
||||
symbol->GetField( REFERENCE_FIELD )->SetVisible( nameAttributeFound );
|
||||
symbol->GetField( FIELD_T::VALUE )->SetVisible( valueAttributeFound );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->SetVisible( nameAttributeFound );
|
||||
}
|
||||
|
||||
// Eagle has a brain dead module reference scheme where the module names separated by colons
|
||||
@@ -1995,7 +2000,7 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr<EINSTANCE>& aInstance,
|
||||
m_connPoints[symbol->GetPinPhysicalPosition( pin )].emplace( pin );
|
||||
|
||||
if( part->IsPower() )
|
||||
m_powerPorts[ reference ] = symbol->GetField( VALUE_FIELD )->GetText();
|
||||
m_powerPorts[ reference ] = symbol->GetField( FIELD_T::VALUE )->GetText();
|
||||
|
||||
symbol->ClearFlags();
|
||||
|
||||
@@ -2037,7 +2042,7 @@ EAGLE_LIBRARY* SCH_IO_EAGLE::loadLibrary( const ELIBRARY* aLibrary, EAGLE_LIBRAR
|
||||
libSymbol->SetUnitCount( gate_count );
|
||||
libSymbol->LockUnits( true );
|
||||
|
||||
SCH_FIELD* reference = libSymbol->GetFieldById( REFERENCE_FIELD );
|
||||
SCH_FIELD* reference = libSymbol->GetField( FIELD_T::REFERENCE );
|
||||
|
||||
if( prefix.length() == 0 )
|
||||
{
|
||||
@@ -2050,7 +2055,7 @@ EAGLE_LIBRARY* SCH_IO_EAGLE::loadLibrary( const ELIBRARY* aLibrary, EAGLE_LIBRAR
|
||||
reference->SetText( edevice->package ? prefix : '#' + prefix );
|
||||
}
|
||||
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetVisible( true );
|
||||
libSymbol->GetValueField().SetVisible( true );
|
||||
|
||||
int gateindex = 1;
|
||||
bool ispower = false;
|
||||
@@ -2129,7 +2134,7 @@ EAGLE_LIBRARY* SCH_IO_EAGLE::loadLibrary( const ELIBRARY* aLibrary, EAGLE_LIBRAR
|
||||
|
||||
aEagleLibrary->KiCadSymbols[ libName ] = std::move( libSymbol );
|
||||
|
||||
// Store information on whether the value of VALUE_FIELD for a part should be
|
||||
// Store information on whether the value of FIELD_T::VALUE for a part should be
|
||||
// part/@value or part/@deviceset + part/@device.
|
||||
m_userValue.emplace( std::make_pair( libName, edeviceset->uservalue == true ) );
|
||||
}
|
||||
@@ -2231,8 +2236,7 @@ bool SCH_IO_EAGLE::loadSymbol( const std::unique_ptr<ESYMBOL>& aEsymbol,
|
||||
if( libtext->GetText() == wxT( "${REFERENCE}" ) )
|
||||
{
|
||||
// Move text & attributes to Reference field and discard LIB_TEXT item
|
||||
SCH_FIELD* field = aSymbol->GetFieldById( REFERENCE_FIELD );
|
||||
loadFieldAttributes( field, libtext.get() );
|
||||
loadFieldAttributes( &aSymbol->GetReferenceField(), libtext.get() );
|
||||
|
||||
// Show Reference field if Eagle reference was uppercase
|
||||
showRefDes = etext->text == wxT( ">NAME" );
|
||||
@@ -2240,8 +2244,7 @@ bool SCH_IO_EAGLE::loadSymbol( const std::unique_ptr<ESYMBOL>& aEsymbol,
|
||||
else if( libtext->GetText() == wxT( "${VALUE}" ) )
|
||||
{
|
||||
// Move text & attributes to Value field and discard LIB_TEXT item
|
||||
SCH_FIELD* field = aSymbol->GetFieldById( VALUE_FIELD );
|
||||
loadFieldAttributes( field, libtext.get() );
|
||||
loadFieldAttributes( &aSymbol->GetValueField(), libtext.get() );
|
||||
|
||||
// Show Value field if Eagle reference was uppercase
|
||||
showValue = etext->text == wxT( ">VALUE" );
|
||||
@@ -2269,8 +2272,8 @@ bool SCH_IO_EAGLE::loadSymbol( const std::unique_ptr<ESYMBOL>& aEsymbol,
|
||||
}
|
||||
}
|
||||
|
||||
aSymbol->GetFieldById( REFERENCE_FIELD )->SetVisible( showRefDes );
|
||||
aSymbol->GetFieldById( VALUE_FIELD )->SetVisible( showValue );
|
||||
aSymbol->GetReferenceField().SetVisible( showRefDes );
|
||||
aSymbol->GetValueField().SetVisible( showValue );
|
||||
|
||||
return pincount == 1 ? ispower : false;
|
||||
}
|
||||
@@ -3347,7 +3350,7 @@ void SCH_IO_EAGLE::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScr
|
||||
return;
|
||||
|
||||
int unit = aSymbol->GetUnit();
|
||||
const wxString reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
const wxString reference = aSymbol->GetField( FIELD_T::REFERENCE )->GetText();
|
||||
std::vector<SCH_PIN*> pins = aSymbol->GetLibSymbolRef()->GetPins();
|
||||
std::set<int> missingUnits;
|
||||
|
||||
|
||||
@@ -963,11 +963,11 @@ LIB_SYMBOL* SCH_EASYEDA_PARSER::ParseSymbol( const VECTOR2D& aOrigi
|
||||
if( valOpt->empty() )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* fd = ksymbol->FindField( attrName, true );
|
||||
SCH_FIELD* fd = ksymbol->FindFieldCaseInsensitive( attrName );
|
||||
|
||||
if( !fd )
|
||||
{
|
||||
fd = new SCH_FIELD( ksymbol.get(), ksymbol->GetNextAvailableFieldId(), attrName );
|
||||
fd = new SCH_FIELD( ksymbol.get(), FIELD_T::USER, attrName );
|
||||
ksymbol->AddField( fd );
|
||||
}
|
||||
|
||||
@@ -1245,7 +1245,7 @@ void SCH_EASYEDA_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aRoot
|
||||
|
||||
schSym->SetPosition( RelPos( pos ) );
|
||||
|
||||
SCH_FIELD* valField = schSym->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* valField = schSym->GetField( FIELD_T::VALUE );
|
||||
|
||||
valField->SetPosition( RelPos( valuePos ) );
|
||||
valField->SetTextAngleDegrees( textAngle - angle );
|
||||
|
||||
@@ -720,11 +720,11 @@ SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohmann::json>& aLines,
|
||||
if( valOpt->empty() )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* fd = ksymbol->FindField( attrName, true );
|
||||
SCH_FIELD* fd = ksymbol->FindFieldCaseInsensitive( attrName );
|
||||
|
||||
if( !fd )
|
||||
{
|
||||
fd = new SCH_FIELD( ksymbol, ksymbol->GetNextAvailableFieldId(), attrName );
|
||||
fd = new SCH_FIELD( ksymbol, FIELD_T::USER, attrName );
|
||||
ksymbol->AddField( fd );
|
||||
}
|
||||
|
||||
@@ -1182,7 +1182,7 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
||||
&aSchematic->CurrentSheet(),
|
||||
esymInfo.partUnits[unitName] );
|
||||
|
||||
schSym->SetFootprintFieldText( newLibSymbol.GetFootprintField().GetText() );
|
||||
schSym->SetFootprintFieldText( newLibSymbol.GetFootprint() );
|
||||
|
||||
for( double i = component->rotation; i > 0; i -= 90 )
|
||||
schSym->Rotate( VECTOR2I(), true );
|
||||
@@ -1196,20 +1196,20 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
||||
{
|
||||
if( auto globalNetAttr = get_opt( attributes, "Global Net Name" ) )
|
||||
{
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( VALUE_FIELD ), *globalNetAttr,
|
||||
false, true, compAttrs, schSym.get() );
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( FIELD_T::VALUE ),
|
||||
*globalNetAttr, false, true, compAttrs, schSym.get() );
|
||||
|
||||
for( SCH_PIN* pin : schSym->GetAllLibPins() )
|
||||
pin->SetName( globalNetAttr->value );
|
||||
}
|
||||
else
|
||||
{
|
||||
schSym->GetField( VALUE_FIELD )
|
||||
->SetText( newLibSymbol.GetValueField().GetText() );
|
||||
SCH_FIELD* valueField = schSym->GetField( FIELD_T::VALUE );
|
||||
valueField->SetText( newLibSymbol.GetValueField().GetText() );
|
||||
}
|
||||
|
||||
schSym->SetRef( &aSchematic->CurrentSheet(), wxS( "#PWR?" ) );
|
||||
schSym->GetField( REFERENCE_FIELD )->SetVisible( false );
|
||||
schSym->GetField( FIELD_T::REFERENCE )->SetVisible( false );
|
||||
}
|
||||
else if( esymInfo.head.symbolType == EASYEDAPRO::SYMBOL_TYPE::NETPORT )
|
||||
{
|
||||
@@ -1291,13 +1291,12 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
||||
if( valOpt->empty() )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* text = schSym->FindField( attrKey, true );
|
||||
SCH_FIELD* text = schSym->FindFieldCaseInsensitive( attrKey );
|
||||
|
||||
if( !text )
|
||||
{
|
||||
text = schSym->AddField( SCH_FIELD( schSym.get(),
|
||||
schSym->GetNextFieldId(),
|
||||
attrKey ) );
|
||||
text = new SCH_FIELD( schSym.get(), FIELD_T::USER, attrKey );
|
||||
schSym->AddField( text );
|
||||
}
|
||||
|
||||
wxString value = *valOpt;
|
||||
@@ -1331,19 +1330,19 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
||||
|
||||
if( targetValueAttr )
|
||||
{
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( VALUE_FIELD ), *targetValueAttr,
|
||||
false, true, compAttrs, schSym.get() );
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( FIELD_T::VALUE ),
|
||||
*targetValueAttr, false, true, compAttrs, schSym.get() );
|
||||
}
|
||||
|
||||
if( auto descrAttr = get_opt( attributes, "Description" ) )
|
||||
{
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( DESCRIPTION_FIELD ), *descrAttr,
|
||||
false, true, compAttrs, schSym.get() );
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( FIELD_T::DESCRIPTION ),
|
||||
*descrAttr, false, true, compAttrs, schSym.get() );
|
||||
}
|
||||
|
||||
if( auto designatorAttr = get_opt( attributes, "Designator" ) )
|
||||
{
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( REFERENCE_FIELD ),
|
||||
ApplyAttrToField( fontStyles, schSym->GetField( FIELD_T::REFERENCE ),
|
||||
*designatorAttr, false, true, compAttrs, schSym.get() );
|
||||
|
||||
schSym->SetRef( &aSchematic->CurrentSheet(), designatorAttr->value );
|
||||
@@ -1363,12 +1362,12 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
||||
if( attr.value.IsEmpty() )
|
||||
continue;
|
||||
|
||||
SCH_FIELD* text = schSym->FindField( attrKey, true );
|
||||
SCH_FIELD* text = schSym->FindFieldCaseInsensitive( attrKey );
|
||||
|
||||
if( !text )
|
||||
{
|
||||
text = schSym->AddField( SCH_FIELD( schSym.get(), schSym->GetNextFieldId(),
|
||||
attrKey ) );
|
||||
text = new SCH_FIELD( schSym.get(), FIELD_T::USER, attrKey );
|
||||
schSym->AddField( text );
|
||||
}
|
||||
|
||||
text->SetPosition( schSym->GetPosition() );
|
||||
|
||||
@@ -474,7 +474,7 @@ LIB_SYMBOL* SCH_IO_HTTP_LIB::loadSymbolFromPart( const wxString& aSymbo
|
||||
// This proves useful in situations where, for instance, an individual requires a particular value, such as
|
||||
// the material type showcased at a specific position for a capacitor. Subsequently, this value could be defined
|
||||
// in the symbol itself and then, potentially, be modified by the HTTP library as necessary.
|
||||
field = symbol->FindField( fieldName );
|
||||
field = symbol->GetField( fieldName );
|
||||
|
||||
if( field != nullptr )
|
||||
{
|
||||
@@ -485,7 +485,7 @@ LIB_SYMBOL* SCH_IO_HTTP_LIB::loadSymbolFromPart( const wxString& aSymbo
|
||||
else
|
||||
{
|
||||
// Generic fields
|
||||
field = new SCH_FIELD( nullptr, symbol->GetNextAvailableFieldId() );
|
||||
field = new SCH_FIELD( symbol, FIELD_T::USER );
|
||||
field->SetName( fieldName );
|
||||
|
||||
field->SetText( std::get<0>( fieldProperties ) );
|
||||
|
||||
@@ -571,23 +571,24 @@ SCH_SHEET* SCH_IO_KICAD_LEGACY::loadSheet( LINE_READER& aReader )
|
||||
|
||||
wxString text;
|
||||
int size;
|
||||
int fieldId = parseInt( aReader, line, &line );
|
||||
int legacy_field_id = parseInt( aReader, line, &line );
|
||||
|
||||
if( fieldId == 0 || fieldId == 1 ) // Sheet name and file name.
|
||||
if( legacy_field_id == 0 || legacy_field_id == 1 ) // Sheet name and file name.
|
||||
{
|
||||
parseQuotedString( text, aReader, line, &line );
|
||||
size = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
|
||||
|
||||
SCH_FIELD& field = sheet->GetFields()[ fieldId ];
|
||||
field.SetText( text );
|
||||
field.SetTextSize( VECTOR2I( size, size ) );
|
||||
SCH_FIELD* field = sheet->GetField( legacy_field_id == 0 ? FIELD_T::SHEET_NAME
|
||||
: FIELD_T::SHEET_FILENAME );
|
||||
field->SetText( text );
|
||||
field->SetTextSize( VECTOR2I( size, size ) );
|
||||
}
|
||||
else // Sheet pin.
|
||||
{
|
||||
// Use a unique_ptr so that we clean up in the case of a throw
|
||||
std::unique_ptr<SCH_SHEET_PIN> sheetPin = std::make_unique<SCH_SHEET_PIN>( sheet.get() );
|
||||
|
||||
sheetPin->SetNumber( fieldId );
|
||||
sheetPin->SetNumber( legacy_field_id );
|
||||
|
||||
// Can be empty fields.
|
||||
parseQuotedString( text, aReader, line, &line, true );
|
||||
@@ -1274,11 +1275,11 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
SCH_PARSE_ERROR( "unit value out of range", aReader, line );
|
||||
|
||||
symbol->AddHierarchicalReference( path, reference, (int)tmp );
|
||||
symbol->GetField( REFERENCE_FIELD )->SetText( reference );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->SetText( reference );
|
||||
}
|
||||
else if( strCompare( "F", line, &line ) )
|
||||
{
|
||||
int index = parseInt( aReader, line, &line );
|
||||
int legacy_field_id = parseInt( aReader, line, &line );
|
||||
|
||||
wxString text, name;
|
||||
|
||||
@@ -1295,37 +1296,21 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
int size = schIUScale.MilsToIU( parseInt( aReader, line, &line ) );
|
||||
int attributes = parseHex( aReader, line, &line );
|
||||
|
||||
// Description was not mandatory until v8.0, so any fields with an index
|
||||
// past this point should be user fields
|
||||
if( index > DATASHEET_FIELD )
|
||||
SCH_FIELD* field;
|
||||
|
||||
// Map fixed legacy IDs
|
||||
switch( legacy_field_id )
|
||||
{
|
||||
// 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() >= MANDATORY_FIELD_COUNT );
|
||||
case 0: field = symbol->GetField( FIELD_T::REFERENCE ); break;
|
||||
case 1: field = symbol->GetField( FIELD_T::VALUE ); break;
|
||||
case 2: field = symbol->GetField( FIELD_T::FOOTPRINT ); break;
|
||||
case 3: field = symbol->GetField( FIELD_T::DATASHEET ); break;
|
||||
|
||||
// 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
|
||||
// is now mandatory but a user could have easily added their own user field named Description
|
||||
// after Datasheet before it was mandatory, and we don't want to add a second Description field.
|
||||
SCH_FIELD* existingField = symbol->GetFieldByName( name );
|
||||
|
||||
if( !existingField )
|
||||
{
|
||||
// Ignore the _supplied_ fieldNdx. It is not important anymore if within the
|
||||
// user defined fields region (i.e. >= MANDATORY_FIELD_COUNT).
|
||||
// We freely renumber the index to fit the next available field slot.
|
||||
index = symbol->GetNextFieldId(); // new has this index after insertion
|
||||
|
||||
SCH_FIELD field( VECTOR2I( 0, 0 ), index, symbol.get(), name );
|
||||
symbol->AddField( field );
|
||||
}
|
||||
else
|
||||
index = existingField->GetId();
|
||||
default:
|
||||
field = symbol->AddField( SCH_FIELD( { 0, 0 }, FIELD_T::USER, symbol.get() ) );
|
||||
break;
|
||||
}
|
||||
|
||||
SCH_FIELD& field = symbol->GetFields()[index];
|
||||
|
||||
// Prior to version 2 of the schematic file format, none of the following existed.
|
||||
if( m_version > 1 )
|
||||
{
|
||||
@@ -1338,9 +1323,9 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
parseQuotedString( name, aReader, line, &line, true );
|
||||
|
||||
if( hjustify == 'L' )
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
field->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
else if( hjustify == 'R' )
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
field->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
else if( hjustify != 'C' )
|
||||
SCH_PARSE_ERROR( "symbol field text horizontal justification must be "
|
||||
"L, R, or C", aReader, line );
|
||||
@@ -1348,9 +1333,9 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
// We are guaranteed to have a least one character here for older file formats
|
||||
// otherwise an exception would have been raised..
|
||||
if( textAttrs[0] == 'T' )
|
||||
field.SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
field->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
else if( textAttrs[0] == 'B' )
|
||||
field.SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
field->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
else if( textAttrs[0] != 'C' )
|
||||
SCH_PARSE_ERROR( "symbol field text vertical justification must be "
|
||||
"B, T, or C", aReader, line );
|
||||
@@ -1366,7 +1351,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
|
||||
if( textAttrs[1] == 'I' )
|
||||
{
|
||||
field.SetItalicFlag( true );
|
||||
field->SetItalicFlag( true );
|
||||
}
|
||||
else if( textAttrs[1] != 'N' )
|
||||
{
|
||||
@@ -1376,7 +1361,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
|
||||
if( textAttrs[2] == 'B' )
|
||||
{
|
||||
field.SetBoldFlag( true );
|
||||
field->SetBoldFlag( true );
|
||||
}
|
||||
else if( textAttrs[2] != 'N' )
|
||||
{
|
||||
@@ -1386,22 +1371,27 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
}
|
||||
}
|
||||
|
||||
field.SetText( text );
|
||||
field.SetTextPos( pos );
|
||||
field.SetVisible( !attributes );
|
||||
field.SetTextSize( VECTOR2I( size, size ) );
|
||||
field->SetText( text );
|
||||
field->SetTextPos( pos );
|
||||
field->SetVisible( !attributes );
|
||||
field->SetTextSize( VECTOR2I( size, size ) );
|
||||
|
||||
if( orientation == 'H' )
|
||||
field.SetTextAngle( ANGLE_HORIZONTAL );
|
||||
field->SetTextAngle( ANGLE_HORIZONTAL );
|
||||
else if( orientation == 'V' )
|
||||
field.SetTextAngle( ANGLE_VERTICAL );
|
||||
field->SetTextAngle( ANGLE_VERTICAL );
|
||||
else
|
||||
SCH_PARSE_ERROR( "symbol field orientation must be H or V", aReader, line );
|
||||
|
||||
if( name.IsEmpty() )
|
||||
name = GetDefaultFieldName( index, !DO_TRANSLATE );
|
||||
{
|
||||
if( field->IsMandatory() )
|
||||
name = GetCanonicalFieldName( field->GetId() );
|
||||
else
|
||||
name = GetUserFieldName( legacy_field_id, !DO_TRANSLATE );
|
||||
}
|
||||
|
||||
field.SetName( name );
|
||||
field->SetName( name );
|
||||
}
|
||||
else if( strCompare( "$EndComp", line ) )
|
||||
{
|
||||
@@ -1414,7 +1404,7 @@ SCH_SYMBOL* SCH_IO_KICAD_LEGACY::loadSymbol( LINE_READER& aReader )
|
||||
|
||||
SCH_SYMBOL_INSTANCE instance;
|
||||
instance.m_Path = path;
|
||||
instance.m_Reference = symbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
instance.m_Reference = symbol->GetField( FIELD_T::REFERENCE )->GetText();
|
||||
instance.m_Unit = symbol->GetUnit();
|
||||
symbol->AddHierarchicalReference( instance );
|
||||
}
|
||||
@@ -1688,10 +1678,10 @@ void SCH_IO_KICAD_LEGACY::saveSymbol( SCH_SYMBOL* aSymbol )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aSymbol->GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
|
||||
if( aSymbol->GetField( FIELD_T::REFERENCE )->GetText().IsEmpty() )
|
||||
name1 = toUTFTildaText( aSymbol->GetPrefix() );
|
||||
else
|
||||
name1 = toUTFTildaText( aSymbol->GetField( REFERENCE_FIELD )->GetText() );
|
||||
name1 = toUTFTildaText( aSymbol->GetField( FIELD_T::REFERENCE )->GetText() );
|
||||
}
|
||||
|
||||
wxString symbol_name = aSymbol->GetLibId().Format();
|
||||
@@ -1748,29 +1738,11 @@ void SCH_IO_KICAD_LEGACY::saveSymbol( SCH_SYMBOL* aSymbol )
|
||||
}
|
||||
}
|
||||
|
||||
// update the ugly field id, which I would like to see go away someday soon.
|
||||
for( int i = 0; i < aSymbol->GetFieldCount(); ++i )
|
||||
aSymbol->GetFields()[i].SetId( i );
|
||||
// NB: FieldIDs in legacy libraries must be consecutive, and include user fields
|
||||
int legacy_field_id = 0;
|
||||
|
||||
// Fixed fields:
|
||||
// Save mandatory fields even if they are blank,
|
||||
// because the visibility, size and orientation are set from library editor.
|
||||
for( SCH_FIELD& field : aSymbol->GetFields() )
|
||||
{
|
||||
if( field.IsMandatory() )
|
||||
saveField( &field );
|
||||
}
|
||||
|
||||
// User defined fields:
|
||||
// The *policy* about which user defined fields are symbol of a symbol is now
|
||||
// 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( SCH_FIELD& field : aSymbol->GetFields() )
|
||||
{
|
||||
if( !field.IsMandatory() )
|
||||
saveField( &field );
|
||||
}
|
||||
saveField( &field, legacy_field_id++ );
|
||||
|
||||
// Unit number, position, box ( old standard )
|
||||
m_out->Print( 0, "\t%-4d %-4d %-4d\n", aSymbol->GetUnit(),
|
||||
@@ -1785,7 +1757,7 @@ void SCH_IO_KICAD_LEGACY::saveSymbol( SCH_SYMBOL* aSymbol )
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_KICAD_LEGACY::saveField( SCH_FIELD* aField )
|
||||
void SCH_IO_KICAD_LEGACY::saveField( SCH_FIELD* aField, int aLegacyId )
|
||||
{
|
||||
char hjustify = 'C';
|
||||
|
||||
@@ -1802,7 +1774,7 @@ void SCH_IO_KICAD_LEGACY::saveField( SCH_FIELD* aField )
|
||||
vjustify = 'T';
|
||||
|
||||
m_out->Print( 0, "F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c",
|
||||
aField->GetId(),
|
||||
aLegacyId,
|
||||
EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too
|
||||
aField->GetTextAngle().IsHorizontal() ? 'H' : 'V',
|
||||
schIUScale.IUToMils( aField->GetLibPosition().x ),
|
||||
@@ -1874,21 +1846,21 @@ void SCH_IO_KICAD_LEGACY::saveSheet( SCH_SHEET* aSheet )
|
||||
|
||||
m_out->Print( 0, "U %8.8X\n", aSheet->m_Uuid.AsLegacyTimestamp() );
|
||||
|
||||
SCH_FIELD& sheetName = aSheet->GetFields()[SHEETNAME];
|
||||
SCH_FIELD& fileName = aSheet->GetFields()[SHEETFILENAME];
|
||||
SCH_FIELD* sheetName = aSheet->GetField( FIELD_T::SHEET_NAME );
|
||||
SCH_FIELD* fileName = aSheet->GetField( FIELD_T::SHEET_FILENAME );
|
||||
|
||||
if( !sheetName.GetText().IsEmpty() )
|
||||
if( !sheetName->GetText().IsEmpty() )
|
||||
{
|
||||
m_out->Print( 0, "F0 %s %d\n",
|
||||
EscapedUTF8( sheetName.GetText() ).c_str(),
|
||||
schIUScale.IUToMils( sheetName.GetTextSize().x ) );
|
||||
EscapedUTF8( sheetName->GetText() ).c_str(),
|
||||
schIUScale.IUToMils( sheetName->GetTextSize().x ) );
|
||||
}
|
||||
|
||||
if( !fileName.GetText().IsEmpty() )
|
||||
if( !fileName->GetText().IsEmpty() )
|
||||
{
|
||||
m_out->Print( 0, "F1 %s %d\n",
|
||||
EscapedUTF8( fileName.GetText() ).c_str(),
|
||||
schIUScale.IUToMils( fileName.GetTextSize().x ) );
|
||||
EscapedUTF8( fileName->GetText() ).c_str(),
|
||||
schIUScale.IUToMils( fileName->GetTextSize().x ) );
|
||||
}
|
||||
|
||||
for( const SCH_SHEET_PIN* pin : aSheet->GetPins() )
|
||||
@@ -1901,9 +1873,9 @@ void SCH_IO_KICAD_LEGACY::saveSheet( SCH_SHEET* aSheet )
|
||||
switch( pin->GetSide() )
|
||||
{
|
||||
default:
|
||||
case SHEET_SIDE::LEFT: side = 'L'; break;
|
||||
case SHEET_SIDE::RIGHT: side = 'R'; break;
|
||||
case SHEET_SIDE::TOP: side = 'T'; break;
|
||||
case SHEET_SIDE::LEFT: side = 'L'; break;
|
||||
case SHEET_SIDE::RIGHT: side = 'R'; break;
|
||||
case SHEET_SIDE::TOP: side = 'T'; break;
|
||||
case SHEET_SIDE::BOTTOM: side = 'B'; break;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ private:
|
||||
std::shared_ptr<BUS_ALIAS> loadBusAlias( LINE_READER& aReader, SCH_SCREEN* aScreen );
|
||||
|
||||
void saveSymbol( SCH_SYMBOL* aSymbol );
|
||||
void saveField( SCH_FIELD* aField );
|
||||
void saveField( SCH_FIELD* aField, int aLegacyId );
|
||||
void saveBitmap( const SCH_BITMAP& aBitmap );
|
||||
void saveSheet( SCH_SHEET* aSheet );
|
||||
void saveJunction( SCH_JUNCTION* aJunction );
|
||||
|
||||
@@ -259,7 +259,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDocs()
|
||||
|
||||
case 'F':
|
||||
if( symbol )
|
||||
symbol->GetFieldById( DATASHEET_FIELD )->SetText( text );
|
||||
symbol->GetField( FIELD_T::DATASHEET )->SetText( text );
|
||||
break;
|
||||
|
||||
case 0:
|
||||
@@ -506,20 +506,14 @@ 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 fieldId : MANDATORY_FIELDS )
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
SCH_FIELD* field = newSymbol->GetFieldById( fieldId );
|
||||
|
||||
// the MANDATORY_FIELD_COUNT are exactly that in RAM.
|
||||
wxASSERT( field );
|
||||
|
||||
SCH_FIELD* parentField = aSymbol->GetFieldById( fieldId );
|
||||
|
||||
wxASSERT( parentField );
|
||||
SCH_FIELD* field = newSymbol->GetField( fieldId );
|
||||
SCH_FIELD* parentField = aSymbol->GetField( fieldId );
|
||||
|
||||
*field = *parentField;
|
||||
|
||||
if( fieldId == VALUE_FIELD )
|
||||
if( fieldId == FIELD_T::VALUE )
|
||||
field->SetText( newAliasName );
|
||||
|
||||
field->SetParent( newSymbol );
|
||||
@@ -542,27 +536,29 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
|
||||
wxCHECK_RET( *line == 'F', "Invalid field line" );
|
||||
|
||||
wxString text;
|
||||
int id;
|
||||
int legacy_field_id;
|
||||
|
||||
if( sscanf( line + 1, "%d", &id ) != 1 || id < 0 )
|
||||
if( sscanf( line + 1, "%d", &legacy_field_id ) != 1 || legacy_field_id < 0 )
|
||||
SCH_PARSE_ERROR( "invalid field ID", aReader, line + 1 );
|
||||
|
||||
FIELD_T id = FIELD_T::USER;
|
||||
SCH_FIELD* field;
|
||||
|
||||
// Description was not mandatory until v8.0, so any fields with an index
|
||||
// past this point should be user fields
|
||||
if( id >= 0 && id < DESCRIPTION_FIELD )
|
||||
// Map fixed legacy IDs
|
||||
switch( legacy_field_id )
|
||||
{
|
||||
field = aSymbol->GetFieldById( id );
|
||||
case 0: id = FIELD_T::REFERENCE; break;
|
||||
case 1: id = FIELD_T::VALUE; break;
|
||||
case 2: id = FIELD_T::FOOTPRINT; break;
|
||||
case 3: id = FIELD_T::DATASHEET; break;
|
||||
}
|
||||
|
||||
// this will fire only if somebody broke a constructor or editor.
|
||||
// MANDATORY_FIELDS are always present in ram resident symbols, no
|
||||
// exceptions, and they always have their names set, even fixed fields.
|
||||
wxASSERT( field );
|
||||
if( id != FIELD_T::USER )
|
||||
{
|
||||
field = aSymbol->GetField( id );
|
||||
}
|
||||
else
|
||||
{
|
||||
id = aSymbol->GetNextAvailableFieldId();
|
||||
field = new SCH_FIELD( aSymbol.get(), id );
|
||||
aSymbol->AddDrawItem( field, false );
|
||||
}
|
||||
@@ -578,7 +574,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
|
||||
|
||||
// The value field needs to be "special" escaped. The other fields are
|
||||
// escaped normally and don't need special handling
|
||||
if( id == VALUE_FIELD )
|
||||
if( id == FIELD_T::VALUE )
|
||||
text = EscapeString( text, CTX_QUOTED_STR );
|
||||
|
||||
// Doctor the *.lib file field which has a "~" in blank fields. New saves will
|
||||
@@ -674,11 +670,11 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
|
||||
// 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 ) );
|
||||
field->SetName( GetCanonicalFieldName( field->GetId() ) );
|
||||
|
||||
// Ensure the VALUE field = the symbol name (can be not the case
|
||||
// with malformed libraries: edited by hand, or converted from other tools)
|
||||
if( id == VALUE_FIELD )
|
||||
if( id == FIELD_T::VALUE )
|
||||
field->SetText( aSymbol->GetName() );
|
||||
}
|
||||
else
|
||||
@@ -693,7 +689,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
|
||||
int suffix = 0;
|
||||
|
||||
//Deduplicate field name
|
||||
while( aSymbol->FindField( candidateFieldName ) != nullptr )
|
||||
while( aSymbol->GetField( candidateFieldName ) != nullptr )
|
||||
candidateFieldName = wxString::Format( "%s_%d", fieldName, ++suffix );
|
||||
|
||||
field->SetName( candidateFieldName );
|
||||
@@ -1007,7 +1003,7 @@ SCH_ITEM* SCH_IO_KICAD_LEGACY_LIB_CACHE::loadText( LINE_READER& aReader,
|
||||
|
||||
if( !visible )
|
||||
{
|
||||
SCH_FIELD* field = new SCH_FIELD( center, -1, nullptr );
|
||||
SCH_FIELD* field = new SCH_FIELD( center, FIELD_T::USER, nullptr );
|
||||
sch_item = field;
|
||||
eda_text = field;
|
||||
}
|
||||
@@ -1540,37 +1536,14 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA
|
||||
aFormatter.Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
|
||||
}
|
||||
|
||||
std::vector<SCH_FIELD*> fields;
|
||||
aSymbol->GetFields( fields );
|
||||
std::vector<SCH_FIELD*> orderedFields;
|
||||
aSymbol->GetFields( orderedFields );
|
||||
|
||||
// Mandatory fields:
|
||||
// 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( SCH_FIELD* field : fields )
|
||||
{
|
||||
if( field->IsMandatory() )
|
||||
saveField( field, aFormatter );
|
||||
}
|
||||
// NB: FieldIDs in legacy libraries must be consecutive, and include user fields
|
||||
int legacy_field_id = 0;
|
||||
|
||||
// User defined fields:
|
||||
// may have their own save policy so there is a separate loop for them.
|
||||
int fieldId = MANDATORY_FIELD_COUNT; // really wish this would go away.
|
||||
|
||||
for( SCH_FIELD* field : fields )
|
||||
{
|
||||
if( field->IsMandatory() )
|
||||
continue;
|
||||
|
||||
// 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
|
||||
// fieldnames.
|
||||
if( !field->GetText().IsEmpty() )
|
||||
{
|
||||
field->SetId( fieldId++ );
|
||||
saveField( field, aFormatter );
|
||||
}
|
||||
}
|
||||
for( SCH_FIELD* field : orderedFields )
|
||||
saveField( field, legacy_field_id++, aFormatter );
|
||||
|
||||
// Save the alias list: a line starting by "ALIAS".
|
||||
if( !aliasNames.IsEmpty() )
|
||||
@@ -1710,13 +1683,12 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMAT
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField,
|
||||
void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField, int aLegacyFieldIdx,
|
||||
OUTPUTFORMATTER& aFormatter )
|
||||
{
|
||||
wxCHECK_RET( aField && aField->Type() == SCH_FIELD_T, "Invalid SCH_FIELD object." );
|
||||
|
||||
int hjustify, vjustify;
|
||||
int id = aField->GetId();
|
||||
wxString text = aField->GetText();
|
||||
|
||||
hjustify = 'C';
|
||||
@@ -1734,7 +1706,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField,
|
||||
vjustify = 'T';
|
||||
|
||||
aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c",
|
||||
id,
|
||||
aLegacyFieldIdx,
|
||||
EscapedUTF8( text ).c_str(), // wraps in quotes
|
||||
schIUScale.IUToMils( aField->GetTextPos().x ),
|
||||
schIUScale.IUToMils( -aField->GetTextPos().y ),
|
||||
@@ -1749,7 +1721,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField( const SCH_FIELD* aField,
|
||||
// default names as they weren't yet canonical.
|
||||
if( !aField->IsMandatory()
|
||||
&& !aField->GetName().IsEmpty()
|
||||
&& aField->GetName() != GetUserFieldName( id, !DO_TRANSLATE ) )
|
||||
&& aField->GetName() != GetUserFieldName( aLegacyFieldIdx, !DO_TRANSLATE ) )
|
||||
{
|
||||
aFormatter.Print( 0, " %s", EscapedUTF8( aField->GetName() ).c_str() );
|
||||
}
|
||||
|
||||
@@ -88,7 +88,8 @@ private:
|
||||
static void saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& aFormatter );
|
||||
static void saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter );
|
||||
static void saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter );
|
||||
static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter );
|
||||
static void saveField( const SCH_FIELD* aField, int aLegacyFieldIdx,
|
||||
OUTPUTFORMATTER& aFormatter );
|
||||
static void savePin( const SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter );
|
||||
static void savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter );
|
||||
static void saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter );
|
||||
|
||||
@@ -80,20 +80,20 @@ SCH_IO_KICAD_SEXPR::~SCH_IO_KICAD_SEXPR()
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_KICAD_SEXPR::init( SCHEMATIC* aSchematic, const std::map<std::string, UTF8>* aProperties )
|
||||
void SCH_IO_KICAD_SEXPR::init( SCHEMATIC* aSchematic,
|
||||
const std::map<std::string, UTF8>* aProperties )
|
||||
{
|
||||
m_version = 0;
|
||||
m_appending = false;
|
||||
m_rootSheet = nullptr;
|
||||
m_schematic = aSchematic;
|
||||
m_cache = nullptr;
|
||||
m_out = nullptr;
|
||||
m_nextFreeFieldId = 100; // number arbitrarily > MANDATORY_FIELD_COUNT or SHEET_MANDATORY_FIELD_COUNT
|
||||
m_version = 0;
|
||||
m_appending = false;
|
||||
m_rootSheet = nullptr;
|
||||
m_schematic = aSchematic;
|
||||
m_cache = nullptr;
|
||||
m_out = nullptr;
|
||||
}
|
||||
|
||||
|
||||
SCH_SHEET* SCH_IO_KICAD_SEXPR::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
|
||||
SCH_SHEET* aAppendToMe,
|
||||
SCH_SHEET* aAppendToMe,
|
||||
const std::map<std::string, UTF8>* aProperties )
|
||||
{
|
||||
wxASSERT( !aFileName || aSchematic != nullptr );
|
||||
@@ -739,54 +739,45 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aSymbol->m_Uuid );
|
||||
|
||||
m_nextFreeFieldId = MANDATORY_FIELD_COUNT;
|
||||
std::vector<SCH_FIELD*> orderedFields;
|
||||
aSymbol->GetFields( orderedFields, false );
|
||||
|
||||
for( SCH_FIELD& field : aSymbol->GetFields() )
|
||||
for( SCH_FIELD* field : orderedFields )
|
||||
{
|
||||
int id = field.GetId();
|
||||
wxString value = field.GetText();
|
||||
FIELD_T id = field->GetId();
|
||||
wxString value = field->GetText();
|
||||
|
||||
if( !aForClipboard && aSymbol->GetInstances().size() )
|
||||
{
|
||||
// The instance fields are always set to the default instance regardless of the
|
||||
// sheet instance to prevent file churn.
|
||||
if( id == REFERENCE_FIELD )
|
||||
{
|
||||
field.SetText( ordinalInstance.m_Reference );
|
||||
}
|
||||
else if( id == VALUE_FIELD )
|
||||
{
|
||||
field.SetText( aSymbol->GetField( VALUE_FIELD )->GetText() );
|
||||
}
|
||||
else if( id == FOOTPRINT_FIELD )
|
||||
{
|
||||
field.SetText( aSymbol->GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
}
|
||||
if( id == FIELD_T::REFERENCE )
|
||||
field->SetText( ordinalInstance.m_Reference );
|
||||
}
|
||||
else if( aForClipboard && aSymbol->GetInstances().size() && aRelativePath
|
||||
&& ( id == REFERENCE_FIELD ) )
|
||||
&& ( id == FIELD_T::REFERENCE ) )
|
||||
{
|
||||
SCH_SYMBOL_INSTANCE instance;
|
||||
|
||||
if( aSymbol->GetInstance( instance, aRelativePath->Path() ) )
|
||||
field.SetText( instance.m_Reference );
|
||||
field->SetText( instance.m_Reference );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
saveField( &field );
|
||||
saveField( field );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// Restore the changed field text on write error.
|
||||
if( id == REFERENCE_FIELD || id == VALUE_FIELD || id == FOOTPRINT_FIELD )
|
||||
field.SetText( value );
|
||||
if( id == FIELD_T::REFERENCE )
|
||||
field->SetText( value );
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
if( id == REFERENCE_FIELD || id == VALUE_FIELD || id == FOOTPRINT_FIELD )
|
||||
field.SetText( value );
|
||||
if( id == FIELD_T::REFERENCE )
|
||||
field->SetText( value );
|
||||
}
|
||||
|
||||
for( const std::unique_ptr<SCH_PIN>& pin : aSymbol->GetRawPins() )
|
||||
@@ -882,24 +873,12 @@ void SCH_IO_KICAD_SEXPR::saveField( SCH_FIELD* aField )
|
||||
{
|
||||
wxCHECK_RET( aField != nullptr && m_out != nullptr, "" );
|
||||
|
||||
wxString fieldName = aField->GetCanonicalName();
|
||||
// For some reason (bug in legacy parser?) the field ID for non-mandatory fields is -1 so
|
||||
// check for this in order to correctly use the field name.
|
||||
wxString fieldName;
|
||||
|
||||
if( aField->GetId() == -1 /* undefined ID */ )
|
||||
{
|
||||
// Replace the default name built by GetCanonicalName() by
|
||||
// the field name if exists
|
||||
if( !aField->GetName().IsEmpty() )
|
||||
fieldName = aField->GetName();
|
||||
|
||||
aField->SetId( m_nextFreeFieldId );
|
||||
m_nextFreeFieldId += 1;
|
||||
}
|
||||
else if( aField->GetId() >= m_nextFreeFieldId )
|
||||
{
|
||||
m_nextFreeFieldId = aField->GetId() + 1;
|
||||
}
|
||||
if( aField->IsMandatory() )
|
||||
fieldName = aField->GetCanonicalName();
|
||||
else
|
||||
fieldName = aField->GetName();
|
||||
|
||||
m_out->Print( "(property %s %s %s (at %s %s %s)",
|
||||
aField->IsPrivate() ? "private" : "",
|
||||
@@ -1005,8 +984,6 @@ void SCH_IO_KICAD_SEXPR::saveSheet( SCH_SHEET* aSheet, const SCH_SHEET_LIST& aSh
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aSheet->m_Uuid );
|
||||
|
||||
m_nextFreeFieldId = SHEET_MANDATORY_FIELD_COUNT;
|
||||
|
||||
for( SCH_FIELD& field : aSheet->GetFields() )
|
||||
saveField( &field );
|
||||
|
||||
@@ -1315,11 +1292,6 @@ void SCH_IO_KICAD_SEXPR::saveText( SCH_TEXT* aText )
|
||||
aText->EDA_TEXT::Format( m_out, 0 );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
|
||||
|
||||
if( label && label->Type() == SCH_GLOBAL_LABEL_T )
|
||||
m_nextFreeFieldId = GLOBALLABEL_MANDATORY_FIELD_COUNT;
|
||||
else
|
||||
m_nextFreeFieldId = 0;
|
||||
|
||||
if( label )
|
||||
{
|
||||
for( SCH_FIELD& field : label->GetFields() )
|
||||
|
||||
@@ -166,7 +166,6 @@ private:
|
||||
|
||||
protected:
|
||||
int m_version; ///< Version of file being loaded.
|
||||
int m_nextFreeFieldId;
|
||||
bool m_appending; ///< Schematic load append status.
|
||||
wxString m_error; ///< For throwing exceptions or errors on partial
|
||||
///< loads.
|
||||
|
||||
@@ -149,8 +149,7 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
|
||||
else
|
||||
aSymbol->GetEmbeddedFiles()->ClearEmbeddedFonts();
|
||||
|
||||
int nextFreeFieldId = MANDATORY_FIELD_COUNT;
|
||||
std::vector<SCH_FIELD*> fields;
|
||||
std::vector<SCH_FIELD*> orderedFields;
|
||||
std::string name = aFormatter.Quotew( aSymbol->GetLibId().GetLibItemName().wx_str() );
|
||||
std::string unitName = aSymbol->GetLibId().GetLibItemName();
|
||||
|
||||
@@ -205,24 +204,21 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
|
||||
|
||||
// TODO: add required token here."
|
||||
|
||||
aSymbol->GetFields( fields );
|
||||
aSymbol->GetFields( orderedFields );
|
||||
|
||||
for( SCH_FIELD* field : fields )
|
||||
for( SCH_FIELD* field : orderedFields )
|
||||
saveField( field, aFormatter );
|
||||
|
||||
nextFreeFieldId = aSymbol->GetNextAvailableFieldId();
|
||||
|
||||
// @todo At some point in the future the lock status (all units interchangeable) should
|
||||
// be set deterministically. For now a custom lock property is used to preserve the
|
||||
// locked flag state.
|
||||
if( aSymbol->UnitsLocked() )
|
||||
{
|
||||
SCH_FIELD locked( nullptr, nextFreeFieldId, "ki_locked" );
|
||||
SCH_FIELD locked( nullptr, FIELD_T::USER, "ki_locked" );
|
||||
saveField( &locked, aFormatter );
|
||||
nextFreeFieldId += 1;
|
||||
}
|
||||
|
||||
saveDcmInfoAsFields( aSymbol, aFormatter, nextFreeFieldId );
|
||||
saveDcmInfoAsFields( aSymbol, aFormatter );
|
||||
|
||||
// Save the draw items grouped by units.
|
||||
std::vector<LIB_SYMBOL_UNIT> units = aSymbol->GetUnitDrawItems();
|
||||
@@ -286,14 +282,12 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
|
||||
name.c_str(),
|
||||
aFormatter.Quotew( parent->GetName() ).c_str() );
|
||||
|
||||
aSymbol->GetFields( fields );
|
||||
aSymbol->GetFields( orderedFields );
|
||||
|
||||
for( SCH_FIELD* field : fields )
|
||||
for( SCH_FIELD* field : orderedFields )
|
||||
saveField( field, aFormatter );
|
||||
|
||||
nextFreeFieldId = aSymbol->GetNextAvailableFieldId();
|
||||
|
||||
saveDcmInfoAsFields( aSymbol, aFormatter, nextFreeFieldId );
|
||||
saveDcmInfoAsFields( aSymbol, aFormatter );
|
||||
}
|
||||
|
||||
aFormatter.Print( ")" );
|
||||
@@ -301,18 +295,16 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
|
||||
|
||||
|
||||
void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol,
|
||||
OUTPUTFORMATTER& aFormatter,
|
||||
int& aNextFreeFieldId )
|
||||
OUTPUTFORMATTER& aFormatter )
|
||||
{
|
||||
wxCHECK_RET( aSymbol, "Invalid LIB_SYMBOL pointer." );
|
||||
|
||||
if( !aSymbol->GetKeyWords().IsEmpty() )
|
||||
{
|
||||
SCH_FIELD keywords( nullptr, aNextFreeFieldId, wxString( "ki_keywords" ) );
|
||||
SCH_FIELD keywords( nullptr, FIELD_T::USER, wxString( "ki_keywords" ) );
|
||||
keywords.SetVisible( false );
|
||||
keywords.SetText( aSymbol->GetKeyWords() );
|
||||
saveField( &keywords, aFormatter );
|
||||
aNextFreeFieldId += 1;
|
||||
}
|
||||
|
||||
wxArrayString fpFilters = aSymbol->GetFPFilters();
|
||||
@@ -332,11 +324,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::saveDcmInfoAsFields( LIB_SYMBOL* aSymbol,
|
||||
tmp += " " + curr_filter;
|
||||
}
|
||||
|
||||
SCH_FIELD description( nullptr, aNextFreeFieldId, wxString( "ki_fp_filters" ) );
|
||||
SCH_FIELD description( nullptr, FIELD_T::USER, wxString( "ki_fp_filters" ) );
|
||||
description.SetVisible( false );
|
||||
description.SetText( tmp );
|
||||
saveField( &description, aFormatter );
|
||||
aNextFreeFieldId += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ private:
|
||||
static void saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter );
|
||||
static void saveTextBox( SCH_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter );
|
||||
|
||||
static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,
|
||||
int& aNextFreeFieldId );
|
||||
static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter );
|
||||
};
|
||||
|
||||
#endif // SCH_IO_KICAD_SEXPR_LIB_CACHE_H_
|
||||
|
||||
@@ -309,14 +309,6 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi
|
||||
|
||||
symbol->SetUnitCount( 1 );
|
||||
|
||||
m_fieldIDsRead.clear();
|
||||
|
||||
// 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 fieldId : MANDATORY_FIELDS )
|
||||
m_fieldIDsRead.insert( fieldId );
|
||||
|
||||
token = NextTok();
|
||||
|
||||
if( !IsSymbol( token ) )
|
||||
@@ -955,19 +947,17 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a property." ) );
|
||||
wxCHECK( aSymbol, nullptr );
|
||||
|
||||
FIELD_T fieldId = FIELD_T::USER;
|
||||
wxString name;
|
||||
wxString value;
|
||||
auto field = std::make_unique<SCH_FIELD>( aSymbol.get(), aSymbol->GetNextAvailableFieldId() );
|
||||
|
||||
// By default, fieds are visible.
|
||||
// Invisible fields have the hide style or keyword specified in file
|
||||
field->SetVisible( true );
|
||||
bool isPrivate = false;
|
||||
bool isVisible = true;
|
||||
|
||||
T token = NextTok();
|
||||
|
||||
if( token == T_private )
|
||||
{
|
||||
field->SetPrivate( true );
|
||||
isPrivate = true;
|
||||
token = NextTok();
|
||||
}
|
||||
|
||||
@@ -985,19 +975,20 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
CurOffset() );
|
||||
}
|
||||
|
||||
field->SetName( name );
|
||||
|
||||
// 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 fieldId : MANDATORY_FIELDS )
|
||||
for( FIELD_T id : MANDATORY_FIELDS )
|
||||
{
|
||||
if( name.CmpNoCase( GetCanonicalFieldName( fieldId ) ) == 0 )
|
||||
if( name.CmpNoCase( GetCanonicalFieldName( id ) ) == 0 )
|
||||
{
|
||||
field->SetId( fieldId );
|
||||
fieldId = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto field = std::make_unique<SCH_FIELD>( aSymbol.get(), fieldId, name );
|
||||
field->SetPrivate( isPrivate );
|
||||
field->SetVisible( isVisible );
|
||||
|
||||
token = NextTok();
|
||||
|
||||
if( !IsSymbol( token ) )
|
||||
@@ -1020,17 +1011,9 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
|
||||
switch( token )
|
||||
{
|
||||
// I am not sure we should even support parsing these IDs any more
|
||||
case T_id:
|
||||
{
|
||||
int id = parseInt( "field ID" );
|
||||
|
||||
// Only set an ID that isn't a MANDATORY_FIELD ID
|
||||
if( id >= MANDATORY_FIELD_COUNT )
|
||||
field->SetId( id );
|
||||
|
||||
case T_id: // legacy token; ignore
|
||||
parseInt( "field ID" );
|
||||
NeedRIGHT();
|
||||
}
|
||||
break;
|
||||
|
||||
case T_at:
|
||||
@@ -1045,7 +1028,8 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
break;
|
||||
|
||||
case T_effects:
|
||||
parseEDA_TEXT( static_cast<EDA_TEXT*>( field.get() ), field->GetId() == VALUE_FIELD );
|
||||
parseEDA_TEXT( static_cast<EDA_TEXT*>( field.get() ),
|
||||
field->GetId() == FIELD_T::VALUE );
|
||||
break;
|
||||
|
||||
case T_show_name:
|
||||
@@ -1067,26 +1051,13 @@ 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() >= MANDATORY_FIELD_COUNT ) && m_fieldIDsRead.count( field->GetId() ) )
|
||||
{
|
||||
int nextAvailableId = field->GetId() + 1;
|
||||
|
||||
while( m_fieldIDsRead.count( nextAvailableId ) )
|
||||
nextAvailableId += 1;
|
||||
|
||||
field->SetId( nextAvailableId );
|
||||
}
|
||||
|
||||
SCH_FIELD* existingField;
|
||||
|
||||
if( field->IsMandatory() )
|
||||
{
|
||||
existingField = aSymbol->GetFieldById( field->GetId() );
|
||||
existingField = aSymbol->GetField( field->GetId() );
|
||||
|
||||
*existingField = *field;
|
||||
m_fieldIDsRead.insert( field->GetId() );
|
||||
return existingField;
|
||||
}
|
||||
else if( name == "ki_keywords" )
|
||||
@@ -1126,7 +1097,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
else
|
||||
{
|
||||
// At this point, a user field is read.
|
||||
existingField = aSymbol->FindField( field->GetCanonicalName() );
|
||||
existingField = aSymbol->GetField( field->GetCanonicalName() );
|
||||
|
||||
#if 1 // Enable it to modify the name of the field to add if already existing
|
||||
// Disable it to skip the field having the same name as previous field
|
||||
@@ -1142,7 +1113,7 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
wxString newname = base_name;
|
||||
newname << '_' << ii;
|
||||
|
||||
existingField = aSymbol->FindField( newname );
|
||||
existingField = aSymbol->GetField( newname );
|
||||
|
||||
if( !existingField ) // the modified name is not found, use it
|
||||
field->SetName( newname );
|
||||
@@ -1152,7 +1123,6 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>
|
||||
if( !existingField )
|
||||
{
|
||||
aSymbol->AddDrawItem( field.get(), false );
|
||||
m_fieldIDsRead.insert( field->GetId() );
|
||||
return field.release();
|
||||
}
|
||||
else
|
||||
@@ -1904,7 +1874,7 @@ SCH_ITEM* SCH_IO_KICAD_SEXPR_PARSER::parseSymbolText()
|
||||
|
||||
// Convert hidden symbol text (which is no longer supported) into a hidden field
|
||||
if( !text->IsVisible() )
|
||||
return new SCH_FIELD( text.get(), -1 );
|
||||
return new SCH_FIELD( text.get(), FIELD_T::USER );
|
||||
|
||||
return text.release();
|
||||
}
|
||||
@@ -2229,51 +2199,60 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
||||
// Empty property values are valid.
|
||||
wxString value = FromUTF8();
|
||||
|
||||
int nextFieldId = 0;
|
||||
|
||||
if( aParent->Type() == SCH_SYMBOL_T )
|
||||
nextFieldId = MANDATORY_FIELD_COUNT;
|
||||
else if( aParent->Type() == SCH_SHEET_T )
|
||||
nextFieldId = SHEET_MANDATORY_FIELD_COUNT;
|
||||
|
||||
std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( VECTOR2I( -1, -1 ), nextFieldId,
|
||||
aParent, name );
|
||||
field->SetText( value );
|
||||
field->SetVisible( true );
|
||||
field->SetPrivate( is_private );
|
||||
FIELD_T fieldId = FIELD_T::USER;
|
||||
|
||||
// Correctly set the ID based on canonical (untranslated) field name
|
||||
// If ID is stored in the file (old versions), it will overwrite this
|
||||
if( aParent->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
for( FIELD_T id : MANDATORY_FIELDS )
|
||||
{
|
||||
if( name == GetCanonicalFieldName( fieldId ) )
|
||||
if( name.CmpNoCase( GetCanonicalFieldName( id ) ) == 0 )
|
||||
{
|
||||
field->SetId( fieldId );
|
||||
field->SetPrivate( false );
|
||||
fieldId = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( aParent->Type() == SCH_SHEET_T )
|
||||
{
|
||||
for( int fieldId : SHEET_MANDATORY_FIELDS )
|
||||
for( FIELD_T id : SHEET_MANDATORY_FIELDS )
|
||||
{
|
||||
if( name == SCH_SHEET::GetDefaultFieldName( fieldId, !DO_TRANSLATE ) )
|
||||
if( name.CmpNoCase( GetCanonicalFieldName( id ) ) == 0 )
|
||||
{
|
||||
field->SetId( fieldId );
|
||||
field->SetPrivate( false );
|
||||
fieldId = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy support for old field names
|
||||
if( name.CmpNoCase( wxT( "Sheet name" ) ) == 0 )
|
||||
field->SetId( SHEETNAME );
|
||||
fieldId = FIELD_T::SHEET_NAME;
|
||||
else if( name.CmpNoCase( wxT( "Sheet file" ) ) == 0 )
|
||||
field->SetId( SHEETFILENAME );
|
||||
fieldId = FIELD_T::SHEET_FILENAME;
|
||||
}
|
||||
else if( aParent->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
for( FIELD_T id : GLOBALLABEL_MANDATORY_FIELDS )
|
||||
{
|
||||
if( name.CmpNoCase( GetCanonicalFieldName( id ) ) == 0 )
|
||||
{
|
||||
fieldId = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy support for old field names
|
||||
if( name.CmpNoCase( wxT( "Intersheet References" ) ) == 0 )
|
||||
fieldId = FIELD_T::INTERSHEET_REFS;
|
||||
}
|
||||
|
||||
std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( VECTOR2I( -1, -1 ), fieldId,
|
||||
aParent, name );
|
||||
field->SetText( value );
|
||||
field->SetVisible( true );
|
||||
|
||||
if( fieldId == FIELD_T::USER )
|
||||
field->SetPrivate( is_private );
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
{
|
||||
@@ -2284,17 +2263,9 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
||||
|
||||
switch( token )
|
||||
{
|
||||
// I am not sure we should even support parsing these IDs any more
|
||||
case T_id:
|
||||
{
|
||||
int id = parseInt( "field ID" );
|
||||
|
||||
// Only set an ID that isn't a mandatory field ID
|
||||
if( id >= nextFieldId )
|
||||
field->SetId( id );
|
||||
|
||||
case T_id: // legacy token; ignore
|
||||
parseInt( "field ID" );
|
||||
NeedRIGHT();
|
||||
}
|
||||
break;
|
||||
|
||||
case T_at:
|
||||
@@ -2309,7 +2280,8 @@ SCH_FIELD* SCH_IO_KICAD_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
|
||||
break;
|
||||
|
||||
case T_effects:
|
||||
parseEDA_TEXT( static_cast<EDA_TEXT*>( field.get() ), field->GetId() == VALUE_FIELD );
|
||||
parseEDA_TEXT( static_cast<EDA_TEXT*>( field.get() ),
|
||||
field->GetId() == FIELD_T::VALUE );
|
||||
break;
|
||||
|
||||
case T_show_name:
|
||||
@@ -2755,7 +2727,6 @@ void SCH_IO_KICAD_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopya
|
||||
{
|
||||
case T_symbol:
|
||||
symbol = parseLibSymbol( symbolLibMap );
|
||||
symbol->UpdateFieldOrdinals();
|
||||
screen->AddLibSymbol( symbol );
|
||||
break;
|
||||
|
||||
@@ -2983,14 +2954,6 @@ SCH_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol()
|
||||
// We'll reset this if we find a fields_autoplaced token
|
||||
symbol->SetFieldsAutoplaced( AUTOPLACE_NONE );
|
||||
|
||||
m_fieldIDsRead.clear();
|
||||
|
||||
// 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 fieldId : MANDATORY_FIELDS )
|
||||
m_fieldIDsRead.insert( fieldId );
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
{
|
||||
if( token != T_LEFT )
|
||||
@@ -3272,26 +3235,21 @@ SCH_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol()
|
||||
break;
|
||||
}
|
||||
|
||||
if( ( field->GetId() >= MANDATORY_FIELD_COUNT ) && m_fieldIDsRead.count( field->GetId() ) )
|
||||
{
|
||||
int nextAvailableId = field->GetId() + 1;
|
||||
SCH_FIELD* existing;
|
||||
|
||||
while( m_fieldIDsRead.count( nextAvailableId ) )
|
||||
nextAvailableId += 1;
|
||||
if( field->IsMandatory() )
|
||||
existing = symbol->GetField( field->GetId() );
|
||||
else
|
||||
existing = symbol->GetField( field->GetName() );
|
||||
|
||||
field->SetId( nextAvailableId );
|
||||
}
|
||||
|
||||
if( symbol->GetFieldById( field->GetId() ) )
|
||||
*symbol->GetFieldById( field->GetId() ) = *field;
|
||||
if( existing )
|
||||
*existing = *field;
|
||||
else
|
||||
symbol->AddField( *field );
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD )
|
||||
if( field->GetId() == FIELD_T::REFERENCE )
|
||||
symbol->UpdatePrefix();
|
||||
|
||||
m_fieldIDsRead.insert( field->GetId() );
|
||||
|
||||
delete field;
|
||||
break;
|
||||
|
||||
@@ -3531,25 +3489,11 @@ SCH_SHEET* SCH_IO_KICAD_SEXPR_PARSER::parseSheet()
|
||||
// Fortunately they only saved the sheetname and sheetfilepath (and always
|
||||
// in that order), so we can hack in a recovery.
|
||||
if( fields.empty() )
|
||||
field->SetId( SHEETNAME );
|
||||
field->setId( FIELD_T::SHEET_NAME );
|
||||
else
|
||||
field->SetId( SHEETFILENAME );
|
||||
field->setId( FIELD_T::SHEET_FILENAME );
|
||||
}
|
||||
|
||||
// It would appear the problem persists past 20200310, but this time with the
|
||||
// earlier ids being re-used for later (user) fields. The easiest (and most
|
||||
// complete) solution is to disallow multiple instances of the same id (for all
|
||||
// files since the source of the error *might* in fact be hand-edited files).
|
||||
//
|
||||
// While no longer used, -1 is still a valid id for user field. We convert it to
|
||||
// the first available ID after the mandatory fields
|
||||
|
||||
if( field->GetId() < 0 )
|
||||
field->SetId( SHEET_MANDATORY_FIELD_COUNT );
|
||||
|
||||
while( !fieldIDsRead.insert( field->GetId() ).second )
|
||||
field->SetId( field->GetId() + 1 );
|
||||
|
||||
fields.emplace_back( *field );
|
||||
|
||||
delete field;
|
||||
@@ -4364,7 +4308,7 @@ SCH_TEXT* SCH_IO_KICAD_SEXPR_PARSER::parseSchText()
|
||||
if( text->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( text.get() );
|
||||
SCH_FIELD* field = &label->GetFields()[0];
|
||||
SCH_FIELD* field = label->GetField( FIELD_T::INTERSHEET_REFS );
|
||||
|
||||
field->SetTextPos( parseXY() );
|
||||
NeedRIGHT();
|
||||
@@ -4386,18 +4330,11 @@ SCH_TEXT* SCH_IO_KICAD_SEXPR_PARSER::parseSchText()
|
||||
|
||||
SCH_FIELD* field = parseSchField( text.get() );
|
||||
|
||||
// If the field is a Intersheetrefs it is not handled like other fields:
|
||||
// It always exists and is the first in list
|
||||
if( text->Type() == SCH_GLOBAL_LABEL_T
|
||||
&& ( field->GetInternalName() == wxT( "Intersheet References" ) // old name in V6.0
|
||||
|| field->GetInternalName() == wxT( "Intersheetrefs" ) ) ) // Current name
|
||||
// Intersheetrefs is a mandatory field and so will already exist
|
||||
if( text->Type() == SCH_GLOBAL_LABEL_T && field->IsMandatory() )
|
||||
{
|
||||
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( text.get() );
|
||||
// Ensure the Id of this special and first field is 0, needed by
|
||||
// SCH_FIELD::IsHypertext() test
|
||||
field->SetId( 0 );
|
||||
|
||||
label->GetFields()[0] = *field;
|
||||
*label->GetField( field->GetId() ) = *field;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -240,9 +240,6 @@ private:
|
||||
wxString m_symbolName; ///< The current symbol name.
|
||||
bool m_appending; ///< Appending load status.
|
||||
|
||||
/// Field IDs that have been read so far for the current symbol.
|
||||
std::set<int> m_fieldIDsRead;
|
||||
|
||||
std::set<KIID> m_uuids;
|
||||
|
||||
PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr
|
||||
|
||||
@@ -152,14 +152,14 @@ void LTSPICE_SCHEMATIC::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet,
|
||||
curSheet->SetPosition( parser.ToKicadCoords( ascFiles[i].Offset ) + bbox.GetOrigin() );
|
||||
curSheet->SetParent( ascFiles[ascFiles[i].ParentIndex].Sheet );
|
||||
|
||||
SCH_FIELD& sheetNameField = curSheet->GetFields()[SHEETNAME];
|
||||
SCH_FIELD& fileNameSheet = curSheet->GetFields()[SHEETFILENAME];
|
||||
SCH_FIELD* sheetNameField = curSheet->GetField( FIELD_T::SHEET_NAME );
|
||||
SCH_FIELD* fileNameSheet = curSheet->GetField( FIELD_T::SHEET_FILENAME );
|
||||
wxString sheetName = wxString::Format( wxS( "%s-subsheet-%d" ),
|
||||
ascFiles[i].ElementName,
|
||||
i );
|
||||
|
||||
sheetNameField.SetText( sheetName );
|
||||
fileNameSheet.SetText( sheetName + ".kicad_sch" );
|
||||
sheetNameField->SetText( sheetName );
|
||||
fileNameSheet->SetText( sheetName + ".kicad_sch" );
|
||||
|
||||
curSheet->SetScreen( ascFiles[i].Screen );
|
||||
|
||||
|
||||
@@ -839,10 +839,10 @@ SCH_SYMBOL* SCH_IO_LTSPICE_PARSER::CreatePowerSymbol( const VECTOR2I& aOffset,
|
||||
SCH_SYMBOL* sch_symbol = new SCH_SYMBOL( *lib_symbol, libId, aSheet, 1 );
|
||||
|
||||
sch_symbol->SetRef( aSheet, wxString::Format( wxS( "#GND%03d" ), m_powerSymbolIndex++ ) );
|
||||
sch_symbol->GetField( REFERENCE_FIELD )->SetVisible( false );
|
||||
sch_symbol->GetField( FIELD_T::REFERENCE )->SetVisible( false );
|
||||
sch_symbol->SetValueFieldText( wxS( "0" ) );
|
||||
sch_symbol->GetField( VALUE_FIELD )->SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
sch_symbol->GetField( VALUE_FIELD )->SetVisible( false );
|
||||
sch_symbol->GetField( FIELD_T::VALUE )->SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
sch_symbol->GetField( FIELD_T::VALUE )->SetVisible( false );
|
||||
|
||||
sch_symbol->Move( ToKicadCoords( aOffset ) + m_originOffset );
|
||||
|
||||
@@ -909,7 +909,7 @@ SCH_LABEL_BASE* SCH_IO_LTSPICE_PARSER::CreateSCH_LABEL( KICAD_T aType, const VEC
|
||||
|
||||
label->SetSpinStyle( SPIN_STYLE::RIGHT );
|
||||
|
||||
SCH_FIELD field( { 0, 0 }, -1, label, wxS( "DATAFLAG" ) );
|
||||
SCH_FIELD field( { 0, 0 }, FIELD_T::USER, label, wxS( "DATAFLAG" ) );
|
||||
field.SetText( aValue );
|
||||
field.SetTextSize( ToKicadFontSize( aFontSize ) );
|
||||
field.SetVisible( true );
|
||||
@@ -954,18 +954,18 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
|
||||
if( !value2.IsEmpty() )
|
||||
{
|
||||
SCH_FIELD paramsField( { 0, 0 }, -1, aSymbol, wxS( "Value2" ) );
|
||||
SCH_FIELD paramsField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Value2" ) );
|
||||
paramsField.SetText( value2 );
|
||||
aSymbol->AddField( paramsField );
|
||||
}
|
||||
|
||||
auto setupNonInferredPassive = [&]( const wxString& aDevice, const wxString& aValueKey )
|
||||
{
|
||||
SCH_FIELD deviceField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Device" ) );
|
||||
SCH_FIELD deviceField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Device" ) );
|
||||
deviceField.SetText( aDevice );
|
||||
aSymbol->AddField( deviceField );
|
||||
|
||||
SCH_FIELD paramsField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Params" ) );
|
||||
SCH_FIELD paramsField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Params" ) );
|
||||
paramsField.SetText( aValueKey + wxS( "=${VALUE}" ) );
|
||||
aSymbol->AddField( paramsField );
|
||||
};
|
||||
@@ -974,15 +974,15 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
{
|
||||
aSymbol->SetValueFieldText( wxS( "${Sim.Params}" ) );
|
||||
|
||||
SCH_FIELD deviceField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Device" ) );
|
||||
SCH_FIELD deviceField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Device" ) );
|
||||
deviceField.SetText( aDevice );
|
||||
aSymbol->AddField( deviceField );
|
||||
|
||||
SCH_FIELD typeField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Type" ) );
|
||||
SCH_FIELD typeField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Type" ) );
|
||||
typeField.SetText( aType );
|
||||
aSymbol->AddField( typeField );
|
||||
|
||||
SCH_FIELD paramsField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Params" ) );
|
||||
SCH_FIELD paramsField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Params" ) );
|
||||
paramsField.SetText( value );
|
||||
aSymbol->AddField( paramsField );
|
||||
};
|
||||
@@ -1019,7 +1019,7 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
}
|
||||
else if( prefix == wxS( "V" ) || symbolName == wxS( "I" ) )
|
||||
{
|
||||
SCH_FIELD deviceField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Device" ) );
|
||||
SCH_FIELD deviceField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Device" ) );
|
||||
deviceField.SetText( wxS( "SPICE" ) );
|
||||
aSymbol->AddField( deviceField );
|
||||
|
||||
@@ -1031,7 +1031,7 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
else
|
||||
simParams << "model=" << '"' << "${VALUE} ${VALUE2}" << '"' << ' ';
|
||||
|
||||
SCH_FIELD paramsField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Params" ) );
|
||||
SCH_FIELD paramsField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Params" ) );
|
||||
paramsField.SetText( simParams );
|
||||
aSymbol->AddField( paramsField );
|
||||
}
|
||||
@@ -1064,20 +1064,20 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
|
||||
if( !libFile.IsEmpty() )
|
||||
{
|
||||
SCH_FIELD libField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Library" ) );
|
||||
SCH_FIELD libField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Library" ) );
|
||||
libField.SetText( libFile );
|
||||
aSymbol->AddField( libField );
|
||||
}
|
||||
|
||||
if( type == wxS( "X" ) )
|
||||
{
|
||||
SCH_FIELD deviceField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Device" ) );
|
||||
SCH_FIELD deviceField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Device" ) );
|
||||
deviceField.SetText( wxS( "SUBCKT" ) );
|
||||
aSymbol->AddField( deviceField );
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_FIELD deviceField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Device" ) );
|
||||
SCH_FIELD deviceField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Device" ) );
|
||||
deviceField.SetText( wxS( "SPICE" ) );
|
||||
aSymbol->AddField( deviceField );
|
||||
}
|
||||
@@ -1087,13 +1087,13 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
if( !spiceLine.IsEmpty() )
|
||||
{
|
||||
// TODO: append value
|
||||
SCH_FIELD paramsField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Params" ) );
|
||||
SCH_FIELD paramsField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Params" ) );
|
||||
paramsField.SetText( spiceLine );
|
||||
aSymbol->AddField( paramsField );
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_FIELD modelField( { 0, 0 }, -1, aSymbol, wxS( "Sim.Params" ) );
|
||||
SCH_FIELD modelField( { 0, 0 }, FIELD_T::USER, aSymbol, wxS( "Sim.Params" ) );
|
||||
modelField.SetText( "model=\"" + value + "\"" );
|
||||
aSymbol->AddField( modelField );
|
||||
}
|
||||
@@ -1106,10 +1106,10 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
switch( lt_window.WindowNumber )
|
||||
{
|
||||
case -1: /* PartNum */ break;
|
||||
case 0: /* InstName */ field = aSymbol->GetField( REFERENCE_FIELD ); break;
|
||||
case 0: /* InstName */ field = aSymbol->GetField( FIELD_T::REFERENCE ); break;
|
||||
case 1: /* Type */ break;
|
||||
case 2: /* RefName */ break;
|
||||
case 3: /* Value */ field = aSymbol->GetField( VALUE_FIELD ); break;
|
||||
case 3: /* Value */ field = aSymbol->GetField( FIELD_T::VALUE ); break;
|
||||
|
||||
case 5: /* QArea */ break;
|
||||
|
||||
@@ -1119,8 +1119,8 @@ void SCH_IO_LTSPICE_PARSER::CreateFields( LTSPICE_SCHEMATIC::LT_SYMBOL& aLTSymbo
|
||||
|
||||
case 16: /* Nec */ break;
|
||||
|
||||
case 38: /* SpiceModel */ field = aSymbol->FindField( wxS( "Sim.Name" ) ); break;
|
||||
case 39: /* SpiceLine */ field = aSymbol->FindField( wxS( "Sim.Params" ) ); break;
|
||||
case 38: /* SpiceModel */ field = aSymbol->GetField( wxS( "Sim.Name" ) ); break;
|
||||
case 39: /* SpiceLine */ field = aSymbol->GetField( wxS( "Sim.Params" ) ); break;
|
||||
case 40: /* SpiceLine2 */ break;
|
||||
|
||||
/*
|
||||
|
||||
@@ -129,7 +129,7 @@ LIB_SYMBOL* SCH_IO_LIB_CACHE::removeSymbol( LIB_SYMBOL* aSymbol )
|
||||
{
|
||||
SCH_FIELD& field = static_cast<SCH_FIELD&>( drawItem );
|
||||
|
||||
if( firstChild->FindField( field.GetCanonicalName() ) )
|
||||
if( firstChild->GetField( field.GetCanonicalName() ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+38
-13
@@ -577,7 +577,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo
|
||||
field.SetTextAngle( ANGLE_HORIZONTAL );
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
|
||||
if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
if( field.GetId() == FIELD_T::INTERSHEET_REFS )
|
||||
offset.x = - ( labelLen + margin );
|
||||
else
|
||||
offset.y = accumulated + field.GetTextHeight() / 2;
|
||||
@@ -588,7 +588,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo
|
||||
field.SetTextAngle( ANGLE_VERTICAL );
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
|
||||
if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
if( field.GetId() == FIELD_T::INTERSHEET_REFS )
|
||||
offset.y = - ( labelLen + margin );
|
||||
else
|
||||
offset.x = accumulated + field.GetTextHeight() / 2;
|
||||
@@ -599,7 +599,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo
|
||||
field.SetTextAngle( ANGLE_HORIZONTAL );
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
|
||||
if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
if( field.GetId() == FIELD_T::INTERSHEET_REFS )
|
||||
offset.x = labelLen + margin;
|
||||
else
|
||||
offset.y = accumulated + field.GetTextHeight() / 2;
|
||||
@@ -610,7 +610,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo
|
||||
field.SetTextAngle( ANGLE_VERTICAL );
|
||||
field.SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
|
||||
if( field.GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
if( field.GetId() == FIELD_T::INTERSHEET_REFS )
|
||||
offset.y = labelLen + margin;
|
||||
else
|
||||
offset.x = accumulated + field.GetTextHeight() / 2;
|
||||
@@ -620,7 +620,7 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo
|
||||
|
||||
field.SetTextPos( GetTextPos() + offset );
|
||||
|
||||
if( field.GetCanonicalName() != wxT( "Intersheetrefs" ) )
|
||||
if( field.GetId() == FIELD_T::INTERSHEET_REFS )
|
||||
accumulated += field.GetTextHeight() + margin;
|
||||
}
|
||||
|
||||
@@ -904,7 +904,10 @@ std::vector<VECTOR2I> SCH_LABEL_BASE::GetConnectionPoints() const
|
||||
|
||||
std::vector<int> SCH_LABEL_BASE::ViewGetLayers() const
|
||||
{
|
||||
return { LAYER_DANGLING, LAYER_DEVICE, LAYER_NETCLASS_REFS, LAYER_FIELDS,
|
||||
return { LAYER_DANGLING,
|
||||
LAYER_DEVICE,
|
||||
LAYER_NETCLASS_REFS,
|
||||
LAYER_FIELDS,
|
||||
LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
@@ -1757,11 +1760,12 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const VECTOR2I& pos, const wxString& text ) :
|
||||
|
||||
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
|
||||
m_fields.emplace_back( SCH_FIELD( pos, INTERSHEET_REFS, this, wxT( "Sheet References" ) ) );
|
||||
m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) );
|
||||
m_fields[0].SetVisible( false );
|
||||
m_fields[0].SetLayer( LAYER_INTERSHEET_REFS );
|
||||
m_fields[0].SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
m_fields.emplace_back( SCH_FIELD( pos, FIELD_T::INTERSHEET_REFS, this,
|
||||
::GetDefaultFieldName( FIELD_T::INTERSHEET_REFS, false ) ) );
|
||||
m_fields.back().SetText( wxT( "${INTERSHEET_REFS}" ) );
|
||||
m_fields.back().SetVisible( false );
|
||||
m_fields.back().SetLayer( LAYER_INTERSHEET_REFS );
|
||||
m_fields.back().SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
}
|
||||
|
||||
|
||||
@@ -1784,6 +1788,22 @@ bool SCH_GLOBALLABEL::Deserialize( const google::protobuf::Any &aContainer )
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_GLOBALLABEL::GetField( FIELD_T aFieldType )
|
||||
{
|
||||
if( SCH_FIELD* field = FindField( m_fields, aFieldType ) )
|
||||
return field;
|
||||
|
||||
m_fields.emplace_back( this, aFieldType );
|
||||
return &m_fields.back();
|
||||
}
|
||||
|
||||
|
||||
const SCH_FIELD* SCH_GLOBALLABEL::GetField( FIELD_T aFieldType ) const
|
||||
{
|
||||
return FindField( m_fields, aFieldType );
|
||||
}
|
||||
|
||||
|
||||
VECTOR2I SCH_GLOBALLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
||||
{
|
||||
int horiz = GetLabelBoxExpansion( aSettings );
|
||||
@@ -1884,8 +1904,13 @@ bool SCH_GLOBALLABEL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* tok
|
||||
|
||||
std::vector<int> SCH_GLOBALLABEL::ViewGetLayers() const
|
||||
{
|
||||
return { LAYER_DANGLING, LAYER_GLOBLABEL, LAYER_DEVICE, LAYER_INTERSHEET_REFS,
|
||||
LAYER_NETCLASS_REFS, LAYER_FIELDS, LAYER_SELECTION_SHADOWS };
|
||||
return { LAYER_DANGLING,
|
||||
LAYER_GLOBLABEL,
|
||||
LAYER_DEVICE,
|
||||
LAYER_INTERSHEET_REFS,
|
||||
LAYER_NETCLASS_REFS,
|
||||
LAYER_FIELDS,
|
||||
LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-11
@@ -131,17 +131,6 @@ enum FLAG_SHAPE : unsigned int
|
||||
};
|
||||
|
||||
|
||||
enum GLOBALLABEL_FIELD_T
|
||||
{
|
||||
INTERSHEET_REFS = 0,
|
||||
|
||||
/// The first 2 are mandatory, and must be instantiated in #SCH_SHEET.
|
||||
GLOBALLABEL_MANDATORY_FIELD_COUNT
|
||||
};
|
||||
|
||||
#define GLOBALLABEL_MANDATORY_FIELDS { INTERSHEET_REFS }
|
||||
|
||||
|
||||
class SCH_LABEL_BASE : public SCH_TEXT
|
||||
{
|
||||
public:
|
||||
@@ -541,6 +530,13 @@ public:
|
||||
|
||||
int GetMandatoryFieldCount() override { return 1; }
|
||||
|
||||
/**
|
||||
* Return a mandatory field in this label. The const version will return nullptr if the
|
||||
* field doesn't exist; the non-const version will create it.
|
||||
*/
|
||||
SCH_FIELD* GetField( FIELD_T aFieldType );
|
||||
const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
|
||||
|
||||
void SetSpinStyle( SPIN_STYLE aSpinStyle ) override;
|
||||
|
||||
VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
|
||||
|
||||
@@ -1174,7 +1174,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
|
||||
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( symbol->GetRef( currentSheet ),
|
||||
UnescapeString( schsymbol->GetField( VALUE_FIELD )->GetText() ) );
|
||||
UnescapeString( schsymbol->GetField( FIELD_T::VALUE )->GetText() ) );
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
@@ -1402,7 +1402,7 @@ wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull
|
||||
const SCH_SYMBOL* symbol = static_cast<const SCH_SYMBOL*>( GetParentSymbol() );
|
||||
|
||||
return wxString::Format( "Symbol %s %s",
|
||||
UnescapeString( symbol->GetField( REFERENCE_FIELD )->GetText() ),
|
||||
UnescapeString( symbol->GetField( FIELD_T::REFERENCE )->GetText() ),
|
||||
itemDesc );
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ void SCH_PLOTTER::createPDFFile( const SCH_PLOT_OPTS& aPlotOpts,
|
||||
m_schematic->SetSheetNumberAndCount();
|
||||
|
||||
SCH_SCREEN* screen = m_schematic->CurrentSheet().LastScreen();
|
||||
wxString sheetName = sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false );
|
||||
wxString sheetName = sheetList[i].Last()->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
|
||||
|
||||
if( aPlotOpts.m_PDFMetadata )
|
||||
{
|
||||
|
||||
@@ -703,8 +703,8 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter )
|
||||
if( aReporter )
|
||||
{
|
||||
msg.Printf( _( "Setting schematic symbol '%s %s' library identifier to '%s'." ),
|
||||
symbol->GetField( REFERENCE_FIELD )->GetText(),
|
||||
symbol->GetField( VALUE_FIELD )->GetText(),
|
||||
symbol->GetField( FIELD_T::REFERENCE )->GetText(),
|
||||
symbol->GetField( FIELD_T::VALUE )->GetText(),
|
||||
UnescapeString( symbol->GetLibId().Format() ) );
|
||||
aReporter->ReportTail( msg, RPT_SEVERITY_INFO );
|
||||
}
|
||||
@@ -774,8 +774,8 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter )
|
||||
if( aReporter )
|
||||
{
|
||||
msg.Printf( _( "Falling back to cache to set symbol '%s:%s' link '%s'." ),
|
||||
symbol->GetField( REFERENCE_FIELD )->GetText(),
|
||||
symbol->GetField( VALUE_FIELD )->GetText(),
|
||||
symbol->GetField( FIELD_T::REFERENCE )->GetText(),
|
||||
symbol->GetField( FIELD_T::VALUE )->GetText(),
|
||||
UnescapeString( id ) );
|
||||
aReporter->ReportTail( msg, RPT_SEVERITY_WARNING );
|
||||
}
|
||||
@@ -795,8 +795,8 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter )
|
||||
if( aReporter )
|
||||
{
|
||||
msg.Printf( _( "Setting schematic symbol '%s %s' library identifier to '%s'." ),
|
||||
symbol->GetField( REFERENCE_FIELD )->GetText(),
|
||||
symbol->GetField( VALUE_FIELD )->GetText(),
|
||||
symbol->GetField( FIELD_T::REFERENCE )->GetText(),
|
||||
symbol->GetField( FIELD_T::VALUE )->GetText(),
|
||||
UnescapeString( symbol->GetLibId().Format() ) );
|
||||
aReporter->ReportTail( msg, RPT_SEVERITY_INFO );
|
||||
}
|
||||
@@ -806,8 +806,8 @@ void SCH_SCREEN::UpdateSymbolLinks( REPORTER* aReporter )
|
||||
if( aReporter )
|
||||
{
|
||||
msg.Printf( _( "No library symbol found for schematic symbol '%s %s'." ),
|
||||
symbol->GetField( REFERENCE_FIELD )->GetText(),
|
||||
symbol->GetField( VALUE_FIELD )->GetText() );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->GetText(),
|
||||
symbol->GetField( FIELD_T::VALUE )->GetText() );
|
||||
aReporter->ReportTail( msg, RPT_SEVERITY_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,11 @@ struct PICKED_SYMBOL
|
||||
int Unit;
|
||||
int Convert;
|
||||
|
||||
std::vector<std::pair<int, wxString>> Fields;
|
||||
std::vector<std::pair<FIELD_T, wxString>> Fields;
|
||||
|
||||
PICKED_SYMBOL() : Unit( 1 ), Convert( 1 )
|
||||
PICKED_SYMBOL() :
|
||||
Unit( 1 ),
|
||||
Convert( 1 )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
+57
-82
@@ -48,37 +48,6 @@
|
||||
#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 ),
|
||||
@@ -96,12 +65,13 @@ SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const VECTOR2I& aPos, VECTOR2I aSize )
|
||||
m_backgroundColor = COLOR4D::UNSPECIFIED;
|
||||
m_fieldsAutoplaced = AUTOPLACE_AUTO;
|
||||
|
||||
m_fields.emplace_back( aPos, SHEETNAME, this, GetDefaultFieldName( SHEETNAME, DO_TRANSLATE ) );
|
||||
m_fields.emplace_back( aPos, FIELD_T::SHEET_NAME, this,
|
||||
GetDefaultFieldName( FIELD_T::SHEET_NAME, DO_TRANSLATE ) );
|
||||
m_fields.back().SetVisible( true );
|
||||
m_fields.back().SetLayer( LAYER_SHEETNAME );
|
||||
|
||||
m_fields.emplace_back( aPos, SHEETFILENAME, this,
|
||||
GetDefaultFieldName( SHEETFILENAME, DO_TRANSLATE ) );
|
||||
m_fields.emplace_back( aPos, FIELD_T::SHEET_FILENAME, this,
|
||||
GetDefaultFieldName( FIELD_T::SHEET_FILENAME, DO_TRANSLATE ) );
|
||||
m_fields.back().SetVisible( true );
|
||||
m_fields.back().SetLayer( LAYER_SHEETNAME );
|
||||
|
||||
@@ -400,26 +370,28 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem )
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_SHEET::GetField( FIELD_T aFieldType )
|
||||
{
|
||||
if( SCH_FIELD* field = FindField( m_fields, aFieldType ) )
|
||||
return field;
|
||||
|
||||
m_fields.emplace_back( this, aFieldType );
|
||||
return &m_fields.back();
|
||||
}
|
||||
|
||||
|
||||
const SCH_FIELD* SCH_SHEET::GetField( FIELD_T aFieldType ) const
|
||||
{
|
||||
return FindField( m_fields, aFieldType );
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET::SetFields( const std::vector<SCH_FIELD>& aFields )
|
||||
{
|
||||
m_fields = aFields;
|
||||
|
||||
// Ensure that mandatory fields are at the beginning
|
||||
std::sort( m_fields.begin(), m_fields.end(),
|
||||
[]( const SCH_FIELD& a, const SCH_FIELD& b )
|
||||
{
|
||||
return a.GetId() < b.GetId();
|
||||
} );
|
||||
|
||||
// After mandatory fields, the rest should be sequential user fields
|
||||
for( int ii = 0; ii < static_cast<int>( m_fields.size() ); ++ii )
|
||||
{
|
||||
if( !m_fields[ii].IsMandatory() )
|
||||
m_fields[ii].SetId( ii );
|
||||
}
|
||||
|
||||
// Make sure that we get the UNIX variant of the file path
|
||||
SetFileName( m_fields[SHEETFILENAME].GetText() );
|
||||
SetFileName( GetField( FIELD_T::SHEET_FILENAME )->GetText() );
|
||||
}
|
||||
|
||||
|
||||
@@ -662,41 +634,44 @@ int SCH_SHEET::GetPenWidth() const
|
||||
|
||||
void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo )
|
||||
{
|
||||
VECTOR2I textSize = m_fields[SHEETNAME].GetTextSize();
|
||||
int borderMargin = KiROUND( GetPenWidth() / 2.0 ) + 4;
|
||||
int margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.5 );
|
||||
SCH_FIELD* sheetNameField = GetField( FIELD_T::SHEET_NAME );
|
||||
VECTOR2I textSize = sheetNameField->GetTextSize();
|
||||
int borderMargin = KiROUND( GetPenWidth() / 2.0 ) + 4;
|
||||
int margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.5 );
|
||||
|
||||
if( IsVerticalOrientation() )
|
||||
{
|
||||
m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( -margin, m_size.y ) );
|
||||
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
m_fields[ SHEETNAME ].SetTextAngle( ANGLE_VERTICAL );
|
||||
sheetNameField->SetTextPos( m_pos + VECTOR2I( -margin, m_size.y ) );
|
||||
sheetNameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
sheetNameField->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
sheetNameField->SetTextAngle( ANGLE_VERTICAL );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( 0, -margin ) );
|
||||
m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
m_fields[ SHEETNAME ].SetTextAngle( ANGLE_HORIZONTAL );
|
||||
sheetNameField->SetTextPos( m_pos + VECTOR2I( 0, -margin ) );
|
||||
sheetNameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
sheetNameField->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
|
||||
sheetNameField->SetTextAngle( ANGLE_HORIZONTAL );
|
||||
}
|
||||
|
||||
textSize = m_fields[ SHEETFILENAME ].GetTextSize();
|
||||
SCH_FIELD* sheetFilenameField = GetField( FIELD_T::SHEET_FILENAME );
|
||||
|
||||
textSize = sheetFilenameField->GetTextSize();
|
||||
margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.4 );
|
||||
|
||||
if( IsVerticalOrientation() )
|
||||
{
|
||||
m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( m_size.x + margin, m_size.y ) );
|
||||
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_VERTICAL );
|
||||
sheetFilenameField->SetTextPos( m_pos + VECTOR2I( m_size.x + margin, m_size.y ) );
|
||||
sheetFilenameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
sheetFilenameField->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
sheetFilenameField->SetTextAngle( ANGLE_VERTICAL );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) );
|
||||
m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_HORIZONTAL );
|
||||
sheetFilenameField->SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) );
|
||||
sheetFilenameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
sheetFilenameField->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
sheetFilenameField->SetTextAngle( ANGLE_HORIZONTAL );
|
||||
}
|
||||
|
||||
if( aAlgo == AUTOPLACE_AUTO || aAlgo == AUTOPLACE_MANUAL )
|
||||
@@ -761,7 +736,7 @@ int SCH_SHEET::SymbolCount() const
|
||||
{
|
||||
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
|
||||
|
||||
if( symbol->GetField( VALUE_FIELD )->GetText().GetChar( 0 ) != '#' )
|
||||
if( symbol->GetField( FIELD_T::VALUE )->GetText().GetChar( 0 ) != '#' )
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -850,8 +825,7 @@ int SCH_SHEET::CountSheets() const
|
||||
void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
||||
{
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( _( "Sheet Name" ),
|
||||
KIUI::EllipsizeStatusText( aFrame, m_fields[ SHEETNAME ].GetText() ) );
|
||||
aList.emplace_back( _( "Sheet Name" ), KIUI::EllipsizeStatusText( aFrame, GetName() ) );
|
||||
|
||||
if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
|
||||
{
|
||||
@@ -862,8 +836,7 @@ void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
|
||||
}
|
||||
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( _( "File Name" ),
|
||||
KIUI::EllipsizeStatusText( aFrame, m_fields[ SHEETFILENAME ].GetText() ) );
|
||||
aList.emplace_back( _( "File Name" ), KIUI::EllipsizeStatusText( aFrame, GetFileName() ) );
|
||||
|
||||
wxArrayString msgs;
|
||||
wxString msg;
|
||||
@@ -1176,9 +1149,11 @@ void SCH_SHEET::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction
|
||||
|
||||
wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
||||
{
|
||||
const SCH_FIELD* sheetnameField = GetField( FIELD_T::SHEET_NAME );
|
||||
|
||||
return wxString::Format( _( "Hierarchical Sheet %s" ),
|
||||
aFull ? m_fields[ SHEETNAME ].GetShownText( false )
|
||||
: KIUI::EllipsizeMenuText( m_fields[ SHEETNAME ].GetText() ) );
|
||||
aFull ? sheetnameField->GetShownText( false )
|
||||
: KIUI::EllipsizeMenuText( sheetnameField->GetText() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -1330,13 +1305,13 @@ bool SCH_SHEET::operator <( const SCH_ITEM& aItem ) const
|
||||
if( Type() != aItem.Type() )
|
||||
return Type() < aItem.Type();
|
||||
|
||||
auto sheet = static_cast<const SCH_SHEET*>( &aItem );
|
||||
const SCH_SHEET* otherSheet = static_cast<const SCH_SHEET*>( &aItem );
|
||||
|
||||
if (m_fields[ SHEETNAME ].GetText() != sheet->m_fields[ SHEETNAME ].GetText() )
|
||||
return m_fields[ SHEETNAME ].GetText() < sheet->m_fields[ SHEETNAME ].GetText();
|
||||
if( GetName() != otherSheet->GetName() )
|
||||
return GetName() < otherSheet->GetName();
|
||||
|
||||
if (m_fields[ SHEETFILENAME ].GetText() != sheet->m_fields[ SHEETFILENAME ].GetText() )
|
||||
return m_fields[ SHEETFILENAME ].GetText() < sheet->m_fields[ SHEETFILENAME ].GetText();
|
||||
if( GetFileName() != otherSheet->GetFileName() )
|
||||
return GetFileName() < otherSheet->GetFileName();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1638,7 +1613,7 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
|
||||
wxString s = GetClass();
|
||||
|
||||
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
|
||||
<< TO_UTF8( m_fields[ SHEETNAME ].GetText() ) << '"' << ">\n";
|
||||
<< TO_UTF8( GetName() ) << '"' << ">\n";
|
||||
|
||||
// show all the pins, and check the linked list integrity
|
||||
for( SCH_SHEET_PIN* sheetPin : m_pins )
|
||||
|
||||
+15
-19
@@ -40,18 +40,6 @@ 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_FIELD_COUNT
|
||||
};
|
||||
|
||||
#define SHEET_MANDATORY_FIELDS { SHEETNAME, SHEETFILENAME }
|
||||
|
||||
|
||||
/**
|
||||
* Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
|
||||
*/
|
||||
@@ -93,9 +81,19 @@ public:
|
||||
*/
|
||||
bool IsMovableFromAnchorPoint() const override { return false; }
|
||||
|
||||
/**
|
||||
* Return a reference to the vector holding the sheet's fields
|
||||
*/
|
||||
std::vector<SCH_FIELD>& GetFields() { return m_fields; }
|
||||
const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
|
||||
|
||||
/**
|
||||
* Return a mandatory field in this sheet. The const version will return nullptr if the
|
||||
* field does not exist; the non-const version will create it.
|
||||
*/
|
||||
SCH_FIELD* GetField( FIELD_T aFieldType );
|
||||
const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
|
||||
|
||||
/**
|
||||
* Set multiple schematic fields.
|
||||
*
|
||||
@@ -105,10 +103,10 @@ public:
|
||||
|
||||
wxString GetShownName( bool aAllowExtraText ) const
|
||||
{
|
||||
return m_fields[SHEETNAME].GetShownText( aAllowExtraText );
|
||||
return GetField( FIELD_T::SHEET_NAME )->GetShownText( aAllowExtraText );
|
||||
}
|
||||
wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); }
|
||||
void SetName( const wxString& aName ) { m_fields[ SHEETNAME ].SetText( aName ); }
|
||||
wxString GetName() const { return GetField( FIELD_T::SHEET_NAME )->GetText(); }
|
||||
void SetName( const wxString& aName ) { GetField( FIELD_T::SHEET_NAME )->SetText( aName ); }
|
||||
|
||||
SCH_SCREEN* GetScreen() const { return m_screen; }
|
||||
|
||||
@@ -309,7 +307,7 @@ public:
|
||||
*/
|
||||
wxString GetFileName() const
|
||||
{
|
||||
return m_fields[ SHEETFILENAME ].GetText();
|
||||
return GetField( FIELD_T::SHEET_FILENAME )->GetText();
|
||||
}
|
||||
|
||||
// Set a new filename without changing anything else
|
||||
@@ -318,7 +316,7 @@ public:
|
||||
// Filenames are stored using unix notation
|
||||
wxString tmp = aFilename;
|
||||
tmp.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
m_fields[ SHEETFILENAME ].SetText( tmp );
|
||||
GetField( FIELD_T::SHEET_FILENAME )->SetText( tmp );
|
||||
}
|
||||
|
||||
// Geometric transforms (used in block operations):
|
||||
@@ -465,8 +463,6 @@ 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;
|
||||
|
||||
+10
-15
@@ -364,7 +364,7 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName,
|
||||
|
||||
// Start at 1 since we've already processed the root sheet.
|
||||
for( unsigned i = 1; i < size(); i++ )
|
||||
s << at( i )->GetFields()[SHEETNAME].GetShownText( false ) << wxS( "/" );
|
||||
s << at( i )->GetField( FIELD_T::SHEET_NAME )->GetShownText( false ) << wxS( "/" );
|
||||
|
||||
if( aStripTrailingSeparator && s.EndsWith( "/" ) )
|
||||
s = s.Left( s.length() - 1 );
|
||||
@@ -390,7 +390,7 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences() const
|
||||
{
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
|
||||
|
||||
symbol->GetField( REFERENCE_FIELD )->SetText( symbol->GetRef( this ) );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->SetText( symbol->GetRef( this ) );
|
||||
symbol->SetUnit( symbol->GetUnitSelection( this ) );
|
||||
LastScreen()->Update( item, false );
|
||||
}
|
||||
@@ -400,20 +400,15 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences() const
|
||||
|
||||
if( label->GetFields().size() > 0 ) // Possible when reading a legacy .sch schematic
|
||||
{
|
||||
SCH_FIELD& intersheetRefs = label->GetFields()[0];
|
||||
SCH_FIELD* intersheetRefs = label->GetField( FIELD_T::INTERSHEET_REFS );
|
||||
|
||||
// Fixup for legacy files which didn't store a position for the intersheet refs
|
||||
// unless they were shown.
|
||||
if( label->GetFields().size() == 1
|
||||
&& intersheetRefs.GetInternalName() == wxT( "Intersheet References" )
|
||||
&& intersheetRefs.GetPosition() == VECTOR2I( 0, 0 )
|
||||
&& !intersheetRefs.IsVisible() )
|
||||
{
|
||||
if( intersheetRefs->GetPosition() == VECTOR2I() && !intersheetRefs->IsVisible() )
|
||||
label->AutoplaceFields( LastScreen(), AUTOPLACE_AUTO );
|
||||
}
|
||||
|
||||
intersheetRefs.SetVisible( label->Schematic()->Settings().m_IntersheetRefsShow );
|
||||
LastScreen()->Update( &intersheetRefs );
|
||||
intersheetRefs->SetVisible( label->Schematic()->Settings().m_IntersheetRefsShow );
|
||||
LastScreen()->Update( intersheetRefs );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -644,7 +639,7 @@ void SCH_SHEET_PATH::AddNewSymbolInstances( const SCH_SHEET_PATH& aPrefixSheetPa
|
||||
// Fall back to the last saved symbol field and unit settings if there is no
|
||||
// instance data.
|
||||
newSymbolInstance.m_Path = newSheetPath.Path();
|
||||
newSymbolInstance.m_Reference = symbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
newSymbolInstance.m_Reference = symbol->GetField( FIELD_T::REFERENCE )->GetText();
|
||||
newSymbolInstance.m_Unit = symbol->GetUnit();
|
||||
symbol->AddHierarchicalReference( newSymbolInstance );
|
||||
}
|
||||
@@ -693,8 +688,8 @@ void SCH_SHEET_PATH::CheckForMissingSymbolInstances( const wxString& aProjectNam
|
||||
if( ( LastScreen()->GetRefCount() <= 1 ) &&
|
||||
( LastScreen()->GetFileFormatVersionAtLoad() <= 20200310 ) )
|
||||
{
|
||||
symbolInstance.m_Reference =
|
||||
symbol->GetField( REFERENCE_FIELD )->GetShownText( this, true );
|
||||
SCH_FIELD* refField = symbol->GetField( FIELD_T::REFERENCE );
|
||||
symbolInstance.m_Reference = refField->GetShownText( this, true );
|
||||
symbolInstance.m_Unit = symbol->GetUnit();
|
||||
}
|
||||
else
|
||||
@@ -1223,7 +1218,7 @@ void SCH_SHEET_LIST::UpdateSymbolInstanceData(
|
||||
// Symbol instance paths are stored and looked up in memory with the root path so use
|
||||
// the full path here.
|
||||
symbol->AddHierarchicalReference( sheetPath.Path(), it->m_Reference, it->m_Unit );
|
||||
symbol->GetField( REFERENCE_FIELD )->SetText( it->m_Reference );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->SetText( it->m_Reference );
|
||||
|
||||
if( !it->m_Value.IsEmpty() )
|
||||
symbol->SetValueFieldText( it->m_Value );
|
||||
|
||||
+111
-130
@@ -117,12 +117,12 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet,
|
||||
SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, aPosition, aParent )
|
||||
{
|
||||
// Set any fields that were modified as part of the symbol selection
|
||||
for( const std::pair<int, wxString>& i : aSel.Fields )
|
||||
for( const auto& [fieldId, fieldValue] : aSel.Fields )
|
||||
{
|
||||
if( i.first == REFERENCE_FIELD )
|
||||
SetRef( aSheet, i.second );
|
||||
else if( SCH_FIELD* field = GetFieldById( i.first ) )
|
||||
field->SetText( i.second );
|
||||
if( fieldId == FIELD_T::REFERENCE )
|
||||
SetRef( aSheet, fieldValue );
|
||||
else if( SCH_FIELD* field = GetField( fieldId ) )
|
||||
field->SetText( fieldValue );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,18 +182,18 @@ void SCH_SYMBOL::Init( const VECTOR2I& pos )
|
||||
m_transform = TRANSFORM();
|
||||
|
||||
auto addField =
|
||||
[&]( int id, SCH_LAYER_ID layer )
|
||||
[&]( FIELD_T id, SCH_LAYER_ID layer )
|
||||
{
|
||||
m_fields.emplace_back( pos, id, this, GetCanonicalFieldName( id ) );
|
||||
m_fields.back().SetLayer( layer );
|
||||
};
|
||||
|
||||
// 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 );
|
||||
addField( FIELD_T::REFERENCE, LAYER_REFERENCEPART );
|
||||
addField( FIELD_T::VALUE, LAYER_VALUEPART );
|
||||
addField( FIELD_T::FOOTPRINT, LAYER_FIELDS );
|
||||
addField( FIELD_T::DATASHEET, LAYER_FIELDS );
|
||||
addField( FIELD_T::DESCRIPTION, LAYER_FIELDS );
|
||||
|
||||
m_prefix = wxString( wxT( "U" ) );
|
||||
m_isInNetlist = true;
|
||||
@@ -548,7 +548,7 @@ void SCH_SYMBOL::AddHierarchicalReference( const KIID_PATH& aPath, const wxStrin
|
||||
// when importing sheets.
|
||||
if( m_instanceReferences.size() == 1 )
|
||||
{
|
||||
m_fields[ REFERENCE_FIELD ].SetText( aRef );
|
||||
GetField( FIELD_T::REFERENCE )->SetText( aRef );
|
||||
m_unit = aUnit;
|
||||
}
|
||||
}
|
||||
@@ -602,7 +602,7 @@ void SCH_SYMBOL::AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance
|
||||
// when importing sheets.
|
||||
if( m_instanceReferences.size() == 1 )
|
||||
{
|
||||
m_fields[ REFERENCE_FIELD ].SetText( instance.m_Reference );
|
||||
GetField( FIELD_T::REFERENCE )->SetText( instance.m_Reference );
|
||||
m_unit = instance.m_Unit;
|
||||
}
|
||||
}
|
||||
@@ -628,8 +628,8 @@ const wxString SCH_SYMBOL::GetRef( const SCH_SHEET_PATH* sheet, bool aIncludeUni
|
||||
// use this as a default for this path. This will happen if we load a version 1 schematic
|
||||
// file. It will also mean that multiple instances of the same sheet by default all have
|
||||
// the same symbol references, but perhaps this is best.
|
||||
if( ref.IsEmpty() && !GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
|
||||
ref = GetField( REFERENCE_FIELD )->GetText();
|
||||
if( ref.IsEmpty() && !GetField( FIELD_T::REFERENCE )->GetText().IsEmpty() )
|
||||
ref = GetField( FIELD_T::REFERENCE )->GetText();
|
||||
|
||||
if( ref.IsEmpty() )
|
||||
ref = UTIL::GetRefDesUnannotated( m_prefix );
|
||||
@@ -643,7 +643,7 @@ const wxString SCH_SYMBOL::GetRef( const SCH_SHEET_PATH* sheet, bool aIncludeUni
|
||||
|
||||
void SCH_SYMBOL::SetRefProp( const wxString& aRef )
|
||||
{
|
||||
FIELD_VALIDATOR validator( REFERENCE_FIELD );
|
||||
FIELD_VALIDATOR validator( FIELD_T::REFERENCE );
|
||||
|
||||
if( validator.DoValidate( aRef, nullptr ) )
|
||||
SetRef( &Schematic()->CurrentSheet(), aRef );
|
||||
@@ -673,7 +673,7 @@ void SCH_SYMBOL::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
|
||||
pin->ClearDefaultNetName( sheet );
|
||||
|
||||
if( Schematic() && *sheet == Schematic()->CurrentSheet() )
|
||||
m_fields[ REFERENCE_FIELD ].SetText( ref );
|
||||
GetField( FIELD_T::REFERENCE )->SetText( ref );
|
||||
|
||||
// Reinit the m_prefix member if needed
|
||||
m_prefix = UTIL::GetRefDesPrefix( ref );
|
||||
@@ -702,7 +702,7 @@ bool SCH_SYMBOL::IsAnnotated( const SCH_SHEET_PATH* aSheet ) const
|
||||
|
||||
void SCH_SYMBOL::UpdatePrefix()
|
||||
{
|
||||
wxString refDesignator = GetField( REFERENCE_FIELD )->GetText();
|
||||
wxString refDesignator = GetField( FIELD_T::REFERENCE )->GetText();
|
||||
|
||||
refDesignator.Replace( "~", " " );
|
||||
|
||||
@@ -782,15 +782,15 @@ const wxString SCH_SYMBOL::GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
|
||||
bool aAllowExtraText ) const
|
||||
{
|
||||
if( aResolve )
|
||||
return GetField( VALUE_FIELD )->GetShownText( aPath, aAllowExtraText );
|
||||
return GetField( FIELD_T::VALUE )->GetShownText( aPath, aAllowExtraText );
|
||||
|
||||
return GetField( VALUE_FIELD )->GetText();
|
||||
return GetField( FIELD_T::VALUE )->GetText();
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::SetValueFieldText( const wxString& aValue )
|
||||
{
|
||||
m_fields[ VALUE_FIELD ].SetText( aValue );
|
||||
GetField( FIELD_T::VALUE )->SetText( aValue );
|
||||
}
|
||||
|
||||
|
||||
@@ -798,69 +798,49 @@ const wxString SCH_SYMBOL::GetFootprintFieldText( bool aResolve, const SCH_SHEET
|
||||
bool aAllowExtraText ) const
|
||||
{
|
||||
if( aResolve )
|
||||
return GetField( FOOTPRINT_FIELD )->GetShownText( aPath, aAllowExtraText );
|
||||
return GetField( FIELD_T::FOOTPRINT )->GetShownText( aPath, aAllowExtraText );
|
||||
|
||||
return GetField( FOOTPRINT_FIELD )->GetText();
|
||||
return GetField( FIELD_T::FOOTPRINT )->GetText();
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::SetFootprintFieldText( const wxString& aFootprint )
|
||||
{
|
||||
m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
|
||||
GetField( FIELD_T::FOOTPRINT )->SetText( aFootprint );
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_SYMBOL::GetField( MANDATORY_FIELD_T aFieldType )
|
||||
SCH_FIELD* SCH_SYMBOL::GetField( FIELD_T aFieldType )
|
||||
{
|
||||
return &m_fields[aFieldType];
|
||||
if( SCH_FIELD* field = FindField( m_fields, aFieldType ) )
|
||||
return field;
|
||||
|
||||
m_fields.emplace_back( this, aFieldType );
|
||||
return &m_fields.back();
|
||||
}
|
||||
|
||||
|
||||
const SCH_FIELD* SCH_SYMBOL::GetField( MANDATORY_FIELD_T aFieldType ) const
|
||||
const SCH_FIELD* SCH_SYMBOL::GetField( FIELD_T aFieldType ) const
|
||||
{
|
||||
return &m_fields[aFieldType];
|
||||
return FindField( m_fields, aFieldType );
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_SYMBOL::GetFieldById( int aFieldId )
|
||||
SCH_FIELD* SCH_SYMBOL::GetField( const wxString& aFieldName )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.GetId() == aFieldId )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return FindField( m_fields, aFieldName );
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_SYMBOL::GetFieldByName( const wxString& aFieldName )
|
||||
const SCH_FIELD* SCH_SYMBOL::GetField( const wxString& aFieldName ) const
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return FindField( m_fields, aFieldName );
|
||||
}
|
||||
|
||||
|
||||
const SCH_FIELD* SCH_SYMBOL::GetFieldByName( const wxString& aFieldName ) const
|
||||
void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const
|
||||
{
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( aVisibleOnly )
|
||||
{
|
||||
@@ -868,8 +848,14 @@ void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly
|
||||
continue;
|
||||
}
|
||||
|
||||
aVector.push_back( &field );
|
||||
aVector.push_back( const_cast<SCH_FIELD*>( &field ) );
|
||||
}
|
||||
|
||||
std::sort( aVector.begin(), aVector.end(),
|
||||
[]( SCH_FIELD* lhs, SCH_FIELD* rhs )
|
||||
{
|
||||
return lhs->GetOrdinal() < rhs->GetOrdinal();
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@@ -896,24 +882,12 @@ void SCH_SYMBOL::RemoveField( const wxString& aFieldName )
|
||||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_SYMBOL::FindField( const wxString& aFieldName, bool aIncludeDefaultFields,
|
||||
bool aCaseInsensitive )
|
||||
SCH_FIELD* SCH_SYMBOL::FindFieldCaseInsensitive( const wxString& aFieldName )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.IsMandatory() && !aIncludeDefaultFields )
|
||||
continue;
|
||||
|
||||
if( aCaseInsensitive )
|
||||
{
|
||||
if( aFieldName.Upper() == field.GetName( false ).Upper() )
|
||||
return &field;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aFieldName == field.GetName( false ) )
|
||||
return &field;
|
||||
}
|
||||
if( field.GetName().IsSameAs( aFieldName, false ) )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -930,22 +904,22 @@ void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, b
|
||||
|
||||
for( const SCH_FIELD* libField : fields )
|
||||
{
|
||||
int id = libField->GetId();
|
||||
SCH_FIELD* schField;
|
||||
FIELD_T fieldType = FIELD_T::USER;
|
||||
|
||||
if( libField->IsMandatory() )
|
||||
{
|
||||
schField = GetFieldById( id );
|
||||
fieldType = libField->GetId();
|
||||
schField = GetField( fieldType );
|
||||
}
|
||||
else
|
||||
{
|
||||
schField = FindField( libField->GetCanonicalName() );
|
||||
schField = GetField( libField->GetCanonicalName() );
|
||||
|
||||
if( !schField )
|
||||
{
|
||||
SCH_FIELD newField( VECTOR2I( 0, 0 ), GetNextFieldId(), this,
|
||||
libField->GetCanonicalName() );
|
||||
schField = AddField( newField );
|
||||
schField = AddField( SCH_FIELD( { 0, 0 }, FIELD_T::USER, this,
|
||||
libField->GetCanonicalName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,23 +931,18 @@ void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, b
|
||||
schField->SetTextPos( m_pos + libField->GetTextPos() );
|
||||
}
|
||||
|
||||
if( id == REFERENCE_FIELD && aPath )
|
||||
if( fieldType == FIELD_T::REFERENCE && aPath )
|
||||
{
|
||||
if( aResetRef )
|
||||
SetRef( aPath, m_part->GetReferenceField().GetText() );
|
||||
SetRef( aPath, m_part->GetField( FIELD_T::REFERENCE )->GetText() );
|
||||
else if( aUpdateRef )
|
||||
SetRef( aPath, libField->GetText() );
|
||||
}
|
||||
else if( id == VALUE_FIELD )
|
||||
else if( fieldType == FIELD_T::VALUE )
|
||||
{
|
||||
SetValueFieldText( UnescapeString( libField->GetText() ) );
|
||||
}
|
||||
else if( id == FOOTPRINT_FIELD )
|
||||
{
|
||||
if( aResetOtherFields || aUpdateOtherFields )
|
||||
SetFootprintFieldText( libField->GetText() );
|
||||
}
|
||||
else if( id == DATASHEET_FIELD )
|
||||
else if( fieldType == FIELD_T::DATASHEET )
|
||||
{
|
||||
if( aResetOtherFields )
|
||||
schField->SetText( GetDatasheet() ); // alias-specific value
|
||||
@@ -1038,23 +1007,32 @@ void SCH_SYMBOL::SyncOtherUnits( const SCH_SHEET_PATH& aSourceSheet, SCH_COMMIT&
|
||||
aCommit.Modify( otherUnit, screen );
|
||||
|
||||
if( updateValue )
|
||||
otherUnit->SetValueFieldText( GetField( VALUE_FIELD )->GetText() );
|
||||
otherUnit->SetValueFieldText( GetField( FIELD_T::VALUE )->GetText() );
|
||||
|
||||
if( updateOtherFields )
|
||||
{
|
||||
otherUnit->SetFootprintFieldText( GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
|
||||
for( size_t ii = DATASHEET_FIELD; ii < m_fields.size(); ++ii )
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
SCH_FIELD* otherField = otherUnit->FindField( m_fields[ii].GetName() );
|
||||
if( field.GetId() == FIELD_T::REFERENCE || field.GetId() == FIELD_T::VALUE )
|
||||
{
|
||||
// already handled
|
||||
continue;
|
||||
}
|
||||
|
||||
SCH_FIELD* otherField;
|
||||
|
||||
if( field.IsMandatory() )
|
||||
otherField = otherUnit->GetField( field.GetId() );
|
||||
else
|
||||
otherField = otherUnit->GetField( field.GetName() );
|
||||
|
||||
if( otherField )
|
||||
{
|
||||
otherField->SetText( m_fields[ii].GetText() );
|
||||
otherField->SetText( field.GetText() );
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_FIELD newField( m_fields[ii] );
|
||||
SCH_FIELD newField( field );
|
||||
const_cast<KIID&>( newField.m_Uuid ) = KIID();
|
||||
|
||||
newField.Offset( -GetPosition() );
|
||||
@@ -1065,11 +1043,11 @@ void SCH_SYMBOL::SyncOtherUnits( const SCH_SHEET_PATH& aSourceSheet, SCH_COMMIT&
|
||||
}
|
||||
}
|
||||
|
||||
for( size_t ii = otherUnit->GetFields().size() - 1; ii > DATASHEET_FIELD; ii-- )
|
||||
for( int ii = (int) otherUnit->GetFields().size() - 1; ii >= 0; ii-- )
|
||||
{
|
||||
SCH_FIELD& otherField = otherUnit->GetFields().at( ii );
|
||||
SCH_FIELD& otherField = otherUnit->GetFields()[ii];
|
||||
|
||||
if( !FindField( otherField.GetName() ) )
|
||||
if( !otherField.IsMandatory() && !GetField( otherField.GetName() ) )
|
||||
otherUnit->GetFields().erase( otherUnit->GetFields().begin() + ii );
|
||||
}
|
||||
}
|
||||
@@ -1402,7 +1380,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i
|
||||
|
||||
if( token->IsSameAs( fieldName, false ) )
|
||||
{
|
||||
if( field.GetId() == REFERENCE_FIELD )
|
||||
if( field.GetId() == FIELD_T::REFERENCE )
|
||||
*token = GetRef( aPath, true );
|
||||
else
|
||||
*token = field.GetShownText( aPath, false, aDepth + 1 );
|
||||
@@ -1605,12 +1583,12 @@ void SCH_SYMBOL::ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetP
|
||||
// When a clear annotation is made, the calling function must call a
|
||||
// UpdateAllScreenReferences for the active sheet.
|
||||
// But this call cannot made here.
|
||||
wxString currentReference = m_fields[REFERENCE_FIELD].GetText();
|
||||
wxString currentReference = GetField( FIELD_T::REFERENCE )->GetText();
|
||||
|
||||
if( currentReference.IsEmpty() || aResetPrefix )
|
||||
m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( m_prefix ) );
|
||||
GetField( FIELD_T::REFERENCE )->SetText( UTIL::GetRefDesUnannotated( m_prefix ) );
|
||||
else
|
||||
m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( currentReference ) );
|
||||
GetField( FIELD_T::REFERENCE )->SetText( UTIL::GetRefDesUnannotated( currentReference ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -1627,7 +1605,7 @@ bool SCH_SYMBOL::AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPat
|
||||
}
|
||||
|
||||
// This entry does not exist: add it, with its last-used reference
|
||||
AddHierarchicalReference( aSheetPath, m_fields[REFERENCE_FIELD].GetText(), m_unit );
|
||||
AddHierarchicalReference( aSheetPath, GetField( FIELD_T::REFERENCE )->GetText(), m_unit );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1838,7 +1816,7 @@ void SCH_SYMBOL::Show( int nestLevel, std::ostream& os ) const
|
||||
{
|
||||
// for now, make it look like XML:
|
||||
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
||||
<< " ref=\"" << TO_UTF8( GetField( REFERENCE_FIELD )->GetName() )
|
||||
<< " ref=\"" << TO_UTF8( GetField( FIELD_T::REFERENCE )->GetName() )
|
||||
<< '"' << " chipName=\""
|
||||
<< GetLibId().Format().wx_str() << '"' << m_pos
|
||||
<< " layer=\"" << m_layer
|
||||
@@ -1958,8 +1936,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
||||
{
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( _( "Power symbol" ),
|
||||
KIUI::EllipsizeStatusText( aFrame,
|
||||
GetField( VALUE_FIELD )->GetText() ) );
|
||||
KIUI::EllipsizeStatusText( aFrame, GetField( FIELD_T::VALUE )->GetText() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1968,8 +1945,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
||||
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( _( "Value" ),
|
||||
KIUI::EllipsizeStatusText( aFrame,
|
||||
GetField( VALUE_FIELD )->GetText() ) );
|
||||
KIUI::EllipsizeStatusText( aFrame, GetField( FIELD_T::VALUE )->GetText() ) );
|
||||
addExcludes();
|
||||
aList.emplace_back( _( "Name" ),
|
||||
KIUI::EllipsizeStatusText( aFrame,
|
||||
@@ -2002,7 +1978,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
||||
|
||||
// Display the current associated footprint, if exists.
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
msg = KIUI::EllipsizeStatusText( aFrame, GetField( FOOTPRINT_FIELD )->GetText() );
|
||||
msg = KIUI::EllipsizeStatusText( aFrame, GetField( FIELD_T::FOOTPRINT )->GetText() );
|
||||
|
||||
if( msg.IsEmpty() )
|
||||
msg = _( "<Unknown>" );
|
||||
@@ -2011,7 +1987,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
||||
|
||||
// Display description of the symbol, and keywords found in lib
|
||||
aList.emplace_back( _( "Description" ) + wxT( ": " )
|
||||
+ GetField( DESCRIPTION_FIELD )->GetText(),
|
||||
+ GetField( FIELD_T::DESCRIPTION )->GetText(),
|
||||
_( "Keywords" ) + wxT( ": " ) + m_part->GetKeyWords() );
|
||||
}
|
||||
}
|
||||
@@ -2021,8 +1997,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
||||
|
||||
// Don't use GetShownText(); we want to see the variable references here
|
||||
aList.emplace_back( _( "Value" ),
|
||||
KIUI::EllipsizeStatusText( aFrame,
|
||||
GetField( VALUE_FIELD )->GetText() ) );
|
||||
KIUI::EllipsizeStatusText( aFrame, GetField( FIELD_T::VALUE )->GetText() ) );
|
||||
addExcludes();
|
||||
aList.emplace_back( _( "Name" ),
|
||||
KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) );
|
||||
@@ -2286,7 +2261,7 @@ SCH_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType )
|
||||
wxString SCH_SYMBOL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
|
||||
{
|
||||
return wxString::Format( _( "Symbol %s [%s]" ),
|
||||
KIUI::EllipsizeMenuText( GetField( REFERENCE_FIELD )->GetText() ),
|
||||
KIUI::EllipsizeMenuText( GetField( FIELD_T::REFERENCE )->GetText() ),
|
||||
KIUI::EllipsizeMenuText( GetLibId().GetLibItemName() ) );
|
||||
}
|
||||
|
||||
@@ -2315,26 +2290,26 @@ INSPECT_RESULT SCH_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
|
||||
|
||||
if( scanType == SCH_FIELD_LOCATE_REFERENCE_T )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( REFERENCE_FIELD ), (void*) this ) )
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( FIELD_T::REFERENCE ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( scanType == SCH_FIELD_LOCATE_VALUE_T
|
||||
|| ( scanType == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( VALUE_FIELD ), (void*) this ) )
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( FIELD_T::VALUE ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( FOOTPRINT_FIELD ), (void*) this ) )
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( FIELD_T::FOOTPRINT ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
if( scanType == SCH_FIELD_LOCATE_DATASHEET_T )
|
||||
{
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( DATASHEET_FIELD ), (void*) this ) )
|
||||
if( INSPECT_RESULT::QUIT == aInspector( GetField( FIELD_T::DATASHEET ), (void*) this ) )
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
@@ -2392,12 +2367,17 @@ bool SCH_SYMBOL::operator==( const SCH_SYMBOL& aSymbol ) const
|
||||
if( GetFieldCount() != aSymbol.GetFieldCount() )
|
||||
return false;
|
||||
|
||||
std::vector<SCH_FIELD*> fields, otherFields;
|
||||
|
||||
GetFields( fields, false );
|
||||
aSymbol.GetFields( otherFields, false );
|
||||
|
||||
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
||||
{
|
||||
if( ii == REFERENCE_FIELD )
|
||||
if( fields[ii]->GetId() == FIELD_T::REFERENCE )
|
||||
continue;
|
||||
|
||||
if( GetFields()[ii].GetText().Cmp( aSymbol.GetFields()[ii].GetText() ) != 0 )
|
||||
if( fields[ii]->GetText().Cmp( otherFields[ii]->GetText() ) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2540,7 +2520,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS&
|
||||
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) )
|
||||
{
|
||||
// Use SCH_FIELD's text resolver
|
||||
SCH_FIELD dummy( this, -1 );
|
||||
SCH_FIELD dummy( this, FIELD_T::USER );
|
||||
dummy.SetText( text->GetText() );
|
||||
text->SetText( dummy.GetShownText( false ) );
|
||||
}
|
||||
@@ -2773,17 +2753,18 @@ std::unordered_set<wxString> SCH_SYMBOL::GetComponentClassNames( const SCH_SHEET
|
||||
{
|
||||
std::unordered_set<wxString> componentClass;
|
||||
|
||||
auto getComponentClassFields = [&]( const auto& fields )
|
||||
{
|
||||
for( const SCH_FIELD& field : fields )
|
||||
{
|
||||
if( field.GetCanonicalName() == wxT( "Component Class" ) )
|
||||
auto getComponentClassFields =
|
||||
[&]( const std::vector<SCH_FIELD>& fields )
|
||||
{
|
||||
if( field.GetShownText( aPath, false ) != wxEmptyString )
|
||||
componentClass.insert( field.GetShownText( aPath, false ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
for( const SCH_FIELD& field : fields )
|
||||
{
|
||||
if( field.GetCanonicalName() == wxT( "Component Class" ) )
|
||||
{
|
||||
if( field.GetShownText( aPath, false ) != wxEmptyString )
|
||||
componentClass.insert( field.GetShownText( aPath, false ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// First get component classes set on the symbol itself
|
||||
getComponentClassFields( m_fields );
|
||||
|
||||
+13
-34
@@ -411,46 +411,28 @@ public:
|
||||
//-----<Fields>-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return a mandatory field in this symbol.
|
||||
*
|
||||
* @note If you need to fetch a user field, use GetFieldById.
|
||||
*
|
||||
* @param aFieldType is one of the mandatory field types (REFERENCE_FIELD, VALUE_FIELD, etc.).
|
||||
* @return is the field at \a aFieldType or NULL if the field does not exist.
|
||||
* Return a mandatory field in this symbol. The const version will return nullptr if the
|
||||
* field is not found; non-const version will create the field.
|
||||
*/
|
||||
SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldType );
|
||||
const SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldNdx ) const;
|
||||
SCH_FIELD* GetField( FIELD_T aFieldType );
|
||||
const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
|
||||
|
||||
/**
|
||||
* Return a field in this symbol.
|
||||
*
|
||||
* @param aFieldId is the id of the field requested. Note that this id ONLY SOMETIMES equates
|
||||
* to the field's position in the vector.
|
||||
* @return is the field at \a aFieldType or NULL if the field does not exist.
|
||||
* Return a field in this symbol. Both versions return nullptr if the field is not found.
|
||||
*/
|
||||
SCH_FIELD* GetFieldById( int aFieldId );
|
||||
SCH_FIELD* GetField( const wxString& aFieldName );
|
||||
const SCH_FIELD* GetField( const wxString& aFieldName ) const;
|
||||
|
||||
/**
|
||||
* Return a field in this symbol.
|
||||
*
|
||||
* @param aFieldName is the name of the field
|
||||
*
|
||||
* @return is the field with \a aFieldName or NULL if the field does not exist.
|
||||
*/
|
||||
SCH_FIELD* GetFieldByName( const wxString& aFieldName );
|
||||
|
||||
const SCH_FIELD* GetFieldByName( const wxString& aFieldName ) const;
|
||||
|
||||
/**
|
||||
* Populate a std::vector with SCH_FIELDs.
|
||||
* Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
|
||||
*
|
||||
* @param aVector is the vector to populate.
|
||||
* @param aVisibleOnly is used to add only the fields that are visible and contain text.
|
||||
*/
|
||||
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) override;
|
||||
void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const override;
|
||||
|
||||
/**
|
||||
* Return a vector of fields from the symbol
|
||||
* Return a reference to the vector holding the symbol's fields
|
||||
*/
|
||||
std::vector<SCH_FIELD>& GetFields() { return m_fields; }
|
||||
const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
|
||||
@@ -466,8 +448,8 @@ public:
|
||||
|
||||
/**
|
||||
* Remove a user field from the symbol.
|
||||
* @param aFieldName is the user fieldName to remove. Attempts to remove a mandatory
|
||||
* field or a non-existant field are silently ignored.
|
||||
*
|
||||
* @param aFieldName is the user fieldName to remove.
|
||||
*/
|
||||
void RemoveField( const wxString& aFieldName );
|
||||
|
||||
@@ -477,13 +459,10 @@ public:
|
||||
* Search for a #SCH_FIELD with \a aFieldName
|
||||
*
|
||||
* @param aFieldName is the name of the field to find.
|
||||
* @param aIncludeDefaultFields searches the library symbol default fields if true.
|
||||
* @param aCaseInsensitive ignore the filed name case if true.
|
||||
*
|
||||
* @return the field if found or NULL if the field was not found.
|
||||
*/
|
||||
SCH_FIELD* FindField( const wxString& aFieldName, bool aIncludeDefaultFields = true,
|
||||
bool aCaseInsensitive = false );
|
||||
SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
|
||||
|
||||
/**
|
||||
* @return the reference for the instance on the given sheet.
|
||||
|
||||
+5
-21
@@ -74,7 +74,7 @@ SCHEMATIC::SCHEMATIC( PROJECT* aPrj ) :
|
||||
|
||||
wxString newValue = aItem->Get<wxString>( aProperty );
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD )
|
||||
if( field->GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
symbol->SetRef( &sheetPath, newValue );
|
||||
|
||||
@@ -98,30 +98,14 @@ SCHEMATIC::SCHEMATIC( PROJECT* aPrj ) :
|
||||
{
|
||||
switch( field->GetId() )
|
||||
{
|
||||
case VALUE_FIELD:
|
||||
case FIELD_T::VALUE:
|
||||
case FIELD_T::FOOTPRINT:
|
||||
case FIELD_T::DATASHEET:
|
||||
{
|
||||
if( aCommit )
|
||||
aCommit->Modify( otherUnit, sheet.LastScreen() );
|
||||
|
||||
otherUnit->SetValueFieldText( newValue );
|
||||
break;
|
||||
}
|
||||
|
||||
case FOOTPRINT_FIELD:
|
||||
{
|
||||
if( aCommit )
|
||||
aCommit->Modify( otherUnit, sheet.LastScreen() );
|
||||
|
||||
otherUnit->SetFootprintFieldText( newValue );
|
||||
break;
|
||||
}
|
||||
|
||||
case DATASHEET_FIELD:
|
||||
{
|
||||
if( aCommit )
|
||||
aCommit->Modify( otherUnit, sheet.LastScreen() );
|
||||
|
||||
otherUnit->GetField( DATASHEET_FIELD )->SetText( newValue );
|
||||
otherUnit->GetField( field->GetId() )->SetText( newValue );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -475,7 +475,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( schItem );
|
||||
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem->GetParent() );
|
||||
|
||||
if( field->GetId() == REFERENCE_FIELD )
|
||||
if( field->GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
// Lazy eval of sheet list; this is expensive even when unsorted
|
||||
if( sheets.empty() )
|
||||
|
||||
+1
-1
@@ -679,7 +679,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard()
|
||||
try
|
||||
{
|
||||
dc.SetUserScale( 1.0, 1.0 );
|
||||
SCH_PRINTOUT printout( this, wxEmptyString, true );
|
||||
SCH_PRINTOUT printout( this, wxEmptyString );
|
||||
// Ensure title block will be when printed on clipboard, regardless
|
||||
// the current Cairo print option
|
||||
EESCHEMA_SETTINGS* eecfg = eeconfig();
|
||||
|
||||
@@ -191,15 +191,14 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
|
||||
|
||||
for( const SCH_FIELD& field : aSymbol.GetFields() )
|
||||
{
|
||||
if( field.GetId() == REFERENCE_FIELD )
|
||||
if( field.GetId() == FIELD_T::REFERENCE )
|
||||
{
|
||||
fields.emplace_back( VECTOR2I(), -1, &aSymbol, field.GetName() );
|
||||
fields.emplace_back( VECTOR2I(), FIELD_T::USER, &aSymbol, field.GetName() );
|
||||
fields.back().SetText( aSymbol.GetRef( aSheetPath ) );
|
||||
}
|
||||
else if( field.GetId() == VALUE_FIELD
|
||||
|| field.GetName().StartsWith( wxS( "Sim." ) ) )
|
||||
else if( field.GetId() == FIELD_T::VALUE || field.GetName().StartsWith( wxS( "Sim." ) ) )
|
||||
{
|
||||
fields.emplace_back( VECTOR2I(), -1, &aSymbol, field.GetName() );
|
||||
fields.emplace_back( VECTOR2I(), FIELD_T::USER, &aSymbol, field.GetName() );
|
||||
fields.back().SetText( field.GetShownText( aSheetPath, false ) );
|
||||
}
|
||||
}
|
||||
@@ -213,7 +212,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
|
||||
return &field;
|
||||
}
|
||||
|
||||
fields.emplace_back( &aSymbol, -1, name );
|
||||
fields.emplace_back( &aSymbol, FIELD_T::USER, name );
|
||||
return &fields.back();
|
||||
};
|
||||
|
||||
@@ -258,8 +257,8 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const std::vector<SCH_FIELD>& aFiel
|
||||
const std::vector<SCH_PIN*>& aPins, bool aResolved,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
std::string libraryPath = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
std::string baseModelName = SIM_MODEL::GetFieldValue( &aFields, SIM_LIBRARY::NAME_FIELD );
|
||||
std::string libraryPath = GetFieldValue( &aFields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
std::string baseModelName = GetFieldValue( &aFields, SIM_LIBRARY::NAME_FIELD );
|
||||
|
||||
if( libraryPath != "" )
|
||||
{
|
||||
|
||||
+26
-93
@@ -407,11 +407,13 @@ TYPE SIM_MODEL::ReadTypeFromFields( const std::vector<SCH_FIELD>& aFields, REPOR
|
||||
if( typeFieldValue.empty() )
|
||||
return TYPE::NONE;
|
||||
|
||||
if( aFields.size() > REFERENCE_FIELD )
|
||||
wxString reference = GetFieldValue( &aFields, FIELD_T::REFERENCE );
|
||||
|
||||
if( !reference.IsEmpty() )
|
||||
{
|
||||
aReporter.Report( wxString::Format( _( "No simulation model definition found for "
|
||||
"symbol '%s'." ),
|
||||
aFields[REFERENCE_FIELD].GetText() ),
|
||||
reference ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
else
|
||||
@@ -473,22 +475,6 @@ void SIM_MODEL::WriteFields( std::vector<SCH_FIELD>& aFields ) const
|
||||
|
||||
if( IsStoredInValue() )
|
||||
SetFieldValue( aFields, SIM_VALUE_FIELD, m_serializer->GenerateValue(), false );
|
||||
|
||||
int lastFreeId = MANDATORY_FIELD_COUNT;
|
||||
|
||||
// Search for the first available value:
|
||||
for( auto& fld : aFields )
|
||||
{
|
||||
if( fld.GetId() >= lastFreeId )
|
||||
lastFreeId = fld.GetId() + 1;
|
||||
}
|
||||
|
||||
// Set undefined IDs to a better value
|
||||
for( auto& fld : aFields )
|
||||
{
|
||||
if( fld.GetId() < 0 )
|
||||
fld.SetId( lastFreeId++ );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -592,7 +578,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL* aBaseModel,
|
||||
{
|
||||
aReporter.Report( wxString::Format( _( "Error reading simulation model from "
|
||||
"symbol '%s':\n%s" ),
|
||||
aFields[REFERENCE_FIELD].GetText(),
|
||||
GetFieldValue( &aFields, FIELD_T::REFERENCE ),
|
||||
err.Problem() ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
@@ -640,7 +626,7 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<SCH_FIELD>& aFie
|
||||
// We own the pin syntax, so if we can't parse it then there's an error.
|
||||
aReporter.Report( wxString::Format( _( "Error reading simulation model from "
|
||||
"symbol '%s':\n%s" ),
|
||||
aFields[REFERENCE_FIELD].GetText(),
|
||||
GetFieldValue( &aFields, FIELD_T::REFERENCE ),
|
||||
err.Problem() ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
}
|
||||
@@ -650,59 +636,6 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const std::vector<SCH_FIELD>& aFie
|
||||
}
|
||||
|
||||
|
||||
std::string SIM_MODEL::GetFieldValue( const std::vector<SCH_FIELD>* aFields,
|
||||
const wxString& aFieldName, bool aResolve )
|
||||
{
|
||||
if( !aFields )
|
||||
return ""; // Should not happen, T=void specialization will be called instead.
|
||||
|
||||
for( const SCH_FIELD& field : *aFields )
|
||||
{
|
||||
if( field.GetName() == aFieldName )
|
||||
{
|
||||
return aResolve ? field.GetShownText( false ).ToStdString()
|
||||
: field.GetText().ToStdString();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void SIM_MODEL::SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString& aFieldName,
|
||||
const std::string& aValue, bool aIsVisible )
|
||||
{
|
||||
auto fieldIt = std::find_if( aFields.begin(), aFields.end(),
|
||||
[&]( const SCH_FIELD& f )
|
||||
{
|
||||
return f.GetName() == aFieldName;
|
||||
} );
|
||||
|
||||
if( fieldIt != aFields.end() )
|
||||
{
|
||||
if( aValue == "" )
|
||||
{
|
||||
aFields.erase( fieldIt );
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldIt->SetText( aValue );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( aValue == "" )
|
||||
return;
|
||||
|
||||
SCH_ITEM* parent = static_cast<SCH_ITEM*>( aFields.at( 0 ).GetParent() );
|
||||
aFields.emplace_back( VECTOR2I(), aFields.size(), parent, aFieldName );
|
||||
|
||||
aFields.back().SetText( aValue );
|
||||
aFields.back().SetVisible( aIsVisible );
|
||||
}
|
||||
|
||||
|
||||
SIM_MODEL::~SIM_MODEL() = default;
|
||||
|
||||
|
||||
@@ -1436,7 +1369,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
|
||||
SCH_FIELD CreateField( T* aSymbol, const wxString& aFieldName )
|
||||
{
|
||||
SCH_FIELD field( aSymbol, -1, aFieldName );
|
||||
SCH_FIELD field( aSymbol, FIELD_T::USER, aFieldName );
|
||||
|
||||
field.SetText( m_Text );
|
||||
field.SetVisible( m_Visible );
|
||||
@@ -1453,10 +1386,10 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
VECTOR2I m_Pos;
|
||||
};
|
||||
|
||||
SCH_FIELD* existing_deviceField = aSymbol.FindField( SIM_DEVICE_FIELD );
|
||||
SCH_FIELD* existing_deviceSubtypeField = aSymbol.FindField( SIM_DEVICE_SUBTYPE_FIELD );
|
||||
SCH_FIELD* existing_pinsField = aSymbol.FindField( SIM_PINS_FIELD );
|
||||
SCH_FIELD* existing_paramsField = aSymbol.FindField( SIM_PARAMS_FIELD );
|
||||
SCH_FIELD* existing_deviceField = aSymbol.GetField( SIM_DEVICE_FIELD );
|
||||
SCH_FIELD* existing_deviceSubtypeField = aSymbol.GetField( SIM_DEVICE_SUBTYPE_FIELD );
|
||||
SCH_FIELD* existing_pinsField = aSymbol.GetField( SIM_PINS_FIELD );
|
||||
SCH_FIELD* existing_paramsField = aSymbol.GetField( SIM_PARAMS_FIELD );
|
||||
|
||||
wxString existing_deviceSubtype;
|
||||
|
||||
@@ -1574,7 +1507,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
};
|
||||
|
||||
wxString prefix = aSymbol.GetPrefix();
|
||||
SCH_FIELD* valueField = aSymbol.FindField( wxT( "Value" ) );
|
||||
SCH_FIELD* valueField = aSymbol.GetField( FIELD_T::VALUE );
|
||||
std::vector<SCH_PIN*> sourcePins = aSymbol.GetPins();
|
||||
bool sourcePinsSorted = false;
|
||||
|
||||
@@ -1601,19 +1534,19 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
FIELD_INFO pinMapInfo;
|
||||
bool modelFromValueField = false;
|
||||
|
||||
if( aSymbol.FindField( SIM_LEGACY_PRIMITIVE_FIELD )
|
||||
|| aSymbol.FindField( SIM_LEGACY_PINS_FIELD )
|
||||
|| aSymbol.FindField( SIM_LEGACY_MODEL_FIELD )
|
||||
|| aSymbol.FindField( SIM_LEGACY_ENABLE_FIELD )
|
||||
|| aSymbol.FindField( SIM_LEGACY_LIBRARY_FIELD ) )
|
||||
if( aSymbol.GetField( SIM_LEGACY_PRIMITIVE_FIELD )
|
||||
|| aSymbol.GetField( SIM_LEGACY_PINS_FIELD )
|
||||
|| aSymbol.GetField( SIM_LEGACY_MODEL_FIELD )
|
||||
|| aSymbol.GetField( SIM_LEGACY_ENABLE_FIELD )
|
||||
|| aSymbol.GetField( SIM_LEGACY_LIBRARY_FIELD ) )
|
||||
{
|
||||
if( SCH_FIELD* primitiveField = aSymbol.FindField( SIM_LEGACY_PRIMITIVE_FIELD ) )
|
||||
if( SCH_FIELD* primitiveField = aSymbol.GetField( SIM_LEGACY_PRIMITIVE_FIELD ) )
|
||||
{
|
||||
deviceInfo = FIELD_INFO( primitiveField->GetText(), primitiveField );
|
||||
aSymbol.RemoveField( primitiveField );
|
||||
}
|
||||
|
||||
if( SCH_FIELD* nodeSequenceField = aSymbol.FindField( SIM_LEGACY_PINS_FIELD ) )
|
||||
if( SCH_FIELD* nodeSequenceField = aSymbol.GetField( SIM_LEGACY_PINS_FIELD ) )
|
||||
{
|
||||
const wxString delimiters( "{:,; }" );
|
||||
const wxString& nodeSequence = nodeSequenceField->GetText();
|
||||
@@ -1639,7 +1572,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
aSymbol.RemoveField( nodeSequenceField );
|
||||
}
|
||||
|
||||
if( SCH_FIELD* modelField = aSymbol.FindField( SIM_LEGACY_MODEL_FIELD ) )
|
||||
if( SCH_FIELD* modelField = aSymbol.GetField( SIM_LEGACY_MODEL_FIELD ) )
|
||||
{
|
||||
modelInfo = FIELD_INFO( getSIValue( modelField ), modelField );
|
||||
aSymbol.RemoveField( modelField );
|
||||
@@ -1650,7 +1583,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
modelFromValueField = true;
|
||||
}
|
||||
|
||||
if( SCH_FIELD* libFileField = aSymbol.FindField( SIM_LEGACY_LIBRARY_FIELD ) )
|
||||
if( SCH_FIELD* libFileField = aSymbol.GetField( SIM_LEGACY_LIBRARY_FIELD ) )
|
||||
{
|
||||
libInfo = FIELD_INFO( libFileField->GetText(), libFileField );
|
||||
aSymbol.RemoveField( libFileField );
|
||||
@@ -1660,17 +1593,17 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
{
|
||||
// Auto convert some legacy fields used in the middle of 7.0 development...
|
||||
|
||||
if( SCH_FIELD* legacyType = aSymbol.FindField( wxT( "Sim_Type" ) ) )
|
||||
if( SCH_FIELD* legacyType = aSymbol.GetField( wxT( "Sim_Type" ) ) )
|
||||
{
|
||||
legacyType->SetName( SIM_DEVICE_SUBTYPE_FIELD );
|
||||
}
|
||||
|
||||
if( SCH_FIELD* legacyDevice = aSymbol.FindField( wxT( "Sim_Device" ) ) )
|
||||
if( SCH_FIELD* legacyDevice = aSymbol.GetField( wxT( "Sim_Device" ) ) )
|
||||
{
|
||||
legacyDevice->SetName( SIM_DEVICE_FIELD );
|
||||
}
|
||||
|
||||
if( SCH_FIELD* legacyPins = aSymbol.FindField( wxT( "Sim_Pins" ) ) )
|
||||
if( SCH_FIELD* legacyPins = aSymbol.GetField( wxT( "Sim_Pins" ) ) )
|
||||
{
|
||||
bool isPassive = prefix.StartsWith( wxT( "R" ) )
|
||||
|| prefix.StartsWith( wxT( "L" ) )
|
||||
@@ -1716,7 +1649,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
legacyPins->SetText( pinMap );
|
||||
}
|
||||
|
||||
if( SCH_FIELD* legacyParams = aSymbol.FindField( wxT( "Sim_Params" ) ) )
|
||||
if( SCH_FIELD* legacyParams = aSymbol.GetField( wxT( "Sim_Params" ) ) )
|
||||
{
|
||||
legacyParams->SetName( SIM_PARAMS_FIELD );
|
||||
}
|
||||
@@ -1921,7 +1854,7 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||
if( modelFromValueField )
|
||||
{
|
||||
// Get the current Value field, after previous changes.
|
||||
valueField = aSymbol.FindField( wxT( "Value" ) );
|
||||
valueField = aSymbol.GetField( FIELD_T::VALUE );
|
||||
|
||||
if( valueField )
|
||||
valueField->SetText( wxT( "${SIM.PARAMS}" ) );
|
||||
|
||||
@@ -425,13 +425,6 @@ public:
|
||||
const std::vector<SCH_PIN*>& aPins,
|
||||
bool aResolved, REPORTER& aReporter );
|
||||
|
||||
static std::string GetFieldValue( const std::vector<SCH_FIELD>* aFields,
|
||||
const wxString& aFieldName,
|
||||
bool aResolve = true );
|
||||
|
||||
static void SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString& aFieldName,
|
||||
const std::string& aValue, bool aIsVisible = true );
|
||||
|
||||
const SPICE_GENERATOR& SpiceGenerator() const { return *m_spiceGenerator; }
|
||||
const SIM_MODEL_SERIALIZER& Serializer() const { return *m_serializer; }
|
||||
|
||||
|
||||
@@ -56,11 +56,11 @@ std::string SPICE_GENERATOR_IBIS::IbisDevice( const SPICE_ITEM& aItem, SCHEMATIC
|
||||
const wxString& aCacheDir,
|
||||
REPORTER& aReporter ) const
|
||||
{
|
||||
std::string ibisLibFilename = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
std::string ibisCompName = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY::NAME_FIELD );
|
||||
std::string ibisPinName = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::PIN_FIELD );
|
||||
std::string ibisModelName = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::MODEL_FIELD );
|
||||
bool diffMode = SIM_MODEL::GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::DIFF_FIELD ) == "1";
|
||||
std::string ibisLibFilename = GetFieldValue( &aItem.fields, SIM_LIBRARY::LIBRARY_FIELD );
|
||||
std::string ibisCompName = GetFieldValue( &aItem.fields, SIM_LIBRARY::NAME_FIELD );
|
||||
std::string ibisPinName = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::PIN_FIELD );
|
||||
std::string ibisModelName = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::MODEL_FIELD );
|
||||
bool diffMode = GetFieldValue( &aItem.fields, SIM_LIBRARY_IBIS::DIFF_FIELD ) == "1";
|
||||
|
||||
WX_STRING_REPORTER reporter;
|
||||
SIM_LIB_MGR mgr( &aSchematic->Prj(), aSchematic );
|
||||
|
||||
@@ -119,9 +119,6 @@ namespace SIM_MODEL_SERIALIZER_GRAMMAR
|
||||
class SIM_MODEL_SERIALIZER
|
||||
{
|
||||
public:
|
||||
static constexpr auto REFERENCE_FIELD = "Reference";
|
||||
static constexpr auto VALUE_FIELD = "Value";
|
||||
|
||||
virtual ~SIM_MODEL_SERIALIZER() = default;
|
||||
SIM_MODEL_SERIALIZER( SIM_MODEL& aModel ) : m_model( aModel ) {}
|
||||
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ public:
|
||||
virtual const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
|
||||
bool aAllowExtraText ) const = 0;
|
||||
|
||||
virtual void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) = 0;
|
||||
virtual void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const = 0;
|
||||
|
||||
virtual std::vector<SCH_PIN*> GetPins() const = 0;
|
||||
|
||||
|
||||
@@ -1737,11 +1737,10 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol )
|
||||
|
||||
std::vector<SCH_FIELD> fullSetOfFields;
|
||||
|
||||
for( int i = 0; i < (int) aSymbol->GetFields().size(); ++i )
|
||||
for( const SCH_FIELD& field : aSymbol->GetFields() )
|
||||
{
|
||||
const SCH_FIELD& field = aSymbol->GetFields()[i];
|
||||
VECTOR2I pos = field.GetPosition() - aSymbol->GetPosition();
|
||||
SCH_FIELD libField( symbol.get(), field.GetId() );
|
||||
VECTOR2I pos = field.GetPosition() - aSymbol->GetPosition();
|
||||
SCH_FIELD libField( symbol.get(), field.GetId() );
|
||||
|
||||
libField = field;
|
||||
|
||||
@@ -1783,7 +1782,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( SCH_SYMBOL* aSymbol )
|
||||
|
||||
m_isSymbolFromSchematic = true;
|
||||
m_schematicSymbolUUID = aSymbol->m_Uuid;
|
||||
m_reference = symbol->GetFieldById( REFERENCE_FIELD )->GetText();
|
||||
m_reference = symbol->GetReferenceField().GetText();
|
||||
m_unit = std::max( 1, aSymbol->GetUnit() );
|
||||
m_bodyStyle = std::max( 1, aSymbol->GetBodyStyle() );
|
||||
|
||||
|
||||
@@ -439,37 +439,34 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol( const wxString& aInheritFrom )
|
||||
new_symbol.SetParent( parent );
|
||||
|
||||
// Inherit the parent mandatory field attributes.
|
||||
for( int fieldId : MANDATORY_FIELDS )
|
||||
for( FIELD_T fieldId : MANDATORY_FIELDS )
|
||||
{
|
||||
SCH_FIELD* field = new_symbol.GetFieldById( fieldId );
|
||||
|
||||
// the MANDATORY_FIELD_COUNT are exactly that in RAM.
|
||||
wxCHECK( field, /* void */ );
|
||||
|
||||
SCH_FIELD* parentField = parent->GetFieldById( fieldId );
|
||||
|
||||
wxCHECK( parentField, /* void */ );
|
||||
SCH_FIELD* field = new_symbol.GetField( fieldId );
|
||||
SCH_FIELD* parentField = parent->GetField( fieldId );
|
||||
|
||||
*field = *parentField;
|
||||
|
||||
switch( fieldId )
|
||||
{
|
||||
case REFERENCE_FIELD:
|
||||
case FIELD_T::REFERENCE:
|
||||
// parent's reference already copied
|
||||
break;
|
||||
|
||||
case VALUE_FIELD:
|
||||
case FIELD_T::VALUE:
|
||||
if( parent->IsPower() )
|
||||
field->SetText( name );
|
||||
break;
|
||||
|
||||
case FOOTPRINT_FIELD:
|
||||
case DATASHEET_FIELD:
|
||||
case FIELD_T::FOOTPRINT:
|
||||
case FIELD_T::DATASHEET:
|
||||
// - footprint might be the same as parent, but might not
|
||||
// - datasheet is most likely different
|
||||
// - probably best to play it safe and copy neither
|
||||
field->SetText( wxEmptyString );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
field->SetParent( &new_symbol );
|
||||
|
||||
@@ -89,9 +89,10 @@ void SCH_EDITOR_CONTROL::AssignFootprints( const std::string& aChangedSetOfRefer
|
||||
// For backwards-compatibility CvPcb currently updates all instances of a
|
||||
// symbol (even though it lists these instances separately).
|
||||
wxString oldfp = refs[ii].GetFootprint();
|
||||
SCH_FIELD* footprintField = symbol->GetField( FIELD_T::FOOTPRINT );
|
||||
|
||||
if( oldfp.IsEmpty() && symbol->GetField( FOOTPRINT_FIELD )->IsVisible() )
|
||||
symbol->GetField( FOOTPRINT_FIELD )->SetVisible( false );
|
||||
if( oldfp.IsEmpty() && footprintField->IsVisible() )
|
||||
footprintField->SetVisible( false );
|
||||
|
||||
if( oldfp != footprint )
|
||||
{
|
||||
@@ -99,8 +100,7 @@ void SCH_EDITOR_CONTROL::AssignFootprints( const std::string& aChangedSetOfRefer
|
||||
SCH_SCREEN* screen = refs[ii].GetSheetPath().LastScreen();
|
||||
|
||||
commit.Modify( symbol, screen );
|
||||
|
||||
symbol->SetFootprintFieldText( footprint );
|
||||
footprintField->SetText( footprint );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ bool SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile( const wxString& aFullFil
|
||||
symbol->SetFootprintFieldText( footprint );
|
||||
|
||||
if( aForceVisibilityState )
|
||||
symbol->GetField( FOOTPRINT_FIELD )->SetVisible( aVisibilityState );
|
||||
symbol->GetField( FIELD_T::FOOTPRINT )->SetVisible( aVisibilityState );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,11 +488,11 @@ void BACK_ANNOTATE::applyChangelist()
|
||||
{
|
||||
const wxString& fpFieldName = field.first;
|
||||
const wxString& fpFieldValue = field.second;
|
||||
SCH_FIELD* symField = symbol->FindField( fpFieldName );
|
||||
SCH_FIELD* symField = symbol->GetField( fpFieldName );
|
||||
|
||||
// Skip fields that are individually controlled
|
||||
if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD )
|
||||
|| fpFieldName == GetCanonicalFieldName( VALUE_FIELD ) )
|
||||
if( fpFieldName == GetCanonicalFieldName( FIELD_T::REFERENCE )
|
||||
|| fpFieldName == GetCanonicalFieldName( FIELD_T::VALUE ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -527,8 +527,8 @@ void BACK_ANNOTATE::applyChangelist()
|
||||
|
||||
if( !m_dryRun )
|
||||
{
|
||||
SCH_FIELD newField( symbol->GetPosition(), symbol->GetNextFieldId(),
|
||||
symbol, fpFieldName );
|
||||
SCH_FIELD newField( symbol->GetPosition(), FIELD_T::USER, symbol,
|
||||
fpFieldName );
|
||||
newField.SetText( fpFieldValue );
|
||||
newField.SetVisible( false ); // Don't clutter up the schematic
|
||||
symbol->AddField( newField );
|
||||
@@ -540,28 +540,22 @@ void BACK_ANNOTATE::applyChangelist()
|
||||
|
||||
// 3. Existing field has been deleted from footprint and needs to be deleted from symbol
|
||||
// Check all symbol fields for existence in the footprint field map
|
||||
for( int ii = symbol->GetFieldCount() - 1; ii >= 0; --ii )
|
||||
for( SCH_FIELD& field : symbol->GetFields() )
|
||||
{
|
||||
SCH_FIELD* field = symbol->GetFieldById( ii );
|
||||
|
||||
if( !field )
|
||||
continue;
|
||||
|
||||
// Never delete mandatory fields
|
||||
if( field->IsMandatory() )
|
||||
if( field.IsMandatory() )
|
||||
continue;
|
||||
|
||||
if( fpData.m_fieldsMap.find( field->GetCanonicalName() )
|
||||
== fpData.m_fieldsMap.end() )
|
||||
if( fpData.m_fieldsMap.find( field.GetCanonicalName() ) == fpData.m_fieldsMap.end() )
|
||||
{
|
||||
// Field not found in footprint field map, delete it
|
||||
m_changesCount++;
|
||||
msg.Printf( _( "Delete %s field '%s.'" ),
|
||||
ref.GetRef(),
|
||||
EscapeHTML( field->GetCanonicalName() ) );
|
||||
EscapeHTML( field.GetName() ) );
|
||||
|
||||
if( !m_dryRun )
|
||||
symbol->RemoveField( field );
|
||||
symbol->RemoveField( symbol->GetField( field.GetName() ) );
|
||||
|
||||
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ void EE_INSPECTION_TOOL::DiffSymbol( SCH_SYMBOL* symbol )
|
||||
dialog->DeleteAllPages();
|
||||
|
||||
wxString symbolDesc = wxString::Format( _( "Symbol %s" ),
|
||||
symbol->GetField( REFERENCE_FIELD )->GetText() );
|
||||
symbol->GetField( FIELD_T::REFERENCE )->GetText() );
|
||||
LIB_ID libId = symbol->GetLibId();
|
||||
wxString libName = libId.GetLibNickname();
|
||||
wxString symbolName = libId.GetLibItemName();
|
||||
@@ -532,7 +532,7 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
|
||||
return 0;
|
||||
|
||||
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
|
||||
SCH_FIELD* field = symbol->GetField( DATASHEET_FIELD );
|
||||
SCH_FIELD* field = symbol->GetField( FIELD_T::DATASHEET );
|
||||
|
||||
// Use GetShownText() to resolve any text variables, but don't allow adding extra text
|
||||
// (ie: the field name)
|
||||
|
||||
@@ -1594,6 +1594,7 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||
SCHEMATIC_SETTINGS& settings = schematic->Settings();
|
||||
SCH_TEXT* textItem = nullptr;
|
||||
SCH_LABEL_BASE* labelItem = nullptr;
|
||||
SCH_GLOBALLABEL* globalLabel = nullptr;
|
||||
wxString netName;
|
||||
|
||||
switch( aType )
|
||||
@@ -1614,9 +1615,8 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||
case LAYER_NETCLASS_REFS:
|
||||
labelItem = new SCH_DIRECTIVE_LABEL( aPosition );
|
||||
labelItem->SetShape( m_lastNetClassFlagShape );
|
||||
labelItem->GetFields().emplace_back( SCH_FIELD( {0,0}, 0, labelItem, wxT( "Netclass" ) ) );
|
||||
labelItem->GetFields().emplace_back(
|
||||
SCH_FIELD( { 0, 0 }, 0, labelItem, wxT( "Component Class" ) ) );
|
||||
labelItem->GetFields().emplace_back( VECTOR2I(), FIELD_T::USER, labelItem, wxT( "Netclass" ) );
|
||||
labelItem->GetFields().emplace_back( VECTOR2I(), FIELD_T::USER, labelItem, wxT( "Component Class" ) );
|
||||
labelItem->GetFields().back().SetItalic( true );
|
||||
labelItem->GetFields().back().SetVisible( true );
|
||||
textItem = labelItem;
|
||||
@@ -1630,11 +1630,11 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||
break;
|
||||
|
||||
case LAYER_GLOBLABEL:
|
||||
labelItem = new SCH_GLOBALLABEL( aPosition );
|
||||
labelItem->SetShape( m_lastGlobalLabelShape );
|
||||
labelItem->GetFields()[0].SetVisible( settings.m_IntersheetRefsShow );
|
||||
labelItem->SetAutoRotateOnPlacement( m_lastAutoLabelRotateOnPlacement );
|
||||
textItem = labelItem;
|
||||
globalLabel = new SCH_GLOBALLABEL( aPosition );
|
||||
globalLabel->SetShape( m_lastGlobalLabelShape );
|
||||
globalLabel->GetField( FIELD_T::INTERSHEET_REFS )->SetVisible( settings.m_IntersheetRefsShow );
|
||||
globalLabel->SetAutoRotateOnPlacement( m_lastAutoLabelRotateOnPlacement );
|
||||
textItem = globalLabel;
|
||||
|
||||
if( SCH_LINE* wire = findWire( aPosition ) )
|
||||
netName = findWireLabelDriverName( wire );
|
||||
@@ -3026,35 +3026,30 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxFileName fn( filename );
|
||||
|
||||
sheet->GetFields()[SHEETNAME].SetText( fn.GetName() );
|
||||
sheet->GetFields()[SHEETFILENAME].SetText( fn.GetName() + wxT( "." )
|
||||
+ FILEEXT::KiCadSchematicFileExtension );
|
||||
sheet->GetField( FIELD_T::SHEET_NAME )->SetText( fn.GetName() );
|
||||
sheet->GetField( FIELD_T::SHEET_FILENAME )->SetText( fn.GetName() + wxT( "." ) + FILEEXT::KiCadSchematicFileExtension );
|
||||
}
|
||||
else if( isDrawSheetFromDesignBlock )
|
||||
{
|
||||
wxFileName fn( filename );
|
||||
|
||||
sheet->GetFields()[SHEETNAME].SetText( designBlock->GetLibId().GetLibItemName() );
|
||||
sheet->GetFields()[SHEETFILENAME].SetText( fn.GetName() + wxT( "." )
|
||||
+ FILEEXT::KiCadSchematicFileExtension );
|
||||
sheet->GetField( FIELD_T::SHEET_NAME )->SetText( designBlock->GetLibId().GetLibItemName() );
|
||||
sheet->GetField( FIELD_T::SHEET_FILENAME )->SetText( fn.GetName() + wxT( "." ) + FILEEXT::KiCadSchematicFileExtension );
|
||||
|
||||
std::vector<SCH_FIELD>& sheetFields = sheet->GetFields();
|
||||
|
||||
// Copy default fields into the sheet
|
||||
for( const auto& field : designBlock->GetFields() )
|
||||
for( const auto& [fieldName, fieldValue] : designBlock->GetFields() )
|
||||
{
|
||||
SCH_FIELD newField( sheet, sheetFields.size(), field.first );
|
||||
newField.SetText( field.second );
|
||||
newField.SetVisible( false );
|
||||
|
||||
sheetFields.emplace_back( newField );
|
||||
sheetFields.emplace_back( sheet, FIELD_T::USER, fieldName );
|
||||
sheetFields.back().SetText( fieldValue );
|
||||
sheetFields.back().SetVisible( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sheet->GetFields()[SHEETNAME].SetText( wxT( "Untitled Sheet" ) );
|
||||
sheet->GetFields()[SHEETFILENAME].SetText(
|
||||
wxString::Format( wxT( "untitled.%s" ), FILEEXT::KiCadSchematicFileExtension ) );
|
||||
sheet->GetField( FIELD_T::SHEET_NAME )->SetText( wxT( "Untitled Sheet" ) );
|
||||
sheet->GetField( FIELD_T::SHEET_FILENAME )->SetText( wxString::Format( wxT( "untitled.%s" ), FILEEXT::KiCadSchematicFileExtension ) );
|
||||
}
|
||||
|
||||
sheet->SetFlags( IS_NEW | IS_MOVING );
|
||||
|
||||
@@ -1808,21 +1808,17 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
|
||||
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
||||
commit.Modify( aField, m_frame->GetScreen() );
|
||||
|
||||
if( parentType == SCH_SYMBOL_T && aField->GetId() == REFERENCE_FIELD )
|
||||
if( parentType == SCH_SYMBOL_T && aField->GetId() == FIELD_T::REFERENCE )
|
||||
static_cast<SCH_ITEM*>( aField->GetParent() )->SetConnectivityDirty();
|
||||
|
||||
wxString caption;
|
||||
|
||||
// Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
|
||||
if( parentType == SCH_SYMBOL_T && aField->IsMandatory() )
|
||||
if( aField->IsMandatory() )
|
||||
{
|
||||
wxString fieldName = GetDefaultFieldName( aField->GetId(), DO_TRANSLATE );
|
||||
caption.Printf( _( "Edit %s Field" ), TitleCaps( fieldName ) );
|
||||
}
|
||||
else if( parentType == SCH_SHEET_T && aField->IsMandatory() )
|
||||
{
|
||||
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
|
||||
@@ -1866,9 +1862,9 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
||||
|
||||
if( ( aEvent.IsAction( &EE_ACTIONS::editReference ) && field->GetId() != REFERENCE_FIELD )
|
||||
|| ( aEvent.IsAction( &EE_ACTIONS::editValue ) && field->GetId() != VALUE_FIELD )
|
||||
|| ( aEvent.IsAction( &EE_ACTIONS::editFootprint ) && field->GetId() != FOOTPRINT_FIELD ) )
|
||||
if( ( aEvent.IsAction( &EE_ACTIONS::editReference ) && field->GetId() != FIELD_T::REFERENCE )
|
||||
|| ( aEvent.IsAction( &EE_ACTIONS::editValue ) && field->GetId() != FIELD_T::VALUE )
|
||||
|| ( aEvent.IsAction( &EE_ACTIONS::editFootprint ) && field->GetId() != FIELD_T::FOOTPRINT ) )
|
||||
{
|
||||
item = field->GetParentSymbol();
|
||||
m_selectionTool->ClearSelection( true );
|
||||
@@ -1882,16 +1878,16 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
|
||||
|
||||
if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
|
||||
{
|
||||
editFieldText( symbol->GetField( REFERENCE_FIELD ) );
|
||||
editFieldText( symbol->GetField( FIELD_T::REFERENCE ) );
|
||||
}
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
|
||||
{
|
||||
editFieldText( symbol->GetField( VALUE_FIELD ) );
|
||||
editFieldText( symbol->GetField( FIELD_T::VALUE ) );
|
||||
}
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
|
||||
{
|
||||
if( !symbol->IsPower() )
|
||||
editFieldText( symbol->GetField( FOOTPRINT_FIELD ) );
|
||||
editFieldText( symbol->GetField( FIELD_T::FOOTPRINT ) );
|
||||
}
|
||||
}
|
||||
else if( item->Type() == SCH_FIELD_T )
|
||||
@@ -1911,16 +1907,16 @@ int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( aEvent.IsAction( &EE_ACTIONS::editReference ) )
|
||||
{
|
||||
editFieldText( symbol->GetField( REFERENCE_FIELD ) );
|
||||
editFieldText( symbol->GetField( FIELD_T::REFERENCE ) );
|
||||
}
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::editValue ) )
|
||||
{
|
||||
editFieldText( symbol->GetField( VALUE_FIELD ) );
|
||||
editFieldText( symbol->GetField( FIELD_T::VALUE ) );
|
||||
}
|
||||
else if( aEvent.IsAction( &EE_ACTIONS::editFootprint ) )
|
||||
{
|
||||
if( !symbol->IsPower() )
|
||||
editFieldText( symbol->GetField( FOOTPRINT_FIELD ) );
|
||||
editFieldText( symbol->GetField( FIELD_T::FOOTPRINT ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2647,7 +2643,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||
// or not.
|
||||
if( !dynamic_cast<SCH_LABEL_BASE*>( item ) )
|
||||
{
|
||||
SCH_FIELD netclass( position, 0, new_label, wxT( "Netclass" ) );
|
||||
SCH_FIELD netclass( position, FIELD_T::USER, new_label, wxT( "Netclass" ) );
|
||||
netclass.SetText( txt );
|
||||
netclass.SetVisible( true );
|
||||
new_label->GetFields().push_back( netclass );
|
||||
@@ -2750,18 +2746,14 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
new_label->AddFields( label->GetFields() );
|
||||
|
||||
// A SCH_GLOBALLABEL has a specific field, that has no meaning for
|
||||
// other labels, and expected to be the first field in list.
|
||||
// It is the first field in list for this kind of label
|
||||
// So remove field named "Intersheetrefs" if exists for other labels
|
||||
int min_idx = new_label->Type() == SCH_GLOBAL_LABEL_T ? 1 : 0;
|
||||
std::vector<SCH_FIELD>& fields = new_label->GetFields();
|
||||
|
||||
for( int ii = fields.size()-1; ii >= min_idx; ii-- )
|
||||
{
|
||||
if( fields[ii].GetCanonicalName() == wxT( "Intersheetrefs" ) )
|
||||
fields.erase( fields.begin() + ii );
|
||||
}
|
||||
// A SCH_GLOBALLABEL has a specific field for intersheet references that has
|
||||
// no meaning for other labels
|
||||
alg::delete_if( new_label->GetFields(),
|
||||
[&]( SCH_FIELD& field )
|
||||
{
|
||||
return field.GetId() == FIELD_T::INTERSHEET_REFS
|
||||
&& new_label->Type() != SCH_GLOBAL_LABEL_T;
|
||||
} );
|
||||
}
|
||||
|
||||
if( selected )
|
||||
|
||||
@@ -1164,21 +1164,21 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( SCH_CONNECTION* pinConn = symbol->GetPins()[0]->Connection() )
|
||||
{
|
||||
std::vector<SCH_FIELD>& fields = symbol->GetFields();
|
||||
|
||||
for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
|
||||
for( FIELD_T id : { FIELD_T::REFERENCE, FIELD_T::VALUE } )
|
||||
{
|
||||
if( !fields[id].IsVisible() )
|
||||
SCH_FIELD* field = symbol->GetField( id );
|
||||
|
||||
if( !field->IsVisible() )
|
||||
continue;
|
||||
|
||||
if( !fields[id].IsBrightened() && connNames.count( pinConn->Name() ) )
|
||||
if( !field->IsBrightened() && connNames.count( pinConn->Name() ) )
|
||||
{
|
||||
fields[id].SetBrightened();
|
||||
field->SetBrightened();
|
||||
redrawItem = symbol;
|
||||
}
|
||||
else if( fields[id].IsBrightened() && !connNames.count( pinConn->Name() ) )
|
||||
else if( field->IsBrightened() && !connNames.count( pinConn->Name() ) )
|
||||
{
|
||||
fields[id].ClearBrightened();
|
||||
field->ClearBrightened();
|
||||
redrawItem = symbol;
|
||||
}
|
||||
}
|
||||
@@ -1499,12 +1499,12 @@ void SCH_EDITOR_CONTROL::updatePastedSymbol( SCH_SYMBOL* aSymbol,
|
||||
|
||||
// Some legacy versions saved value fields escaped. While we still do in the symbol
|
||||
// editor, we don't anymore in the schematic, so be sure to unescape them.
|
||||
SCH_FIELD* valueField = aSymbol->GetField( VALUE_FIELD );
|
||||
SCH_FIELD* valueField = aSymbol->GetField( FIELD_T::VALUE );
|
||||
valueField->SetText( UnescapeString( valueField->GetText() ) );
|
||||
|
||||
// Pasted from notepad or an older instance of eeschema. Use the values in the fields
|
||||
// instead.
|
||||
newInstance.m_Reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
newInstance.m_Reference = aSymbol->GetField( FIELD_T::REFERENCE )->GetText();
|
||||
newInstance.m_Unit = aSymbol->GetUnit();
|
||||
}
|
||||
|
||||
@@ -1798,8 +1798,8 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||
if( item->Type() == SCH_SHEET_T )
|
||||
{
|
||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
|
||||
SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
|
||||
wxString baseName = nameField.GetText();
|
||||
SCH_FIELD* nameField = sheet->GetField( FIELD_T::SHEET_NAME );
|
||||
wxString baseName = nameField->GetText();
|
||||
wxFileName srcFn = sheet->GetFileName();
|
||||
|
||||
if( srcFn.IsRelative() )
|
||||
@@ -1909,8 +1909,8 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||
else if( item->Type() == SCH_SHEET_T )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||
SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
|
||||
wxString baseName = nameField.GetText();
|
||||
SCH_FIELD* nameField = sheet->GetField( FIELD_T::SHEET_NAME );
|
||||
wxString baseName = nameField->GetText();
|
||||
wxString candidateName = baseName;
|
||||
wxString number;
|
||||
|
||||
@@ -1931,7 +1931,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
||||
while( hierarchy.NameExists( candidateName ) )
|
||||
candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
|
||||
|
||||
nameField.SetText( candidateName );
|
||||
nameField->SetText( candidateName );
|
||||
|
||||
wxFileName fn = sheet->GetFileName();
|
||||
SCH_SCREEN* existingScreen = nullptr;
|
||||
|
||||
@@ -458,22 +458,9 @@ int SCH_FIND_REPLACE_TOOL::ReplaceAll( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
||||
|
||||
if( field->GetParent() && field->GetParent()->Type() == SCH_SYMBOL_T )
|
||||
{
|
||||
switch( field->GetId() )
|
||||
{
|
||||
case REFERENCE_FIELD:
|
||||
case VALUE_FIELD:
|
||||
case FOOTPRINT_FIELD:
|
||||
// must be handled for each distinct sheet
|
||||
doReplace( field, &sheets[ii], data );
|
||||
break;
|
||||
|
||||
default:
|
||||
// handled in first iteration
|
||||
break;
|
||||
}
|
||||
}
|
||||
// References must be handled for each distinct sheet
|
||||
if( field->GetId() == FIELD_T::REFERENCE )
|
||||
doReplace( field, &sheets[ii], data );
|
||||
}
|
||||
|
||||
item = nextMatch( screen, &sheets[ii], item, data, false );
|
||||
|
||||
@@ -526,8 +526,8 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent )
|
||||
|
||||
libSymbol->SetName( newName );
|
||||
|
||||
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
|
||||
if( libSymbol->GetValueField().GetText() == oldName )
|
||||
libSymbol->GetValueField().SetText( newName );
|
||||
|
||||
libMgr.UpdateSymbolAfterRename( libSymbol, newName, libName );
|
||||
libMgr.SetSymbolModified( newName, libName );
|
||||
@@ -545,8 +545,8 @@ int SYMBOL_EDITOR_CONTROL::RenameSymbol( const TOOL_EVENT& aEvent )
|
||||
|
||||
libSymbol->SetName( newName );
|
||||
|
||||
if( libSymbol->GetFieldById( VALUE_FIELD )->GetText() == oldName )
|
||||
libSymbol->GetFieldById( VALUE_FIELD )->SetText( newName );
|
||||
if( libSymbol->GetValueField().GetText() == oldName )
|
||||
libSymbol->GetValueField().SetText( newName );
|
||||
|
||||
editFrame->RebuildView();
|
||||
editFrame->OnModify();
|
||||
|
||||
@@ -132,7 +132,7 @@ void HIERARCHY_PANE::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItem
|
||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
|
||||
aList->push_back( sheet );
|
||||
|
||||
wxString sheetNameBase = sheet->GetFields()[SHEETNAME].GetShownText( false );
|
||||
wxString sheetNameBase = sheet->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
|
||||
wxString sheetName = formatPageString( sheetNameBase, aList->GetPageNumber() );
|
||||
wxString sheetNumber = aList->GetPageNumber();
|
||||
wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
|
||||
@@ -336,14 +336,14 @@ void HIERARCHY_PANE::UpdateLabelsHierarchyTree()
|
||||
std::function<void( const wxTreeItemId& )> updateLabel =
|
||||
[&]( const wxTreeItemId& id )
|
||||
{
|
||||
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
|
||||
SCH_SHEET* sheet = itemData->m_SheetPath.Last();
|
||||
wxString sheetNameLabel =
|
||||
formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ),
|
||||
itemData->m_SheetPath.GetPageNumber() );
|
||||
auto* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
|
||||
SCH_SHEET* sheet = itemData->m_SheetPath.Last();
|
||||
wxString sheetNameBase = sheet->GetField( FIELD_T::SHEET_NAME )->GetShownText( false );
|
||||
wxString sheetName = formatPageString( sheetNameBase,
|
||||
itemData->m_SheetPath.GetPageNumber() );
|
||||
|
||||
if( m_tree->GetItemText( id ) != sheetNameLabel )
|
||||
m_tree->SetItemText( id, sheetNameLabel );
|
||||
if( m_tree->GetItemText( id ) != sheetName )
|
||||
m_tree->SetItemText( id, sheetName );
|
||||
};
|
||||
|
||||
wxTreeItemId rootId = m_tree->GetRootItem();
|
||||
@@ -473,7 +473,7 @@ void HIERARCHY_PANE::onTreeEditFinished( wxTreeEvent& event )
|
||||
if( parentSheet )
|
||||
{
|
||||
SCH_COMMIT commit( m_frame );
|
||||
commit.Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
|
||||
commit.Modify( data->m_SheetPath.Last()->GetField( FIELD_T::SHEET_NAME ),
|
||||
parentSheet->GetScreen() );
|
||||
|
||||
data->m_SheetPath.Last()->SetName( newName );
|
||||
@@ -589,7 +589,7 @@ void HIERARCHY_PANE::renameIdenticalSheets( const SCH_SHEET_PATH& renamedSheet,
|
||||
if( parentSheet && data->m_SheetPath.Cmp( renamedSheet ) != 0
|
||||
&& data->m_SheetPath.Last() == renamedSheet.Last() )
|
||||
{
|
||||
commit->Modify( &data->m_SheetPath.Last()->GetFields()[SHEETNAME],
|
||||
commit->Modify( data->m_SheetPath.Last()->GetField( FIELD_T::SHEET_NAME ),
|
||||
parentSheet->GetScreen() );
|
||||
|
||||
data->m_SheetPath.Last()->SetName( newName );
|
||||
|
||||
@@ -146,12 +146,12 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
|
||||
{
|
||||
storageList.emplace_back( *symbol );
|
||||
|
||||
for( const std::pair<int, wxString>& fieldDef : i.Fields )
|
||||
for( const auto& [fieldType, fieldValue] : i.Fields )
|
||||
{
|
||||
SCH_FIELD* field = storageList.back().GetFieldById( fieldDef.first );
|
||||
SCH_FIELD* field = storageList.back().GetField( fieldType );
|
||||
|
||||
if( field )
|
||||
field->SetText( fieldDef.second );
|
||||
field->SetText( fieldValue );
|
||||
}
|
||||
|
||||
resultList.push_back( &storageList.back() );
|
||||
@@ -572,7 +572,7 @@ void PANEL_SYMBOL_CHOOSER::showFootprintFor( LIB_ID const& aLibId )
|
||||
if( !symbol )
|
||||
return;
|
||||
|
||||
SCH_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
|
||||
SCH_FIELD* fp_field = symbol->GetField( FIELD_T::FOOTPRINT );
|
||||
wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
|
||||
|
||||
showFootprint( fp_name );
|
||||
@@ -632,7 +632,7 @@ void PANEL_SYMBOL_CHOOSER::populateFootprintSelector( LIB_ID const& aLibId )
|
||||
if( symbol != nullptr )
|
||||
{
|
||||
int pinCount = symbol->GetPins( 0 /* all units */, 1 /* single bodyStyle */ ).size();
|
||||
SCH_FIELD* fp_field = symbol->GetFieldById( FOOTPRINT_FIELD );
|
||||
SCH_FIELD* fp_field = symbol->GetField( FIELD_T::FOOTPRINT );
|
||||
wxString fp_name = fp_field ? fp_field->GetFullText() : wxString( "" );
|
||||
|
||||
m_fp_sel_ctrl->FilterByPinCount( pinCount );
|
||||
@@ -653,12 +653,12 @@ void PANEL_SYMBOL_CHOOSER::onFootprintSelected( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_fp_override = aEvent.GetString();
|
||||
|
||||
alg::delete_if( m_field_edits, []( std::pair<int, wxString> const& i )
|
||||
alg::delete_if( m_field_edits, []( std::pair<FIELD_T, wxString> const& i )
|
||||
{
|
||||
return i.first == FOOTPRINT_FIELD;
|
||||
return i.first == FIELD_T::FOOTPRINT;
|
||||
} );
|
||||
|
||||
m_field_edits.emplace_back( std::make_pair( FOOTPRINT_FIELD, m_fp_override ) );
|
||||
m_field_edits.emplace_back( std::make_pair( FIELD_T::FOOTPRINT, m_fp_override ) );
|
||||
|
||||
showFootprint( m_fp_override );
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#ifndef PANEL_SYMBOL_CHOOSER_H
|
||||
#define PANEL_SYMBOL_CHOOSER_H
|
||||
|
||||
#include <template_fieldnames.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <symbol_tree_model_adapter.h>
|
||||
#include <footprint_info.h>
|
||||
@@ -92,9 +93,9 @@ public:
|
||||
/**
|
||||
* Get a list of fields edited by the user.
|
||||
*
|
||||
* @return vector of pairs; each.first = field ID, each.second = new value.
|
||||
* @return vector of pairs; each.first = field type, each.second = new value.
|
||||
*/
|
||||
std::vector<std::pair<int, wxString>> GetFields() const
|
||||
std::vector<std::pair<FIELD_T, wxString>> GetFields() const
|
||||
{
|
||||
return m_field_edits;
|
||||
}
|
||||
@@ -171,7 +172,7 @@ protected:
|
||||
bool m_show_footprints;
|
||||
wxString m_fp_override;
|
||||
|
||||
std::vector<std::pair<int, wxString>> m_field_edits;
|
||||
std::vector<std::pair<FIELD_T, wxString>> m_field_edits;
|
||||
};
|
||||
|
||||
#endif /* PANEL_SYMBOL_CHOOSER_H */
|
||||
|
||||
@@ -218,9 +218,9 @@ wxString SYMBOL_SEARCH_HANDLER::getResultCell( const SCH_SEARCH_HIT& aHit, int a
|
||||
if( aCol == 0 )
|
||||
return sym->GetRef( aHit.sheetPath, true );
|
||||
else if( aCol == 1 )
|
||||
return sym->GetField( VALUE_FIELD )->GetShownText( aHit.sheetPath, false );
|
||||
return sym->GetField( FIELD_T::VALUE )->GetShownText( aHit.sheetPath, false );
|
||||
else if( aCol == 2 )
|
||||
return sym->GetField( FOOTPRINT_FIELD )->GetShownText( aHit.sheetPath, false );
|
||||
return sym->GetField( FIELD_T::FOOTPRINT )->GetShownText( aHit.sheetPath, false );
|
||||
else if( aCol == 3 )
|
||||
return aHit.sheetPath->GetPageNumber();
|
||||
else if( aCol == 4 )
|
||||
@@ -299,7 +299,7 @@ wxString POWER_SEARCH_HANDLER::getResultCell( const SCH_SEARCH_HIT& aHit, int aC
|
||||
if( aCol == 0 )
|
||||
return sym->GetRef( aHit.sheetPath, true );
|
||||
else if( aCol == 1 )
|
||||
return sym->GetField( VALUE_FIELD )->GetShownText( aHit.sheetPath, false );
|
||||
return sym->GetField( FIELD_T::VALUE )->GetShownText( aHit.sheetPath, false );
|
||||
else if( aCol == 2 )
|
||||
return aHit.sheetPath->GetPageNumber();
|
||||
else if( aCol == 3 )
|
||||
|
||||
@@ -36,21 +36,33 @@ class TEMPLATE_FIELDNAMES_LEXER;
|
||||
*
|
||||
* The first fields are fixed fields and are defined by #MANDATORY_FIELDS. After that come
|
||||
* an unlimited number of user defined fields, only some of which have indices defined here.
|
||||
*
|
||||
* NOTE: this must stay a enum class to prevent developers from trying to use it as an array
|
||||
* index.
|
||||
*/
|
||||
enum MANDATORY_FIELD_T {
|
||||
INVALID_FIELD = -1, ///< The field ID hasn't been set yet; field is invalid
|
||||
REFERENCE_FIELD = 0, ///< Field Reference of part, i.e. "IC21"
|
||||
VALUE_FIELD, ///< Field Value of part, i.e. "3.3K"
|
||||
FOOTPRINT_FIELD, ///< Field Name Module PCB, i.e. "16DIP300"
|
||||
DATASHEET_FIELD, ///< name of datasheet
|
||||
DESCRIPTION_FIELD, ///< Field Description of part, i.e. "1/4W 1% Metal Film Resistor"
|
||||
|
||||
/// The first 5 are mandatory, and must be instantiated in SCH_COMPONENT, LIB_PART, and
|
||||
/// FOOTPRINT constructors
|
||||
MANDATORY_FIELD_COUNT
|
||||
enum class FIELD_T {
|
||||
USER, ///< The field ID hasn't been set yet; field is invalid
|
||||
REFERENCE, ///< Field Reference of part, i.e. "IC21"
|
||||
VALUE, ///< Field Value of part, i.e. "3.3K"
|
||||
FOOTPRINT, ///< Field Name Module PCB, i.e. "16DIP300"
|
||||
DATASHEET, ///< name of datasheet
|
||||
DESCRIPTION, ///< Field Description of part, i.e. "1/4W 1% Metal Film Resistor"
|
||||
INTERSHEET_REFS, ///< Global label cross-reference page numbers
|
||||
SHEET_NAME,
|
||||
SHEET_FILENAME,
|
||||
SHEET_USER
|
||||
};
|
||||
|
||||
#define MANDATORY_FIELDS { REFERENCE_FIELD, VALUE_FIELD, FOOTPRINT_FIELD, DATASHEET_FIELD, DESCRIPTION_FIELD }
|
||||
#define MANDATORY_FIELDS { FIELD_T::REFERENCE, \
|
||||
FIELD_T::VALUE, \
|
||||
FIELD_T::FOOTPRINT, \
|
||||
FIELD_T::DATASHEET, \
|
||||
FIELD_T::DESCRIPTION }
|
||||
|
||||
#define GLOBALLABEL_MANDATORY_FIELDS { FIELD_T::INTERSHEET_REFS }
|
||||
|
||||
#define SHEET_MANDATORY_FIELDS { FIELD_T::SHEET_NAME, \
|
||||
FIELD_T::SHEET_FILENAME }
|
||||
|
||||
// A helper to call GetDefaultFieldName with or without translation.
|
||||
// Translation should be used only to display field names in dialogs
|
||||
@@ -58,25 +70,20 @@ enum MANDATORY_FIELD_T {
|
||||
|
||||
|
||||
/**
|
||||
* Return a default symbol field name for field \a aFieldNdx for all components.
|
||||
* Return a default symbol field name for a mandatory field type.
|
||||
*
|
||||
* These field names are not modifiable but template field names are.
|
||||
*
|
||||
* @param aFieldNdx The field number index, > 0.
|
||||
* @param aTranslateForHI If true, return the translated field name,
|
||||
* else get the canonical name (defualt). Translation is intended only for dialogs
|
||||
*/
|
||||
wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI );
|
||||
wxString GetDefaultFieldName( FIELD_T aFieldId, bool aTranslateForHI );
|
||||
wxString GetUserFieldName( int aFieldNdx, bool aTranslateForHI );
|
||||
|
||||
|
||||
inline wxString GetCanonicalFieldName( int idx )
|
||||
inline wxString GetCanonicalFieldName( FIELD_T aFieldType )
|
||||
{
|
||||
// While TEMPLATE_FIELDNAME::GetDefaultFieldName() still works for non-mandatory fields,
|
||||
// it's confusing to call it through this function.
|
||||
wxASSERT( idx < MANDATORY_FIELD_COUNT );
|
||||
|
||||
return GetDefaultFieldName( idx, !DO_TRANSLATE );
|
||||
return GetDefaultFieldName( aFieldType, !DO_TRANSLATE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-84
@@ -38,16 +38,7 @@
|
||||
#include <wx/regex.h>
|
||||
|
||||
#include <lib_id.h>
|
||||
|
||||
|
||||
#define FIELD_NAME -1
|
||||
#define FIELD_VALUE -2
|
||||
|
||||
#define SHEETNAME_V 100 // We can't use SHEETNAME and SHEETFILENAME because they
|
||||
#define SHEETFILENAME_V 101 // overlap with REFERENCE_FIELD and VALUE_FIELD
|
||||
#define SHEETUSERFIELD_V 102
|
||||
|
||||
#define LABELUSERFIELD_V 200
|
||||
#include <template_fieldnames.h>
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,20 +56,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Provide a custom wxValidator object for limiting the allowable characters when
|
||||
* defining file names with path, for instance in schematic sheet file names.
|
||||
*
|
||||
* The characters *?|"<> are illegal and filtered by the validator,
|
||||
* but /\: are valid (\ and : only on Windows.)
|
||||
*/
|
||||
class FILE_NAME_WITH_PATH_CHAR_VALIDATOR : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
FILE_NAME_WITH_PATH_CHAR_VALIDATOR( wxString* aValue = nullptr );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Provide a custom wxValidator object for limiting the allowable characters when defining an
|
||||
* environment variable name in a text edit control.
|
||||
@@ -109,64 +86,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Custom validator that checks verifies that a string *exactly* matches a regular expression.
|
||||
*/
|
||||
class REGEX_VALIDATOR : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param aRegEx is a regular expression to validate strings.
|
||||
* @param aValue is a pointer to a wxString containing the value to validate.
|
||||
*/
|
||||
REGEX_VALIDATOR( const wxString& aRegEx, wxString* aValue = nullptr )
|
||||
: wxTextValidator( wxFILTER_NONE, aValue )
|
||||
{
|
||||
compileRegEx( aRegEx, wxRE_DEFAULT );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aRegEx is a regular expression to validate strings.
|
||||
* @param aFlags are compilation flags (normally wxRE_DEFAULT).
|
||||
* @param aValue is a pointer to a wxString containing the value to validate.
|
||||
*/
|
||||
REGEX_VALIDATOR( const wxString& aRegEx, int aFlags, wxString* aValue = nullptr )
|
||||
: wxTextValidator( wxFILTER_NONE, aValue )
|
||||
{
|
||||
compileRegEx( aRegEx, aFlags );
|
||||
}
|
||||
|
||||
REGEX_VALIDATOR( const REGEX_VALIDATOR& aOther ) : wxTextValidator( aOther )
|
||||
{
|
||||
compileRegEx( aOther.m_regExString, aOther.m_regExFlags );
|
||||
}
|
||||
|
||||
virtual wxObject* Clone() const override
|
||||
{
|
||||
return new REGEX_VALIDATOR( *this );
|
||||
}
|
||||
|
||||
bool Validate( wxWindow* aParent ) override;
|
||||
|
||||
const wxString& GetRegEx() const
|
||||
{
|
||||
return m_regExString;
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Compiles and stores a regular expression.
|
||||
void compileRegEx( const wxString& aRegEx, int aFlags );
|
||||
|
||||
/// Original regular expression (for copy constructor).
|
||||
wxString m_regExString;
|
||||
|
||||
/// Original compilation flags (for copy constructor).
|
||||
int m_regExFlags;
|
||||
|
||||
/// Compiled regular expression.
|
||||
wxRegEx m_regEx;
|
||||
};
|
||||
|
||||
class NETNAME_VALIDATOR : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
@@ -223,7 +142,7 @@ void ValidatorTransferToWindowWithoutEvents( wxValidator& aValidator );
|
||||
class FIELD_VALIDATOR : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
FIELD_VALIDATOR( int aFieldId, wxString* aValue = nullptr );
|
||||
FIELD_VALIDATOR( FIELD_T aFieldId, wxString* aValue = nullptr );
|
||||
|
||||
FIELD_VALIDATOR( const FIELD_VALIDATOR& aValidator );
|
||||
|
||||
@@ -241,7 +160,7 @@ public:
|
||||
bool DoValidate( const wxString& aValue, wxWindow* aParent );
|
||||
|
||||
private:
|
||||
int m_fieldId;
|
||||
FIELD_T m_fieldId;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -501,7 +501,6 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
|
||||
if( !m_itemsGrid->CommitPendingChanges() )
|
||||
return false;
|
||||
|
||||
auto view = m_frame->GetCanvas()->GetView();
|
||||
BOARD_COMMIT commit( m_frame );
|
||||
commit.Modify( m_footprint );
|
||||
|
||||
@@ -517,12 +516,10 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
|
||||
std::set<wxString> files_to_delete;
|
||||
|
||||
// Get the new files from the footprint fields
|
||||
for( size_t ii = 0; ii < m_fields->size(); ++ii )
|
||||
for( PCB_FIELD& field : *m_fields )
|
||||
{
|
||||
const wxString& name = m_fields->at( ii ).GetText();
|
||||
|
||||
if( name.StartsWith( FILEEXT::KiCadUriPrefix ) )
|
||||
files.insert( name );
|
||||
if( field.GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
|
||||
files.insert( field.GetText() );
|
||||
}
|
||||
|
||||
// Find any files referenced in the old fields that are not in the new fields
|
||||
@@ -542,27 +539,22 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
|
||||
}
|
||||
|
||||
// Update fields
|
||||
for( size_t ii = 0; ii < m_fields->size(); ++ii )
|
||||
{
|
||||
PCB_FIELD& field = m_fields->at( ii );
|
||||
field.SetText( m_footprint->GetBoard()->ConvertCrossReferencesToKIIDs( field.GetText() ) );
|
||||
}
|
||||
for( PCB_FIELD* existing : m_footprint->GetFields() )
|
||||
delete existing;
|
||||
|
||||
size_t i = 0;
|
||||
m_footprint->GetFields().clear();
|
||||
|
||||
for( PCB_FIELD* field : m_footprint->GetFields() )
|
||||
{
|
||||
// copy grid table entries till we run out, then delete any remaining texts
|
||||
if( i < m_fields->size() )
|
||||
*field = m_fields->at( i++ );
|
||||
else
|
||||
field->DeleteStructure();
|
||||
}
|
||||
int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
|
||||
|
||||
// if there are still grid table entries, create new fields for them
|
||||
while( i < m_fields->size() )
|
||||
for( PCB_FIELD& field : *m_fields )
|
||||
{
|
||||
view->Add( m_footprint->AddField( m_fields->at( i++ ) ) );
|
||||
PCB_FIELD* newField = field.CloneField();
|
||||
newField->SetText( commit.GetBoard()->ConvertCrossReferencesToKIIDs( field.GetText() ) );
|
||||
|
||||
if( !field.IsMandatory() )
|
||||
newField->SetOrdinal( ordinal++ );
|
||||
|
||||
m_footprint->Add( newField );
|
||||
}
|
||||
|
||||
// Initialize masks clearances
|
||||
@@ -670,7 +662,7 @@ void DIALOG_FOOTPRINT_PROPERTIES::OnAddField( wxCommandEvent& )
|
||||
if( !m_itemsGrid->CommitPendingChanges() )
|
||||
return;
|
||||
|
||||
PCB_FIELD newField( m_footprint, m_footprint->GetNextFieldId(),
|
||||
PCB_FIELD newField( m_footprint, FIELD_T::USER,
|
||||
GetUserFieldName( m_fields->GetNumberRows(), DO_TRANSLATE ) );
|
||||
|
||||
newField.SetVisible( false );
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/pcb_selection_tool.h>
|
||||
#include <validators.h>
|
||||
#include <widgets/grid_text_button_helpers.h>
|
||||
@@ -544,12 +545,10 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
|
||||
std::set<wxString> files_to_delete;
|
||||
|
||||
// Get the new files from the footprint fields
|
||||
for( PCB_FIELD& m_field : *m_fields)
|
||||
for( const PCB_FIELD& field : *m_fields )
|
||||
{
|
||||
const wxString& name = m_field.GetText();
|
||||
|
||||
if( name.StartsWith( FILEEXT::KiCadUriPrefix ) )
|
||||
files.insert( name );
|
||||
if( field.GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
|
||||
files.insert( field.GetText() );
|
||||
}
|
||||
|
||||
// Find any files referenced in the old fields that are not in the new fields
|
||||
@@ -576,33 +575,22 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
|
||||
m_footprint->SetKeywords( m_KeywordCtrl->GetValue() );
|
||||
|
||||
// Update fields
|
||||
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
||||
|
||||
std::vector<PCB_FIELD*> items_to_remove;
|
||||
size_t i = 0;
|
||||
|
||||
for( PCB_FIELD* field : m_footprint->GetFields() )
|
||||
for( PCB_FIELD* existing : m_footprint->GetFields() )
|
||||
{
|
||||
// copy grid table entries till we run out, then delete any remaining texts
|
||||
if( i < m_fields->size() )
|
||||
*field = m_fields->at( i++ );
|
||||
else
|
||||
items_to_remove.push_back( field );
|
||||
m_footprint->Remove( existing );
|
||||
view->Remove( existing );
|
||||
delete existing;
|
||||
}
|
||||
|
||||
// Remove text items:
|
||||
PCB_SELECTION_TOOL* selTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
||||
|
||||
for( PCB_TEXT* item : items_to_remove )
|
||||
for( PCB_FIELD& field : *m_fields )
|
||||
{
|
||||
selTool->RemoveItemFromSel( item );
|
||||
view->Remove( item );
|
||||
item->DeleteStructure();
|
||||
PCB_FIELD* newField = field.CloneField();
|
||||
m_footprint->Add( newField );
|
||||
view->Add( newField );
|
||||
}
|
||||
|
||||
// if there are still grid table entries, create new fields for them
|
||||
while( i < m_fields->size() )
|
||||
view->Add( m_footprint->AddField( m_fields->at( i++ ) ) );
|
||||
|
||||
LSET privateLayers;
|
||||
|
||||
for( PCB_LAYER_ID layer : *m_privateLayers )
|
||||
@@ -698,7 +686,7 @@ void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField( wxCommandEvent& event )
|
||||
|
||||
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
||||
|
||||
PCB_FIELD newField( m_footprint, m_footprint->GetNextFieldId(),
|
||||
PCB_FIELD newField( m_footprint, FIELD_T::USER,
|
||||
GetUserFieldName( m_fields->GetNumberRows(), DO_TRANSLATE ) );
|
||||
|
||||
// Set active layer if legal; otherwise copy layer from previous text item
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user