KiCad PCB EDA Suite
Loading...
Searching...
No Matches
schematic_text_var_adapter.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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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#ifndef SCHEMATIC_TEXT_VAR_ADAPTER_H_
21#define SCHEMATIC_TEXT_VAR_ADAPTER_H_
22
23#include <schematic.h>
24#include <text_var_dependency.h>
25
26#include <set>
27#include <unordered_set>
28
29class SCH_ITEM;
30class SCH_SYMBOL;
31
32
42{
43public:
44 explicit SCHEMATIC_TEXT_VAR_ADAPTER( SCHEMATIC& aSchematic );
45 ~SCHEMATIC_TEXT_VAR_ADAPTER() override = default;
46
48 const TEXT_VAR_TRACKER& Tracker() const { return m_tracker; }
49
50 void OnSchItemsAdded( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aItems ) override;
51 void OnSchItemsRemoved( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aItems ) override;
52 void OnSchItemsChanged( SCHEMATIC& aSch, std::vector<SCH_ITEM*>& aItems ) override;
53
59 void RebuildIndex();
60
66 void SyncToHierarchy();
67
70
77 std::vector<TEXT_VAR_REF_KEY> ExtractSourceKeys( EDA_ITEM* aItem ) const;
78
79private:
80 static SCH_ITEM* trackedItem( SCH_ITEM* aItem );
81 static std::vector<TEXT_VAR_REF_KEY> collectKeys( SCH_ITEM* aItem );
82
83 std::set<SCH_SCREEN*> hierarchyScreens() const;
84 void noteSheets( const std::vector<SCH_ITEM*>& aItems );
85 std::vector<TEXT_VAR_REF_KEY> trackKeys( SCH_ITEM* aItem );
86 void registerItem( SCH_ITEM* aItem );
87 void handleItemChanged( SCH_ITEM* aItem );
88
91 std::unordered_set<SCH_ITEM*> m_registered;
92 std::set<SCH_SCREEN*> m_indexedScreens;
93 bool m_hierarchyChanged = false;
94};
95
96
97#endif // SCHEMATIC_TEXT_VAR_ADAPTER_H_
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
static SCH_ITEM * trackedItem(SCH_ITEM *aItem)
std::vector< TEXT_VAR_REF_KEY > ExtractSourceKeys(EDA_ITEM *aItem) const
Return the keys aItem could source as a cross-reference target.
void noteSheets(const std::vector< SCH_ITEM * > &aItems)
void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aItems) override
void SyncToHierarchy()
Rebuild only if a sheet was added or removed, or the set of screens in the hierarchy differs from the...
std::vector< TEXT_VAR_REF_KEY > trackKeys(SCH_ITEM *aItem)
~SCHEMATIC_TEXT_VAR_ADAPTER() override=default
SCHEMATIC_TEXT_VAR_ADAPTER(SCHEMATIC &aSchematic)
void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aItems) override
std::set< SCH_SCREEN * > m_indexedScreens
void MarkHierarchyChanged()
Force the next SyncToHierarchy() to rebuild.
std::set< SCH_SCREEN * > hierarchyScreens() const
static std::vector< TEXT_VAR_REF_KEY > collectKeys(SCH_ITEM *aItem)
const TEXT_VAR_TRACKER & Tracker() const
void RebuildIndex()
Walk every sheet in the hierarchy and register text-bearing items.
void OnSchItemsAdded(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aItems) override
std::unordered_set< SCH_ITEM * > m_registered
Holds all the data relating to one schematic.
Definition schematic.h:149
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
Schematic symbol object.
Definition sch_symbol.h:73
Coordinates the dependency index with change notifications.