Picker Tools: make sure we know what tool we are

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/14621
This commit is contained in:
Mike Williams 2023-05-01 11:01:48 -04:00
parent 6618cda214
commit 04a53ea40d
12 changed files with 32 additions and 19 deletions

View File

@ -26,6 +26,7 @@
#include <tool/picker_tool.h>
#include <view/view_controls.h>
#include <eda_draw_frame.h>
#include <wx/debug.h>
void PICKER_TOOL_BASE::reset()
@ -77,7 +78,12 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
KIGFX::VIEW_CONTROLS* controls = getViewControls();
int finalize_state = WAIT_CANCEL;
m_frame->PushTool( aEvent );
wxCHECK_MSG( aEvent.Parameter<const TOOL_EVENT*>(), -1,
wxT( "PICKER_TOOL::Main() called without a source event" ) );
const TOOL_EVENT sourceEvent = *aEvent.Parameter<const TOOL_EVENT*>();
m_frame->PushTool( sourceEvent );
Activate();
setControls();
@ -193,7 +199,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
reset();
controls->ForceCursorPosition( false );
m_frame->PopTool( aEvent );
m_frame->PopTool( sourceEvent );
return 0;
}

View File

@ -1353,7 +1353,7 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -649,7 +649,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}
@ -739,7 +739,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}
@ -1167,7 +1167,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
return highlightNet( m_toolMgr, aPos );
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -397,7 +397,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -476,7 +476,7 @@ int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PL_ACTIONS::selectionActivate, false );
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -1589,7 +1589,7 @@ int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
return false; // drill origin is a one-shot; don't continue with tool
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -1815,7 +1815,7 @@ int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
}
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -2420,7 +2420,8 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
m_statusPopup->Popup();
canvas()->SetStatusPopup( m_statusPopup->GetPanel() );
m_toolMgr->RunAction( ACTIONS::pickerSubTool, true );
TOOL_EVENT subtoolEvent = PCB_ACTIONS::pickerSubTool.MakeEvent();
m_toolMgr->RunAction( ACTIONS::pickerSubTool, true, (void*) &subtoolEvent );
while( !done )
{

View File

@ -131,7 +131,6 @@ int GROUP_TOOL::GroupProperties( const TOOL_EVENT& aEvent )
int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
{
std::string tool = "pcbnew.EditGroups.selectNewMember";
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
STATUS_TEXT_POPUP statusPopup( frame() );
bool done = false;
@ -201,7 +200,7 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
statusPopup.Popup();
canvas()->SetStatusPopup( statusPopup.GetPanel() );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
while( !done )
{

View File

@ -542,7 +542,7 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
return false; // drill origin is a one-shot; don't continue with tool
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
}
return 0;
@ -655,7 +655,7 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->Refresh();
} );
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
return 0;
}

View File

@ -44,8 +44,16 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
PCB_GRID_HELPER grid( m_toolMgr, frame->GetMagneticItemsSettings() );
int finalize_state = WAIT_CANCEL;
TOOL_EVENT sourceEvent;
if( aEvent.IsAction( &ACTIONS::pickerTool ) )
frame->PushTool( aEvent );
{
wxCHECK_MSG( aEvent.Parameter<const TOOL_EVENT*>(), -1,
wxT( "PCB_PICKER_TOOL::Main() called without a source event" ) );
sourceEvent = *aEvent.Parameter<const TOOL_EVENT*>();
frame->PushTool( sourceEvent );
}
Activate();
setControls();
@ -174,7 +182,7 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
controls->ShowCursor( false );
if( aEvent.IsAction( &ACTIONS::pickerTool ) )
frame->PopTool( aEvent );
frame->PopTool( sourceEvent );
return 0;
}

View File

@ -164,7 +164,6 @@ int POSITION_RELATIVE_TOOL::RelativeItemSelectionMove( const VECTOR2I& aPosAncho
int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent )
{
std::string tool = "pcbnew.PositionRelative.selectReferenceItem";
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
STATUS_TEXT_POPUP statusPopup( frame() );
bool done = false;
@ -220,7 +219,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
statusPopup.Popup();
canvas()->SetStatusPopup( statusPopup.GetPanel() );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, (void*) &aEvent );
while( !done )
{