Fix some issues with global-label fields' bounding boxes.
This commit is contained in:
parent
73f835437e
commit
63b5ad7df1
|
@ -890,6 +890,12 @@ bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
|||
|
||||
rect.Inflate( aAccuracy );
|
||||
|
||||
if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
|
||||
rect.Offset( label->GetSchematicTextOffset( nullptr ) );
|
||||
}
|
||||
|
||||
return rect.Contains( aPosition );
|
||||
}
|
||||
|
||||
|
@ -904,6 +910,12 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
|
|||
|
||||
rect.Inflate( aAccuracy );
|
||||
|
||||
if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
|
||||
{
|
||||
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
|
||||
rect.Offset( label->GetSchematicTextOffset( nullptr ) );
|
||||
}
|
||||
|
||||
if( aContained )
|
||||
return rect.Contains( GetBoundingBox() );
|
||||
|
||||
|
|
|
@ -606,15 +606,21 @@ const EDA_RECT SCH_LABEL_BASE::GetBodyBoundingBox() const
|
|||
|
||||
const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() const
|
||||
{
|
||||
// build the bounding box of the entire net class flag, including both the symbol and the
|
||||
// net class reference text
|
||||
// build the bounding box of the entire label, including its fields
|
||||
|
||||
EDA_RECT box( GetBodyBoundingBox() );
|
||||
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.IsVisible() )
|
||||
box.Merge( field.GetBoundingBox() );
|
||||
{
|
||||
EDA_RECT fieldBBox = field.GetBoundingBox();
|
||||
|
||||
if( Type() == SCH_GLOBAL_LABEL_T )
|
||||
fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
|
||||
|
||||
box.Merge( fieldBBox );
|
||||
}
|
||||
}
|
||||
|
||||
box.Normalize();
|
||||
|
@ -635,11 +641,14 @@ bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
|||
{
|
||||
if( field.IsVisible() )
|
||||
{
|
||||
bbox = field.GetBoundingBox();
|
||||
bbox.Inflate( aAccuracy );
|
||||
EDA_RECT fieldBBox = field.GetBoundingBox();
|
||||
fieldBBox.Inflate( aAccuracy );
|
||||
|
||||
if( bbox.Contains( aPosition ) )
|
||||
return bbox.Contains( aPosition );
|
||||
if( Type() == SCH_GLOBAL_LABEL_T )
|
||||
fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
|
||||
|
||||
if( fieldBBox.Contains( aPosition ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,9 +673,17 @@ bool SCH_LABEL_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur
|
|||
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( field.IsVisible() && rect.Intersects( field.GetBoundingBox() ) )
|
||||
if( field.IsVisible() )
|
||||
{
|
||||
EDA_RECT fieldBBox = field.GetBoundingBox();
|
||||
|
||||
if( Type() == SCH_GLOBAL_LABEL_T )
|
||||
fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
|
||||
|
||||
if( rect.Intersects( fieldBBox ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1066,7 +1066,12 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
|||
rect.Collide( poss, collector.m_Threshold, &dist );
|
||||
}
|
||||
|
||||
if( dist < closestDist )
|
||||
if( dist == closestDist )
|
||||
{
|
||||
if( item->GetParent() == closest )
|
||||
closest = item;
|
||||
}
|
||||
else if( dist < closestDist )
|
||||
{
|
||||
closestDist = dist;
|
||||
closest = item;
|
||||
|
|
Loading…
Reference in New Issue