mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Formatting; code brevity.
This commit is contained in:
parent
ef75f63f10
commit
481e467968
@ -158,8 +158,8 @@ SCHEMATIC* EESCHEMA_JOBS_HANDLER::getSchematic( const wxString& aPath )
|
||||
if( !Pgm().IsGUI() && Pgm().GetSettingsManager().IsProjectOpenNotDummy() )
|
||||
{
|
||||
PROJECT& project = Pgm().GetSettingsManager().Prj();
|
||||
|
||||
wxString schPath = aPath;
|
||||
|
||||
if( schPath.IsEmpty() )
|
||||
{
|
||||
wxFileName path = project.GetProjectFullName();
|
||||
@ -175,8 +175,8 @@ SCHEMATIC* EESCHEMA_JOBS_HANDLER::getSchematic( const wxString& aPath )
|
||||
}
|
||||
else if( Pgm().IsGUI() && Pgm().GetSettingsManager().IsProjectOpen() )
|
||||
{
|
||||
SCH_EDIT_FRAME* editFrame =
|
||||
dynamic_cast<SCH_EDIT_FRAME*>( m_kiway->Player( FRAME_SCH, false ) );
|
||||
SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( m_kiway->Player( FRAME_SCH,
|
||||
false ) );
|
||||
|
||||
if( editFrame )
|
||||
sch = &editFrame->Schematic();
|
||||
@ -221,9 +221,8 @@ void EESCHEMA_JOBS_HANDLER::InitRenderSettings( SCH_RENDER_SETTINGS* aRenderSett
|
||||
resolve.SetProject( &aSch->Prj() );
|
||||
resolve.SetProgramBase( &Pgm() );
|
||||
|
||||
wxString absolutePath = resolve.ResolvePath( path,
|
||||
wxGetCwd(),
|
||||
aSch->GetEmbeddedFiles() );
|
||||
wxString absolutePath = resolve.ResolvePath( path, wxGetCwd(),
|
||||
aSch->GetEmbeddedFiles() );
|
||||
|
||||
if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( absolutePath, &msg ) )
|
||||
{
|
||||
@ -326,8 +325,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
|
||||
|
||||
wxString outPath = aPlotJob->GetFullOutputPath( &sch->Prj() );
|
||||
|
||||
if( !PATHS::EnsurePathExists( outPath,
|
||||
!aPlotJob->GetOutputPathIsDirectory() ) )
|
||||
if( !PATHS::EnsurePathExists( outPath, !aPlotJob->GetOutputPathIsDirectory() ) )
|
||||
{
|
||||
m_reporter->Report( _( "Failed to create output directory\n" ), RPT_SEVERITY_ERROR );
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
@ -656,9 +654,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
|
||||
|
||||
field.name = fieldName;
|
||||
field.show = !fieldName.StartsWith( wxT( "__" ), &field.name );
|
||||
field.groupBy = std::find( aBomJob->m_fieldsGroupBy.begin(),
|
||||
aBomJob->m_fieldsGroupBy.end(), field.name )
|
||||
!= aBomJob->m_fieldsGroupBy.end();
|
||||
field.groupBy = alg::contains( aBomJob->m_fieldsGroupBy, field.name );
|
||||
|
||||
if( ( aBomJob->m_fieldsLabels.size() > i ) && !aBomJob->m_fieldsLabels[i].IsEmpty() )
|
||||
field.label = aBomJob->m_fieldsLabels[i];
|
||||
@ -876,12 +872,8 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
|
||||
|
||||
filename = symbol->GetName();
|
||||
|
||||
while( wxString::npos
|
||||
!= ( forbidden_char = filename.find_first_of(
|
||||
wxFileName::GetForbiddenChars( wxPATH_DOS ) ) ) )
|
||||
{
|
||||
filename = filename.replace( forbidden_char, 1, wxS( '_' ) );
|
||||
}
|
||||
for( wxChar c : wxFileName::GetForbiddenChars( wxPATH_DOS ) )
|
||||
filename.Replace( c, ' ' );
|
||||
|
||||
// Even single units get a unit number in the filename. This simplifies the
|
||||
// handling of the files as they have a uniform pattern.
|
||||
@ -1012,9 +1004,9 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob )
|
||||
// Just plot all the symbols we can
|
||||
const LIB_SYMBOL_MAP& libSymMap = schLibrary.GetSymbolMap();
|
||||
|
||||
for( const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
|
||||
for( const auto& [name, libSymbol] : libSymMap )
|
||||
{
|
||||
exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second );
|
||||
exitCode = doSymExportSvg( svgJob, &renderSettings, libSymbol );
|
||||
|
||||
if( exitCode != CLI::EXIT_CODES::OK )
|
||||
break;
|
||||
|
@ -92,18 +92,15 @@ public:
|
||||
|
||||
KIWAY::FACE_T iface = JOB_REGISTRY::GetKifaceType( job.m_type );
|
||||
wxString source = wxEmptyString;
|
||||
|
||||
if( iface < KIWAY::KIWAY_FACE_COUNT )
|
||||
{
|
||||
|
||||
if( iface == KIWAY::FACE_PCB )
|
||||
{
|
||||
source = wxT( "PCB" );
|
||||
}
|
||||
else if( iface == KIWAY::FACE_SCH )
|
||||
{
|
||||
source = wxT( "SCH" );
|
||||
}
|
||||
}
|
||||
|
||||
m_jobList->SetItem( itemIndex, jobSourceColId, source );
|
||||
}
|
||||
|
||||
@ -248,8 +245,8 @@ public:
|
||||
|
||||
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile, &project );
|
||||
|
||||
WX_PROGRESS_REPORTER* progressReporter =
|
||||
new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), 1 );
|
||||
auto* progressReporter = new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ),
|
||||
1 );
|
||||
|
||||
if( JOBSET_OUTPUT* output = GetOutput() )
|
||||
jobRunner.RunJobsForOutput( output );
|
||||
@ -512,7 +509,7 @@ void PANEL_JOBSET::rebuildJobList()
|
||||
if( m_jobsGrid->GetNumberRows() )
|
||||
m_jobsGrid->DeleteRows( 0, m_jobsGrid->GetNumberRows() );
|
||||
|
||||
m_jobsGrid->AppendRows( m_jobsFile->GetJobs().size() );
|
||||
m_jobsGrid->AppendRows( (int) m_jobsFile->GetJobs().size() );
|
||||
|
||||
int num = 1;
|
||||
|
||||
@ -527,16 +524,13 @@ void PANEL_JOBSET::rebuildJobList()
|
||||
|
||||
KIWAY::FACE_T iface = JOB_REGISTRY::GetKifaceType( job.m_type );
|
||||
wxString source = wxEmptyString;
|
||||
|
||||
if( iface < KIWAY::KIWAY_FACE_COUNT )
|
||||
{
|
||||
if( iface == KIWAY::FACE_PCB )
|
||||
{
|
||||
source = wxT( "PCB" );
|
||||
}
|
||||
else if( iface == KIWAY::FACE_SCH )
|
||||
{
|
||||
source = wxT( "SCH" );
|
||||
}
|
||||
}
|
||||
|
||||
m_jobsGrid->SetCellValue( num - 1, COL_SOURCE, source );
|
||||
@ -700,6 +694,7 @@ void PANEL_JOBSET::OnAddJobClick( wxCommandEvent& aEvent )
|
||||
wxString selectedString = dlg.GetTextSelection();
|
||||
|
||||
wxString jobKey;
|
||||
|
||||
if( !selectedString.IsEmpty() )
|
||||
{
|
||||
for( const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
|
||||
@ -790,11 +785,11 @@ void PANEL_JOBSET::OnAddOutputClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxString selectedString = dlg.GetTextSelection();
|
||||
|
||||
for( const std::pair<const JOBSET_OUTPUT_TYPE, JOBSET_OUTPUT_TYPE_INFO>& jobType : JobsetOutputTypeInfos )
|
||||
for( const auto& [outputType, outputTypeInfo] : JobsetOutputTypeInfos )
|
||||
{
|
||||
if( wxGetTranslation( jobType.second.name ) == selectedString )
|
||||
if( wxGetTranslation( outputTypeInfo.name ) == selectedString )
|
||||
{
|
||||
JOBSET_OUTPUT* output = m_jobsFile->AddNewJobOutput( jobType.first );
|
||||
JOBSET_OUTPUT* output = m_jobsFile->AddNewJobOutput( outputType );
|
||||
|
||||
DIALOG_JOBSET_OUTPUT_OPTIONS dialog( m_frame, m_jobsFile.get(), output );
|
||||
|
||||
|
@ -1209,6 +1209,7 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
|
||||
wxString layerName;
|
||||
wxString sheetName;
|
||||
wxString sheetPath;
|
||||
wxString outPath = aGerberJob->GetFullOutputPath( brd->GetProject() );
|
||||
|
||||
// The first layer will be treated as the layer name for the gerber header,
|
||||
// the other layers will be treated equivalent to the "Plot on All Layers" option
|
||||
@ -1229,9 +1230,8 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
|
||||
sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||
|
||||
// We are feeding it one layer at the start here to silence a logic check
|
||||
GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
|
||||
aGerberJob->GetFullOutputPath( brd->GetProject() ),
|
||||
sheetName, sheetPath );
|
||||
PLOTTER* plotter = StartPlotBoard( brd, &plotOpts, layer, layerName, outPath, sheetName,
|
||||
sheetPath );
|
||||
|
||||
if( plotter )
|
||||
{
|
||||
@ -1240,8 +1240,7 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Failed to plot to '%s'.\n" ),
|
||||
aGerberJob->GetFullOutputPath( brd->GetProject() ) ),
|
||||
m_reporter->Report( wxString::Format( _( "Failed to plot to '%s'.\n" ), outPath ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
exitCode = CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
@ -1514,7 +1513,7 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob )
|
||||
{
|
||||
PLACEFILE_GERBER_WRITER exporter( brd );
|
||||
PCB_LAYER_ID gbrLayer = F_Cu;
|
||||
wxString outPath_base = outPath;
|
||||
wxString outPath_base = outPath;
|
||||
|
||||
if( aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::FRONT
|
||||
|| aPosJob->m_side == JOB_EXPORT_PCB_POS::SIDE::BOTH )
|
||||
@ -1564,9 +1563,6 @@ int PCBNEW_JOBS_HANDLER::JobExportPos( JOB* aJob )
|
||||
return CLI::EXIT_CODES::OK;
|
||||
}
|
||||
|
||||
extern FOOTPRINT* try_load_footprint( const wxFileName& aFileName, PCB_IO_MGR::PCB_FILE_T aFileType,
|
||||
const wxString& aName );
|
||||
|
||||
|
||||
int PCBNEW_JOBS_HANDLER::JobExportFpUpgrade( JOB* aJob )
|
||||
{
|
||||
@ -1687,31 +1683,21 @@ int PCBNEW_JOBS_HANDLER::JobExportFpSvg( JOB* aJob )
|
||||
wxFileName::Mkdir( svgJob->m_outputDirectory );
|
||||
}
|
||||
|
||||
int exitCode = CLI::EXIT_CODES::OK;
|
||||
|
||||
// Just plot all the symbols we can
|
||||
boost::ptr_map<wxString, FP_CACHE_ENTRY>& footprintMap = fpLib.GetFootprints();
|
||||
|
||||
int exitCode = CLI::EXIT_CODES::OK;
|
||||
bool singleFpPlotted = false;
|
||||
|
||||
for( auto it = footprintMap.begin(); it != footprintMap.end(); ++it )
|
||||
for( const auto& [fpName, fpCacheEntry] : fpLib.GetFootprints() )
|
||||
{
|
||||
const std::unique_ptr<FOOTPRINT>& fp = it->second->GetFootprint();
|
||||
|
||||
if( !svgJob->m_footprint.IsEmpty() )
|
||||
{
|
||||
if( fp->GetFPID().GetLibItemName().wx_str() != svgJob->m_footprint )
|
||||
{
|
||||
// skip until we find the right footprint
|
||||
// skip until we find the right footprint
|
||||
if( fpName != svgJob->m_footprint )
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
singleFpPlotted = true;
|
||||
}
|
||||
}
|
||||
|
||||
exitCode = doFpExportSvg( svgJob, fp.get() );
|
||||
exitCode = doFpExportSvg( svgJob, fpCacheEntry->GetFootprint().get() );
|
||||
|
||||
if( exitCode != CLI::EXIT_CODES::OK )
|
||||
break;
|
||||
@ -2168,7 +2154,8 @@ int PCBNEW_JOBS_HANDLER::JobExportOdb( JOB* aJob )
|
||||
case JOB_EXPORT_PCB_ODB::ODB_COMPRESSION::TGZ:
|
||||
fn.SetExt( "tgz" );
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
job->SetWorkingOutputPath( fn.GetFullName() );
|
||||
@ -2207,28 +2194,28 @@ void PCBNEW_JOBS_HANDLER::loadOverrideDrawingSheet( BOARD* aBrd, const wxString&
|
||||
|
||||
auto loadSheet =
|
||||
[&]( const wxString& path ) -> bool
|
||||
{
|
||||
BASE_SCREEN::m_DrawingSheetFileName = path;
|
||||
FILENAME_RESOLVER resolver;
|
||||
resolver.SetProject( aBrd->GetProject() );
|
||||
resolver.SetProgramBase( &Pgm() );
|
||||
{
|
||||
BASE_SCREEN::m_DrawingSheetFileName = path;
|
||||
FILENAME_RESOLVER resolver;
|
||||
resolver.SetProject( aBrd->GetProject() );
|
||||
resolver.SetProgramBase( &Pgm() );
|
||||
|
||||
wxString filename = resolver.ResolvePath( BASE_SCREEN::m_DrawingSheetFileName,
|
||||
aBrd->GetProject()->GetProjectPath(),
|
||||
aBrd->GetEmbeddedFiles() );
|
||||
wxString msg;
|
||||
wxString filename = resolver.ResolvePath( BASE_SCREEN::m_DrawingSheetFileName,
|
||||
aBrd->GetProject()->GetProjectPath(),
|
||||
aBrd->GetEmbeddedFiles() );
|
||||
wxString msg;
|
||||
|
||||
if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename, &msg ) )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Error loading drawing sheet '%s'." ),
|
||||
path )
|
||||
+ wxS( "\n" ) + msg + wxS( "\n" ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
return false;
|
||||
}
|
||||
if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename, &msg ) )
|
||||
{
|
||||
m_reporter->Report( wxString::Format( _( "Error loading drawing sheet '%s'." ),
|
||||
path )
|
||||
+ wxS( "\n" ) + msg + wxS( "\n" ),
|
||||
RPT_SEVERITY_ERROR );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
return true;
|
||||
};
|
||||
|
||||
if( loadSheet( aSheetPath ) )
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user