From 9a258df58aba148052551d6793c69608a9600caf Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 5 Apr 2020 22:17:26 +0100 Subject: [PATCH] Fix layout issues in Gen FP Positions dialog and add text var support. Also adds text var support to Export SVG dialog. --- pcbnew/dialogs/dialog_export_svg.cpp | 24 ++++++----- ...ialog_gen_footprint_position_file_base.cpp | 14 +++---- ...ialog_gen_footprint_position_file_base.fbp | 20 ++++----- .../dialog_gen_footprint_position_file_base.h | 2 +- pcbnew/exporters/gen_footprints_placefile.cpp | 42 ++++++++----------- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_svg.cpp b/pcbnew/dialogs/dialog_export_svg.cpp index 1319eb729b..152b451155 100644 --- a/pcbnew/dialogs/dialog_export_svg.cpp +++ b/pcbnew/dialogs/dialog_export_svg.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -77,11 +76,14 @@ private: * DIALOG_EXPORT_SVG functions */ DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_EDIT_FRAME* aParent, BOARD* aBoard ) : - DIALOG_EXPORT_SVG_BASE( aParent ), m_parent( aParent ), - m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true ) + DIALOG_EXPORT_SVG_BASE( aParent ), + m_board( aBoard ), + m_parent( aParent ), + m_printBW( false ), + m_printMirror( false ), + m_oneFileOnly( false ), + m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true ) { - m_board = aBoard; - memset( m_boxSelectLayer, 0, sizeof( m_boxSelectLayer ) ); m_browseButton->SetBitmap( KiBitmap( folder_xpm ) ); @@ -190,17 +192,16 @@ LSET DIALOG_EXPORT_SVG::getCheckBoxSelectedLayers() const void DIALOG_EXPORT_SVG::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() ); + wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() ); wxMessageDialog dialog( this, _( "Use a relative path?" ), _( "Plot Output Directory" ), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); @@ -227,7 +228,8 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile ) // Create output directory if it does not exist (also transform it in // absolute form). Bail if it fails - wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); + wxString path = ExpandEnvVarSubstitutions( m_outputDirectory, &Prj() ); + wxFileName outputDir = wxFileName::DirName( path ); wxString boardFilename = m_board->GetFileName(); REPORTER& reporter = m_messagesPanel->Reporter(); diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp index ec93231db8..d462e529fb 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -31,7 +31,7 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_outputDirectoryName->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the board file location.") ); m_outputDirectoryName->SetMinSize( wxSize( 350,-1 ) ); - bSizerdirBrowse->Add( m_outputDirectoryName, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bSizerdirBrowse->Add( m_outputDirectoryName, 1, wxALIGN_CENTER_VERTICAL, 5 ); m_browseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_browseButton->SetMinSize( wxSize( 30,28 ) ); @@ -39,7 +39,7 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow bSizerdirBrowse->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - bUpperSizer->Add( bSizerdirBrowse, 0, wxEXPAND|wxALL, 5 ); + bUpperSizer->Add( bSizerdirBrowse, 1, wxEXPAND|wxALL, 10 ); m_MainSizer->Add( bUpperSizer, 0, wxEXPAND, 2 ); @@ -51,21 +51,21 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow int m_rbFormatNChoices = sizeof( m_rbFormatChoices ) / sizeof( wxString ); m_rbFormat = new wxRadioBox( this, wxID_ANY, _("Format"), wxDefaultPosition, wxDefaultSize, m_rbFormatNChoices, m_rbFormatChoices, 1, wxRA_SPECIFY_COLS ); m_rbFormat->SetSelection( 2 ); - bSizerMiddle->Add( m_rbFormat, 0, wxALL, 5 ); + bSizerMiddle->Add( m_rbFormat, 1, wxALL|wxEXPAND, 5 ); wxString m_radioBoxUnitsChoices[] = { _("Inches"), _("Millimeters") }; int m_radioBoxUnitsNChoices = sizeof( m_radioBoxUnitsChoices ) / sizeof( wxString ); m_radioBoxUnits = new wxRadioBox( this, wxID_ANY, _("Units"), wxDefaultPosition, wxDefaultSize, m_radioBoxUnitsNChoices, m_radioBoxUnitsChoices, 1, wxRA_SPECIFY_COLS ); m_radioBoxUnits->SetSelection( 0 ); - bSizerMiddle->Add( m_radioBoxUnits, 0, wxALL, 5 ); + bSizerMiddle->Add( m_radioBoxUnits, 1, wxALL|wxEXPAND, 5 ); - wxString m_radioBoxFilesCountChoices[] = { _("Separate files for front and back"), _("Single file for board") }; + wxString m_radioBoxFilesCountChoices[] = { _("Separate files for front, back"), _("Single file for board") }; int m_radioBoxFilesCountNChoices = sizeof( m_radioBoxFilesCountChoices ) / sizeof( wxString ); m_radioBoxFilesCount = new wxRadioBox( this, wxID_ANY, _("Files"), wxDefaultPosition, wxDefaultSize, m_radioBoxFilesCountNChoices, m_radioBoxFilesCountChoices, 1, wxRA_SPECIFY_COLS ); m_radioBoxFilesCount->SetSelection( 0 ); m_radioBoxFilesCount->SetToolTip( _("Creates 2 files: one for each board side or\nCreates only one file containing all footprints to place\n") ); - bSizerMiddle->Add( m_radioBoxFilesCount, 0, wxALL, 5 ); + bSizerMiddle->Add( m_radioBoxFilesCount, 1, wxALL|wxEXPAND, 5 ); m_MainSizer->Add( bSizerMiddle, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp index bb08cea8fa..cab15b4137 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp @@ -68,9 +68,9 @@ wxHORIZONTAL none - 5 + 10 wxEXPAND|wxALL - 0 + 1 bSizerdirBrowse @@ -140,7 +140,7 @@ 5 wxALIGN_CENTER_VERTICAL - 0 + 1 1 1 @@ -289,8 +289,8 @@ none 5 - wxALL - 0 + wxALL|wxEXPAND + 1 1 1 @@ -356,8 +356,8 @@ 5 - wxALL - 0 + wxALL|wxEXPAND + 1 1 1 @@ -423,8 +423,8 @@ 5 - wxALL - 0 + wxALL|wxEXPAND + 1 1 1 @@ -439,7 +439,7 @@ 1 0 - "Separate files for front and back" "Single file for board" + "Separate files for front, back" "Single file for board" 1 1 diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h index 9fc536084d..a3145763bc 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/pcbnew/exporters/gen_footprints_placefile.cpp b/pcbnew/exporters/gen_footprints_placefile.cpp index 19138027e8..6e5fc7c901 100644 --- a/pcbnew/exporters/gen_footprints_placefile.cpp +++ b/pcbnew/exporters/gen_footprints_placefile.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015-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 @@ -34,13 +34,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -119,11 +117,6 @@ private: bool CreateGerberFiles(); // accessors to options: - wxString GetOutputDirectory() - { - return m_outputDirectoryName->GetValue(); - } - bool UnitsMM() { return m_radioBoxUnits->GetSelection() == 1; @@ -177,9 +170,9 @@ void DIALOG_GEN_FOOTPRINT_POSITION::initDialog() void DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { - // Build the absolute path of current output plot directory - // to preselect it when opening the dialog. - 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 ); @@ -240,10 +233,10 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles() wxString msg; int fullcount = 0; - // Create output directory if it does not exist. - // Also transform it in absolute path. + // Create output directory if it does not exist. Also transform it in absolute path. // 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(); m_reporter = &m_messagesPanel->Reporter(); @@ -327,7 +320,8 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() // Test for any footprint candidate in list, and display the list of forced footprints // if ForceAllSmd() is true { - PLACE_FILE_EXPORTER exporter( brd, UnitsMM(), ForceAllSmd(), top_side, bottom_side, useCSVfmt ); + PLACE_FILE_EXPORTER exporter( brd, UnitsMM(), ForceAllSmd(), top_side, bottom_side, + useCSVfmt ); exporter.GenPositionData(); if( exporter.GetFootprintCount() == 0) @@ -342,7 +336,8 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles() for( MODULE* item : fp_no_smd_list ) { - msg.Printf( _( "footprint %s (not set as SMD) forced in list" ), item->GetReference() ); + msg.Printf( _( "footprint %s (not set as SMD) forced in list" ), + item->GetReference() ); m_reporter->Report( msg, RPT_SEVERITY_INFO ); } } @@ -477,7 +472,8 @@ int PCB_EDITOR_CONTROL::GeneratePosFile( const TOOL_EVENT& aEvent ) int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, bool aUnitsMM, - bool aForceSmdItems, bool aTopSide, bool aBottomSide, bool aFormatCSV ) + bool aForceSmdItems, bool aTopSide, + bool aBottomSide, bool aFormatCSV ) { FILE * file = NULL; @@ -490,8 +486,8 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, } std::string data; - PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aForceSmdItems, - aTopSide, aBottomSide, aFormatCSV ); + PLACE_FILE_EXPORTER exporter( GetBoard(), aUnitsMM, aForceSmdItems, aTopSide, aBottomSide, + aFormatCSV ); data = exporter.GenPositionData(); // if aFullFileName is empty, the file is not created, only the @@ -514,7 +510,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 ) @@ -545,11 +541,7 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) */ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool aUnitsMM ) { - wxString msg; - FILE* rptfile; - wxPoint module_pos; - - rptfile = wxFopen( aFullFilename, wxT( "wt" ) ); + FILE* rptfile = wxFopen( aFullFilename, wxT( "wt" ) ); if( rptfile == NULL ) return false;