From f993e45325eb8dee964caa38d9e25fccba1ff69a Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Wed, 29 Nov 2023 09:55:17 -0500 Subject: [PATCH] Variables: make consistent across editors Fixes: https://gitlab.com/kicad/code/kicad/-/issues/16180 --- common/drawing_sheet/ds_painter.cpp | 13 +++++++++++ .../sch_plugins/altium/sch_altium_plugin.cpp | 4 +++- eeschema/schematic.cpp | 7 ++++++ pcbnew/board.cpp | 23 ++++++++++++++++++- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index 7ef19fe2f4..ea8c619d7f 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -102,6 +102,8 @@ void DS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars ) aVars->push_back( wxT( "SHEETNAME" ) ); aVars->push_back( wxT( "SHEETPATH" ) ); aVars->push_back( wxT( "FILENAME" ) ); + aVars->push_back( wxT( "FILEPATH" ) ); + aVars->push_back( wxT( "PROJECTNAME" ) ); aVars->push_back( wxT( "PAPER" ) ); aVars->push_back( wxT( "LAYER" ) ); TITLE_BLOCK::GetContextualTextVars( aVars ); @@ -154,6 +156,17 @@ wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) *token = fn.GetFullName(); tokenUpdated = true; } + else if( token->IsSameAs( wxT( "FILEPATH" ) ) ) + { + wxFileName fn( m_fileName ); + *token = fn.GetFullPath(); + return true; + } + else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) && m_project ) + { + *token = m_project->GetProjectName(); + return true; + } else if( token->IsSameAs( wxT( "PAPER" ) ) ) { *token = m_paperFormat; diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index 3d7be2aa69..3653e1933c 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -1248,6 +1248,8 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map& aPropert { "CURRENTDATE", "CURRENT_DATE" }, { "COMPANYNAME", "COMPANY" }, { "DOCUMENTNAME", "FILENAME" }, + { "DOCUMENTFULLPATHANDNAME", + "FILEPATH" }, { "PROJECTNAME", "PROJECTNAME" }, }; @@ -4176,4 +4178,4 @@ LIB_SYMBOL* SCH_ALTIUM_PLUGIN::LoadSymbol( const wxString& aLibraryPath, } return nullptr; -} \ No newline at end of file +} diff --git a/eeschema/schematic.cpp b/eeschema/schematic.cpp index c5bd4308ed..5c69f05945 100644 --- a/eeschema/schematic.cpp +++ b/eeschema/schematic.cpp @@ -143,6 +143,7 @@ void SCHEMATIC::GetContextualTextVars( wxArrayString* aVars ) const add( wxT( "SHEETPATH" ) ); add( wxT( "SHEETNAME" ) ); add( wxT( "FILENAME" ) ); + add( wxT( "FILEPATH" ) ); add( wxT( "PROJECTNAME" ) ); if( !CurrentSheet().empty() ) @@ -184,6 +185,12 @@ bool SCHEMATIC::ResolveTextVar( const SCH_SHEET_PATH* aSheetPath, wxString* toke *token = fn.GetFullName(); return true; } + else if( token->IsSameAs( wxT( "FILEPATH" ) ) ) + { + wxFileName fn( GetFileName() ); + *token = fn.GetFullPath(); + return true; + } else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) ) { *token = Prj().GetProjectName(); diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 1487acef72..4b2ab1e0cf 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -376,6 +376,9 @@ void BOARD::GetContextualTextVars( wxArrayString* aVars ) const }; add( wxT( "LAYER" ) ); + add( wxT( "FILENAME" ) ); + add( wxT( "FILEPATH" ) ); + add( wxT( "PROJECTNAME" ) ); GetTitleBlock().GetContextualTextVars( aVars ); @@ -407,6 +410,24 @@ bool BOARD::ResolveTextVar( wxString* token, int aDepth ) const } } + if( token->IsSameAs( wxT( "FILENAME" ) ) ) + { + wxFileName fn( GetFileName() ); + *token = fn.GetFullName(); + return true; + } + else if( token->IsSameAs( wxT( "FILEPATH" ) ) ) + { + wxFileName fn( GetFileName() ); + *token = fn.GetFullPath(); + return true; + } + else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) && GetProject() ) + { + *token = GetProject()->GetProjectName(); + return true; + } + wxString var = *token; if( GetTitleBlock().TextVarResolver( token, m_project ) ) @@ -2664,4 +2685,4 @@ bool BOARD::operator==( const BOARD_ITEM& aItem ) const return false; return true; -} \ No newline at end of file +}