diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index 4a8112bf46..62085c7e3f 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -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; } diff --git a/common/widgets/grid_text_button_helpers.cpp b/common/widgets/grid_text_button_helpers.cpp index bdb8c65f97..437cd8bb2d 100644 --- a/common/widgets/grid_text_button_helpers.cpp +++ b/common/widgets/grid_text_button_helpers.cpp @@ -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 ) { diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index d654aa0e26..767ff4dd6c 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -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 { diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 4aab70b858..8e52c1b7f6 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -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 - * - * 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); diff --git a/eeschema/dialogs/dialog_plot_schematic.h b/eeschema/dialogs/dialog_plot_schematic.h index 6b2f40d52d..4d8a390e09 100644 --- a/eeschema/dialogs/dialog_plot_schematic.h +++ b/eeschema/dialogs/dialog_plot_schematic.h @@ -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 - * - * 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 ); }; diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index b369834de9..4a78fcb68c 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -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 { diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 4a574447a6..1ac5109768 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -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(); diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index e5384964f4..b88aa9c119 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -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 ) ) diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index 0ddf601524..7bfc5a4957 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -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; diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index 61d2320a1f..a488dd2e5c 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -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() ) ) { diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index ae93747670..be842b2abd 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -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 ) ) diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index b20d2cefad..c9eb1fb0c1 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011-2016 Wayne Stambaugh - * 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 ); diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index 1c74b8c0b7..3346f39aea 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -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(); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index f83c7a46c2..1e56a593eb 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -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();