KiCad PCB EDA Suite
module_editor_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 MODULE_EDITOR_FRAME_H_
26 #define MODULE_EDITOR_FRAME_H_
27 
28 #include <wxBasePcbFrame.h>
29 #include <pcb_base_edit_frame.h>
30 #include <io_mgr.h>
31 #include <config_params.h>
32 
33 class PCB_LAYER_WIDGET;
34 class FP_LIB_TABLE;
35 class EDGE_MODULE;
36 
37 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
38 
39 
41 {
42  friend struct PCB::IFACE;
43 
44 public:
45 
47 
53  static const wxChar* GetFootprintEditorFrameName();
54 
56  BOARD_ITEM_CONTAINER* GetModel() const override;
57 
58  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
59  void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) override;
60 
61  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
62  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
63 
64  void LoadSettings( wxConfigBase* aCfg ) override;
65  void SaveSettings( wxConfigBase* aCfg ) override;
66 
80 
81  void InstallOptionsFrame( const wxPoint& pos );
82 
83  void OnCloseWindow( wxCloseEvent& Event ) override;
84  void CloseModuleEditor( wxCommandEvent& Event );
85 
86  void Process_Special_Functions( wxCommandEvent& event );
87 
88  void ProcessPreferences( wxCommandEvent& event );
89 
94  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
95 
100  void ReCreateHToolbar() override;
101 
102  void ReCreateVToolbar() override;
103  void ReCreateOptToolbar();
104  void ReCreateAuxiliaryToolbar() override;
105  void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
106 
112  void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;
113 
120  bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
121 
125  void ReCreateMenuBar() override;
126 
127  // The Tool Framework initalization, for GAL mode
128  void setupTools();
129 
130  void ToolOnRightClick( wxCommandEvent& event ) override;
131  void OnSelectOptionToolbar( wxCommandEvent& event );
132  void OnConfigurePaths( wxCommandEvent& aEvent );
133 
141  void OnSaveLibraryAs( wxCommandEvent& aEvent );
142 
144  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
145 
154  bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
155 
156  BOARD_ITEM* PrepareItemForHotkey( bool failIfCurrentlyEdited );
157 
158  bool OnHotkeyEditItem( int aIdCommand );
159  bool OnHotkeyDeleteItem( int aIdCommand );
160  bool OnHotkeyMoveItem( int aIdCommand );
161  bool OnHotkeyMoveItemExact();
162  bool OnHotkeyRotateItem( int aIdCommand );
163  bool OnHotkeyDuplicateItem( int aIdCommand );
164 
169  void Show3D_Frame( wxCommandEvent& event ) override;
170 
171  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
172  void OnVerticalToolbar( wxCommandEvent& aEvent );
173 
177  void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
178 
182  void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
183 
184  void OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent );
185  void OnUpdateLibSelected( wxUpdateUIEvent& aEvent );
186  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
187  void OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent );
188  void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
189  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
190  void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent );
191  void OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent );
192 
194  void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) override;
195 
200  void LoadModuleFromBoard( wxCommandEvent& event );
201 
213  bool SaveFootprintInLibrary( const wxString& aLibName,
214  MODULE* aModule,
215  bool aOverwrite,
216  bool aDisplayDialog );
217 
225  virtual void OnModify() override;
226 
231  void ToPrinter( wxCommandEvent& event );
232 
242  virtual void PrintPage( wxDC* aDC, LSET aPrintMaskLayer, bool aPrintMirrorMode,
243  void * aData = NULL) override;
244 
245  // BOARD handling
246 
252  bool Clear_Pcb( bool aQuery );
253 
254  /* handlers for block commands */
255  virtual int BlockCommand( EDA_KEY key ) override;
256 
264  virtual void HandleBlockPlace( wxDC* DC ) override;
265 
276  virtual bool HandleBlockEnd( wxDC* DC ) override;
277 
278  BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
279 
281  const wxString GetCurrentLib() const;
282 
283  // Footprint edition
284  void RemoveStruct( EDA_ITEM* Item );
285 
290  void Transform( MODULE* module, int transform );
291 
292  // importing / exporting Footprint
303  void Export_Module( MODULE* aModule );
304 
314  MODULE* Import_Module( const wxString& aName = wxT("") );
315 
316 
323  bool SaveCurrentModule( const wxString* aLibPath = NULL );
324 
331  bool Load_Module_From_BOARD( MODULE* Module );
332 
339  MODULE* SelectFootprint( BOARD* aPcb );
340 
341  // functions to edit footprint edges
342 
350  void Edit_Edge_Width( EDGE_MODULE* aEdge );
351 
358  void Edit_Edge_Layer( EDGE_MODULE* Edge );
359 
365  void Delete_Edge_Module( EDGE_MODULE* Edge );
366 
376  EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, STROKE_T type_edge );
377 
382  void End_Edge_Module( EDGE_MODULE* Edge );
383 
392  void Enter_Edge_Width( EDGE_MODULE* aEdge );
393 
395  void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
396 
398  void Place_EdgeMod( EDGE_MODULE* drawitem );
399 
406 
414  void DlgGlobalChange_PadSettings( D_PAD* aPad );
415 
421 
430  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
431 
439  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
440 
445  virtual bool IsGridVisible() const override;
446 
453  virtual void SetGridVisibility( bool aVisible ) override;
454 
459  virtual COLOR4D GetGridColor() override;
460 
462  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
463 
465  virtual void UseGalCanvas( bool aEnable ) override;
466 
481  bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
482 
483  int GetIconScale() override;
484  void SetIconScale( int aScale ) override;
485 
486  DECLARE_EVENT_TABLE()
487 
488 protected:
489 
491  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
492 
494 
497 
502  void updateTitle();
503 
505  void updateView();
506 
508  const wxString getLibPath();
509 
510  void restoreLastFootprint();
511  void retainLastFootprint();
512 
519  TEXTE_MODULE* CreateTextModule( MODULE* aModule, wxDC* aDC );
520 
521 private:
522 
528  void moveExact();
529 
535  void duplicateItems( bool aIncrement ) override;
536 };
537 
538 #endif // MODULE_EDITOR_FRAME_H_
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
handle most of tools og the vertical right toolbar ("Tools" toolbar)
void DlgGlobalChange_PadSettings(D_PAD *aPad)
Function DlgGlobalChange_PadSettings changes pad characteristics for the given footprint or all footp...
void OnLeftDClick(wxDC *DC, const wxPoint &MousePos) override
Function OnLeftDClick handles the double click in the footprint editor: If the double clicked item is...
BOARD_ITEM * ModeditLocateAndDisplay(int aHotKeyCode=0)
Definition: modedit.cpp:82
PARAM_CFG_ARRAY m_configParams
List of footprint editor configuration parameters.
A list of parameters type.
void OnConfigurePaths(wxCommandEvent &aEvent)
void ReCreateHToolbar() override
Function ReCreateHToolbar create the main horizontal toolbar for the footprint editor.
bool OnHotkeyRotateItem(int aIdCommand)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void ReCreateVToolbar() override
void SetActiveLayer(PCB_LAYER_ID aLayer) override
>
Definition: modedit.cpp:998
void RemoveStruct(EDA_ITEM *Item)
Definition: editmod.cpp:99
void OnVerticalToolbar(wxCommandEvent &aEvent)
Definition: modedit.cpp:918
EDA_HOTKEY * GetHotKeyDescription(int aCommand) const override
>
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual COLOR4D GetGridColor() override
Function GetGridColor() , virtual.
Definition: modedit.cpp:992
void ReCreateAuxiliaryToolbar() override
Class PCB_LAYER_WIDGET is here to implement the abstract functions of LAYER_WIDGET so they may be tie...
void OnUpdateLibAndModuleSelected(wxUpdateUIEvent &aEvent)
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Function OpenProjectFiles (was LoadOnePcbFile) loads a KiCad board (.kicad_pcb) from aFileName...
Definition: modedit.cpp:1012
bool OnHotkeyDuplicateItem(int aIdCommand)
PCB_LAYER_WIDGET * m_Layers
the layer manager
void OnCloseWindow(wxCloseEvent &Event) override
void OnUpdateReplaceModuleInBoard(wxUpdateUIEvent &aEvent)
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
virtual void SetGridVisibility(bool aVisible) override
Function SetGridVisibility() , virtual It may be overloaded by derived classes if you want to store/r...
The common library.
void OnSaveLibraryAs(wxCommandEvent &aEvent)
Function OnSaveLibraryAs saves the current library to a new name and/or library type.
Definition: loadcmp.cpp:543
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate the item under the cursor.
Definition: modedit.cpp:872
TEXTE_MODULE * CreateTextModule(MODULE *aModule, wxDC *aDC)
Creates a new text for the footprint.
Definition: edtxtmod.cpp:66
bool OnHotkeyMoveItem(int aIdCommand)
MODULE * SelectFootprint(BOARD *aPcb)
Function SelectFootprint Display the list of modules currently existing on the BOARD.
Definition: loadcmp.cpp:493
void OnUpdateLoadModuleFromBoard(wxUpdateUIEvent &aEvent)
void OnUpdateLibSelected(wxUpdateUIEvent &aEvent)
const wxString GetCurrentLib() const
Return the current library nickname.
virtual void UseGalCanvas(bool aEnable) override
>
void Enter_Edge_Width(EDGE_MODULE *aEdge)
Function Enter_Edge_Width Edition of width of module outlines Ask for a new width.
Definition: edgemod.cpp:249
int GetIconScale() override
Function GetIconScale.
void Edit_Edge_Width(EDGE_MODULE *aEdge)
Function Edit_Edge_Width changes the width of module perimeter lines, EDGE_MODULEs.
Definition: edgemod.cpp:162
bool IsElementVisible(GAL_LAYER_ID aElement) const
Function IsElementVisible tests whether a given element category is visible.
void ReCreateMenuBar() override
(Re)Create the menubar for the module editor frame
void OnUpdateOptionsToolbar(wxUpdateUIEvent &aEvent)
PCB_LAYER_ID
A quick note on layer IDs:
bool Clear_Pcb(bool aQuery)
Function Clear_Pcb delete all and reinitialize the current board.
Definition: initpcb.cpp:94
Class LSET is a set of PCB_LAYER_IDs.
void InstallOptionsFrame(const wxPoint &pos)
Classes used in Pcbnew, CvPcb and GerbView.
virtual bool IsGridVisible() const override
Function IsGridVisible() , virtual.
virtual void PrintPage(wxDC *aDC, LSET aPrintMaskLayer, bool aPrintMirrorMode, void *aData=NULL) override
Function PrintPage is used to print a page.
virtual void HandleBlockPlace(wxDC *DC) override
Function HandleBlockPlace handles the BLOCK PLACE command Last routine for block operation for: ...
virtual void OnModify() override
Virtual Function OnModify() Must be called after a footprint change in order to set the "modify" flag...
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void OnSelectOptionToolbar(wxCommandEvent &event)
void SetElementVisibility(GAL_LAYER_ID aElement, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void Show3D_Frame(wxCommandEvent &event) override
Function Show3D_Frame displays 3D view of the footprint (module) being edited.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
bool Load_Module_From_BOARD(MODULE *Module)
Function Load_Module_From_BOARD load in Modedit a footprint from the main board.
Definition: loadcmp.cpp:75
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:52
virtual int BlockCommand(EDA_KEY key) override
Function BlockCommand Returns the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the...
EDGE_MODULE * Begin_Edge_Module(EDGE_MODULE *Edge, wxDC *DC, STROKE_T type_edge)
Function Begin_Edge_Module creates a new edge item (line, arc ..).
Definition: edgemod.cpp:322
void OnUpdateSelectTool(wxUpdateUIEvent &aEvent)
handle ID_ZOOM_SELECTION and ID_NO_TOOL_SELECTED tools
void ProcessPreferences(wxCommandEvent &event)
void moveExact()
Function moveExact Move the selected item exactly, popping up a dialog to allow the user the enter th...
Definition: modedit.cpp:839
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Function RedrawActiveWindoow draws the footprint editor BOARD, and others elements such as axis and g...
Definition: tracepcb.cpp:60
void ToolOnRightClick(wxCommandEvent &event) override
const PCB_PLOT_PARAMS & GetPlotSettings() const override
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
void Export_Module(MODULE *aModule)
Function Export_Module Create a file containing only one footprint.
Definition: librairi.cpp:341
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
Function OnHotKey handle hot key events.
bool DeleteModuleFromCurrentLibrary()
Function DeleteModuleFromCurrentLibrary prompts user for footprint name, then deletes it from current...
Definition: librairi.cpp:532
bool SaveCurrentModule(const wxString *aLibPath=NULL)
Function SaveCurrentModule saves the module which is currently being edited into aLibPath or into the...
Definition: librairi.cpp:415
void Process_Special_Functions(wxCommandEvent &event)
Definition: modedit.cpp:197
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings) override
bool OnHotkeyEditItem(int aIdCommand)
void updateTitle()
Function UpdateTitle updates window title according to getLibNickName().
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
void OnUpdateSelectCurrentLib(wxUpdateUIEvent &aEvent)
void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings) override
void LoadModuleFromBoard(wxCommandEvent &event)
Function LoadModuleFromBoard called from the main toolbar to load a footprint from board mainly to ed...
Definition: modedit.cpp:175
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:57
Common, abstract interface for edit frames.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void Place_EdgeMod(EDGE_MODULE *drawitem)
Function to place a graphic item type EDGE_MODULE currently moved.
Definition: edgemod.cpp:76
PARAM_CFG_ARRAY & GetConfigurationSettings()
Function GetConfigurationSettings returns the footpr�int editor settings list.
void ToPrinter(wxCommandEvent &event)
Function ToPrinter Install the print dialog.
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Function GeneralControl performs application specific control using aDC at aPosition in logical units...
void OnUpdateInsertModuleInBoard(wxUpdateUIEvent &aEvent)
const wxString getLibPath()
The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must.
BOARD_ITEM_CONTAINER * GetModel() const override
>
void updateView()
Reloads displayed items and sets view.
void Delete_Edge_Module(EDGE_MODULE *Edge)
Function Delete_Edge_Module deletes EDGE_MODULE Edge.
Definition: edgemod.cpp:272
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
void End_Edge_Module(EDGE_MODULE *Edge)
Function End_Edge_Module terminates a move or create edge function.
Definition: edgemod.cpp:419
void SetIconScale(int aScale) override
Function SetIconScale.
void CloseModuleEditor(wxCommandEvent &Event)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
void OnEditItemRequest(wxDC *aDC, BOARD_ITEM *aItem) override
>
bool SaveFootprintInLibrary(const wxString &aLibName, MODULE *aModule, bool aOverwrite, bool aDisplayDialog)
Function SaveFootprintInLibrary Save in an existing library a given footprint.
Definition: librairi.cpp:656
void OnUpdateModuleSelected(wxUpdateUIEvent &aEvent)
void Start_Move_EdgeMod(EDGE_MODULE *drawitem, wxDC *DC)
Function to initialize the move function params of a graphic item type DRAWSEGMENT.
Definition: edgemod.cpp:61
BOARD_ITEM * PrepareItemForHotkey(bool failIfCurrentlyEdited)
MODULE * Import_Module(const wxString &aName=wxT(""))
Function Import_Module Read a file containing only one footprint.
Definition: librairi.cpp:254
void InstallFootprintBodyItemPropertiesDlg(EDGE_MODULE *aItem)
Function InstallFootprintBodyItemPropertiesDlg Install a dialog to edit a graphic item of a footprint...
void Edit_Edge_Layer(EDGE_MODULE *Edge)
Function Edit_Edge_Layer changes the EDGE_MODULE Edge layer, (The new layer will be asked) if Edge ==...
Definition: edgemod.cpp:191
void OnLeftClick(wxDC *DC, const wxPoint &MousePos) override
static const wxChar * GetFootprintEditorFrameName()
Function GetFootprintEditorFrameName (static)
virtual bool HandleBlockEnd(wxDC *DC) override
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
void Transform(MODULE *module, int transform)
Function Transform performs a geometric transform on the current footprint.
Definition: modedit.cpp:880
bool OnHotkeyDeleteItem(int aIdCommand)
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
bool OnRightClick(const wxPoint &MousePos, wxMenu *PopMenu) override
Function OnRightClick handles the right mouse click in the footprint editor: Create the pop up menu A...