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.

104 lines
3.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 CERN
  5. * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
  6. * @author Jon Evans <jon@craftyjon.com>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef KICAD_NET_SETTINGS_H
  22. #define KICAD_NET_SETTINGS_H
  23. #include <netclass.h>
  24. #include <settings/nested_settings.h>
  25. #include <eda_pattern_match.h>
  26. /**
  27. * NET_SETTINGS stores various net-related settings in a project context. These settings are
  28. * accessible and editable from both the schematic and PCB editors.
  29. */
  30. class KICOMMON_API NET_SETTINGS : public NESTED_SETTINGS
  31. {
  32. public:
  33. NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
  34. virtual ~NET_SETTINGS();
  35. bool operator==( const NET_SETTINGS& aOther ) const;
  36. bool operator!=( const NET_SETTINGS& aOther ) const { return !operator==( aOther ); }
  37. public:
  38. std::map<wxString, std::shared_ptr<NETCLASS>> m_NetClasses;
  39. std::shared_ptr<NETCLASS> m_DefaultNetClass;
  40. std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>
  41. m_NetClassPatternAssignments;
  42. mutable std::map<wxString, wxString> m_NetClassPatternAssignmentCache;
  43. std::map<wxString, wxString> m_NetClassLabelAssignments;
  44. /**
  45. * A map of fully-qualified net names to colors used in the board context.
  46. * Since these color overrides are for the board, buses are not included here.
  47. * Only nets that the user has assigned custom colors to will be in this list.
  48. * Nets that no longer exist will be deleted during a netlist read in Pcbnew.
  49. */
  50. std::map<wxString, KIGFX::COLOR4D> m_NetColorAssignments;
  51. public:
  52. std::shared_ptr<NETCLASS> GetEffectiveNetClass( const wxString& aNetName ) const;
  53. /**
  54. * Get a NETCLASS object from a given Netclass name string
  55. *
  56. * @param aNetClassName the Netclass name to resolve
  57. * @return shared pointer to the requested NETCLASS object, or the default NETCLASS
  58. */
  59. std::shared_ptr<NETCLASS> GetNetClassByName( const wxString& aNetName ) const;
  60. /**
  61. * Parse a bus vector (e.g. A[7..0]) into name, begin, and end.
  62. *
  63. * Ensure that begin and end are positive and that end > begin.
  64. *
  65. * @param aBus is a bus vector label string
  66. * @param aName out is the bus name, e.g. "A"
  67. * @param aMemberList is a list of member strings, e.g. "A7", "A6", and so on
  68. * @return true if aBus was successfully parsed
  69. */
  70. static bool ParseBusVector( const wxString& aBus, wxString* aName,
  71. std::vector<wxString>* aMemberList );
  72. /**
  73. * Parse a bus group label into the name and a list of components.
  74. *
  75. * @param aGroup is the input label, e.g. "USB{DP DM}"
  76. * @param name is the output group name, e.g. "USB"
  77. * @param aMemberList is a list of member strings, e.g. "DP", "DM"
  78. * @return true if aGroup was successfully parsed
  79. */
  80. static bool ParseBusGroup( const wxString& aGroup, wxString* name,
  81. std::vector<wxString>* aMemberList );
  82. private:
  83. bool migrateSchema0to1();
  84. bool migrateSchema2to3();
  85. // TODO: Add diff pairs, bus information, etc.
  86. };
  87. #endif // KICAD_NET_SETTINGS_H