Move some MRU paths from app to project.
Also augments Save As path updating to handle these newly-moved paths, and to handle absolute paths that point into the project directory.
This commit is contained in:
parent
265720ec65
commit
56752e9bad
|
@ -53,37 +53,47 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
|
|||
|
||||
m_params.emplace_back( new PARAM_WXSTRING_MAP( "text_variables", &m_TextVars, {} ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs", &m_PinnedSymbolLibs, {} ) );
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( "libraries.pinned_symbol_libs",
|
||||
&m_PinnedSymbolLibs, {} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>(
|
||||
"libraries.pinned_footprint_libs", &m_PinnedFootprintLibs, {} ) );
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( "libraries.pinned_footprint_libs",
|
||||
&m_PinnedFootprintLibs, {} ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH_LIST( "cvpcb.equivalence_files", &m_EquivalenceFiles, {} ) );
|
||||
m_params.emplace_back( new PARAM_PATH_LIST( "cvpcb.equivalence_files",
|
||||
&m_EquivalenceFiles, {} ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.page_layout_descr_file", &m_BoardDrawingSheetFile, "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.page_layout_descr_file",
|
||||
&m_BoardDrawingSheetFile, "" ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.netlist", &m_PcbLastPath[LAST_PATH_NETLIST], "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.netlist",
|
||||
&m_PcbLastPath[LAST_PATH_NETLIST], "" ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.step", &m_PcbLastPath[LAST_PATH_STEP], "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.step",
|
||||
&m_PcbLastPath[LAST_PATH_STEP], "" ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.idf", &m_PcbLastPath[LAST_PATH_IDF], "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.idf",
|
||||
&m_PcbLastPath[LAST_PATH_IDF], "" ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.vrml", &m_PcbLastPath[LAST_PATH_VRML], "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.vrml",
|
||||
&m_PcbLastPath[LAST_PATH_VRML], "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_PATH(
|
||||
"pcbnew.last_paths.specctra_dsn", &m_PcbLastPath[LAST_PATH_SPECCTRADSN], "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.specctra_dsn",
|
||||
&m_PcbLastPath[LAST_PATH_SPECCTRADSN], "" ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM_PATH( "pcbnew.last_paths.gencad", &m_PcbLastPath[LAST_PATH_GENCAD], "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.gencad",
|
||||
&m_PcbLastPath[LAST_PATH_GENCAD], "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( "schematic.legacy_lib_dir", &m_LegacyLibDir, "" ) );
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.pos_files",
|
||||
&m_PcbLastPath[LAST_PATH_POS_FILES], "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.svg",
|
||||
&m_PcbLastPath[LAST_PATH_SVG], "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_PATH( "pcbnew.last_paths.plot",
|
||||
&m_PcbLastPath[LAST_PATH_PLOT], "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( "schematic.legacy_lib_dir",
|
||||
&m_LegacyLibDir, "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "schematic.legacy_lib_list",
|
||||
[&]() -> nlohmann::json
|
||||
|
@ -571,6 +581,7 @@ bool PROJECT_FILE::SaveAs( const wxString& aDirectory, const wxString& aFile )
|
|||
{
|
||||
wxFileName oldFilename( GetFilename() );
|
||||
wxString oldProjectName = oldFilename.GetName();
|
||||
wxString oldProjectPath = oldFilename.GetPath();
|
||||
|
||||
Set( "meta.filename", aFile + "." + ProjectFileExtension );
|
||||
SetFilename( aFile );
|
||||
|
@ -580,14 +591,28 @@ bool PROJECT_FILE::SaveAs( const wxString& aDirectory, const wxString& aFile )
|
|||
{
|
||||
if( aPath.StartsWith( oldProjectName + wxS( "." ) ) )
|
||||
aPath.Replace( oldProjectName, aFile, false );
|
||||
else if( aPath.StartsWith( oldProjectPath + wxS( "/" ) ) )
|
||||
aPath.Replace( oldProjectPath, aDirectory, false );
|
||||
};
|
||||
|
||||
updatePath( m_PcbLastPath[ LAST_PATH_NETLIST ] );
|
||||
updatePath( m_PcbLastPath[ LAST_PATH_STEP ] );
|
||||
updatePath( m_PcbLastPath[ LAST_PATH_IDF ] );
|
||||
updatePath( m_PcbLastPath[ LAST_PATH_VRML ] );
|
||||
updatePath( m_PcbLastPath[ LAST_PATH_SPECCTRADSN ] );
|
||||
updatePath( m_PcbLastPath[ LAST_PATH_GENCAD ] );
|
||||
updatePath( m_BoardDrawingSheetFile );
|
||||
|
||||
for( int ii = LAST_PATH_FIRST; ii < (int) LAST_PATH_SIZE; ++ii )
|
||||
updatePath( m_PcbLastPath[ ii ] );
|
||||
|
||||
auto updatePathByPtr =
|
||||
[&]( const std::string& aPtr )
|
||||
{
|
||||
if( std::optional<wxString> path = Get<wxString>( aPtr ) )
|
||||
{
|
||||
updatePath( path.value() );
|
||||
Set( aPtr, path.value() );
|
||||
}
|
||||
};
|
||||
|
||||
updatePathByPtr( "schematic.page_layout_descr_file" );
|
||||
updatePathByPtr( "schematic.plot_directory" );
|
||||
updatePathByPtr( "schematic.ngspice.workbook_filename" );
|
||||
|
||||
// While performing Save As, we have already checked that we can write to the directory
|
||||
// so don't carry the previous flag
|
||||
|
|
|
@ -45,12 +45,16 @@ typedef std::pair<KIID, wxString> FILE_INFO_PAIR;
|
|||
*/
|
||||
enum LAST_PATH_TYPE : unsigned int
|
||||
{
|
||||
LAST_PATH_NETLIST = 0,
|
||||
LAST_PATH_FIRST = 0,
|
||||
LAST_PATH_NETLIST = LAST_PATH_FIRST,
|
||||
LAST_PATH_STEP,
|
||||
LAST_PATH_IDF,
|
||||
LAST_PATH_VRML,
|
||||
LAST_PATH_SPECCTRADSN,
|
||||
LAST_PATH_GENCAD,
|
||||
LAST_PATH_POS_FILES,
|
||||
LAST_PATH_SVG,
|
||||
LAST_PATH_PLOT,
|
||||
|
||||
LAST_PATH_SIZE
|
||||
};
|
||||
|
|
|
@ -27,13 +27,10 @@
|
|||
#include <pcbnew_settings.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <reporter.h>
|
||||
#include <board_design_settings.h>
|
||||
#include <confirm.h>
|
||||
#include <core/arraydim.h>
|
||||
#include <core/kicad_algo.h>
|
||||
#include <pcbplot.h>
|
||||
#include <locale_io.h>
|
||||
#include <board.h>
|
||||
#include <dialog_export_svg_base.h>
|
||||
#include <bitmaps.h>
|
||||
#include <widgets/std_bitmap_button.h>
|
||||
|
@ -41,6 +38,7 @@
|
|||
#include <plotters/plotters_pslike.h>
|
||||
#include <wx/dirdlg.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project/project_file.h>
|
||||
#include <pcb_plot_svg.h>
|
||||
|
||||
class DIALOG_EXPORT_SVG : public DIALOG_EXPORT_SVG_BASE
|
||||
|
@ -104,6 +102,8 @@ DIALOG_EXPORT_SVG::~DIALOG_EXPORT_SVG()
|
|||
m_outputDirectory = m_outputDirectoryName->GetValue();
|
||||
m_outputDirectory.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
|
||||
m_parent->Prj().GetProjectFile().m_PcbLastPath[ LAST_PATH_SVG ] = m_outputDirectory;
|
||||
|
||||
auto cfg = m_parent->GetPcbNewSettings();
|
||||
|
||||
cfg->m_ExportSvg.black_and_white = m_printBW;
|
||||
|
@ -137,12 +137,17 @@ DIALOG_EXPORT_SVG::~DIALOG_EXPORT_SVG()
|
|||
|
||||
void DIALOG_EXPORT_SVG::initDialog()
|
||||
{
|
||||
PROJECT_FILE& projectFile = m_parent->Prj().GetProjectFile();
|
||||
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
||||
|
||||
m_printBW = cfg->m_ExportSvg.black_and_white;
|
||||
m_printMirror = cfg->m_ExportSvg.mirror;
|
||||
m_oneFileOnly = cfg->m_ExportSvg.one_file;
|
||||
m_outputDirectory = cfg->m_ExportSvg.output_dir;
|
||||
|
||||
if( !projectFile.m_PcbLastPath[ LAST_PATH_SVG ].IsEmpty() )
|
||||
m_outputDirectory = projectFile.m_PcbLastPath[ LAST_PATH_SVG ];
|
||||
else
|
||||
m_outputDirectory = cfg->m_ExportSvg.output_dir;
|
||||
|
||||
m_rbSvgPageSizeOpt->SetSelection( cfg->m_ExportSvg.page_size );
|
||||
m_checkboxPagePerLayer->SetValue( !m_oneFileOnly );
|
||||
|
|
|
@ -27,14 +27,12 @@
|
|||
*/
|
||||
|
||||
#include <confirm.h>
|
||||
#include <string_utils.h>
|
||||
#include <gestfich.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <project/project_file.h>
|
||||
#include <bitmaps.h>
|
||||
#include <reporter.h>
|
||||
#include <tools/board_editor_control.h>
|
||||
#include <board.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <kiface_base.h>
|
||||
#include <widgets/wx_html_report_panel.h>
|
||||
|
@ -169,12 +167,16 @@ void DIALOG_GEN_FOOTPRINT_POSITION::initDialog()
|
|||
{
|
||||
m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
|
||||
|
||||
PROJECT_FILE& projectFile = m_parent->Prj().GetProjectFile();
|
||||
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
||||
|
||||
m_units = cfg->m_PlaceFile.units == 0 ? EDA_UNITS::INCHES : EDA_UNITS::MILLIMETRES;
|
||||
|
||||
// Output directory
|
||||
m_outputDirectoryName->SetValue( cfg->m_PlaceFile.output_directory );
|
||||
if( !projectFile.m_PcbLastPath[ LAST_PATH_POS_FILES ].IsEmpty() )
|
||||
m_outputDirectoryName->SetValue( projectFile.m_PcbLastPath[ LAST_PATH_POS_FILES ] );
|
||||
else
|
||||
m_outputDirectoryName->SetValue( cfg->m_PlaceFile.output_directory );
|
||||
|
||||
// Update Options
|
||||
m_radioBoxUnits->SetSelection( cfg->m_PlaceFile.units );
|
||||
|
@ -191,6 +193,7 @@ void DIALOG_GEN_FOOTPRINT_POSITION::initDialog()
|
|||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
||||
{
|
||||
// Build the absolute path of current output directory to preselect it in the file browser.
|
||||
|
@ -212,9 +215,11 @@ void DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEve
|
|||
wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath();
|
||||
|
||||
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
||||
{
|
||||
wxMessageBox( _( "Cannot make path relative (target volume different from board "
|
||||
"file volume)!" ),
|
||||
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
||||
|
@ -231,8 +236,8 @@ void DIALOG_GEN_FOOTPRINT_POSITION::OnGenerate( wxCommandEvent& event )
|
|||
// Keep unix directory format convention in cfg files
|
||||
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
|
||||
m_parent->Prj().GetProjectFile().m_PcbLastPath[LAST_PATH_POS_FILES] = dirStr;
|
||||
cfg->m_PlaceFile.output_directory = dirStr;
|
||||
|
||||
cfg->m_PlaceFile.units = m_units == EDA_UNITS::INCHES ? 0 : 1;
|
||||
cfg->m_PlaceFile.file_options = m_radioBoxFilesCount->GetSelection();
|
||||
cfg->m_PlaceFile.file_format = m_rbFormat->GetSelection();
|
||||
|
@ -252,7 +257,6 @@ void DIALOG_GEN_FOOTPRINT_POSITION::OnGenerate( wxCommandEvent& event )
|
|||
bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles()
|
||||
{
|
||||
BOARD* brd = m_parent->GetBoard();
|
||||
wxFileName fn;
|
||||
wxString msg;
|
||||
int fullcount = 0;
|
||||
|
||||
|
@ -282,13 +286,13 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles()
|
|||
return false;
|
||||
}
|
||||
|
||||
fn = m_parent->GetBoard()->GetFileName();
|
||||
wxFileName fn = m_parent->GetBoard()->GetFileName();
|
||||
fn.SetPath( outputDir.GetPath() );
|
||||
|
||||
// Create the Front and Top side placement files. Gerber P&P files are always separated.
|
||||
// Not also they include all footprints
|
||||
PLACEFILE_GERBER_WRITER exporter( brd );
|
||||
wxString filename = exporter.GetPlaceFileName( fn.GetFullPath(), F_Cu );
|
||||
wxString filename = exporter.GetPlaceFileName( fn.GetFullPath(), F_Cu );
|
||||
|
||||
int fpcount = exporter.CreatePlaceFile( filename, F_Cu, m_cbIncludeBoardEdge->GetValue() );
|
||||
|
||||
|
@ -341,7 +345,6 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles()
|
|||
bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
||||
{
|
||||
BOARD * brd = m_parent->GetBoard();
|
||||
wxFileName fn;
|
||||
wxString msg;
|
||||
bool singleFile = OneFileOnly();
|
||||
bool useCSVfmt = m_rbFormat->GetSelection() == 1;
|
||||
|
@ -390,7 +393,7 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
|||
return false;
|
||||
}
|
||||
|
||||
fn = m_parent->GetBoard()->GetFileName();
|
||||
wxFileName fn = m_parent->GetBoard()->GetFileName();
|
||||
fn.SetPath( outputDir.GetPath() );
|
||||
|
||||
// Create the Front or Top side placement file, or a single file
|
||||
|
@ -493,16 +496,13 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
|||
}
|
||||
|
||||
m_reporter->Report( _( "File generation successful." ), RPT_SEVERITY_INFO );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int BOARD_EDITOR_CONTROL::GeneratePosFile( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
||||
DIALOG_GEN_FOOTPRINT_POSITION dlg( editFrame );
|
||||
|
||||
DIALOG_GEN_FOOTPRINT_POSITION dlg( getEditFrame<PCB_EDIT_FRAME>() );
|
||||
dlg.ShowModal();
|
||||
return 0;
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
|
|||
{
|
||||
wxFileName fn;
|
||||
|
||||
wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName() ).GetPath();
|
||||
wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName() ).GetPath();
|
||||
wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
|
||||
|
||||
if( dirDialog.ShowModal() == wxID_CANCEL )
|
||||
|
@ -568,7 +568,6 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
|
|||
msg.Printf( _( "Footprint report file created:\n'%s'." ), fn.GetFullPath() );
|
||||
wxMessageBox( msg, _( "Footprint Report" ), wxICON_INFORMATION );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
|
||||
|
|
|
@ -25,11 +25,10 @@
|
|||
#include <wx/clntdata.h>
|
||||
#include <wx/rearrangectrl.h>
|
||||
|
||||
#include <kiface_base.h>
|
||||
#include <plotters/plotter.h>
|
||||
#include <confirm.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <project/project_file.h>
|
||||
#include <pcbplot.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gerber_jobfile_writer.h>
|
||||
|
@ -38,8 +37,6 @@
|
|||
#include <layer_ids.h>
|
||||
#include <locale_io.h>
|
||||
#include <bitmaps.h>
|
||||
#include <board.h>
|
||||
#include <board_design_settings.h>
|
||||
#include <dialog_plot.h>
|
||||
#include <dialog_gendrill.h>
|
||||
#include <widgets/wx_html_report_panel.h>
|
||||
|
@ -200,7 +197,11 @@ void DIALOG_PLOT::init_Dialog()
|
|||
BOARD* board = m_parent->GetBoard();
|
||||
wxFileName fileName;
|
||||
|
||||
auto cfg = m_parent->GetPcbNewSettings();
|
||||
PROJECT_FILE& projectFile = m_parent->Prj().GetProjectFile();
|
||||
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
||||
|
||||
if( !projectFile.m_PcbLastPath[ LAST_PATH_PLOT ].IsEmpty() )
|
||||
m_plotOpts.SetOutputDirectory( projectFile.m_PcbLastPath[ LAST_PATH_PLOT ] );
|
||||
|
||||
m_XScaleAdjust = cfg->m_Plot.fine_scale_x;
|
||||
m_YScaleAdjust = cfg->m_Plot.fine_scale_y;
|
||||
|
@ -940,6 +941,7 @@ void DIALOG_PLOT::applyPlotSettings()
|
|||
dirStr = m_outputDirectoryName->GetValue();
|
||||
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
||||
tempOptions.SetOutputDirectory( dirStr );
|
||||
m_parent->Prj().GetProjectFile().m_PcbLastPath[ LAST_PATH_PLOT ] = dirStr;
|
||||
|
||||
if( !m_plotOpts.IsSameAs( tempOptions ) )
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 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
|
||||
|
@ -37,9 +37,7 @@
|
|||
#include <tools/pcb_actions.h>
|
||||
#include <tools/board_editor_control.h>
|
||||
#include <tools/pad_tool.h>
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pcb_text.h>
|
||||
#include <board_commit.h>
|
||||
#include <footprint_edit_frame.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
@ -236,8 +234,7 @@ FOOTPRINT* try_load_footprint( const wxFileName& aFileName, IO_MGR::PCB_FILE_T a
|
|||
|
||||
FOOTPRINT* FOOTPRINT_EDIT_FRAME::ImportFootprint( const wxString& aName )
|
||||
{
|
||||
FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings();
|
||||
wxFileName fn;
|
||||
wxFileName fn;
|
||||
|
||||
if( aName != wxT("") )
|
||||
fn = aName;
|
||||
|
|
|
@ -193,7 +193,7 @@ public:
|
|||
bool one_file;
|
||||
bool plot_board_edges;
|
||||
int page_size;
|
||||
wxString output_dir;
|
||||
wxString output_dir; // legacy; now in project settings
|
||||
std::vector<int> layers;
|
||||
};
|
||||
|
||||
|
@ -250,7 +250,7 @@ public:
|
|||
|
||||
struct DIALOG_PLACE_FILE
|
||||
{
|
||||
wxString output_directory;
|
||||
wxString output_directory; // legacy; now in project settings
|
||||
int units;
|
||||
int file_options;
|
||||
int file_format;
|
||||
|
|
Loading…
Reference in New Issue