From 4f2ed1b05f57cdfcc532bf7b9d77a12c0316b751 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 3 May 2017 20:04:31 +0200 Subject: [PATCH] Plot gerber: fix a minor issue: an aperture attribute was incorrectly set on non copper layers when drawing some pads. --- common/common_plotGERBER_functions.cpp | 30 +++++++++++++++++++------- common/gbr_metadata.cpp | 5 +++-- include/plot_auxiliary_data.h | 29 ++++++++++++++++++++++--- pcbnew/plot_brditems_plotter.cpp | 5 ++++- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp index eaba330c0f..0df6b64ab5 100644 --- a/common/common_plotGERBER_functions.cpp +++ b/common/common_plotGERBER_functions.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 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 @@ -657,7 +657,7 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub /* Plot a flashed shape. */ if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 ) - && trace_mode == FILLED ) + && trace_mode == FILLED ) { if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */ std::swap( size.x, size.y ); @@ -705,9 +705,13 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub if( gbr_metadata ) { metadata = *gbr_metadata; - metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); - // Cleat .P attribute, only allowed for flashed items + // If the pad is drawn on a copper layer, + // set attribute to GBR_APERTURE_ATTRIB_CONDUCTOR + if( metadata.IsCopper() ) + metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); + + // Clear .P attribute, only allowed for flashed items wxString attrname( ".P" ); metadata.m_NetlistMetadata.ClearAttribute( &attrname ); } @@ -821,7 +825,10 @@ void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS if( aData ) { gbr_metadata = *static_cast( aData ); - gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); + // If the pad is drawn on a copper layer, + // set attribute to GBR_APERTURE_ATTRIB_CONDUCTOR + if( gbr_metadata.IsCopper() ) + gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); wxString attrname( ".P" ); gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers @@ -855,7 +862,10 @@ void GERBER_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize if( aData ) { gbr_metadata = *static_cast( aData ); - gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); + // If the pad is drawn on a copper layer, + // set attribute to GBR_APERTURE_ATTRIB_CONDUCTOR + if( gbr_metadata.IsCopper() ) + gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); wxString attrname( ".P" ); gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers @@ -927,7 +937,11 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCo if( gbr_metadata ) { metadata = *gbr_metadata; - metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); + // If the pad is drawn on a copper layer, + // set attribute to GBR_APERTURE_ATTRIB_CONDUCTOR + if( metadata.IsCopper() ) + metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR ); + wxString attrname( ".P" ); metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers } diff --git a/common/gbr_metadata.cpp b/common/gbr_metadata.cpp index 0511fbb0e2..f9faecf525 100644 --- a/common/gbr_metadata.cpp +++ b/common/gbr_metadata.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2016 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 @@ -61,7 +61,8 @@ std::string GBR_APERTURE_METADATA::FormatAttribute( GBR_APERTURE_ATTRIB aAttribu attribute_string = "%TA.AperFunction,ViaPad*%\n"; break; - case GBR_APERTURE_ATTRIB_NONCONDUCTOR: // print info associated to a flashed pad + case GBR_APERTURE_ATTRIB_NONCONDUCTOR: // print info associated to a item on a copper layer + // which is not a track (for instance a text) attribute_string = "%TA.AperFunction,NonConductor*%\n"; break; diff --git a/include/plot_auxiliary_data.h b/include/plot_auxiliary_data.h index a58e1d6e27..861dd5d0a4 100644 --- a/include/plot_auxiliary_data.h +++ b/include/plot_auxiliary_data.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 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 @@ -98,7 +98,7 @@ public: class GBR_METADATA { public: - GBR_METADATA() {} + GBR_METADATA(): m_isCopper( false) {} void SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute ) { @@ -124,8 +124,31 @@ public: void SetPadName( const wxString& aPadname ) { m_NetlistMetadata.m_Padname = aPadname; } void SetCmpReference( const wxString& aComponentRef ) { m_NetlistMetadata.m_Cmpref = aComponentRef; } + /** + * Allowed attributes are not the same on board copper layers and on other layers + * Therefore a flag can be set or reset when attributes can be depending on layers + */ + bool IsCopper() { return m_isCopper; } + void SetCopper( bool aValue ) { m_isCopper = aValue; } + + /** + * a item to handle aperture attribute: + */ GBR_APERTURE_METADATA m_ApertureMetadata; + + /** + * a item to handle object attribute: + */ GBR_NETLIST_METADATA m_NetlistMetadata; + +private: + /** + * if the metadata is relative to a copper layer or not. This is a flag + * which can be set/reset when an attribute for a given item depends on the fact + * a copper layer or a non copper layer is plotted. + * The initial state in false. + */ + bool m_isCopper; }; /** diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index c29b9ade58..7555058b80 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -7,7 +7,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 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 @@ -77,6 +77,7 @@ void BRDITEMS_PLOTTER::PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPl if( isOnCopperLayer ) { gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL ); + gbr_metadata.SetCopper( true ); if( isOnExternalCopperLayer ) gbr_metadata.SetPadName( aPad->GetPadName() ); @@ -479,6 +480,7 @@ void BRDITEMS_PLOTTER::Plot_1_EdgeModule( EDGE_MODULE* aEdge ) if( isOnCopperLayer ) { gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP ); + gbr_metadata.SetCopper( true ); } else if( aEdge->GetLayer() == Edge_Cuts ) // happens also when plotting copper layers { @@ -621,6 +623,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( ZONE_CONTAINER* aZone ) if( isOnCopperLayer ) { gbr_metadata.SetNetName( aZone->GetNetname() ); + gbr_metadata.SetCopper( true ); // Zones with no net name can exist. // they are not used to connect items, so the aperture attribute cannot