From 50405b558edea83691466cf02e26586794dd873c Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Thu, 8 Oct 2020 00:45:47 +0100 Subject: [PATCH] Make the gerbview ruler tool more like the pcb ruler tool * Allow the ruler to persist after clicking once on the canvas --- gerbview/tools/gerbview_selection_tool.cpp | 33 ++++++++-------------- pcbnew/tools/pcb_viewer_tools.cpp | 2 +- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index bab9052af1..4cf3c2adc8 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -585,17 +585,21 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); const VECTOR2I cursorPos = controls.GetCursorPosition(); - auto clearRuler = [&] () { - view.SetVisible( &ruler, false ); - controls.SetAutoPan( false ); - controls.CaptureCursor( false ); - originSet = false; - }; + auto clearRuler = + [&] () + { + view.SetVisible( &ruler, false ); + controls.SetAutoPan( false ); + controls.CaptureCursor( false ); + originSet = false; + }; if( evt->IsCancelInteractive() ) { if( originSet ) + { clearRuler(); + } else { m_frame->PopTool( tool ); @@ -623,11 +627,8 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) // click or drag starts else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) ) { - if( !evt->IsDrag( BUT_LEFT ) ) - { - twoPtMgr.SetOrigin( cursorPos ); - twoPtMgr.SetEnd( cursorPos ); - } + twoPtMgr.SetOrigin( cursorPos ); + twoPtMgr.SetEnd( cursorPos ); controls.CaptureCursor( true ); controls.SetAutoPan( true ); @@ -635,14 +636,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) originSet = true; } - else if( !originSet && evt->IsMotion() ) - { - // make sure the origin is set before a drag starts - // otherwise you can miss a step - twoPtMgr.SetOrigin( cursorPos ); - twoPtMgr.SetEnd( cursorPos ); - } - // second click or mouse up after drag ends else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) ) { @@ -650,8 +643,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) controls.SetAutoPan( false ); controls.CaptureCursor( false ); - - view.SetVisible( &ruler, false ); } // move or drag when origin set updates rules diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index ee07bfa60f..eb89bfa0bc 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -220,7 +220,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) controls.SetAutoPan( false ); controls.CaptureCursor( false ); - while( auto evt = Wait() ) + while( TOOL_EVENT* evt = Wait() ) { frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );