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 <lib_id.h>
29 #include <draw_frame.h>
30 
31 #include <sch_screen.h>
32 #include <sch_draw_panel.h>
33 #include "template_fieldnames.h"
34 
35 
36 namespace KIGFX
37 {
38  class SCH_RENDER_SETTINGS;
39 }
40 
41 class PAGE_INFO;
42 class TITLE_BLOCK;
43 class LIB_VIEW_FRAME;
44 class LIB_EDIT_FRAME;
45 class LIB_ALIAS;
46 class LIB_PART;
47 class PART_LIB;
48 class SCHLIB_FILTER;
49 class LIB_ID;
50 class SYMBOL_LIB_TABLE;
51 class SCH_DRAW_PANEL;
52 
67 LIB_ALIAS* SchGetLibAlias( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
68  PART_LIB* aCacheLib = NULL, wxWindow* aParent = NULL,
69  bool aShowErrorMsg = false );
70 
71 LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
72  PART_LIB* aCacheLib = NULL, wxWindow* aParent = NULL,
73  bool aShowErrorMsg = false );
74 
75 
86 {
87 protected:
89 
91  int m_repeatDeltaLabel;
93 
95 
96 public:
97  SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
98  FRAME_T aWindowType,
99  const wxString& aTitle,
100  const wxPoint& aPosition, const wxSize& aSize,
101  long aStyle, const wxString & aFrameName );
102 
103  virtual ~SCH_BASE_FRAME();
104 
105  void createCanvas();
106 
107  SCH_DRAW_PANEL* GetCanvas() const override;
108  SCH_SCREEN* GetScreen() const override;
109 
110  KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings();
111 
115  void OnSwitchCanvas( wxCommandEvent& aEvent );
116 
120  void OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent );
121 
126  const wxPoint GetRepeatStep() const { return m_repeatStep; }
127 
133  void SetRepeatStep( const wxPoint& aStep) { m_repeatStep = aStep; }
134 
139  int GetRepeatDeltaLabel() const { return m_repeatDeltaLabel; }
140 
146  void SetRepeatDeltaLabel( int aDelta ) { m_repeatDeltaLabel = aDelta; }
147 
148 
155  const wxString GetZoomLevelIndicator() const override;
156 
157  void SetPageSettings( const PAGE_INFO& aPageSettings ) override;
158  const PAGE_INFO& GetPageSettings () const override;
159  const wxSize GetPageSizeIU() const override;
160 
161  const wxPoint& GetAuxOrigin() const override;
162  void SetAuxOrigin( const wxPoint& aPosition ) override;
163 
164  const wxPoint& GetGridOrigin() const override
165  {
166  static wxPoint zero;
167  return zero;
168  }
169  void SetGridOrigin( const wxPoint& aPoint ) override {}
170 
171  void OnGridSettings( wxCommandEvent& aEvent ) override;
172 
173  const TITLE_BLOCK& GetTitleBlock() const override;
174  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
175 
176  void UpdateStatusBar() override;
177 
178 
180  {
182  int Unit;
183  int Convert;
184 
185  std::vector<std::pair<int, wxString>> Fields;
186 
188  Unit( 1 ),
189  Convert( 1 )
190  {}
191  };
192 
193  typedef std::vector<COMPONENT_SELECTION> HISTORY_LIST;
194 
219  COMPONENT_SELECTION SelectComponentFromLibTree(
220  const SCHLIB_FILTER* aFilter,
221  std::vector<COMPONENT_SELECTION>& aHistoryList,
222  bool aUseLibBrowser,
223  int aUnit,
224  int aConvert,
225  bool aShowFootprints,
226  const LIB_ID* aHighlight = nullptr,
227  bool aAllowFields = true );
228 
229  void OnConfigurePaths( wxCommandEvent& aEvent );
230 
235  {
236  return m_templateFieldNames.GetTemplateFieldNames();
237  }
238 
245  const TEMPLATE_FIELDNAME* GetTemplateFieldName( const wxString& aName ) const
246  {
247  return m_templateFieldNames.GetFieldName( aName );
248  }
249 
250  virtual void OnEditSymbolLibTable( wxCommandEvent& aEvent );
251 
261  LIB_ALIAS* GetLibAlias( const LIB_ID& aLibId, bool aUseCacheLib = false,
262  bool aShowError = false );
263 
264  LIB_PART* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false,
265  bool aShowErrorMsg = false );
266 
280  COMPONENT_SELECTION SelectComponentFromLibBrowser( wxTopLevelWindow* aParent,
281  const SCHLIB_FILTER* aFilter,
282  const LIB_ID& aPreselectedLibid,
283  int aUnit, int aConvert );
284 
285 
286  virtual void Zoom_Automatique( bool aWarpPointer ) override;
287 
288  /* Set the zoom level to show the area Rect */
289  virtual void Window_Zoom( EDA_RECT& aRect ) override;
290 
291  virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) override;
292 
293  virtual void RedrawScreen2( const wxPoint& posBefore ) override;
294 
295  virtual void CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
296 
297  virtual void HardRedraw() override;
298 
302  void AddToScreen( SCH_ITEM* aItem );
303 
307  void AddToScreen( DLIST<SCH_ITEM>& aItems );
308 
312  void RemoveFromScreen( SCH_ITEM* aItem );
313 
317  void RefreshItem( SCH_ITEM* aItem, bool isAddOrDelete = false );
318 
322  void SyncView();
323 
324 
325 protected:
326 
332  void OnOpenLibraryViewer( wxCommandEvent& event );
333 
346  bool DisplayListComponentsInLib( wxString& aLibrary, wxString& aBuffer,
347  wxString& aPreviousChoice );
348 
357  wxString SelectLibraryFromList();
358 
370  bool SelectPartNameToLoad( wxString& aLibrary, wxString& aBufName );
371 
379  bool saveSymbolLibTables( bool aGlobal, bool aProject );
380 
381  virtual bool HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
382  int aExplicitCommand = 0 ) override;
383 
384 };
385 
386 #endif // SCH_BASE_FRAME_H_
Part library alias object definition.
LIB_PART * SchGetLibPart(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib=NULL, wxWindow *aParent=NULL, bool aShowErrorMsg=false)
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
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
const wxPoint GetRepeatStep() const
TEMPLATES m_templateFieldNames
wxPoint m_repeatStep
the increment value of the position of an item when it is repeated
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
std::vector< COMPONENT_SELECTION > HISTORY_LIST
LIB_ALIAS * SchGetLibAlias(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib=NULL, wxWindow *aParent=NULL, bool aShowErrorMsg=false)
Load symbol from symbol library table.
int GetRepeatDeltaLabel() const
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.
Definition: draw_frame.h:78
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
Symbol library viewer main window.
Definition: viewlib_frame.h:44
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName) const
Function GetFieldName searches for aName in the the template field name list.
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames() const
Return a template field names list for read only access.
Define a library symbol object.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
uint32_t EDA_KEY
Definition: common.h:73
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames() const
Function GetTemplateFieldName returns a template fieldnames list for read only access.
const TEMPLATE_FIELDNAME * GetTemplateFieldName(const wxString &aName) const
Search for aName in the the template field name list.
std::vector< std::pair< int, wxString > > Fields
void SetGridOrigin(const wxPoint &aPoint) override
Definitions for the Eeschema program SCH_SCREEN class.
The symbol library editor main window.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:66
Struct TEMPLATE_FIELDNAME holds a name of a component&#39;s field, field value, and default visibility...
void SetRepeatStep(const wxPoint &aStep)
Sets the repeat step value for repeat command.
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
Object used to load, save, search, and otherwise manipulate symbol library files. ...
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...