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

One open symbol tab owning a working LIB_SYMBOL and screen lent to the frame while active. More...

#include <symbol_editor_tab_context.h>

Inheritance diagram for SYMBOL_EDITOR_TAB_CONTEXT:
EDITOR_TAB_CONTEXT

Public Types

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

Public Member Functions

 SYMBOL_EDITOR_TAB_CONTEXT (const wxString &aLib, const wxString &aName, SYMBOL_BUFFER *aBuffer)
 Construct a library tab over the buffer for aLibrary:aName.
 
 SYMBOL_EDITOR_TAB_CONTEXT (LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
 Construct an unsaved tab over an already-built transient working symbol/screen.
 
 SYMBOL_EDITOR_TAB_CONTEXT (LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen, const KIID &aSchematicSymbolUUID, const wxString &aReference)
 Construct an instance (schematic) tab over an already-built transient working symbol/screen.
 
 ~SYMBOL_EDITOR_TAB_CONTEXT () override
 
wxString GetTabKey () const override
 Stable identity for persistence and de-duplication.
 
wxString GetDisplayName (bool aShortForm=false) const override
 Short label shown on the tab.
 
bool IsTransient () const
 True for a tab that is session-only and not persisted.
 
bool IsFromSchematic () const
 
bool IsUnsaved () const
 
const KIID & GetSchematicSymbolUUID () const
 
const wxString & GetReference () const
 
bool IsModified () const override
 True when the working screen carries unsaved edits.
 
const wxString & GetLibrary () const
 
const wxString & GetName () const
 
void SetName (const wxString &aName)
 
void PromoteToLibrary (const wxString &aLib, const wxString &aName)
 Gives an unsaved new symbol a library identity.
 
LIB_SYMBOL * GetSymbol () const
 Observe the working symbol/screen.
 
SCH_SCREEN * GetScreen () const
 
void ReleaseToFrame ()
 Hand the working symbol/screen to the frame as the tab becomes active.
 
void AdoptWorkingObjects (LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
 Take ownership back on detach, capturing whatever the frame's symbol now points at.
 
void RefreshFrameOwnedObjects (LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
 Track the frame's new working symbol after undo/redo replaces it, while staying frame-owned.
 
int GetUnit () const
 
void SetUnit (int aUnit)
 
int GetBodyStyle () const
 
void SetBodyStyle (int aBodyStyle)
 
bool IsPreview () const
 
void SetPreview (bool aPreview)
 
UNDO_REDO_CONTAINER & UndoList ()
 
UNDO_REDO_CONTAINER & RedoList ()
 
VIEW_SNAPSHOT & ViewSnapshot ()
 
std::vector< KIID > & SavedSelection ()
 Selection saved as resolved KIIDs, restored after the view is rebuilt.
 

Static Public Member Functions

static wxString MakeTabKey (const wxString &aLib, const wxString &aName)
 De-duplication key for a library:symbol pair.
 
static wxString MakeInstanceTabKey (const KIID &aSchematicSymbolUUID)
 De-duplication key for a placed schematic instance, in a namespace disjoint from library keys.
 
static wxString MakeUnsavedTabKey (const KIID &aSessionId)
 De-duplication key for an unsaved new symbol.
 

Protected Attributes

bool m_preview = false
 
std::unique_ptr< UNDO_REDO_CONTAINER > m_undo
 
std::unique_ptr< UNDO_REDO_CONTAINER > m_redo
 
VIEW_SNAPSHOT m_viewSnapshot
 
std::vector< KIID > m_savedSelection
 

Private Attributes

wxString m_lib
 
wxString m_name
 
LIB_SYMBOL * m_symbol
 Working copy; owned by the context while detached.
 
SCH_SCREEN * m_screen
 Working screen; owned by the context while detached.
 
bool m_frameOwns
 True while the tab is active and the frame owns the symbol/screen.
 
int m_unit
 
int m_bodyStyle
 
KIND m_kind = KIND::LIBRARY
 
KIID m_schematicSymbolUUID
 Source instance UUID, used as both the de-dup key and the save-back target.
 
wxString m_reference
 Reference designator of the source instance, shown as the tab label.
 
KIID m_sessionId
 Identity of an unsaved new symbol, which has no library:name pair to key on.
 

Detailed Description

One open symbol tab owning a working LIB_SYMBOL and screen lent to the frame while active.

A tab is one of three kinds. A library tab edits a buffered library symbol and is keyed by its library:name pair and persisted across sessions. An instance tab edits a symbol pulled from a placed schematic instance (Ctrl-E); it owns a transient working symbol with no library buffer, is keyed by the source instance UUID, and is session-only so it is never persisted. An unsaved tab edits a brand-new symbol with no library home yet; it is keyed by a session id and is promoted to a library tab by the save that gives it an identity.

Definition at line 44 of file symbol_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 symbol, keyed library:name and persisted across sessions.

SCHEMATIC_INSTANCE 

A symbol pulled off a placed schematic symbol, session-only.

UNSAVED 

A brand-new symbol with no library home yet, session-only.

Definition at line 50 of file symbol_editor_tab_context.h.

Constructor & Destructor Documentation

◆ SYMBOL_EDITOR_TAB_CONTEXT() [1/3]

SYMBOL_EDITOR_TAB_CONTEXT::SYMBOL_EDITOR_TAB_CONTEXT ( const wxString & aLib,
const wxString & aName,
SYMBOL_BUFFER * aBuffer )

Construct a library tab over the buffer for aLibrary:aName.

The context edits a private clone of the buffered symbol; the buffer keeps ownership of the original. A fresh empty screen is created since symbol geometry lives in the LIB_SYMBOL.

Definition at line 64 of file symbol_editor_tab_context.cpp.

References SYMBOL_BUFFER::GetSymbol(), SYMBOL_BUFFER::IsModified(), m_bodyStyle, m_frameOwns, m_lib, m_name, m_screen, m_symbol, and m_unit.

◆ SYMBOL_EDITOR_TAB_CONTEXT() [2/3]

SYMBOL_EDITOR_TAB_CONTEXT::SYMBOL_EDITOR_TAB_CONTEXT ( LIB_SYMBOL * aSymbol,
SCH_SCREEN * aScreen )

Construct an unsaved tab over an already-built transient working symbol/screen.

The context takes ownership of both objects, following the same frame-borrow contract as a library tab. There is no library buffer; the symbol has no library identity yet.

Definition at line 27 of file symbol_editor_tab_context.cpp.

References m_bodyStyle, m_frameOwns, m_kind, m_screen, m_sessionId, m_symbol, m_unit, and UNSAVED.

◆ SYMBOL_EDITOR_TAB_CONTEXT() [3/3]

SYMBOL_EDITOR_TAB_CONTEXT::SYMBOL_EDITOR_TAB_CONTEXT ( LIB_SYMBOL * aSymbol,
SCH_SCREEN * aScreen,
const KIID & aSchematicSymbolUUID,
const wxString & aReference )

Construct an instance (schematic) tab over an already-built transient working symbol/screen.

The context takes ownership of both objects, following the same frame-borrow contract as a library tab. There is no library buffer. Save routing is driven by the stored source UUID and reference, which the frame restores on activation.

Definition at line 39 of file symbol_editor_tab_context.cpp.

References m_bodyStyle, m_frameOwns, m_kind, m_reference, m_schematicSymbolUUID, m_screen, m_symbol, m_unit, and SCHEMATIC_INSTANCE.

◆ ~SYMBOL_EDITOR_TAB_CONTEXT()

SYMBOL_EDITOR_TAB_CONTEXT::~SYMBOL_EDITOR_TAB_CONTEXT ( )
override

Definition at line 86 of file symbol_editor_tab_context.cpp.

References m_frameOwns, m_screen, and m_symbol.

Member Function Documentation

◆ AdoptWorkingObjects()

void SYMBOL_EDITOR_TAB_CONTEXT::AdoptWorkingObjects ( LIB_SYMBOL * aSymbol,
SCH_SCREEN * aScreen )
inline

Take ownership back on detach, capturing whatever the frame's symbol now points at.

Definition at line 181 of file symbol_editor_tab_context.h.

References m_frameOwns, m_screen, and m_symbol.

Referenced by SYMBOL_EDIT_FRAME::promptAndCloseSymbolTab().

◆ GetBodyStyle()

int SYMBOL_EDITOR_TAB_CONTEXT::GetBodyStyle ( ) const
inline

◆ GetDisplayName()

wxString SYMBOL_EDITOR_TAB_CONTEXT::GetDisplayName ( bool aShortForm = false) const
inlineoverridevirtual

◆ GetLibrary()

const wxString & SYMBOL_EDITOR_TAB_CONTEXT::GetLibrary ( ) const
inline

Definition at line 156 of file symbol_editor_tab_context.h.

References m_lib.

◆ GetName()

const wxString & SYMBOL_EDITOR_TAB_CONTEXT::GetName ( ) const
inline

Definition at line 157 of file symbol_editor_tab_context.h.

References m_name.

◆ GetReference()

const wxString & SYMBOL_EDITOR_TAB_CONTEXT::GetReference ( ) const
inline

◆ GetSchematicSymbolUUID()

const KIID & SYMBOL_EDITOR_TAB_CONTEXT::GetSchematicSymbolUUID ( ) const
inline

◆ GetScreen()

◆ GetSymbol()

LIB_SYMBOL * SYMBOL_EDITOR_TAB_CONTEXT::GetSymbol ( ) const
inline

Observe the working symbol/screen.

Valid whether active or detached.

Definition at line 168 of file symbol_editor_tab_context.h.

References m_symbol.

Referenced by SYMBOL_EDIT_FRAME::activateSymbolTab(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ GetTabKey()

◆ GetUnit()

int SYMBOL_EDITOR_TAB_CONTEXT::GetUnit ( ) const
inline

Definition at line 197 of file symbol_editor_tab_context.h.

References m_unit.

Referenced by SYMBOL_EDIT_FRAME::activateSymbolTab(), and BOOST_AUTO_TEST_CASE().

◆ IsFromSchematic()

bool SYMBOL_EDITOR_TAB_CONTEXT::IsFromSchematic ( ) const
inline

◆ IsModified()

bool SYMBOL_EDITOR_TAB_CONTEXT::IsModified ( ) const
overridevirtual

True when the working screen carries unsaved edits.

Implements EDITOR_TAB_CONTEXT.

Definition at line 97 of file symbol_editor_tab_context.cpp.

References m_screen.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SYMBOL_EDIT_FRAME::promptAndCloseSymbolTab().

◆ IsPreview()

bool EDITOR_TAB_CONTEXT::IsPreview ( ) const
inlineinherited

Definition at line 58 of file editor_tab_context.h.

References m_preview.

◆ IsTransient()

bool SYMBOL_EDITOR_TAB_CONTEXT::IsTransient ( ) const
inline

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

Definition at line 144 of file symbol_editor_tab_context.h.

References LIBRARY, and m_kind.

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsUnsaved()

bool SYMBOL_EDITOR_TAB_CONTEXT::IsUnsaved ( ) const
inline

Definition at line 147 of file symbol_editor_tab_context.h.

References m_kind, and UNSAVED.

◆ MakeInstanceTabKey()

static wxString SYMBOL_EDITOR_TAB_CONTEXT::MakeInstanceTabKey ( const KIID & aSchematicSymbolUUID)
inlinestatic

De-duplication key for a placed schematic instance, 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 100 of file symbol_editor_tab_context.h.

References KIID::AsString().

Referenced by BOOST_AUTO_TEST_CASE(), SYMBOL_EDIT_FRAME::findOrCreateSymbolInstanceTab(), and GetTabKey().

◆ MakeTabKey()

static wxString SYMBOL_EDITOR_TAB_CONTEXT::MakeTabKey ( const wxString & aLib,
const wxString & aName )
inlinestatic

◆ MakeUnsavedTabKey()

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

De-duplication key for an unsaved new symbol.

Definition at line 108 of file symbol_editor_tab_context.h.

References KIID::AsString().

Referenced by GetTabKey().

◆ PromoteToLibrary()

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

Gives an unsaved new symbol a library identity.

Definition at line 54 of file symbol_editor_tab_context.cpp.

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

◆ RedoList()

◆ RefreshFrameOwnedObjects()

void SYMBOL_EDITOR_TAB_CONTEXT::RefreshFrameOwnedObjects ( LIB_SYMBOL * aSymbol,
SCH_SCREEN * aScreen )
inline

Track the frame's new working symbol after undo/redo replaces it, while staying frame-owned.

Definition at line 191 of file symbol_editor_tab_context.h.

References m_screen, and m_symbol.

◆ ReleaseToFrame()

void SYMBOL_EDITOR_TAB_CONTEXT::ReleaseToFrame ( )
inline

Hand the working symbol/screen to the frame as the tab becomes active.

The context stops deleting them until AdoptWorkingObjects takes ownership back on detach.

Definition at line 176 of file symbol_editor_tab_context.h.

References m_frameOwns.

Referenced by SYMBOL_EDIT_FRAME::activateSymbolTab().

◆ 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(), FOOTPRINT_EDIT_FRAME::installFootprintTabBoard(), and FOOTPRINT_EDIT_FRAME::RefreshLibraryFootprintTab().

◆ SetBodyStyle()

void SYMBOL_EDITOR_TAB_CONTEXT::SetBodyStyle ( int aBodyStyle)
inline

◆ SetName()

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

Definition at line 158 of file symbol_editor_tab_context.h.

References m_name.

◆ SetPreview()

void EDITOR_TAB_CONTEXT::SetPreview ( bool aPreview)
inlineinherited

Definition at line 59 of file editor_tab_context.h.

References m_preview.

◆ SetUnit()

void SYMBOL_EDITOR_TAB_CONTEXT::SetUnit ( int aUnit)
inline

◆ UndoList()

◆ ViewSnapshot()

VIEW_SNAPSHOT & EDITOR_TAB_CONTEXT::ViewSnapshot ( )
inlineinherited

Member Data Documentation

◆ m_bodyStyle

int SYMBOL_EDITOR_TAB_CONTEXT::m_bodyStyle
private

◆ m_frameOwns

bool SYMBOL_EDITOR_TAB_CONTEXT::m_frameOwns
private

True while the tab is active and the frame owns the symbol/screen.

Definition at line 208 of file symbol_editor_tab_context.h.

Referenced by AdoptWorkingObjects(), ReleaseToFrame(), SYMBOL_EDITOR_TAB_CONTEXT(), SYMBOL_EDITOR_TAB_CONTEXT(), SYMBOL_EDITOR_TAB_CONTEXT(), and ~SYMBOL_EDITOR_TAB_CONTEXT().

◆ m_kind

◆ m_lib

wxString SYMBOL_EDITOR_TAB_CONTEXT::m_lib
private

◆ m_name

wxString SYMBOL_EDITOR_TAB_CONTEXT::m_name
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 SYMBOL_EDITOR_TAB_CONTEXT::m_reference
private

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

Definition at line 218 of file symbol_editor_tab_context.h.

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

◆ 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_schematicSymbolUUID

KIID SYMBOL_EDITOR_TAB_CONTEXT::m_schematicSymbolUUID
private

Source instance UUID, used as both the de-dup key and the save-back target.

Definition at line 215 of file symbol_editor_tab_context.h.

Referenced by GetSchematicSymbolUUID(), GetTabKey(), and SYMBOL_EDITOR_TAB_CONTEXT().

◆ m_screen

SCH_SCREEN* SYMBOL_EDITOR_TAB_CONTEXT::m_screen
private

◆ m_sessionId

KIID SYMBOL_EDITOR_TAB_CONTEXT::m_sessionId
private

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

Definition at line 221 of file symbol_editor_tab_context.h.

Referenced by GetTabKey(), and SYMBOL_EDITOR_TAB_CONTEXT().

◆ m_symbol

LIB_SYMBOL* SYMBOL_EDITOR_TAB_CONTEXT::m_symbol
private

◆ 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_unit

int SYMBOL_EDITOR_TAB_CONTEXT::m_unit
private

◆ 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: