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 );
|
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 );
|
return rect.Contains( aPosition );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,6 +910,12 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
|
||||||
|
|
||||||
rect.Inflate( 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 )
|
if( aContained )
|
||||||
return rect.Contains( GetBoundingBox() );
|
return rect.Contains( GetBoundingBox() );
|
||||||
|
|
||||||
|
|
|
@ -606,15 +606,21 @@ const EDA_RECT SCH_LABEL_BASE::GetBodyBoundingBox() const
|
||||||
|
|
||||||
const EDA_RECT SCH_LABEL_BASE::GetBoundingBox() 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
|
// build the bounding box of the entire label, including its fields
|
||||||
// net class reference text
|
|
||||||
|
|
||||||
EDA_RECT box( GetBodyBoundingBox() );
|
EDA_RECT box( GetBodyBoundingBox() );
|
||||||
|
|
||||||
for( const SCH_FIELD& field : m_fields )
|
for( const SCH_FIELD& field : m_fields )
|
||||||
{
|
{
|
||||||
if( field.IsVisible() )
|
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();
|
box.Normalize();
|
||||||
|
@ -635,11 +641,14 @@ bool SCH_LABEL_BASE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
||||||
{
|
{
|
||||||
if( field.IsVisible() )
|
if( field.IsVisible() )
|
||||||
{
|
{
|
||||||
bbox = field.GetBoundingBox();
|
EDA_RECT fieldBBox = field.GetBoundingBox();
|
||||||
bbox.Inflate( aAccuracy );
|
fieldBBox.Inflate( aAccuracy );
|
||||||
|
|
||||||
if( bbox.Contains( aPosition ) )
|
if( Type() == SCH_GLOBAL_LABEL_T )
|
||||||
return bbox.Contains( aPosition );
|
fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
|
||||||
|
|
||||||
|
if( fieldBBox.Contains( aPosition ) )
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,8 +673,16 @@ bool SCH_LABEL_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur
|
||||||
|
|
||||||
for( const SCH_FIELD& field : m_fields )
|
for( const SCH_FIELD& field : m_fields )
|
||||||
{
|
{
|
||||||
if( field.IsVisible() && rect.Intersects( field.GetBoundingBox() ) )
|
if( field.IsVisible() )
|
||||||
return true;
|
{
|
||||||
|
EDA_RECT fieldBBox = field.GetBoundingBox();
|
||||||
|
|
||||||
|
if( Type() == SCH_GLOBAL_LABEL_T )
|
||||||
|
fieldBBox.Offset( GetSchematicTextOffset( nullptr ) );
|
||||||
|
|
||||||
|
if( rect.Intersects( fieldBBox ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1066,7 +1066,12 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
||||||
rect.Collide( poss, collector.m_Threshold, &dist );
|
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;
|
closestDist = dist;
|
||||||
closest = item;
|
closest = item;
|
||||||
|
|
Loading…
Reference in New Issue