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-2018 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 <lib_id.h>
31 #include <page_info.h>
32 #include <sch_draw_panel.h>
33 #include <sch_screen.h>
34 #include <schematic_settings.h>
35 
36 #include <stddef.h>
37 #include <utility>
38 #include <vector>
39 #include <wx/event.h>
40 #include <wx/gdicmn.h>
41 #include <wx/string.h>
42 
43 #include <template_fieldnames.h>
44 
45 
46 namespace KIGFX
47 {
48  class SCH_RENDER_SETTINGS;
49 }
50 
51 class PAGE_INFO;
52 class TITLE_BLOCK;
53 class LIB_VIEW_FRAME;
54 class LIB_EDIT_FRAME;
55 class LIB_PART;
56 class PART_LIB;
57 class SCHLIB_FILTER;
58 class LIB_ID;
59 class SYMBOL_LIB_TABLE;
60 class EESCHEMA_SETTINGS;
61 class LIBEDIT_SETTINGS;
62 
77 LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
78  PART_LIB* aCacheLib = NULL, wxWindow* aParent = NULL,
79  bool aShowErrorMsg = false );
80 
91 {
92 protected:
94 
97 
99 
100 public:
101  SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
102  FRAME_T aWindowType,
103  const wxString& aTitle,
104  const wxPoint& aPosition, const wxSize& aSize,
105  long aStyle, const wxString & aFrameName );
106 
107  virtual ~SCH_BASE_FRAME();
108 
109  void createCanvas();
110 
111  SCH_DRAW_PANEL* GetCanvas() const override;
112  SCH_SCREEN* GetScreen() const override;
113 
114  EESCHEMA_SETTINGS* eeconfig() const;
115 
117 
118  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
119  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
120 
122 
124  {
125  return *m_defaults;
126  }
127 
131  virtual bool GetShowAllPins() const { return true; }
132 
139  const wxString GetZoomLevelIndicator() const override;
140 
141  void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
142  const PAGE_INFO& GetPageSettings () const override;
143  const wxSize GetPageSizeIU() const override;
144 
145  const wxPoint& GetAuxOrigin() const override;
146  void SetAuxOrigin( const wxPoint& aPosition ) override;
147 
148  const wxPoint& GetGridOrigin() const override
149  {
150  static wxPoint zero;
151  return zero;
152  }
153  void SetGridOrigin( const wxPoint& aPoint ) override {}
154 
155  void OnGridSettings( wxCommandEvent& aEvent ) override;
156 
157  const TITLE_BLOCK& GetTitleBlock() const override;
158  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
159 
160  void UpdateStatusBar() override;
161 
187  const SCHLIB_FILTER* aFilter,
188  std::vector<COMPONENT_SELECTION>& aHistoryList,
189  bool aUseLibBrowser,
190  int aUnit,
191  int aConvert,
192  bool aShowFootprints,
193  const LIB_ID* aHighlight = nullptr,
194  bool aAllowFields = true );
195 
200  {
202  }
203 
208  {
210  }
211 
218  const TEMPLATE_FIELDNAME* GetTemplateFieldName( const wxString& aName )
219  {
220  return m_templateFieldNames.GetFieldName( aName );
221  }
222 
232  LIB_PART* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false,
233  bool aShowErrorMsg = false );
234 
235  LIB_PART* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false );
236 
250  COMPONENT_SELECTION SelectComponentFromLibBrowser( wxTopLevelWindow* aParent,
251  const SCHLIB_FILTER* aFilter,
252  const LIB_ID& aPreselectedLibid,
253  int aUnit, int aConvert );
254 
255  virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
256 
257  virtual void CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
258 
259  void HardRedraw() override;
260 
265  void AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr );
266 
271  void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr );
272 
276  void RefreshItem( EDA_ITEM* aItem, bool isAddOrDelete = false );
277 
281  void RefreshSelection();
282 
286  void SyncView();
287 
292  virtual void OnModify() {}
293 
294  void CommonSettingsChanged( bool aEnvVarsChanged ) override;
295 
300 
301  COLOR_SETTINGS* GetColorSettings() override;
302 
303 protected:
311  bool saveSymbolLibTables( bool aGlobal, bool aProject );
312 
313 };
314 
315 #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 libedit. Eeschema should be using the one inside the SCHEMATIC.
LIB_PART * SchGetLibPart(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib=NULL, wxWindow *aParent=NULL, bool aShowErrorMsg=false)
Load symbol from symbol library table.
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
These settings were stored in SCH_BASE_FRAME previously.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:131
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 HardRedraw() override
Rebuild the GAL and redraws the screen.
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
LIB_PART * GetFlattenedLibPart(const LIB_ID &aLibId, bool aShowErrorMsg=false)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
TEMPLATES m_templateFieldNames
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
COLOR_SETTINGS * GetColorSettings() override
Returns a pointer to the active color theme settings.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
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.
SCHEMATIC_SETTINGS & GetDefaults()
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Symbol library viewer main window.
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
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:73
#define NULL
void SetAuxOrigin(const wxPoint &aPosition) override
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.
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Define a library symbol object.
virtual ~SCH_BASE_FRAME()
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Saves Symbol Library Tables to disk.
SCH_LAYER_ID
Eeschema drawing layers.
COMPONENT_SELECTION SelectCompFromLibTree(const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Function SelectComponentFromLib Calls the library viewer to select component to import into schematic...
Definition: getpart.cpp:89
SCHEMATIC_SETTINGS * m_defaults
void SetPageSettings(const PAGE_INFO &aPageSettings) override
LIBEDIT_SETTINGS * libeditconfig() const
COMPONENT_SELECTION SelectComponentFromLibBrowser(wxTopLevelWindow *aParent, const SCHLIB_FILTER *aFilter, const LIB_ID &aPreselectedLibid, int aUnit, int aConvert)
Function SelectComponentFromLibBrowser Calls the library viewer to select component to import into sc...
Definition: getpart.cpp:45
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Function GetFieldName searches for aName in the the template field name list.
const PAGE_INFO & GetPageSettings() const override
void SetGridOrigin(const wxPoint &aPoint) override
void UpdateStatusBar() override
Update the status bar information.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames(bool aGlobal)
Return a specific template field names list (global or project) for read only access.
The symbol library editor main window.
virtual bool GetShowAllPins() const
Allow some frames to show/hide hidden pins.
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
const TITLE_BLOCK & GetTitleBlock() const override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:70
Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.
void OnGridSettings(wxCommandEvent &aEvent) override
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)
const TEMPLATE_FIELDNAME * GetTemplateFieldName(const wxString &aName)
Search for aName in the the template field name list.
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
Object used to load, save, search, and otherwise manipulate symbol library files.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Function GetTemplateFieldName returns a template fieldnames list for read only access.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field names list for read only access.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40