diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 8f63f01b4f..0e56b6e10b 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -87,18 +87,17 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom ) EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid ) - EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng ) + EVT_TOOL( ID_FPEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng ) - EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) - EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard ) - EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) + EVT_TOOL( ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard ) + EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard ) // Horizontal toolbar EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings ) - EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) + EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, FOOTPRINT_EDIT_FRAME::SelectLayer ) // UI update events. - EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, + EVT_UPDATE_UI( ID_LOAD_FOOTPRINT_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard ) EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard ) @@ -384,6 +383,15 @@ LIB_ID FOOTPRINT_EDIT_FRAME::GetLoadedFPID() const } +void FOOTPRINT_EDIT_FRAME::ClearModify() +{ + if( GetBoard()->GetFirstFootprint() ) + m_footprintNameWhenLoaded = GetBoard()->GetFirstFootprint()->GetFPID().GetLibItemName(); + + GetScreen()->ClrModify(); +} + + bool FOOTPRINT_EDIT_FRAME::IsCurrentFPFromBoard() const { MODULE* footprint = GetBoard()->GetFirstFootprint(); @@ -755,7 +763,7 @@ void FOOTPRINT_EDIT_FRAME::UpdateUserInterface() } -void FOOTPRINT_EDIT_FRAME::updateView() +void FOOTPRINT_EDIT_FRAME::UpdateView() { GetCanvas()->UpdateColors(); GetCanvas()->DisplayBoard( GetBoard() ); @@ -837,6 +845,12 @@ void FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree() } +void FOOTPRINT_EDIT_FRAME::RefreshLibraryTree() +{ + m_treePane->GetLibTree()->RefreshLibTree(); +} + + void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID ) { m_treePane->GetLibTree()->SelectLibId( aLibID ); @@ -1016,7 +1030,7 @@ void FOOTPRINT_EDIT_FRAME::ActivateGalCanvas() // Be sure the axis are enabled GetCanvas()->GetGAL()->SetAxesEnabled( true ); - updateView(); + UpdateView(); // Ensure the m_Layers settings are using the canvas type: UpdateUserInterface(); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 03b3e05b39..8a4d8805b8 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -106,8 +106,6 @@ public: */ void UpdateUserInterface(); - void Process_Special_Functions( wxCommandEvent& event ); - /** * Refresh the library tree and redraw the window */ @@ -137,6 +135,8 @@ public: void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); + void SelectLayer( wxCommandEvent& event ); + // The Tool Framework initalization, for GAL mode void setupTools(); @@ -163,7 +163,9 @@ public: /** * Called from the main toolbar to load a footprint from board mainly to edit it. */ - void LoadModuleFromBoard( wxCommandEvent& event ); + void LoadFootprintFromBoard( wxCommandEvent& event ); + + void SaveFootprintToBoard( wxCommandEvent& event ); void LoadModuleFromLibrary( LIB_ID aFPID ); @@ -213,6 +215,8 @@ public: /// there is no selection in the tree. LIB_ID GetTargetFPID() const; + void ClearModify(); + // importing / exporting Footprint /** * Create a file containing only one footprint. @@ -319,6 +323,11 @@ public: */ void RegenerateLibraryTree(); + void RefreshLibraryTree(); + + /// Reloads displayed items and sets view. + void UpdateView(); + void FocusOnLibID( const LIB_ID& aLibID ); void KiwayMailIn( KIWAY_EXPRESS& mail ) override; @@ -344,9 +353,6 @@ protected: */ void updateTitle(); - /// Reloads displayed items and sets view. - void updateView(); - void restoreLastFootprint(); void retainLastFootprint(); diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 5f7b61d04b..22b440c24c 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -21,38 +21,26 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <3d_viewer/eda_3d_viewer.h> -#include -#include -#include -#include #include -#include #include #include #include -#include -#include #include #include -#include -#include #include #include #include #include -#include #include #include #include -#include #include #include using namespace std::placeholders; -void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event ) +void FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( wxCommandEvent& event ) { LoadFootprintFromBoard( NULL ); } @@ -100,7 +88,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID) GetScreen()->ClrModify(); - updateView(); + UpdateView(); GetCanvas()->Refresh(); // Update the save items if needed. @@ -116,202 +104,18 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID) } -void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) +void FOOTPRINT_EDIT_FRAME::SelectLayer( wxCommandEvent& event ) { - int id = event.GetId(); - wxPoint pos; + SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) ); - wxGetMousePosition( &pos.x, &pos.y ); - pos.y += 20; + if( GetDisplayOptions().m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ) + GetCanvas()->Refresh(); +} - switch( id ) - { - case ID_MODEDIT_NEW_MODULE: - { - LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId(); - MODULE* module = CreateNewFootprint( wxEmptyString ); - if( !module ) - break; - - if( !Clear_Pcb( true ) ) - break; - - GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); - AddModuleToBoard( module ); - - // Initialize data relative to nets and netclasses (for a new - // module the defaults are used) - // This is mandatory to handle and draw pads - GetBoard()->BuildListOfNets(); - module->SetPosition( wxPoint( 0, 0 ) ); - - if( GetBoard()->GetFirstFootprint() ) - GetBoard()->GetFirstFootprint()->ClearFlags(); - - Zoom_Automatique( false ); - GetScreen()->SetModify(); - - // If selected from the library tree then go ahead and save it there - if( !selected.GetLibNickname().empty() ) - { - LIB_ID fpid = module->GetFPID(); - fpid.SetLibNickname( selected.GetLibNickname() ); - module->SetFPID( fpid ); - SaveFootprint( module ); - GetScreen()->ClrModify(); - } - - updateView(); - GetCanvas()->Refresh(); - Update3DView( true ); - - SyncLibraryTree( false ); - } - break; - - case ID_MODEDIT_NEW_MODULE_FROM_WIZARD: - { - LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId(); - - if( IsContentModified() ) - { - if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. " - "Save changes?" ), - [&]() -> bool - { - return SaveFootprint( GetBoard()->GetFirstFootprint() ); - } ) ) - { - break; - } - } - - FOOTPRINT_WIZARD_FRAME* wizard = - (FOOTPRINT_WIZARD_FRAME*) Kiway().Player( FRAME_FOOTPRINT_WIZARD, true, this ); - - if( wizard->ShowModal( NULL, this ) ) - { - // Creates the new footprint from python script wizard - MODULE* module = wizard->GetBuiltFootprint(); - - if( module ) // i.e. if create module command is OK - { - Clear_Pcb( false ); - - GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); - // Add the new object to board - AddModuleToBoard( module ); - - // Initialize data relative to nets and netclasses (for a new - // module the defaults are used) - // This is mandatory to handle and draw pads - GetBoard()->BuildListOfNets(); - module->SetPosition( wxPoint( 0, 0 ) ); - module->ClearFlags(); - - Zoom_Automatique( false ); - GetScreen()->SetModify(); - - // If selected from the library tree then go ahead and save it there - if( !selected.GetLibNickname().empty() ) - { - LIB_ID fpid = module->GetFPID(); - fpid.SetLibNickname( selected.GetLibNickname() ); - module->SetFPID( fpid ); - SaveFootprint( module ); - GetScreen()->ClrModify(); - } - - updateView(); - GetCanvas()->Refresh(); - Update3DView( true ); - - SyncLibraryTree( false ); - } - } - - wizard->Destroy(); - } - break; - - case ID_MODEDIT_SAVE: - if( !GetBoard()->GetFirstFootprint() ) // no loaded footprint - break; - - if( GetTargetFPID() == GetLoadedFPID() ) - { - if( SaveFootprint( GetBoard()->GetFirstFootprint() ) ) - { - m_toolManager->GetView()->Update( GetBoard()->GetFirstFootprint() ); - - GetCanvas()->ForceRefresh(); - GetScreen()->ClrModify(); - } - } - - m_treePane->GetLibTree()->RefreshLibTree(); - break; - - case ID_MODEDIT_SAVE_AS: - if( GetTargetFPID().GetLibItemName().empty() ) - { - // Save Library As - const wxString& src_libNickname = GetTargetFPID().GetLibNickname(); - wxString src_libFullName = Prj().PcbFootprintLibs()->GetFullURI( src_libNickname ); - - if( SaveLibraryAs( src_libFullName ) ) - SyncLibraryTree( true ); - } - else if( GetTargetFPID() == GetLoadedFPID() ) - { - // Save Board Footprint As - MODULE* footprint = GetBoard()->GetFirstFootprint(); - - if( footprint && SaveFootprintAs( footprint ) ) - { - m_footprintNameWhenLoaded = footprint->GetFPID().GetLibItemName(); - m_toolManager->GetView()->Update( footprint ); - GetScreen()->ClrModify(); - - GetCanvas()->ForceRefresh(); - SyncLibraryTree( true ); - } - } - else - { - // Save Selected Footprint As - MODULE* footprint = LoadFootprint( GetTargetFPID() ); - - if( footprint && SaveFootprintAs( footprint ) ) - SyncLibraryTree( true ); - } - - m_treePane->GetLibTree()->RefreshLibTree(); - break; - - case ID_ADD_FOOTPRINT_TO_BOARD: - SaveFootprintToBoard( true ); - break; - - case ID_TOOLBARH_PCB_SELECT_LAYER: - SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) ); - - if( GetDisplayOptions().m_ContrastModeDisplay != - HIGH_CONTRAST_MODE::NORMAL ) - { - GetCanvas()->Refresh(); - } - break; - - case ID_MODEDIT_CHECK: - // Currently: not implemented - break; - - default: - wxFAIL_MSG( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ); - break; - } +void FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( wxCommandEvent& event ) +{ + SaveFootprintToBoard( true ); } diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 46e204865f..6e4247c56b 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -300,7 +300,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module( const wxString& aName ) module->SetPosition( wxPoint( 0, 0 ) ); GetBoard()->BuildListOfNets(); - updateView(); + UpdateView(); return module; } @@ -1007,7 +1007,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint() ClearUndoRedoList(); GetScreen()->ClrModify(); - updateView(); + UpdateView(); GetCanvas()->Refresh(); return true; diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index b966916ae9..1cc18ba465 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -151,7 +151,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint ) } Update3DView( true ); - updateView(); + UpdateView(); GetCanvas()->Refresh(); m_treePane->GetLibTree()->RefreshLibTree(); // update any previously-highlighted items diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 2bbdcda4ea..5e8677810b 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -88,7 +88,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() submenuExport->Add( PCB_ACTIONS::exportFootprint ); submenuExport->Add( _( "Export View as &PNG..." ), _( "Create a PNG file from the current view" ), - ID_MODEDIT_SAVE_PNG, + ID_FPEDIT_SAVE_PNG, plot_xpm ); fileMenu->Add( submenuExport ); @@ -213,7 +213,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() toolsMenu->Add( _( "&Load Footprint from PCB..." ), _( "Load a footprint from the current board into the editor" ), - ID_MODEDIT_LOAD_MODULE_FROM_BOARD, + ID_LOAD_FOOTPRINT_FROM_BOARD, load_module_board_xpm ); toolsMenu->Add( _( "&Insert Footprint on PCB" ), diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 86ea4fe520..68bb6fb763 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -97,14 +97,7 @@ enum pcbnew_ids ID_TOOLBARH_PCB_SELECT_LAYER, - // ID used in module editor: - ID_MODEDIT_CHECK, - ID_MODEDIT_SAVE, - ID_MODEDIT_SAVE_AS, - ID_MODEDIT_SAVE_PNG, - ID_MODEDIT_NEW_MODULE, - ID_MODEDIT_NEW_MODULE_FROM_WIZARD, - ID_MODEDIT_LOAD_MODULE_FROM_BOARD, + ID_FPEDIT_SAVE_PNG, ID_MODVIEW_LIB_FILTER, ID_MODVIEW_LIB_LIST, @@ -122,6 +115,7 @@ enum pcbnew_ids ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, ID_ADD_FOOTPRINT_TO_BOARD, + ID_LOAD_FOOTPRINT_FROM_BOARD, ID_PCBNEW_END_LIST }; diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 219f6417a0..c1ae45d502 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -84,7 +84,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->Add( PCB_ACTIONS::defaultPadProperties ); m_mainToolBar->AddScaledSeparator( this ); - m_mainToolBar->AddTool( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString, + m_mainToolBar->AddTool( ID_LOAD_FOOTPRINT_FROM_BOARD, wxEmptyString, KiScaledBitmap( load_module_board_xpm, this ), _( "Load footprint from current board" ) ); @@ -92,13 +92,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() KiScaledBitmap( export_xpm, this ), _( "Insert footprint into current board" ) ); -#if 0 // Currently there is no check footprint function defined, so do not show this tool - m_mainToolBar->AddScaledSeparator( this ); - m_mainToolBar->AddTool( ID_MODEDIT_CHECK, wxEmptyString, - KiScaledBitmap( module_check_xpm, this ), - _( "Check footprint" ) ); -#endif - m_mainToolBar->AddScaledSeparator( this ); // Grid selection choice box. diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 11867a523d..50fee5af78 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -36,7 +36,8 @@ #include #include #include - +#include +#include FOOTPRINT_EDITOR_TOOLS::FOOTPRINT_EDITOR_TOOLS() : PCB_TOOL_BASE( "pcbnew.ModuleEditor" ), @@ -125,32 +126,166 @@ bool FOOTPRINT_EDITOR_TOOLS::Init() int FOOTPRINT_EDITOR_TOOLS::NewFootprint( const TOOL_EVENT& aEvent ) { - wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_NEW_MODULE ); - getEditFrame()->Process_Special_Functions( evt ); + LIB_ID selected = m_frame->GetTreeFPID(); + MODULE* newFootprint = m_frame->CreateNewFootprint( wxEmptyString ); + + if( !newFootprint ) + return 0; + + if( !m_frame->Clear_Pcb( true ) ) + return 0; + + canvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); + m_frame->AddModuleToBoard( newFootprint ); + + // Initialize data relative to nets and netclasses (for a new + // module the defaults are used) + // This is mandatory to handle and draw pads + board()->BuildListOfNets(); + newFootprint->SetPosition( wxPoint( 0, 0 ) ); + newFootprint->ClearFlags(); + + m_frame->Zoom_Automatique( false ); + m_frame->GetScreen()->SetModify(); + + // If selected from the library tree then go ahead and save it there + if( !selected.GetLibNickname().empty() ) + { + LIB_ID fpid = newFootprint->GetFPID(); + fpid.SetLibNickname( selected.GetLibNickname() ); + newFootprint->SetFPID( fpid ); + m_frame->SaveFootprint( newFootprint ); + m_frame->ClearModify(); + } + + m_frame->UpdateView(); + m_frame->Update3DView( true ); + + m_frame->SyncLibraryTree( false ); return 0; } int FOOTPRINT_EDITOR_TOOLS::CreateFootprint( const TOOL_EVENT& aEvent ) { - wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_NEW_MODULE_FROM_WIZARD ); - getEditFrame()->Process_Special_Functions( evt ); + LIB_ID selected = m_frame->GetTreeFPID(); + + if( m_frame->IsContentModified() ) + { + if( !HandleUnsavedChanges( m_frame, _( "The current footprint has been modified. " + "Save changes?" ), + [&]() -> bool + { + return m_frame->SaveFootprint( footprint() ); + } ) ) + { + return 0; + } + } + + auto* wizard = (FOOTPRINT_WIZARD_FRAME*) m_frame->Kiway().Player( FRAME_FOOTPRINT_WIZARD, + true, m_frame ); + + if( wizard->ShowModal( NULL, m_frame ) ) + { + // Creates the new footprint from python script wizard + MODULE* newFootprint = wizard->GetBuiltFootprint(); + + if( newFootprint ) // i.e. if create module command is OK + { + m_frame->Clear_Pcb( false ); + + canvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); + // Add the new object to board + m_frame->AddModuleToBoard( newFootprint ); + + // Initialize data relative to nets and netclasses (for a new + // module the defaults are used) + // This is mandatory to handle and draw pads + board()->BuildListOfNets(); + newFootprint->SetPosition( wxPoint( 0, 0 ) ); + newFootprint->ClearFlags(); + + m_frame->Zoom_Automatique( false ); + m_frame->GetScreen()->SetModify(); + + // If selected from the library tree then go ahead and save it there + if( !selected.GetLibNickname().empty() ) + { + LIB_ID fpid = newFootprint->GetFPID(); + fpid.SetLibNickname( selected.GetLibNickname() ); + newFootprint->SetFPID( fpid ); + m_frame->SaveFootprint( newFootprint ); + m_frame->ClearModify(); + } + + m_frame->UpdateView(); + canvas()->Refresh(); + m_frame->Update3DView( true ); + + m_frame->SyncLibraryTree( false ); + } + } + + wizard->Destroy(); return 0; } int FOOTPRINT_EDITOR_TOOLS::Save( const TOOL_EVENT& aEvent ) { - wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE ); - getEditFrame()->Process_Special_Functions( evt ); + if( !footprint() ) // no loaded footprint + return 0; + + if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() ) + { + if( m_frame->SaveFootprint( footprint() ) ) + { + view()->Update( footprint() ); + + canvas()->ForceRefresh(); + m_frame->ClearModify(); + } + } + + m_frame->RefreshLibraryTree(); return 0; } int FOOTPRINT_EDITOR_TOOLS::SaveAs( const TOOL_EVENT& aEvent ) { - wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE_AS ); - getEditFrame()->Process_Special_Functions( evt ); + if( m_frame->GetTargetFPID().GetLibItemName().empty() ) + { + // Save Library As + const wxString& src_libNickname = m_frame->GetTargetFPID().GetLibNickname(); + wxString src_libFullName = m_frame->Prj().PcbFootprintLibs()->GetFullURI( src_libNickname ); + + if( m_frame->SaveLibraryAs( src_libFullName ) ) + m_frame->SyncLibraryTree( true ); + } + else if( m_frame->GetTargetFPID() == m_frame->GetLoadedFPID() ) + { + // Save Board Footprint As + if( footprint() && m_frame->SaveFootprintAs( footprint() ) ) + { + view()->Update( footprint() ); + m_frame->ClearModify(); + + canvas()->ForceRefresh(); + m_frame->SyncLibraryTree( true ); + } + } + else + { + // Save Selected Footprint As + MODULE* footprint = m_frame->LoadFootprint( m_frame->GetTargetFPID() ); + + if( footprint && m_frame->SaveFootprintAs( footprint ) ) + m_frame->SyncLibraryTree( true ); + } + + m_frame->RefreshLibraryTree(); return 0; } diff --git a/pcbnew/tools/pcb_tool_base.h b/pcbnew/tools/pcb_tool_base.h index 541003f8d6..402f6c5504 100644 --- a/pcbnew/tools/pcb_tool_base.h +++ b/pcbnew/tools/pcb_tool_base.h @@ -159,7 +159,7 @@ protected: BOARD* board() const { return getModel(); } - MODULE* module() const + MODULE* footprint() const { return board()->GetFirstFootprint(); } diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 8aa4f8967a..f83651795c 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -653,7 +653,7 @@ int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent ) // The clipboard can contain two different things, an entire kicad_pcb // or a single module - if( isFootprintEditor && ( !board() || !module() ) ) + if( isFootprintEditor && ( !board() || !footprint() ) ) { return 0; }