diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 3f8da55722..a77141c1d1 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -48,6 +48,7 @@ #include #include #include "footprint_viewer_frame.h" +#include "tools/pad_tool.h" #include #include @@ -784,6 +785,11 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( FOOTPRINT* aFootprint ) if( !aFootprint ) // Happen if no footprint loaded return false; + PAD_TOOL* padTool = m_toolManager->GetTool(); + + if( padTool->InPadEditMode() ) + m_toolManager->RunAction( PCB_ACTIONS::recombinePad, true ); + wxString libraryName = aFootprint->GetFPID().GetLibNickname(); wxString footprintName = aFootprint->GetFPID().GetLibItemName(); bool nameChanged = m_footprintNameWhenLoaded != footprintName; @@ -879,7 +885,6 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew ) return false; } - TOOL_MANAGER* toolMgr = pcbframe->GetToolManager(); BOARD* mainpcb = pcbframe->GetBoard(); FOOTPRINT* sourceFootprint = nullptr; FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint(); @@ -906,14 +911,13 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew ) return false; } - if( aAddNew && toolMgr->GetTool()->PlacingFootprint() ) + if( aAddNew && m_toolManager->GetTool()->PlacingFootprint() ) { DisplayError( this, _( "Previous footprint placement still in progress." ) ); return false; } m_toolManager->RunAction( PCB_ACTIONS::selectionClear, true ); - toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); BOARD_COMMIT commit( pcbframe ); // Create a copy for the board, first using Clone() to keep existing Uuids, and then either @@ -960,7 +964,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew ) commit.Push( wxT( "Insert footprint" ) ); pcbframe->Raise(); - toolMgr->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint ); + m_toolManager->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint ); } newFootprint->ClearFlags(); diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 38aae5acba..cb31d76bdf 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -59,6 +59,17 @@ void PAD_TOOL::Reset( RESET_REASON aReason ) if( aReason == MODEL_RELOAD ) m_lastPadNumber = wxT( "1" ); + if( m_editPad != niluuid ) + { + PCB_DISPLAY_OPTIONS opts = frame()->GetDisplayOptions(); + bool highContrast = ( opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ); + + if( m_wasHighContrast != highContrast ) + m_toolMgr->RunAction( ACTIONS::highContrastMode, true ); + + frame()->GetInfoBar()->Dismiss(); + } + m_editPad = niluuid; } @@ -576,7 +587,7 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent ) frame()->SetActiveLayer( layer ); if( !m_wasHighContrast ) - m_toolMgr->RunAction( ACTIONS::highContrastMode, false ); + m_toolMgr->RunAction( ACTIONS::highContrastMode, true ); if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() ) { @@ -600,7 +611,7 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent ) bool highContrast = ( opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL ); if( m_wasHighContrast != highContrast ) - m_toolMgr->RunAction( ACTIONS::highContrastMode, false ); + m_toolMgr->RunAction( ACTIONS::highContrastMode, true ); infoBar->Dismiss(); } diff --git a/pcbnew/tools/pad_tool.h b/pcbnew/tools/pad_tool.h index dc4614d9e8..71a41a11be 100644 --- a/pcbnew/tools/pad_tool.h +++ b/pcbnew/tools/pad_tool.h @@ -59,6 +59,8 @@ public: */ int EditPad( const TOOL_EVENT& aEvent ); + bool InPadEditMode() { return m_editPad != niluuid; } + wxString GetLastPadNumber() const { return m_lastPadNumber; } void SetLastPadNumber( const wxString& aPadNumber ) { m_lastPadNumber = aPadNumber; } diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index 16b68d59fd..801d9d287e 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -400,7 +400,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos if( aFrom ) return; - const std::shared_ptr eshape = aPad->GetEffectiveShape( aPad->GetLayer() ); + const std::shared_ptr eshape = aPad->GetEffectiveShape(); wxASSERT( eshape->Type() == SH_COMPOUND ); const std::vector shapes =