KiCad PCB EDA Suite
Loading...
Searching...
No Matches
component_class_settings.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef PROJECT_COMPONENT_CLASS_SETTINGS_H
21#define PROJECT_COMPONENT_CLASS_SETTINGS_H
22
23#include <vector>
24#include <unordered_map>
25
27
28
30{
31public:
43
46 {
49 };
50
52 void SetCondition( const CONDITION_TYPE aCondition, const wxString& aPrimaryData,
53 const wxString& aSecondaryData )
54 {
55 m_conditions[aCondition] = { aPrimaryData, aSecondaryData };
56 }
57
59 const std::unordered_map<CONDITION_TYPE, std::pair<wxString, wxString>>& GetConditions() const
60 {
61 return m_conditions;
62 }
63
65 void SetComponentClass( const wxString& aComponentClass )
66 {
67 m_componentClass = aComponentClass;
68 }
69
71 const wxString& GetComponentClass() const { return m_componentClass; }
72
75 {
76 m_conditionsOperator = aOperator;
77 }
78
81
83 static wxString GetConditionName( const CONDITION_TYPE aCondition );
84
86 static CONDITION_TYPE GetConditionType( const wxString& aCondition );
87
89 wxString GetAssignmentInDRCLanguage() const;
90
91protected:
94
96 std::unordered_map<CONDITION_TYPE, std::pair<wxString, wxString>> m_conditions;
97
101};
102
103
109{
110public:
111 COMPONENT_CLASS_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
112
114
116 void SetEnableSheetComponentClasses( bool aEnabled )
117 {
119 }
120
123
126
128 const std::vector<COMPONENT_CLASS_ASSIGNMENT_DATA>& GetComponentClassAssignments() const
129 {
131 }
132
133 // Adds a dynamic component class assignment
135 {
136 m_componentClassAssignments.push_back( aAssignment );
137 }
138
139 bool operator==( const COMPONENT_CLASS_SETTINGS& aOther ) const;
140
141 bool operator!=( const COMPONENT_CLASS_SETTINGS& aOther ) const
142 {
143 return !operator==( aOther );
144 }
145
146private:
149
151 std::vector<COMPONENT_CLASS_ASSIGNMENT_DATA> m_componentClassAssignments;
152
154 static nlohmann::json saveAssignment( const COMPONENT_CLASS_ASSIGNMENT_DATA& aAssignment );
155
157 static COMPONENT_CLASS_ASSIGNMENT_DATA loadAssignment( const nlohmann::json& aJson );
158};
159
160#endif // PROJECT_COMPONENT_CLASS_SETTINGS_H
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
wxString m_componentClass
The name of the component class for this assignment rule.
void SetConditionsOperation(const CONDITIONS_OPERATOR aOperator)
Sets the boolean operation in use for all conditions.
const std::unordered_map< CONDITION_TYPE, std::pair< wxString, wxString > > & GetConditions() const
Gets all conditions.
std::unordered_map< CONDITION_TYPE, std::pair< wxString, wxString > > m_conditions
Map of condition types to primary and secondary data fields for the condition.
void SetCondition(const CONDITION_TYPE aCondition, const wxString &aPrimaryData, const wxString &aSecondaryData)
Sets the given condition type with the assocated match data.
CONDITIONS_OPERATOR
Whether conditions are applied with OR or AND logic.
CONDITIONS_OPERATOR m_conditionsOperator
Whether conditions are applied with AND or OR logic Defaults to ALL.
void SetComponentClass(const wxString &aComponentClass)
Sets the resulting component class for matching footprints.
CONDITIONS_OPERATOR GetConditionsOperator() const
Gets the boolean operation in use for all conditions.
const wxString & GetComponentClass() const
Gets the resulting component class for matching footprints.
COMPONENT_CLASS_SETTINGS stores data for component classes, including rules for automatic generation ...
bool GetEnableSheetComponentClasses() const
Gets whether component classes should be generated for components in hierarchical sheets.
COMPONENT_CLASS_SETTINGS(JSON_SETTINGS *aParent, const std::string &aPath)
static nlohmann::json saveAssignment(const COMPONENT_CLASS_ASSIGNMENT_DATA &aAssignment)
Saves a dynamic component class assignment to JSON.
void ClearComponentClassAssignments()
Clear all dynamic component class assignments.
void SetEnableSheetComponentClasses(bool aEnabled)
Sets whether component classes should be generated for components in hierarchical sheets.
std::vector< COMPONENT_CLASS_ASSIGNMENT_DATA > m_componentClassAssignments
All dynamic component class assignment rules.
bool operator!=(const COMPONENT_CLASS_SETTINGS &aOther) const
void AddComponentClassAssignment(const COMPONENT_CLASS_ASSIGNMENT_DATA &aAssignment)
static COMPONENT_CLASS_ASSIGNMENT_DATA loadAssignment(const nlohmann::json &aJson)
Loads a dynamic component class assignment from JSON.
const std::vector< COMPONENT_CLASS_ASSIGNMENT_DATA > & GetComponentClassAssignments() const
Gets all dynamic component class assignments.
bool m_enableSheetComponentClasses
Toggle generation of component classes for hierarchical sheets.
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
NESTED_SETTINGS(const std::string &aName, int aSchemaVersion, JSON_SETTINGS *aParent, const std::string &aPath, bool aLoadFromFile=true)
#define KICOMMON_API
Definition kicommon.h:28