KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sheet_synchronization_agent.cpp
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 (C) 2023 Ethan Chien <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
23
24#include <sch_base_frame.h>
25#include <sch_commit.h>
26#include <sch_edit_frame.h>
27#include <sch_sheet_pin.h>
28
30 DO_DELETE_ITEM aNotifyItemChange,
31 DO_PLACE_ITEM aPlaceItem,
32 TOOL_MANAGER* aToolManager,
33 SCH_EDIT_FRAME* a_frame ) :
34 m_doModify( std::move( aDoModify ) ),
35 m_doDelete( std::move( aNotifyItemChange ) ),
36 m_doPlaceItem( std::move( aPlaceItem ) )
37{
38}
39
40
42
43
45 std::function<void()> const& aDoModify,
46 SCH_SHEET_PATH const& aPath )
47{
48 return ModifyItem( aItem.GetItem(), aDoModify, aPath, aItem.GetKind() );
49}
50
51
53 std::function<void()> const& aDoModify,
54 const SCH_SHEET_PATH& aPath,
56{
57 if( !aDoModify )
58 return;
59
60 switch( aKind )
61 {
63 m_doModify( sch_item, aPath, aDoModify );
64 break;
65
67 {
68 SCH_SHEET_PATH path_cp = aPath;
69 path_cp.pop_back();
70 m_doModify( sch_item, path_cp, aDoModify );
71 break;
72 }
73
75 break;
76 }
77}
78
79
81 const SCH_SHEET_PATH& aPath )
82{
83 if( !aSheet )
84 return;
85
86 switch( aItem.GetKind() )
87 {
89 m_doDelete( aItem.GetItem(), aPath );
90 break;
91
93 {
94 SCH_SHEET_PATH path_cp = aPath;
95 path_cp.pop_back();
96 m_doDelete( aItem.GetItem(), std::move( path_cp ) );
97 break;
98 }
99
101 break;
102 }
103}
104
105
107 std::set<EDA_ITEM*> const& aLabels )
108{
109 SCH_SHEET_PATH cp = aPath;
110 cp.pop_back();
112}
113
114
116 std::set<EDA_ITEM*> const& aPins )
117{
119}
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void pop_back()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:44
void RemoveItem(SHEET_SYNCHRONIZATION_ITEM &aItem, SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath)
void PlaceHieraLable(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, std::set< EDA_ITEM * > const &aPins)
std::function< void(EDA_ITEM *, SCH_SHEET_PATH, MODIFICATION const &)> DO_MODIFY_ITEM
void PlaceSheetPin(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, std::set< EDA_ITEM * > const &aLabels)
std::function< void(SCH_SHEET *, SCH_SHEET_PATH, SHEET_SYNCHRONIZATION_PLACEMENT, std::set< EDA_ITEM * > const &)> DO_PLACE_ITEM
void ModifyItem(SHEET_SYNCHRONIZATION_ITEM &aItem, std::function< void()> const &aDoModify, const SCH_SHEET_PATH &aPath)
std::function< void(EDA_ITEM *, SCH_SHEET_PATH)> DO_DELETE_ITEM
SHEET_SYNCHRONIZATION_AGENT(DO_MODIFY_ITEM aDoModify, DO_DELETE_ITEM aDoDelete, DO_PLACE_ITEM aPlaceItem, TOOL_MANAGER *aToolManager, SCH_EDIT_FRAME *a_frame)
virtual SCH_ITEM * GetItem() const =0
virtual SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const =0
Master controller class:
STL namespace.
SHEET_SYNCHRONIZATION_ITEM_KIND