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 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
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{
42}
43
44
46{
47 return m_label->GetShownText( true );
48}
49
50
52{
53 return m_label->GetShape();
54}
55
56
58{
59 static wxBitmap bitMap =
60 KiBitmap( BITMAPS::add_hierarchical_label, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
61 return bitMap;
62}
63
64
66{
67 return m_label;
68}
69
70
72{
73 return SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL;
74}
75
76
78 SCH_SHEET* aSheet ) :
79 m_pin( aPin )
80{
81}
82
83
85{
86 return m_pin->GetShownText( true );
87}
88
89
91{
92 return m_pin->GetShape();
93}
94
95
97{
98 static wxBitmap bitMap =
99 KiBitmap( BITMAPS::add_hierar_pin, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
100 return bitMap;
101}
102
103
105{
106 return m_pin;
107}
108
109
111{
112 return SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN;
113}
114
115
117 m_label( aLabel ), m_pin( aPin )
118{
119}
120
121
124 ASSOCIATED_SCH_LABEL_PIN( aLabel->GetLabel(), aPin->GetPin() )
125{
126}
127
128
130{
131 return m_label->GetShownText( true );
132}
133
134
136{
137 return m_label->GetShape();
138}
139
140
142{
143 static auto label_and_pin_icon = ( []{
144 wxBitmap left = KiBitmap( BITMAPS::add_hierar_pin,
146 wxBitmap right =
147 KiBitmap( BITMAPS::add_hierarchical_label,
149 wxImage img( wxSize{ SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH * 2,
151 img.Paste( left.ConvertToImage(), 0, 0 );
152 img.Paste( right.ConvertToImage(), SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH, 0 );
153 return wxBitmap( img );
154 } )();
155
156 return label_and_pin_icon;
157}
158
159
161{
162 return nullptr;
163}
164
165
167{
168 return SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN;
169}
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:168
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
Definition: sch_label.cpp:891
LABEL_FLAG_SHAPE GetShape() const
Definition: sch_label.h:176
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:47
SHEET_SYNCHRONIZATION_ITEM_KIND