Pl_editor: add missing HitTest() for WS_DRAW_ITEM_BITMAP item.

This commit is contained in:
jean-pierre charras 2019-06-06 11:13:10 +02:00
parent 27a5ed1a9f
commit ce9b1e3da5
3 changed files with 47 additions and 18 deletions

View File

@ -368,10 +368,32 @@ void WS_DRAW_ITEM_BITMAP::PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4
const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const
{
auto* bitmap = static_cast<const WS_DATA_ITEM_BITMAP*>( m_peer );
EDA_RECT rect = bitmap->m_ImageBitmap->GetBoundingBox();
wxSize bm_size = bitmap->m_ImageBitmap->GetSize();
rect.Move( m_pos );
return rect;
// Size is in mils, convert to iu (0.001 mm)
bm_size.x *= 25.4;
bm_size.y *= 25.4;
EDA_RECT bbox;
bbox.SetSize( bm_size );
bbox.SetOrigin( m_pos.x - bm_size.x/2, m_pos.y - bm_size.y/2 );
return bbox;
}
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
EDA_RECT bbox = GetBoundingBox();
bbox.Inflate( aAccuracy );
return bbox.Contains( aPosition );
}
bool WS_DRAW_ITEM_BITMAP::HitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
{
return WS_DRAW_ITEM_BASE::HitTest( aRect, aContains, aAccuracy );
}

View File

@ -40,9 +40,11 @@ class WS_DRAW_ITEM_TEXT; // Forward declaration
#define TB_DEFAULT_TEXTSIZE 1.5 // default worksheet text size in mm
// A coordinate is relative to a page corner.
// Any of the 4 corners can be a reference.
// The default is the right bottom corner
/**
* A coordinate is relative to a page corner.
* Any of the 4 corners can be a reference.
* The default is the right bottom corner
*/
enum CORNER_ANCHOR
{
RB_CORNER, // right bottom corner
@ -58,10 +60,11 @@ enum PAGE_OPTION
SUBSEQUENT_PAGES
};
// a coordinate point
// The position is always relative to the corner anchor
// Note the coordinate is from the anchor point
// to the opposite corner.
/**
* A coordinate point
* The position is always relative to the corner anchor
* Note the coordinate is from the anchor point to the opposite corner.
*/
class POINT_COORD
{
public:
@ -78,13 +81,15 @@ public:
};
// Work sheet structure type definitions.
// Basic items are:
// * segment and rect (defined by 2 points)
// * text (defined by a coordinate), the text and its justifications
// * poly polygon defined by a coordinate, and a set of list of corners
// ( because we use it for logos, there are more than one polygon
// in this description
/**
* Work sheet structure type definitions.
* Basic items are:
* * segment and rect (defined by 2 points)
* * text (defined by a coordinate), the text and its justifications
* * poly polygon defined by a coordinate, and a set of list of corners
* ( because we use it for logos, there are more than one polygon
* in this description
*/
class WS_DATA_ITEM
{
public:
@ -295,7 +300,7 @@ class WS_DATA_ITEM_TEXT : public WS_DATA_ITEM
public:
wxString m_TextBase; // The basic text, with format symbols
wxString m_FullText; // The expanded text, shown on screen
double m_Orient; // Orientation in degrees
double m_Orient; // Orientation in degrees
EDA_TEXT_HJUSTIFY_T m_Hjustify;
EDA_TEXT_VJUSTIFY_T m_Vjustify;
bool m_Italic;

View File

@ -287,6 +287,8 @@ public:
void PrintWsItem( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor ) override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
const EDA_RECT GetBoundingBox() const override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;