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.

92 lines
3.4 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 NET_SETTINGS : public NESTED_SETTINGS
  31. {
  32. public:
  33. NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
  34. virtual ~NET_SETTINGS();
  35. public:
  36. std::map<wxString, std::shared_ptr<NETCLASS>> m_NetClasses;
  37. std::shared_ptr<NETCLASS> m_DefaultNetClass;
  38. std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>
  39. m_NetClassPatternAssignments;
  40. mutable std::map<wxString, wxString> m_NetClassPatternAssignmentCache;
  41. std::map<wxString, wxString> m_NetClassLabelAssignments;
  42. /**
  43. * A map of fully-qualified net names to colors used in the board context.
  44. * Since these color overrides are for the board, buses are not included here.
  45. * Only nets that the user has assigned custom colors to will be in this list.
  46. * Nets that no longer exist will be deleted during a netlist read in Pcbnew.
  47. */
  48. std::map<wxString, KIGFX::COLOR4D> m_NetColorAssignments;
  49. public:
  50. std::shared_ptr<NETCLASS> GetEffectiveNetClass( const wxString& aNetName ) const;
  51. /**
  52. * Parse a bus vector (e.g. A[7..0]) into name, begin, and end.
  53. *
  54. * Ensure that begin and end are positive and that end > begin.
  55. *
  56. * @param aBus is a bus vector label string
  57. * @param aName out is the bus name, e.g. "A"
  58. * @param aMemberList is a list of member strings, e.g. "A7", "A6", and so on
  59. * @return true if aBus was successfully parsed
  60. */
  61. static bool ParseBusVector( const wxString& aBus, wxString* aName,
  62. std::vector<wxString>* aMemberList );
  63. /**
  64. * Parse a bus group label into the name and a list of components.
  65. *
  66. * @param aGroup is the input label, e.g. "USB{DP DM}"
  67. * @param name is the output group name, e.g. "USB"
  68. * @param aMemberList is a list of member strings, e.g. "DP", "DM"
  69. * @return true if aGroup was successfully parsed
  70. */
  71. static bool ParseBusGroup( const wxString& aGroup, wxString* name,
  72. std::vector<wxString>* aMemberList );
  73. private:
  74. bool migrateSchema0to1();
  75. bool migrateSchema2to3();
  76. // TODO: Add diff pairs, bus information, etc.
  77. };
  78. #endif // KICAD_NET_SETTINGS_H