Fix several bugs in selection exhibited by 74LS02.

1) Use PenWidth() (which is clipped at 0) instead of Width()
2) Implement an interior HitTest when a PolyLine is filled
3) Brighten background objects as well as foreground
4) Don't HitTest last segment when PolyLine is not filled

Fixes: lp:1834703
* https://bugs.launchpad.net/kicad/+bug/1834703
This commit is contained in:
Jeff Young 2019-06-29 19:45:32 +01:00
parent 7297208119
commit 51479c2042
2 changed files with 27 additions and 16 deletions

View File

@ -228,19 +228,19 @@ void LIB_POLYLINE::print( wxDC* aDC, const wxPoint& aOffset, void* aData,
bool LIB_POLYLINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE );
wxPoint start, end;
int delta = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE );
SHAPE_LINE_CHAIN shape;
for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
for( wxPoint pt : m_PolyPoints )
shape.Append( DefaultTransform.TransformCoordinate( pt ) );
if( m_Fill != NO_FILL && m_PolyPoints.size() > 2 )
{
start = DefaultTransform.TransformCoordinate( m_PolyPoints[ii - 1] );
end = DefaultTransform.TransformCoordinate( m_PolyPoints[ii] );
if( TestSegmentHit( aPosition, start, end, mindist ) )
return true;
shape.SetClosed( true );
return shape.PointInside( aPosition, delta );
}
return false;
else
return shape.PointOnEdge( aPosition, delta );
}
@ -262,8 +262,10 @@ bool LIB_POLYLINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccurac
return false;
// Account for the width of the line
sel.Inflate( GetWidth() / 2 );
int count = m_PolyPoints.size();
sel.Inflate( GetPenSize() / 2 );
// Only test closing segment if the polyline is filled
int count = m_Fill == NO_FILL ? m_PolyPoints.size() - 1 : m_PolyPoints.size();
for( int ii = 0; ii < count; ii++ )
{

View File

@ -227,14 +227,23 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aOn
{
COLOR4D color = m_schSettings.GetLayerColor( aLayer );
if( aItem->IsBrightened() && !aOnBackgroundLayer )
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
else if( aItem->Type() == SCH_LINE_T )
if( aItem->Type() == SCH_LINE_T )
color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
if( aItem->IsBrightened() )
{
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
if( aOnBackgroundLayer )
color = color.WithAlpha( 0.2 );
}
if( aItem->IsSelected() )
{
return color.Brightened( 0.5 );
if( aOnBackgroundLayer )
return color.Brightened( 0.2 );
else
return color.Brightened( 0.5 );
}
else if( aItem->IsHighlighted() )
{