27#include <wx/hyperlink.h>
105 m_unitSelectBox(
nullptr ),
106 m_isSymbolFromSchematic( false )
108 SetShowDeMorgan(
false );
109 m_SyncPinEdit =
false;
112 m_treePane =
nullptr;
116 m_aboutTitle =
_HKI(
"KiCad Symbol Editor" );
119 wxIconBundle icon_bundle;
122 icon_bundle.AddIcon( icon );
124 icon_bundle.AddIcon( icon );
126 icon_bundle.AddIcon( icon );
128 SetIcons( icon_bundle );
131 LoadSettings( m_settings );
134 bool loadingCancelled =
false;
140 m_libMgr->GetLibraryCount(),
true );
141 m_libMgr->Preload( reporter );
147 SyncLibraries(
false, loadingCancelled );
152 SwitchCanvas( m_canvasType );
159 SetScreen( m_dummyScreen );
160 GetScreen()->m_Center =
true;
162 GetCanvas()->GetViewControls()->SetCrossHairCursorPosition(
VECTOR2D( 0, 0 ),
false );
164 GetRenderSettings()->LoadColors( GetColorSettings() );
165 GetRenderSettings()->m_IsSymbolEditor =
true;
174 ReCreateOptToolbar();
177 UpdateSymbolMsgPanelInfo();
178 RebuildSymbolUnitsList();
181 m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter );
183 m_auimgr.SetManagedWindow(
this );
188 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name(
"MainToolbar" )
191 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" )
192 .Bottom().Layer( 6 ) );
195 m_auimgr.AddPane( m_treePane,
EDA_PANE().Palette().Name(
"SymbolTree" )
197 .TopDockable(
false ).BottomDockable(
false )
198 .Caption(
_(
"Libraries" ) )
199 .MinSize( 250, -1 ).BestSize( 250, -1 ) );
203 wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( PropertiesPaneName() );
204 propertiesPaneInfo.Show( m_settings->m_AuiPanels.show_properties );
206 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name(
"OptToolbar" )
207 .Left().Layer( 2 ) );
209 m_auimgr.AddPane( m_drawToolBar,
EDA_PANE().VToolbar().Name(
"ToolsToolbar" )
210 .Right().Layer( 2 ) );
213 m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name(
"DrawFrame" )
216 FinishAUIInitialization();
218 if( m_settings->m_LibWidth > 0 )
219 SetAuiPaneSize( m_auimgr, m_auimgr.GetPane(
"SymbolTree" ), m_settings->m_LibWidth, -1 );
225 GetCanvas()->GetView()->UseDrawPriority(
true );
226 GetCanvas()->GetGAL()->SetAxesEnabled(
true );
228 setupUnits( m_settings );
235 bbox.
SetOrigin( -max_size_x /2, -max_size_y/2 );
236 bbox.
SetSize( max_size_x, max_size_y );
237 GetCanvas()->GetView()->SetBoundary( bbox );
242 DragAcceptFiles(
true );
254 if( loadingCancelled )
255 ShowInfoBarWarning(
_(
"Symbol library loading was cancelled by user." ) );
286 catch(
const std::runtime_error& e )
288 wxFAIL_MSG( e.what() );
293 Pgm().GetSettingsManager().Save( cfg );
302 wxCHECK_RET(
m_settings,
"Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );
313 wxCHECK_RET(
m_settings,
"Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" );
388#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
389#define CHECK( x ) ACTION_CONDITIONS().Check( x )
391 auto haveSymbolCond =
397 auto isEditableCond =
405 auto symbolModifiedCondition =
412 auto libSelectedCondition =
418 auto canEditProperties =
424 auto saveSymbolAsCondition =
470 auto showCompTreeCond =
476 auto propertiesCond =
493 auto demorganStandardCond =
499 auto demorganAlternateCond =
505 auto multiUnitModeCond =
511 auto hasMultipleUnitsCond =
517 auto syncedPinsModeCond =
523 auto haveDatasheetCond =
544#define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) )
569 wxString msg =
_(
"Save changes to '%s' before closing?" );
602 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
699 int i =
event.GetSelection();
701 if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) ==
m_unit ) )
733 if( !libNickname.empty() )
738 libNickname = wxEmptyString;
803 msg.Printf(
_(
"Editing symbol %s from schematic. Saving will update the schematic "
811 wxHyperlinkCtrl* button =
new wxHyperlinkCtrl( infobar, wxID_ANY,
812 _(
"Manage symbol libraries" ),
815 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<
void( wxHyperlinkEvent& aEvent )>(
816 [=]( wxHyperlinkEvent& aEvent )
823 infobar->
ShowMessage(
_(
"Symbols in legacy libraries are not editable. Use Manage "
824 "Symbol Libraries to migrate to current format." ),
825 wxICON_INFORMATION );
829 wxString rootSymbolName;
833 rootSymbolName = rootSymbol->GetName();
844 msg.Printf(
_(
"Symbol %s is a derived symbol. Symbol graphics will not be editable." ),
849 wxHyperlinkCtrl* button =
new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString );
850 button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<
void( wxHyperlinkEvent& aEvent )>(
851 [=]( wxHyperlinkEvent& aEvent )
886 if( !GetTitle().StartsWith(
"*" ) )
903 return wxEmptyString;
912 return wxEmptyString;
915 wxString libName = fn.GetName();
917 if( libName.IsEmpty() )
918 return wxEmptyString;
922 DisplayError(
this, wxString::Format(
_(
"Library '%s' already exists." ), libName ) );
923 return wxEmptyString;
930 DisplayError(
this, wxString::Format(
_(
"Could not create the library file '%s'.\n"
931 "Make sure you have write permissions and "
933 fn.GetFullPath() ) );
934 return wxEmptyString;
941 DisplayError(
this,
_(
"Could not open the library file." ) );
942 return wxEmptyString;
949 std::string packet = fn.GetFullPath().ToStdString();
952 return fn.GetFullPath();
964 wxFileName fn = wxFileName( aLibFile );
966 wxString libName = fn.GetName();
968 if( libName.IsEmpty() )
973 DisplayError(
this, wxString::Format(
_(
"Library '%s' already exists." ), libName ) );
979 DisplayError(
this,
_(
"Could not open the library file." ) );
986 std::string packet = fn.GetFullPath().ToStdString();
1038 std::vector<LIB_ID> ids;
1057 const wxString& aForceRefresh )
1070 [&](
int progress,
int max,
const wxString& libName )
1072 progressDlg.
Update( progress, wxString::Format(
_(
"Loading library '%s'..." ),
1076 else if( !aPreloadCancelled )
1079 [&](
int progress,
int max,
const wxString& libName )
1086 wxDataViewItem found;
1101 if( !found && selected.
IsValid() )
1145 if( aTreeItem.IsOk() )
1156 if( aOriginalFile.FileExists() )
1158 wxFileName backupFileName( aOriginalFile );
1159 backupFileName.SetExt( aBackupExt );
1161 if( backupFileName.FileExists() )
1162 wxRemoveFile( backupFileName.GetFullPath() );
1164 if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
1166 DisplayError(
this, wxString::Format(
_(
"Failed to save backup to '%s'." ),
1167 backupFileName.GetFullPath() ) );
1227 if( aEnvVarsChanged )
1246 bool tree_shown = tree_pane_info.IsShown();
1247 tree_pane_info.Caption(
_(
"Libraries" ) );
1248 tree_pane_info.Show( tree_shown );
1307 item.ClearSelected();
1347 if(
pin->m_Uuid == lastBrightenedItemID )
1351 std::vector<LIB_FIELD*> fields;
1357 if( field->m_Uuid == lastBrightenedItemID )
1362 if( lastItem && lastItem != aItem )
1367 lastBrightenedItemID =
niluuid;
1377 lastBrightenedItemID = aItem->
m_Uuid;
1387 const std::string& payload = mail.
GetPayload();
1392 if( !payload.empty() )
1394 wxString libFileName( payload );
1395 wxString libNickname;
1403 msg.Printf(
_(
"The current configuration does not include the library '%s'.\n"
1404 "Use Manage Symbol Libraries to edit the configuration." ),
1412 if( !libTable->
HasLibrary( libNickname,
true ) )
1414 msg.Printf(
_(
"The library '%s' is not enabled in the current configuration.\n"
1415 "Use Manage Symbol Libraries to edit the configuration." ),
1425 LIB_ID id( libNickname, wxEmptyString );
1442 if( !currentLib.empty() && libTable && !libTable->
HasLibrary( currentLib,
true ) )
1460 wxLogTrace(
"KICAD_LIB_WATCH",
"Received refresh symbol request for %s",
1463 if( !tbl || !symbol )
1472 wxFileName libfullname( row->
GetFullURI(
true ) );
1475 wxLogTrace(
"KICAD_LIB_WATCH",
1476 "Received refresh symbol request for %s, current symbols is %s",
1477 changedLib.GetFullPath(), libfullname.GetFullPath() );
1479 if( changedLib == libfullname )
1481 wxLogTrace(
"KICAD_LIB_WATCH",
"Refreshing symbol %s", symbol->
GetName() );
1486 wxCHECK2_MSG( lib_symbol,
break, wxString::Format(
"Symbol %s not found in library %s",
1487 symbol->
GetName(), libName ) );
1550 if( aItemCount == 0 )
1576 std::unique_ptr<LIB_SYMBOL> symbol = aSymbol->
GetLibSymbolRef()->Flatten();
1584 std::vector<LIB_FIELD> fullSetOfFields;
1586 for(
int i = 0; i < (int) aSymbol->
GetFields().size(); ++i )
1606 switch( orientation )
1611 std::swap( pos.
x, pos.
y );
1615 std::swap( pos.
x, pos.
y );
1626 fullSetOfFields.emplace_back( std::move( libField ) );
1629 symbol->SetFields( fullSetOfFields );
1644 tools->SetDrawSpecificUnit( symbol->UnitsLocked() );
1678 wxFileName fn = aLibFile;
1679 wxFileName libTableFileName(
Prj().GetProjectPath(),
1681 wxString libNickname = fn.GetName();
1692 tmp.Printf(
"%s%d", fn.GetName(), suffix );
1701 wxString normalizedPath =
NormalizePath( aLibFile, &envVars,
Prj().GetProjectPath() );
1709 normalizedPath =
NormalizePath( aLibFile, &envVars, wxEmptyString );
1714 wxCHECK( libTable->
InsertRow( row ),
false );
1718 libTable->
Save( libTableFileName.GetFullPath() );
1722 wxString msg = aScope ==
GLOBAL_LIB_TABLE ?
_(
"Error saving global library table." )
1723 :
_(
"Error saving project library table." );
1725 wxMessageDialog dlg(
this, msg,
_(
"File Save Error" ), wxOK | wxICON_ERROR );
1726 dlg.SetExtendedMessage( ioe.
What() );
1737 const wxString& aLibFile )
1741 bool isGlobalTable =
true;
1749 libTableFileName.SetPath(
Prj().GetProjectPath() );
1752 isGlobalTable =
false;
1753 row = libTable->
FindRow( aLibNickname );
1756 wxCHECK( row,
false );
1758 wxString projectPath;
1760 if( !isGlobalTable )
1763 wxString normalizedPath =
NormalizePath( aLibFile, &envVars, projectPath );
1770 libTable->
Save( libTableFileName.GetFullPath() );
1774 wxString msg = isGlobalTable ?
_(
"Error saving global library table." )
1775 :
_(
"Error saving project library table." );
1777 wxMessageDialog dlg(
this, msg,
_(
"File Save Error" ), wxOK | wxICON_ERROR );
1778 dlg.SetExtendedMessage( ioe.
What() );
1806 eda_text->ClearBoundingBoxCache();
1807 eda_text->ClearRenderCache();
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE schIUScale
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
static TOOL_ACTION toggleGrid
static TOOL_ACTION cancelInteractive
static TOOL_ACTION millimetersUnits
static TOOL_ACTION unselectAll
static TOOL_ACTION revert
static TOOL_ACTION milsUnits
static TOOL_ACTION toggleBoundingBoxes
static TOOL_ACTION saveAll
static TOOL_ACTION duplicate
static TOOL_ACTION inchesUnits
static TOOL_ACTION toggleCursorStyle
static TOOL_ACTION doDelete
static TOOL_ACTION selectionTool
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION deleteTool
static TOOL_ACTION zoomTool
static TOOL_ACTION showProperties
static TOOL_ACTION ddAddLibrary
static TOOL_ACTION toggleGridOverrides
static TOOL_ACTION selectAll
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
wxProgressDialog with the option to also update the application progress on the taskbar
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=nullptr) override
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
wxString m_ColorTheme
Active color theme name.
Handles how to draw a screen (a board, a schematic ...)
void SetContentModified(bool aModified=true)
void SetOrigin(const Vec &pos)
void SetSize(const Vec &size)
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
Handle actions that are shared between different applications.
UNDO_REDO_CONTAINER m_undoList
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
SETTINGS_MANAGER * GetSettingsManager() const
UNDO_REDO_LIST
Specifies whether we are interacting with the undo or redo stacks.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
UNDO_REDO_CONTAINER m_redoList
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
void ReCreateMenuBar()
Recreates the menu bar.
WX_INFOBAR * GetInfoBar()
COLOR_SETTINGS * m_colorSettings
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
static const wxString PropertiesPaneName()
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void SetScreen(BASE_SCREEN *aScreen)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
PROPERTIES_PANEL * m_propertiesPanel
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual const VECTOR2I GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
bool IsBrightened() const
Specialization of the wxAuiPaneInfo class for KiCad panels.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
virtual void SetText(const wxString &aText)
Class that groups generic conditions for editor states.
SELECTION_CONDITION BoundingBoxes()
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
virtual SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION GridOverrides()
Create a functor testing if the grid overrides wires is enabled in a frame.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
Gather all the actions that are shared by tools.
static TOOL_ACTION mirrorV
static TOOL_ACTION runERC
static TOOL_ACTION pinTable
static TOOL_ACTION clearSelection
Clears the current selection.
static TOOL_ACTION placeSymbolAnchor
static TOOL_ACTION drawSymbolPolygon
static TOOL_ACTION showDeMorganAlternate
static TOOL_ACTION newSymbol
static TOOL_ACTION drawCircle
static TOOL_ACTION showDeMorganStandard
static TOOL_ACTION rotateCCW
static TOOL_ACTION saveLibraryAs
static TOOL_ACTION symbolImportGraphics
static TOOL_ACTION placeSymbolText
static TOOL_ACTION mirrorH
static TOOL_ACTION rotateCW
static TOOL_ACTION importSymbol
static TOOL_ACTION showDatasheet
Inspection and Editing.
static TOOL_ACTION saveSymbolCopyAs
static TOOL_ACTION symbolProperties
static TOOL_ACTION drawRectangle
static TOOL_ACTION setUnitDisplayName
static TOOL_ACTION drawSymbolTextBox
static TOOL_ACTION drawSymbolLines
static TOOL_ACTION drawArc
static TOOL_ACTION toggleSyncedPinsMode
static TOOL_ACTION showSymbolTree
static TOOL_ACTION placeSymbolPin
static TOOL_ACTION showElectricalTypes
Tool that displays edit points allowing to modify items by dragging the points.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
bool m_axesEnabled
Fullscreen crosshair or small cross.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
void SetDefaultFont(const wxString &aFont)
bool m_ShowPinsElectricalType
bool m_ShowGraphicsDisabled
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
void Clear()
Remove all items from the view.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Field object used in symbol libraries.
void SetName(const wxString &aName)
Set a user definable field name to aName.
A logical library item identifier and consists of various portions much like a URI.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
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.
The base class for drawable items used by schematic library symbols.
void SetPosition(const VECTOR2I &aPosition) override
Symbol library management helper that is specific to the symbol library editor frame.
void Sync(const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
Updates the SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Define a library symbol object.
bool UnitsLocked() const
Check whether symbol units are interchangeable.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
LIB_ID GetLibId() const override
wxString GetName() const override
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this symbol.
wxString GetLibNickname() const override
Sets the Description field text value.
std::vector< LIB_PIN * > GetAllLibPins() const
Return a list of pin pointers for all units / converts.
int GetUnitCount() const override
For items with units, return the number of units.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
LIB_SYMBOL_SPTR GetRootSymbol() const
Get the parent symbol that does not have another parent.
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
const wxString & GetNickName() const
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...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
const LIB_TABLE_ROW * FindRowByURI(const wxString &aURI)
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
LIB_TREE_NODE * GetCurrentTreeNode() const
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
int GetSelectionCount() const
void ShowChangedLanguage()
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
int GetSelectedLibIds(std::vector< LIB_ID > &aSelection, std::vector< int > *aUnit=nullptr) const
Retrieves a list of selections for trees that allow multi-selection.
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
void ExpandLibId(const LIB_ID &aLibId)
Expand and item i the tree widget.
void Regenerate(bool aKeepState)
Regenerate the tree.
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
A holder to handle information on schematic or board items.
void ClearListAndDeleteItems(std::function< void(EDA_ITEM *)> aItemDeleter)
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
bool IsCancelled() const override
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual void SetRString(RSTRING_T aStringId, const wxString &aString)
Store a "retained string", which is any session and project specific string identified in enum RSTRIN...
virtual const wxString & GetRString(RSTRING_T aStringId)
Return a "retained string", which is any session and project specific string identified in enum RSTRI...
float SplitterProportion() const
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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.
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
void setSymWatcher(const LIB_ID *aSymbol)
Creates (or removes) a watcher on the specified symbol library.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void DisplaySymbol(LIB_SYMBOL *aSymbol)
Schematic editor (Eeschema) main window.
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol, const KIID &aSchematicSymbolUUID)
Update a schematic symbol from a LIB_SYMBOL.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
VECTOR2I GetPosition() const override
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
VECTOR2I GetPosition() const override
int GetOrientation() const
Get the display symbol orientation.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
Handle actions for the various symbol editor and viewers.
bool m_ShowPinElectricalType
The symbol library editor main window.
bool m_isSymbolFromSchematic
void OnExitKiCad(wxCommandEvent &event)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
int m_convert
Flag if the symbol being edited was loaded directly from a schematic.
void FocusOnItem(LIB_ITEM *aItem)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
APP_SETTINGS_BASE * config() const override
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
bool addLibTableEntry(const wxString &aLibFile, TABLE_SCOPE aScope=GLOBAL_LIB_TABLE)
Add aLibFile to the symbol library table defined by aScope.
void storeCurrentSymbol()
Rename LIB_SYMBOL aliases to avoid conflicts before adding a symbol to a library.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
wxString getTargetLib() const
bool IsCurrentSymbol(const LIB_ID &aLibId) const
Restore the empty editor screen, without any symbol or library selected.
bool backupFile(const wxFileName &aOriginalFile, const wxString &aBackupExt)
Return currently edited symbol.
void RefreshLibraryTree()
Redisplay the library tree.
wxComboBox * m_unitSelectBox
int GetTreeLIBIDs(std::vector< LIB_ID > &aSelection) const
LIB_ID GetTreeLIBID(int *aUnit=nullptr) const
Return the LIB_ID of the library or symbol selected in the symbol tree.
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
wxString GetCurLib() const
The nickname of the current library being edited and empty string if none.
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)
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
SYMBOL_EDITOR_SETTINGS * m_settings
bool LoadSymbolFromCurrentLib(const wxString &aAliasName, int aUnit=0, int aConvert=0)
Load a symbol from the current active library, optionally setting the selected unit and convert.
void HardRedraw() override
Rebuild the GAL and redraw the screen.
bool GetShowDeMorgan() const
bool IsSymbolTreeShown() const
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 SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
bool CanCloseSymbolFromSchematic(bool doClose)
void RebuildSymbolUnitsList()
bool IsSymbolFromLegacyLibrary() const
bool replaceLibTableEntry(const wxString &aLibNickname, const wxString &aLibFile)
Replace the file path of the symbol library table entry aLibNickname with aLibFile.
bool IsSymbolFromSchematic() const
void OnToggleSymbolTree(wxCommandEvent &event)
static bool m_showDeMorgan
void SetScreen(BASE_SCREEN *aScreen) override
SYMBOL_EDITOR_SETTINGS * GetSettings() const
SCH_SCREEN * m_dummyScreen
< Helper screen used when no symbol is loaded
void KiwayMailIn(KIWAY_EXPRESS &mail) override
Receive KIWAY_EXPRESS messages from other players.
void SetCurSymbol(LIB_SYMBOL *aSymbol, bool aUpdateZoom)
Take ownership of aSymbol and notes that it is the one currently being edited.
KIID m_schematicSymbolUUID
RefDes of the symbol (only valid if symbol was loaded from schematic)
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
std::vector< LIB_ID > GetSelectedLibIds() const
LIB_TREE_NODE * GetCurrentTreeNode() const
void SyncLibraries(bool aShowProgress, bool aPreloadCancelled=false, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
void OnSelectUnit(wxCommandEvent &event)
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void UpdateSymbolMsgPanelInfo()
Display the documentation of the selected symbol.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
bool saveAllLibraries(bool aRequireConfirmation)
Save the current symbol.
void UpdateMsgPanel() override
Redraw the message panel.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
wxString SetCurLib(const wxString &aLibNickname)
Set the current library nickname and returns the old library nickname.
void UpdateTitle()
Update the main window title bar with the current library name and read only status of the library.
void ReCreateHToolbar() override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
bool HasLibModifications() const
Check if any pending libraries have been modified.
SYMBOL_TREE_PANE * m_treePane
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType) override
Switch currently used canvas ( Cairo / OpenGL).
void doCloseWindow() override
void DdAddLibrary(wxString aLibFile)
Add a library dropped file to the symbol library table.
wxString AddLibraryFile(bool aCreateNew)
Create or add an existing library to the symbol library table.
~SYMBOL_EDIT_FRAME() override
void CloseWindow(wxCommandEvent &event)
Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:
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 SetShowDeMorgan(bool show)
void ShowChangedLanguage() override
bool IsContentModified() const override
Get if any symbols or libraries have been modified but not saved.
LIB_SYMBOL * getTargetSymbol() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
void OnUpdateUnitNumber(wxUpdateUIEvent &event)
LIB_SYMBOL * GetBufferedSymbol(const wxString &aAlias, const wxString &aLibrary)
Return the symbol copy from the buffer.
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.
LIB_SYMBOL * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
SCH_SCREEN * GetScreen(const wxString &aAlias, const wxString &aLibrary)
Return the screen used to edit a specific symbol.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
wxArrayString GetLibraryNames() const
Return the array of library names.
wxString GetUniqueLibraryName() const
Return a library name that is not currently in use.
bool HasModifications() const
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Create an empty library and adds it to the library table.
bool IsSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
bool UpdateLibraryBuffer(const wxString &aLibrary)
Update the library buffer with a new version of the library.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
void SetType(const wxString &aType) override
Change the schematic plugin type represented by this row.
const wxString GetType() const override
Return the type of symbol library table represented by this row.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static const wxString & GetSymbolLibTableFileName()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
Library Editor pane with symbol tree and symbol library table selector.
LIB_TREE * GetLibTree() const
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
A modified version of the wxInfoBar class that allows us to:
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
This file is part of the common library.
static bool empty(const wxTextEntryBase *aCtrl)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define LIB_EDIT_FRAME_NAME
@ ID_LIBEDIT_SELECT_UNIT_NUMBER
const wxAuiPaneInfo & defaultPropertiesPaneInfo()
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
@ FRAME_SCH_SYMBOL_EDITOR
const std::string KiCadSymbolLibFileExtension
wxString KiCadSymbolLibFileWildcard()
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
@ LAYER_SCHEMATIC_GRID_AXES
@ ALL
All except INITIAL_ADD.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString UnescapeString(const wxString &aSource)
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)
ACTION_CONDITIONS & Check(const SELECTION_CONDITION &aCondition)
constexpr int mmToIU(double mm) const
float properties_splitter
Definition for symbol library class.
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.
void SetAuiPaneSize(wxAuiManager &aManager, wxAuiPaneInfo &aPane, int aWidth, int aHeight)
Sets the size of an AUI pane, working around http://trac.wxwidgets.org/ticket/13180.