Gerber file generation: in X1 format, in header, use structured comments instead of basic comments.
(a structured comment starts by "G04 #@! " followed by a X2 attribute, and is a comment for old Gerber readers)
This commit is contained in:
parent
9a535d4c70
commit
6d6542e133
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* 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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-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
|
||||||
|
@ -85,8 +85,8 @@ const wxString GetGerberProtelExtension( LAYER_NUM aLayer )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard,
|
|
||||||
LAYER_NUM aLayer, bool aUseX1CompatibilityMode )
|
const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer )
|
||||||
{
|
{
|
||||||
wxString attrib;
|
wxString attrib;
|
||||||
|
|
||||||
|
@ -193,11 +193,7 @@ const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard,
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString fileFct;
|
wxString fileFct;
|
||||||
|
fileFct.Printf( "%%TF.FileFunction,%s*%%", GetChars( attrib ) );
|
||||||
if( aUseX1CompatibilityMode )
|
|
||||||
fileFct.Printf( "G04 #@! TF.FileFunction,%s*", GetChars( attrib ) );
|
|
||||||
else
|
|
||||||
fileFct.Printf( "%%TF.FileFunction,%s*%%", GetChars( attrib ) );
|
|
||||||
|
|
||||||
return fileFct;
|
return fileFct;
|
||||||
}
|
}
|
||||||
|
@ -260,15 +256,28 @@ static const wxString GetGerberFilePolarityAttribute( LAYER_NUM aLayer )
|
||||||
/* Add some X2 attributes to the file header, as defined in the
|
/* Add some X2 attributes to the file header, as defined in the
|
||||||
* Gerber file format specification J4 and "Revision 2015.06"
|
* Gerber file format specification J4 and "Revision 2015.06"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// A helper function to convert a X2 attribute string to a X1 structured comment:
|
||||||
|
static wxString& makeStringCompatX1( wxString& aText, bool aUseX1CompatibilityMode )
|
||||||
|
{
|
||||||
|
if( aUseX1CompatibilityMode )
|
||||||
|
{
|
||||||
|
aText.Replace( "%", "" );
|
||||||
|
aText.Prepend( "G04 #@! " );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aText;
|
||||||
|
}
|
||||||
|
|
||||||
void AddGerberX2Attribute( PLOTTER * aPlotter,
|
void AddGerberX2Attribute( PLOTTER * aPlotter,
|
||||||
const BOARD *aBoard, LAYER_NUM aLayer )
|
const BOARD *aBoard, LAYER_NUM aLayer, bool aUseX1CompatibilityMode )
|
||||||
{
|
{
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
// Creates the TF,.GenerationSoftware. Format is:
|
// Creates the TF,.GenerationSoftware. Format is:
|
||||||
// %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
|
// %TF,.GenerationSoftware,<vendor>,<application name>[,<application version>]*%
|
||||||
text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
|
text.Printf( wxT( "%%TF.GenerationSoftware,KiCad,Pcbnew,%s*%%" ), GetBuildVersion() );
|
||||||
aPlotter->AddLineToHeader( text );
|
aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
|
||||||
|
|
||||||
// creates the TF.CreationDate ext:
|
// creates the TF.CreationDate ext:
|
||||||
// The attribute value must conform to the full version of the ISO 8601
|
// The attribute value must conform to the full version of the ISO 8601
|
||||||
|
@ -283,7 +292,7 @@ void AddGerberX2Attribute( PLOTTER * aPlotter,
|
||||||
if( msg.Len() > 3 )
|
if( msg.Len() > 3 )
|
||||||
msg.insert( 3, ":", 1 ),
|
msg.insert( 3, ":", 1 ),
|
||||||
text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
|
text.Printf( wxT( "%%TF.CreationDate,%s%s*%%" ), GetChars( date.FormatISOCombined() ), GetChars( msg ) );
|
||||||
aPlotter->AddLineToHeader( text );
|
aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
|
||||||
|
|
||||||
// Creates the TF,.ProjectId. Format is (from Gerber file format doc):
|
// Creates the TF,.ProjectId. Format is (from Gerber file format doc):
|
||||||
// %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
|
// %TF.ProjectId,<project id>,<project GUID>,<revision id>*%
|
||||||
|
@ -329,17 +338,17 @@ void AddGerberX2Attribute( PLOTTER * aPlotter,
|
||||||
rev = wxT( "rev?" );
|
rev = wxT( "rev?" );
|
||||||
|
|
||||||
text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
|
text.Printf( wxT( "%%TF.ProjectId,%s,%s,%s*%%" ), msg.ToAscii(), GetChars( guid ), rev.ToAscii() );
|
||||||
aPlotter->AddLineToHeader( text );
|
aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
|
||||||
|
|
||||||
// Add the TF.FileFunction
|
// Add the TF.FileFunction
|
||||||
text = GetGerberFileFunctionAttribute( aBoard, aLayer, false );
|
text = GetGerberFileFunctionAttribute( aBoard, aLayer );
|
||||||
aPlotter->AddLineToHeader( text );
|
aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
|
||||||
|
|
||||||
// Add the TF.FilePolarity (for layers which support that)
|
// Add the TF.FilePolarity (for layers which support that)
|
||||||
text = GetGerberFilePolarityAttribute( aLayer );
|
text = GetGerberFilePolarityAttribute( aLayer );
|
||||||
|
|
||||||
if( !text.IsEmpty() )
|
if( !text.IsEmpty() )
|
||||||
aPlotter->AddLineToHeader( text );
|
aPlotter->AddLineToHeader( makeStringCompatX1( text, aUseX1CompatibilityMode ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,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-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-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
|
||||||
|
@ -264,12 +264,9 @@ const wxString GetGerberProtelExtension( LAYER_NUM aLayer );
|
||||||
* the "%TF.FileFunction" attribute prefix and the "*%" suffix.
|
* the "%TF.FileFunction" attribute prefix and the "*%" suffix.
|
||||||
* @param aBoard = the board, needed to get the total count of copper layers
|
* @param aBoard = the board, needed to get the total count of copper layers
|
||||||
* @param aLayer = the layer number to create the attribute for
|
* @param aLayer = the layer number to create the attribute for
|
||||||
* @param aUseX1CompatibilityMode = true to use a file function attribute like G04 comment
|
|
||||||
* , compatible with X1 (rx274) notation (G04#@!TF.FileFunction)
|
|
||||||
* @return The attribute, as a text string
|
* @return The attribute, as a text string
|
||||||
*/
|
*/
|
||||||
const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard,
|
const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard, LAYER_NUM aLayer );
|
||||||
LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function AddGerberX2Attribute
|
* Function AddGerberX2Attribute
|
||||||
|
@ -279,7 +276,11 @@ const wxString GetGerberFileFunctionAttribute( const BOARD *aBoard,
|
||||||
* @param aPlotter, the current plotter.
|
* @param aPlotter, the current plotter.
|
||||||
* @param aBoard = the board, needed to extract some info
|
* @param aBoard = the board, needed to extract some info
|
||||||
* @param aLayer = the layer number to create the attribute for
|
* @param aLayer = the layer number to create the attribute for
|
||||||
|
* @param aUseX1CompatibilityMode = false to generate X2 attributes, true to
|
||||||
|
* use X1 compatibility (X2 attributes added as structured comments,
|
||||||
|
* starting by "G04 #@! " followed by the X2 attribute
|
||||||
*/
|
*/
|
||||||
extern void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard, LAYER_NUM aLayer );
|
extern void AddGerberX2Attribute( PLOTTER * aPlotter, const BOARD *aBoard,
|
||||||
|
LAYER_NUM aLayer, bool aUseX1CompatibilityMode );
|
||||||
|
|
||||||
#endif // PCBPLOT_H_
|
#endif // PCBPLOT_H_
|
||||||
|
|
|
@ -8,7 +8,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-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-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
|
||||||
|
@ -1031,14 +1031,15 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts,
|
||||||
|
|
||||||
if( useX2mode )
|
if( useX2mode )
|
||||||
{
|
{
|
||||||
AddGerberX2Attribute( plotter, aBoard, aLayer );
|
AddGerberX2Attribute( plotter, aBoard, aLayer, false );
|
||||||
GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
|
GERBER_PLOTTER* gbrplotter = static_cast <GERBER_PLOTTER*> ( plotter );
|
||||||
gbrplotter->UseX2Attributes( true );
|
gbrplotter->UseX2Attributes( true );
|
||||||
gbrplotter->UseX2NetAttributes( plotOpts.GetIncludeGerberNetlistInfo() );
|
gbrplotter->UseX2NetAttributes( plotOpts.GetIncludeGerberNetlistInfo() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
plotter->AddLineToHeader( GetGerberFileFunctionAttribute(
|
{
|
||||||
aBoard, aLayer, true ) );
|
AddGerberX2Attribute( plotter, aBoard, aLayer, true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plotter->StartPlot();
|
plotter->StartPlot();
|
||||||
|
|
Loading…
Reference in New Issue