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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
27
28#include <sch_base_frame.h>
29#include <sch_commit.h>
30#include <sch_edit_frame.h>
31#include <sch_sheet_pin.h>
32
34 DO_DELETE_ITEM aNotifyItemChange,
35 DO_PLACE_ITEM aPlaceItem,
36 TOOL_MANAGER* aToolManager,
37 SCH_EDIT_FRAME* a_frame ) :
38 m_doModify( std::move( aDoModify ) ),
39 m_doDelete( std::move( aNotifyItemChange ) ),
40 m_doPlaceItem( std::move( aPlaceItem ) )
41{
42}
43
44
46
47
49 std::function<void()> const& aDoModify,
50 SCH_SHEET_PATH const& aPath )
51{
52 return ModifyItem( aItem.GetItem(), aDoModify, aPath, aItem.GetKind() );
53}
54
55
57 std::function<void()> const& aDoModify,
58 const SCH_SHEET_PATH& aPath,
60{
61 if( !aDoModify )
62 return;
63
64 switch( aKind )
65 {
66 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL:
67 {
68 m_doModify( sch_item, aPath, aDoModify );
69 break;
70 }
71 case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN:
72 {
73 SCH_SHEET_PATH path_cp = aPath;
74 path_cp.pop_back();
75 m_doModify( sch_item, path_cp, aDoModify );
76 break;
77 }
78 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN:
79 break;
80 }
81}
82
83
85 const SCH_SHEET_PATH& aPath )
86{
87 if( !aSheet )
88 return;
89
90 switch( aItem.GetKind() )
91 {
92 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL:
93 {
94 m_doDelete( aItem.GetItem(), aPath );
95 break;
96 }
97 case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN:
98
99 {
100 SCH_SHEET_PATH path_cp = aPath;
101 path_cp.pop_back();
102 m_doDelete( aItem.GetItem(), std::move( path_cp ) );
103 break;
104 }
105 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN:
106 break;
107 }
108}
109
110
112 std::set<EDA_ITEM*> const& aLabels )
113{
114 SCH_SHEET_PATH cp = aPath;
115 cp.pop_back();
117}
118
119
121 std::set<EDA_ITEM*> const& aPins )
122{
124}
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
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:47
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:
Definition: tool_manager.h:62
STL namespace.
SHEET_SYNCHRONIZATION_ITEM_KIND