Hittesting already handles inverse coordinate system.

Fixes https://gitlab.com/kicad/code/kicad/issues/9926
This commit is contained in:
Jeff Young 2021-12-11 00:27:36 +00:00
parent 91dace3e5e
commit 1f126c5619
1 changed files with 3 additions and 4 deletions

View File

@ -841,7 +841,7 @@ bool EE_POINT_EDITOR::addCornerCondition( const SELECTION& )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition(); VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
double threshold = getView()->ToWorld( EDIT_POINT::POINT_SIZE ); double threshold = getView()->ToWorld( EDIT_POINT::POINT_SIZE );
return shape->HitTest( mapCoords( cursorPos ), (int) threshold ); return shape->HitTest( (wxPoint) cursorPos, (int) threshold );
} }
@ -854,14 +854,13 @@ int EE_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 ); SHAPE_LINE_CHAIN& poly = shape->GetPolyShape().Outline( 0 );
VECTOR2I cursor = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() ); VECTOR2I cursor = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() );
wxPoint pos = mapCoords( cursor );
int currentMinDistance = INT_MAX; int currentMinDistance = INT_MAX;
int closestLineStart = 0; int closestLineStart = 0;
for( unsigned i = 0; i < poly.GetPointCount() - 1; ++i ) for( unsigned i = 0; i < poly.GetPointCount() - 1; ++i )
{ {
int distance = (int) DistanceLinePoint( (wxPoint) poly.CPoint( i ), int distance = (int) DistanceLinePoint( (wxPoint) poly.CPoint( i ),
(wxPoint) poly.CPoint( i + 1 ), pos ); (wxPoint) poly.CPoint( i + 1 ), (wxPoint) cursor );
if( distance < currentMinDistance ) if( distance < currentMinDistance )
{ {
@ -871,7 +870,7 @@ int EE_POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
} }
saveItemsToUndo(); saveItemsToUndo();
poly.Insert( closestLineStart, pos ); poly.Insert( closestLineStart, (wxPoint) cursor );
updateItem( shape, true ); updateItem( shape, true );
updatePoints(); updatePoints();