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
43
class
FOOTPRINT_EDITOR_TAB_CONTEXT
:
public
EDITOR_TAB_CONTEXT
44
{
45
public
:
46
FOOTPRINT_EDITOR_TAB_CONTEXT
(
const
wxString& aLib,
const
wxString& aName,
47
std::unique_ptr<BOARD> aBoard );
48
56
FOOTPRINT_EDITOR_TAB_CONTEXT
(
const
KIID
& aSourceUuid,
const
wxString& aReference,
57
std::unique_ptr<BOARD> aBoard );
58
59
~FOOTPRINT_EDITOR_TAB_CONTEXT
()
override
;
60
67
static
wxString
MakeInstanceTabKey
(
const
KIID
& aSourceUuid )
68
{
69
return
wxString( wxT(
"\x01@fp:"
) ) + aSourceUuid.
AsString
();
70
}
71
72
wxString
GetTabKey
()
const override
73
{
74
return
m_fromBoard
?
MakeInstanceTabKey
(
m_sourceUuid
) :
m_lib
+ wxT(
":"
) +
m_name
;
75
}
76
77
wxString
GetDisplayName
()
const override
{
return
m_fromBoard
?
m_reference
:
m_name
; }
78
82
bool
IsTransient
()
const
{
return
m_fromBoard
; }
83
84
bool
IsFromBoard
()
const
{
return
m_fromBoard
; }
85
const
KIID
&
GetSourceUuid
()
const
{
return
m_sourceUuid
; }
86
const
wxString&
GetReference
()
const
{
return
m_reference
; }
87
92
std::map<KIID, KIID>&
BoardFootprintUuids
() {
return
m_boardFootprintUuids
; }
93
97
bool
IsModified
()
const override
;
98
99
void
SetModified
(
bool
aModified ) {
m_modified
= aModified; }
100
104
BOARD
*
GetBoard
()
const
{
return
m_board
.get(); }
105
106
const
wxString&
GetLib
()
const
{
return
m_lib
; }
107
const
wxString&
GetName
()
const
{
return
m_name
; }
108
void
SetName
(
const
wxString& aName ) {
m_name
= aName; }
109
113
FOOTPRINT
*
GetOriginalFootprintCopy
()
const
{
return
m_originalFootprintCopy
.get(); }
114
void
SetOriginalFootprintCopy
( std::unique_ptr<FOOTPRINT> aCopy );
115
116
const
wxString&
GetFootprintNameWhenLoaded
()
const
{
return
m_footprintNameWhenLoaded
; }
117
void
SetFootprintNameWhenLoaded
(
const
wxString& aName ) {
m_footprintNameWhenLoaded
= aName; }
118
119
private
:
120
wxString
m_lib
;
121
wxString
m_name
;
122
std::unique_ptr<BOARD>
m_board
;
123
std::unique_ptr<FOOTPRINT>
m_originalFootprintCopy
;
124
wxString
m_footprintNameWhenLoaded
;
125
bool
m_modified
=
false
;
126
128
bool
m_fromBoard
=
false
;
129
131
KIID
m_sourceUuid
;
132
134
wxString
m_reference
;
135
137
std::map<KIID, KIID>
m_boardFootprintUuids
;
138
};
139
140
#endif
// FOOTPRINT_EDITOR_TAB_CONTEXT_H
BOARD
Information pertinent to a Pcbnew printed circuit board.
Definition
board.h:320
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:92
FOOTPRINT_EDITOR_TAB_CONTEXT::m_footprintNameWhenLoaded
wxString m_footprintNameWhenLoaded
Definition
footprint_editor_tab_context.h:124
FOOTPRINT_EDITOR_TAB_CONTEXT::m_lib
wxString m_lib
Definition
footprint_editor_tab_context.h:120
FOOTPRINT_EDITOR_TAB_CONTEXT::IsTransient
bool IsTransient() const
True for an instance (board) tab, which is session-only and never persisted.
Definition
footprint_editor_tab_context.h:82
FOOTPRINT_EDITOR_TAB_CONTEXT::GetBoard
BOARD * GetBoard() const
The fp-holder board owned by this context.
Definition
footprint_editor_tab_context.h:104
FOOTPRINT_EDITOR_TAB_CONTEXT::m_sourceUuid
KIID m_sourceUuid
Reference designator of the source footprint, shown as the tab label.
Definition
footprint_editor_tab_context.h:131
FOOTPRINT_EDITOR_TAB_CONTEXT::m_originalFootprintCopy
std::unique_ptr< FOOTPRINT > m_originalFootprintCopy
Definition
footprint_editor_tab_context.h:123
FOOTPRINT_EDITOR_TAB_CONTEXT::GetDisplayName
wxString GetDisplayName() const override
Short label shown on the tab.
Definition
footprint_editor_tab_context.h:77
FOOTPRINT_EDITOR_TAB_CONTEXT::m_name
wxString m_name
Definition
footprint_editor_tab_context.h:121
FOOTPRINT_EDITOR_TAB_CONTEXT::m_boardFootprintUuids
std::map< KIID, KIID > m_boardFootprintUuids
Definition
footprint_editor_tab_context.h:137
FOOTPRINT_EDITOR_TAB_CONTEXT::~FOOTPRINT_EDITOR_TAB_CONTEXT
~FOOTPRINT_EDITOR_TAB_CONTEXT() override
FOOTPRINT_EDITOR_TAB_CONTEXT::GetSourceUuid
const KIID & GetSourceUuid() const
Definition
footprint_editor_tab_context.h:85
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:67
FOOTPRINT_EDITOR_TAB_CONTEXT::SetModified
void SetModified(bool aModified)
Definition
footprint_editor_tab_context.h:99
FOOTPRINT_EDITOR_TAB_CONTEXT::GetName
const wxString & GetName() const
Definition
footprint_editor_tab_context.h:107
FOOTPRINT_EDITOR_TAB_CONTEXT::m_board
std::unique_ptr< BOARD > m_board
Definition
footprint_editor_tab_context.h:122
FOOTPRINT_EDITOR_TAB_CONTEXT::m_modified
bool m_modified
True for an instance tab edited in place from a placed board footprint.
Definition
footprint_editor_tab_context.h:125
FOOTPRINT_EDITOR_TAB_CONTEXT::SetFootprintNameWhenLoaded
void SetFootprintNameWhenLoaded(const wxString &aName)
Definition
footprint_editor_tab_context.h:117
FOOTPRINT_EDITOR_TAB_CONTEXT::SetOriginalFootprintCopy
void SetOriginalFootprintCopy(std::unique_ptr< FOOTPRINT > aCopy)
Definition
footprint_editor_tab_context.cpp:57
FOOTPRINT_EDITOR_TAB_CONTEXT::GetFootprintNameWhenLoaded
const wxString & GetFootprintNameWhenLoaded() const
Definition
footprint_editor_tab_context.h:116
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:51
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:113
FOOTPRINT_EDITOR_TAB_CONTEXT::GetTabKey
wxString GetTabKey() const override
Stable identity for persistence and de-duplication.
Definition
footprint_editor_tab_context.h:72
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:26
FOOTPRINT_EDITOR_TAB_CONTEXT::GetReference
const wxString & GetReference() const
Definition
footprint_editor_tab_context.h:86
FOOTPRINT_EDITOR_TAB_CONTEXT::m_fromBoard
bool m_fromBoard
Source board footprint UUID, used as the de-dup key and save-back target.
Definition
footprint_editor_tab_context.h:128
FOOTPRINT_EDITOR_TAB_CONTEXT::GetLib
const wxString & GetLib() const
Definition
footprint_editor_tab_context.h:106
FOOTPRINT_EDITOR_TAB_CONTEXT::IsFromBoard
bool IsFromBoard() const
Definition
footprint_editor_tab_context.h:84
FOOTPRINT_EDITOR_TAB_CONTEXT::SetName
void SetName(const wxString &aName)
Definition
footprint_editor_tab_context.h:108
FOOTPRINT_EDITOR_TAB_CONTEXT::m_reference
wxString m_reference
Editor-to-board UUID remap used to save instance edits back to the original board items.
Definition
footprint_editor_tab_context.h:134
FOOTPRINT
Definition
footprint.h:286
KIID
Definition
kiid.h:44
KIID::AsString
wxString AsString() const
Definition
kiid.cpp:242
editor_tab_context.h
kiid.h
src
pcbnew
footprint_editor_tab_context.h
Generated on Thu Jun 18 2026 00:07:00 for KiCad PCB EDA Suite by
1.13.2