Add envVar and text variable resolution to plot directory paths.
Fixes https://gitlab.com/kicad/code/kicad/issues/3808
This commit is contained in:
parent
78159c6744
commit
b13559c926
|
@ -171,7 +171,7 @@ int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
GetAssociatedDocument( m_frame, helpFile, &m_frame->Kiway().Prj() );
|
||||
GetAssociatedDocument( m_frame, helpFile, &m_frame->Prj() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ protected:
|
|||
wxString filename = GetValue();
|
||||
|
||||
if( !filename.IsEmpty() && filename != wxT( "~" ) )
|
||||
GetAssociatedDocument( m_dlg, GetValue(), &m_dlg->Kiway().Prj() );
|
||||
GetAssociatedDocument( m_dlg, GetValue(), &m_dlg->Prj() );
|
||||
}
|
||||
|
||||
DIALOG_SHIM* m_dlg;
|
||||
|
@ -336,7 +336,7 @@ protected:
|
|||
if( path.IsEmpty() )
|
||||
path = *m_currentDir;
|
||||
else
|
||||
path = ExpandEnvVarSubstitutions( path, &m_dlg->Kiway().Prj() );
|
||||
path = ExpandEnvVarSubstitutions( path, &m_dlg->Prj() );
|
||||
|
||||
if( m_ext )
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ protected:
|
|||
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
||||
{
|
||||
wxString datasheet_uri = m_grid->GetCellValue( m_grid->GetGridCursorRow(), DATASHEET );
|
||||
GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Kiway().Prj() );
|
||||
GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
* Copyright (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2010 Lorenzo Marcantonio
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
*
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -155,10 +154,9 @@ void DIALOG_PLOT_SCHEMATIC::initDlg()
|
|||
*/
|
||||
void DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
// Build the absolute path of current output plot directory
|
||||
// to preselect it when opening the dialog.
|
||||
wxFileName fn( m_outputDirectoryName->GetValue() );
|
||||
wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() );
|
||||
// Build the absolute path of current output directory to preselect it in the file browser.
|
||||
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
|
||||
path = Prj().AbsolutePath( path );
|
||||
|
||||
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
||||
|
||||
|
@ -167,7 +165,7 @@ void DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked( wxCommandEvent& even
|
|||
|
||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||
|
||||
fn = Prj().AbsolutePath( g_RootSheet->GetFileName() );
|
||||
wxFileName fn( Prj().AbsolutePath( g_RootSheet->GetFileName() ) );
|
||||
wxString defaultPath = fn.GetPathWithSep();
|
||||
wxString msg;
|
||||
msg.Printf( _( "Do you want to use a path relative to\n\"%s\"" ), GetChars( defaultPath ) );
|
||||
|
@ -352,13 +350,12 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
|
|||
}
|
||||
|
||||
|
||||
wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirectoryName,
|
||||
wxString& aPlotFileName,
|
||||
wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxString& aPlotFileName,
|
||||
wxString& aExtension,
|
||||
REPORTER* aReporter )
|
||||
{
|
||||
wxString outputDirName = aOutputDirectoryName->GetValue();
|
||||
wxFileName outputDir = wxFileName::DirName( outputDirName );
|
||||
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
|
||||
wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT( "." ) + aExtension);
|
||||
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
* Copyright (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2010 Lorenzo Marcantonio
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
*
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -141,15 +140,12 @@ private:
|
|||
|
||||
/**
|
||||
* Create a file name with an absolute path name
|
||||
* @param aOutputDirectoryName the directory name to plot, this can be a relative name of the
|
||||
* current project directory or an absolute directory name.
|
||||
* @param aPlotFileName the name for the file to plot without a path
|
||||
* @param aExtension the extension for the file to plot
|
||||
* @param aReporter a point to a REPORTER object use to show messages (can be NULL)
|
||||
* @return the created file name
|
||||
* @throw IO_ERROR on file I/O errors
|
||||
*/
|
||||
wxFileName createPlotFileName( wxTextCtrl* aOutputDirectoryName,
|
||||
wxString& aPlotFileName,
|
||||
wxString& aExtension, REPORTER* aReporter = NULL );
|
||||
wxFileName createPlotFileName( wxString& aPlotFileName, wxString& aExtension,
|
||||
REPORTER* aReporter = NULL );
|
||||
};
|
||||
|
|
|
@ -691,7 +691,7 @@ void FIELDS_GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
|
|||
else if (event.GetId() == MYID_SHOW_DATASHEET )
|
||||
{
|
||||
wxString datasheet_uri = m_grid->GetCellValue( DATASHEET, FDC_VALUE );
|
||||
GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Kiway().Prj() );
|
||||
GetAssociatedDocument( m_dlg, datasheet_uri, &m_dlg->Prj() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -649,8 +649,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
pglayout.SetEmptyLayout();
|
||||
|
||||
BASE_SCREEN::m_PageLayoutDescrFileName = "empty.kicad_wks";
|
||||
wxFileName layoutfn( Kiway().Prj().GetProjectPath(),
|
||||
BASE_SCREEN::m_PageLayoutDescrFileName );
|
||||
wxFileName layoutfn( Prj().GetProjectPath(), BASE_SCREEN::m_PageLayoutDescrFileName );
|
||||
wxFile layoutfile;
|
||||
|
||||
if( layoutfile.Create( layoutfn.GetFullPath() ) )
|
||||
|
@ -659,9 +658,9 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
layoutfile.Close();
|
||||
}
|
||||
|
||||
projectpath = Kiway().Prj().GetProjectPath();
|
||||
newfilename.SetPath( Prj().GetProjectPath() );
|
||||
newfilename.SetName( Prj().GetProjectName() );
|
||||
projectpath = Prj().GetProjectPath();
|
||||
newfilename.SetPath( projectpath );
|
||||
newfilename.SetName( projectpath );
|
||||
newfilename.SetExt( LegacySchematicFileExtension );
|
||||
|
||||
g_CurrentSheet->clear();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 Lorenzo Marcantonio
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -72,8 +72,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef )
|
|||
{
|
||||
wxString fname = schframe->GetUniqueFilenameForCurrentSheet();
|
||||
wxString ext = DXF_PLOTTER::GetDefaultFileExtension();
|
||||
wxFileName plotFileName = createPlotFileName( m_outputDirectoryName, fname,
|
||||
ext, &reporter );
|
||||
wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
|
||||
|
||||
if( PlotOneSheetDXF( plotFileName.GetFullPath(), screen, plot_offset, 1.0,
|
||||
aPlotFrameRef ) )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -142,8 +142,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef )
|
|||
{
|
||||
wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
|
||||
wxString ext = HPGL_PLOTTER::GetDefaultFileExtension();
|
||||
wxFileName plotFileName = createPlotFileName( m_outputDirectoryName, fname,
|
||||
ext, &reporter );
|
||||
wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
|
||||
|
||||
LOCALE_IO toggle;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2010 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -87,7 +87,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef,
|
|||
{
|
||||
wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
|
||||
wxString ext = PDF_PLOTTER::GetDefaultFileExtension();
|
||||
plotFileName = createPlotFileName( m_outputDirectoryName, fname, ext, &reporter );
|
||||
plotFileName = createPlotFileName( fname, ext, &reporter );
|
||||
|
||||
if( !plotter->OpenFile( plotFileName.GetFullPath() ) )
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -91,8 +91,6 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef,
|
|||
|
||||
wxPoint plot_offset;
|
||||
|
||||
wxString outputDirName = m_outputDirectoryName->GetValue();
|
||||
|
||||
wxString msg;
|
||||
REPORTER& reporter = m_MessagesBox->Reporter();
|
||||
|
||||
|
@ -100,8 +98,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef,
|
|||
{
|
||||
wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
|
||||
wxString ext = PS_PLOTTER::GetDefaultFileExtension();
|
||||
wxFileName plotFileName = createPlotFileName( m_outputDirectoryName,
|
||||
fname, ext, &reporter );
|
||||
wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
|
||||
|
||||
if( plotOneSheetPS( plotFileName.GetFullPath(), screen, aDefaultLineWidth, plotPage,
|
||||
plot_offset, scale, aPlotFrameRef ) )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -66,8 +66,7 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef,
|
|||
{
|
||||
wxString fname = m_parent->GetUniqueFilenameForCurrentSheet();
|
||||
wxString ext = SVG_PLOTTER::GetDefaultFileExtension();
|
||||
wxFileName plotFileName = createPlotFileName( m_outputDirectoryName,
|
||||
fname, ext, &reporter );
|
||||
wxFileName plotFileName = createPlotFileName( fname, ext, &reporter );
|
||||
|
||||
bool success = plotOneSheetSVG( plotFileName.GetFullPath(), screen, aDefaultLineWidth,
|
||||
getModeColor() ? false : true, aPrintFrameRef );
|
||||
|
|
|
@ -292,21 +292,19 @@ void DIALOG_GENDRILL::UpdatePrecisionOptions()
|
|||
|
||||
void DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
// Build the absolute path of current output plot directory
|
||||
// to preselect it when opening the dialog.
|
||||
wxFileName fn( m_outputDirectoryName->GetValue() );
|
||||
wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() );
|
||||
// Build the absolute path of current output directory to preselect it in the file browser.
|
||||
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
|
||||
path = Prj().AbsolutePath( path );
|
||||
|
||||
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
||||
|
||||
if( dirDialog.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||
|
||||
fn = Prj().AbsolutePath( m_board->GetFileName() );
|
||||
wxString defaultPath = fn.GetPathWithSep();
|
||||
wxString msg;
|
||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||
wxFileName fn( Prj().AbsolutePath( m_board->GetFileName() ) );
|
||||
wxString defaultPath = fn.GetPathWithSep();
|
||||
wxString msg;
|
||||
msg.Printf( _( "Do you want to use a path relative to\n\"%s\"" ), GetChars( defaultPath ) );
|
||||
|
||||
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
|
||||
|
@ -378,7 +376,8 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap )
|
|||
|
||||
// Create output directory if it does not exist (also transform it in
|
||||
// absolute form). Bail if it fails
|
||||
wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() );
|
||||
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_board->GetFileName();
|
||||
|
||||
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
|
||||
|
@ -399,8 +398,8 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles( bool aGenDrill, bool aGenMap )
|
|||
excellonWriter.SetRouteModeForOvalHoles( m_UseRouteModeForOvalHoles );
|
||||
excellonWriter.SetMapFileFormat( filefmt[choice] );
|
||||
|
||||
excellonWriter.CreateDrillandMapFilesSet( outputDir.GetFullPath(),
|
||||
aGenDrill, aGenMap, &reporter );
|
||||
excellonWriter.CreateDrillandMapFilesSet( outputDir.GetFullPath(), aGenDrill, aGenMap,
|
||||
&reporter );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -427,7 +426,8 @@ void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event )
|
|||
fn.SetName( fn.GetName() + wxT( "-drl" ) );
|
||||
fn.SetExt( ReportFileExtension );
|
||||
|
||||
wxString defaultPath = Prj().AbsolutePath( m_plotOpts.GetOutputDirectory() );
|
||||
wxString defaultPath = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
defaultPath = Prj().AbsolutePath( defaultPath );
|
||||
|
||||
if( defaultPath.IsEmpty() )
|
||||
defaultPath = wxStandardPaths::Get().GetDocumentsDir();
|
||||
|
|
|
@ -346,10 +346,9 @@ void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
|
|||
|
||||
void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
// Build the absolute path of current output plot directory
|
||||
// to preselect it when opening the dialog.
|
||||
wxFileName fn( m_outputDirectoryName->GetValue() );
|
||||
wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() );
|
||||
// Build the absolute path of current output directory to preselect it in the file browser.
|
||||
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
|
||||
path = Prj().AbsolutePath( path );
|
||||
|
||||
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
||||
|
||||
|
@ -358,7 +357,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|||
|
||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||
|
||||
fn = Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() );
|
||||
wxFileName fn( Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ) );
|
||||
wxString defaultPath = fn.GetPathWithSep();
|
||||
wxString msg;
|
||||
msg.Printf( _( "Do you want to use a path relative to\n\"%s\"" ),
|
||||
|
@ -752,7 +751,8 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
|||
|
||||
// Create output directory if it does not exist (also transform it in
|
||||
// absolute form). Bail if it fails
|
||||
wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() );
|
||||
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_parent->GetBoard()->GetFileName();
|
||||
REPORTER& reporter = m_messagesPanel->Reporter();
|
||||
|
||||
|
|
Loading…
Reference in New Issue