KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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 SYMBOL_EDITOR_TAB_CONTEXT_H
21#define SYMBOL_EDITOR_TAB_CONTEXT_H
22
23#include <wx/string.h>
24
25#include <kiid.h>
27
28class LIB_SYMBOL;
29class SCH_SCREEN;
30class SYMBOL_BUFFER;
31
32
42{
43public:
44 SYMBOL_EDITOR_TAB_CONTEXT( const wxString& aLib, const wxString& aName, SYMBOL_BUFFER* aBuffer );
45
54 const KIID& aSchematicSymbolUUID, const wxString& aReference );
55
57
61 static wxString MakeTabKey( const wxString& aLib, const wxString& aName )
62 {
63 return aLib + wxT( ":" ) + aName;
64 }
65
72 static wxString MakeInstanceTabKey( const KIID& aSchematicSymbolUUID )
73 {
74 return wxString( wxT( "\x01@sym:" ) ) + aSchematicSymbolUUID.AsString();
75 }
76
77 wxString GetTabKey() const override
78 {
81 }
82
83 wxString GetDisplayName() const override { return m_fromSchematic ? m_reference : m_name; }
84
88 bool IsTransient() const { return m_fromSchematic; }
89
90 bool IsFromSchematic() const { return m_fromSchematic; }
92 const wxString& GetReference() const { return m_reference; }
93
97 bool IsModified() const override;
98
99 const wxString& GetLibrary() const { return m_lib; }
100 const wxString& GetName() const { return m_name; }
101
105 LIB_SYMBOL* GetSymbol() const { return m_symbol; }
106 SCH_SCREEN* GetScreen() const { return m_screen; }
107
113 void ReleaseToFrame() { m_frameOwns = true; }
114
118 void AdoptWorkingObjects( LIB_SYMBOL* aSymbol, SCH_SCREEN* aScreen )
119 {
120 m_symbol = aSymbol;
121 m_screen = aScreen;
122 m_frameOwns = false;
123 }
124
129 {
130 m_symbol = aSymbol;
131 m_screen = aScreen;
132 }
133
134 int GetUnit() const { return m_unit; }
135 void SetUnit( int aUnit ) { m_unit = aUnit; }
136
137 int GetBodyStyle() const { return m_bodyStyle; }
138 void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
139
140private:
141 wxString m_lib;
142 wxString m_name;
148
151
154
156 wxString m_reference;
157};
158
159#endif // SYMBOL_EDITOR_TAB_CONTEXT_H
Definition kiid.h:44
wxString AsString() const
Definition kiid.cpp:242
Define a library symbol object.
Definition lib_symbol.h:79
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 m_bodyStyle
True for an instance tab edited in place from a placed schematic symbol.
bool m_fromSchematic
Source instance UUID, used as both the de-dup key and the save-back target.
void ReleaseToFrame()
Hand the working symbol/screen to the frame as the tab becomes active.
wxString GetDisplayName() const override
Short label shown on the tab.
LIB_SYMBOL * GetSymbol() const
Observe the working symbol/screen.
LIB_SYMBOL * m_symbol
Working copy; owned by the context while detached.
const wxString & GetReference() const
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.
SYMBOL_EDITOR_TAB_CONTEXT(const wxString &aLib, const wxString &aName, SYMBOL_BUFFER *aBuffer)
wxString GetTabKey() const override
Stable identity for persistence and de-duplication.
const KIID & GetSchematicSymbolUUID() const
bool m_frameOwns
True while the tab is active and the frame owns the symbol/screen.
bool IsModified() const override
True when the working screen carries unsaved edits.
SCH_SCREEN * m_screen
Working screen; owned by the context while detached.
void AdoptWorkingObjects(LIB_SYMBOL *aSymbol, SCH_SCREEN *aScreen)
Take ownership back on detach, capturing whatever the frame's symbol now points at.
const wxString & GetLibrary() const
bool IsTransient() const
True for an instance (schematic) tab, which is session-only and never persisted.
KIID m_schematicSymbolUUID
Reference designator of the source instance, shown as the tab label.