KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_fields_data_model.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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
23#include <sch_reference_list.h>
24
25
26class SCH_SYMBOL;
27
28
30{
33 wxString reference;
34 wxString caseFoldedKey;
35 std::vector<std::pair<wxString, wxString>> variants;
36};
37
38
39std::vector<FIELD_CASE_CONFLICT> DetectFieldCaseConflicts( const SCH_REFERENCE_LIST& aSymbols );
40
42
44{
45public:
53
55 m_symbolsList( aSymbolsList ),
57 {
58 m_symbolsList.SplitReferences();
59 }
60
61 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override;
62
63 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
64 void ClearCell( int aRow, int aCol ) override;
65 void RevertRow( int aRow ) override;
66
67 void RebuildRows() override;
68
69 void ApplyData( SCH_COMMIT& aCommit, TEMPLATES& aTemplateFieldnames, const wxString& aVariantName );
70
71 void SetScope( SCOPE aScope ) { m_scope = aScope; }
72 SCOPE GetScope() { return m_scope; }
73
74 void SetPath( const SCH_SHEET_PATH& aPath ) { m_path = aPath; }
75 const SCH_SHEET_PATH& GetPath() { return m_path; }
76
77 void AddReferences( const SCH_REFERENCE_LIST& aRefs );
78 void RemoveReferences( const SCH_REFERENCE_LIST& aRefs );
79 void RemoveSymbol( const SCH_SYMBOL& aSymbol );
80 void UpdateReferences( const SCH_REFERENCE_LIST& aRefs );
81
82 bool DeleteRows( size_t aPosition = 0, size_t aNumRows = 1 ) override;
83
85
86private:
87 bool unitMatch( const SCH_REFERENCE& lhItem, const SCH_REFERENCE& rhItem ) override;
88
100 bool storageIsSharedAcrossPaths( const wxString& aFieldName ) const;
101
102 // True when an ancestor sheet forces this attribute on, not the symbol itself.
103 bool attributeForcedOnBySheet( const SCH_REFERENCE& aRef, const wxString& aAttributeName ) const override;
104
105 wxString getAttributeValue( const SCH_REFERENCE& aRef, const wxString& aAttributeName,
106 const wxString& aVariantNames );
107 bool getLiveFieldValueForVariant( const SCH_REFERENCE& aRef, const wxString& aFieldName,
108 const wxString& aVariantName, wxString& aValue );
109
119 wxString getDefaultFieldValue( const SCH_REFERENCE& aRef, const wxString& aFieldName );
120
131 bool setAttributeValue( SCH_REFERENCE& aRef, const wxString& aAttributeName, const wxString& aValue,
132 const wxString& aVariantName = wxEmptyString );
133
134 bool getLiveFieldValue( const SCH_REFERENCE& aRef, const wxString& aFieldName,
135 wxString& aValue ) override;
136 std::vector<SCH_REFERENCE> getAllItems() const override;
137
138 wxString getFieldResolvedLiveValue( const SCH_REFERENCE& aRef, const wxString& aFieldName ) override;
139 wxString resolveTextVars( const SCH_REFERENCE& aRef, const wxString& aText ) override;
140
141 KIID_PATH getDataStoreKey( const SCH_REFERENCE& aItem ) const override;
142 wxString getItemIdentifier( const SCH_REFERENCE& aItem ) const override;
143
144protected:
154};
The rest of the generic fields data model stuff, primarily around row functionality.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A helper to define a symbol's reference designator in a schematic.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:75
void RemoveReferences(const SCH_REFERENCE_LIST &aRefs)
wxString getAttributeValue(const SCH_REFERENCE &aRef, const wxString &aAttributeName, const wxString &aVariantNames)
bool attributeForcedOnBySheet(const SCH_REFERENCE &aRef, const wxString &aAttributeName) const override
Sheets can force all the symbols in them to have certain attributes on, like DNP.
wxString getFieldResolvedLiveValue(const SCH_REFERENCE &aRef, const wxString &aFieldName) override
Explicitly bypasses the data store's field values and retries them from the item's current field valu...
void UpdateReferences(const SCH_REFERENCE_LIST &aRefs)
bool getLiveFieldValueForVariant(const SCH_REFERENCE &aRef, const wxString &aFieldName, const wxString &aVariantName, wxString &aValue)
wxString getItemIdentifier(const SCH_REFERENCE &aItem) const override
bool setAttributeValue(SCH_REFERENCE &aRef, const wxString &aAttributeName, const wxString &aValue, const wxString &aVariantName=wxEmptyString)
Set the attribute value.
SCH_REFERENCE_LIST m_symbolsList
The flattened by hierarchy list of symbols.
void RemoveSymbol(const SCH_SYMBOL &aSymbol)
bool getLiveFieldValue(const SCH_REFERENCE &aRef, const wxString &aFieldName, wxString &aValue) override
Gets the current value of the field from the live item, e.g.
void RevertRow(int aRow) override
Go through and revert all the fields in the row to their live values from the item (symbol/footprint/...
void AddReferences(const SCH_REFERENCE_LIST &aRefs)
wxString resolveTextVars(const SCH_REFERENCE &aRef, const wxString &aText) override
bool unitMatch(const SCH_REFERENCE &lhItem, const SCH_REFERENCE &rhItem) override
void ClearCell(int aRow, int aCol) override
Clears the field from the data store, rather than setting its value to an empty string.
void SetValue(int aRow, int aCol, const wxString &aValue) override
void ApplyData(SCH_COMMIT &aCommit, TEMPLATES &aTemplateFieldnames, const wxString &aVariantName)
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
KIID_PATH getDataStoreKey(const SCH_REFERENCE &aItem) const override
Create a unique key for the data store by combining the KIID_PATH from the SCH_SHEET_PATH with the sy...
void SetPath(const SCH_SHEET_PATH &aPath)
const SCH_REFERENCE_LIST & GetReferenceList() const
wxString getDefaultFieldValue(const SCH_REFERENCE &aRef, const wxString &aFieldName)
Get the default (non-variant) value for a field.
std::vector< SCH_REFERENCE > getAllItems() const override
SYMBOL_FIELDS_EDITOR_GRID_DATA_MODEL(const SCH_REFERENCE_LIST &aSymbolsList)
bool storageIsSharedAcrossPaths(const wxString &aFieldName) const
Test whether a field's storage is common to every sheet path that reaches a symbol.
bool DeleteRows(size_t aPosition=0, size_t aNumRows=1) override
std::vector< std::pair< wxString, wxString > > variants
DATA_MODEL_ROW< SCH_REFERENCE > SYMBOL_FIELDS_TABLE_DATA_MODEL_ROW
std::vector< FIELD_CASE_CONFLICT > DetectFieldCaseConflicts(const SCH_REFERENCE_LIST &aSymbols)