Allow titleblock vars to be resolved outside the titleblock.
Also implements some variable resolving for Altium imports.
This commit is contained in:
parent
799d6690c0
commit
3288971a7c
|
@ -780,8 +780,24 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
ASCH_LABEL elem( aProperties );
|
ASCH_LABEL elem( aProperties );
|
||||||
|
|
||||||
// TODO: text variable support
|
// TODO: text variable support
|
||||||
|
|
||||||
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
||||||
{
|
{
|
||||||
|
if( elem.text == "=SheetNumber" )
|
||||||
|
elem.text = "${#}";
|
||||||
|
else if( elem.text == "=SheetTotal" )
|
||||||
|
elem.text = "${##}";
|
||||||
|
else if( elem.text == "=Title" )
|
||||||
|
elem.text = "${TITLE}";
|
||||||
|
else if( elem.text == "=ProjectRev" )
|
||||||
|
elem.text = "${REVISION}";
|
||||||
|
else if( elem.text == "=Date" )
|
||||||
|
elem.text = "${ISSUE_DATE}";
|
||||||
|
else if( elem.text == "=CompanyName" )
|
||||||
|
elem.text = "${COMPANY}";
|
||||||
|
else if( elem.text == "=DocumentName" )
|
||||||
|
elem.text = "${FILENAME}";
|
||||||
|
|
||||||
SCH_TEXT* text = new SCH_TEXT( elem.location + m_sheetOffset, elem.text );
|
SCH_TEXT* text = new SCH_TEXT( elem.location + m_sheetOffset, elem.text );
|
||||||
|
|
||||||
SetEdaTextJustification( text, elem.justification );
|
SetEdaTextJustification( text, elem.justification );
|
||||||
|
|
|
@ -615,6 +615,12 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::function<bool( wxString* )> schematicTextResolver =
|
||||||
|
[&]( wxString* token ) -> bool
|
||||||
|
{
|
||||||
|
return Schematic()->ResolveTextVar( token, aDepth + 1 );
|
||||||
|
};
|
||||||
|
|
||||||
wxString text = EDA_TEXT::GetShownText();
|
wxString text = EDA_TEXT::GetShownText();
|
||||||
|
|
||||||
if( text == "~" ) // Legacy placeholder for empty string
|
if( text == "~" ) // Legacy placeholder for empty string
|
||||||
|
@ -631,7 +637,7 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
|
||||||
project = &Schematic()->Prj();
|
project = &Schematic()->Prj();
|
||||||
|
|
||||||
if( aDepth < 10 )
|
if( aDepth < 10 )
|
||||||
text = ExpandTextVars( text, &textResolver, nullptr, project );
|
text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project );
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
|
@ -120,6 +120,34 @@ SCH_SCREEN* SCHEMATIC::RootScreen() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SCHEMATIC::ResolveTextVar( wxString* token, int aDepth ) const
|
||||||
|
{
|
||||||
|
if( token->IsSameAs( wxT( "#" ) ) )
|
||||||
|
{
|
||||||
|
*token = CurrentSheet().GetPageNumber();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if( token->IsSameAs( wxT( "##" ) ) )
|
||||||
|
{
|
||||||
|
*token = wxString::Format( "%i", Root().CountSheets() );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
|
||||||
|
{
|
||||||
|
*token = CurrentSheet().PathHumanReadable();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
|
||||||
|
{
|
||||||
|
wxFileName fn( GetFileName() );
|
||||||
|
*token = fn.GetFullName();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CurrentSheet().LastScreen()->GetTitleBlock().TextVarResolver( token, m_project );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SCHEMATIC::GetFileName() const
|
wxString SCHEMATIC::GetFileName() const
|
||||||
{
|
{
|
||||||
return IsValid() ? m_rootSheet->GetScreen()->GetFileName() : wxString( wxEmptyString );
|
return IsValid() ? m_rootSheet->GetScreen()->GetFileName() : wxString( wxEmptyString );
|
||||||
|
|
|
@ -113,6 +113,8 @@ public:
|
||||||
/// Helper to retrieve the screen of the root sheet
|
/// Helper to retrieve the screen of the root sheet
|
||||||
SCH_SCREEN* RootScreen() const;
|
SCH_SCREEN* RootScreen() const;
|
||||||
|
|
||||||
|
bool ResolveTextVar( wxString* token, int aDepth ) const;
|
||||||
|
|
||||||
/// Helper to retrieve the filename from the root sheet screen
|
/// Helper to retrieve the filename from the root sheet screen
|
||||||
wxString GetFileName() const override;
|
wxString GetFileName() const override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue