From 58ca5b71a9e943742288d9806fd87e176067b60d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 15 Jul 2019 13:15:58 +0100 Subject: [PATCH] A more robust fix for 36f1d023f016f105eaf0eeadc231aa78e5034c31. This one also handles when the events get out-of-order due to them starting out in the Simulation window and not getting dispatched until the mouse goes over the Schematic window. Fixes: lp:1835907 * https://bugs.launchpad.net/kicad/+bug/1835907 Fixes: lp:1836544 * https://bugs.launchpad.net/kicad/+bug/1836544 --- common/eda_draw_frame.cpp | 44 ++++++++----- common/tool/common_tools.cpp | 5 -- common/tool/zoom_tool.cpp | 5 +- cvpcb/tools/cvpcb_selection_tool.cpp | 7 ++- eeschema/tools/ee_picker_tool.cpp | 1 - eeschema/tools/lib_drawing_tools.cpp | 21 ++++--- eeschema/tools/lib_edit_tool.cpp | 6 +- eeschema/tools/lib_move_tool.cpp | 5 +- eeschema/tools/sch_drawing_tools.cpp | 39 +++++++----- eeschema/tools/sch_edit_tool.cpp | 6 +- eeschema/tools/sch_editor_control.cpp | 18 ++++-- eeschema/tools/sch_line_wire_bus_tool.cpp | 18 +++--- eeschema/tools/sch_line_wire_bus_tool.h | 2 +- eeschema/tools/sch_move_tool.cpp | 5 +- gerbview/tools/gerbview_selection_tool.cpp | 7 ++- include/eda_draw_frame.h | 4 +- pagelayout_editor/tools/pl_drawing_tools.cpp | 12 ++-- pagelayout_editor/tools/pl_edit_tool.cpp | 11 ++-- pagelayout_editor/tools/pl_picker_tool.cpp | 1 - pcbnew/router/length_tuner_tool.cpp | 5 +- pcbnew/router/router_tool.cpp | 9 +-- pcbnew/tools/drawing_tool.cpp | 65 +++++++++++--------- pcbnew/tools/drawing_tool.h | 5 +- pcbnew/tools/edit_tool.cpp | 12 ++-- pcbnew/tools/footprint_editor_tools.cpp | 4 +- pcbnew/tools/microwave_tool.cpp | 12 ++-- pcbnew/tools/pad_tool.cpp | 9 +-- pcbnew/tools/pcb_editor_control.cpp | 32 ++++++---- pcbnew/tools/pcb_tool_base.cpp | 10 +-- pcbnew/tools/pcb_tool_base.h | 2 +- pcbnew/tools/pcbnew_control.cpp | 12 ++-- pcbnew/tools/pcbnew_picker_tool.cpp | 1 - pcbnew/tools/position_relative_tool.cpp | 2 +- 33 files changed, 230 insertions(+), 167 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index b3fb37a0da..05be7383c9 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -430,7 +430,7 @@ void EDA_DRAW_FRAME::PushTool( const std::string& actionName ) // Human cognitive stacking is very shallow; deeper tool stacks just get annoying if( m_toolStack.size() > 3 ) - m_toolStack.pop_front(); + m_toolStack.erase( m_toolStack.begin() ); TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName ); @@ -441,27 +441,41 @@ void EDA_DRAW_FRAME::PushTool( const std::string& actionName ) } -void EDA_DRAW_FRAME::PopTool() +void EDA_DRAW_FRAME::PopTool( const std::string& actionName ) { - if( m_toolStack.size() > 0 ) - m_toolStack.pop_back(); + // 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. - if( m_toolStack.size() > 0 ) + for( size_t i = m_toolStack.size() - 1; i >= 0; --i ) { - TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( m_toolStack.back() ); - - if( action ) + if( m_toolStack[ i ] == actionName ) { - // Pop the action as running it will push it back onto the stack - m_toolStack.pop_back(); + m_toolStack.erase( m_toolStack.begin() + i ); - TOOL_EVENT evt = action->MakeEvent(); - evt.SetHasPosition( false ); - GetToolManager()->PostEvent( evt ); + // If there's something underneath us, and it's now the top of the stack, then + // re-activate it + if( ( --i ) >= 0 && i == m_toolStack.size() - 1 ) + { + std::string back = m_toolStack[ i ]; + TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( back ); + + if( action ) + { + // Pop the action as running it will push it back onto the stack + m_toolStack.pop_back(); + + TOOL_EVENT evt = action->MakeEvent(); + evt.SetHasPosition( false ); + GetToolManager()->PostEvent( evt ); + } + } + else + DisplayToolMsg( ACTIONS::selectionTool.GetLabel() ); + + return; } } - else - DisplayToolMsg( ACTIONS::selectionTool.GetLabel() ); } diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 2334f577ed..a597e284b2 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -49,11 +49,6 @@ int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent ) // just a cancel of whatever other tools might be running. m_toolMgr->ProcessEvent( TOOL_EVENT( TC_COMMAND, TA_CANCEL_TOOL ) ); - - // Shouldn't be necessary, but as the Irish would say: "just to be sure to be sure" - while( !m_frame->ToolStackIsEmpty() ) - m_frame->PopTool(); - return 0; } diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index c15dc421f2..10f3fd0f7d 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -46,7 +46,8 @@ void ZOOM_TOOL::Reset( RESET_REASON aReason ) int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) { - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); while( TOOL_EVENT* evt = Wait() ) { @@ -66,7 +67,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) } // Exit zoom tool - m_frame->PopTool(); + m_frame->PopTool( tool ); return 0; } diff --git a/cvpcb/tools/cvpcb_selection_tool.cpp b/cvpcb/tools/cvpcb_selection_tool.cpp index 7e8dc233eb..25d4c5dafe 100644 --- a/cvpcb/tools/cvpcb_selection_tool.cpp +++ b/cvpcb/tools/cvpcb_selection_tool.cpp @@ -108,7 +108,8 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) auto& controls = *getViewControls(); auto previous_settings = controls.GetSettings(); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; @@ -141,7 +142,7 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) clearRuler(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -158,7 +159,7 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } diff --git a/eeschema/tools/ee_picker_tool.cpp b/eeschema/tools/ee_picker_tool.cpp index d68ae09aa0..b9d4f61eab 100644 --- a/eeschema/tools/ee_picker_tool.cpp +++ b/eeschema/tools/ee_picker_tool.cpp @@ -135,7 +135,6 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) resetPicker(); controls->ForceCursorPosition( false ); - m_frame->PopTool(); return 0; } diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 924c02a12b..d6fff81ab4 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -76,7 +76,8 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -102,7 +103,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -118,7 +119,7 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -239,7 +240,8 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); LIB_PART* part = m_frame->GetCurPart(); @@ -270,7 +272,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -291,7 +293,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -383,7 +385,8 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) getViewControls()->ShowCursor( true ); getViewControls()->SetSnapping( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Main loop: keep receiving events @@ -393,12 +396,12 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) if( evt->IsCancelInteractive() ) { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } else if( evt->IsActivate() ) { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } else if( evt->IsClick( BUT_LEFT ) ) diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index 7e98382aff..519197b7aa 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -282,7 +282,8 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); EE_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -333,7 +334,8 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index ac273790bf..d41f29d8ce 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -83,7 +83,8 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( selection.Empty() ) return 0; - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); controls->ShowCursor( true ); @@ -282,7 +283,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->OnModify(); m_moveInProgress = false; - m_frame->PopTool(); + m_frame->PopTool( tool ); return 0; } diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index f9bb9e0d7a..d3d490059b 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -100,7 +100,8 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) m_selectionTool->AddItemToSel( component ); } - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -131,7 +132,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -147,7 +148,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -247,7 +248,8 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) m_view->AddToPreview( image->Clone() ); } - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -275,13 +277,13 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } if( immediateMode ) { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -297,7 +299,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -350,7 +352,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) if( immediateMode ) { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -426,7 +428,8 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) m_view->ClearPreview(); m_view->AddToPreview( previewItem->Clone() ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -441,7 +444,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) if( evt->IsCancelInteractive() ) { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } else if( evt->IsActivate() ) @@ -453,7 +456,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -505,7 +508,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -531,7 +535,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -551,7 +555,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -692,7 +696,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -720,7 +725,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -740,7 +745,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index da4e5fd707..b62ef9f0eb 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -944,7 +944,8 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); EE_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -1006,7 +1007,8 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index badea219d6..355e075cc9 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -478,14 +478,16 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) { EE_PICKER_TOOL* picker = m_toolMgr->GetTool(); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); m_frame->GetCanvas()->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::PROBE ) ); picker->SetClickHandler( std::bind( probeSimulation, m_frame, std::placeholders::_1 ) ); picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } @@ -520,14 +522,16 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent ) { EE_PICKER_TOOL* picker = m_toolMgr->GetTool(); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); m_frame->GetCanvas()->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::TUNE ) ); picker->SetClickHandler( std::bind( tuneSimulation, m_frame, std::placeholders::_1 ) ); picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } #endif /* KICAD_SPICE */ @@ -686,13 +690,15 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) EE_PICKER_TOOL* picker = m_toolMgr->GetTool(); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) ); picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 8b09507dc9..2c6101f5e0 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -257,7 +257,8 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); if( aEvent.HasPosition() ) { @@ -265,7 +266,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent ) segment = startSegments( layer, cursorPos ); } - return doDrawSegments( layer, segment ); + return doDrawSegments( tool, layer, segment ); } @@ -277,7 +278,8 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); if( netPtr ) @@ -313,10 +315,10 @@ 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( LAYER_WIRE, segment ); + return doDrawSegments( tool, LAYER_WIRE, segment ); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); return 0; } } @@ -437,7 +439,7 @@ static void computeBreakPoint( SCH_SCREEN* aScreen, SCH_LINE* aSegment, wxPoint& } -int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment ) +int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType, SCH_LINE* aSegment ) { bool forceHV = m_frame->GetForceHVLines(); SCH_SCREEN* screen = m_frame->GetScreen(); @@ -486,7 +488,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( aTool ); break; } } @@ -502,7 +504,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment ) } else { - m_frame->PopTool(); + m_frame->PopTool( aTool ); break; } } diff --git a/eeschema/tools/sch_line_wire_bus_tool.h b/eeschema/tools/sch_line_wire_bus_tool.h index 55d52732a1..1495bbda52 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.h +++ b/eeschema/tools/sch_line_wire_bus_tool.h @@ -80,7 +80,7 @@ public: int AddJunctionsIfNeeded( const TOOL_EVENT& aEvent ); private: - int doDrawSegments( int aType, SCH_LINE* aSegment ); + int doDrawSegments( const std::string& aTool, int aType, SCH_LINE* aSegment ); SCH_LINE* startSegments( int aType, const VECTOR2D& aPos ); SCH_LINE* doUnfoldBus( const wxString& aNet ); void finishSegments(); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 0fe0abd788..392372c452 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -119,7 +119,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) else return 0; - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); if( m_moveInProgress ) { @@ -448,7 +449,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) m_dragAdditions.clear(); m_moveInProgress = false; - m_frame->PopTool(); + m_frame->PopTool( tool ); return 0; } diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index 4f9fbf1264..5a54824794 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -574,7 +574,8 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) auto& controls = *getViewControls(); auto previous_settings = controls.GetSettings(); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; @@ -607,7 +608,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) clearRuler(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -624,7 +625,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index d157c03c1d..e9a738b694 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -118,7 +118,7 @@ protected: /// Tool ID of previously active draw tool bar button. int m_lastDrawToolId; // JEY TODO: remove this; it doesn't work in modern toolset anyway - std::deque m_toolStack; // stack of user-level "tools". Used to temporarily + std::vector m_toolStack; // stack of user-level "tools". Used to temporarily // invoke an immediate-mode action. Note that these // are "tools" in the UI sense, which are actually // TOOL_ACTIONs internally @@ -308,7 +308,7 @@ public: * 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(); + virtual void PopTool( const std::string& actionName ); bool ToolStackIsEmpty() { return m_toolStack.empty(); } diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index f91bbb1664..c479250a36 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -80,7 +80,8 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -108,7 +109,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -124,7 +125,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -196,7 +197,8 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Prime the pump @@ -277,7 +279,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) getViewControls()->CaptureCursor( item != nullptr ); } - m_frame->PopTool(); + m_frame->PopTool( tool ); return 0; } diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index e920006380..039f2e85c6 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -101,7 +101,8 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( selection.Empty() ) return 0; - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); controls->ShowCursor( true ); @@ -247,7 +248,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->OnModify(); m_moveInProgress = false; - m_frame->PopTool(); + m_frame->PopTool( tool ); return 0; } @@ -340,7 +341,8 @@ int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) { - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); PL_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -399,7 +401,8 @@ int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } diff --git a/pagelayout_editor/tools/pl_picker_tool.cpp b/pagelayout_editor/tools/pl_picker_tool.cpp index 8e62a655af..494d4170c1 100644 --- a/pagelayout_editor/tools/pl_picker_tool.cpp +++ b/pagelayout_editor/tools/pl_picker_tool.cpp @@ -159,7 +159,6 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) resetPicker(); controls->ForceCursorPosition( false ); - m_frame->PopTool(); return 0; } diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 48cadbb831..f199e51651 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -263,7 +263,8 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) // Deselect all items m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - frame()->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + frame()->PushTool( tool ); Activate(); m_router->SetMode( aEvent.Parameter() ); @@ -306,7 +307,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) m_savedSettings = m_router->Settings(); m_savedSizes = m_router->Sizes(); - frame()->PopTool(); + frame()->PopTool( tool ); return 0; } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 1d61d292a7..9b48ac8324 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -869,7 +869,8 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) // Deselect all items m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + frame->PushTool( tool ); Activate(); m_router->SetMode( mode ); @@ -894,7 +895,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) if( evt->IsCancelInteractive() ) { - frame->PopTool(); + frame->PopTool( tool ); break; } else if( evt->IsActivate() ) @@ -906,7 +907,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) } else { - frame->PopTool(); + frame->PopTool( tool ); break; } } @@ -964,7 +965,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) if( m_cancelled ) { - frame->PopTool(); + frame->PopTool( tool ); break; } } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 2005343795..ac0b204bc6 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -145,10 +145,11 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); - while( drawSegment( S_SEGMENT, line, startingPoint ) ) + while( drawSegment( tool, S_SEGMENT, line, startingPoint ) ) { if( line ) { @@ -188,10 +189,11 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent ) if( aEvent.HasPosition() ) startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); - while( drawSegment( S_CIRCLE, circle, startingPoint ) ) + while( drawSegment( tool, S_CIRCLE, circle, startingPoint ) ) { if( circle ) { @@ -226,10 +228,11 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent ) arc->SetFlags( IS_NEW ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); - while( drawArc( arc, immediateMode ) ) + while( drawArc( tool, arc, immediateMode ) ) { if( arc ) { @@ -266,7 +269,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); bool reselect = false; @@ -299,7 +303,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -315,7 +319,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -472,7 +476,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); enum DIMENSION_STEPS @@ -517,7 +522,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -537,7 +542,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -749,7 +754,8 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) m_view->Update( &preview ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Main loop: keep receiving events @@ -762,7 +768,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) { preview.FreeItems(); - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } else if( evt->IsMotion() ) @@ -827,7 +833,8 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); m_controls->ShowCursor( true ); @@ -854,7 +861,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(); + m_frame->PopTool( tool ); break; } else if( evt->IsClick( BUT_RIGHT ) ) @@ -863,7 +870,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) } else if( evt->IsCancelInteractive() || evt->IsActivate() ) { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -872,7 +879,8 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) } -bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT aStartingPoint ) +bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, DRAWSEGMENT*& aGraphic, + OPT aStartingPoint ) { // Only two shapes are currently supported assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); @@ -956,7 +964,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPTPopTool(); + m_frame->PopTool( aTool ); cancelled = true; } @@ -982,7 +990,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPTPopTool(); + m_frame->PopTool( aTool ); cancelled = true; break; } @@ -1135,7 +1143,7 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER } -bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ) +bool DRAWING_TOOL::drawArc( const std::string& aTool, DRAWSEGMENT*& aGraphic, bool aImmediateMode ) { m_lineWidth = getSegmentWidth( getDrawingLayer() ); @@ -1188,7 +1196,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( aTool ); cancelled = true; } @@ -1214,7 +1222,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ) if( firstPoint ) cleanup(); - m_frame->PopTool(); + m_frame->PopTool( aTool ); cancelled = true; break; } @@ -1387,7 +1395,8 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) // hands the calculated points over to the zone creator tool POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // register for events m_controls->ShowCursor( true ); @@ -1427,7 +1436,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -1447,7 +1456,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) } else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -1814,9 +1823,9 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) VIA_PLACER placer( frame() ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA ); - frame()->PushTool( aEvent.GetCommandStr().get() ); - doInteractiveItemPlacement( &placer, _( "Place via" ), IPO_REPEAT | IPO_SINGLE_CLICK ); + doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place via" ), + IPO_REPEAT | IPO_SINGLE_CLICK ); return 0; } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index a8a2e97874..f32410e0ad 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -164,14 +164,15 @@ private: ///> and its settings (width, layer) set to the current default values. ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> the same point. - bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT aStartingPoint ); + bool drawSegment( const std::string& aTool, int aShape, DRAWSEGMENT*& aGraphic, + OPT aStartingPoint ); ///> Starts drawing an arc. ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> be already created. The tool deletes the object if it is not added to a BOARD. ///> @return False if the tool was cancelled before the origin was set or origin and end are ///> the same point. - bool drawArc( DRAWSEGMENT*& aGraphic, bool aImmediateMode ); + bool drawArc( const std::string& aTool, DRAWSEGMENT*& aGraphic, bool aImmediateMode ); /** * Draws a polygon, that is added as a zone or a keepout area. diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 7a90be9068..c40a10e3c5 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -269,7 +269,8 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( selection.Empty() ) return 0; - editFrame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + editFrame->PushTool( tool ); Activate(); controls->ShowCursor( true ); controls->SetAutoPan( true ); @@ -506,7 +507,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) m_commit->Push( _( "Drag" ) ); } - editFrame->PopTool(); + editFrame->PopTool( tool ); return 0; } @@ -1117,7 +1118,8 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) auto& view = *getView(); auto& controls = *getViewControls(); - frame()->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + frame()->PushTool( tool ); Activate(); EDA_UNITS_T units = frame()->GetUserUnits(); @@ -1157,7 +1159,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) clearRuler(); else { - frame()->PopTool(); + frame()->PopTool( tool ); break; } } @@ -1174,7 +1176,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) } else { - frame()->PopTool(); + frame()->PopTool( tool ); break; } } diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 7317b6c099..59936a81c6 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -313,9 +313,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) PAD_PLACER placer; - frame()->PushTool( aEvent.GetCommandStr().get() ); - - doInteractiveItemPlacement( &placer, _( "Place pad" ), + doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP ); return 0; diff --git a/pcbnew/tools/microwave_tool.cpp b/pcbnew/tools/microwave_tool.cpp index fe20ebb049..c6b01c64bb 100644 --- a/pcbnew/tools/microwave_tool.cpp +++ b/pcbnew/tools/microwave_tool.cpp @@ -90,9 +90,8 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent ) MICROWAVE_PLACER placer( frame, aEvent.Parameter() ); - frame->PushTool( aEvent.GetCommandStr().get() ); - - doInteractiveItemPlacement( &placer, _( "Place microwave feature" ), + doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, + _( "Place microwave feature" ), IPO_REPEAT | IPO_ROTATE | IPO_FLIP ); return 0; @@ -150,7 +149,8 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent ) KIGFX::VIEW_CONTROLS& controls = *getViewControls(); auto& frame = *getEditFrame(); - frame.PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + frame.PushTool( tool ); Activate(); TWO_POINT_GEOMETRY_MANAGER tpGeomMgr; @@ -189,7 +189,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent ) cleanup(); else { - frame.PopTool(); + frame.PopTool( tool ); break; } } @@ -206,7 +206,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent ) } else { - frame.PopTool(); + frame.PopTool( tool ); break; } } diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 23b28d8645..c2230b25b5 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -328,7 +328,8 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) if( settingsDlg.ShowModal() != wxID_OK ) return 0; - frame()->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + frame()->PushTool( tool ); Activate(); GENERAL_COLLECTOR collector; @@ -370,7 +371,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); commit.Revert(); - frame()->PopTool(); + frame()->PopTool( tool ); break; } @@ -378,7 +379,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) { commit.Push( _( "Renumber pads" ) ); - frame()->PopTool(); + frame()->PopTool( tool ); break; } @@ -478,7 +479,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent ) evt->IsDblClick( BUT_LEFT ) ) { commit.Push( _( "Renumber pads" ) ); - frame()->PopTool(); + frame()->PopTool( tool ); break; } diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index e32bf51d32..9944598b75 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -649,7 +649,8 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) controls->ShowCursor( true ); controls->SetSnapping( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); VECTOR2I cursorPos = controls->GetCursorPosition(); @@ -686,7 +687,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) cleanup(); else { - m_frame->PopTool(); + m_frame->PopTool( tool ); break; } } @@ -703,7 +704,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) } else { - frame()->PopTool(); + frame()->PopTool( tool ); break; } } @@ -858,7 +859,8 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); controls->SetSnapping( true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); // Main loop: keep receiving events @@ -869,7 +871,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent ) if( evt->IsCancelInteractive() ) { - frame()->PopTool(); + frame()->PopTool( tool ); break; } @@ -882,7 +884,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent ) } else { - frame()->PopTool(); + frame()->PopTool( tool ); break; } } @@ -1118,7 +1120,8 @@ void PCB_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* a int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) { - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -1133,7 +1136,8 @@ int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } @@ -1304,7 +1308,8 @@ int PCB_EDITOR_CONTROL::HighlightNetTool( const TOOL_EVENT& aEvent ) highlightNet( getViewControls()->GetMousePosition(), use_selection ); } - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -1318,7 +1323,8 @@ int PCB_EDITOR_CONTROL::HighlightNetTool( const TOOL_EVENT& aEvent ) picker->SetLayerSet( LSET::AllCuMask() ); picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } @@ -1372,7 +1378,8 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, BOARD* aBoard, bool aShow int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) { - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); auto picker = m_toolMgr->GetTool(); @@ -1398,7 +1405,8 @@ int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index 29c97198d0..39a5b6a059 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -33,12 +33,14 @@ #include "pcb_actions.h" #include "tool_event_utils.h" -void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer, +void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, + INTERACTIVE_PLACER_BASE* aPlacer, const wxString& aCommitMessage, int aOptions ) { using namespace std::placeholders; std::unique_ptr newItem; + frame()->PushTool( aTool ); Activate(); BOARD_COMMIT commit( frame() ); @@ -100,14 +102,14 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer if( aOptions & IPO_SINGLE_CLICK ) { cleanup(); - frame()->PopTool(); + frame()->PopTool( aTool ); break; } else if( newItem ) cleanup(); else { - frame()->PopTool(); + frame()->PopTool( aTool ); break; } } @@ -127,7 +129,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer } else { - frame()->PopTool(); + frame()->PopTool( aTool ); break; } } diff --git a/pcbnew/tools/pcb_tool_base.h b/pcbnew/tools/pcb_tool_base.h index a77dd78af5..d7793b60b4 100644 --- a/pcbnew/tools/pcb_tool_base.h +++ b/pcbnew/tools/pcb_tool_base.h @@ -126,7 +126,7 @@ protected: * @param aItemCreator the callable that will attempt to create the item * @param aCommitMessage the message used on a successful commit */ - void doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE *aPlacer, + void doInteractiveItemPlacement( const std::string& aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString& aCommitMessage, int aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT ); diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 5b8c33c192..9f427cf2cf 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -450,7 +450,8 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) } else { - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -464,7 +465,8 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); } return 0; @@ -486,7 +488,8 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) { m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - m_frame->PushTool( aEvent.GetCommandStr().get() ); + std::string tool = aEvent.GetCommandStr().get(); + m_frame->PushTool( tool ); Activate(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); @@ -551,7 +554,8 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) picker->Activate(); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() + + m_frame->PopTool( tool ); return 0; } diff --git a/pcbnew/tools/pcbnew_picker_tool.cpp b/pcbnew/tools/pcbnew_picker_tool.cpp index 36f0ab27f0..958763a0fc 100644 --- a/pcbnew/tools/pcbnew_picker_tool.cpp +++ b/pcbnew/tools/pcbnew_picker_tool.cpp @@ -147,7 +147,6 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) reset(); controls->ForceCursorPosition( false ); - frame()->PopTool(); return 0; } diff --git a/pcbnew/tools/position_relative_tool.cpp b/pcbnew/tools/position_relative_tool.cpp index c9e511c951..41fa5c75ad 100644 --- a/pcbnew/tools/position_relative_tool.cpp +++ b/pcbnew/tools/position_relative_tool.cpp @@ -169,9 +169,9 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent { statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) ); Wait(); - // Picker calls PopTool() so that it gets done before activating tool's PushTool() } + frame()->PopTool( "pcbnew.PositionRelative.selectReferenceItem" ); return 0; }