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-2015 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
29 #ifndef MODULE_EDITOR_FRAME_H_
30 #define MODULE_EDITOR_FRAME_H_
31 
32 #include <wxBasePcbFrame.h>
33 #include <pcb_base_edit_frame.h>
34 #include <io_mgr.h>
35 #include <config_params.h>
36 
37 class PCB_LAYER_WIDGET;
38 class FP_LIB_TABLE;
39 class EDGE_MODULE;
40 
41 namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
42 
43 
45 {
46  friend struct PCB::IFACE;
47 
48 public:
49 
51 
57  static const wxChar* GetFootprintEditorFrameName();
58 
60  BOARD_ITEM_CONTAINER* GetModel() const override;
61 
62  BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
63  void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) override;
64 
65  const PCB_PLOT_PARAMS& GetPlotSettings() const override;
66  void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
67 
68  void LoadSettings( wxConfigBase* aCfg ) override;
69  void SaveSettings( wxConfigBase* aCfg ) override;
70 
84 
85  void InstallOptionsFrame( const wxPoint& pos );
86 
87  void OnCloseWindow( wxCloseEvent& Event ) override;
88  void CloseModuleEditor( wxCommandEvent& Event );
89 
90  void Process_Special_Functions( wxCommandEvent& event );
91 
92  void ProcessPreferences( wxCommandEvent& event );
93 
98  void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
99 
104  void ReCreateHToolbar() override;
105 
106  void ReCreateVToolbar() override;
107  void ReCreateOptToolbar();
108  void ReCreateAuxiliaryToolbar() override;
109  void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
110 
116  void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;
117 
124  bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
125 
129  void ReCreateMenuBar() override;
130 
131  // The Tool Framework initalization, for GAL mode
132  void setupTools();
133 
134  void ToolOnRightClick( wxCommandEvent& event ) override;
135  void OnSelectOptionToolbar( wxCommandEvent& event );
136  void OnConfigurePaths( wxCommandEvent& aEvent );
137 
145  void OnSaveLibraryAs( wxCommandEvent& aEvent );
146 
148  EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
149 
158  bool OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
159 
160  BOARD_ITEM* PrepareItemForHotkey( bool failIfCurrentlyEdited );
161 
162  bool OnHotkeyEditItem( int aIdCommand );
163  bool OnHotkeyDeleteItem( int aIdCommand );
164  bool OnHotkeyMoveItem( int aIdCommand );
165  bool OnHotkeyMoveItemExact();
166  bool OnHotkeyRotateItem( int aIdCommand );
167  bool OnHotkeyDuplicateItem( int aIdCommand );
168 
173  void Show3D_Frame( wxCommandEvent& event ) override;
174 
175  bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
176  void OnVerticalToolbar( wxCommandEvent& aEvent );
177 
178  void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
179  void OnUpdateOptionsToolbar( wxUpdateUIEvent& aEvent );
180  void OnUpdateLibSelected( wxUpdateUIEvent& aEvent );
181  void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
182  void OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent );
183  void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
184  void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
185  void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent );
186  void OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent );
187 
189  void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) override;
190 
195  void LoadModuleFromBoard( wxCommandEvent& event );
196 
208  bool SaveFootprintInLibrary( const wxString& aLibName,
209  MODULE* aModule,
210  bool aOverwrite,
211  bool aDisplayDialog );
212 
220  virtual void OnModify() override;
221 
226  void ToPrinter( wxCommandEvent& event );
227 
237  virtual void PrintPage( wxDC* aDC, LSET aPrintMaskLayer, bool aPrintMirrorMode,
238  void * aData = NULL) override;
239 
240  // BOARD handling
241 
247  bool Clear_Pcb( bool aQuery );
248 
249  /* handlers for block commands */
250  virtual int BlockCommand( EDA_KEY key ) override;
251 
259  virtual void HandleBlockPlace( wxDC* DC ) override;
260 
271  virtual bool HandleBlockEnd( wxDC* DC ) override;
272 
273  BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
274 
276  const wxString GetCurrentLib() const;
277 
278  // Footprint edition
279  void RemoveStruct( EDA_ITEM* Item );
280 
285  void Transform( MODULE* module, int transform );
286 
287  // importing / exporting Footprint
298  void Export_Module( MODULE* aModule );
299 
310 
317  bool SaveCurrentModule( const wxString* aLibPath = NULL );
318 
325  bool Load_Module_From_BOARD( MODULE* Module );
326 
333  MODULE* SelectFootprint( BOARD* aPcb );
334 
335  // functions to edit footprint edges
336 
344  void Edit_Edge_Width( EDGE_MODULE* aEdge );
345 
352  void Edit_Edge_Layer( EDGE_MODULE* Edge );
353 
359  void Delete_Edge_Module( EDGE_MODULE* Edge );
360 
370  EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, STROKE_T type_edge );
371 
376  void End_Edge_Module( EDGE_MODULE* Edge );
377 
386  void Enter_Edge_Width( EDGE_MODULE* aEdge );
387 
389  void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
390 
392  void Place_EdgeMod( EDGE_MODULE* drawitem );
393 
400 
408  void DlgGlobalChange_PadSettings( D_PAD* aPad );
409 
415 
424  bool IsElementVisible( GAL_LAYER_ID aElement ) const;
425 
433  void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
434 
439  virtual bool IsGridVisible() const override;
440 
447  virtual void SetGridVisibility( bool aVisible ) override;
448 
453  virtual COLOR4D GetGridColor() const override;
454 
456  void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
457 
459  virtual void UseGalCanvas( bool aEnable ) override;
460 
461  DECLARE_EVENT_TABLE()
462 
463 protected:
464 
466  FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
467 
469 
471 
476  void updateTitle();
477 
479  void updateView();
480 
482  const wxString getLibPath();
483 
484  void restoreLastFootprint();
485  void retainLastFootprint();
486 
493  TEXTE_MODULE* CreateTextModule( MODULE* aModule, wxDC* aDC );
494 
495 private:
496 
502  void moveExact();
503 
509  void duplicateItems( bool aIncrement ) override;
510 };
511 
512 #endif // MODULE_EDITOR_FRAME_H_
void OnUpdateVerticalToolbar(wxUpdateUIEvent &aEvent)
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
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:1014
void RemoveStruct(EDA_ITEM *Item)
Definition: editmod.cpp:99
void OnVerticalToolbar(wxCommandEvent &aEvent)
Definition: modedit.cpp:940
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...
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 OnHotkeyDuplicateItem(int aIdCommand)
PCB_LAYER_WIDGET * m_Layers
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:535
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate the item under the cursor.
Definition: modedit.cpp:894
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:485
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
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.
PARAM_CFG_ARRAY m_configSettings
List of footprint editor configuration settings.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
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 ProcessPreferences(wxCommandEvent &event)
virtual COLOR4D GetGridColor() const override
Function GetGridColor() , virtual.
Definition: modedit.cpp:1008
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:338
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:509
bool SaveCurrentModule(const wxString *aLibPath=NULL)
Function SaveCurrentModule saves the module which is currently being edited into aLibPath or into the...
Definition: librairi.cpp:412
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)
MODULE * Import_Module()
Function Import_Module Read a file containing only one footprint.
Definition: librairi.cpp:256
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:166
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:151
void End_Edge_Module(EDGE_MODULE *Edge)
Function End_Edge_Module terminates a move or create edge function.
Definition: edgemod.cpp:419
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:633
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)
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:902
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...