KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_editor_tab_context.h
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 The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef FOOTPRINT_EDITOR_TAB_CONTEXT_H
21
#define FOOTPRINT_EDITOR_TAB_CONTEXT_H
22
23
#include <map>
24
#include <memory>
25
26
#include <wx/string.h>
27
28
#include <
kiid.h
>
29
#include <
widgets/editor_tab_context.h
>
30
31
class
BOARD
;
32
class
FOOTPRINT
;
33
34
45
class
FOOTPRINT_EDITOR_TAB_CONTEXT
:
public
EDITOR_TAB_CONTEXT
46
{
47
public
:
51
enum class
KIND
52
{
53
LIBRARY
,
54
BOARD_INSTANCE
,
55
UNSAVED
56
};
57
58
FOOTPRINT_EDITOR_TAB_CONTEXT
(
const
wxString& aLib,
const
wxString& aName,
59
std::unique_ptr<BOARD> aBoard );
60
69
FOOTPRINT_EDITOR_TAB_CONTEXT
(
const
KIID
& aSourceUuid,
const
wxString& aReference,
70
std::unique_ptr<BOARD> aBoard );
71
72
~FOOTPRINT_EDITOR_TAB_CONTEXT
()
override
;
73
80
static
std::unique_ptr<FOOTPRINT_EDITOR_TAB_CONTEXT>
MakeUnsaved
( std::unique_ptr<BOARD> aBoard );
81
88
static
wxString
MakeInstanceTabKey
(
const
KIID
& aSourceUuid )
89
{
90
return
wxString( wxT(
"\x01@fp:"
) ) + aSourceUuid.
AsString
();
91
}
92
97
static
wxString
MakeUnsavedTabKey
(
const
KIID
& aSessionId )
98
{
99
return
wxString( wxT(
"\x01@import:"
) ) + aSessionId.
AsString
();
100
}
101
102
wxString
GetTabKey
()
const override
103
{
104
switch
(
m_kind
)
105
{
106
case
KIND::BOARD_INSTANCE
:
return
MakeInstanceTabKey
(
m_sourceUuid
);
107
case
KIND::UNSAVED
:
return
MakeUnsavedTabKey
(
m_sessionId
);
108
default
:
return
m_lib
+ wxT(
":"
) +
m_name
;
109
}
110
}
111
112
wxString
GetDisplayName
(
bool
aShortForm =
false
)
const override
;
113
120
void
PromoteToLibrary
(
const
wxString& aLib,
const
wxString& aName );
121
125
bool
IsTransient
()
const
{
return
m_kind
!=
KIND::LIBRARY
; }
126
127
bool
IsFromBoard
()
const
{
return
m_kind
==
KIND::BOARD_INSTANCE
; }
128
bool
IsUnsaved
()
const
{
return
m_kind
==
KIND::UNSAVED
; }
129
const
KIID
&
GetSourceUuid
()
const
{
return
m_sourceUuid
; }
130
const
wxString&
GetReference
()
const
{
return
m_reference
; }
131
136
std::map<KIID, KIID>&
BoardFootprintUuids
() {
return
m_boardFootprintUuids
; }
137
141
bool
IsModified
()
const override
;
142
143
void
SetModified
(
bool
aModified ) {
m_modified
= aModified; }
144
148
BOARD
*
GetBoard
()
const
{
return
m_board
.get(); }
149
150
const
wxString&
GetLib
()
const
{
return
m_lib
; }
151
const
wxString&
GetName
()
const
{
return
m_name
; }
152
void
SetName
(
const
wxString& aName ) {
m_name
= aName; }
153
157
FOOTPRINT
*
GetOriginalFootprintCopy
()
const
{
return
m_originalFootprintCopy
.get(); }
158
void
SetOriginalFootprintCopy
( std::unique_ptr<FOOTPRINT> aCopy );
159
160
const
wxString&
GetFootprintNameWhenLoaded
()
const
{
return
m_footprintNameWhenLoaded
; }
161
void
SetFootprintNameWhenLoaded
(
const
wxString& aName ) {
m_footprintNameWhenLoaded
= aName; }
162
163
private
:
164
FOOTPRINT_EDITOR_TAB_CONTEXT
(
KIND
aKind, std::unique_ptr<BOARD> aBoard );
165
166
wxString
m_lib
;
167
wxString
m_name
;
168
std::unique_ptr<BOARD>
m_board
;
169
std::unique_ptr<FOOTPRINT>
m_originalFootprintCopy
;
170
wxString
m_footprintNameWhenLoaded
;
171
bool
m_modified
=
false
;
172
173
KIND
m_kind
=
KIND::LIBRARY
;
174
176
KIID
m_sourceUuid
;
177
179
KIID
m_sessionId
;
180
182
wxString
m_reference
;
183
185
std::map<KIID, KIID>
m_boardFootprintUuids
;
186
};
187
188
#endif
// FOOTPRINT_EDITOR_TAB_CONTEXT_H
BOARD
Information pertinent to a Pcbnew printed circuit board.
Definition
board.h:410
EDITOR_TAB_CONTEXT::EDITOR_TAB_CONTEXT
EDITOR_TAB_CONTEXT()
Definition
editor_tab_context.h:38
FOOTPRINT_EDITOR_TAB_CONTEXT::BoardFootprintUuids
std::map< KIID, KIID > & BoardFootprintUuids()
Editor-to-board UUID remap captured at load, used by SaveFootprintToBoard to restore the original boa...
Definition
footprint_editor_tab_context.h:136
FOOTPRINT_EDITOR_TAB_CONTEXT::m_footprintNameWhenLoaded
wxString m_footprintNameWhenLoaded
Definition
footprint_editor_tab_context.h:170
FOOTPRINT_EDITOR_TAB_CONTEXT::m_lib
wxString m_lib
Definition
footprint_editor_tab_context.h:166
FOOTPRINT_EDITOR_TAB_CONTEXT::IsTransient
bool IsTransient() const
True for a tab that is session-only and not yet saved.
Definition
footprint_editor_tab_context.h:125
FOOTPRINT_EDITOR_TAB_CONTEXT::IsUnsaved
bool IsUnsaved() const
Definition
footprint_editor_tab_context.h:128
FOOTPRINT_EDITOR_TAB_CONTEXT::GetBoard
BOARD * GetBoard() const
The fp-holder board owned by this context.
Definition
footprint_editor_tab_context.h:148
FOOTPRINT_EDITOR_TAB_CONTEXT::m_sourceUuid
KIID m_sourceUuid
Source board footprint UUID, used as the de-dup key and save-back target.
Definition
footprint_editor_tab_context.h:176
FOOTPRINT_EDITOR_TAB_CONTEXT::m_originalFootprintCopy
std::unique_ptr< FOOTPRINT > m_originalFootprintCopy
Definition
footprint_editor_tab_context.h:169
FOOTPRINT_EDITOR_TAB_CONTEXT::KIND
KIND
What the tab edits, which decides its key, its label and whether it is persisted.
Definition
footprint_editor_tab_context.h:52
FOOTPRINT_EDITOR_TAB_CONTEXT::KIND::UNSAVED
@ UNSAVED
An imported footprint with no library home yet, session-only.
Definition
footprint_editor_tab_context.h:55
FOOTPRINT_EDITOR_TAB_CONTEXT::KIND::BOARD_INSTANCE
@ BOARD_INSTANCE
A footprint pulled off a placed board footprint, session-only.
Definition
footprint_editor_tab_context.h:54
FOOTPRINT_EDITOR_TAB_CONTEXT::KIND::LIBRARY
@ LIBRARY
A library footprint, keyed library:name and persisted across sessions.
Definition
footprint_editor_tab_context.h:53
FOOTPRINT_EDITOR_TAB_CONTEXT::PromoteToLibrary
void PromoteToLibrary(const wxString &aLib, const wxString &aName)
Give an imported footprint the library identity a save-as just assigned it.
Definition
footprint_editor_tab_context.cpp:88
FOOTPRINT_EDITOR_TAB_CONTEXT::m_name
wxString m_name
Definition
footprint_editor_tab_context.h:167
FOOTPRINT_EDITOR_TAB_CONTEXT::m_boardFootprintUuids
std::map< KIID, KIID > m_boardFootprintUuids
Editor-to-board UUID remap used to save instance edits back to the original board items.
Definition
footprint_editor_tab_context.h:185
FOOTPRINT_EDITOR_TAB_CONTEXT::MakeUnsavedTabKey
static wxString MakeUnsavedTabKey(const KIID &aSessionId)
De-duplication key for an imported footprint, in a namespace disjoint from the library and instance k...
Definition
footprint_editor_tab_context.h:97
FOOTPRINT_EDITOR_TAB_CONTEXT::~FOOTPRINT_EDITOR_TAB_CONTEXT
~FOOTPRINT_EDITOR_TAB_CONTEXT() override
FOOTPRINT_EDITOR_TAB_CONTEXT::GetDisplayName
wxString GetDisplayName(bool aShortForm=false) const override
Short label shown on the tab.
Definition
footprint_editor_tab_context.cpp:68
FOOTPRINT_EDITOR_TAB_CONTEXT::GetSourceUuid
const KIID & GetSourceUuid() const
Definition
footprint_editor_tab_context.h:129
FOOTPRINT_EDITOR_TAB_CONTEXT::MakeInstanceTabKey
static wxString MakeInstanceTabKey(const KIID &aSourceUuid)
De-duplication key for a placed board footprint, in a namespace disjoint from library keys.
Definition
footprint_editor_tab_context.h:88
FOOTPRINT_EDITOR_TAB_CONTEXT::m_sessionId
KIID m_sessionId
Identity of an unsaved import, which has no library:name pair to key on.
Definition
footprint_editor_tab_context.h:179
FOOTPRINT_EDITOR_TAB_CONTEXT::SetModified
void SetModified(bool aModified)
Definition
footprint_editor_tab_context.h:143
FOOTPRINT_EDITOR_TAB_CONTEXT::MakeUnsaved
static std::unique_ptr< FOOTPRINT_EDITOR_TAB_CONTEXT > MakeUnsaved(std::unique_ptr< BOARD > aBoard)
Construct a tab for an imported footprint that has no library identity yet.
Definition
footprint_editor_tab_context.cpp:61
FOOTPRINT_EDITOR_TAB_CONTEXT::GetName
const wxString & GetName() const
Definition
footprint_editor_tab_context.h:151
FOOTPRINT_EDITOR_TAB_CONTEXT::m_board
std::unique_ptr< BOARD > m_board
Definition
footprint_editor_tab_context.h:168
FOOTPRINT_EDITOR_TAB_CONTEXT::m_modified
bool m_modified
Definition
footprint_editor_tab_context.h:171
FOOTPRINT_EDITOR_TAB_CONTEXT::SetFootprintNameWhenLoaded
void SetFootprintNameWhenLoaded(const wxString &aName)
Definition
footprint_editor_tab_context.h:161
FOOTPRINT_EDITOR_TAB_CONTEXT::m_kind
KIND m_kind
Definition
footprint_editor_tab_context.h:173
FOOTPRINT_EDITOR_TAB_CONTEXT::SetOriginalFootprintCopy
void SetOriginalFootprintCopy(std::unique_ptr< FOOTPRINT > aCopy)
Definition
footprint_editor_tab_context.cpp:108
FOOTPRINT_EDITOR_TAB_CONTEXT::GetFootprintNameWhenLoaded
const wxString & GetFootprintNameWhenLoaded() const
Definition
footprint_editor_tab_context.h:160
FOOTPRINT_EDITOR_TAB_CONTEXT::IsModified
bool IsModified() const override
True only when dirty and the board actually holds a footprint to edit.
Definition
footprint_editor_tab_context.cpp:102
FOOTPRINT_EDITOR_TAB_CONTEXT::GetOriginalFootprintCopy
FOOTPRINT * GetOriginalFootprintCopy() const
Baseline clone captured at load, used to detect edits and to revert.
Definition
footprint_editor_tab_context.h:157
FOOTPRINT_EDITOR_TAB_CONTEXT::GetTabKey
wxString GetTabKey() const override
Stable identity for persistence and de-duplication.
Definition
footprint_editor_tab_context.h:102
FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT
FOOTPRINT_EDITOR_TAB_CONTEXT(const wxString &aLib, const wxString &aName, std::unique_ptr< BOARD > aBoard)
Definition
footprint_editor_tab_context.cpp:28
FOOTPRINT_EDITOR_TAB_CONTEXT::GetReference
const wxString & GetReference() const
Definition
footprint_editor_tab_context.h:130
FOOTPRINT_EDITOR_TAB_CONTEXT::GetLib
const wxString & GetLib() const
Definition
footprint_editor_tab_context.h:150
FOOTPRINT_EDITOR_TAB_CONTEXT::IsFromBoard
bool IsFromBoard() const
Definition
footprint_editor_tab_context.h:127
FOOTPRINT_EDITOR_TAB_CONTEXT::SetName
void SetName(const wxString &aName)
Definition
footprint_editor_tab_context.h:152
FOOTPRINT_EDITOR_TAB_CONTEXT::m_reference
wxString m_reference
Reference designator of the source footprint, shown as the tab label.
Definition
footprint_editor_tab_context.h:182
FOOTPRINT
Definition
footprint.h:315
KIID
Definition
kiid.h:46
KIID::AsString
wxString AsString() const
Definition
kiid.cpp:264
editor_tab_context.h
kiid.h
src
pcbnew
footprint_editor_tab_context.h
Generated on Wed Oct 7 2026 00:06:02 for KiCad PCB EDA Suite by
1.13.2