Fix layout issues in Gen FP Positions dialog and add text var support.

Also adds text var support to Export SVG dialog.
This commit is contained in:
Jeff Young 2020-04-05 22:17:26 +01:00
parent b13559c926
commit 9a258df58a
5 changed files with 48 additions and 54 deletions

View File

@ -36,7 +36,6 @@
#include <pcbplot.h>
#include <class_board.h>
#include <dialog_export_svg_base.h>
#include <invoke_pcb_dialog.h>
#include <wx_html_report_panel.h>
#include <bitmaps.h>
#include <widgets/unit_binder.h>
@ -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();

View File

@ -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 );

View File

@ -68,9 +68,9 @@
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="border">10</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerdirBrowse</property>
@ -140,7 +140,7 @@
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -289,8 +289,8 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -356,8 +356,8 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -423,8 +423,8 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
@ -439,7 +439,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Separate files for front and back&quot; &quot;Single file for board&quot;</property>
<property name="choices">&quot;Separate files for front, back&quot; &quot;Single file for board&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>

View File

@ -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!

View File

@ -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 <pcbnew_settings.h>
#include <pgm_base.h>
#include <bitmaps.h>
#include <build_version.h>
#include <macros.h>
#include <reporter.h>
#include <tools/pcb_editor_control.h>
#include <class_board.h>
#include <class_module.h>
#include <pcbnew.h>
#include <wildcards_and_files_ext.h>
#include <kiface_i.h>
#include <wx_html_report_panel.h>
@ -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;