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.

148 lines
5.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@inpg.fr
  6. * Copyright (C) 2009-2022 KiCad Developers, see change_log.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #ifndef CLASS_NETCLASS_H
  26. #define CLASS_NETCLASS_H
  27. #include <kicommon.h>
  28. #include <gal/color4d.h>
  29. #include <optional>
  30. #include <macros_swig.h>
  31. using KIGFX::COLOR4D;
  32. DECL_SET_FOR_SWIG( STRINGSET, wxString )
  33. /**
  34. * A collection of nets and the parameters used to route or test these nets.
  35. */
  36. class KICOMMON_API NETCLASS
  37. {
  38. public:
  39. static const char Default[]; ///< the name of the default NETCLASS
  40. /**
  41. * Create a NETCLASS instance with \a aName.
  42. * The units on the optional parameters are Internal Units (1 nm)
  43. * @param aName is the name of this new netclass.
  44. */
  45. NETCLASS( const wxString& aName );
  46. ~NETCLASS();
  47. wxString GetClass() const
  48. {
  49. return wxT( "NETCLASS" );
  50. }
  51. const wxString GetName() const { return m_Name; }
  52. void SetName( const wxString& aName ) { m_Name = aName; }
  53. const wxString& GetDescription() const { return m_Description; }
  54. void SetDescription( const wxString& aDesc ) { m_Description = aDesc; }
  55. bool HasClearance() const { return (bool) m_Clearance; }
  56. int GetClearance() const { return m_Clearance.value_or(-1); }
  57. void SetClearance( int aClearance ) { m_Clearance = aClearance; }
  58. bool HasTrackWidth() const { return (bool) m_TrackWidth; }
  59. int GetTrackWidth() const { return m_TrackWidth.value_or( -1 ); }
  60. void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; }
  61. bool HasViaDiameter() const { return (bool) m_ViaDia; }
  62. int GetViaDiameter() const { return m_ViaDia.value_or( -1 ); }
  63. void SetViaDiameter( int aDia ) { m_ViaDia = aDia; }
  64. int HasViaDrill() const { return (bool) m_ViaDrill; }
  65. int GetViaDrill() const { return m_ViaDrill.value_or( -1 ); }
  66. void SetViaDrill( int aSize ) { m_ViaDrill = aSize; }
  67. bool HasuViaDiameter() const { return (bool) m_uViaDia; }
  68. int GetuViaDiameter() const { return m_uViaDia.value_or( -1 ); }
  69. void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; }
  70. bool HasuViaDrill() const { return (bool) m_uViaDrill; }
  71. int GetuViaDrill() const { return m_uViaDrill.value_or( -1 ); }
  72. void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; }
  73. bool HasDiffPairWidth() const { return (bool) m_diffPairWidth; }
  74. int GetDiffPairWidth() const { return m_diffPairWidth.value_or( -1 ); }
  75. void SetDiffPairWidth( int aSize ) { m_diffPairWidth = aSize; }
  76. bool HasDiffPairGap() const { return (bool) m_diffPairGap; }
  77. int GetDiffPairGap() const { return m_diffPairGap.value_or( -1 ); }
  78. void SetDiffPairGap( int aSize ) { m_diffPairGap = aSize; }
  79. bool HasDiffPairViaGap() const { return (bool) m_diffPairViaGap; }
  80. int GetDiffPairViaGap() const { return m_diffPairViaGap.value_or( -1 ); }
  81. void SetDiffPairViaGap( int aSize ) { m_diffPairViaGap = aSize; }
  82. COLOR4D GetPcbColor() const { return m_PcbColor; }
  83. void SetPcbColor( const COLOR4D& aColor ) { m_PcbColor = aColor; }
  84. int GetWireWidth() const { return m_wireWidth; }
  85. void SetWireWidth( int aWidth ) { m_wireWidth = aWidth; }
  86. int GetBusWidth() const { return m_busWidth; }
  87. void SetBusWidth( int aWidth ) { m_busWidth = aWidth; }
  88. COLOR4D GetSchematicColor() const { return m_schematicColor; }
  89. void SetSchematicColor( COLOR4D aColor ) { m_schematicColor = aColor; }
  90. int GetLineStyle() const { return m_lineStyle; }
  91. void SetLineStyle( int aStyle ) { m_lineStyle = aStyle; }
  92. protected:
  93. wxString m_Name; ///< Name of the net class
  94. wxString m_Description; ///< what this NETCLASS is for.
  95. std::optional<int> m_Clearance; ///< clearance when routing
  96. std::optional<int> m_TrackWidth; ///< track width used to route NETs in this NETCLASS
  97. std::optional<int> m_ViaDia; ///< via diameter
  98. std::optional<int> m_ViaDrill; ///< via drill hole diameter
  99. std::optional<int> m_uViaDia; ///< microvia diameter
  100. std::optional<int> m_uViaDrill; ///< microvia drill hole diameter
  101. std::optional<int> m_diffPairWidth;
  102. std::optional<int> m_diffPairGap;
  103. std::optional<int> m_diffPairViaGap;
  104. int m_wireWidth;
  105. int m_busWidth;
  106. COLOR4D m_schematicColor;
  107. int m_lineStyle;
  108. COLOR4D m_PcbColor; ///< Optional color override for this netclass (PCB context)
  109. };
  110. #endif // CLASS_NETCLASS_H