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 (C) 2015-2022 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/fswatcher.h>
39#include <wx/datetime.h>
40#include <wx/gdicmn.h>
41#include <wx/string.h>
42#include <wx/timer.h>
43
44#include <template_fieldnames.h>
45
46
47namespace KIGFX
48{
49 class SCH_RENDER_SETTINGS;
50}
51
52class PAGE_INFO;
53class TITLE_BLOCK;
56class LIB_SYMBOL;
57class SYMBOL_LIB;
59class LIB_ID;
64
79LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
80 SYMBOL_LIB* aCacheLib = nullptr, wxWindow* aParent = nullptr,
81 bool aShowErrorMsg = false );
82
93{
94public:
95 SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindowType, const wxString& aTitle,
96 const wxPoint& aPosition, const wxSize& aSize, long aStyle,
97 const wxString & aFrameName );
98
99 virtual ~SCH_BASE_FRAME();
100
101 void createCanvas();
102
103 SCH_DRAW_PANEL* GetCanvas() const override;
104 SCH_SCREEN* GetScreen() const override;
105
107
109
110 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
111 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
112
114
115 COLOR4D GetDrawBgColor() const override;
116
120 virtual bool GetShowAllPins() const { return true; }
121
122 void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
123 const PAGE_INFO& GetPageSettings () const override;
124 const VECTOR2I GetPageSizeIU() const override;
125
126 const VECTOR2I& GetGridOrigin() const override
127 {
128 static VECTOR2I zero;
129 return zero;
130 }
131 void SetGridOrigin( const VECTOR2I& aPoint ) override {}
132
133 const TITLE_BLOCK& GetTitleBlock() const override;
134 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
135
136 void UpdateStatusBar() override;
137
157 std::vector<PICKED_SYMBOL>& aHistoryList,
158 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
159 bool aShowFootprints, const LIB_ID* aHighlight = nullptr,
160 bool aAllowFields = true );
161
171 LIB_SYMBOL* GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib = false,
172 bool aShowErrorMsg = false );
173
181 wxString SelectLibraryFromList();
182
189 SYMBOL_LIB_TABLE* SelectSymLibTable( bool aOptional = false );
190
191 virtual void RedrawScreen( const VECTOR2I& aCenterPoint, bool aWarpPointer );
192
193 void HardRedraw() override;
194
199 void AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr );
200
205 void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen );
206
210 virtual void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false,
211 bool aUpdateRtree = false );
212
217
221 void SyncView();
222
223 void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
224
229
230 COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
231
232 void ActivateGalCanvas() override;
233
237 void OnSymChange( wxFileSystemWatcherEvent& aEvent );
238
242 void OnSymChangeDebounceTimer( wxTimerEvent& aEvent );
243
251 void SetSymModificationTime( const wxDateTime& aTime )
252 {
253 m_watcherLastModified = aTime;
254 }
255
256protected:
257 void handleActivateEvent( wxActivateEvent& aEvent ) override;
258
259 void handleIconizeEvent( wxIconizeEvent& aEvent ) override;
260
268 bool saveSymbolLibTables( bool aGlobal, bool aProject );
269
274 void setSymWatcher( const LIB_ID* aSymbol );
275
279
280private:
281
283 std::unique_ptr<wxFileSystemWatcher> m_watcher;
287
289};
290
291#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:92
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:85
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Store schematic specific render settings.
Definition: sch_painter.h:71
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:279
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:99
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
These settings were stored in SCH_BASE_FRAME previously.
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 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 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.
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:49
SCHEMATIC_SETTINGS m_base_frame_defaults
These are only used by symbol_editor.
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.
void SetSymModificationTime(const wxDateTime &aTime)
Set the modification time of the symbol library table file.
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.
const VECTOR2I & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
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.
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.
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.
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:352
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
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.