KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sheet_synchronization_item.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
29#include <sch_label.h>
30#include <sch_sheet_pin.h>
32#include <sch_sheet.h>
33#include <sch_screen.h>
34#include <wx/bitmap.h>
35#include <wx/image.h>
36
37
39 SCH_SHEET* aSheet ) :
40 m_label( aLabel ),
41 m_sheet( aSheet )
42{
43}
44
45
47{
48 return m_label->GetShownText( true );
49}
50
51
53{
54 return m_label->GetShape();
55}
56
57
59{
60 static wxBitmap bitMap =
61 KiBitmap( BITMAPS::add_hierarchical_label, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
62 return bitMap;
63}
64
65
67{
68 return m_label;
69}
70
71
73{
74 return SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL;
75}
76
77
79 SCH_SHEET* aSheet ) :
80 m_pin( aPin ),
81 m_sheet( aSheet )
82{
83}
84
85
87{
88 return m_pin->GetShownText( true );
89}
90
91
93{
94 return m_pin->GetShape();
95}
96
97
99{
100 static wxBitmap bitMap =
101 KiBitmap( BITMAPS::add_hierar_pin, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
102 return bitMap;
103}
104
105
107{
108 return m_pin;
109}
110
111
113{
114 return SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN;
115}
116
117
119 m_label( aLabel ), m_pin( aPin )
120{
121}
122
123
126 ASSOCIATED_SCH_LABEL_PIN( aLabel->GetLabel(), aPin->GetPin() )
127{
128}
129
130
132{
133 return m_label->GetShownText( true );
134}
135
136
138{
139 return m_label->GetShape();
140}
141
142
144{
145 static auto label_and_pin_icon = ( []{
146 wxBitmap left = KiBitmap( BITMAPS::add_hierar_pin,
148 wxBitmap right =
149 KiBitmap( BITMAPS::add_hierarchical_label,
151 wxImage img( wxSize{ SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH * 2,
153 img.Paste( left.ConvertToImage(), 0, 0 );
154 img.Paste( right.ConvertToImage(), SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH, 0 );
155 return wxBitmap( img );
156 } )();
157
158 return label_and_pin_icon;
159}
160
161
163{
164 return nullptr;
165}
166
167
169{
170 return SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN;
171}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
ASSOCIATED_SCH_LABEL_PIN(SCH_HIERLABEL *aLabel, SCH_SHEET_PIN *aPin)
wxString GetName() const override
SCH_ITEM * GetItem() const override
SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const override
wxBitmap & GetBitmap() const override
SCH_HIERLABEL_SYNCHRONIZATION_ITEM(SCH_HIERLABEL *aLabel, SCH_SHEET *aSheet)
SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
Definition: sch_label.cpp:892
LABEL_FLAG_SHAPE GetShape() const
Definition: sch_label.h:172
SCH_SHEET_PIN_SYNCHRONIZATION_ITEM(SCH_SHEET_PIN *aPin, SCH_SHEET *aSheet)
SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const override
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
SHEET_SYNCHRONIZATION_ITEM_KIND