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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SCH_BASE_FRAME_H_
26#define SCH_BASE_FRAME_H_
27
28#include <eda_draw_frame.h>
29#include <frame_type.h>
30#include <sch_draw_panel.h>
31#include <sch_screen.h>
32#include <schematic_settings.h>
33
34#include <stddef.h>
35#include <utility>
36#include <vector>
37#include <wx/event.h>
38#include <wx/datetime.h>
39#include <wx/gdicmn.h>
40#include <wx/string.h>
41#include <wx/timer.h>
42
43#include <template_fieldnames.h>
44
45
47class PAGE_INFO;
48class TITLE_BLOCK;
51class LIB_SYMBOL;
52class SYMBOL_LIB;
54class LIB_ID;
60class DIALOG_SCH_FIND;
61
62#ifdef wxHAS_INOTIFY
63#define wxFileSystemWatcher wxInotifyFileSystemWatcher
64#elif defined( wxHAS_KQUEUE ) && defined( wxHAVE_FSEVENTS_FILE_NOTIFICATIONS )
65#define wxFileSystemWatcher wxFsEventsFileSystemWatcher
66#elif defined( wxHAS_KQUEUE )
67#define wxFileSystemWatcher wxKqueueFileSystemWatcher
68#elif defined( __WINDOWS__ )
69#define wxFileSystemWatcher wxMSWFileSystemWatcher
70#else
71#define wxFileSystemWatcher wxPollingFileSystemWatcher
72#endif
73
75class wxFileSystemWatcherEvent;
76
91LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
92 SYMBOL_LIB* aCacheLib = nullptr, wxWindow* aParent = nullptr,
93 bool aShowErrorMsg = false );
94
105{
106public:
107 SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType, const wxString& aTitle,
108 const wxPoint& aPosition, const wxSize& aSize, long aStyle,
109 const wxString & aFrameName );
110
111 virtual ~SCH_BASE_FRAME();
112
113 void createCanvas();
114
115 SCH_DRAW_PANEL* GetCanvas() const override;
116 SCH_SCREEN* GetScreen() const override;
117
119
121
123
124 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
125 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
126
128
129 COLOR4D GetDrawBgColor() const override;
130
134 virtual bool GetShowAllPins() const { return true; }
135
136 void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
137 const PAGE_INFO& GetPageSettings () const override;
138 const VECTOR2I GetPageSizeIU() const override;
139
140 const VECTOR2I& GetGridOrigin() const override
141 {
142 static VECTOR2I zero;
143 return zero;
144 }
145 void SetGridOrigin( const VECTOR2I& aPoint ) override {}
146
147 const TITLE_BLOCK& GetTitleBlock() const override;
148 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
149
150 void UpdateStatusBar() override;
151
152
172 std::vector<PICKED_SYMBOL>& aHistoryList,
173 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
174 bool aShowFootprints, const LIB_ID* aHighlight = nullptr,
175 bool aAllowFields = true );
176
186 LIB_SYMBOL* GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib = false,
187 bool aShowErrorMsg = false );
188
199 wxString SelectLibrary( const wxString& aDialogTitle, const wxString& aListLabel,
200 const std::vector<std::pair<wxString, bool*>>& aExtraCheckboxes = {} );
201
202 virtual void RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer );
203
204 void HardRedraw() override;
205
210 void AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr ) override;
211
216 void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen ) override;
217
221 virtual void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false,
222 bool aUpdateRtree = false );
223
228
232 void SyncView();
233
237 void ShowFindReplaceDialog( bool aReplace );
238
240
241 void ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime );
243
247 void OnFindDialogClose();
248
249 void CommonSettingsChanged( int aFlags ) override;
250
255
256 COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
257
258 void ActivateGalCanvas() override;
259
263 void OnSymChange( wxFileSystemWatcherEvent& aEvent );
264
268 void OnSymChangeDebounceTimer( wxTimerEvent& aEvent );
269
277 void SetSymModificationTime( const wxDateTime& aTime )
278 {
279 m_watcherLastModified = aTime;
280 }
281
283
284 void GetLibraryItemsForListDialog( wxArrayString& aHeaders, std::vector<wxArrayString>& aItemsToDisplay );
285
286protected:
287 void handleActivateEvent( wxActivateEvent& aEvent ) override;
288
289 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
290
291 void doCloseWindow() override;
292
300 bool saveSymbolLibTables( bool aGlobal, bool aProject );
301
306 void setSymWatcher( const LIB_ID* aSymbol );
307
313
314protected:
317
320
321private:
322
324 std::unique_ptr<wxFileSystemWatcher> m_watcher;
329
330 std::unique_ptr<NL_SCHEMATIC_PLUGIN> m_spaceMouse;
331};
332
333#endif // SCH_BASE_FRAME_H_
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:108
Color settings are a bit different than most of the settings objects in that there can be more than o...
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:98
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:286
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Define a library symbol object.
Definition: lib_symbol.h:85
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:59
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.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
void SetGridOrigin(const VECTOR2I &aPoint) override
virtual void RedrawScreen(const VECTOR2I &aCenterPoint, bool aWarpPointer)
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 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.
Definition: picksymbol.cpp:51
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)
wxDateTime m_watcherLastModified
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 void updateSelectionFilterVisbility()
Selection filter panel doesn't have a dedicated visibility control, so show it if any other AUI panel...
void SetSymModificationTime(const wxDateTime &aTime)
Set the modification time of the symbol library table file.
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.
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
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 ClearFindReplaceStatus()
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
The symbol library editor main window.
Helper object to filter a list of libraries.
Object used to load, save, search, and otherwise manipulate symbol library files.
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:41
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:33
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:439
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.
#define wxFileSystemWatcher