TOOL_EVENT: make command string non-optional
We're getting segfaults in places where this isn't checked. Also, add some asserts so we can catch bad tool push/pop. Removes all uses of GetCommandStr() and makes it private.
This commit is contained in:
parent
b7ba24b2d9
commit
9304607624
|
@ -77,8 +77,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
int finalize_state = WAIT_CANCEL;
|
||||
|
||||
std::string tool = *aEvent.Parameter<std::string*>();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
Activate();
|
||||
|
||||
setControls();
|
||||
|
@ -194,7 +193,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
reset();
|
||||
controls->ForceCursorPosition( false );
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,8 +180,7 @@ const std::string TOOL_EVENT::Format() const
|
|||
ev += tmp;
|
||||
}
|
||||
|
||||
if( m_commandStr )
|
||||
ev += "cmd-str: " + ( *m_commandStr );
|
||||
ev += "cmd-str: " + m_commandStr;
|
||||
|
||||
return ev;
|
||||
}
|
||||
|
@ -212,9 +211,9 @@ bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
|
|||
|
||||
bool TOOL_EVENT::IsCancelInteractive() const
|
||||
{
|
||||
return ( ( m_commandStr && *m_commandStr == ACTIONS::cancelInteractive.GetName() )
|
||||
|| ( m_commandId && *m_commandId == ACTIONS::cancelInteractive.GetId() )
|
||||
|| ( m_actions == TA_CANCEL_TOOL ) );
|
||||
return ( ( m_commandStr == ACTIONS::cancelInteractive.GetName() )
|
||||
|| ( m_commandId && *m_commandId == ACTIONS::cancelInteractive.GetId() )
|
||||
|| ( m_actions == TA_CANCEL_TOOL ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,26 +228,24 @@ bool TOOL_EVENT::IsSelectionEvent() const
|
|||
|
||||
bool TOOL_EVENT::IsPointEditor() const
|
||||
{
|
||||
return ( ( m_commandStr && m_commandStr->find( "PointEditor" ) != GetCommandStr()->npos )
|
||||
|| ( m_commandId && *m_commandId == ACTIONS::activatePointEditor.GetId() ) );
|
||||
return ( ( m_commandStr.find( "PointEditor" ) != getCommandStr().npos )
|
||||
|| ( m_commandId && *m_commandId == ACTIONS::activatePointEditor.GetId() ) );
|
||||
}
|
||||
|
||||
|
||||
bool TOOL_EVENT::IsMoveTool() const
|
||||
{
|
||||
return ( m_commandStr
|
||||
&& m_commandStr->find( "InteractiveMove" ) != GetCommandStr()->npos );
|
||||
return ( m_commandStr.find( "InteractiveMove" ) != getCommandStr().npos );
|
||||
}
|
||||
|
||||
|
||||
bool TOOL_EVENT::IsEditorTool() const
|
||||
{
|
||||
return ( m_commandStr
|
||||
&& m_commandStr->find( "InteractiveEdit" ) != GetCommandStr()->npos );
|
||||
return ( m_commandStr.find( "InteractiveEdit" ) != getCommandStr().npos );
|
||||
}
|
||||
|
||||
|
||||
bool TOOL_EVENT::IsSimulator() const
|
||||
{
|
||||
return ( m_commandStr && m_commandStr->find( "Simulation" ) != GetCommandStr()->npos );
|
||||
return ( m_commandStr.find( "Simulation" ) != getCommandStr().npos );
|
||||
}
|
||||
|
|
|
@ -829,7 +829,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( aEvent.IsActivate() )
|
||||
{
|
||||
auto tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
|
||||
auto tool = m_toolNameIndex.find( aEvent.getCommandStr() );
|
||||
|
||||
if( tool != m_toolNameIndex.end() )
|
||||
{
|
||||
|
@ -1153,9 +1153,8 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
|||
if( GetToolHolder() && !GetToolHolder()->GetDoImmediateActions() )
|
||||
{
|
||||
// An tool-selection-event has no position
|
||||
if( mod_event.GetCommandStr()
|
||||
&& *mod_event.GetCommandStr() != GetToolHolder()->CurrentToolName()
|
||||
&& !mod_event.ForceImmediate() )
|
||||
if( mod_event.getCommandStr() != GetToolHolder()->CurrentToolName()
|
||||
&& !mod_event.ForceImmediate() )
|
||||
{
|
||||
mod_event.SetHasPosition( false );
|
||||
}
|
||||
|
|
|
@ -41,8 +41,12 @@ TOOLS_HOLDER::TOOLS_HOLDER() :
|
|||
|
||||
|
||||
// TODO: Implement an RAII mechanism for the stack PushTool/PopTool pairs
|
||||
void TOOLS_HOLDER::PushTool( const std::string& actionName )
|
||||
void TOOLS_HOLDER::PushTool( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const std::string& actionName = aEvent.getCommandStr();
|
||||
|
||||
wxASSERT_MSG( !actionName.empty(), "Pushed Empty Tool Name!" );
|
||||
|
||||
m_toolStack.push_back( actionName );
|
||||
|
||||
// Human cognitive stacking is very shallow; deeper tool stacks just get annoying
|
||||
|
@ -58,8 +62,12 @@ void TOOLS_HOLDER::PushTool( const std::string& actionName )
|
|||
}
|
||||
|
||||
|
||||
void TOOLS_HOLDER::PopTool( const std::string& actionName )
|
||||
void TOOLS_HOLDER::PopTool( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const std::string& actionName = aEvent.getCommandStr();
|
||||
|
||||
wxASSERT_MSG( !aEvent.getCommandStr().empty(), "Popped Empty Tool Name!" );
|
||||
|
||||
// Push/pop events can get out of order (such as when they're generated by the Simulator
|
||||
// frame but not processed until the mouse is back in the Schematic frame), so make sure
|
||||
// we're popping the right stack frame.
|
||||
|
@ -94,6 +102,8 @@ void TOOLS_HOLDER::PopTool( const std::string& actionName )
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
wxASSERT_MSG( false, "Popped a Tool Not on the Tool Stack!" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,12 +60,7 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason )
|
|||
|
||||
int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool;
|
||||
|
||||
if( aEvent.GetCommandStr() )
|
||||
tool = *aEvent.GetCommandStr();
|
||||
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -102,7 +97,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
// Exit zoom tool
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,8 +144,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
wxFAIL_MSG( "PlaceSymbol(): unexpected request" );
|
||||
}
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto addSymbol =
|
||||
[&]( SCH_SYMBOL* aSymbol )
|
||||
|
@ -250,9 +249,8 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = symbol
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = symbol && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -264,7 +262,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +289,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -463,8 +461,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_view->AddToPreview( image->Clone() );
|
||||
}
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -514,9 +511,8 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = image
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = image && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -528,13 +524,13 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
|
||||
if( immediateMode )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +557,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +625,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( immediateMode )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -751,8 +747,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
aEvent.Position() :
|
||||
controls->GetMousePosition() );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -790,7 +785,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsActivate() )
|
||||
|
@ -802,7 +797,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -841,7 +836,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1135,8 +1130,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
|
@ -1208,9 +1202,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = item
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -1222,7 +1215,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1252,7 +1245,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1489,8 +1482,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1526,9 +1518,8 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = item
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -1538,7 +1529,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1565,7 +1556,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1698,8 +1689,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1735,9 +1725,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = sheet
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = sheet && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -1749,7 +1738,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1780,7 +1769,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1294,7 +1294,6 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
@ -1355,7 +1354,7 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -922,8 +922,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1012,8 +1011,7 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1384,7 +1382,6 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
|||
if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
|
||||
m_frame->RecalculateConnections( NO_CLEANUP );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
|
||||
// Deactivate other tools; particularly important if another PICKER is currently running
|
||||
|
@ -1399,7 +1396,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
|
|||
return highlightNet( m_toolMgr, aPos );
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -302,8 +302,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent )
|
|||
|
||||
DRAW_SEGMENT_EVENT_PARAMS* params = aEvent.Parameter<DRAW_SEGMENT_EVENT_PARAMS*>();
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
if( aEvent.HasPosition() )
|
||||
|
@ -316,7 +315,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent )
|
|||
startSegments( params->layer, cursorPos, params->sourceSegment );
|
||||
}
|
||||
|
||||
return doDrawSegments( tool, params->layer, params->quitOnDraw );
|
||||
return doDrawSegments( aEvent, params->layer, params->quitOnDraw );
|
||||
}
|
||||
|
||||
|
||||
|
@ -331,8 +330,7 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
|||
wxString net;
|
||||
SCH_LINE* segment = nullptr;
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
Activate();
|
||||
|
||||
if( netPtr )
|
||||
|
@ -377,11 +375,11 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
|||
// If we have an unfolded wire to draw, then draw it
|
||||
if( segment )
|
||||
{
|
||||
return doDrawSegments( tool, LAYER_WIRE, false );
|
||||
return doDrawSegments( aEvent, LAYER_WIRE, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -574,7 +572,7 @@ void SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint( const std::pair<SCH_LINE*, SCH_L
|
|||
}
|
||||
|
||||
|
||||
int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType, bool aQuitOnDraw )
|
||||
int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const TOOL_EVENT& aTool, int aType, bool aQuitOnDraw )
|
||||
{
|
||||
SCH_SCREEN* screen = m_frame->GetScreen();
|
||||
SCH_LINE* segment = nullptr;
|
||||
|
@ -647,9 +645,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
|
|||
bool twoSegments = currentMode != LINE_MODE::LINE_MODE_FREE;
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = ( segment || m_busUnfold.in_progress )
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == aTool;
|
||||
bool isSyntheticClick = ( segment || m_busUnfold.in_progress ) && evt->IsActivate()
|
||||
&& evt->HasPosition() && evt->Matches( aTool );
|
||||
|
||||
setCursor();
|
||||
grid.SetMask( GRID_HELPER::ALL );
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
int TrimOverLappingWires( const TOOL_EVENT& aEvent );
|
||||
|
||||
private:
|
||||
int doDrawSegments( const std::string& aTool, int aType, bool aQuitOnDraw );
|
||||
int doDrawSegments( const TOOL_EVENT& aTool, int aType, bool aQuitOnDraw );
|
||||
SCH_LINE* startSegments( int aType, const VECTOR2D& aPos, SCH_LINE* aSegment = nullptr );
|
||||
SCH_LINE* doUnfoldBus( const wxString& aNet, const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
|
||||
void finishSegments();
|
||||
|
|
|
@ -144,20 +144,20 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
// Must be done after Activate() so that it gets set into the correct context
|
||||
controls->ShowCursor( true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
if( selection.Empty() )
|
||||
{
|
||||
// Note that it's important to go through push/pop even when the selection is empty.
|
||||
// This keeps other tools from having to special-case an empty move.
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool restore_state = false;
|
||||
bool chain_commands = false;
|
||||
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
|
||||
TOOL_EVENT copy = aEvent;
|
||||
TOOL_EVENT* evt = ©
|
||||
VECTOR2I prevPos;
|
||||
int snapLayer = UNDEFINED_LAYER;
|
||||
|
||||
|
@ -910,7 +910,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
m_dragAdditions.clear();
|
||||
m_lineConnectionCache.clear();
|
||||
m_moveInProgress = false;
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,8 +95,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -145,9 +144,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = item
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -159,7 +157,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +187,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +339,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -376,9 +373,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
|
||||
|
||||
// The tool hotkey is interpreted as a click when drawing
|
||||
bool isSyntheticClick = item
|
||||
&& evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->GetCommandStr() == tool;
|
||||
bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
|
||||
&& evt->Matches( aEvent );
|
||||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
|
@ -388,7 +384,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +404,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -542,8 +538,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -564,12 +559,12 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsActivate() )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
|
||||
|
|
|
@ -333,7 +333,6 @@ int SYMBOL_EDITOR_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
@ -401,7 +400,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( EE_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -110,8 +110,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
|
@ -120,7 +119,8 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
bool restore_state = false;
|
||||
bool chain_commands = false;
|
||||
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
|
||||
TOOL_EVENT copy = aEvent;
|
||||
TOOL_EVENT* evt = ©
|
||||
VECTOR2I prevPos;
|
||||
|
||||
if( !selection.Front()->IsNew() )
|
||||
|
@ -365,7 +365,7 @@ int SYMBOL_EDITOR_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
m_moveInProgress = false;
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,8 +207,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
EDA_UNITS units = m_frame->GetUserUnits();
|
||||
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, gerbIUScale, units, false, false );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -247,7 +246,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -263,7 +262,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
class TOOL_ACTION;
|
||||
class TOOL_MANAGER;
|
||||
class TOOL_BASE;
|
||||
class TOOLS_HOLDER;
|
||||
|
||||
/**
|
||||
* Internal (GUI-independent) event definitions.
|
||||
|
@ -368,8 +369,8 @@ public:
|
|||
|
||||
if( m_category == TC_COMMAND || m_category == TC_MESSAGE )
|
||||
{
|
||||
if( (bool) m_commandStr && (bool) aEvent.m_commandStr )
|
||||
return *m_commandStr == *aEvent.m_commandStr;
|
||||
if( !m_commandStr.empty() && !aEvent.getCommandStr().empty() )
|
||||
return m_commandStr == aEvent.m_commandStr;
|
||||
|
||||
if( (bool) m_commandId && (bool) aEvent.m_commandId )
|
||||
return *m_commandId == *aEvent.m_commandId;
|
||||
|
@ -466,11 +467,6 @@ public:
|
|||
return m_commandId;
|
||||
}
|
||||
|
||||
std::optional<std::string> GetCommandStr() const
|
||||
{
|
||||
return m_commandStr;
|
||||
}
|
||||
|
||||
void SetMousePosition( const VECTOR2D& aP )
|
||||
{
|
||||
m_mousePos = aP;
|
||||
|
@ -478,9 +474,13 @@ public:
|
|||
|
||||
private:
|
||||
friend class TOOL_DISPATCHER;
|
||||
friend class TOOL_MANAGER;
|
||||
friend class TOOLS_HOLDER;
|
||||
|
||||
void init();
|
||||
|
||||
const std::string& getCommandStr() const { return m_commandStr; }
|
||||
|
||||
void setMouseDragOrigin( const VECTOR2D& aP )
|
||||
{
|
||||
m_mouseDragOrigin = aP;
|
||||
|
@ -551,7 +551,7 @@ private:
|
|||
TOOL_BASE* m_firstResponder;
|
||||
|
||||
std::optional<int> m_commandId;
|
||||
std::optional<std::string> m_commandStr;
|
||||
std::string m_commandStr;
|
||||
};
|
||||
|
||||
typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
|
||||
|
|
|
@ -110,8 +110,20 @@ public:
|
|||
* "tools", such as rectangle and circle, or wire and bus. So each user-level tool is
|
||||
* actually a #TOOL_ACTION.
|
||||
*/
|
||||
virtual void PushTool( const std::string& actionName );
|
||||
virtual void PopTool( const std::string& actionName );
|
||||
|
||||
/**
|
||||
* @brief Pushes a tool to the stack.
|
||||
*
|
||||
* @param aEvent The event that is starting the tool to be pushed to the stack.
|
||||
*/
|
||||
virtual void PushTool( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* @brief Pops a tool from the stack.
|
||||
*
|
||||
* @param aEvent The event that started the tool that was pushed to the stack.
|
||||
*/
|
||||
virtual void PopTool( const TOOL_EVENT& aEvent );
|
||||
|
||||
bool ToolStackIsEmpty() { return m_toolStack.empty(); }
|
||||
|
||||
|
|
|
@ -78,8 +78,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -122,7 +121,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
cleanup();
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +137,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -226,8 +225,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -333,7 +331,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
getViewControls()->SetAutoPan( false );
|
||||
getViewControls()->CaptureCursor( false );
|
||||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
unique_peers.insert( drawItem->GetPeer() );
|
||||
}
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
|
@ -127,7 +126,8 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
bool restore_state = false;
|
||||
bool chain_commands = false;
|
||||
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
|
||||
TOOL_EVENT copy = aEvent;
|
||||
TOOL_EVENT* evt = ©
|
||||
VECTOR2I prevPos;
|
||||
|
||||
if( !selection.Front()->IsNew() )
|
||||
|
@ -301,7 +301,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->PostEvent( EVENTS::SelectedEvent );
|
||||
|
||||
m_moveInProgress = false;
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,6 @@ int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
|
|||
|
||||
int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
|
||||
|
||||
// Deactivate other tools; particularly important if another PICKER is currently running
|
||||
|
@ -455,7 +454,7 @@ int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( PL_ACTIONS::selectionActivate, false );
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
|
|||
|
||||
MICROWAVE_PLACER placer( this, aEvent.Parameter<MICROWAVE_FOOTPRINT_SHAPE>() );
|
||||
|
||||
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer,
|
||||
_( "Place microwave feature" ),
|
||||
doInteractiveItemPlacement( aEvent, &placer, _( "Place microwave feature" ),
|
||||
IPO_REPEAT | IPO_ROTATE | IPO_FLIP );
|
||||
|
||||
return 0;
|
||||
|
@ -114,8 +113,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
|||
KIGFX::VIEW_CONTROLS& controls = *getViewControls();
|
||||
PCB_EDIT_FRAME& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
frame.PushTool( tool );
|
||||
frame.PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -161,7 +159,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
|||
cleanup();
|
||||
else
|
||||
{
|
||||
frame.PopTool( tool );
|
||||
frame.PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +175,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
frame.PopTool( tool );
|
||||
frame.PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,8 +274,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
// Deselect all items
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
frame()->PushTool( tool );
|
||||
frame()->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -338,7 +337,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
m_savedSizes = m_router->Sizes();
|
||||
|
||||
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1534,8 +1534,7 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = aEvent.GetCommandStr().value();
|
||||
frame->PushTool( tool );
|
||||
frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1632,7 +1631,7 @@ int ROUTER_TOOL::RouteSelected( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
m_iface->SetCommitFlags( 0 );
|
||||
frame->PopTool( tool );
|
||||
frame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1654,8 +1653,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
// Deselect all items
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
frame->PushTool( tool );
|
||||
frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1684,7 +1682,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
frame->PopTool( tool );
|
||||
frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsActivate() )
|
||||
|
@ -1696,7 +1694,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
frame->PopTool( tool );
|
||||
frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1769,7 +1767,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( m_cancelled )
|
||||
{
|
||||
frame->PopTool( tool );
|
||||
frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -982,8 +982,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1058,7 +1057,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1074,7 +1073,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1570,7 +1569,6 @@ void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME*
|
|||
|
||||
int BOARD_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||
|
||||
// Deactivate other tools; particularly important if another PICKER is currently running
|
||||
|
@ -1584,7 +1582,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, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1539,7 +1539,6 @@ int BOARD_INSPECTION_TOOL::ClearHighlight( const TOOL_EVENT& aEvent )
|
|||
|
||||
int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||
BOARD* board = getModel<BOARD>();
|
||||
|
||||
|
@ -1610,7 +1609,7 @@ int BOARD_INSPECTION_TOOL::LocalRatsnestTool( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -554,8 +554,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
|||
// do not capture or auto-pan until we start placing the table
|
||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
|
@ -586,7 +585,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
|||
|
||||
if( evt->IsCancelInteractive() )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
cancelled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -617,7 +616,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
cancelled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -638,7 +637,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
|||
if( destLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
|
||||
{
|
||||
// The user did not pick any layer.
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
cancelled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -663,7 +662,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
|||
}
|
||||
|
||||
commit.Push( wxT( "Placing items" ) );
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -313,11 +313,10 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
Activate();
|
||||
|
||||
while( drawShape( tool, &line, startingPoint ) )
|
||||
while( drawShape( aEvent, &line, startingPoint ) )
|
||||
{
|
||||
if( line )
|
||||
{
|
||||
|
@ -387,11 +386,10 @@ int DRAWING_TOOL::DrawRectangle( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
Activate();
|
||||
|
||||
while( drawShape( tool, &rect, startingPoint ) )
|
||||
while( drawShape( aEvent, &rect, startingPoint ) )
|
||||
{
|
||||
if( rect )
|
||||
{
|
||||
|
@ -447,11 +445,10 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
|
|||
if( aEvent.HasPosition() )
|
||||
startingPoint = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
Activate();
|
||||
|
||||
while( drawShape( tool, &circle, startingPoint ) )
|
||||
while( drawShape( aEvent, &circle, startingPoint ) )
|
||||
{
|
||||
if( circle )
|
||||
{
|
||||
|
@ -495,14 +492,13 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
|
|||
arc->SetShape( SHAPE_T::ARC );
|
||||
arc->SetFlags( IS_NEW );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
Activate();
|
||||
|
||||
if( aEvent.HasPosition() )
|
||||
startingPoint = aEvent.Position();
|
||||
|
||||
while( drawArc( tool, &arc, startingPoint ) )
|
||||
while( drawArc( aEvent, &arc, startingPoint ) )
|
||||
{
|
||||
if( arc )
|
||||
{
|
||||
|
@ -553,8 +549,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_view->AddToPreview( image->Clone() );
|
||||
}
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
|
@ -610,13 +605,13 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
|
||||
if( immediateMode )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -643,7 +638,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +710,7 @@ int DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( immediateMode )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -797,8 +792,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
|
@ -832,7 +826,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +842,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1079,8 +1073,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
|
@ -1130,7 +1123,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1150,7 +1143,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1560,8 +1553,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &selectedItems );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1636,7 +1628,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
m_controls->ForceCursorPosition( false );
|
||||
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1659,8 +1651,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -1701,7 +1692,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
|
||||
// Usually, we do not need to change twice the anchor position,
|
||||
// so deselect the active tool
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsClick( BUT_RIGHT ) )
|
||||
|
@ -1710,7 +1701,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -1759,7 +1750,7 @@ static void updateSegmentFromGeometryMgr( const KIGFX::PREVIEW::TWO_POINT_GEOMET
|
|||
}
|
||||
|
||||
|
||||
bool DRAWING_TOOL::drawShape( const std::string& aTool, PCB_SHAPE** aGraphic,
|
||||
bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||
std::optional<VECTOR2D> aStartingPoint )
|
||||
{
|
||||
SHAPE_T shape = ( *aGraphic )->GetShape();
|
||||
|
@ -2152,7 +2143,7 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
|
|||
}
|
||||
|
||||
|
||||
bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic,
|
||||
bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||
std::optional<VECTOR2D> aStartingPoint )
|
||||
{
|
||||
PCB_SHAPE*& graphic = *aGraphic;
|
||||
|
@ -2498,8 +2489,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
status.SetTextColor( wxColour( 255, 0, 0 ) );
|
||||
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
m_frame->PushTool( tool );
|
||||
m_frame->PushTool( aEvent );
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
|
@ -2554,7 +2544,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
// We've handled the cancel event. Don't cancel other tools
|
||||
evt->SetPassEvent( false );
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2574,7 +2564,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->PopTool( tool );
|
||||
m_frame->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3216,8 +3206,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
|
|||
|
||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
|
||||
|
||||
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer, _( "Place via" ),
|
||||
IPO_REPEAT | IPO_SINGLE_CLICK );
|
||||
doInteractiveItemPlacement( aEvent, &placer, _( "Place via" ), IPO_REPEAT | IPO_SINGLE_CLICK );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -229,7 +229,8 @@ private:
|
|||
* @return False if the tool was canceled before the origin was set or origin and end are
|
||||
* the same point.
|
||||
*/
|
||||
bool drawShape( const std::string& aTool, PCB_SHAPE** aGraphic, std::optional<VECTOR2D> aStartingPoint );
|
||||
bool drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||
std::optional<VECTOR2D> aStartingPoint );
|
||||
|
||||
/**
|
||||
* Start drawing an arc.
|
||||
|
@ -239,7 +240,8 @@ private:
|
|||
* @return False if the tool was canceled before the origin was set or origin and end are
|
||||
* the same point.
|
||||
*/
|
||||
bool drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, std::optional<VECTOR2D> aStartingPoint );
|
||||
bool drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
|
||||
std::optional<VECTOR2D> aStartingPoint );
|
||||
|
||||
/**
|
||||
* Draw a polygon, that is added as a zone or a keepout area.
|
||||
|
@ -274,7 +276,7 @@ private:
|
|||
|
||||
/**
|
||||
* Clamps the end vector to respect numeric limits of difference representation
|
||||
*
|
||||
*
|
||||
* @param aOrigin - the origin vector.
|
||||
* @param aEnd - the end vector.
|
||||
* @return clamped end vector.
|
||||
|
@ -304,7 +306,7 @@ private:
|
|||
|
||||
/**
|
||||
* Clamps the end vector to respect numeric limits of radius representation
|
||||
*
|
||||
*
|
||||
* @param aOrigin - the origin vector.
|
||||
* @param aEnd - the end vector.
|
||||
* @return clamped end vector.
|
||||
|
|
|
@ -1431,8 +1431,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
editFrame->PushTool( tool );
|
||||
editFrame->PushTool( aEvent );
|
||||
|
||||
std::vector<BOARD_ITEM*> lockedItems;
|
||||
Activate();
|
||||
|
@ -1473,7 +1472,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
wxBell();
|
||||
canvas()->Refresh();
|
||||
editFrame->PopTool( tool );
|
||||
editFrame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1669,7 +1668,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
m_commit->Push( _( "Delete" ) );
|
||||
|
||||
editFrame->PopTool( tool );
|
||||
editFrame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2087,12 +2086,14 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
|
|||
|
||||
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
|
||||
CLIPBOARD_IO io;
|
||||
PCB_GRID_HELPER grid( m_toolMgr,
|
||||
getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
|
||||
TOOL_EVENT selectReferencePoint( aEvent.Category(), aEvent.Action(),
|
||||
"pcbnew.InteractiveEdit.selectReferencePoint",
|
||||
TOOL_ACTION_SCOPE::AS_GLOBAL );
|
||||
|
||||
frame()->PushTool( tool );
|
||||
frame()->PushTool( selectReferencePoint );
|
||||
Activate();
|
||||
|
||||
PCB_SELECTION& selection = m_selectionTool->RequestSelection(
|
||||
|
@ -2128,7 +2129,7 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
|||
_( "Copy canceled" ),
|
||||
refPoint ) )
|
||||
{
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( selectReferencePoint );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -2144,7 +2145,7 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
|
|||
frame()->SetStatusText( _( "Selection copied" ) );
|
||||
}
|
||||
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( selectReferencePoint );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2157,7 +2158,7 @@ int EDIT_TOOL::cutToClipboard( const TOOL_EVENT& aEvent )
|
|||
// N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items
|
||||
// that were copied to the clipboard, no more, no fewer. Filtering for locked item, if
|
||||
// any will be done in the copyToClipboard() routine
|
||||
TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL );
|
||||
TOOL_EVENT evt = aEvent;
|
||||
evt.SetParameter( PCB_ACTIONS::REMOVE_FLAGS::CUT );
|
||||
Remove( evt );
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ private:
|
|||
bool invokeInlineRouter( int aDragMode );
|
||||
bool isRouterActive() const;
|
||||
|
||||
int doMoveSelection( TOOL_EVENT aEvent, bool aPickReference = false );
|
||||
int doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference = false );
|
||||
|
||||
VECTOR2I getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSourceBBox,
|
||||
const VECTOR2D& aBBoxOffset );
|
||||
|
|
|
@ -439,9 +439,7 @@ VECTOR2I EDIT_TOOL::getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSo
|
|||
}
|
||||
|
||||
|
||||
// Note: aEvent MUST NOT be const&; the source will get de-allocated if we go into the picker's
|
||||
// event loop.
|
||||
int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
||||
int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference )
|
||||
{
|
||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
BOARD* board = editFrame->GetBoard();
|
||||
|
@ -485,8 +483,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
|||
if( selection.Empty() )
|
||||
return 0;
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
editFrame->PushTool( tool );
|
||||
editFrame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
// Must be done after Activate() so that it gets set into the correct context
|
||||
|
@ -500,7 +497,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
|||
if( is_hover )
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
editFrame->PopTool( tool );
|
||||
editFrame->PopTool( aEvent );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -546,7 +543,8 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
|||
BOX2I originalBBox;
|
||||
bool updateBBox = true;
|
||||
PCB_GRID_HELPER grid( m_toolMgr, editFrame->GetMagneticItemsSettings() );
|
||||
TOOL_EVENT* evt = &aEvent;
|
||||
TOOL_EVENT copy = aEvent;
|
||||
TOOL_EVENT* evt = ©
|
||||
VECTOR2I prevPos;
|
||||
|
||||
bool hv45Mode = false;
|
||||
|
@ -926,7 +924,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
|||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &orig_items );
|
||||
|
||||
editFrame->PopTool( tool );
|
||||
editFrame->PopTool( aEvent );
|
||||
editFrame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
|
||||
|
||||
return restore_state ? -1 : 0;
|
||||
|
|
|
@ -299,8 +299,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
frame()->PushTool( tool );
|
||||
frame()->PushTool( aEvent );
|
||||
|
||||
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
|
||||
std::list<PAD*> selectedPads;
|
||||
|
@ -349,14 +348,14 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
commit.Revert();
|
||||
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsActivate() )
|
||||
{
|
||||
commit.Push( _( "Renumber pads" ) );
|
||||
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
||||
|
@ -452,7 +451,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
evt->IsDblClick( BUT_LEFT ) )
|
||||
{
|
||||
commit.Push( _( "Renumber pads" ) );
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
else if( evt->IsClick( BUT_RIGHT ) )
|
||||
|
@ -558,7 +557,7 @@ int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
|
|||
|
||||
PAD_PLACER placer( this );
|
||||
|
||||
doInteractiveItemPlacement( *aEvent.GetCommandStr(), &placer, _( "Place pad" ),
|
||||
doInteractiveItemPlacement( aEvent, &placer, _( "Place pad" ),
|
||||
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -518,7 +518,6 @@ int PCB_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
|
|||
if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
|
||||
return 0;
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||
|
||||
if( !picker ) // Happens in footprint wizard
|
||||
|
@ -535,7 +534,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, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -558,7 +557,6 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
if( m_isFootprintEditor && !m_frame->GetBoard()->GetFirstFootprint() )
|
||||
return 0;
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
PCB_PICKER_TOOL* picker = m_toolMgr->GetTool<PCB_PICKER_TOOL>();
|
||||
|
||||
m_pickerItem = nullptr;
|
||||
|
@ -644,7 +642,7 @@ int PCB_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
|||
m_frame->GetCanvas()->Refresh();
|
||||
} );
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,16 +43,13 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
PCB_GRID_HELPER grid( m_toolMgr, frame->GetMagneticItemsSettings() );
|
||||
int finalize_state = WAIT_CANCEL;
|
||||
|
||||
std::string tool = *aEvent.Parameter<std::string*>();
|
||||
|
||||
if( !tool.empty() )
|
||||
frame->PushTool( tool );
|
||||
frame->PushTool( aEvent );
|
||||
|
||||
Activate();
|
||||
setControls();
|
||||
|
||||
auto setCursor =
|
||||
[&]()
|
||||
auto setCursor =
|
||||
[&]()
|
||||
{
|
||||
frame->GetCanvas()->SetCurrentCursor( m_cursor );
|
||||
controls->ShowCursor( true );
|
||||
|
@ -173,8 +170,7 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
controls->ForceCursorPosition( false );
|
||||
controls->ShowCursor( false );
|
||||
|
||||
if( !tool.empty() )
|
||||
frame->PopTool( tool );
|
||||
frame->PopTool( aEvent );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <tools/pcb_actions.h>
|
||||
#include <tools/tool_event_utils.h>
|
||||
|
||||
void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
||||
void PCB_TOOL_BASE::doInteractiveItemPlacement( const TOOL_EVENT& aTool,
|
||||
INTERACTIVE_PLACER_BASE* aPlacer,
|
||||
const wxString& aCommitMessage, int aOptions )
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ protected:
|
|||
* @param aItemCreator the callable that will attempt to create the item
|
||||
* @param aCommitMessage the message used on a successful commit
|
||||
*/
|
||||
void doInteractiveItemPlacement( const std::string& aTool, INTERACTIVE_PLACER_BASE *aPlacer,
|
||||
void doInteractiveItemPlacement( const TOOL_EVENT& aTool, INTERACTIVE_PLACER_BASE* aPlacer,
|
||||
const wxString& aCommitMessage,
|
||||
int aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT );
|
||||
|
||||
|
|
|
@ -197,8 +197,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
auto& view = *getView();
|
||||
auto& controls = *getViewControls();
|
||||
|
||||
std::string tool = *aEvent.GetCommandStr();
|
||||
frame()->PushTool( tool );
|
||||
frame()->PushTool( aEvent );
|
||||
|
||||
TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
|
||||
PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
|
||||
|
@ -253,7 +252,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +268,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
frame()->PopTool( tool );
|
||||
frame()->PopTool( aEvent );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue