Make the gerbview ruler tool more like the pcb ruler tool
* Allow the ruler to persist after clicking once on the canvas
This commit is contained in:
parent
7e17b39755
commit
50405b558e
|
@ -585,17 +585,21 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
||||||
|
|
||||||
auto clearRuler = [&] () {
|
auto clearRuler =
|
||||||
view.SetVisible( &ruler, false );
|
[&] ()
|
||||||
controls.SetAutoPan( false );
|
{
|
||||||
controls.CaptureCursor( false );
|
view.SetVisible( &ruler, false );
|
||||||
originSet = false;
|
controls.SetAutoPan( false );
|
||||||
};
|
controls.CaptureCursor( false );
|
||||||
|
originSet = false;
|
||||||
|
};
|
||||||
|
|
||||||
if( evt->IsCancelInteractive() )
|
if( evt->IsCancelInteractive() )
|
||||||
{
|
{
|
||||||
if( originSet )
|
if( originSet )
|
||||||
|
{
|
||||||
clearRuler();
|
clearRuler();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( tool );
|
||||||
|
@ -623,11 +627,8 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
// click or drag starts
|
// click or drag starts
|
||||||
else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
|
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.CaptureCursor( true );
|
||||||
controls.SetAutoPan( true );
|
controls.SetAutoPan( true );
|
||||||
|
@ -635,14 +636,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
originSet = true;
|
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
|
// second click or mouse up after drag ends
|
||||||
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
|
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.SetAutoPan( false );
|
||||||
controls.CaptureCursor( false );
|
controls.CaptureCursor( false );
|
||||||
|
|
||||||
view.SetVisible( &ruler, false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// move or drag when origin set updates rules
|
// move or drag when origin set updates rules
|
||||||
|
|
|
@ -220,7 +220,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
controls.SetAutoPan( false );
|
controls.SetAutoPan( false );
|
||||||
controls.CaptureCursor( false );
|
controls.CaptureCursor( false );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
|
|
Loading…
Reference in New Issue