KiCad PCB EDA Suite
Loading...
Searching...
No Matches
FOOTPRINT_EDITOR_TAB_CONTEXT Class Reference

One open footprint tab owning its fp-holder board, lent to the frame by raw pointer while active. More...

#include <footprint_editor_tab_context.h>

Inheritance diagram for FOOTPRINT_EDITOR_TAB_CONTEXT:
EDITOR_TAB_CONTEXT

Public Types

enum class  KIND { LIBRARY , BOARD_INSTANCE , UNSAVED }
 What the tab edits, which decides its key, its label and whether it is persisted. More...
 

Public Member Functions

 FOOTPRINT_EDITOR_TAB_CONTEXT (const wxString &aLib, const wxString &aName, std::unique_ptr< BOARD > aBoard)
 
 FOOTPRINT_EDITOR_TAB_CONTEXT (const KIID &aSourceUuid, const wxString &aReference, std::unique_ptr< BOARD > aBoard)
 Construct an instance (board) tab over an fp-holder board carrying a clone of a placed footprint.
 
 ~FOOTPRINT_EDITOR_TAB_CONTEXT () override
 
wxString GetTabKey () const override
 Stable identity for persistence and de-duplication.
 
wxString GetDisplayName () const override
 Short label shown on the tab.
 
void PromoteToLibrary (const wxString &aLib, const wxString &aName)
 Give an imported footprint the library identity a save-as just assigned it.
 
bool IsTransient () const
 True for a tab that is session-only and never persisted.
 
bool IsFromBoard () const
 
bool IsUnsaved () const
 
const KIIDGetSourceUuid () const
 
const wxString & GetReference () const
 
std::map< KIID, KIID > & BoardFootprintUuids ()
 Editor-to-board UUID remap captured at load, used by SaveFootprintToBoard to restore the original board item identities.
 
bool IsModified () const override
 True only when dirty and the board actually holds a footprint to edit.
 
void SetModified (bool aModified)
 
BOARDGetBoard () const
 The fp-holder board owned by this context.
 
const wxString & GetLib () const
 
const wxString & GetName () const
 
void SetName (const wxString &aName)
 
FOOTPRINTGetOriginalFootprintCopy () const
 Baseline clone captured at load, used to detect edits and to revert.
 
void SetOriginalFootprintCopy (std::unique_ptr< FOOTPRINT > aCopy)
 
const wxString & GetFootprintNameWhenLoaded () const
 
void SetFootprintNameWhenLoaded (const wxString &aName)
 
bool IsPreview () const
 
void SetPreview (bool aPreview)
 
UNDO_REDO_CONTAINERUndoList ()
 
UNDO_REDO_CONTAINERRedoList ()
 
VIEW_SNAPSHOTViewSnapshot ()
 
std::vector< KIID > & SavedSelection ()
 Selection saved as resolved KIIDs, restored after the view is rebuilt.
 

Static Public Member Functions

static std::unique_ptr< FOOTPRINT_EDITOR_TAB_CONTEXTMakeUnsaved (std::unique_ptr< BOARD > aBoard)
 Construct a tab for an imported footprint that has no library identity yet.
 
static wxString MakeInstanceTabKey (const KIID &aSourceUuid)
 De-duplication key for a placed board footprint, in a namespace disjoint from library keys.
 
static wxString MakeUnsavedTabKey (const KIID &aSessionId)
 De-duplication key for an imported footprint, in a namespace disjoint from the library and instance keys.
 

Protected Attributes

bool m_preview = false
 
std::unique_ptr< UNDO_REDO_CONTAINERm_undo
 
std::unique_ptr< UNDO_REDO_CONTAINERm_redo
 
VIEW_SNAPSHOT m_viewSnapshot
 
std::vector< KIIDm_savedSelection
 

Private Member Functions

 FOOTPRINT_EDITOR_TAB_CONTEXT (KIND aKind, std::unique_ptr< BOARD > aBoard)
 

Private Attributes

wxString m_lib
 
wxString m_name
 
std::unique_ptr< BOARDm_board
 
std::unique_ptr< FOOTPRINTm_originalFootprintCopy
 
wxString m_footprintNameWhenLoaded
 
bool m_modified = false
 
KIND m_kind = KIND::LIBRARY
 Source board footprint UUID, used as the de-dup key and save-back target.
 
KIID m_sourceUuid
 Identity of an unsaved import, which has no library:name pair to key on.
 
KIID m_sessionId
 Reference designator of the source footprint, shown as the tab label.
 
wxString m_reference
 Editor-to-board UUID remap used to save instance edits back to the original board items.
 
std::map< KIID, KIIDm_boardFootprintUuids
 

Detailed Description

One open footprint tab owning its fp-holder board, lent to the frame by raw pointer while active.

A tab is one of three kinds. A library tab edits a library footprint, is keyed by its library:name pair and persisted across sessions. An instance tab edits a footprint pulled from a placed board footprint (Ctrl-E); it is keyed by the source board footprint UUID, carries the board-uuid remap used to save the edits back to that instance, and is session-only so it is never persisted. An unsaved tab edits an imported footprint that has no library home yet; it is keyed by a session id and is promoted to a library tab by the save-as that gives it an identity.

Definition at line 45 of file footprint_editor_tab_context.h.

Member Enumeration Documentation

◆ KIND

What the tab edits, which decides its key, its label and whether it is persisted.

Enumerator
LIBRARY 

A library footprint, keyed library:name and persisted across sessions.

BOARD_INSTANCE 

A footprint pulled off a placed board footprint, session-only.

UNSAVED 

An imported footprint with no library home yet, session-only.

Definition at line 51 of file footprint_editor_tab_context.h.

Constructor & Destructor Documentation

◆ FOOTPRINT_EDITOR_TAB_CONTEXT() [1/3]

FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT ( const wxString & aLib,
const wxString & aName,
std::unique_ptr< BOARD > aBoard )

Definition at line 28 of file footprint_editor_tab_context.cpp.

References m_board, m_footprintNameWhenLoaded, m_lib, m_name, and move.

Referenced by MakeUnsaved().

◆ FOOTPRINT_EDITOR_TAB_CONTEXT() [2/3]

FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT ( const KIID & aSourceUuid,
const wxString & aReference,
std::unique_ptr< BOARD > aBoard )

Construct an instance (board) tab over an fp-holder board carrying a clone of a placed footprint.

Parameters
aSourceUuidis the source board footprint's UUID, used as the de-dup key and tab label.
aReferenceis the placed footprint reference shown on the tab.

Definition at line 39 of file footprint_editor_tab_context.cpp.

References BOARD_INSTANCE, m_board, m_kind, m_reference, m_sourceUuid, and move.

◆ ~FOOTPRINT_EDITOR_TAB_CONTEXT()

FOOTPRINT_EDITOR_TAB_CONTEXT::~FOOTPRINT_EDITOR_TAB_CONTEXT ( )
overridedefault

◆ FOOTPRINT_EDITOR_TAB_CONTEXT() [3/3]

FOOTPRINT_EDITOR_TAB_CONTEXT::FOOTPRINT_EDITOR_TAB_CONTEXT ( KIND aKind,
std::unique_ptr< BOARD > aBoard )
private

Definition at line 50 of file footprint_editor_tab_context.cpp.

References m_board, m_kind, and move.

Member Function Documentation

◆ BoardFootprintUuids()

std::map< KIID, KIID > & FOOTPRINT_EDITOR_TAB_CONTEXT::BoardFootprintUuids ( )
inline

Editor-to-board UUID remap captured at load, used by SaveFootprintToBoard to restore the original board item identities.

Empty for a library tab.

Definition at line 135 of file footprint_editor_tab_context.h.

References m_boardFootprintUuids.

Referenced by BOOST_AUTO_TEST_CASE(), and FOOTPRINT_EDIT_FRAME::installFootprintTabBoard().

◆ GetBoard()

BOARD * FOOTPRINT_EDITOR_TAB_CONTEXT::GetBoard ( ) const
inline

◆ GetDisplayName()

wxString FOOTPRINT_EDITOR_TAB_CONTEXT::GetDisplayName ( ) const
overridevirtual

◆ GetFootprintNameWhenLoaded()

const wxString & FOOTPRINT_EDITOR_TAB_CONTEXT::GetFootprintNameWhenLoaded ( ) const
inline

◆ GetLib()

const wxString & FOOTPRINT_EDITOR_TAB_CONTEXT::GetLib ( ) const
inline

Definition at line 149 of file footprint_editor_tab_context.h.

References m_lib.

Referenced by FOOTPRINT_EDIT_FRAME::SaveSettings().

◆ GetName()

const wxString & FOOTPRINT_EDITOR_TAB_CONTEXT::GetName ( ) const
inline

Definition at line 150 of file footprint_editor_tab_context.h.

References m_name.

Referenced by FOOTPRINT_EDIT_FRAME::SaveSettings().

◆ GetOriginalFootprintCopy()

FOOTPRINT * FOOTPRINT_EDITOR_TAB_CONTEXT::GetOriginalFootprintCopy ( ) const
inline

Baseline clone captured at load, used to detect edits and to revert.

Definition at line 156 of file footprint_editor_tab_context.h.

References m_originalFootprintCopy.

Referenced by FOOTPRINT_EDIT_FRAME::installFootprintTabBoard().

◆ GetReference()

const wxString & FOOTPRINT_EDITOR_TAB_CONTEXT::GetReference ( ) const
inline

Definition at line 129 of file footprint_editor_tab_context.h.

References m_reference.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetSourceUuid()

const KIID & FOOTPRINT_EDITOR_TAB_CONTEXT::GetSourceUuid ( ) const
inline

Definition at line 128 of file footprint_editor_tab_context.h.

References m_sourceUuid.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetTabKey()

wxString FOOTPRINT_EDITOR_TAB_CONTEXT::GetTabKey ( ) const
inlineoverridevirtual

◆ IsFromBoard()

bool FOOTPRINT_EDITOR_TAB_CONTEXT::IsFromBoard ( ) const
inline

Definition at line 126 of file footprint_editor_tab_context.h.

References BOARD_INSTANCE, and m_kind.

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsModified()

bool FOOTPRINT_EDITOR_TAB_CONTEXT::IsModified ( ) const
overridevirtual

True only when dirty and the board actually holds a footprint to edit.

Implements EDITOR_TAB_CONTEXT.

Definition at line 93 of file footprint_editor_tab_context.cpp.

References m_board, and m_modified.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FOOTPRINT_EDIT_FRAME::installFootprintTabBoard(), and FOOTPRINT_EDIT_FRAME::promptAndCloseFootprintTab().

◆ IsPreview()

bool EDITOR_TAB_CONTEXT::IsPreview ( ) const
inlineinherited

Definition at line 58 of file editor_tab_context.h.

References m_preview.

◆ IsTransient()

bool FOOTPRINT_EDITOR_TAB_CONTEXT::IsTransient ( ) const
inline

True for a tab that is session-only and never persisted.

Definition at line 124 of file footprint_editor_tab_context.h.

References LIBRARY, and m_kind.

Referenced by BOOST_AUTO_TEST_CASE(), and FOOTPRINT_EDIT_FRAME::SaveSettings().

◆ IsUnsaved()

bool FOOTPRINT_EDITOR_TAB_CONTEXT::IsUnsaved ( ) const
inline

Definition at line 127 of file footprint_editor_tab_context.h.

References m_kind, and UNSAVED.

◆ MakeInstanceTabKey()

static wxString FOOTPRINT_EDITOR_TAB_CONTEXT::MakeInstanceTabKey ( const KIID & aSourceUuid)
inlinestatic

De-duplication key for a placed board footprint, in a namespace disjoint from library keys.

The leading control character cannot appear in a library nickname, so an instance key can never collide with a library:name key.

Definition at line 87 of file footprint_editor_tab_context.h.

References KIID::AsString().

Referenced by BOOST_AUTO_TEST_CASE(), FOOTPRINT_EDIT_FRAME::findOrCreateFootprintInstanceTab(), GetTabKey(), and FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard().

◆ MakeUnsaved()

std::unique_ptr< FOOTPRINT_EDITOR_TAB_CONTEXT > FOOTPRINT_EDITOR_TAB_CONTEXT::MakeUnsaved ( std::unique_ptr< BOARD > aBoard)
static

Construct a tab for an imported footprint that has no library identity yet.

Each import gets its own session id, so importing the same file twice opens two tabs rather than one clobbering the other.

Definition at line 61 of file footprint_editor_tab_context.cpp.

References FOOTPRINT_EDITOR_TAB_CONTEXT(), and UNSAVED.

Referenced by FOOTPRINT_EDIT_FRAME::createUnsavedFootprintTab().

◆ MakeUnsavedTabKey()

static wxString FOOTPRINT_EDITOR_TAB_CONTEXT::MakeUnsavedTabKey ( const KIID & aSessionId)
inlinestatic

De-duplication key for an imported footprint, in a namespace disjoint from the library and instance keys.

Definition at line 96 of file footprint_editor_tab_context.h.

References KIID::AsString().

Referenced by GetTabKey().

◆ PromoteToLibrary()

void FOOTPRINT_EDITOR_TAB_CONTEXT::PromoteToLibrary ( const wxString & aLib,
const wxString & aName )

Give an imported footprint the library identity a save-as just assigned it.

The key changes with the kind, so the caller must re-key the tab strip entry using the key it captured before this call.

Definition at line 82 of file footprint_editor_tab_context.cpp.

References LIBRARY, m_footprintNameWhenLoaded, m_kind, m_lib, m_name, and UNSAVED.

◆ RedoList()

◆ SavedSelection()

std::vector< KIID > & EDITOR_TAB_CONTEXT::SavedSelection ( )
inlineinherited

Selection saved as resolved KIIDs, restored after the view is rebuilt.

Definition at line 77 of file editor_tab_context.h.

References m_savedSelection.

Referenced by SYMBOL_EDIT_FRAME::activateSymbolTab(), and FOOTPRINT_EDIT_FRAME::installFootprintTabBoard().

◆ SetFootprintNameWhenLoaded()

void FOOTPRINT_EDITOR_TAB_CONTEXT::SetFootprintNameWhenLoaded ( const wxString & aName)
inline

Definition at line 160 of file footprint_editor_tab_context.h.

References m_footprintNameWhenLoaded.

◆ SetModified()

void FOOTPRINT_EDITOR_TAB_CONTEXT::SetModified ( bool aModified)
inline

◆ SetName()

void FOOTPRINT_EDITOR_TAB_CONTEXT::SetName ( const wxString & aName)
inline

Definition at line 151 of file footprint_editor_tab_context.h.

References m_name.

◆ SetOriginalFootprintCopy()

void FOOTPRINT_EDITOR_TAB_CONTEXT::SetOriginalFootprintCopy ( std::unique_ptr< FOOTPRINT > aCopy)

Definition at line 99 of file footprint_editor_tab_context.cpp.

References m_originalFootprintCopy.

◆ SetPreview()

void EDITOR_TAB_CONTEXT::SetPreview ( bool aPreview)
inlineinherited

Definition at line 59 of file editor_tab_context.h.

References m_preview.

◆ UndoList()

◆ ViewSnapshot()

VIEW_SNAPSHOT & EDITOR_TAB_CONTEXT::ViewSnapshot ( )
inlineinherited

Member Data Documentation

◆ m_board

std::unique_ptr<BOARD> FOOTPRINT_EDITOR_TAB_CONTEXT::m_board
private

◆ m_boardFootprintUuids

std::map<KIID, KIID> FOOTPRINT_EDITOR_TAB_CONTEXT::m_boardFootprintUuids
private

Definition at line 184 of file footprint_editor_tab_context.h.

Referenced by BoardFootprintUuids().

◆ m_footprintNameWhenLoaded

wxString FOOTPRINT_EDITOR_TAB_CONTEXT::m_footprintNameWhenLoaded
private

◆ m_kind

KIND FOOTPRINT_EDITOR_TAB_CONTEXT::m_kind = KIND::LIBRARY
private

Source board footprint UUID, used as the de-dup key and save-back target.

Definition at line 172 of file footprint_editor_tab_context.h.

Referenced by FOOTPRINT_EDITOR_TAB_CONTEXT(), FOOTPRINT_EDITOR_TAB_CONTEXT(), GetDisplayName(), GetTabKey(), IsFromBoard(), IsTransient(), IsUnsaved(), and PromoteToLibrary().

◆ m_lib

wxString FOOTPRINT_EDITOR_TAB_CONTEXT::m_lib
private

◆ m_modified

bool FOOTPRINT_EDITOR_TAB_CONTEXT::m_modified = false
private

Definition at line 170 of file footprint_editor_tab_context.h.

Referenced by IsModified(), and SetModified().

◆ m_name

wxString FOOTPRINT_EDITOR_TAB_CONTEXT::m_name
private

◆ m_originalFootprintCopy

std::unique_ptr<FOOTPRINT> FOOTPRINT_EDITOR_TAB_CONTEXT::m_originalFootprintCopy
private

◆ m_preview

bool EDITOR_TAB_CONTEXT::m_preview = false
protectedinherited

Definition at line 80 of file editor_tab_context.h.

Referenced by IsPreview(), and SetPreview().

◆ m_redo

std::unique_ptr<UNDO_REDO_CONTAINER> EDITOR_TAB_CONTEXT::m_redo
protectedinherited

Definition at line 82 of file editor_tab_context.h.

Referenced by EDITOR_TAB_CONTEXT(), and RedoList().

◆ m_reference

wxString FOOTPRINT_EDITOR_TAB_CONTEXT::m_reference
private

Editor-to-board UUID remap used to save instance edits back to the original board items.

Definition at line 181 of file footprint_editor_tab_context.h.

Referenced by FOOTPRINT_EDITOR_TAB_CONTEXT(), GetDisplayName(), and GetReference().

◆ m_savedSelection

std::vector<KIID> EDITOR_TAB_CONTEXT::m_savedSelection
protectedinherited

Definition at line 84 of file editor_tab_context.h.

Referenced by SavedSelection().

◆ m_sessionId

KIID FOOTPRINT_EDITOR_TAB_CONTEXT::m_sessionId
private

Reference designator of the source footprint, shown as the tab label.

Definition at line 178 of file footprint_editor_tab_context.h.

Referenced by GetTabKey().

◆ m_sourceUuid

KIID FOOTPRINT_EDITOR_TAB_CONTEXT::m_sourceUuid
private

Identity of an unsaved import, which has no library:name pair to key on.

Definition at line 175 of file footprint_editor_tab_context.h.

Referenced by FOOTPRINT_EDITOR_TAB_CONTEXT(), GetSourceUuid(), and GetTabKey().

◆ m_undo

std::unique_ptr<UNDO_REDO_CONTAINER> EDITOR_TAB_CONTEXT::m_undo
protectedinherited

Definition at line 81 of file editor_tab_context.h.

Referenced by EDITOR_TAB_CONTEXT(), and UndoList().

◆ m_viewSnapshot

VIEW_SNAPSHOT EDITOR_TAB_CONTEXT::m_viewSnapshot
protectedinherited

Definition at line 83 of file editor_tab_context.h.

Referenced by ViewSnapshot().


The documentation for this class was generated from the following files: