pcbnew: Don't call evt->pos for non-mouse events

Since we are handling snapping in the grid helper, we don't need to
enable it in the cursor position return.  This allows the grid helper to
use the frame position while optionally snapping to segments.
This commit is contained in:
Seth Hillbrand 2018-10-04 05:26:48 -07:00
parent 3a9e7a496a
commit a4966adb67
1 changed files with 8 additions and 5 deletions

View File

@ -985,7 +985,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->SetSnapping( true ); m_controls->SetSnapping( false );
Activate(); Activate();
@ -1023,7 +1023,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
{ {
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
cursorPos = grid.BestSnapAnchor( evt->Position(), aGraphic ); cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic );
// 45 degree angle constraint enabled with an option and toggled with Ctrl // 45 degree angle constraint enabled with an option and toggled with Ctrl
const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) ); const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
@ -1069,6 +1069,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
} }
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{ {
if( !started ) if( !started )
{ {
// Init the new item attributes // Init the new item attributes
@ -1206,7 +1207,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
GRID_HELPER grid( m_frame ); GRID_HELPER grid( m_frame );
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->SetSnapping( true ); m_controls->SetSnapping( false );
Activate(); Activate();
@ -1219,7 +1220,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
const VECTOR2I cursorPos = grid.BestSnapAnchor( evt->Position(), aGraphic ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic );
if( evt->IsClick( BUT_LEFT ) ) if( evt->IsClick( BUT_LEFT ) )
{ {
@ -1353,12 +1354,14 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr )
STATUS_TEXT_POPUP status( m_frame ); STATUS_TEXT_POPUP status( m_frame );
status.SetTextColor( wxColour( 255, 0, 0 ) ); status.SetTextColor( wxColour( 255, 0, 0 ) );
status.SetText( _( "Self-intersecting polygons are not allowed" ) ); status.SetText( _( "Self-intersecting polygons are not allowed" ) );
m_controls->SetSnapping( false );
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
LSET layers( m_frame->GetActiveLayer() ); LSET layers( m_frame->GetActiveLayer() );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
VECTOR2I cursorPos = grid.BestSnapAnchor( evt->Position(), layers );
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), layers );
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{ {