Do not add a title/comment in mandatory field strings when writting netlists.

This is mainly for "Sheetfile" property because current it is the only one
that has a title when plotting/drawing it.
This commit is contained in:
jean-pierre charras 2022-10-22 15:29:30 +02:00
parent ceaf3fc72d
commit 8e331628b6
10 changed files with 16 additions and 11 deletions

View File

@ -332,7 +332,9 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl )
xproperty->AddAttribute( wxT( "name" ), sheetField.GetCanonicalName() );
if( m_resolveTextVars )
xproperty->AddAttribute( wxT( "value" ), sheetField.GetShownText() );
// do not allow GetShownText() to add any prefix useful only when displaying
// the field on screen
xproperty->AddAttribute( wxT( "value" ), sheetField.GetShownText( 0, false ) );
else
xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() );
}

View File

@ -102,7 +102,7 @@ void SCH_FIELD::SetId( int aId )
}
wxString SCH_FIELD::GetShownText( int aDepth ) const
wxString SCH_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const
{
std::function<bool( wxString* )> symbolResolver =
[&]( wxString* token ) -> bool
@ -185,7 +185,7 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
}
else if( m_parent && m_parent->Type() == SCH_SHEET_T )
{
if( m_id == SHEETFILENAME )
if( m_id == SHEETFILENAME && aAllowExtraText )
text = _( "File:" ) + wxS( " " )+ text;
}

View File

@ -114,7 +114,7 @@ public:
void SetId( int aId );
wxString GetShownText( int aDepth = 0 ) const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
/**
* Adjusters to allow EDA_TEXT to draw/print/etc. text in absolute coords.

View File

@ -597,7 +597,7 @@ void SCH_TEXT::GetContextualTextVars( wxArrayString* aVars ) const
}
wxString SCH_TEXT::GetShownText( int aDepth ) const
wxString SCH_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
{
std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool

View File

@ -139,7 +139,7 @@ public:
*/
void GetContextualTextVars( wxArrayString* aVars ) const;
wxString GetShownText( int aDepth = 0 ) const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
/**
* Increment the label text, if it ends with a number.

View File

@ -158,8 +158,11 @@ public:
*
* @param aDepth is used to prevent infinite recursions and loops when expanding
* text variables.
* @param aAllowExtraText true to allow adding more text than the initial expanded text,
* for intance a title, a prefix for texts in display functions.
* False to disable any added text (for instance when writing the shown text in netlists).
*/
virtual wxString GetShownText( int aDepth = 0 ) const { return m_shown_text; }
virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const { return m_shown_text; }
/**
* Returns a shortened version (max 15 characters) of the shown text

View File

@ -408,7 +408,7 @@ double FP_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
}
wxString FP_TEXT::GetShownText( int aDepth ) const
wxString FP_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
{
const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
wxASSERT( parentFootprint );

View File

@ -221,7 +221,7 @@ public:
EDA_ITEM* Clone() const override;
virtual wxString GetShownText( int aDepth = 0 ) const override;
virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
virtual const BOX2I ViewBBox() const override;

View File

@ -53,7 +53,7 @@ PCB_TEXT::~PCB_TEXT()
}
wxString PCB_TEXT::GetShownText( int aDepth ) const
wxString PCB_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
{
BOARD* board = dynamic_cast<BOARD*>( GetParent() );

View File

@ -62,7 +62,7 @@ public:
return false;
}
wxString GetShownText( int aDepth = 0 ) const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
/// PCB_TEXTs are always visible:
void SetVisible( bool aVisible ) override { /* do nothing */}