You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.5 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef GBR_NETLIST_METADATA_H
  25. #define GBR_NETLIST_METADATA_H
  26. /** this class handle info which can be added in a gerber file as attribute
  27. * of an obtect
  28. * the GBR_INFO_TYPE types can be OR'ed to add 2 (or more) attributes
  29. * There are only 3 net attributes defined attached to an object by the %TO command
  30. * %TO.P
  31. * %TO.N
  32. * %TO.C
  33. * the .P attribute can be used only for flashed pads (using the D03 command)
  34. * and only for external copper layers, if the component is on a external copper layer
  35. * for other copper layer items (pads on internal layers, tracks ... ), only .N and .C
  36. * can be used
  37. */
  38. class GBR_NETLIST_METADATA
  39. {
  40. public:
  41. // This enum enables the different net attributes attache to the object
  42. // the values can be ORed for items which can have more than one attribute
  43. // (A flashed pad has all allowed attributes)
  44. enum GBR_NETINFO_TYPE
  45. {
  46. GBR_NETINFO_UNSPECIFIED, ///< idle command (no command)
  47. GBR_NETINFO_PAD = 1, ///< print info associated to a flashed pad (TO.P attribute)
  48. GBR_NETINFO_NET = 2, ///< print info associated to a net (TO.N attribute)
  49. GBR_NETINFO_CMP = 4 ///< print info associated to a component (TO.C attribute)
  50. };
  51. // these members are used in the %TO object attributes command.
  52. int m_NetAttribType; ///< the type of net info
  53. ///< (used to define the gerber string to create)
  54. bool m_NotInNet; ///< true if a pad of a footprint cannot be connected
  55. ///< (for instance a mechanical NPTH, ot a not named pad)
  56. ///< in this case the pad net name is empty in gerber file
  57. wxString m_Padname; ///< for a flashed pad: the pad name ((TO.P attribute)
  58. wxString m_Cmpref; ///< the component reference parent of the data
  59. wxString m_Netname; ///< for items associated to a net: the netname
  60. GBR_NETLIST_METADATA(): m_NetAttribType( GBR_NETINFO_UNSPECIFIED ), m_NotInNet( false )
  61. {
  62. }
  63. /**
  64. * remove the net attribute specified by aName
  65. * If aName == NULL or empty, remove all attributes
  66. * @param aName is the name (.CN, .P .N or .C) of the attribute to remove
  67. */
  68. void ClearAttribute( const wxString* aName )
  69. {
  70. if( m_NetAttribType == GBR_NETINFO_UNSPECIFIED )
  71. {
  72. m_Padname.clear();
  73. m_Cmpref.clear();
  74. m_Netname.clear();
  75. return;
  76. }
  77. if( !aName || aName->IsEmpty() || *aName == ".CN" )
  78. {
  79. m_NetAttribType = GBR_NETINFO_UNSPECIFIED;
  80. m_Padname.clear();
  81. m_Cmpref.clear();
  82. m_Netname.clear();
  83. return;
  84. }
  85. if( *aName == ".C" )
  86. {
  87. m_NetAttribType &= ~GBR_NETINFO_CMP;
  88. m_Cmpref.clear();
  89. return;
  90. }
  91. if( *aName == ".N" )
  92. {
  93. m_NetAttribType &= ~GBR_NETINFO_NET;
  94. m_Netname.clear();
  95. return;
  96. }
  97. if( *aName == ".P" )
  98. {
  99. m_NetAttribType &= ~GBR_NETINFO_PAD;
  100. m_Padname.clear();
  101. return;
  102. }
  103. }
  104. };
  105. // Flashed pads use the full attribute set: this is a helper for flashed pads
  106. #define GBR_NETINFO_ALL (GBR_NETLIST_METADATA::GBR_NETINFO_PAD\
  107. | GBR_NETLIST_METADATA::GBR_NETINFO_NET\
  108. | GBR_NETLIST_METADATA::GBR_NETINFO_CMP )
  109. #endif // GBR_NETLIST_METADATA_H