Fix selection clearance for via and tracks
- fixed via bounding box calculation in TRACK::GetBoundingBox() - moved clearance to TRACK::ViewBBox() - modified the Selection Tool to use EDA_ITEM::GetBoundingBox() rather than VIEW_ITEM::ViewBBox() to determine selection Fixes: lp:1776314 * https://bugs.launchpad.net/kicad/+bug/1776314
This commit is contained in:
parent
5d276a43f6
commit
9605dd8e1d
|
@ -290,23 +290,11 @@ STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
|
||||||
const EDA_RECT TRACK::GetBoundingBox() const
|
const EDA_RECT TRACK::GetBoundingBox() const
|
||||||
{
|
{
|
||||||
// end of track is round, this is its radius, rounded up
|
// end of track is round, this is its radius, rounded up
|
||||||
int radius;
|
int radius = ( m_Width + 1 ) / 2;
|
||||||
|
int ymax, xmax, ymin, xmin;
|
||||||
int ymax;
|
|
||||||
int xmax;
|
|
||||||
|
|
||||||
int ymin;
|
|
||||||
int xmin;
|
|
||||||
|
|
||||||
if( Type() == PCB_VIA_T )
|
if( Type() == PCB_VIA_T )
|
||||||
{
|
{
|
||||||
// Because vias are sometimes drawn larger than their m_Width would
|
|
||||||
// provide, erasing them using a dirty rect must also compensate for this
|
|
||||||
// possibility (that the via is larger on screen than its m_Width would provide).
|
|
||||||
// Because it is cheap to return a larger BoundingBox, do it so that
|
|
||||||
// the via gets erased properly. Do not divide width by 2 for this reason.
|
|
||||||
radius = m_Width;
|
|
||||||
|
|
||||||
ymax = m_Start.y;
|
ymax = m_Start.y;
|
||||||
xmax = m_Start.x;
|
xmax = m_Start.x;
|
||||||
|
|
||||||
|
@ -315,8 +303,6 @@ const EDA_RECT TRACK::GetBoundingBox() const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
radius = ( m_Width + 1 ) / 2;
|
|
||||||
|
|
||||||
ymax = std::max( m_Start.y, m_End.y );
|
ymax = std::max( m_Start.y, m_End.y );
|
||||||
xmax = std::max( m_Start.x, m_End.x );
|
xmax = std::max( m_Start.x, m_End.x );
|
||||||
|
|
||||||
|
@ -324,9 +310,6 @@ const EDA_RECT TRACK::GetBoundingBox() const
|
||||||
xmin = std::min( m_Start.x, m_End.x );
|
xmin = std::min( m_Start.x, m_End.x );
|
||||||
}
|
}
|
||||||
|
|
||||||
// + 1 is for the clearance line itself.
|
|
||||||
radius += GetClearance() + 1;
|
|
||||||
|
|
||||||
ymax += radius;
|
ymax += radius;
|
||||||
xmax += radius;
|
xmax += radius;
|
||||||
|
|
||||||
|
@ -822,6 +805,14 @@ unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BOX2I TRACK::ViewBBox() const
|
||||||
|
{
|
||||||
|
BOX2I bbox( GetBoundingBox() );
|
||||||
|
bbox.Inflate( 2 * GetClearance() );
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
|
void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( panel != NULL, wxT( "VIA::Draw panel cannot be NULL." ) );
|
wxCHECK_RET( panel != NULL, wxT( "VIA::Draw panel cannot be NULL." ) );
|
||||||
|
|
|
@ -304,6 +304,8 @@ public:
|
||||||
|
|
||||||
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||||
|
|
||||||
|
const BOX2I ViewBBox() const override;
|
||||||
|
|
||||||
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
virtual void SwapData( BOARD_ITEM* aImage ) override;
|
||||||
|
|
||||||
#if defined (DEBUG)
|
#if defined (DEBUG)
|
||||||
|
|
|
@ -624,7 +624,9 @@ bool SELECTION_TOOL::selectMultiple()
|
||||||
|
|
||||||
if( windowSelection )
|
if( windowSelection )
|
||||||
{
|
{
|
||||||
if( selectionBox.Contains( item->ViewBBox() ) )
|
BOX2I bbox( item->GetBoundingBox() );
|
||||||
|
|
||||||
|
if( selectionBox.Contains( bbox ) )
|
||||||
{
|
{
|
||||||
if( m_subtractive )
|
if( m_subtractive )
|
||||||
unselect( item );
|
unselect( item );
|
||||||
|
|
Loading…
Reference in New Issue