Commit 2d761f30 authored by Marco Mattila's avatar Marco Mattila

Fix drawsegment bounding box and hittest issues in pcbnew.

parent 8db19bbd
...@@ -856,7 +856,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) ...@@ -856,7 +856,7 @@ bool BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
// Check segments, dimensions, texts, and fiducials // Check segments, dimensions, texts, and fiducials
for( BOARD_ITEM* item = m_Drawings; item != NULL; item = item->Next() ) for( BOARD_ITEM* item = m_Drawings; item != NULL; item = item->Next() )
{ {
if( aBoardEdgesOnly && item->Type() != TYPE_DRAWSEGMENT && item->GetLayer() != EDGE_N ) if( aBoardEdgesOnly && (item->Type() != TYPE_DRAWSEGMENT || item->GetLayer() != EDGE_N ) )
continue; continue;
if( !hasItems ) if( !hasItems )
......
...@@ -290,7 +290,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx ...@@ -290,7 +290,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
StAngle = (int) ArcTangente( dy - uy0, dx - ux0 ); StAngle = (int) ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + m_Angle; EndAngle = StAngle + m_Angle;
if ( ! panel->m_PrintIsMirrored) if( !panel->m_PrintIsMirrored )
{ {
if( StAngle > EndAngle ) if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle ); EXCHG( StAngle, EndAngle );
...@@ -435,7 +435,10 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const ...@@ -435,7 +435,10 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const
case S_ARC: case S_ARC:
{ {
bbox.Inflate( GetRadius() + 1 ); bbox.Merge( m_End );
wxPoint end = m_End;
RotatePoint( &end, m_Start, -m_Angle );
bbox.Merge( end );
} }
break; break;
...@@ -463,7 +466,7 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const ...@@ -463,7 +466,7 @@ EDA_RECT DRAWSEGMENT::GetBoundingBox() const
p_end.y = MAX( p_end.y, pt.y ); p_end.y = MAX( p_end.y, pt.y );
} }
bbox.SetEnd(p_end); bbox.SetEnd( p_end );
bbox.Inflate( 1 ); bbox.Inflate( 1 );
break; break;
} }
...@@ -492,17 +495,17 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aRefPos ) ...@@ -492,17 +495,17 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aRefPos )
if( m_Shape == S_CIRCLE ) if( m_Shape == S_CIRCLE )
return true; return true;
int mouseAngle = ArcTangente( relPos.y, relPos.x ); wxPoint startVec = wxPoint( m_End.x - m_Start.x, m_End.y - m_Start.y );
int stAngle = ArcTangente( m_End.y - m_Start.y, m_End.x - m_Start.x ); wxPoint endVec = m_End - m_Start;
int endAngle = stAngle + m_Angle; RotatePoint( &endVec, -m_Angle );
if( endAngle > 3600 ) // Check dot products
{ if( (long long)relPos.x*startVec.x + (long long)relPos.y*startVec.y < 0 )
stAngle -= 3600; return false;
endAngle -= 3600;
} if( (long long)relPos.x*endVec.x + (long long)relPos.y*endVec.y < 0 )
return false;
if( mouseAngle >= stAngle && mouseAngle <= endAngle )
return true; return true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment