48#include <wx/choicdlg.h>
54 SYMBOL_LIB* aCacheLib, wxWindow* aParent,
bool aShowErrorMsg )
56 wxCHECK_MSG( aLibTable,
nullptr, wxS(
"Invalid symbol library table." ) );
64 if( !symbol && aCacheLib )
66 wxCHECK_MSG( aCacheLib->
IsCache(),
nullptr, wxS(
"Invalid cache library." ) );
77 wxString msg = wxString::Format(
_(
"Error loading symbol %s from library '%s'." ),
89 const wxString& aTitle,
const wxPoint& aPosition,
90 const wxSize& aSize,
long aStyle,
const wxString& aFrameName ) :
91 EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle,
93 m_base_frame_defaults( nullptr,
"base_Frame_defaults" ), m_spaceMouse( nullptr )
98 [
this]( wxIdleEvent& aEvent )
107 selTool->
OnIdle( aEvent );
186 line.Printf( wxS(
"X %s Y %s" ),
189 SetStatusText( line, 2 );
191 line.Printf( wxS(
"dx %s dy %s dist %s" ),
195 SetStatusText( line, 3 );
205 SYMBOL_LIB* cache = ( aUseCacheLib ) ?
Prj().SchLibs()->GetCacheLibrary() :
nullptr;
207 return SchGetLibSymbol( aLibId,
Prj().SchSymbolLibTable(), cache,
this, aShowErrorMsg );
225 msg.Printf(
_(
"Error saving global symbol library table:\n%s" ), ioe.
What() );
230 if( aProject && !
Prj().GetProjectName().IsEmpty() )
236 Prj().SchSymbolLibTable()->Save( fn.GetFullPath() );
241 msg.Printf(
_(
"Error saving project-specific symbol library table:\n%s" ),
254 if(
Prj().IsNullProject() )
260 wxMessageDialog dlg(
this,
_(
"Add the library to the global library table?" ),
261 _(
"Add To Global Library Table" ), wxYES_NO );
263 if( dlg.ShowModal() != wxID_OK )
270 wxArrayString libTableNames;
271 libTableNames.Add(
_(
"Global" ) );
272 libTableNames.Add(
_(
"Project" ) );
274 wxSingleChoiceDialog dlg(
this,
_(
"Choose the Library Table to add the library to:" ),
275 _(
"Add To Library Table" ), libTableNames );
279 dlg.FindWindow( wxID_CANCEL )->SetLabel(
_(
"Skip" ) );
280 dlg.FindWindow( wxID_OK )->SetLabel(
_(
"Add" ) );
283 if( dlg.ShowModal() != wxID_OK )
286 switch( dlg.GetSelection() )
289 case 1:
return Prj().SchSymbolLibTable();
290 default:
return nullptr;
357 catch(
const std::system_error& e )
359 wxLogTrace( wxT(
"KI_TRACE_NAVLIB" ), e.what() );
381 if( parent && parent->
IsType( { SCH_SYMBOL_T, SCH_SHEET_T, SCH_LABEL_LOCATE_ANY_T } ) )
389 if( aUpdateRtree &&
dynamic_cast<SCH_ITEM*
>( aItem ) )
440 wxCHECK( aItem !=
nullptr, );
442 auto screen = aScreen;
444 if( aScreen ==
nullptr )
447 screen->Append( (
SCH_ITEM*) aItem );
459 auto screen = aScreen;
461 if( aScreen ==
nullptr )
467 screen->Remove( (
SCH_ITEM*) aItem );
559 if( prj.SchSymbolLibTable()->IsEmpty() )
562 return wxEmptyString;
565 wxArrayString headers;
567 headers.Add(
_(
"Library" ) );
569 std::vector< wxArrayString > itemsToDisplay;
570 std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
572 for(
const wxString&
name : libNicknames )
575 if( !prj.SchSymbolLibTable()->IsSymbolLibWritable(
name ) )
584 itemsToDisplay.push_back( item );
588 for(
const wxString&
name : libNicknames )
591 if( !prj.SchSymbolLibTable()->IsSymbolLibWritable(
name ) )
600 itemsToDisplay.push_back( item );
606 EDA_LIST_DIALOG dlg(
this,
_(
"Select Symbol Library" ), headers, itemsToDisplay, oldLibName,
609 if( dlg.ShowModal() != wxID_OK )
610 return wxEmptyString;
614 if( !libName.empty() )
616 if( prj.SchSymbolLibTable()->HasLibrary( libName ) )
619 libName = wxEmptyString;
632 wxLogTrace(
"KICAD_LIB_WATCH",
"No symbol library specified, disabling watcher" );
637 wxString libfullname;
652 catch(
const std::exception& e )
659 wxLogTrace(
"KICAD_LIB_WATCH",
"Error: %s", error.
What() );
663 wxLogTrace(
"KICAD_LIB_WATCH",
"Setting up watcher for %s", libfullname );
669 wxLog::EnableLogging(
false );
671 wxLog::EnableLogging(
true );
674 m_watcher = std::make_unique<wxFileSystemWatcher>();
689 wxLogTrace(
"KICAD_LIB_WATCH",
"OnSymChange: %s, watcher file: %s",
701 wxLogTrace(
"KICAD_LIB_WATCH",
"Failed to start the debounce timer" );
709 wxLogTrace(
"KICAD_LIB_WATCH",
"OnSymChangeDebounceTimer" );
711 wxLog::EnableLogging(
false );
713 wxLog::EnableLogging(
true );
721 "Do you want to reload the library?" ) ) )
723 wxLogTrace(
"KICAD_LIB_WATCH",
"Sending refresh symbol mail" );
constexpr EDA_IU_SCALE schIUScale
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString m_ColorTheme
Active color theme name.
Handles how to draw a screen (a board, a schematic ...)
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
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
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual bool IsContentModified() const
Get if the contents of the frame have been modified since the last save.
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
The base class for create windows for drawing purpose.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
COLOR_SETTINGS * m_colorSettings
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayUnitsMsg()
Display current unit pane in the status bar.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
virtual void DisplayGridMsg()
Display current grid size in the status bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
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.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
EDA_ITEM * GetParent() const
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
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()
A color representation with 4 components: red, green, blue, alpha.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
double GetWorldScale() const
Get the world scale.
Contains all the knowledge about how to draw graphical object onto any particular output device.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
static std::vector< KICAD_T > g_ScaledSelectionTypes
Store schematic specific render settings.
virtual void CenterOnCursor()=0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
void RecacheAllItems()
Rebuild GAL display lists.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Define a library symbol object.
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...
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static const wxString GetPinningSymbol()
The class that implements the public interface to the SpaceMouse plug-in.
void SetFocus(bool aFocus)
Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed to thi...
void SetCanvas(EDA_DRAW_PANEL_GAL *aViewport)
Sets the viewport controlled by the SpaceMouse.
Describe the page size and margins of a paper page on which to eventually print or plot.
const VECTOR2I GetSizeIU(double aIUScale) const
Gets the page size in internal units.
std::vector< wxString > m_PinnedSymbolLibs
Below are project-level settings that have not been moved to a dedicated file.
Container for project specific data.
virtual PROJECT_FILE & GetProjectFile() const
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...
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void RedrawScreen(const VECTOR2I &aCenterPoint, bool aWarpPointer)
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
void UpdateStatusBar() override
Update the status bar information.
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
void OnSymChange(wxFileSystemWatcherEvent &aEvent)
Handler for Symbol change events.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SYMBOL_EDITOR_SETTINGS * libeditconfig() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void HardRedraw() override
Rebuild the GAL and redraws the screen.
wxTimer m_watcherDebounceTimer
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
void SyncView()
Mark all items for refresh.
wxDateTime m_watcherLastModified
std::unique_ptr< wxFileSystemWatcher > m_watcher
These are file watchers for the symbol library tables.
virtual ~SCH_BASE_FRAME()
const TITLE_BLOCK & GetTitleBlock() const override
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
NL_SCHEMATIC_PLUGIN * m_spaceMouse
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
void RefreshZoomDependentItems()
Mark selected items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
virtual void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
wxFileName m_watcherFileName
void setSymWatcher(const LIB_ID *aSymbol)
Creates (or removes) a watcher on the specified symbol library.
const PAGE_INFO & GetPageSettings() const override
COLOR4D GetDrawBgColor() const override
void OnSymChangeDebounceTimer(wxTimerEvent &aEvent)
Handler for the filesystem watcher debounce timer.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Base class for any item which can be embedded within the SCHEMATIC container class,...
const PAGE_INFO & GetPageSettings() const
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
void SetPageSettings(const PAGE_INFO &aPageSettings)
const TITLE_BLOCK & GetTitleBlock() const
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
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.
bool m_UseEeschemaColorSettings
A collection of SYMBOL_LIB objects.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
static const wxString & GetSymbolLibTableFileName()
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
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...
Object used to load, save, search, and otherwise manipulate symbol library files.
LIB_SYMBOL * FindSymbol(const wxString &aName) const
Find LIB_SYMBOL by aName.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
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_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
@ FRAME_SCH_SYMBOL_EDITOR
bool m_Use3DConnexionDriver
Use the 3DConnexion Driver.
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_SCHEMATIC_GRID_AXES
@ LAYER_SCHEMATIC_BACKGROUND
@ REPAINT
Item needs to be redrawn.
@ ALL
All except INITIAL_ADD.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Declaration of the NL_SCHEMATIC_PLUGIN class.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, SYMBOL_LIB *aCacheLib=nullptr, wxWindow *aParent=nullptr, bool aShowErrorMsg=false)
Load symbol from symbol library table.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< wxString > pinned_symbol_libs
Definition for symbol library class.