Override SCH_GLOBALLABEL::HitTest
Global labels can optionally have intersheet references. When enabled, they expand the bounding box of the label. Because they can be far away from the actual label, the bounding box is not a good approximation for the hittest
This commit is contained in:
parent
ebda02255c
commit
2fdd805eda
|
@ -1477,6 +1477,58 @@ BITMAPS SCH_GLOBALLABEL::GetMenuImage() const
|
|||
}
|
||||
|
||||
|
||||
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT bbox = GetBoundingBox();
|
||||
bbox.Inflate( aAccuracy );
|
||||
|
||||
if( !bbox.Contains( aPosition ) )
|
||||
{
|
||||
if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow )
|
||||
{
|
||||
bbox = m_intersheetRefsField.GetBoundingBox();
|
||||
bbox.Inflate( aAccuracy );
|
||||
|
||||
return bbox.Contains( aPosition );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_GLOBALLABEL::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
||||
{
|
||||
EDA_RECT bbox = GetBoundingBox();
|
||||
|
||||
if( aContained )
|
||||
{
|
||||
if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow )
|
||||
bbox.Merge( m_intersheetRefsField.GetBoundingBox() );
|
||||
|
||||
bbox.Inflate( aAccuracy );
|
||||
return aRect.Contains( bbox );
|
||||
}
|
||||
|
||||
bbox.Inflate( aAccuracy );
|
||||
|
||||
if( aRect.Intersects( bbox ) )
|
||||
return true;
|
||||
|
||||
if( Schematic() && Schematic()->Settings().m_IntersheetRefsShow )
|
||||
{
|
||||
bbox = m_intersheetRefsField.GetBoundingBox();
|
||||
bbox.Inflate( aAccuracy );
|
||||
|
||||
return aRect.Intersects( bbox );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType )
|
||||
: SCH_TEXT( pos, text, aType )
|
||||
{
|
||||
|
|
|
@ -378,6 +378,14 @@ public:
|
|||
*/
|
||||
const EDA_RECT GetBoundingBox() const override;
|
||||
|
||||
/**
|
||||
* Override basic hit test to allow testing separately for label and intersheet refs
|
||||
* which can move independently
|
||||
* @return True if hit in either label or associated intersheet ref
|
||||
*/
|
||||
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
|
||||
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
||||
|
||||
void CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings,
|
||||
std::vector<wxPoint>& aPoints, const wxPoint& aPos ) const override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue