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:
parent
7297208119
commit
51479c2042
|
@ -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
|
bool LIB_POLYLINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||||
{
|
{
|
||||||
int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE );
|
int delta = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE );
|
||||||
wxPoint start, end;
|
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] );
|
shape.SetClosed( true );
|
||||||
end = DefaultTransform.TransformCoordinate( m_PolyPoints[ii] );
|
return shape.PointInside( aPosition, delta );
|
||||||
|
|
||||||
if( TestSegmentHit( aPosition, start, end, mindist ) )
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return false;
|
return shape.PointOnEdge( aPosition, delta );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,8 +262,10 @@ bool LIB_POLYLINE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccurac
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Account for the width of the line
|
// Account for the width of the line
|
||||||
sel.Inflate( GetWidth() / 2 );
|
sel.Inflate( GetPenSize() / 2 );
|
||||||
int count = m_PolyPoints.size();
|
|
||||||
|
// 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++ )
|
for( int ii = 0; ii < count; ii++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,14 +227,23 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aOn
|
||||||
{
|
{
|
||||||
COLOR4D color = m_schSettings.GetLayerColor( aLayer );
|
COLOR4D color = m_schSettings.GetLayerColor( aLayer );
|
||||||
|
|
||||||
if( aItem->IsBrightened() && !aOnBackgroundLayer )
|
if( aItem->Type() == SCH_LINE_T )
|
||||||
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
|
|
||||||
else if( aItem->Type() == SCH_LINE_T )
|
|
||||||
color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
|
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() )
|
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() )
|
else if( aItem->IsHighlighted() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue