diff --git a/eeschema/eeschema_jobs_handler.cpp b/eeschema/eeschema_jobs_handler.cpp index 91c1f36a01..32cbd98d8e 100644 --- a/eeschema/eeschema_jobs_handler.cpp +++ b/eeschema/eeschema_jobs_handler.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Mark Roszko - * 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 as published by the @@ -155,9 +155,15 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob ) // Annotation warning check SCH_REFERENCE_LIST referenceList; sch->GetSheets().GetSymbols( referenceList ); + if( referenceList.GetCount() > 0 ) { - if( referenceList.CheckAnnotation( []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* ) {} ) > 0 ) + if( referenceList.CheckAnnotation( + []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* ) + { + // We're only interested in the end result -- either errors or not + } ) + > 0 ) { wxPrintf( _( "Warning: schematic has annotation errors, please use the schematic editor to fix them\n" ) ); } @@ -259,7 +265,12 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob ) SCH_REFERENCE_LIST copy = referenceList; // Check annotation splits references... - if( copy.CheckAnnotation( []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* ) {} ) > 0 ) + if( copy.CheckAnnotation( + []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* ) + { + // We're only interested in the end result -- either errors or not + } ) + > 0 ) { wxPrintf( _( "Warning: schematic has annotation errors, please use the schematic " "editor to fix them\n" ) ); @@ -388,11 +399,13 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob ) // Annotation warning check SCH_REFERENCE_LIST referenceList; sch->GetSheets().GetSymbols( referenceList ); + if( referenceList.GetCount() > 0 ) { if( referenceList.CheckAnnotation( []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* ) { + // We're only interested in the end result -- either errors or not } ) > 0 ) { @@ -405,9 +418,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob ) ERC_TESTER erc( sch ); if( erc.TestDuplicateSheetNames( false ) > 0 ) - { wxPrintf( _( "Warning: duplicate sheet names.\n" ) ); - } std::unique_ptr xmlNetlist = std::make_unique( sch ); @@ -424,17 +435,15 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob ) bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this ); if( !res ) - { return CLI::EXIT_CODES::ERR_UNKNOWN; - } return CLI::EXIT_CODES::OK; } int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, - KIGFX::SCH_RENDER_SETTINGS* aRenderSettings, - LIB_SYMBOL* symbol ) + KIGFX::SCH_RENDER_SETTINGS* aRenderSettings, + LIB_SYMBOL* symbol ) { wxASSERT( symbol != nullptr ); @@ -526,10 +535,12 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, // note, we want to use the fields from the original symbol pointer (in case of non-alias) symbolToPlot->Plot( plotter, unit, convert, background, plotPos, temp, false ); - symbol->PlotLibFields( plotter, unit, convert, background, plotPos, temp, false, aSvgJob->m_includeHiddenFields ); + symbol->PlotLibFields( plotter, unit, convert, background, plotPos, temp, false, + aSvgJob->m_includeHiddenFields ); symbolToPlot->Plot( plotter, unit, convert, !background, plotPos, temp, false ); - symbol->PlotLibFields( plotter, unit, convert, !background, plotPos, temp, false, aSvgJob->m_includeHiddenFields ); + symbol->PlotLibFields( plotter, unit, convert, !background, plotPos, temp, false, + aSvgJob->m_includeHiddenFields ); plotter->EndPlot(); delete plotter; @@ -562,10 +573,12 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob ) } LIB_SYMBOL* symbol = nullptr; + if( !svgJob->m_symbol.IsEmpty() ) { // See if the selected symbol exists symbol = schLibrary.GetSymbol( svgJob->m_symbol ); + if( !symbol ) { wxFprintf( stderr, _( "There is no symbol selected to save." ) ); @@ -584,6 +597,7 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob ) renderSettings.SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS ); int exitCode = CLI::EXIT_CODES::OK; + if( symbol ) { exitCode = doSymExportSvg( svgJob, &renderSettings, symbol ); @@ -596,6 +610,7 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob ) for( const std::pair& entry : libSymMap ) { exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second ); + if( exitCode != CLI::EXIT_CODES::OK ) break; } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 5a590d44df..b2791637c2 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -35,6 +35,8 @@ #include #include +#include + // the separator char between the subpart id and the reference // 0 (no separator) or '.' or some other character int LIB_SYMBOL::m_subpartIdSeparator = 0; @@ -606,7 +608,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) ); // Copy the parent. - retv.reset( new LIB_SYMBOL( *parent.get() ) ); + retv = std::make_unique( *parent.get() ); retv->m_name = m_name; retv->SetLibId( m_libId ); @@ -661,7 +663,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const } else { - retv.reset( new LIB_SYMBOL( *this ) ); + retv = std::make_unique( *this ); } return retv; @@ -863,6 +865,7 @@ void LIB_SYMBOL::Plot( PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackgro color.Desaturate( ); color = color.Mix( bg, 0.5f ); } + aPlotter->SetColor( color ); for( const LIB_ITEM& item : m_drawings )