Plot gerber: fix a minor issue: an aperture attribute was incorrectly set on non copper layers when drawing some pads.

This commit is contained in:
jean-pierre charras 2017-05-03 20:04:31 +02:00
parent d1dfa5aba3
commit 4f2ed1b05f
4 changed files with 55 additions and 14 deletions

View File

@ -1,8 +1,8 @@
/* /*
* 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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 KiCad Developers, see CHANGELOG.TXT for contributors. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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. */ /* Plot a flashed shape. */
if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 ) if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
&& trace_mode == FILLED ) && trace_mode == FILLED )
{ {
if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */ if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
std::swap( size.x, size.y ); std::swap( size.x, size.y );
@ -705,9 +705,13 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, doub
if( gbr_metadata ) if( gbr_metadata )
{ {
metadata = *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" ); wxString attrname( ".P" );
metadata.m_NetlistMetadata.ClearAttribute( &attrname ); metadata.m_NetlistMetadata.ClearAttribute( &attrname );
} }
@ -821,7 +825,10 @@ void GERBER_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aS
if( aData ) if( aData )
{ {
gbr_metadata = *static_cast<GBR_METADATA*>( aData ); gbr_metadata = *static_cast<GBR_METADATA*>( 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" ); wxString attrname( ".P" );
gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers 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 ) if( aData )
{ {
gbr_metadata = *static_cast<GBR_METADATA*>( aData ); gbr_metadata = *static_cast<GBR_METADATA*>( 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" ); wxString attrname( ".P" );
gbr_metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers 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 ) if( gbr_metadata )
{ {
metadata = *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" ); wxString attrname( ".P" );
metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers metadata.m_NetlistMetadata.ClearAttribute( &attrname ); // not allowed on inner layers
} }

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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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"; attribute_string = "%TA.AperFunction,ViaPad*%\n";
break; 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"; attribute_string = "%TA.AperFunction,NonConductor*%\n";
break; break;

View File

@ -1,8 +1,8 @@
/* /*
* 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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -98,7 +98,7 @@ public:
class GBR_METADATA class GBR_METADATA
{ {
public: public:
GBR_METADATA() {} GBR_METADATA(): m_isCopper( false) {}
void SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB aApertAttribute ) 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 SetPadName( const wxString& aPadname ) { m_NetlistMetadata.m_Padname = aPadname; }
void SetCmpReference( const wxString& aComponentRef ) { m_NetlistMetadata.m_Cmpref = aComponentRef; } 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; GBR_APERTURE_METADATA m_ApertureMetadata;
/**
* a item to handle object attribute:
*/
GBR_NETLIST_METADATA m_NetlistMetadata; 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;
}; };
/** /**

View File

@ -7,7 +7,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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ) if( isOnCopperLayer )
{ {
gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL ); gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
gbr_metadata.SetCopper( true );
if( isOnExternalCopperLayer ) if( isOnExternalCopperLayer )
gbr_metadata.SetPadName( aPad->GetPadName() ); gbr_metadata.SetPadName( aPad->GetPadName() );
@ -479,6 +480,7 @@ void BRDITEMS_PLOTTER::Plot_1_EdgeModule( EDGE_MODULE* aEdge )
if( isOnCopperLayer ) if( isOnCopperLayer )
{ {
gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_ETCHEDCMP ); 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 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 ) if( isOnCopperLayer )
{ {
gbr_metadata.SetNetName( aZone->GetNetname() ); gbr_metadata.SetNetName( aZone->GetNetname() );
gbr_metadata.SetCopper( true );
// Zones with no net name can exist. // Zones with no net name can exist.
// they are not used to connect items, so the aperture attribute cannot // they are not used to connect items, so the aperture attribute cannot