From 1e9639e89ca303da23288df81bdb45a8041972f5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 26 Jan 2021 15:27:42 +0000 Subject: [PATCH] Save pintype alongside pinfunction (in pads). Fixes https://gitlab.com/kicad/code/kicad/issues/7283 --- common/pcb.keywords | 1 + pcbnew/plugins/kicad/kicad_plugin.cpp | 46 +++++++++++++++++++++------ pcbnew/plugins/kicad/kicad_plugin.h | 3 +- pcbnew/plugins/kicad/pcb_parser.cpp | 10 ++++-- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/common/pcb.keywords b/common/pcb.keywords index 339600177b..2d4c8327c3 100644 --- a/common/pcb.keywords +++ b/common/pcb.keywords @@ -214,6 +214,7 @@ pcb_text_size pcb_text_width pcbplotparams pinfunction +pintype placed plus polygon diff --git a/pcbnew/plugins/kicad/kicad_plugin.cpp b/pcbnew/plugins/kicad/kicad_plugin.cpp index 65a5c19024..110835140a 100644 --- a/pcbnew/plugins/kicad/kicad_plugin.cpp +++ b/pcbnew/plugins/kicad/kicad_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 CERN - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 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 @@ -22,7 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include // LEGACY_BOARD_FILE_VERSION #include #include #include @@ -1311,7 +1310,8 @@ void PCB_IO::format( const PAD* aPad, int aNestLevel ) const m_out->Print( aNestLevel, "(pad %s %s %s", m_out->Quotew( aPad->GetName() ).c_str(), - type, shape ); + type, + shape ); m_out->Print( 0, " (at %s", FormatInternalUnits( aPad->GetPos0() ).c_str() ); if( aPad->GetOrientation() != 0.0 ) @@ -1403,47 +1403,75 @@ void PCB_IO::format( const PAD* aPad, int aNestLevel ) const // Unconnected pad is default net so don't save it. if( !( m_ctl & CTL_OMIT_PAD_NETS ) && aPad->GetNetCode() != NETINFO_LIST::UNCONNECTED ) + { StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ), m_out->Quotew( aPad->GetNetname() ).c_str() ); + } - // Add pinfunction, if exists. - // Pin function is closely related to nets, so if CTL_OMIT_NETS is set, - // omit also pin function (for instance when saved from library editor) - if( !( m_ctl & CTL_OMIT_PAD_NETS ) && !aPad->GetPinFunction().IsEmpty() ) - StrPrintf( &output, " (pinfunction %s)", - m_out->Quotew( aPad->GetPinFunction() ).c_str() ); + // Pin functions and types are closely related to nets, so if CTL_OMIT_NETS is set, omit + // them as well (for instance when saved from library editor). + if( !( m_ctl & CTL_OMIT_PAD_NETS ) ) + { + if( !aPad->GetPinFunction().IsEmpty() ) + { + StrPrintf( &output, " (pinfunction %s)", + m_out->Quotew( aPad->GetPinFunction() ).c_str() ); + } + + if( !aPad->GetPinType().IsEmpty() ) + { + StrPrintf( &output, " (pintype %s)", + m_out->Quotew( aPad->GetPinType() ).c_str() ); + } + } if( aPad->GetPadToDieLength() != 0 ) + { StrPrintf( &output, " (die_length %s)", FormatInternalUnits( aPad->GetPadToDieLength() ).c_str() ); + } if( aPad->GetLocalSolderMaskMargin() != 0 ) + { StrPrintf( &output, " (solder_mask_margin %s)", FormatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() ); + } if( aPad->GetLocalSolderPasteMargin() != 0 ) + { StrPrintf( &output, " (solder_paste_margin %s)", FormatInternalUnits( aPad->GetLocalSolderPasteMargin() ).c_str() ); + } if( aPad->GetLocalSolderPasteMarginRatio() != 0 ) + { StrPrintf( &output, " (solder_paste_margin_ratio %s)", Double2Str( aPad->GetLocalSolderPasteMarginRatio() ).c_str() ); + } if( aPad->GetLocalClearance() != 0 ) + { StrPrintf( &output, " (clearance %s)", FormatInternalUnits( aPad->GetLocalClearance() ).c_str() ); + } if( aPad->GetEffectiveZoneConnection() != ZONE_CONNECTION::INHERITED ) + { StrPrintf( &output, " (zone_connect %d)", static_cast( aPad->GetEffectiveZoneConnection() ) ); + } if( aPad->GetThermalSpokeWidth() != 0 ) + { StrPrintf( &output, " (thermal_width %s)", FormatInternalUnits( aPad->GetThermalSpokeWidth() ).c_str() ); + } if( aPad->GetThermalGap() != 0 ) + { StrPrintf( &output, " (thermal_gap %s)", FormatInternalUnits( aPad->GetThermalGap() ).c_str() ); + } if( output.size() ) { diff --git a/pcbnew/plugins/kicad/kicad_plugin.h b/pcbnew/plugins/kicad/kicad_plugin.h index ad4116ec3d..b950ee4199 100644 --- a/pcbnew/plugins/kicad/kicad_plugin.h +++ b/pcbnew/plugins/kicad/kicad_plugin.h @@ -93,7 +93,8 @@ class PCB_TEXT; //#define SEXPR_BOARD_FILE_VERSION 20201115 // module -> footprint and change fill syntax. //#define SEXPR_BOARD_FILE_VERSION 20201116 // Write version and generator string in footprint files. //#define SEXPR_BOARD_FILE_VERSION 20201220 // Add free via token -#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads +//#define SEXPR_BOARD_FILE_VERSION 20210108 // Pad locking moved from footprint to pads +#define SEXPR_BOARD_FILE_VERSION 20210126 // Store pintype alongside pinfunction (in pads). #define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 232ba60db4..cd95267a75 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 CERN - * Copyright (C) 2012-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012-2021 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 @@ -3773,6 +3773,12 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent ) NeedRIGHT(); break; + case T_pintype: + NeedSYMBOLorNUMBER(); + pad->SetPinType( FromUTF8() ); + NeedRIGHT(); + break; + case T_die_length: pad->SetPadToDieLength( parseBoardUnits( T_die_length ) ); NeedRIGHT(); @@ -4009,7 +4015,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent ) Expecting( "at, locked, drill, layers, net, die_length, roundrect_rratio, " "solder_mask_margin, solder_paste_margin, solder_paste_margin_ratio, " "clearance, tstamp, primitives, remove_unused_layers, keep_end_layers, " - "zone_connect, thermal_width, or thermal_gap" ); + "pinfunction, pintype, zone_connect, thermal_width, or thermal_gap" ); } }