KiCad PCB EDA Suite
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 <dick@softplc.com>
5  * Copyright (C) 2015-2021 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/gdicmn.h>
39 #include <wx/string.h>
40 
41 #include <template_fieldnames.h>
42 
43 
44 namespace KIGFX
45 {
46  class SCH_RENDER_SETTINGS;
47 }
48 
49 class PAGE_INFO;
50 class TITLE_BLOCK;
52 class SYMBOL_EDIT_FRAME;
53 class LIB_SYMBOL;
54 class SYMBOL_LIB;
55 class SCHLIB_FILTER;
56 class LIB_ID;
57 class SYMBOL_LIB_TABLE;
58 class EESCHEMA_SETTINGS;
60 
75 LIB_SYMBOL* SchGetLibSymbol( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
76  SYMBOL_LIB* aCacheLib = nullptr, wxWindow* aParent = nullptr,
77  bool aShowErrorMsg = false );
78 
89 {
90 public:
91  SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
92  FRAME_T aWindowType,
93  const wxString& aTitle,
94  const wxPoint& aPosition, const wxSize& aSize,
95  long aStyle, const wxString & aFrameName );
96 
97  virtual ~SCH_BASE_FRAME();
98 
99  void createCanvas();
100 
101  SCH_DRAW_PANEL* GetCanvas() const override;
102  SCH_SCREEN* GetScreen() const override;
103 
104  EESCHEMA_SETTINGS* eeconfig() const;
105 
107 
108  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
109  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
110 
112 
113  COLOR4D GetDrawBgColor() const override;
114 
118  virtual bool GetShowAllPins() const { return true; }
119 
120  void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
121  const PAGE_INFO& GetPageSettings () const override;
122  const wxSize GetPageSizeIU() const override;
123 
124  const wxPoint& GetGridOrigin() const override
125  {
126  static wxPoint zero;
127  return zero;
128  }
129  void SetGridOrigin( const wxPoint& aPoint ) override {}
130 
131  const TITLE_BLOCK& GetTitleBlock() const override;
132  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
133 
134  void UpdateStatusBar() override;
135 
158  std::vector<PICKED_SYMBOL>& aHistoryList,
159  bool aUseLibBrowser,
160  int aUnit,
161  int aConvert,
162  bool aShowFootprints,
163  const LIB_ID* aHighlight = nullptr,
164  bool aAllowFields = true );
165 
175  LIB_SYMBOL* GetLibSymbol( const LIB_ID& aLibId, bool aUseCacheLib = false,
176  bool aShowErrorMsg = false );
177 
190  PICKED_SYMBOL PickSymbolFromLibBrowser( wxTopLevelWindow* aParent,
191  const SCHLIB_FILTER* aFilter,
192  const LIB_ID& aPreselectedLibId,
193  int aUnit, int aConvert );
194 
195  virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
196 
197  virtual void CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
198 
199  void HardRedraw() override;
200 
205  void AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen );
206 
211  void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen );
212 
216  void UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete = false );
217 
221  void RefreshSelection();
222 
226  void SyncView();
227 
232  virtual void OnModify() {}
233 
234  void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
235 
240 
241  COLOR_SETTINGS* GetColorSettings() const override;
242 
243 protected:
251  bool saveSymbolLibTables( bool aGlobal, bool aProject );
252 
256 };
257 
258 #endif // SCH_BASE_FRAME_H_
void RefreshSelection()
Mark selected items for refresh.
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
SCHEMATIC_SETTINGS m_base_frame_defaults
These are only used by symbol_editor.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:236
void HardRedraw() override
Rebuild the GAL and redraws the screen.
Object used to load, save, search, and otherwise manipulate symbol library files.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
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.
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,...
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
Symbol library viewer main window.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
The base class for create windows for drawing purpose.
Define a library symbol object.
Definition: lib_symbol.h:96
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
EESCHEMA_SETTINGS * eeconfig() const
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:323
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
void SyncView()
Mark all items for refresh.
PICKED_SYMBOL PickSymbolFromLibTree(const SCHLIB_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
Definition: getpart.cpp:88
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual ~SCH_BASE_FRAME()
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
SYMBOL_EDITOR_SETTINGS * libeditconfig() const
COLOR4D GetDrawBgColor() const override
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
void SetPageSettings(const PAGE_INFO &aPageSettings) override
PICKED_SYMBOL PickSymbolFromLibBrowser(wxTopLevelWindow *aParent, const SCHLIB_FILTER *aFilter, const LIB_ID &aPreselectedLibId, int aUnit, int aConvert)
Call the library viewer to select symbol to import into schematic.
Definition: getpart.cpp:42
const PAGE_INFO & GetPageSettings() const override
void SetGridOrigin(const wxPoint &aPoint) override
void UpdateStatusBar() override
Update the status bar information.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
virtual bool GetShowAllPins() const
Allow some frames to show/hide hidden pins.
const TITLE_BLOCK & GetTitleBlock() const override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
These settings were stored in SCH_BASE_FRAME previously.
Store schematic specific render settings.
Definition: sch_painter.h:70
Color settings are a bit different than most of the settings objects in that there can be more than o...
virtual void CenterScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
The symbol library editor main window.