mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-07 22:05:32 +00:00
Hook up TITLE_BLOCK resolver to jobs.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19471
This commit is contained in:
parent
62041fdb69
commit
a7c130b82d
common
eeschema
include
pcbnew
@ -190,6 +190,7 @@ set( KICOMMON_SRCS
|
||||
systemdirsappend.cpp
|
||||
thread_pool.cpp
|
||||
ui_events.cpp
|
||||
title_block.cpp
|
||||
trace_helpers.cpp
|
||||
wildcards_and_files_ext.cpp
|
||||
wx_filename.cpp
|
||||
@ -619,7 +620,6 @@ set( COMMON_SRCS
|
||||
stroke_params.cpp
|
||||
template_fieldnames.cpp
|
||||
textentry_tricks.cpp
|
||||
title_block.cpp
|
||||
undo_redo_container.cpp
|
||||
validators.cpp
|
||||
drawing_sheet/ds_painter.cpp
|
||||
|
@ -97,7 +97,14 @@ void PrependDirectoryToPath( wxFileName& aFileName, const wxString aDirPath )
|
||||
|
||||
wxString JOB::GetFullOutputPath( PROJECT* aProject ) const
|
||||
{
|
||||
wxString outPath = ExpandTextVars( m_outputPath, aProject );
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
return m_titleBlock.TextVarResolver( token, aProject );
|
||||
};
|
||||
|
||||
wxString outPath = ExpandTextVars( m_outputPath, &textResolver );
|
||||
|
||||
if( !m_tempOutputDirectory.IsEmpty() )
|
||||
{
|
||||
if( m_outputPathIsDirectory )
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <settings/json_settings.h>
|
||||
#include <lseq.h>
|
||||
#include <lset.h>
|
||||
#include <title_block.h>
|
||||
|
||||
class PROJECT;
|
||||
|
||||
@ -193,6 +194,8 @@ public:
|
||||
m_varOverrides = aVarOverrides;
|
||||
}
|
||||
|
||||
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titleBlock = aTitleBlock; }
|
||||
|
||||
virtual void FromJson( const nlohmann::json& j );
|
||||
virtual void ToJson( nlohmann::json& j ) const;
|
||||
|
||||
@ -216,8 +219,9 @@ public:
|
||||
bool GetOutpathIsDirectory() const { return m_outputPathIsDirectory; }
|
||||
|
||||
protected:
|
||||
std::string m_type;
|
||||
std::string m_type;
|
||||
std::map<wxString, wxString> m_varOverrides;
|
||||
TITLE_BLOCK m_titleBlock;
|
||||
|
||||
wxString m_tempOutputDirectory;
|
||||
|
||||
|
@ -71,15 +71,6 @@ PROJECT::~PROJECT()
|
||||
|
||||
bool PROJECT::TextVarResolver( wxString* aToken ) const
|
||||
{
|
||||
// Special case because the resolution of PROJECTNAME is usually tied to title blocks
|
||||
// but we want this for jobs
|
||||
// Future todo is to rework vars entirely
|
||||
if( aToken->IsSameAs( wxT( "PROJECTNAME" ) ) )
|
||||
{
|
||||
*aToken = GetProjectName();
|
||||
return true;
|
||||
}
|
||||
|
||||
if( GetTextVars().count( *aToken ) > 0 )
|
||||
{
|
||||
*aToken = GetTextVars().at( *aToken );
|
||||
|
@ -157,6 +157,7 @@ EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER( KIWAY* aKiway ) :
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
SCHEMATIC* EESCHEMA_JOBS_HANDLER::getSchematic( const wxString& aPath )
|
||||
{
|
||||
SCHEMATIC* sch = nullptr;
|
||||
@ -272,6 +273,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
|
||||
if( !sch )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( sch->RootScreen()->GetTitleBlock() );
|
||||
sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
|
||||
|
||||
std::unique_ptr<SCH_RENDER_SETTINGS> renderSettings = std::make_unique<SCH_RENDER_SETTINGS>();
|
||||
@ -384,6 +386,9 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
|
||||
if( !sch )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( sch->RootScreen()->GetTitleBlock() );
|
||||
sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
|
||||
|
||||
// Annotation warning check
|
||||
SCH_REFERENCE_LIST referenceList;
|
||||
sch->Hierarchy().GetSymbols( referenceList );
|
||||
@ -501,6 +506,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
||||
if( !sch )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( sch->RootScreen()->GetTitleBlock() );
|
||||
sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
|
||||
|
||||
// Annotation warning check
|
||||
@ -763,6 +769,9 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
|
||||
if( !sch )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( sch->RootScreen()->GetTitleBlock() );
|
||||
sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
|
||||
|
||||
// Annotation warning check
|
||||
SCH_REFERENCE_LIST referenceList;
|
||||
sch->Hierarchy().GetSymbols( referenceList );
|
||||
@ -1104,6 +1113,7 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
|
||||
if( !sch )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( sch->RootScreen()->GetTitleBlock() );
|
||||
sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
|
||||
|
||||
if( ercJob->GetOutputPath().IsEmpty() )
|
||||
|
@ -37,7 +37,7 @@ class PROJECT;
|
||||
* Hold the information shown in the lower right corner of a plot, printout, or
|
||||
* editing view.
|
||||
*/
|
||||
class TITLE_BLOCK
|
||||
class KICOMMON_API TITLE_BLOCK
|
||||
{
|
||||
// Texts are stored in wxArraystring.
|
||||
// TEXTS_IDX gives the index of known texts in this array
|
||||
|
@ -273,8 +273,7 @@ BOARD* PCBNEW_JOBS_HANDLER::getBoard( const wxString& aPath )
|
||||
{
|
||||
BOARD* brd = nullptr;
|
||||
|
||||
if( !Pgm().IsGUI() &&
|
||||
Pgm().GetSettingsManager().IsProjectOpen() )
|
||||
if( !Pgm().IsGUI() && Pgm().GetSettingsManager().IsProjectOpen() )
|
||||
{
|
||||
wxString pcbPath = aPath;
|
||||
|
||||
@ -309,7 +308,7 @@ BOARD* PCBNEW_JOBS_HANDLER::getBoard( const wxString& aPath )
|
||||
brd = LoadBoard( aPath, true );
|
||||
}
|
||||
|
||||
if ( !brd )
|
||||
if( !brd )
|
||||
{
|
||||
m_reporter->Report( _( "Failed to load board\n" ), RPT_SEVERITY_ERROR );
|
||||
}
|
||||
@ -330,6 +329,7 @@ int PCBNEW_JOBS_HANDLER::JobExportStep( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
|
||||
@ -472,6 +472,7 @@ int PCBNEW_JOBS_HANDLER::JobExportRender( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
|
||||
@ -714,6 +715,8 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
|
||||
if( aSvgJob->m_genMode == JOB_EXPORT_PCB_SVG::GEN_MODE::SINGLE )
|
||||
{
|
||||
if( aSvgJob->GetOutputPath().IsEmpty() )
|
||||
@ -785,6 +788,7 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
loadOverrideDrawingSheet( brd, aDxfJob->m_drawingSheet );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
@ -855,6 +859,7 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
loadOverrideDrawingSheet( brd, aPdfJob->m_drawingSheet );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
@ -935,6 +940,7 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
loadOverrideDrawingSheet( brd, aGerberJob->m_drawingSheet );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
@ -1149,6 +1155,7 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
|
||||
@ -1228,6 +1235,8 @@ int PCBNEW_JOBS_HANDLER::JobExportDrill( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
|
||||
wxString outPath = aDrillJob->GetFullOutputPath( brd->GetProject() );
|
||||
|
||||
if( !PATHS::EnsurePathExists( outPath ) )
|
||||
@ -1344,9 +1353,9 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob )
|
||||
BOARD* brd = getBoard( aPosJob->m_filename );
|
||||
|
||||
if( !brd )
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
}
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
|
||||
if( aPosJob->GetOutputPath().IsEmpty() )
|
||||
{
|
||||
@ -1667,6 +1676,7 @@ int PCBNEW_JOBS_HANDLER::JobExportDrc( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
|
||||
@ -1843,6 +1853,8 @@ int PCBNEW_JOBS_HANDLER::JobExportIpc2581( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
|
||||
if( job->OutputPathFullSpecified() )
|
||||
{
|
||||
wxFileName fn = brd->GetFileName();
|
||||
@ -1936,6 +1948,8 @@ int PCBNEW_JOBS_HANDLER::JobExportOdb( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
|
||||
wxFileName fn( brd->GetFileName() );
|
||||
wxString path = job->GetOutputPath();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user