kicad/pcbnew/footprint_edit_frame.h

359 lines
11 KiB
C
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2018-01-29 20:58:58 +00:00
#ifndef FOOTPRINT_EDIT_FRAME_H
#define FOOTPRINT_EDIT_FRAME_H
2018-01-29 15:39:40 +00:00
#include <pcb_base_frame.h>
#include <pcb_base_edit_frame.h>
#include <io_mgr.h>
#include <config_params.h>
#include <fp_tree_synchronizing_adapter.h>
class PCB_LAYER_BOX_SELECTOR;
class FP_LIB_TABLE;
class FOOTPRINT_TREE_PANE;
2020-10-31 01:27:16 +00:00
class SYMBOL_LIBRARY_MANAGER;
class FOOTPRINT_EDITOR_SETTINGS;
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
class FOOTPRINT_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
{
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
friend struct PCB::IFACE;
FOOTPRINT_TREE_PANE* m_treePane;
2020-11-07 14:31:50 +00:00
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
2020-11-13 15:15:52 +00:00
std::unique_ptr<FOOTPRINT> m_revertModule;
wxString m_footprintNameWhenLoaded;
int m_defaultLibWidth;
public:
~FOOTPRINT_EDIT_FRAME();
/**
* Function GetFootprintEditorFrameName (static)
* @return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
static const wxChar* GetFootprintEditorFrameName();
///> @copydoc PCB_BASE_FRAME::GetModel()
2016-05-13 15:31:54 +00:00
BOARD_ITEM_CONTAINER* GetModel() const override;
SELECTION& GetCurrentSelection() override;
2016-05-13 15:31:54 +00:00
/**
* Get if any footprints or libraries have been modified but not saved.
*
* @return true if the any changes have not been saved
*/
bool IsContentModified() override;
bool IsCurrentFPFromBoard() const;
FOOTPRINT_EDITOR_SETTINGS* GetSettings();
APP_SETTINGS_BASE* config() const override;
2016-09-25 17:06:49 +00:00
BOARD_DESIGN_SETTINGS& GetDesignSettings() const override;
2016-09-25 17:06:49 +00:00
const PCB_PLOT_PARAMS& GetPlotSettings() const override;
void SetPlotSettings( const PCB_PLOT_PARAMS& aSettings ) override;
MAGNETIC_SETTINGS* GetMagneticItemsSettings() override;
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
COLOR_SETTINGS* GetColorSettings() const override;
const BOX2I GetDocumentExtents( bool aIncludeAllVisible = true ) const override;
bool canCloseWindow( wxCloseEvent& Event ) override;
void doCloseWindow() override;
void CloseFootprintEditor( wxCommandEvent& Event );
void OnExitKiCad( wxCommandEvent& aEvent );
/**
* switches currently used canvas (Cairo / OpenGL).
* It also reinit the layers manager that slightly changes with canvases
*/
void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
/**
* Update the layer manager and other widgets from the board setup
* (layer and items visibility, colors ...)
*/
void UpdateUserInterface();
/**
* Refresh the library tree and redraw the window
*/
void HardRedraw() override;
/**
* Create the main horizontal toolbar for the footprint editor.
*/
2016-09-24 18:53:15 +00:00
void ReCreateHToolbar() override;
2016-09-24 18:53:15 +00:00
void ReCreateVToolbar() override;
void ReCreateOptToolbar() override;
/**
* @brief (Re)Create the menubar for the Footprint Editor frame
*/
2016-09-24 18:53:15 +00:00
void ReCreateMenuBar() override;
/**
* Re create the layer Box by clearing the old list, and building
* le new one, from the new layers names and cole layers
* @param aForceResizeToolbar = true to resize the parent toolbar
* false if not needed (mainly in parent toolbar creation,
* or when the layers names are not modified)
*/
void ReCreateLayerBox( bool aForceResizeToolbar = true );
void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
void SelectLayer( wxCommandEvent& event );
// The Tool Framework initalization, for GAL mode
void setupTools();
void OnSaveFootprintAsPng( wxCommandEvent& event );
bool IsSearchTreeShown();
void ToggleSearchTree();
/**
* Save a library to a new name and/or library type.
*
* @note Saving as a new library type requires the plug-in to support saving libraries
* @see PLUGIN::FootprintSave and PLUGIN::FootprintLibCreate
*/
bool SaveLibraryAs( const wxString& aLibraryPath );
void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
void OnUpdateLoadFootprintFromBoard( wxUpdateUIEvent& aEvent );
void OnUpdateSaveFootprintToBoard( wxUpdateUIEvent& aEvent );
///> @copydoc PCB_BASE_EDIT_FRAME::OnEditItemRequest()
void OnEditItemRequest( BOARD_ITEM* aItem ) override;
2010-11-12 15:17:10 +00:00
/**
* Called from the main toolbar to load a footprint from board mainly to edit it.
*/
void LoadFootprintFromBoard( wxCommandEvent& event );
void SaveFootprintToBoard( wxCommandEvent& event );
void LoadFootprintFromLibrary( LIB_ID aFPID );
/**
* Returns the adapter object that provides the stored data.
*/
2020-11-07 14:31:50 +00:00
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetLibTreeAdapter() { return m_adapter; }
/**
* Save in an existing library a given footprint.
*
2020-11-08 21:29:04 +00:00
* @param aFootprint = the given footprint
* @return : true if OK, false if abort
*/
2020-11-13 15:15:52 +00:00
bool SaveFootprint( FOOTPRINT* aFootprint );
bool SaveFootprintAs( FOOTPRINT* aFootprint );
bool SaveFootprintToBoard( bool aAddNew );
2020-11-13 15:15:52 +00:00
bool SaveFootprintInLibrary( FOOTPRINT* aFootprint, const wxString& aLibraryName );
bool RevertFootprint();
/**
* Must be called after a footprint change
* in order to set the "modify" flag of the current screen
* and prepare, if needed the refresh of the 3D frame showing the footprint
* do not forget to call the basic OnModify function to update auxiliary info
*/
2019-05-27 09:06:34 +00:00
void OnModify() override;
// BOARD handling
2010-11-12 15:17:10 +00:00
/**
* Delete all and reinitialize the current board.
*
* @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool Clear_Pcb( bool aQuery );
/// Return the LIB_ID of the part or library selected in the footprint tree.
LIB_ID GetTreeFPID() const;
LIB_TREE_NODE* GetCurrentTreeNode() const;
/// Return the LIB_ID of the part being edited.
LIB_ID GetLoadedFPID() const;
/// Return the LIB_ID of the part selected in the footprint tree, or the loaded part if
/// there is no selection in the tree.
LIB_ID GetTargetFPID() const;
void ClearModify();
// importing / exporting Footprint
2010-12-29 17:47:32 +00:00
/**
* Create a file containing only one footprint.
*/
2020-11-13 15:15:52 +00:00
void ExportFootprint( FOOTPRINT* aFootprint );
/**
* Read a file containing only one footprint.
*
* The import function can also read gpcb footprint file, in Newlib format.
* (One footprint per file, Newlib files have no special ext.)
*/
2020-11-13 15:15:52 +00:00
FOOTPRINT* ImportFootprint( const wxString& aName = wxT( "") );
2010-11-12 15:17:10 +00:00
/**
* Load a footprint from the main board into the Footprint Editor.
*
* @param aFootprint = the footprint to load. If NULL, the user will be asked for a
* footprint reference.
* @return true if a footprint is loaded.
*/
2020-11-13 15:15:52 +00:00
bool LoadFootprintFromBoard( FOOTPRINT* aFootprint );
2010-11-12 15:17:10 +00:00
/**
* Display the list of footprints currently existing on the BOARD.
*
* @return the selected footprint or nullptr
*/
2020-11-13 15:15:52 +00:00
FOOTPRINT* SelectFootprintFromBoard( BOARD* aPcb );
/**
* Delete the given footprint from its library.
*/
bool DeleteFootprintFromLibrary( const LIB_ID& aFPID, bool aConfirm );
/**
* @return the color of the grid
*/
2019-05-27 09:06:34 +00:00
COLOR4D GetGridColor() override;
///> @copydoc PCB_BASE_FRAME::SetActiveLayer()
void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
///> @copydoc PCB_BASE_FRAME::OnUpdateLayerAlpha()
void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
void OnDisplayOptionsChanged() override;
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void ActivateGalCanvas() override;
/**
* Load a KiCad board (.kicad_pcb) from \a aFileName.
*
* @param aFileSet - hold the BOARD file to load, a vector of one element.
* @param aCtl - KICTL_ bits, one to indicate that an append of the board file
* aFileName to the currently loaded file is desired.
* @see #KIWAY_PLAYER for bit defines.
* @return bool - false if file load fails, otherwise true.
*/
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
/**
* Override from PCB_BASE_EDIT_FRAME which adds a footprint to the editor's dummy board,
* NOT to the user's PCB.
*/
2020-11-13 15:15:52 +00:00
void AddFootprintToBoard( FOOTPRINT* aFootprint ) override;
/**
2020-11-16 00:45:43 +00:00
* Allows Footprint Editor to install its preferences panel into the preferences dialog.
*/
2019-06-09 21:57:23 +00:00
void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override;
/**
* Update visible items after a language change.
*/
void ShowChangedLanguage() override;
/**
* Called after the preferences dialog is run.
*/
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
/**
* Synchronize the footprint library tree to the current state of the footprint library
* table.
* @param aProgress
*/
void SyncLibraryTree( bool aProgress );
/**
* Filter, sort, and redisplay the library tree. Does NOT synchronize it with libraries
* in disk.
*/
void RegenerateLibraryTree();
void RefreshLibraryTree();
/// Reloads displayed items and sets view.
void UpdateView();
void FocusOnLibID( const LIB_ID& aLibID );
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
DECLARE_EVENT_TABLE()
protected:
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
/// protected so only friend PCB::IFACE::CreateWindow() can act as sole factory.
FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
PCB_LAYER_BOX_SELECTOR* m_selLayerBox; // a combo box to display and select active layer
FOOTPRINT_EDITOR_SETTINGS* m_settings;
/**
* Make sure the footprint info list is loaded (with a progress dialog) and then initialize
* the footprint library tree.
*/
void initLibraryTree();
/**
* Updates window title according to getLibNickName().
*/
void updateTitle();
void restoreLastFootprint();
void retainLastFootprint();
/**
* Run the Footprint Properties dialog and handle changes made in it.
*/
2020-11-13 15:15:52 +00:00
void editFootprintProperties( FOOTPRINT* aFootprint );
void setupUIConditions() override;
};
2018-01-29 20:58:58 +00:00
#endif // FOOTPRINT_EDIT_FRAME_H