KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_editor_tab_context.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 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
#include <
footprint_editor_tab_context.h
>
21
22
#include <wx/translation.h>
23
24
#include <
board.h
>
25
#include <
footprint.h
>
26
27
28
FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT
(
const
wxString& aLib,
29
const
wxString& aName,
30
std::unique_ptr<BOARD> aBoard ) :
31
m_lib
( aLib ),
32
m_name
( aName ),
33
m_board
(
std
::
move
( aBoard ) ),
34
m_footprintNameWhenLoaded
( aName )
35
{
36
}
37
38
39
FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT
(
const
KIID
& aSourceUuid,
40
const
wxString& aReference,
41
std::unique_ptr<BOARD> aBoard ) :
42
m_board
(
std
::
move
( aBoard ) ),
43
m_kind
(
KIND
::
BOARD_INSTANCE
),
44
m_sourceUuid
( aSourceUuid ),
45
m_reference
( aReference )
46
{
47
}
48
49
50
FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT
(
KIND
aKind, std::unique_ptr<BOARD> aBoard ) :
51
m_board
(
std
::
move
( aBoard ) ),
52
m_kind
( aKind )
53
{
54
}
55
56
57
FOOTPRINT_EDITOR_TAB_CONTEXT::~FOOTPRINT_EDITOR_TAB_CONTEXT
() =
default
;
58
59
60
std::unique_ptr<FOOTPRINT_EDITOR_TAB_CONTEXT>
61
FOOTPRINT_EDITOR_TAB_CONTEXT::MakeUnsaved
( std::unique_ptr<BOARD> aBoard )
62
{
63
return
std::unique_ptr<FOOTPRINT_EDITOR_TAB_CONTEXT>(
64
new
FOOTPRINT_EDITOR_TAB_CONTEXT
(
KIND::UNSAVED
, std::move( aBoard ) ) );
65
}
66
67
68
wxString
FOOTPRINT_EDITOR_TAB_CONTEXT::GetDisplayName
()
const
69
{
70
switch
(
m_kind
)
71
{
72
case
KIND::BOARD_INSTANCE
:
return
m_reference
;
73
74
// The imported name is not an identity the editor can save to, so the tab reads as unnamed
75
case
KIND::UNSAVED
:
return
_
(
"<unnamed>"
);
76
77
default
:
return
m_name
;
78
}
79
}
80
81
82
void
FOOTPRINT_EDITOR_TAB_CONTEXT::PromoteToLibrary
(
const
wxString& aLib,
const
wxString& aName )
83
{
84
wxCHECK(
m_kind
==
KIND::UNSAVED
,
/* void */
);
85
86
m_kind
=
KIND::LIBRARY
;
87
m_lib
= aLib;
88
m_name
= aName;
89
m_footprintNameWhenLoaded
= aName;
90
}
91
92
93
bool
FOOTPRINT_EDITOR_TAB_CONTEXT::IsModified
()
const
94
{
95
return
m_modified
&&
m_board
&&
m_board
->GetFirstFootprint();
96
}
97
98
99
void
FOOTPRINT_EDITOR_TAB_CONTEXT::SetOriginalFootprintCopy
( std::unique_ptr<FOOTPRINT> aCopy )
100
{
101
m_originalFootprintCopy
= std::move( aCopy );
102
}
BITMAPS::move
@ move
Definition
bitmaps_list.h:374
board.h
FOOTPRINT_EDITOR_TAB_CONTEXT::m_footprintNameWhenLoaded
wxString m_footprintNameWhenLoaded
Definition
footprint_editor_tab_context.h:169
FOOTPRINT_EDITOR_TAB_CONTEXT::m_lib
wxString m_lib
Definition
footprint_editor_tab_context.h:165
FOOTPRINT_EDITOR_TAB_CONTEXT::m_sourceUuid
KIID m_sourceUuid
Identity of an unsaved import, which has no library:name pair to key on.
Definition
footprint_editor_tab_context.h:175
FOOTPRINT_EDITOR_TAB_CONTEXT::m_originalFootprintCopy
std::unique_ptr< FOOTPRINT > m_originalFootprintCopy
Definition
footprint_editor_tab_context.h:168
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::GetDisplayName
wxString GetDisplayName() const override
Short label shown on the tab.
Definition
footprint_editor_tab_context.cpp:68
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:82
FOOTPRINT_EDITOR_TAB_CONTEXT::m_name
wxString m_name
Definition
footprint_editor_tab_context.h:166
FOOTPRINT_EDITOR_TAB_CONTEXT::~FOOTPRINT_EDITOR_TAB_CONTEXT
~FOOTPRINT_EDITOR_TAB_CONTEXT() override
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::m_board
std::unique_ptr< BOARD > m_board
Definition
footprint_editor_tab_context.h:167
FOOTPRINT_EDITOR_TAB_CONTEXT::m_modified
bool m_modified
Definition
footprint_editor_tab_context.h:170
FOOTPRINT_EDITOR_TAB_CONTEXT::m_kind
KIND m_kind
Source board footprint UUID, used as the de-dup key and save-back target.
Definition
footprint_editor_tab_context.h:172
FOOTPRINT_EDITOR_TAB_CONTEXT::SetOriginalFootprintCopy
void SetOriginalFootprintCopy(std::unique_ptr< FOOTPRINT > aCopy)
Definition
footprint_editor_tab_context.cpp:99
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:93
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::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:181
KIID
Definition
kiid.h:46
_
#define _(s)
Definition
eda_3d_actions.cpp:36
footprint.h
footprint_editor_tab_context.h
std
STL namespace.
src
pcbnew
footprint_editor_tab_context.cpp
Generated on Fri Jul 31 2026 00:07:56 for KiCad PCB EDA Suite by
1.13.2