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 
35 #include <stddef.h>
36 #include <utility>
37 #include <vector>
38 #include <wx/event.h>
39 #include <wx/gdicmn.h>
40 #include <wx/string.h>
41 
42 #include <template_fieldnames.h>
43 
44 
45 namespace KIGFX
46 {
47  class SCH_RENDER_SETTINGS;
48 }
49 
50 class PAGE_INFO;
51 class TITLE_BLOCK;
52 class LIB_VIEW_FRAME;
53 class LIB_EDIT_FRAME;
54 class LIB_PART;
55 class PART_LIB;
56 class SCHLIB_FILTER;
57 class LIB_ID;
58 class SYMBOL_LIB_TABLE;
59 
74 LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
75  PART_LIB* aCacheLib = NULL, wxWindow* aParent = NULL,
76  bool aShowErrorMsg = false );
77 
88 {
89 protected:
91  wxPoint m_repeatStep; // the increment value of the position of an item
92  // when it is repeated
93  int m_repeatDeltaLabel; // the increment value of labels like bus members
94  // when they are repeated
96  bool m_dragActionIsMove; // drag action defaults to move, otherwise it's drag
97 
98  bool m_repeatComponent; // After placing one component, reload a sequential
99  bool m_useAllUnits; // After placing unit A, place unit B of the same
100 
101 public:
102  SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
103  FRAME_T aWindowType,
104  const wxString& aTitle,
105  const wxPoint& aPosition, const wxSize& aSize,
106  long aStyle, const wxString & aFrameName );
107 
108  virtual ~SCH_BASE_FRAME();
109 
110  void createCanvas();
111 
112  SCH_DRAW_PANEL* GetCanvas() const override;
113  SCH_SCREEN* GetScreen() const override;
114  void SetScreen( BASE_SCREEN* aScreen ) override;
115 
117 
121  virtual bool GetShowAllPins() const { return true; }
122 
127  virtual bool GetSelectPinSelectSymbol() const { return false; }
128 
133  void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
134 
139  const wxPoint GetRepeatStep() const { return m_repeatStep; }
140 
146  void SetRepeatStep( const wxPoint& aStep) { m_repeatStep = aStep; }
147 
152  int GetRepeatDeltaLabel() const { return m_repeatDeltaLabel; }
153 
159  void SetRepeatDeltaLabel( int aDelta ) { m_repeatDeltaLabel = aDelta; }
160 
164  const bool GetRepeatComponent() { return m_repeatComponent; }
165 
170  void SetRepeatComponent( bool aRepeat ) { m_repeatComponent = aRepeat; }
171 
175  const bool GetUseAllUnits() { return m_useAllUnits; }
176 
181  void SetUseAllUnits( bool aUseAll ) { m_useAllUnits = aUseAll; }
182 
183 
190  const wxString GetZoomLevelIndicator() const override;
191 
192  void SetDragActionIsMove( bool aValue ) { m_dragActionIsMove = aValue; }
193  bool GetDragActionIsMove() const { return m_dragActionIsMove; }
194 
195  void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
196  const PAGE_INFO& GetPageSettings () const override;
197  const wxSize GetPageSizeIU() const override;
198 
199  const wxPoint& GetAuxOrigin() const override;
200  void SetAuxOrigin( const wxPoint& aPosition ) override;
201 
202  const wxPoint& GetGridOrigin() const override
203  {
204  static wxPoint zero;
205  return zero;
206  }
207  void SetGridOrigin( const wxPoint& aPoint ) override {}
208 
209  void OnGridSettings( wxCommandEvent& aEvent ) override;
210 
211  const TITLE_BLOCK& GetTitleBlock() const override;
212  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
213 
214  void UpdateStatusBar() override;
215 
216  typedef std::vector<COMPONENT_SELECTION> HISTORY_LIST;
217 
243  const SCHLIB_FILTER* aFilter,
244  std::vector<COMPONENT_SELECTION>& aHistoryList,
245  bool aUseLibBrowser,
246  int aUnit,
247  int aConvert,
248  bool aShowFootprints,
249  const LIB_ID* aHighlight = nullptr,
250  bool aAllowFields = true );
251 
256  {
258  }
259 
266  const TEMPLATE_FIELDNAME* GetTemplateFieldName( const wxString& aName ) const
267  {
268  return m_templateFieldNames.GetFieldName( aName );
269  }
270 
280  LIB_PART* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false,
281  bool aShowErrorMsg = false );
282 
283  LIB_PART* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false );
284 
298  COMPONENT_SELECTION SelectComponentFromLibBrowser( wxTopLevelWindow* aParent,
299  const SCHLIB_FILTER* aFilter,
300  const LIB_ID& aPreselectedLibid,
301  int aUnit, int aConvert );
302 
303  virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
304 
305  virtual void CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
306 
307  void HardRedraw() override;
308 
313  void AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr );
314 
319  void RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen = nullptr );
320 
324  void RefreshItem( EDA_ITEM* aItem, bool isAddOrDelete = false );
325 
329  void RefreshSelection();
330 
334  void SyncView();
335 
340  virtual void OnModify() {}
341 
342 protected:
350  bool saveSymbolLibTables( bool aGlobal, bool aProject );
351 
352 };
353 
354 #endif // SCH_BASE_FRAME_H_
void SetScreen(BASE_SCREEN *aScreen) override
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)
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)
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.
void SetRepeatDeltaLabel(int aDelta)
Sets the repeat delta label value for repeat command.
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
wxPoint m_repeatStep
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
std::vector< COMPONENT_SELECTION > HISTORY_LIST
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void SetShowElectricalType(bool aShow)
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
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.
virtual bool GetSelectPinSelectSymbol() const
Allow some frames to select the parent symbol when trying to select a pin.
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
const bool GetUseAllUnits()
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 SetDragActionIsMove(bool aValue)
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
#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.
bool GetDragActionIsMove() const
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Define a library symbol object.
const wxPoint GetRepeatStep() const
virtual ~SCH_BASE_FRAME()
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:274
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Saves Symbol Library Tables to disk.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames() const
Function GetTemplateFieldName returns a template fieldnames list for read only access.
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:94
bool m_showPinElectricalTypeName
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void SetUseAllUnits(bool aUseAll)
Sets whether to utilize all units of a component when placing.
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:50
const PAGE_INFO & GetPageSettings() const override
void SetGridOrigin(const wxPoint &aPoint) override
void UpdateStatusBar() override
Update the status bar information.
const bool GetRepeatComponent()
The symbol library editor main window.
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName) const
Function GetFieldName searches for aName in the the template field name list.
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 TEMPLATE_FIELDNAME * GetTemplateFieldName(const wxString &aName) const
Search for aName in the the template field name list.
const TITLE_BLOCK & GetTitleBlock() const override
int GetRepeatDeltaLabel() const
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:69
Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.
void OnGridSettings(wxCommandEvent &aEvent) override
void SetRepeatStep(const wxPoint &aStep)
Sets the repeat step value for repeat command.
virtual void CenterScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames() const
Return a template field names list for read only access.
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.
void SetRepeatComponent(bool aRepeat)
If true, keep placing new copies of the same symbol on each click.
bool GetShowElectricalType()
Allow some frames to show/hide pin electrical type names.