mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 15:01:41 +00:00
Remove ability to specify fp sides for position file jobs.
This commit is contained in:
parent
a8582e9054
commit
044fe24293
@ -52,6 +52,8 @@ JOB_EXPORT_PCB_POS::JOB_EXPORT_PCB_POS() :
|
||||
m_excludeDNP( false ),
|
||||
m_negateBottomX( false ),
|
||||
m_side( SIDE::BOTH ),
|
||||
m_singleFile( false ),
|
||||
m_nakedFilename( false ),
|
||||
m_units( UNITS::MILLIMETERS ),
|
||||
m_format( FORMAT::ASCII ),
|
||||
m_gerberBoardEdge( true )
|
||||
@ -76,6 +78,10 @@ JOB_EXPORT_PCB_POS::JOB_EXPORT_PCB_POS() :
|
||||
&m_negateBottomX,
|
||||
m_negateBottomX ) );
|
||||
|
||||
m_params.emplace_back( new JOB_PARAM<bool>( "single_file",
|
||||
&m_singleFile,
|
||||
m_singleFile ) );
|
||||
|
||||
m_params.emplace_back( new JOB_PARAM<bool>( "gerber_board_edge",
|
||||
&m_gerberBoardEdge,
|
||||
m_gerberBoardEdge ) );
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
bool m_excludeFootprintsWithTh;
|
||||
bool m_excludeDNP;
|
||||
bool m_negateBottomX;
|
||||
bool m_singleFile;
|
||||
bool m_nakedFilename;
|
||||
|
||||
enum class SIDE
|
||||
{
|
||||
|
@ -108,6 +108,8 @@ int CLI::PCB_EXPORT_POS_COMMAND::doPerform( KIWAY& aKiway )
|
||||
}
|
||||
|
||||
aPosJob->m_negateBottomX = m_argParser.get<bool>( ARG_NEGATE_BOTTOM_X );
|
||||
aPosJob->m_singleFile = true;
|
||||
aPosJob->m_nakedFilename = true;
|
||||
aPosJob->m_smdOnly = m_argParser.get<bool>( ARG_SMD_ONLY );
|
||||
aPosJob->m_excludeFootprintsWithTh = m_argParser.get<bool>( ARG_EXCLUDE_FOOTPRINTS_TH );
|
||||
aPosJob->m_useDrillPlaceFileOrigin = m_argParser.get<bool>( ARG_USE_DRILL_FILE_ORIGIN );
|
||||
|
@ -95,9 +95,6 @@ void DIALOG_GEN_FOOTPRINT_POSITION::initDialog()
|
||||
// Output directory
|
||||
m_outputDirectoryName->SetValue( projectFile.m_PcbLastPath[LAST_PATH_POS_FILES] );
|
||||
|
||||
m_sideLabel->Hide();
|
||||
m_sideCtrl->Hide();
|
||||
|
||||
// Update Options
|
||||
m_unitsCtrl->SetSelection( cfg->m_PlaceFile.units );
|
||||
m_singleFile->SetValue( cfg->m_PlaceFile.file_options == 1 );
|
||||
@ -123,16 +120,8 @@ void DIALOG_GEN_FOOTPRINT_POSITION::initDialog()
|
||||
m_staticTextDir->SetLabel( _( "Output file:" ) );
|
||||
m_outputDirectoryName->SetValue( m_job->GetConfiguredOutputPath() );
|
||||
|
||||
switch( m_job->m_side )
|
||||
{
|
||||
case JOB_EXPORT_PCB_POS::SIDE::FRONT: m_sideCtrl->SetSelection( 0 ); break;
|
||||
case JOB_EXPORT_PCB_POS::SIDE::BACK: m_sideCtrl->SetSelection( 1 ); break;
|
||||
default: m_sideCtrl->SetSelection( 2 ); break;
|
||||
}
|
||||
|
||||
m_singleFile->Hide();
|
||||
|
||||
m_unitsCtrl->SetSelection( static_cast<int>( m_job->m_units ) );
|
||||
m_singleFile->SetValue( m_job->m_singleFile );
|
||||
m_formatCtrl->SetSelection( static_cast<int>( m_job->m_format ) );
|
||||
m_cbIncludeBoardEdge->SetValue( m_job->m_gerberBoardEdge );
|
||||
m_useDrillPlaceOrigin->SetValue( m_job->m_useDrillPlaceFileOrigin );
|
||||
@ -162,8 +151,6 @@ void DIALOG_GEN_FOOTPRINT_POSITION::onUpdateUIUnits( wxUpdateUIEvent& event )
|
||||
void DIALOG_GEN_FOOTPRINT_POSITION::onUpdateUIFileOpt( wxUpdateUIEvent& event )
|
||||
{
|
||||
m_singleFile->Enable( m_formatCtrl->GetSelection() != 2 );
|
||||
m_sideLabel->Enable( m_formatCtrl->GetSelection() != 2 );
|
||||
m_sideCtrl->Enable( m_formatCtrl->GetSelection() != 2 );
|
||||
}
|
||||
|
||||
|
||||
@ -310,14 +297,8 @@ void DIALOG_GEN_FOOTPRINT_POSITION::onGenerate( wxCommandEvent& event )
|
||||
m_job->m_units = m_unitsCtrl->GetSelection() == 0 ? JOB_EXPORT_PCB_POS::UNITS::INCHES
|
||||
: JOB_EXPORT_PCB_POS::UNITS::MILLIMETERS;
|
||||
m_job->m_format = static_cast<JOB_EXPORT_PCB_POS::FORMAT>( m_formatCtrl->GetSelection() );
|
||||
|
||||
switch( m_sideCtrl->GetSelection() )
|
||||
{
|
||||
case 0: m_job->m_side = JOB_EXPORT_PCB_POS::SIDE::FRONT; break;
|
||||
case 1: m_job->m_side = JOB_EXPORT_PCB_POS::SIDE::BACK; break;
|
||||
default: m_job->m_side = JOB_EXPORT_PCB_POS::SIDE::BOTH; break;
|
||||
}
|
||||
|
||||
m_job->m_side = JOB_EXPORT_PCB_POS::SIDE::BOTH;
|
||||
m_job->m_singleFile = m_singleFile->GetValue();
|
||||
m_job->m_gerberBoardEdge = m_cbIncludeBoardEdge->GetValue();
|
||||
m_job->m_excludeFootprintsWithTh = m_excludeTH->GetValue();
|
||||
m_job->m_smdOnly = m_onlySMD->GetValue();
|
||||
@ -450,14 +431,14 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles board->GetTitleBlock() *and* board->GetProject()
|
||||
return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
|
||||
return m_editFrame->GetBoard()->ResolveTextVar( token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_editFrame->GetPcbNewSettings()->m_PlaceFile.output_directory;
|
||||
path = ExpandTextVars( path, &textResolver );
|
||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxFileName outputDir = wxFileName::DirName( path );
|
||||
wxString boardFilename = m_editFrame->GetBoard()->GetFileName();
|
||||
|
||||
m_reporter = &m_messagesPanel->Reporter();
|
||||
@ -474,28 +455,16 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
||||
|
||||
// Create the Front or Top side placement file, or a single file
|
||||
topSide = true;
|
||||
bottomSide = false;
|
||||
|
||||
if( singleFile )
|
||||
{
|
||||
bottomSide = true;
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + wxT( "all" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + PLACE_FILE_EXPORTER::GetFrontSideName().c_str() );
|
||||
}
|
||||
bottomSide = singleFile;
|
||||
|
||||
fn.SetName( PLACE_FILE_EXPORTER::DecorateFilename( fn.GetName(), topSide, bottomSide ) );
|
||||
fn.SetExt( FILEEXT::FootprintPlaceFileExtension );
|
||||
|
||||
if( useCSVfmt )
|
||||
{
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + FILEEXT::FootprintPlaceFileExtension );
|
||||
fn.SetExt( wxT( "csv" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fn.SetExt( FILEEXT::FootprintPlaceFileExtension );
|
||||
}
|
||||
|
||||
int fpcount = m_editFrame->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), OnlySMD(),
|
||||
ExcludeAllTH(), ExcludeDNP(), topSide,
|
||||
@ -531,17 +500,14 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
|
||||
bottomSide = true;
|
||||
fn = brd->GetFileName();
|
||||
fn.SetPath( outputDir.GetPath() );
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + PLACE_FILE_EXPORTER::GetBackSideName().c_str() );
|
||||
fn.SetName( PLACE_FILE_EXPORTER::DecorateFilename( fn.GetName(), topSide, bottomSide ) );
|
||||
fn.SetExt( FILEEXT::FootprintPlaceFileExtension );
|
||||
|
||||
if( useCSVfmt )
|
||||
{
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + FILEEXT::FootprintPlaceFileExtension );
|
||||
fn.SetExt( wxT( "csv" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fn.SetExt( FILEEXT::FootprintPlaceFileExtension );
|
||||
}
|
||||
|
||||
fpcount = m_editFrame->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), OnlySMD(),
|
||||
ExcludeAllTH(), ExcludeDNP(), topSide,
|
||||
|
@ -62,16 +62,6 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow
|
||||
m_formatCtrl->SetSelection( 0 );
|
||||
fgSizer1->Add( m_formatCtrl, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_sideLabel = new wxStaticText( this, wxID_ANY, _("Side:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_sideLabel->Wrap( -1 );
|
||||
fgSizer1->Add( m_sideLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
wxString m_sideCtrlChoices[] = { _("Front"), _("Back"), _("Both") };
|
||||
int m_sideCtrlNChoices = sizeof( m_sideCtrlChoices ) / sizeof( wxString );
|
||||
m_sideCtrl = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_sideCtrlNChoices, m_sideCtrlChoices, 0 );
|
||||
m_sideCtrl->SetSelection( 0 );
|
||||
fgSizer1->Add( m_sideCtrl, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_unitsLabel = new wxStaticText( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_unitsLabel->Wrap( -1 );
|
||||
fgSizer1->Add( m_unitsLabel, 0, wxRIGHT, 5 );
|
||||
|
@ -48,8 +48,6 @@ class DIALOG_GEN_FOOTPRINT_POSITION_BASE : public DIALOG_SHIM
|
||||
STD_BITMAP_BUTTON* m_browseButton;
|
||||
wxStaticText* m_formatLabel;
|
||||
wxChoice* m_formatCtrl;
|
||||
wxStaticText* m_sideLabel;
|
||||
wxChoice* m_sideCtrl;
|
||||
wxStaticText* m_unitsLabel;
|
||||
wxChoice* m_unitsCtrl;
|
||||
wxCheckBox* m_onlySMD;
|
||||
|
@ -437,3 +437,16 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
wxString PLACE_FILE_EXPORTER::DecorateFilename( const wxString& aBaseName, bool aFront, bool aBack )
|
||||
{
|
||||
if( aFront && aBack )
|
||||
return aBaseName + wxT( "-" ) + wxT( "all" );
|
||||
else if( aFront )
|
||||
return aBaseName + wxT( "-" ) + GetFrontSideName();
|
||||
else if( aBack )
|
||||
return aBaseName + wxT( "-" ) + GetBackSideName();
|
||||
else
|
||||
return aBaseName;
|
||||
}
|
||||
|
@ -92,6 +92,8 @@ public:
|
||||
static std::string GetFrontSideName() { return std::string( "top" ); }
|
||||
static std::string GetBackSideName() { return std::string( "bottom" ); }
|
||||
|
||||
static wxString DecorateFilename( const wxString& aBaseName, bool aFront, bool aBack );
|
||||
|
||||
private:
|
||||
BOARD* m_board;
|
||||
bool m_unitsMM; // true for mm, false for inches
|
||||
|
@ -1385,56 +1385,146 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob )
|
||||
if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::ASCII
|
||||
|| aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV )
|
||||
{
|
||||
FILE* file = nullptr;
|
||||
file = wxFopen( outPath, wxS( "wt" ) );
|
||||
wxFileName fn( outPath );
|
||||
wxString baseName = fn.GetName();
|
||||
|
||||
if( file == nullptr )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
auto exportPlaceFile =
|
||||
[&]( bool frontSide, bool backSide, const wxString& outPath ) -> bool
|
||||
{
|
||||
FILE* file = wxFopen( outPath, wxS( "wt" ) );
|
||||
wxCHECK( file, false );
|
||||
|
||||
std::string data;
|
||||
PLACE_FILE_EXPORTER exporter( brd,
|
||||
aPosJob->m_units == JOB_EXPORT_PCB_POS::UNITS::MILLIMETERS,
|
||||
aPosJob->m_smdOnly,
|
||||
aPosJob->m_excludeFootprintsWithTh,
|
||||
aPosJob->m_excludeDNP,
|
||||
frontSide,
|
||||
backSide,
|
||||
aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV,
|
||||
aPosJob->m_useDrillPlaceFileOrigin,
|
||||
aPosJob->m_negateBottomX );
|
||||
|
||||
bool frontSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::FRONT
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH;
|
||||
std::string data = exporter.GenPositionData();
|
||||
fputs( data.c_str(), file );
|
||||
fclose( file );
|
||||
|
||||
bool backSide = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH;
|
||||
return true;
|
||||
};
|
||||
|
||||
PLACE_FILE_EXPORTER exporter( brd,
|
||||
aPosJob->m_units == JOB_EXPORT_PCB_POS::UNITS::MILLIMETERS,
|
||||
aPosJob->m_smdOnly, aPosJob->m_excludeFootprintsWithTh,
|
||||
aPosJob->m_excludeDNP,
|
||||
frontSide, backSide,
|
||||
aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV,
|
||||
aPosJob->m_useDrillPlaceFileOrigin,
|
||||
aPosJob->m_negateBottomX );
|
||||
data = exporter.GenPositionData();
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH && !aPosJob->m_singleFile )
|
||||
{
|
||||
fn.SetName( PLACE_FILE_EXPORTER::DecorateFilename( baseName, true, false ) );
|
||||
|
||||
fputs( data.c_str(), file );
|
||||
fclose( file );
|
||||
if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV && !aPosJob->m_nakedFilename )
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + FILEEXT::FootprintPlaceFileExtension );
|
||||
|
||||
m_reporter->Report( wxString::Format( _( "Wrote position data to '%s'.\n" ), outPath ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
if( exportPlaceFile( true, false, fn.GetFullPath() ) )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Wrote front position data to '%s'.\n" ),
|
||||
fn.GetFullPath() ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
|
||||
aPosJob->AddOutput( outPath );
|
||||
aPosJob->AddOutput( fn.GetFullPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
|
||||
fn.SetName( PLACE_FILE_EXPORTER::DecorateFilename( baseName, false, true ) );
|
||||
|
||||
if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV && !aPosJob->m_nakedFilename )
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + FILEEXT::FootprintPlaceFileExtension );
|
||||
|
||||
if( exportPlaceFile( false, true, fn.GetFullPath() ) )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Wrote back position data to '%s'.\n" ),
|
||||
fn.GetFullPath() ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
|
||||
aPosJob->AddOutput( fn.GetFullPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool front = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::FRONT
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH;
|
||||
|
||||
bool back = aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH;
|
||||
|
||||
if( !aPosJob->m_nakedFilename )
|
||||
{
|
||||
fn.SetName( PLACE_FILE_EXPORTER::DecorateFilename( fn.GetName(), front, back ) );
|
||||
|
||||
if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::CSV )
|
||||
fn.SetName( fn.GetName() + wxT( "-" ) + FILEEXT::FootprintPlaceFileExtension );
|
||||
}
|
||||
|
||||
if( exportPlaceFile( front, back, fn.GetFullPath() ) )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Wrote position data to '%s'.\n" ),
|
||||
fn.GetFullPath() ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
|
||||
aPosJob->AddOutput( fn.GetFullPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( aPosJob->m_format == JOB_EXPORT_PCB_POS::FORMAT::GERBER )
|
||||
{
|
||||
PLACEFILE_GERBER_WRITER exporter( brd );
|
||||
PCB_LAYER_ID gbrLayer = F_Cu;
|
||||
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK )
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::FRONT
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH )
|
||||
{
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH || !aPosJob->m_nakedFilename )
|
||||
outPath = exporter.GetPlaceFileName( outPath, gbrLayer );
|
||||
|
||||
if( exporter.CreatePlaceFile( outPath, gbrLayer, aPosJob->m_gerberBoardEdge ) >= 0 )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Wrote front position data to '%s'.\n" ),
|
||||
outPath ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
|
||||
aPosJob->AddOutput( outPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
}
|
||||
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BACK
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH )
|
||||
{
|
||||
gbrLayer = B_Cu;
|
||||
|
||||
if( exporter.CreatePlaceFile( outPath, gbrLayer, aPosJob->m_gerberBoardEdge ) >= 0 )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Wrote position data to '%s'.\n" ), outPath ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH || !aPosJob->m_nakedFilename )
|
||||
outPath = exporter.GetPlaceFileName( outPath, gbrLayer );
|
||||
|
||||
aPosJob->AddOutput( outPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
if( exporter.CreatePlaceFile( outPath, gbrLayer, aPosJob->m_gerberBoardEdge ) >= 0 )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Wrote back position data to '%s'.\n" ),
|
||||
outPath ),
|
||||
RPT_SEVERITY_ACTION );
|
||||
|
||||
aPosJob->AddOutput( outPath );
|
||||
}
|
||||
else
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user