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 12:50:26 +02:00
parent 958bd1897d
commit 63002cec57
23 changed files with 30 additions and 23 deletions

View File

@ -394,7 +394,7 @@ wxString LIB_FIELD::GetFullText( int unit ) const
} }
wxString LIB_FIELD::GetShownText( int aDepth ) const wxString LIB_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const
{ {
wxString text = EDA_TEXT::GetShownText( aDepth ); wxString text = EDA_TEXT::GetShownText( aDepth );

View File

@ -148,7 +148,7 @@ public:
*/ */
wxString GetFullText( int unit = 1 ) const; wxString GetFullText( int unit = 1 ) const;
wxString GetShownText( int aDepth = 0 ) const override; wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
SCH_LAYER_ID GetDefaultLayer() const; SCH_LAYER_ID GetDefaultLayer() const;

View File

@ -315,7 +315,7 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
} }
wxString LIB_TEXTBOX::GetShownText( int aDepth ) const wxString LIB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
{ {
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText();

View File

@ -55,7 +55,7 @@ public:
VECTOR2I GetDrawPos() const override; VECTOR2I GetDrawPos() const override;
wxString GetShownText( int aDepth = 0 ) const override; wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
KIFONT::FONT* GetDrawFont() const override; KIFONT::FONT* GetDrawFont() const override;

View File

@ -331,7 +331,9 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl )
xproperty->AddAttribute( wxT( "name" ), sheetField.GetCanonicalName() ); xproperty->AddAttribute( wxT( "name" ), sheetField.GetCanonicalName() );
if( m_resolveTextVars ) 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 else
xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() ); xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() );
} }

View File

@ -166,7 +166,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 = std::function<bool( wxString* )> symbolResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool
@ -252,7 +252,7 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
} }
else if( m_parent && m_parent->Type() == SCH_SHEET_T ) else if( m_parent && m_parent->Type() == SCH_SHEET_T )
{ {
if( m_id == SHEETFILENAME ) if( m_id == SHEETFILENAME && aAllowExtraText )
text = _( "File:" ) + wxS( " " )+ text; text = _( "File:" ) + wxS( " " )+ text;
} }

View File

@ -117,7 +117,7 @@ public:
void SetId( int aId ); void SetId( int aId );
wxString GetShownText( int aDepth = 0 ) const override; wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
COLOR4D GetFieldColor() const; COLOR4D GetFieldColor() const;

View File

@ -555,7 +555,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
} }
wxString SCH_LABEL_BASE::GetShownText( int aDepth ) const wxString SCH_LABEL_BASE::GetShownText( int aDepth, bool aAllowExtraText ) const
{ {
std::function<bool( wxString* )> textResolver = std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool

View File

@ -128,7 +128,7 @@ public:
virtual bool ResolveTextVar( wxString* token, int aDepth ) const; virtual bool ResolveTextVar( wxString* token, int aDepth ) const;
wxString GetShownText( int aDepth = 0 ) const override; wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override; void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;

View File

@ -334,7 +334,7 @@ const BOX2I SCH_TEXT::GetBoundingBox() const
} }
wxString SCH_TEXT::GetShownText( int aDepth ) const wxString SCH_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
{ {
std::function<bool( wxString* )> textResolver = std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool

View File

@ -128,7 +128,7 @@ public:
return wxT( "SCH_TEXT" ); return wxT( "SCH_TEXT" );
} }
wxString GetShownText( int aDepth = 0 ) const override; wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
bool IsHypertext() const override bool IsHypertext() const override
{ {

View File

@ -278,7 +278,7 @@ void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
} }
wxString SCH_TEXTBOX::GetShownText( int aDepth ) const wxString SCH_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
{ {
std::function<bool( wxString* )> textResolver = std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool

View File

@ -55,7 +55,7 @@ public:
VECTOR2I GetDrawPos() const override; VECTOR2I GetDrawPos() const override;
wxString GetShownText( int aDepth = 0 ) const override; wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
bool IsHypertext() const override bool IsHypertext() const override
{ {

View File

@ -1015,6 +1015,7 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
param = file.GetNextLine(); param = file.GetNextLine();
#if 0 // no longer in use
if( param.IsEmpty() ) if( param.IsEmpty() )
{ {
DISPLAY_LOAD_ERROR( "Error loading workbook: Line %d is empty." ); DISPLAY_LOAD_ERROR( "Error loading workbook: Line %d is empty." );
@ -1022,6 +1023,7 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
return false; return false;
} }
#endif
addPlot( name, (SIM_PLOT_TYPE) traceType ); addPlot( name, (SIM_PLOT_TYPE) traceType );
} }

View File

@ -91,8 +91,11 @@ public:
* *
* @param aDepth is used to prevent infinite recursions and loops when expanding * @param aDepth is used to prevent infinite recursions and loops when expanding
* text variables. * text variables.
* @param aAllowExtraText is 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; }
/** /**
* Indicates the ShownText has text var references which need to be processed. * Indicates the ShownText has text var references which need to be processed.

View File

@ -409,7 +409,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() ); const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
wxASSERT( parentFootprint ); wxASSERT( parentFootprint );

View File

@ -177,7 +177,7 @@ public:
EDA_ITEM* Clone() const override; 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; virtual const BOX2I ViewBBox() const override;

View File

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

View File

@ -128,7 +128,7 @@ public:
EDA_ITEM* Clone() const override; 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 void ViewGetLayers( int aLayers[], int& aCount ) const override; virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;

View File

@ -52,7 +52,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() ); BOARD* board = dynamic_cast<BOARD*>( GetParent() );

View File

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

View File

@ -238,7 +238,7 @@ double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
} }
wxString PCB_TEXTBOX::GetShownText( int aDepth ) const wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
{ {
BOARD* board = dynamic_cast<BOARD*>( GetParent() ); BOARD* board = dynamic_cast<BOARD*>( GetParent() );

View File

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