KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_base_frame.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 (C) 2015 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SCH_BASE_FRAME_H_
22#define SCH_BASE_FRAME_H_
23
24#include <eda_draw_frame.h>
25#include <frame_type.h>
27#include <sch_draw_panel.h>
28#include <sch_screen.h>
29#include <schematic_settings.h>
30
31#include <stddef.h>
32#include <utility>
33#include <future>
34#include <vector>
35#include <wx/event.h>
36#include <wx/datetime.h>
37#include <wx/gdicmn.h>
38#include <wx/string.h>
39#include <wx/timer.h>
40
41#include <template_fieldnames.h>
42
43
45class PAGE_INFO;
46class TITLE_BLOCK;
49class LIB_SYMBOL;
52class LIB_ID;
57
58#if defined(__linux__) || defined(__FreeBSD__)
59class SPNAV_2D_PLUGIN;
60#else
62#endif
63
65class DIALOG_SCH_FIND;
66struct BACKGROUND_JOB;
67
68#ifdef wxHAS_INOTIFY
69#define wxFileSystemWatcher wxInotifyFileSystemWatcher
70#elif defined( wxHAS_KQUEUE ) && defined( wxHAVE_FSEVENTS_FILE_NOTIFICATIONS )
71#define wxFileSystemWatcher wxFsEventsFileSystemWatcher
72#elif defined( wxHAS_KQUEUE )
73#define wxFileSystemWatcher wxKqueueFileSystemWatcher
74#elif defined( __WINDOWS__ )
75#define wxFileSystemWatcher wxMSWFileSystemWatcher
76#else
77#define wxFileSystemWatcher wxPollingFileSystemWatcher
78#endif
79
81class wxFileSystemWatcherEvent;
82
98 LEGACY_SYMBOL_LIB* aCacheLib = nullptr, wxWindow* aParent = nullptr,
99 bool aShowErrorMsg = false );
100
111{
112public:
113 SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType, const wxString& aTitle,
114 const wxPoint& aPosition, const wxSize& aSize, long aStyle,
115 const wxString & aFrameName );
116
117 virtual ~SCH_BASE_FRAME();
118
119 void createCanvas();
120
121 SCH_DRAW_PANEL* GetCanvas() const override;
122 SCH_SCREEN* GetScreen() const override;
123
125
127
129
130 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
131 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
132
134
135 COLOR4D GetDrawBgColor() const override;
136
140 virtual bool GetShowAllPins() const { return true; }
141
142 void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
143 const PAGE_INFO& GetPageSettings () const override;
144 const VECTOR2I GetPageSizeIU() const override;
145
146 const VECTOR2I& GetGridOrigin() const override
147 {
148 static VECTOR2I zero;
149 return zero;
150 }
151 void SetGridOrigin( const VECTOR2I& aPoint ) override {}
152
153 const TITLE_BLOCK& GetTitleBlock() const override;
154 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
155
156 void UpdateStatusBar() override;
157
177 std::vector<PICKED_SYMBOL>& aHistoryList,
178 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
179 bool aShowFootprints, const LIB_ID* aHighlight = nullptr,
180 bool aAllowFields = true );
181
191 LIB_SYMBOL* GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib = false,
192 bool aShowErrorMsg = false );
193
204 wxString SelectLibrary( const wxString& aDialogTitle, const wxString& aListLabel,
205 const std::vector<std::pair<wxString, bool*>>& aExtraCheckboxes = {} );
206
207 virtual void RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer );
208
209 void HardRedraw() override;
210
215 void AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr ) override;
216
221 void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen ) override;
222
226 virtual void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false,
227 bool aUpdateRtree = false );
228
233
237 void SyncView();
238
242 void ShowFindReplaceDialog( bool aReplace );
243
245
246 void ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime );
248
252 void OnFindDialogClose();
253
254 void CommonSettingsChanged( int aFlags ) override;
255
260
261 COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
262
263 void ActivateGalCanvas() override;
264
268 void OnSymChange( wxFileSystemWatcherEvent& aEvent );
269
273 void OnSymChangeDebounceTimer( wxTimerEvent& aEvent );
274
282 void SetSymModificationTime( long long aTimestamp )
283 {
284 m_watcherTimestamp = aTimestamp;
285 }
286
288
289 void GetLibraryItemsForListDialog( wxArrayString& aHeaders, std::vector<wxArrayString>& aItemsToDisplay );
290
292
293protected:
294 void handleActivateEvent( wxActivateEvent& aEvent ) override;
295
296 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
297
298 void doCloseWindow() override;
299
304 void setSymWatcher( const LIB_ID* aSymbol );
305
311
312protected:
315
318
319private:
320
322 std::unique_ptr<wxFileSystemWatcher> m_watcher;
328
329#if defined(__linux__) || defined(__FreeBSD__)
330 std::unique_ptr<SPNAV_2D_PLUGIN> m_spaceMouse;
331#else
332 std::unique_ptr<NL_SCHEMATIC_PLUGIN> m_spaceMouse;
333#endif
334};
335
336#endif // SCH_BASE_FRAME_H_
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Color settings are a bit different than most of the settings objects in that there can be more than o...
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)
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
Object used to load, save, search, and otherwise manipulate symbol library files.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Define a library symbol object.
Definition lib_symbol.h:79
The class that implements the public interface to the SpaceMouse plug-in.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
This is a bridge class to help the schematic be able to affect SCH_EDIT_FRAME without doing anything ...
These are loaded from Eeschema settings but then overwritten by the project settings.
void SetGridOrigin(const VECTOR2I &aPoint) override
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 SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
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.
PICKED_SYMBOL PickSymbolFromLibrary(const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, std::vector< PICKED_SYMBOL > &aAlreadyPlaced, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
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
DIALOG_SCH_FIND * GetFindReplaceDialog() const
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.
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.
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 void updateSelectionFilterVisbility()
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
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
const VECTOR2I & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
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.
virtual bool GetShowAllPins() const
Allow some frames to show/hide hidden pins.
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.
void SetSymModificationTime(long long aTimestamp)
Set the modification timestamp of the watched symbol library.
long long m_watcherTimestamp
void ClearFindReplaceStatus()
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
The symbol library editor main window.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
Helper object to filter a list of libraries.
Symbol library viewer main window.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition title_block.h:37
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:29
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:447
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.
#define wxFileSystemWatcher
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683