2016-08-16 10:56:20 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2020-12-19 16:00:52 +00:00
|
|
|
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-08-16 10:56:20 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GBR_NETLIST_METADATA_H
|
|
|
|
#define GBR_NETLIST_METADATA_H
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Information which can be added in a gerber P&P file as attribute of a component.
|
|
|
|
*
|
|
|
|
* This is only applicable to objects having the TA.AperFunction attribute "ComponentMain"
|
2019-09-15 15:08:57 +00:00
|
|
|
* There are specific attributes defined attached to the component by the %TO command
|
|
|
|
* %TO.CRot,<angle> The rotation angle of the component.
|
|
|
|
* The rotation angle is consistent with the one for graphics objects.
|
|
|
|
* Positive rotation is counter- clockwise as viewed from the top side, even if
|
|
|
|
* the component is on the board side.
|
2019-12-30 13:01:06 +00:00
|
|
|
* The base orientation of component - no rotation - on the top side is as in IPC-7351.
|
2019-09-15 15:08:57 +00:00
|
|
|
* Components on the bottom side are of course mirrored.
|
|
|
|
* The base orientation on the bottom side is the one on the top side
|
|
|
|
* mirrored around the X axis.
|
2020-12-19 16:00:52 +00:00
|
|
|
*
|
2019-09-15 15:08:57 +00:00
|
|
|
* %TO.CMfr,<string> Manufacturer
|
|
|
|
* %TO.CMPN,<string> Manufacturer part number
|
|
|
|
* %TO.Cpkg,<string> Package, as per IPC-7351
|
2019-10-06 11:39:50 +00:00
|
|
|
* %TO.CVal,<string> Value, a string. E.g. 220nF
|
2019-11-10 13:29:08 +00:00
|
|
|
* %TO.CMnt,<string> Mount type: (SMD|TH|Other)
|
2019-09-15 15:08:57 +00:00
|
|
|
* %TO.CFtp,<string> Footprint name, a string. E.g. LQFP-100_14x14mm_P0.5mm
|
|
|
|
This is the footprint name coming from the CAD tool libraries.
|
2019-10-06 11:39:50 +00:00
|
|
|
* %TO.CPgN,<string> Package name, like the JEDEC JEP95 standard.
|
|
|
|
* %TO.CPgD,<string> Package description.
|
2019-09-15 15:08:57 +00:00
|
|
|
* %TO.CHgt,<string> Height, a decimal, in the unit of the file.
|
2019-10-06 11:39:50 +00:00
|
|
|
* %TO.CLbN,<string> Library name.
|
|
|
|
* %TO.CLbD,<string> Library description.
|
2020-12-19 16:00:52 +00:00
|
|
|
* %TO.Sup,<SN>,<SPN> SN is a field with the supplier name.
|
|
|
|
* SPN is a field with the supplier part name.
|
2019-09-15 15:08:57 +00:00
|
|
|
*/
|
|
|
|
class GBR_CMP_PNP_METADATA
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum MOUNT_TYPE
|
|
|
|
{
|
|
|
|
MOUNT_TYPE_UNSPECIFIED,
|
|
|
|
MOUNT_TYPE_SMD,
|
|
|
|
MOUNT_TYPE_TH
|
|
|
|
};
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
GBR_CMP_PNP_METADATA() :
|
|
|
|
m_Orientation( 0.0 ),
|
|
|
|
m_MountType( MOUNT_TYPE_UNSPECIFIED )
|
|
|
|
{}
|
|
|
|
|
|
|
|
void ClearData(); // Clear all strings
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return a string containing the formatted metadata in X2 syntax.
|
|
|
|
*/
|
|
|
|
wxString FormatCmpPnPMetadata();
|
|
|
|
|
|
|
|
|
2019-09-15 15:08:57 +00:00
|
|
|
double m_Orientation; // orientation in degree
|
|
|
|
wxString m_Manufacturer; // Manufacturer name
|
|
|
|
wxString m_MPN; // Manufacturer part number
|
|
|
|
wxString m_Package; // Package, as per IPC-7351
|
|
|
|
wxString m_Footprint; // Footprint name, from library
|
2019-10-06 11:39:50 +00:00
|
|
|
wxString m_LibraryName; // Library name, containing the footprint
|
|
|
|
wxString m_LibraryDescr; // Library description
|
2019-09-15 15:08:57 +00:00
|
|
|
wxString m_Value; // Component value
|
|
|
|
MOUNT_TYPE m_MountType; // SMD|TH|Other
|
|
|
|
};
|
|
|
|
|
2019-11-17 09:11:29 +00:00
|
|
|
/**
|
2020-12-19 16:00:52 +00:00
|
|
|
* A Gerber data field.
|
|
|
|
*
|
|
|
|
* This is a Unicode string with some chars converted in escaped hexadecimal sequence
|
|
|
|
* when creating the file. The following characters are always escaped because they
|
|
|
|
* are separator in Gerber files: * , \ %. Non ASCII7 characters can be converted to
|
|
|
|
* UTF8 or escaped.
|
2019-11-17 09:11:29 +00:00
|
|
|
*/
|
|
|
|
class GBR_DATA_FIELD
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GBR_DATA_FIELD() : m_useUTF8( false ), m_escapeString( false )
|
|
|
|
{}
|
|
|
|
|
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
m_field.clear();
|
|
|
|
m_useUTF8 = false;
|
|
|
|
m_escapeString = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear() { clear(); }
|
|
|
|
|
2020-10-27 11:03:35 +00:00
|
|
|
const wxString& GetValue() const { return m_field; }
|
2019-11-17 09:11:29 +00:00
|
|
|
|
|
|
|
void SetField( const wxString& aField, bool aUseUTF8, bool aEscapeString )
|
|
|
|
{
|
|
|
|
m_field = aField;
|
|
|
|
m_useUTF8 = aUseUTF8;
|
|
|
|
m_escapeString = aEscapeString;
|
|
|
|
}
|
|
|
|
|
2020-10-27 11:03:35 +00:00
|
|
|
bool IsEmpty() const { return m_field.IsEmpty(); }
|
2019-11-17 09:11:29 +00:00
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
std::string GetGerberString() const;
|
2019-11-17 09:11:29 +00:00
|
|
|
|
|
|
|
private:
|
2020-12-19 16:00:52 +00:00
|
|
|
wxString m_field; ///< the Unicode text to print in Gbr file
|
2019-11-17 09:11:29 +00:00
|
|
|
///< (after escape and quoting)
|
2020-12-19 16:00:52 +00:00
|
|
|
bool m_useUTF8; ///< true to use UTF8, false to escape non ASCII7 chars
|
2019-11-17 09:11:29 +00:00
|
|
|
bool m_escapeString; ///< true to quote the field in gbr file
|
|
|
|
};
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Information which can be added in a gerber file as attribute of an object.
|
|
|
|
*
|
|
|
|
* The #GBR_INFO_TYPE types can be OR'ed to add 2 (or more) attributes. There are only 3
|
|
|
|
* net attributes defined attached to an object by the %TO command:
|
|
|
|
* - %TO.P
|
|
|
|
* - %TO.N
|
|
|
|
* - %TO.C
|
|
|
|
*
|
|
|
|
* The .P attribute can be used only for flashed pads (using the D03 command) and only for
|
|
|
|
* external copper layers, if the component is on a external copper layer for other copper
|
|
|
|
* layer items (pads on internal layers, tracks ... ), only .N and .C can be used.
|
2017-07-02 14:41:31 +00:00
|
|
|
*/
|
2016-08-16 10:56:20 +00:00
|
|
|
class GBR_NETLIST_METADATA
|
|
|
|
{
|
|
|
|
public:
|
2021-06-09 19:32:58 +00:00
|
|
|
// This enum enables the different net attributes attached to the object
|
2016-08-16 10:56:20 +00:00
|
|
|
// the values can be ORed for items which can have more than one attribute
|
|
|
|
// (A flashed pad has all allowed attributes)
|
|
|
|
enum GBR_NETINFO_TYPE
|
|
|
|
{
|
|
|
|
GBR_NETINFO_UNSPECIFIED, ///< idle command (no command)
|
|
|
|
GBR_NETINFO_PAD = 1, ///< print info associated to a flashed pad (TO.P attribute)
|
|
|
|
GBR_NETINFO_NET = 2, ///< print info associated to a net (TO.N attribute)
|
|
|
|
GBR_NETINFO_CMP = 4 ///< print info associated to a component (TO.C attribute)
|
|
|
|
};
|
|
|
|
|
2019-10-17 10:41:42 +00:00
|
|
|
GBR_NETLIST_METADATA(): m_NetAttribType( GBR_NETINFO_UNSPECIFIED ),
|
|
|
|
m_NotInNet( false ), m_TryKeepPreviousAttributes( false )
|
2016-08-16 10:56:20 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Clear the extra data string printed at end of net attributes.
|
2019-09-18 09:48:49 +00:00
|
|
|
*/
|
|
|
|
void ClearExtraData()
|
|
|
|
{
|
|
|
|
m_ExtraData.Clear();
|
|
|
|
}
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Set the extra data string printed at end of net attributes
|
2019-09-18 09:48:49 +00:00
|
|
|
*/
|
|
|
|
void SetExtraData( const wxString& aExtraData)
|
|
|
|
{
|
|
|
|
m_ExtraData = aExtraData;
|
|
|
|
}
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
/**
|
2020-12-19 16:00:52 +00:00
|
|
|
* Remove the net attribute specified by \a aName.
|
|
|
|
*
|
|
|
|
* If aName == NULL or empty, remove all attributes.
|
|
|
|
*
|
|
|
|
* @param aName is the name (.CN, .P .N or .C) of the attribute to remove.
|
2016-08-16 10:56:20 +00:00
|
|
|
*/
|
|
|
|
void ClearAttribute( const wxString* aName )
|
|
|
|
{
|
|
|
|
if( m_NetAttribType == GBR_NETINFO_UNSPECIFIED )
|
|
|
|
{
|
|
|
|
m_Padname.clear();
|
2019-11-17 09:11:29 +00:00
|
|
|
m_PadPinFunction.clear();
|
2016-08-16 10:56:20 +00:00
|
|
|
m_Cmpref.clear();
|
|
|
|
m_Netname.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aName || aName->IsEmpty() || *aName == ".CN" )
|
|
|
|
{
|
|
|
|
m_NetAttribType = GBR_NETINFO_UNSPECIFIED;
|
|
|
|
m_Padname.clear();
|
2019-11-17 09:11:29 +00:00
|
|
|
m_PadPinFunction.clear();
|
2016-08-16 10:56:20 +00:00
|
|
|
m_Cmpref.clear();
|
|
|
|
m_Netname.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( *aName == ".C" )
|
|
|
|
{
|
|
|
|
m_NetAttribType &= ~GBR_NETINFO_CMP;
|
|
|
|
m_Cmpref.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( *aName == ".N" )
|
|
|
|
{
|
|
|
|
m_NetAttribType &= ~GBR_NETINFO_NET;
|
|
|
|
m_Netname.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( *aName == ".P" )
|
|
|
|
{
|
|
|
|
m_NetAttribType &= ~GBR_NETINFO_PAD;
|
2017-07-02 14:41:31 +00:00
|
|
|
m_Padname.clear();
|
2019-11-17 09:11:29 +00:00
|
|
|
m_PadPinFunction.clear();
|
2016-08-16 10:56:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-12-19 16:00:52 +00:00
|
|
|
|
|
|
|
// these members are used in the %TO object attributes command.
|
|
|
|
int m_NetAttribType; ///< the type of net info
|
|
|
|
///< (used to define the gerber string to create)
|
|
|
|
bool m_NotInNet; ///< true if a pad of a footprint cannot be connected
|
|
|
|
///< (for instance a mechanical NPTH, ot a not named pad)
|
|
|
|
///< in this case the pad net name is empty in gerber file
|
|
|
|
GBR_DATA_FIELD m_Padname; ///< for a flashed pad: the pad name ((TO.P attribute)
|
|
|
|
GBR_DATA_FIELD m_PadPinFunction; ///< for a pad: the pin function (defined in schematic)
|
|
|
|
wxString m_Cmpref; ///< the component reference parent of the data
|
|
|
|
wxString m_Netname; ///< for items associated to a net: the netname
|
|
|
|
|
|
|
|
wxString m_ExtraData; ///< a string to print after %TO object attributes, if not empty
|
|
|
|
///< it is printed "as this"
|
|
|
|
/**
|
|
|
|
* If true, do not clear all attributes when a attribute has changed. This is useful
|
|
|
|
* when some attributes need to be persistent. If false, attributes will be cleared
|
|
|
|
* if only one attribute cleared. This is a more secure way to set attributes, when
|
|
|
|
* all attribute changes are not safely managed.
|
|
|
|
*/
|
|
|
|
bool m_TryKeepPreviousAttributes;
|
2016-08-16 10:56:20 +00:00
|
|
|
};
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
// Flashed pads use the full attribute set: this is a helper for flashed pads
|
2020-12-19 16:00:52 +00:00
|
|
|
#define GBR_NETINFO_ALL \
|
|
|
|
( GBR_NETLIST_METADATA::GBR_NETINFO_PAD | GBR_NETLIST_METADATA::GBR_NETINFO_NET \
|
|
|
|
| GBR_NETLIST_METADATA::GBR_NETINFO_CMP )
|
2016-08-16 10:56:20 +00:00
|
|
|
|
|
|
|
#endif // GBR_NETLIST_METADATA_H
|