Gerber X1 format: add more structured comments in file.
This commit is contained in:
parent
d1cab6ec62
commit
1ebee39973
|
@ -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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2018 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
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file GERBER_gerber.cpp
|
* @file GERBER_plotter.cpp
|
||||||
* @brief Kicad: specialized plotter for GERBER files format
|
* @brief specialized plotter for GERBER files format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
|
@ -113,7 +113,10 @@ void GERBER_PLOTTER::clearNetAttribute()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Remove all net attributes from object attributes dictionnary
|
// Remove all net attributes from object attributes dictionnary
|
||||||
fputs( "%TD*%\n", outputFile );
|
if( m_useX2Attributes )
|
||||||
|
fputs( "%TD*%\n", outputFile );
|
||||||
|
else
|
||||||
|
fputs( "G04 #@! TD*\n", outputFile );
|
||||||
|
|
||||||
m_objectAttributesDictionnary.clear();
|
m_objectAttributesDictionnary.clear();
|
||||||
}
|
}
|
||||||
|
@ -138,14 +141,21 @@ void GERBER_PLOTTER::formatNetAttribute( GBR_NETLIST_METADATA* aData )
|
||||||
// print a Gerber net attribute record.
|
// print a Gerber net attribute record.
|
||||||
// it is added to the object attributes dictionnary
|
// it is added to the object attributes dictionnary
|
||||||
// On file, only modified or new attributes are printed.
|
// On file, only modified or new attributes are printed.
|
||||||
if( aData == NULL || !m_useX2Attributes || !m_useNetAttributes )
|
if( aData == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool useX1StructuredComment = false;
|
||||||
|
|
||||||
|
if( !m_useX2Attributes )
|
||||||
|
useX1StructuredComment = true;
|
||||||
|
else if( !m_useNetAttributes )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool clearDict;
|
bool clearDict;
|
||||||
std::string short_attribute_string;
|
std::string short_attribute_string;
|
||||||
|
|
||||||
if( !FormatNetAttribute( short_attribute_string, m_objectAttributesDictionnary,
|
if( !FormatNetAttribute( short_attribute_string, m_objectAttributesDictionnary,
|
||||||
aData, clearDict, false ) )
|
aData, clearDict, useX1StructuredComment ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( clearDict )
|
if( clearDict )
|
||||||
|
@ -290,7 +300,8 @@ std::vector<APERTURE>::iterator GERBER_PLOTTER::getAperture( const wxSize& aSize
|
||||||
{
|
{
|
||||||
last_D_code = tool->m_DCode;
|
last_D_code = tool->m_DCode;
|
||||||
|
|
||||||
if( (tool->m_Type == aType) && (tool->m_Size == aSize) && (tool->m_ApertureAttribute == aApertureAttribute) )
|
if( (tool->m_Type == aType) && (tool->m_Size == aSize) &&
|
||||||
|
(tool->m_ApertureAttribute == aApertureAttribute) )
|
||||||
return tool;
|
return tool;
|
||||||
|
|
||||||
++tool;
|
++tool;
|
||||||
|
@ -317,7 +328,7 @@ void GERBER_PLOTTER::selectAperture( const wxSize& aSize,
|
||||||
( currentAperture->m_Type != aType ) ||
|
( currentAperture->m_Type != aType ) ||
|
||||||
( currentAperture->m_Size != aSize );
|
( currentAperture->m_Size != aSize );
|
||||||
|
|
||||||
if( !m_useX2Attributes || !m_useNetAttributes )
|
if( m_useX2Attributes && !m_useNetAttributes )
|
||||||
aApertureAttribute = 0;
|
aApertureAttribute = 0;
|
||||||
else
|
else
|
||||||
change = change || ( currentAperture->m_ApertureAttribute != aApertureAttribute );
|
change = change || ( currentAperture->m_ApertureAttribute != aApertureAttribute );
|
||||||
|
@ -336,6 +347,11 @@ void GERBER_PLOTTER::writeApertureList()
|
||||||
wxASSERT( outputFile );
|
wxASSERT( outputFile );
|
||||||
char cbuf[1024];
|
char cbuf[1024];
|
||||||
|
|
||||||
|
bool useX1StructuredComment = false;
|
||||||
|
|
||||||
|
if( !m_useX2Attributes )
|
||||||
|
useX1StructuredComment = true;
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
for( std::vector<APERTURE>::iterator tool = apertures.begin();
|
for( std::vector<APERTURE>::iterator tool = apertures.begin();
|
||||||
tool != apertures.end(); ++tool )
|
tool != apertures.end(); ++tool )
|
||||||
|
@ -350,9 +366,11 @@ void GERBER_PLOTTER::writeApertureList()
|
||||||
int attribute = tool->m_ApertureAttribute;
|
int attribute = tool->m_ApertureAttribute;
|
||||||
|
|
||||||
if( attribute != m_apertureAttribute )
|
if( attribute != m_apertureAttribute )
|
||||||
|
{
|
||||||
fputs( GBR_APERTURE_METADATA::FormatAttribute(
|
fputs( GBR_APERTURE_METADATA::FormatAttribute(
|
||||||
(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB) attribute, false ).c_str(),
|
(GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB) attribute,
|
||||||
outputFile );
|
useX1StructuredComment ).c_str(), outputFile );
|
||||||
|
}
|
||||||
|
|
||||||
char* text = cbuf + sprintf( cbuf, "%%ADD%d", tool->m_DCode );
|
char* text = cbuf + sprintf( cbuf, "%%ADD%d", tool->m_DCode );
|
||||||
|
|
||||||
|
@ -394,7 +412,11 @@ void GERBER_PLOTTER::writeApertureList()
|
||||||
// is to store the last attribute
|
// is to store the last attribute
|
||||||
if( attribute )
|
if( attribute )
|
||||||
{
|
{
|
||||||
fputs( "%TD*%\n", outputFile );
|
if( m_useX2Attributes )
|
||||||
|
fputs( "%TD*%\n", outputFile );
|
||||||
|
else
|
||||||
|
fputs( "G04 #@! TD*\n", outputFile );
|
||||||
|
|
||||||
m_apertureAttribute = 0;
|
m_apertureAttribute = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue