67#include <wx/choicdlg.h>
68#include <wx/evtloop.h>
69#include <wx/fswatcher.h>
74#if defined(__linux__) || defined(__FreeBSD__)
78#include <wx/fdrepdlg.h>
83 wxWindow* aParent,
bool aShowErrorMsg )
85 wxCHECK_MSG( aLibMgr,
nullptr, wxS(
"Invalid symbol library manager adapter." ) );
93 if( !symbol && aCacheLib )
95 wxCHECK_MSG( aCacheLib->
IsCache(),
nullptr, wxS(
"Invalid cache library." ) );
106 wxString msg = wxString::Format(
_(
"Error loading symbol %s from library '%s'." ),
118 const wxPoint& aPosition,
const wxSize& aSize,
long aStyle,
119 const wxString& aFrameName ) :
130 if( ( aStyle & wxFRAME_NO_TASKBAR ) == 0 )
134 [
this]( wxIdleEvent& aEvent )
143 selTool->
OnIdle( aEvent );
162 GetCanvas()->SetEvtHandlerEnabled(
false );
264 line.Printf( wxS(
"X %s Y %s" ),
267 SetStatusText( line, 2 );
269 line.Printf( wxS(
"dx %s dy %s dist %s" ),
273 SetStatusText( line, 3 );
346#if defined(__linux__) || defined(__FreeBSD__)
356 catch(
const std::exception& e )
358 wxLogTrace( wxT(
"KI_TRACE_NAVLIB" ), wxS(
"%s" ), e.what() );
362 wxLogTrace( wxT(
"KI_TRACE_NAVLIB" ), wxT(
"Unknown exception during SpaceMouse initialization" ) );
380 static_cast<SCH_SHAPE*
>( aItem )->UpdateHatching();
399 if( aUpdateRtree &&
dynamic_cast<SCH_ITEM*
>( aItem ) )
409 group->RunOnChildren(
448 if( item->RenderAsBitmap( view->
GetGAL()->
GetWorldScale() ) != item->IsShownAsBitmap() || scaled )
472 if( aScreen ==
nullptr )
488 auto screen = aScreen;
490 if( aScreen ==
nullptr )
497 screen->Remove( (
SCH_ITEM*) aItem );
532 switch( front->
Type() )
555 if( findString.Contains( wxT(
"\n" ) ) )
556 findString = findString.Before(
'\n' );
569 wxDefaultPosition, wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
583 m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
625 wxString colorTheme = cfg ? cfg->
m_ColorTheme : wxString(
"" );
631 if( !sym_edit_cfg->m_UseEeschemaColorSettings )
632 colorTheme = sym_edit_cfg->m_ColorTheme;
668 std::vector<wxArrayString>& aItemsToDisplay )
670 aHeaders.Add(
_(
"Library" ) );
671 aHeaders.Add(
_(
"Description" ) );
677 std::vector<wxArrayString> unpinned;
679 for(
const wxString& nickname : libNicknames )
688 item.Add( description );
689 aItemsToDisplay.push_back( item );
693 item.Add( nickname );
694 item.Add( description );
695 unpinned.push_back( item );
699 std::sort( aItemsToDisplay.begin(), aItemsToDisplay.end(),
700 [](
const wxArrayString& a,
const wxArrayString& b )
702 return StrNumCmp( a[0], b[0], true ) < 0;
705 std::sort( unpinned.begin(), unpinned.end(),
706 [](
const wxArrayString& a,
const wxArrayString& b )
708 return StrNumCmp( a[0], b[0], true ) < 0;
711 std::ranges::copy( unpinned, std::back_inserter( aItemsToDisplay ) );
716 const std::vector<std::pair<wxString, bool*>>& aExtraCheckboxes )
723 wxArrayString headers;
724 std::vector<wxArrayString> itemsToDisplay;
730 EDA_LIST_DIALOG dlg(
this, aDialogTitle, headers, itemsToDisplay, libraryName,
false );
733 for(
const auto& [label, val] : aExtraCheckboxes )
738 dlg.
m_ButtonsSizer->Prepend( newLibraryButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
740 newLibraryButton->Bind( wxEVT_BUTTON,
741 [&dlg]( wxCommandEvent& )
747 dlg.GetSizer()->Fit( &dlg );
754 return wxEmptyString;
766 bool useGlobalTable =
false;
775 libraryName = fn.GetName();
782 if( adapter->
HasLibrary( libraryName,
false ) )
784 DisplayError(
this, wxString::Format(
_(
"Library '%s' already exists." ), libraryName ) );
789 DisplayError(
this, wxString::Format(
_(
"Could not add library '%s'." ), libraryName ) );
833 wxLogTrace(
traceLibWatch,
"Setting up watcher for %s", tmp );
835 if( wxFileName::DirExists( tmp ) )
856 if( !wxEventLoopBase::GetActive() )
866 wxLogTrace(
traceLibWatch,
"Network path, not watching: %s", fn.GetPath() );
871 m_watcher = std::make_unique<wxFileSystemWatcher>();
884 wxLogTrace(
traceLibWatch,
"OnSymChange: %s, watcher file: %s",
893 wxString eventPath = aEvent.GetPath().GetFullPath();
896 if( !eventPath.StartsWith( dirPath ) )
908 wxLogTrace(
traceLibWatch,
"Failed to start the debounce timer" );
931 if( !IsEnabled() ||
Kiway().HasBlockingDialog() )
933 wxLogTrace(
traceLibWatch,
"Dialog open; restarting debounce timer" );
944 wxLogTrace(
traceLibWatch,
"Interactive tool active; restarting debounce timer" );
951 long long currentTimestamp = 0;
963 if( !lastModified.IsValid() )
966 currentTimestamp = lastModified.GetValue().GetValue();
977 ||
IsOK(
this,
_(
"The library containing the current symbol has changed.\n"
978 "Do you want to reload the library?" ) ) )
1007 wxPostEvent(
this, evt );
ARC_DRAW_MODE
Construction sequence used when interactively drawing a circular arc.
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
static TOOL_ACTION updateFind
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
wxString m_ColorTheme
Active color theme name.
void UnregisterStatusBar(KISTATUSBAR *aStatusBar)
Removes status bar from handling.
void RegisterStatusBar(KISTATUSBAR *aStatusBar)
Add a status bar for handling.
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
FRAME_T GetFrameType() const
virtual APP_SETTINGS_BASE * config() const
Return 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.
bool IsType(FRAME_T aType) const
wxArrayString m_replaceStringHistoryList
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
COLOR_SETTINGS * m_colorSettings
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
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.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
EDA_DRAW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
bool LibraryFileBrowser(const wxString &aTitle, bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory, FILEDLG_HOOK_NEW_LIBRARY *aFileDlgHook=nullptr)
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.
virtual void DisplayGridMsg()
Display current grid size in the status bar.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Return the canvas type stored in the application settings.
wxArrayString m_findStringHistoryList
std::unique_ptr< EDA_SEARCH_DATA > m_findReplaceData
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the KIGFX::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.
EDA_ITEM * GetParent() const
wxBoxSizer * m_ButtonsSizer
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
void AddExtraCheckbox(const wxString &aLabel, bool *aValuePtr)
Add a checkbox value to the dialog.
void GetExtraCheckboxValues()
Fills in the value pointers from the checkboxes after the dialog has run.
bool GetUseGlobalTable() const
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.
virtual bool SupportsStrokePixelPad() const
Tell whether strokes can carry part of their width in pixels, see SetStrokePixelPad().
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
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
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.
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_ITEM objects.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
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, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
LEGACY_SYMBOL_LIB * GetCacheLibrary()
Object used to load, save, search, and otherwise manipulate symbol library files.
LIB_SYMBOL * FindSymbol(const wxString &aName) const
Find LIB_SYMBOL by aName.
std::optional< wxString > GetLibraryDescription(const wxString &aNickname) const
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library tables.
std::vector< wxString > GetLibraryNames() const
Returns a list of library nicknames that are available (skips any that failed to load)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
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.
static const wxString GetPinningSymbol()
Describe the page size and margins of a paper page on which to eventually print or plot.
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
The backing store for a PROJECT, in JSON format.
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
static LEGACY_SYMBOL_LIBS * LegacySchLibs(PROJECT *aProject)
Returns the list of symbol libraries from a legacy (pre-5.x) design This is only used from the remapp...
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...
static const TOOL_ACTION & DrawArcForMode(ARC_DRAW_MODE aMode)
Tool action that starts the arc tool in the given mode.
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 RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen) override
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
SCH_RENDER_SETTINGS * GetRenderSettings()
void doCloseWindow() override
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 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.
APP_SETTINGS_BASE * GetViewerSettingsBase() const
void HighlightSelectionFilter(const SCH_SELECTION_FILTER_OPTIONS &aOptions)
void HardRedraw() override
Rebuild the GAL and redraws the screen.
DIALOG_SCH_FIND * m_findReplaceDialog
SCHEMATIC_SETTINGS m_base_frame_defaults
Only used by symbol_editor. Eeschema should be using the one inside the SCHEMATIC.
wxTimer m_watcherDebounceTimer
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
const TOOL_ACTION * drawArcAction(ARC_DRAW_MODE aMode) const override
The action that starts the arc tool in aMode, or nullptr in a frame without an arc tool.
SCH_SELECTION_TOOL * GetSelectionTool() override
void SyncView()
Mark all items for refresh.
std::unique_ptr< NL_SCHEMATIC_PLUGIN > m_spaceMouse
void GetLibraryItemsForListDialog(wxArrayString &aHeaders, std::vector< wxArrayString > &aItemsToDisplay)
std::unique_ptr< wxFileSystemWatcher > m_watcher
These are file watchers for the symbol library tables.
bool m_inSymChangeTimerEvent
wxString SelectLibrary(const wxString &aDialogTitle, const wxString &aListLabel, const std::vector< std::pair< wxString, bool * > > &aExtraCheckboxes={})
Display a list of loaded libraries and allows the user to select a library.
virtual ~SCH_BASE_FRAME()
Needs to be in the cpp file to encode the sizeof() for std::unique_ptr.
const TITLE_BLOCK & GetTitleBlock() const override
void RefreshZoomDependentItems()
Mark selected items for refresh.
EESCHEMA_SETTINGS * eeconfig() const
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
PANEL_SCH_SELECTION_FILTER * m_selectionFilterPanel
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
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.
void OnFindDialogClose()
Notification that the Find dialog has closed.
wxFileName m_watcherFileName
void setSymWatcher(const LIB_ID *aSymbol)
Creates (or removes) a watcher on the specified symbol library.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr) override
Add an item to the screen (and view) aScreen is the screen the item is located on,...
const PAGE_INFO & GetPageSettings() const override
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
COLOR4D GetDrawBgColor() const override
void OnSymChangeDebounceTimer(wxTimerEvent &aEvent)
Handler for the filesystem watcher debounce timer.
long long m_watcherTimestamp
void ClearFindReplaceStatus()
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 KIGFX::VIEW instance used in the panel.
virtual const wxString & GetText() const override
Return the string associated with the text object.
A set of SCH_ITEMs (i.e., without duplicates).
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 Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
void SetPageSettings(const PAGE_INFO &aPageSettings)
TITLE_BLOCK & GetTitleBlock()
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Refresh a changed item in the tree and invalidate connectivity.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
int Size() const
Returns the number of selected parts.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
Class to handle modifications to the symbol libraries.
bool CreateLibrary(const wxString &aFilePath, LIBRARY_TABLE_SCOPE aScope)
Create an empty library and adds it to the library table.
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) const
A lower-precision version of StringFromValue().
const char * c_str() const
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject, bool aAllowEscapes)
Replace any environment variable & text variable references with their values.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box 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
static const std::string KiCadSymbolLibFileExtension
static wxString KiCadSymbolLibFileWildcard()
const wxChar *const traceLibWatch
Flag to enable debug output for library file watch refreshes.
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_SCHEMATIC_GRID_AXES
@ LAYER_SCHEMATIC_BACKGROUND
Definition for symbol library class.
@ 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.
PGM_BASE & Pgm()
The global program "get" accessor.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIBRARY_ADAPTER *aLibMgr, LEGACY_SYMBOL_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
LIB_SYMBOL * SchGetLibSymbol(const LIB_ID &aLibId, SYMBOL_LIBRARY_ADAPTER *aLibMgr, LEGACY_SYMBOL_LIB *aCacheLib=nullptr, wxWindow *aParent=nullptr, bool aShowErrorMsg=false)
Load symbol from symbol library table.
Class to handle a set of SCH_ITEMs.
T * GetAppSettings(const char *aFilename)
KIWAY Kiway(KFCTL_STANDALONE)
wxString UnescapeString(const wxString &aSource)
std::vector< wxString > pinned_symbol_libs
@ VALUE
Field Value of part, i.e. "3.3K".
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.