Cancel or commit pad edit mode when switching footprints.
Fixes https://gitlab.com/kicad/code/kicad/issues/10209
This commit is contained in:
parent
8ef7252330
commit
85805b95ba
|
@ -48,6 +48,7 @@
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
#include <footprint_editor_settings.h>
|
#include <footprint_editor_settings.h>
|
||||||
#include "footprint_viewer_frame.h"
|
#include "footprint_viewer_frame.h"
|
||||||
|
#include "tools/pad_tool.h"
|
||||||
#include <wx/choicdlg.h>
|
#include <wx/choicdlg.h>
|
||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
|
|
||||||
|
@ -784,6 +785,11 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( FOOTPRINT* aFootprint )
|
||||||
if( !aFootprint ) // Happen if no footprint loaded
|
if( !aFootprint ) // Happen if no footprint loaded
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
PAD_TOOL* padTool = m_toolManager->GetTool<PAD_TOOL>();
|
||||||
|
|
||||||
|
if( padTool->InPadEditMode() )
|
||||||
|
m_toolManager->RunAction( PCB_ACTIONS::recombinePad, true );
|
||||||
|
|
||||||
wxString libraryName = aFootprint->GetFPID().GetLibNickname();
|
wxString libraryName = aFootprint->GetFPID().GetLibNickname();
|
||||||
wxString footprintName = aFootprint->GetFPID().GetLibItemName();
|
wxString footprintName = aFootprint->GetFPID().GetLibItemName();
|
||||||
bool nameChanged = m_footprintNameWhenLoaded != footprintName;
|
bool nameChanged = m_footprintNameWhenLoaded != footprintName;
|
||||||
|
@ -879,7 +885,6 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TOOL_MANAGER* toolMgr = pcbframe->GetToolManager();
|
|
||||||
BOARD* mainpcb = pcbframe->GetBoard();
|
BOARD* mainpcb = pcbframe->GetBoard();
|
||||||
FOOTPRINT* sourceFootprint = nullptr;
|
FOOTPRINT* sourceFootprint = nullptr;
|
||||||
FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
|
FOOTPRINT* editorFootprint = GetBoard()->GetFirstFootprint();
|
||||||
|
@ -906,14 +911,13 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aAddNew && toolMgr->GetTool<BOARD_EDITOR_CONTROL>()->PlacingFootprint() )
|
if( aAddNew && m_toolManager->GetTool<BOARD_EDITOR_CONTROL>()->PlacingFootprint() )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "Previous footprint placement still in progress." ) );
|
DisplayError( this, _( "Previous footprint placement still in progress." ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_toolManager->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolManager->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
||||||
BOARD_COMMIT commit( pcbframe );
|
BOARD_COMMIT commit( pcbframe );
|
||||||
|
|
||||||
// Create a copy for the board, first using Clone() to keep existing Uuids, and then either
|
// 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" ) );
|
commit.Push( wxT( "Insert footprint" ) );
|
||||||
|
|
||||||
pcbframe->Raise();
|
pcbframe->Raise();
|
||||||
toolMgr->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
|
m_toolManager->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
|
||||||
}
|
}
|
||||||
|
|
||||||
newFootprint->ClearFlags();
|
newFootprint->ClearFlags();
|
||||||
|
|
|
@ -59,6 +59,17 @@ void PAD_TOOL::Reset( RESET_REASON aReason )
|
||||||
if( aReason == MODEL_RELOAD )
|
if( aReason == MODEL_RELOAD )
|
||||||
m_lastPadNumber = wxT( "1" );
|
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;
|
m_editPad = niluuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +587,7 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
|
||||||
frame()->SetActiveLayer( layer );
|
frame()->SetActiveLayer( layer );
|
||||||
|
|
||||||
if( !m_wasHighContrast )
|
if( !m_wasHighContrast )
|
||||||
m_toolMgr->RunAction( ACTIONS::highContrastMode, false );
|
m_toolMgr->RunAction( ACTIONS::highContrastMode, true );
|
||||||
|
|
||||||
if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
|
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 );
|
bool highContrast = ( opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL );
|
||||||
|
|
||||||
if( m_wasHighContrast != highContrast )
|
if( m_wasHighContrast != highContrast )
|
||||||
m_toolMgr->RunAction( ACTIONS::highContrastMode, false );
|
m_toolMgr->RunAction( ACTIONS::highContrastMode, true );
|
||||||
|
|
||||||
infoBar->Dismiss();
|
infoBar->Dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
*/
|
*/
|
||||||
int EditPad( const TOOL_EVENT& aEvent );
|
int EditPad( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
bool InPadEditMode() { return m_editPad != niluuid; }
|
||||||
|
|
||||||
wxString GetLastPadNumber() const { return m_lastPadNumber; }
|
wxString GetLastPadNumber() const { return m_lastPadNumber; }
|
||||||
void SetLastPadNumber( const wxString& aPadNumber ) { m_lastPadNumber = aPadNumber; }
|
void SetLastPadNumber( const wxString& aPadNumber ) { m_lastPadNumber = aPadNumber; }
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos
|
||||||
if( aFrom )
|
if( aFrom )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::shared_ptr<SHAPE> eshape = aPad->GetEffectiveShape( aPad->GetLayer() );
|
const std::shared_ptr<SHAPE> eshape = aPad->GetEffectiveShape();
|
||||||
|
|
||||||
// PTH reduced to only a hole do not return a valid pad shape list
|
// PTH reduced to only a hole do not return a valid pad shape list
|
||||||
if( eshape->Type() != SH_COMPOUND )
|
if( eshape->Type() != SH_COMPOUND )
|
||||||
|
|
Loading…
Reference in New Issue