67
67
void LIB_FIELD::Init( int id )
70
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT;
70
m_Size.x = GetDefaultTextSize();
71
m_Size.y = GetDefaultTextSize();
71
72
m_typeName = _( "Field" );
72
73
m_Orient = TEXT_ORIENT_HORIZ;
323
bool LIB_FIELD::HitTest( const wxPoint& aPosition )
324
bool LIB_FIELD::HitTest( const wxPoint& aPosition ) const
325
326
// Because HitTest is mainly used to select the field
326
327
// return always false if this field is void
334
bool LIB_FIELD::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTransform )
335
bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
336
337
if( aThreshold < 0 )
339
int extraCharCount = 0;
340
// Build a temporary copy of the text for hit testing
341
EDA_TEXT tmp_text( *this );
341
343
// Reference designator text has one or 2 additional character (displays
343
345
if( m_id == REFERENCE )
347
LIB_COMPONENT* parent = (LIB_COMPONENT*)m_Parent;
347
wxString extended_text = tmp_text.GetText();
348
extended_text.Append('?');
349
const LIB_COMPONENT* parent = static_cast<const LIB_COMPONENT*>( m_Parent );
349
351
if ( parent && ( parent->GetPartCount() > 1 ) )
352
extended_text.Append('A');
353
tmp_text.SetText( extended_text );
356
wxPoint physicalpos = aTransform.TransformCoordinate( m_Pos );
356
tmp_text.SetTextPosition( aTransform.TransformCoordinate( m_Pos ) );
360
358
/* The text orientation may need to be flipped if the
361
359
* transformation matrix causes xy axes to be flipped.
362
360
* this simple algo works only for schematic matrix (rot 90 or/and mirror)
364
362
int t1 = ( aTransform.x1 != 0 ) ^ ( m_Orient != 0 );
365
int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT;
366
EXCHG( m_Orient, orient );
368
bool hit = TextHitTest( aPosition );
370
EXCHG( m_Orient, orient );
373
while( extraCharCount-- )
374
m_Text.RemoveLast( );
363
tmp_text.SetOrientation( t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT );
365
return tmp_text.TextHitTest( aPosition );