Formatting.

(cherry picked from commit 4e420f3cf6)
This commit is contained in:
Jeff Young 2023-05-09 12:22:17 +01:00
parent 97be02356f
commit 5998fabadd
2 changed files with 25 additions and 12 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> * Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* 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 * 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 * under the terms of the GNU General Public License as published by the
@ -199,9 +199,15 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
// Annotation warning check // Annotation warning check
SCH_REFERENCE_LIST referenceList; SCH_REFERENCE_LIST referenceList;
sch->GetSheets().GetSymbols( referenceList ); sch->GetSheets().GetSymbols( referenceList );
if( referenceList.GetCount() > 0 ) 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" ) ); wxPrintf( _( "Warning: schematic has annotation errors, please use the schematic editor to fix them\n" ) );
} }
@ -294,11 +300,13 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
// Annotation warning check // Annotation warning check
SCH_REFERENCE_LIST referenceList; SCH_REFERENCE_LIST referenceList;
sch->GetSheets().GetSymbols( referenceList ); sch->GetSheets().GetSymbols( referenceList );
if( referenceList.GetCount() > 0 ) if( referenceList.GetCount() > 0 )
{ {
if( referenceList.CheckAnnotation( if( referenceList.CheckAnnotation(
[]( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* ) []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
{ {
// We're only interested in the end result -- either errors or not
} ) } )
> 0 ) > 0 )
{ {
@ -311,9 +319,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
ERC_TESTER erc( sch ); ERC_TESTER erc( sch );
if( erc.TestDuplicateSheetNames( false ) > 0 ) if( erc.TestDuplicateSheetNames( false ) > 0 )
{
wxPrintf( _( "Warning: duplicate sheet names.\n" ) ); wxPrintf( _( "Warning: duplicate sheet names.\n" ) );
}
std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist = std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
std::make_unique<NETLIST_EXPORTER_XML>( sch ); std::make_unique<NETLIST_EXPORTER_XML>( sch );
@ -330,17 +336,15 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this ); bool res = xmlNetlist->WriteNetlist( aNetJob->m_outputFile, GNL_OPT_BOM, *this );
if( !res ) if( !res )
{
return CLI::EXIT_CODES::ERR_UNKNOWN; return CLI::EXIT_CODES::ERR_UNKNOWN;
}
return CLI::EXIT_CODES::OK; return CLI::EXIT_CODES::OK;
} }
int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
KIGFX::SCH_RENDER_SETTINGS* aRenderSettings, KIGFX::SCH_RENDER_SETTINGS* aRenderSettings,
LIB_SYMBOL* symbol ) LIB_SYMBOL* symbol )
{ {
wxASSERT( symbol != nullptr ); wxASSERT( symbol != nullptr );
@ -432,10 +436,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) // 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 ); 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 ); 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(); plotter->EndPlot();
delete plotter; delete plotter;
@ -465,10 +471,12 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob )
} }
LIB_SYMBOL* symbol = nullptr; LIB_SYMBOL* symbol = nullptr;
if( !svgJob->m_symbol.IsEmpty() ) if( !svgJob->m_symbol.IsEmpty() )
{ {
// See if the selected symbol exists // See if the selected symbol exists
symbol = schLibrary.GetSymbol( svgJob->m_symbol ); symbol = schLibrary.GetSymbol( svgJob->m_symbol );
if( !symbol ) if( !symbol )
{ {
wxFprintf( stderr, _( "There is no symbol selected to save." ) ); wxFprintf( stderr, _( "There is no symbol selected to save." ) );
@ -487,6 +495,7 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob )
renderSettings.SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS ); renderSettings.SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
int exitCode = CLI::EXIT_CODES::OK; int exitCode = CLI::EXIT_CODES::OK;
if( symbol ) if( symbol )
{ {
exitCode = doSymExportSvg( svgJob, &renderSettings, symbol ); exitCode = doSymExportSvg( svgJob, &renderSettings, symbol );
@ -499,6 +508,7 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob )
for( const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap ) for( const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
{ {
exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second ); exitCode = doSymExportSvg( svgJob, &renderSettings, entry.second );
if( exitCode != CLI::EXIT_CODES::OK ) if( exitCode != CLI::EXIT_CODES::OK )
break; break;
} }

View File

@ -36,6 +36,8 @@
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <lib_shape.h> #include <lib_shape.h>
#include <memory>
// the separator char between the subpart id and the reference // the separator char between the subpart id and the reference
// 0 (no separator) or '.' or some other character // 0 (no separator) or '.' or some other character
int LIB_SYMBOL::m_subpartIdSeparator = 0; int LIB_SYMBOL::m_subpartIdSeparator = 0;
@ -465,7 +467,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) ); wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) );
// Copy the parent. // Copy the parent.
retv.reset( new LIB_SYMBOL( *parent.get() ) ); retv = std::make_unique<LIB_SYMBOL>( *parent.get() );
retv->m_name = m_name; retv->m_name = m_name;
retv->SetLibId( m_libId ); retv->SetLibId( m_libId );
@ -520,7 +522,7 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
} }
else else
{ {
retv.reset( new LIB_SYMBOL( *this ) ); retv = std::make_unique<LIB_SYMBOL>( *this );
} }
return retv; return retv;
@ -722,6 +724,7 @@ void LIB_SYMBOL::Plot( PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackgro
color.Desaturate( ); color.Desaturate( );
color = color.Mix( bg, 0.5f ); color = color.Mix( bg, 0.5f );
} }
aPlotter->SetColor( color ); aPlotter->SetColor( color );
for( const LIB_ITEM& item : m_drawings ) for( const LIB_ITEM& item : m_drawings )