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 );
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 void setCellValues( int aRow, int aCol, const std::vector<wxString>& aValues ) override;
88
89 bool fieldSupportsVariants( const wxString& aFieldName ) const override;
90
91 bool unitMatch( const SCH_REFERENCE& lhItem, const SCH_REFERENCE& rhItem ) override;
92
104 bool storageIsSharedAcrossPaths( const wxString& aFieldName ) const;
105
106 // True when an ancestor sheet forces this attribute on, not the symbol itself.
107 bool attributeForcedOnBySheet( const SCH_REFERENCE& aRef, const wxString& aAttributeName,
108 const wxString& aVariantName ) const override;
109
110 wxString getAttributeValue( const SCH_REFERENCE& aRef, const wxString& aAttributeName,
111 const wxString& aVariantNames );
112 bool getLiveFieldValueForVariant( const SCH_REFERENCE& aRef, const wxString& aFieldName,
113 const wxString& aVariantName, wxString& aValue ) override;
114
124 wxString getDefaultFieldValue( const SCH_REFERENCE& aRef, const wxString& aFieldName );
125
136 bool setAttributeValue( SCH_REFERENCE& aRef, const wxString& aAttributeName, const wxString& aValue,
137 const wxString& aVariantName = wxEmptyString );
138
139 bool getLiveFieldValue( const SCH_REFERENCE& aRef, const wxString& aFieldName,
140 wxString& aValue ) override;
141 std::vector<SCH_REFERENCE> getAllItems() const override;
142
143 wxString getFieldResolvedLiveValue( const SCH_REFERENCE& aRef, const wxString& aFieldName ) override;
144 wxString resolveTextVars( const SCH_REFERENCE& aRef, const wxString& aText ) override;
145
146 KIID_PATH getDataStoreKey( const SCH_REFERENCE& aItem ) const override;
147 wxString getItemIdentifier( const SCH_REFERENCE& aItem ) const override;
148
149protected:
159};
The rest of the generic fields data model stuff, primarily around row functionality.
Commit for the schematic and symbol editors.
Definition sch_commit.h:54
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:73
void RemoveReferences(const SCH_REFERENCE_LIST &aRefs)
wxString getAttributeValue(const SCH_REFERENCE &aRef, const wxString &aAttributeName, const wxString &aVariantNames)
void setCellValues(int aRow, int aCol, const std::vector< wxString > &aValues) override
Write one value per item represented by the cell. Models may propagate shared storage.
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)
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 fieldSupportsVariants(const wxString &aFieldName) const override
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)
void ApplyData(SCH_COMMIT &aCommit, TEMPLATES &aTemplateFieldnames)
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.
bool getLiveFieldValueForVariant(const SCH_REFERENCE &aRef, const wxString &aFieldName, const wxString &aVariantName, wxString &aValue) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
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)
bool attributeForcedOnBySheet(const SCH_REFERENCE &aRef, const wxString &aAttributeName, const wxString &aVariantName) const override
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)