diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index f973f3605e..e086096e00 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -215,13 +215,13 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, if( symbol->GetUnitCount() > 1 ) msg.Printf( _( "Updated %s (unit %s) from %s to %s" ), - symbol->GetValue( sheet ), + symbol->GetValue( sheet, true ), LIB_PART::SubReference( symbol->GetUnit(), false ), prevRef, newRef ); else msg.Printf( _( "Updated %s from %s to %s" ), - symbol->GetValue( sheet ), + symbol->GetValue( sheet, true ), prevRef, newRef ); } @@ -229,12 +229,12 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, { if( symbol->GetUnitCount() > 1 ) msg.Printf( _( "Annotated %s (unit %s) as %s" ), - symbol->GetValue( sheet ), + symbol->GetValue( sheet, true ), LIB_PART::SubReference( symbol->GetUnit(), false ), newRef ); else msg.Printf( _( "Annotated %s as %s" ), - symbol->GetValue( sheet ), + symbol->GetValue( sheet, true ), newRef ); } diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index ce46b4da09..906a3f6682 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -665,11 +665,11 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aSymbol, LIB_PART* aLibPart, { wxASSERT( aSymbol != NULL ); - m_rootSymbol = aSymbol; - m_libPart = aLibPart; // Warning: can be nullptr for orphan components - // (i.e. with a symbol library not found) + m_rootSymbol = aSymbol; + m_libPart = aLibPart; // Warning: can be nullptr for orphan components + // (i.e. with a symbol library not found) m_unit = aSymbol->GetUnitSelection( &aSheetPath ); - m_footprint = aSymbol->GetFootprint( &aSheetPath ); + m_footprint = aSymbol->GetFootprint( &aSheetPath, true ); m_sheetPath = aSheetPath; m_isNew = false; m_flag = 0; @@ -685,10 +685,10 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aSymbol, LIB_PART* aLibPart, m_numRef = -1; - if( aSymbol->GetValue( &aSheetPath ).IsEmpty() ) + if( aSymbol->GetValue( &aSheetPath, false ).IsEmpty() ) aSymbol->SetValue( &aSheetPath, wxT( "~" ) ); - m_value = aSymbol->GetValue( &aSheetPath ); + m_value = aSymbol->GetValue( &aSheetPath, false ); } diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 45bc036468..20b6c4966f 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -72,7 +72,7 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPO m_newId->AppendText( FROM_UTF8( m_symbol->GetLibId().Format().c_str() ) ); m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) ); - m_specifiedValue->ChangeValue( m_symbol->GetValue( currentSheet ) ); + m_specifiedValue->ChangeValue( m_symbol->GetValue( currentSheet, false ) ); m_specifiedId->ChangeValue( FROM_UTF8( m_symbol->GetLibId().Format().c_str() ) ); } else @@ -352,13 +352,13 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aIn } else if( m_matchByReference->GetValue() ) { - return WildCompareString( m_specifiedReference->GetValue(), aSymbol->GetRef( aInstance ), - false ); + return WildCompareString( m_specifiedReference->GetValue(), + aSymbol->GetRef( aInstance, false ), false ); } else if( m_matchByValue->GetValue() ) { - return WildCompareString( m_specifiedValue->GetValue(), aSymbol->GetValue( aInstance ), - false ); + return WildCompareString( m_specifiedValue->GetValue(), + aSymbol->GetValue( aInstance, false ), false ); } else if( m_matchById ) { diff --git a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp index 12c2a875b2..e967b15416 100644 --- a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp @@ -87,7 +87,7 @@ bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName, unsig ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) ); ret |= fprintf( f, "%s", TO_UTF8( msg ) ); - msg = symbol->GetValue( &sheetList[i] ); + msg = symbol->GetValue( &sheetList[i], true ); msg.Replace( wxT( " " ), wxT( "_" ) ); ret |= fprintf( f, " \"%s\"", TO_UTF8( msg ) ); ret |= fprintf( f, " \"%s\"", TO_UTF8( footprint ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index 621a7170a9..25d8d77328 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -82,7 +82,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, if( comp->GetPartRef() && comp->GetPartRef()->GetFootprints().GetCount() != 0 ) cmpList.push_back( SCH_REFERENCE( comp, comp->GetPartRef().get(), sheet ) ); - footprint = comp->GetFootprint( &sheet ); + footprint = comp->GetFootprint( &sheet, true ); footprint.Replace( wxT( " " ), wxT( "_" ) ); if( footprint.IsEmpty() ) @@ -96,7 +96,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, ret |= fprintf( f, " %s", TO_UTF8( field ) ); - field = comp->GetValue( &sheet ); + field = comp->GetValue( &sheet, true ); field.Replace( wxT( " " ), wxT( "_" ) ); ret |= fprintf( f, " %s", TO_UTF8( field ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index cb06b42e00..4ba28d0617 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -121,22 +121,16 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_COMPONENT* aSymbol // The lowest unit number wins. User should only set fields in any one unit. // remark: IsVoid() returns true for empty strings or the "~" string (empty // field value) - if( !comp2->GetValue( &sheetList[i] ).IsEmpty() + if( !comp2->GetValue( &sheetList[i], m_resolveTextVars ).IsEmpty() && ( unit < minUnit || fields.value.IsEmpty() ) ) { - if( m_resolveTextVars ) - fields.value = comp2->GetValue( &sheetList[i] ); - else - fields.value = comp2->GetField( VALUE_FIELD )->GetText(); + fields.value = comp2->GetValue( &sheetList[i], m_resolveTextVars ); } - if( !comp2->GetFootprint( &sheetList[i] ).IsEmpty() + if( !comp2->GetFootprint( &sheetList[i], m_resolveTextVars ).IsEmpty() && ( unit < minUnit || fields.footprint.IsEmpty() ) ) { - if( m_resolveTextVars ) - fields.footprint = comp2->GetFootprint( &sheetList[i] ); - else - fields.footprint = comp2->GetField( FOOTPRINT_FIELD )->GetText(); + fields.footprint = comp2->GetFootprint( &sheetList[i], m_resolveTextVars ); } if( !comp2->GetField( DATASHEET_FIELD )->IsVoid() diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 33f8d9554b..2a0041e388 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -567,7 +567,7 @@ void SCH_COMPONENT::SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSel } -const wxString SCH_COMPONENT::GetValue( const SCH_SHEET_PATH* sheet ) const +const wxString SCH_COMPONENT::GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const { KIID_PATH path = sheet->Path(); @@ -575,12 +575,18 @@ const wxString SCH_COMPONENT::GetValue( const SCH_SHEET_PATH* sheet ) const { if( instance.m_Path == path && !instance.m_Value.IsEmpty() ) { + if( !aResolve ) + return instance.m_Value; + SCH_FIELD dummy( wxDefaultPosition, VALUE_FIELD, const_cast( this ) ); dummy.SetText( instance.m_Value ); return dummy.GetShownText(); } } + if( !aResolve ) + return GetField( VALUE_FIELD )->GetText(); + return GetField( VALUE_FIELD )->GetShownText(); } @@ -614,7 +620,7 @@ void SCH_COMPONENT::SetValue( const SCH_SHEET_PATH* sheet, const wxString& aValu } -const wxString SCH_COMPONENT::GetFootprint( const SCH_SHEET_PATH* sheet ) const +const wxString SCH_COMPONENT::GetFootprint( const SCH_SHEET_PATH* sheet, bool aResolve ) const { KIID_PATH path = sheet->Path(); @@ -622,12 +628,18 @@ const wxString SCH_COMPONENT::GetFootprint( const SCH_SHEET_PATH* sheet ) const { if( instance.m_Path == path && !instance.m_Footprint.IsEmpty() ) { + if( !aResolve ) + return instance.m_Footprint; + SCH_FIELD dummy( wxDefaultPosition, FOOTPRINT_FIELD, const_cast( this ) ); dummy.SetText( instance.m_Footprint ); return dummy.GetShownText(); } } + if( !aResolve ) + return GetField( FOOTPRINT_FIELD )->GetText(); + return GetField( FOOTPRINT_FIELD )->GetShownText(); } @@ -915,9 +927,9 @@ bool SCH_COMPONENT::ResolveTextVar( wxString* token, int aDepth ) const if( i == REFERENCE_FIELD && schematic ) *token = GetRef( &schematic->CurrentSheet(), true ); else if( i == VALUE_FIELD && schematic ) - *token = GetValue( &schematic->CurrentSheet() ); + *token = GetValue( &schematic->CurrentSheet(), true ); else if( i == FOOTPRINT_FIELD && schematic ) - *token = GetFootprint( &schematic->CurrentSheet() ); + *token = GetFootprint( &schematic->CurrentSheet(), true ); else *token = m_fields[ i ].GetShownText( aDepth + 1 ); @@ -940,7 +952,7 @@ bool SCH_COMPONENT::ResolveTextVar( wxString* token, int aDepth ) const wxString footprint; if( schematic ) - footprint = GetFootprint( &schematic->CurrentSheet() ); + footprint = GetFootprint( &schematic->CurrentSheet(), true ); else footprint = m_fields[ FOOTPRINT_FIELD ].GetShownText(); @@ -954,7 +966,7 @@ bool SCH_COMPONENT::ResolveTextVar( wxString* token, int aDepth ) const wxString footprint; if( schematic ) - footprint = GetFootprint( &schematic->CurrentSheet() ); + footprint = GetFootprint( &schematic->CurrentSheet(), true ); else footprint = m_fields[ FOOTPRINT_FIELD ].GetShownText(); @@ -1343,7 +1355,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aL msg = m_part->IsPower() ? _( "Power symbol" ) : _( "Value" ); - aList.push_back( MSG_PANEL_ITEM( msg, GetValue( currentSheet ), DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( msg, GetValue( currentSheet, true ), DARKCYAN ) ); #if 0 // Display component flags, for debug only aList.push_back( MSG_PANEL_ITEM( _( "flags" ), @@ -1375,7 +1387,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aL } // Display the current associated footprint, if exists. - msg = GetFootprint( currentSheet ); + msg = GetFootprint( currentSheet, true ); if( msg.IsEmpty() ) msg = _( "" ); @@ -1392,7 +1404,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aL { aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), GetRef( currentSheet ), DARKCYAN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetValue( currentSheet ), DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetValue( currentSheet, true ), DARKCYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), BROWN ) ); wxString libNickname = GetLibId().GetLibNickname(); diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 11ba3a7895..25c5d2604c 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -554,7 +554,7 @@ public: void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection ); // Returns the instance-specific value for the given sheet path. - const wxString GetValue( const SCH_SHEET_PATH* sheet ) const; + const wxString GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const; void SetValue( const SCH_SHEET_PATH* sheet, const wxString& aValue ); // Set the value for all instances (the default GUI behaviour) @@ -564,7 +564,7 @@ public: } // Returns the instance-specific footprint assignment for the given sheet path. - const wxString GetFootprint( const SCH_SHEET_PATH* sheet ) const; + const wxString GetFootprint( const SCH_SHEET_PATH* sheet, bool aResolve ) const; void SetFootprint( const SCH_SHEET_PATH* sheet, const wxString& aFootprint ); // Set the value for all instances (the default GUI behaviour) diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index dcf1295935..d24fc05db2 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -201,7 +201,8 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr; SCH_COMPONENT* symbol = GetParentSymbol(); - aList.emplace_back( symbol->GetRef( currentSheet ), symbol->GetValue( currentSheet ), DARKCYAN ); + aList.emplace_back( symbol->GetRef( currentSheet ), symbol->GetValue( currentSheet, true ), + DARKCYAN ); #if defined(DEBUG) diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 50631b6372..9efcf175d7 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -249,12 +249,12 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const void SCH_SHEET_PATH::UpdateAllScreenReferences() { - for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) ) + for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) ) { - auto component = static_cast( item ); + SCH_COMPONENT* component = static_cast( item ); component->GetField( REFERENCE_FIELD )->SetText( component->GetRef( this ) ); - component->GetField( VALUE_FIELD )->SetText( component->GetValue( this ) ); - component->GetField( FOOTPRINT_FIELD )->SetText( component->GetFootprint( this ) ); + component->GetField( VALUE_FIELD )->SetText( component->GetValue( this, false ) ); + component->GetField( FOOTPRINT_FIELD )->SetText( component->GetFootprint( this, false ) ); component->UpdateUnit( component->GetUnitSelection( this ) ); } }