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 (C) 2023 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 m_toolManager( aToolManager ),
42 m_frame( a_frame )
43{
44}
45
46
48
49
51 std::function<void()> const& aDoModify,
52 SCH_SHEET_PATH const& aPath )
53{
54 return ModifyItem( aItem.GetItem(), aDoModify, aPath, aItem.GetKind() );
55}
56
57
59 std::function<void()> const& aDoModify,
60 const SCH_SHEET_PATH& aPath,
62{
63 if( !aDoModify )
64 return;
65
66 switch( aKind )
67 {
68 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL:
69 {
70 m_doModify( sch_item, aPath, aDoModify );
71 break;
72 }
73 case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN:
74 {
75 SCH_SHEET_PATH path_cp = aPath;
76 path_cp.pop_back();
77 m_doModify( sch_item, path_cp, aDoModify );
78 break;
79 }
80 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN:
81 break;
82 }
83}
84
85
87 const SCH_SHEET_PATH& aPath )
88{
89 if( !aSheet )
90 return;
91
92 switch( aItem.GetKind() )
93 {
94 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL:
95 {
96 m_doDelete( aItem.GetItem(), aPath );
97 break;
98 }
99 case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN:
100
101 {
102 SCH_SHEET_PATH path_cp = aPath;
103 path_cp.pop_back();
104 m_doDelete( aItem.GetItem(), std::move( path_cp ) );
105 break;
106 }
107 case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN:
108 break;
109 }
110}
111
112
114 SCH_HIERLABEL* aLabel )
115{
116 SCH_SHEET_PATH cp = aPath;
117 cp.pop_back();
119}
120
121
123 SCH_SHEET_PIN* aPin )
124{
126}
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
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.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void PlaceHieraLable(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, SCH_SHEET_PIN *aPin)
void RemoveItem(SHEET_SYNCHRONIZATION_ITEM &aItem, SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath)
std::function< void(EDA_ITEM *, SCH_SHEET_PATH, MODIFICATION const &)> DO_MODIFY_ITEM
std::function< void(SCH_SHEET *, SCH_SHEET_PATH, SHEET_SYNCHRONIZATION_PLACEMENT, EDA_ITEM *)> 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
void PlaceSheetPin(SCH_SHEET *aSheet, SCH_SHEET_PATH const &aPath, SCH_HIERLABEL *aLabel)
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