KiCad PCB EDA Suite
footprint_edit_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) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
25 #ifndef FOOTPRINT_EDIT_FRAME_H
26 #define FOOTPRINT_EDIT_FRAME_H
27 
28 #include <pcb_base_frame.h>
29 #include <pcb_base_edit_frame.h>
30 #include <io_mgr.h>
31 #include <config_params.h>
33 
34 class PCB_LAYER_WIDGET;
35 class FP_LIB_TABLE;
36 class EDGE_MODULE;
38 class LIB_MANAGER;
39 
40 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
41 
42 
44 {
45  friend struct PCB::IFACE;
46 
49 
50  std::unique_ptr<MODULE> m_copiedModule;
51  std::unique_ptr<MODULE> m_revertModule;
53 
54 public:
55 
57 
63  static const wxChar* GetFootprintEditorFrameName();
64 
66  BOARD_ITEM_CONTAINER* GetModel() const override;
67 
68  bool IsCurrentFPFromBoard() const;
69 
70  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
71  void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) override;
72 
73  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
74  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
75 
76  void LoadSettings( wxConfigBase* aCfg ) override;
77  void SaveSettings( wxConfigBase* aCfg ) override;
78 
79  double BestZoom() override;
80 
92  PARAM_CFG_ARRAY& GetConfigurationSettings();
93 
94  void OnCloseWindow( wxCloseEvent& Event ) override;
95  void CloseModuleEditor( wxCommandEvent& Event );
96 
101  virtual void OnSwitchCanvas( wxCommandEvent& aEvent ) override;
102 
107  void UpdateUserInterface();
108 
109  void Process_Special_Functions( wxCommandEvent& event );
110 
111  void ProcessPreferences( wxCommandEvent& event );
112 
116  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
117 
121  void ReCreateHToolbar() override;
122 
123  void ReCreateVToolbar() override;
124  void ReCreateOptToolbar() override;
125  void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
126 
132  void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;
133 
139  bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
140 
144  void ReCreateMenuBar() override;
145 
146  // The Tool Framework initalization, for GAL mode
147  void setupTools();
148 
149  void ToolOnRightClick( wxCommandEvent& event ) override;
150  void OnSelectOptionToolbar( wxCommandEvent& event );
151  void OnConfigurePaths( wxCommandEvent& aEvent );
152  void OnToggleSearchTree( wxCommandEvent& event );
153 
154  void OnSaveFootprintAsPng( wxCommandEvent& event );
155 
156  bool IsSearchTreeShown();
157 
164  bool SaveLibraryAs( const wxString& aLibraryPath );
165 
167  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
168 
176  bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
177 
178  BOARD_ITEM* PrepareItemForHotkey( bool failIfCurrentlyEdited );
179 
180  bool OnHotkeyEditItem( int aIdCommand );
181  bool OnHotkeyDeleteItem( int aIdCommand );
182  bool OnHotkeyMoveItem( int aIdCommand );
183  bool OnHotkeyMoveItemExact();
184  bool OnHotkeyRotateItem( int aIdCommand );
185  bool OnHotkeyDuplicateItem( int aIdCommand );
186 
190  void Show3D_Frame( wxCommandEvent& event ) override;
191 
192  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
193  void OnVerticalToolbar( wxCommandEvent& aEvent );
194 
198  void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
199 
203  void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
204 
205  void OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent );
206  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
207  void OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent );
208  void OnUpdateSave( wxUpdateUIEvent& aEvent );
209  void OnUpdateSaveAs( wxUpdateUIEvent& aEvent );
210  void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
211  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
212 
214  void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) override;
215 
219  void LoadModuleFromBoard( wxCommandEvent& event );
220 
221  void LoadModuleFromLibrary( LIB_ID aFPID );
222 
227 
234  bool SaveFootprint( MODULE* aModule );
235  bool SaveFootprintAs( MODULE* aModule );
236  bool SaveFootprintToBoard( bool aAddNew );
237  bool RevertFootprint();
238 
245  virtual void OnModify() override;
246 
250  void ToPrinter( wxCommandEvent& event );
251 
252  // BOARD handling
253 
259  bool Clear_Pcb( bool aQuery );
260 
261  /* handlers for block commands */
262  virtual int BlockCommand( EDA_KEY key ) override;
263 
271  virtual void HandleBlockPlace( wxDC* DC ) override;
272 
282  virtual bool HandleBlockEnd( wxDC* DC ) override;
283 
284  BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
285 
287  LIB_ID getTargetFPID() const;
288 
290  LIB_ID GetLoadedFPID() const;
291 
292  void RemoveStruct( EDA_ITEM* Item );
293 
297  void Transform( MODULE* module, int transform );
298 
299  // importing / exporting Footprint
310  void Export_Module( MODULE* aModule );
311 
321  MODULE* Import_Module( const wxString& aName = wxT("") );
322 
329  bool Load_Module_From_BOARD( MODULE* Module );
330 
337  MODULE* SelectFootprintFromBoard( BOARD* aPcb );
338 
339  // functions to edit footprint edges
340 
348  void Edit_Edge_Width( EDGE_MODULE* aEdge );
349 
356  void Edit_Edge_Layer( EDGE_MODULE* Edge );
357 
363  void Delete_Edge_Module( EDGE_MODULE* Edge );
364 
373  EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, STROKE_T type_edge );
374 
378  void End_Edge_Module( EDGE_MODULE* Edge );
379 
381  void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
382 
384  void Place_EdgeMod( EDGE_MODULE* drawitem );
385 
392  void PushPadProperties( D_PAD* aPad );
393 
397  bool DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm );
398 
408  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
409 
417  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
418 
422  virtual bool IsGridVisible() const override;
423 
429  virtual void SetGridVisibility( bool aVisible ) override;
430 
434  virtual COLOR4D GetGridColor() override;
435 
437  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
438 
440  void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
441 
443  virtual void UseGalCanvas( bool aEnable ) override;
444 
458  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
459 
464  void AddModuleToBoard( MODULE* module ) override;
465 
469  void InstallPreferences( PAGED_DIALOG* aParent ) override;
470 
471  void ReFillLayerWidget();
472 
476  void ShowChangedLanguage() override;
477 
481  void CommonSettingsChanged() override;
482 
488  void SyncLibraryTree( bool aProgress );
489 
497  void UpdateMsgPanel() override;
498 
499  void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
500 
501  DECLARE_EVENT_TABLE()
502 
503 protected:
504 
506  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
507 
509 
512 
517  void initLibraryTree();
518 
522  void updateTitle();
523 
525  void updateView();
526 
527  void restoreLastFootprint();
528  void retainLastFootprint();
529 
536  TEXTE_MODULE* CreateTextModule( MODULE* aModule, wxDC* aDC );
537 
538 private:
539 
543  void editFootprintProperties( MODULE* aFootprint );
544 
545  bool saveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
546 
551  void moveExact();
552 
558  void duplicateItems( bool aIncrement ) override;
559 };
560 
561 #endif // FOOTPRINT_EDIT_FRAME_H
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility, colors ...) (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins.
PARAM_CFG_ARRAY m_configParams
List of footprint editor configuration parameters.
A list of parameters type.
Class KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
LIB_TREE_MODEL_ADAPTER::PTR & GetLibTreeAdapter()
Returns the adapter object that provides the stored data.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
PCB_LAYER_WIDGET * m_Layers
the layer manager
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
The common library.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Classes used in Pcbnew, CvPcb and GerbView.
std::unique_ptr< MODULE > m_revertModule
PCB_LAYER_ID
A quick note on layer IDs:
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
STROKE_T
Enum STROKE_T is the set of shapes for segments (graphic segments and tracks) which are often in the ...
uint32_t EDA_KEY
Definition: common.h:73
Footprint Editor pane with footprint library tree.
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
Class to handle modifications to the symbol libraries.
Definition: lib_manager.h:49
LIB_TREE_MODEL_ADAPTER::PTR m_adapter
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
Common, abstract interface for edit frames.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
FOOTPRINT_TREE_PANE * m_treePane
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > PTR
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms) ...
Definition: ifsg_api.cpp:471
std::unique_ptr< MODULE > m_copiedModule
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39