2020-05-31 21:42:04 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 CERN
|
2022-08-14 11:03:18 +00:00
|
|
|
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-05-31 21:42:04 +00:00
|
|
|
* @author Jon Evans <jon@craftyjon.com>
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KICAD_NET_SETTINGS_H
|
|
|
|
#define KICAD_NET_SETTINGS_H
|
|
|
|
|
|
|
|
#include <netclass.h>
|
|
|
|
#include <settings/nested_settings.h>
|
2022-08-14 11:03:18 +00:00
|
|
|
#include <eda_pattern_match.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* NET_SETTINGS stores various net-related settings in a project context. These settings are
|
|
|
|
* accessible and editable from both the schematic and PCB editors.
|
|
|
|
*/
|
2024-03-20 01:53:21 +00:00
|
|
|
class KICOMMON_API NET_SETTINGS : public NESTED_SETTINGS
|
2020-05-31 21:42:04 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
|
|
|
|
|
|
|
|
virtual ~NET_SETTINGS();
|
|
|
|
|
2024-01-01 18:37:31 +00:00
|
|
|
bool operator==( const NET_SETTINGS& aOther ) const;
|
|
|
|
|
|
|
|
bool operator!=( const NET_SETTINGS& aOther ) const { return !operator==( aOther ); }
|
|
|
|
|
2020-07-06 10:51:04 +00:00
|
|
|
public:
|
2022-08-14 11:03:18 +00:00
|
|
|
std::map<wxString, std::shared_ptr<NETCLASS>> m_NetClasses;
|
|
|
|
std::shared_ptr<NETCLASS> m_DefaultNetClass;
|
2020-05-31 21:42:04 +00:00
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
std::vector<std::pair<std::unique_ptr<EDA_COMBINED_MATCHER>, wxString>>
|
|
|
|
m_NetClassPatternAssignments;
|
2023-03-06 13:55:40 +00:00
|
|
|
mutable std::map<wxString, wxString> m_NetClassPatternAssignmentCache;
|
2022-08-14 11:03:18 +00:00
|
|
|
|
|
|
|
std::map<wxString, wxString> m_NetClassLabelAssignments;
|
2020-07-06 10:51:04 +00:00
|
|
|
|
2020-07-08 02:21:45 +00:00
|
|
|
/**
|
|
|
|
* A map of fully-qualified net names to colors used in the board context.
|
|
|
|
* Since these color overrides are for the board, buses are not included here.
|
|
|
|
* Only nets that the user has assigned custom colors to will be in this list.
|
2021-06-08 17:47:06 +00:00
|
|
|
* Nets that no longer exist will be deleted during a netlist read in Pcbnew.
|
2020-07-08 02:21:45 +00:00
|
|
|
*/
|
2022-08-14 11:03:18 +00:00
|
|
|
std::map<wxString, KIGFX::COLOR4D> m_NetColorAssignments;
|
2020-07-08 02:21:45 +00:00
|
|
|
|
2020-07-06 10:51:04 +00:00
|
|
|
public:
|
2022-08-14 11:03:18 +00:00
|
|
|
std::shared_ptr<NETCLASS> GetEffectiveNetClass( const wxString& aNetName ) const;
|
2020-10-07 14:40:12 +00:00
|
|
|
|
2024-02-27 18:04:15 +00:00
|
|
|
/**
|
|
|
|
* Get a NETCLASS object from a given Netclass name string
|
2024-03-14 02:49:01 +00:00
|
|
|
*
|
2024-02-27 18:04:15 +00:00
|
|
|
* @param aNetClassName the Netclass name to resolve
|
|
|
|
* @return shared pointer to the requested NETCLASS object, or the default NETCLASS
|
|
|
|
*/
|
|
|
|
std::shared_ptr<NETCLASS> GetNetClassByName( const wxString& aNetName ) const;
|
|
|
|
|
2020-07-06 10:51:04 +00:00
|
|
|
/**
|
2021-06-08 17:47:06 +00:00
|
|
|
* Parse a bus vector (e.g. A[7..0]) into name, begin, and end.
|
|
|
|
*
|
|
|
|
* Ensure that begin and end are positive and that end > begin.
|
2020-07-06 10:51:04 +00:00
|
|
|
*
|
|
|
|
* @param aBus is a bus vector label string
|
|
|
|
* @param aName out is the bus name, e.g. "A"
|
|
|
|
* @param aMemberList is a list of member strings, e.g. "A7", "A6", and so on
|
|
|
|
* @return true if aBus was successfully parsed
|
|
|
|
*/
|
|
|
|
static bool ParseBusVector( const wxString& aBus, wxString* aName,
|
|
|
|
std::vector<wxString>* aMemberList );
|
2020-05-31 21:42:04 +00:00
|
|
|
|
2020-07-06 10:51:04 +00:00
|
|
|
/**
|
2021-06-08 17:47:06 +00:00
|
|
|
* Parse a bus group label into the name and a list of components.
|
2020-07-06 10:51:04 +00:00
|
|
|
*
|
|
|
|
* @param aGroup is the input label, e.g. "USB{DP DM}"
|
|
|
|
* @param name is the output group name, e.g. "USB"
|
|
|
|
* @param aMemberList is a list of member strings, e.g. "DP", "DM"
|
|
|
|
* @return true if aGroup was successfully parsed
|
|
|
|
*/
|
2021-06-08 17:47:06 +00:00
|
|
|
static bool ParseBusGroup( const wxString& aGroup, wxString* name,
|
2020-07-06 10:51:04 +00:00
|
|
|
std::vector<wxString>* aMemberList );
|
|
|
|
|
|
|
|
private:
|
2021-06-14 23:16:34 +00:00
|
|
|
bool migrateSchema0to1();
|
2024-05-05 18:08:55 +00:00
|
|
|
bool migrateSchema1to2();
|
2022-08-14 11:03:18 +00:00
|
|
|
bool migrateSchema2to3();
|
2021-06-14 23:16:34 +00:00
|
|
|
|
|
|
|
// TODO: Add diff pairs, bus information, etc.
|
2020-05-31 21:42:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KICAD_NET_SETTINGS_H
|