40#include <wx/filedlg.h>
41#include "wx/generic/textdlgg.h"
46 m_frame = getEditFrame<SCH_BASE_FRAME>();
55 wxCHECK( editFrame,
false );
57 auto libSelectedCondition =
66 auto libInferredCondition =
72 auto pinnedLibSelectedCondition =
78 auto unpinnedLibSelectedCondition =
84 auto symbolSelectedCondition =
90 auto saveSymbolAsCondition =
96 auto multiSelectedCondition =
101 auto canOpenWithTextEditor =
144 canOpenWithTextEditor
145 && ( symbolSelectedCondition || libSelectedCondition ) );
166 wxString libFile = *aEvent.
Parameter<wxString*>();
199 if( libName.IsEmpty() )
201 msg.Printf(
_(
"No symbol library selected." ) );
208 msg.Printf(
_(
"Symbol library '%s' is not writable." ), libName );
273 wxString fullEditorName =
Pgm().GetTextEditor();
275 if( fullEditorName.IsEmpty() )
277 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
290 if( !tempFName.IsEmpty() )
292 ExecuteFile( fullEditorName, tempFName,
nullptr,
false );
310 bool hasWritableLibs =
false;
315 const wxString& libName = sel.GetLibNickname();
318 msg.Printf(
_(
"Symbol library '%s' is not writable." ), libName );
320 hasWritableLibs =
true;
326 if( !hasWritableLibs )
348 if( !sel.
IsValid() && !isPasteAction )
351 msg.Printf(
_(
"No symbol selected" ) );
360 msg.Printf(
_(
"Symbol library '%s' is not writable." ), libName );
376 std::function<
bool( wxString newName )> aValidator ) :
377 wxTextEntryDialog( aParent,
_(
"New name:" ),
_(
"Change Symbol Name" ), aName ),
384 name.Trim(
true ).Trim(
false );
415 [&]( wxString newName )
417 if( newName.IsEmpty() )
419 wxMessageBox( _(
"Symbol must have a name." ) );
425 msg = wxString::Format( _(
"Symbol '%s' already exists in library '%s'." ),
428 KIDIALOG errorDlg( m_frame, msg, _(
"Confirmation" ),
429 wxOK | wxCANCEL | wxICON_WARNING );
430 errorDlg.SetOKLabel( _(
"Overwrite" ) );
432 return errorDlg.ShowModal() == wxID_OK;
438 if( dlg.ShowModal() != wxID_OK )
442 wxString oldName = symbolName;
475 wxDataViewItem treeItem = libMgr.
GetAdapter()->FindItem( libId );
517 if( currentNode && !currentNode->
m_Pinned )
537 if( currentNode && currentNode->
m_Pinned )
554 wxCommandEvent
dummy;
565 getEditFrame<SYMBOL_EDIT_FRAME>()->ToggleProperties();
645 wxMessageBox(
_(
"No symbol to export" ) );
649 wxFileName fn( symbol->
GetName() );
654 wxFileDialog dlg( editFrame,
_(
"Export View as PNG" ), projectPath, fn.GetFullName(),
657 if( dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty() )
665 wxMessageBox( wxString::Format(
_(
"Can't save file '%s'." ), dlg.GetPath() ) );
683 wxMessageBox(
_(
"No symbol to export" ) );
687 wxFileName fn( symbol->
GetName() );
692 wxString fullFileName = wxFileSelector(
_(
"SVG File Name" ), pro_dir, fn.GetFullName(),
697 if( !fullFileName.IsEmpty() )
764 if( blocking_dialog )
766 blocking_dialog->Raise();
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION cancelInteractive
static TOOL_ACTION revert
static TOOL_ACTION addLibrary
static TOOL_ACTION pinLibrary
static TOOL_ACTION saveAll
static TOOL_ACTION unpinLibrary
static TOOL_ACTION showProperties
static TOOL_ACTION newLibrary
static TOOL_ACTION ddAddLibrary
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const Vec & GetOrigin() const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
const Vec & GetSize() const
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool IsType(FRAME_T aType) const
bool SaveCanvasImageToFile(const wxString &aFileName, BITMAP_TYPE aBitmapType)
Save the current view as an image file.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
virtual void SetParent(EDA_ITEM *aParent)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetText(const wxString &aText)
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION deleteSymbol
static TOOL_ACTION cutSymbol
static TOOL_ACTION showHiddenLibFields
static TOOL_ACTION placeSymbol
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION openWithTextEditor
static TOOL_ACTION duplicateSymbol
static TOOL_ACTION showDeMorganAlternate
static TOOL_ACTION newSymbol
static TOOL_ACTION showDeMorganStandard
static TOOL_ACTION editSymbol
static TOOL_ACTION saveLibraryAs
static TOOL_ACTION addSymbolToSchematic
static TOOL_ACTION showPinNumbers
static TOOL_ACTION exportSymbolAsSVG
static TOOL_ACTION importSymbol
static TOOL_ACTION showHiddenLibPins
static TOOL_ACTION saveSymbolCopyAs
static TOOL_ACTION hideSymbolTree
static TOOL_ACTION copySymbol
static TOOL_ACTION renameSymbol
static TOOL_ACTION exportSymbol
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION showSymbolTree
static TOOL_ACTION exportSymbolView
static TOOL_ACTION deriveFromExistingSymbol
static TOOL_ACTION pasteSymbol
static TOOL_ACTION showElectricalTypes
Store schematic specific render settings.
bool m_ShowHiddenLibFields
bool m_ShowPinsElectricalType
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Symbol library management helper that is specific to the symbol library editor frame.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Define a library symbol object.
const BOX2I GetUnitBoundingBox(int aUnit, int aBodyStyle, bool aIgnoreHiddenFields=true) const
Get the bounding box for the symbol.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
LIB_ID GetLibId() const override
wxString GetName() const override
virtual void SetName(const wxString &aName)
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetHeightMils(double aHeightInMils)
void SetWidthMils(double aWidthInMils)
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
void UnpinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
void PinLibrary(const wxString &aLibrary, bool isSymbolLibrary)
std::function< bool(wxString newName)> m_validator
bool TransferDataFromWindow() override
RENAME_DIALOG(wxWindow *aParent, const wxString &aName, std::function< bool(wxString newName)> aValidator)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
const PAGE_INFO & GetPageSettings() const
void SetPageSettings(const PAGE_INFO &aPageSettings)
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
int ToggleSyncedPinsMode(const TOOL_EVENT &aEvent)
int OnDeMorgan(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvt)
int EditSymbol(const TOOL_EVENT &aEvent)
int ExportView(const TOOL_EVENT &aEvent)
int ToggleHiddenLibPins(const TOOL_EVENT &aEvent)
int ShowElectricalTypes(const TOOL_EVENT &aEvent)
int ToggleHiddenLibFields(const TOOL_EVENT &aEvent)
int RenameSymbol(const TOOL_EVENT &newName)
int DuplicateSymbol(const TOOL_EVENT &aEvent)
int UnpinLibrary(const TOOL_EVENT &aEvent)
int AddLibrary(const TOOL_EVENT &aEvent)
int AddSymbol(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int OpenWithTextEditor(const TOOL_EVENT &aEvent)
int ExportSymbol(const TOOL_EVENT &aEvent)
void setTransitions() override
< Set up handlers for various events.
int ToggleProperties(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int ToggleSymbolTree(const TOOL_EVENT &aEvent)
int ExportSymbolAsSVG(const TOOL_EVENT &aEvent)
int ShowPinNumbers(const TOOL_EVENT &aEvent)
int DdAddLibrary(const TOOL_EVENT &aEvent)
int AddSymbolToSchematic(const TOOL_EVENT &aEvent)
int PinLibrary(const TOOL_EVENT &aEvent)
int CutCopyDelete(const TOOL_EVENT &aEvent)
The symbol library editor main window.
void SaveAll()
Save all modified symbols and libraries.
void DeleteSymbolFromLibrary()
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Restore the empty editor screen, without any symbol or library selected.
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_ID GetTargetLibId() const
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
void FocusOnLibId(const LIB_ID &aLibID)
void Save()
Save the selected symbol or library.
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
bool m_SyncPinEdit
Set to true to synchronize pins at the same position when editing symbols with multiple units or mult...
int GetTreeSelectionCount() const
void SaveSymbolCopyAs()
Save the currently selected symbol to a new name and/or location.
void DuplicateSymbol(bool aFromClipboard)
Insert a duplicate symbol.
std::vector< LIB_ID > GetSelectedLibIds() const
LIB_TREE_NODE * GetCurrentTreeNode() const
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void SetBodyStyle(int aBodyStyle)
void UpdateMsgPanel() override
Redraw the message panel.
void CreateNewSymbol(const wxString &newName=wxEmptyString)
Create a new symbol in the selected library.
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
void SVGPlotSymbol(const wxString &aFullFileName, VECTOR2I aOffset)
Create the SVG print file for the current edited symbol.
void CopySymbolToClipboard()
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void DdAddLibrary(wxString aLibFile)
Add a library dropped file to the symbol library table.
void UpdateLibraryTree(const wxDataViewItem &aTreeItem, LIB_SYMBOL *aSymbol)
Update a symbol node in the library tree.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void SaveLibraryAs()
Save the currently selected library to a new file.
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &oldAlias, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
void SetSymbolModified(const wxString &aAlias, const wxString &aLibrary)
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
Symbol library viewer main window.
void SetUnitAndBodyStyle(int aUnit, int aBodyStyle)
Set unit and convert, and set flag preventing them from automatically resetting to 1.
LIB_SYMBOL * GetSelectedSymbol() const
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
@ FRAME_SCH_SYMBOL_EDITOR
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
bool m_EnableLibWithText
Enable option to load lib files with text editor.
static const std::string SVGFileExtension
static wxString PngFileWildcard()
static wxString SVGFileWildcard()
@ REPAINT
Item needs to be redrawn.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
constexpr int IUToMils(int iu) const
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
Definition of file extensions used in Kicad.