bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const { EDA_RECT rect = aRect; rect.Inflate( aAccuracy ); if( aContains ) return rect.Contains( GetTextBox( -1 ) ); return rect.Intersects( GetTextBox( -1 ) ); }
EDA_RECT SCH_FIELD::GetBoundingBox() const { SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; // We must pass the effective text thickness to GetTextBox // when calculating the bounding box linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); // Calculate the text bounding box: EDA_RECT rect; // set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use // a justification relative to the text itself // i.e. justification relative to an horizontal text // or to 1 to keep the initial behavior #if (USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR == 1 ) if( m_Orient == TEXT_ORIENT_VERT ) { // For vertical texts, exchange the horizontal and the vertical justification // The idea is to keep the justification always left or top for instance, // no matter the text orientation SCH_FIELD text( *this ); // Make a local copy to swap justifications // because GetBoundingBox() is const int tmp = (int)text.m_VJustify; NEGATE( tmp ); text.m_VJustify = (EDA_TEXT_VJUSTIFY_T)text.m_HJustify; text.m_HJustify = (EDA_TEXT_HJUSTIFY_T)tmp; rect = text.GetTextBox( -1, linewidth ); } else #endif rect = GetTextBox( -1, linewidth ); // Calculate the bounding box position relative to the component: wxPoint origin = parentComponent->GetPosition(); wxPoint pos = m_Pos - origin; wxPoint begin = rect.GetOrigin() - origin; wxPoint end = rect.GetEnd() - origin; RotatePoint( &begin, pos, m_Orient ); RotatePoint( &end, pos, m_Orient ); // Due to the Y axis direction, we must mirror the bounding box, // relative to the text position: begin.y -= pos.y; end.y -= pos.y; NEGATE( begin.y ); NEGATE( end.y ); begin.y += pos.y; end.y += pos.y; // Now, apply the component transform (mirror/rot) begin = parentComponent->GetTransform().TransformCoordinate( begin ); end = parentComponent->GetTransform().TransformCoordinate( end ); rect.SetOrigin( begin); rect.SetEnd( end); rect.Move( origin ); rect.Normalize(); return rect; }
/** * Function TransformBoundingBoxWithClearanceToPolygon * Convert the text bounding box to a rectangular polygon * Used in filling zones calculations * Circles and arcs are approximated by segments * @param aCornerBuffer = a buffer to store the polygon * @param aClearanceValue = the clearance around the text bounding box */ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue ) const { if( GetText().Length() == 0 ) return; wxPoint corners[4]; // Buffer of polygon corners EDA_RECT rect = GetTextBox( -1 ); rect.Inflate( aClearanceValue ); corners[0].x = rect.GetOrigin().x; corners[0].y = rect.GetOrigin().y; corners[1].y = corners[0].y; corners[1].x = rect.GetRight(); corners[2].x = corners[1].x; corners[2].y = rect.GetBottom(); corners[3].y = corners[2].y; corners[3].x = corners[0].x; aCornerBuffer.NewOutline(); for( int ii = 0; ii < 4; ii++ ) { // Rotate polygon RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient ); aCornerBuffer.Append( corners[ii].x, corners[ii].y ); } }
const EDA_RECT SCH_TEXT::GetBoundingBox() const { // We must pass the effective text thickness to GetTextBox // when calculating the bounding box int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() ); EDA_RECT rect = GetTextBox( -1, linewidth ); if( GetTextAngle() != 0 ) // Rotate rect { wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); RotatePoint( &pos, GetTextPos(), GetTextAngle() ); RotatePoint( &end, GetTextPos(), GetTextAngle() ); rect.SetOrigin( pos ); rect.SetEnd( end ); } rect.Normalize(); return rect; }
void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer, int aClearanceValue ) const { // Oh dear. When in UTF-8 mode, wxString puts string iterators in a linked list, and // that linked list is not thread-safe. std::lock_guard<std::mutex> guard( m_mutex ); if( GetText().Length() == 0 ) return; wxPoint corners[4]; // Buffer of polygon corners EDA_RECT rect = GetTextBox( -1 ); rect.Inflate( aClearanceValue ); corners[0].x = rect.GetOrigin().x; corners[0].y = rect.GetOrigin().y; corners[1].y = corners[0].y; corners[1].x = rect.GetRight(); corners[2].x = corners[1].x; corners[2].y = rect.GetBottom(); corners[3].y = corners[2].y; corners[3].x = corners[0].x; aCornerBuffer->NewOutline(); for( int ii = 0; ii < 4; ii++ ) { // Rotate polygon RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() ); aCornerBuffer->Append( corners[ii].x, corners[ii].y ); } }
const EDA_RECT TEXTE_PCB::GetBoundingBox() const { EDA_RECT rect = GetTextBox( -1, -1 ); if( m_Orient ) rect = rect.GetBoundingBoxRotated( m_Pos, m_Orient ); return rect; }
const EDA_RECT TEXTE_PCB::GetBoundingBox() const { EDA_RECT rect = GetTextBox( -1, -1 ); if( GetTextAngle() ) rect = rect.GetBoundingBoxRotated( GetTextPos(), GetTextAngle() ); return rect; }
/* * Function GetBoundingBox (virtual) * returns the bounding box of this Text (according to text and footprint * orientation) */ const EDA_RECT TEXTE_MODULE::GetBoundingBox() const { double angle = GetDrawRotation(); EDA_RECT text_area = GetTextBox( -1, -1 ); if( angle ) text_area = text_area.GetBoundingBoxRotated( m_Pos, m_Orient ); return text_area; }
const BOX2I TEXTE_MODULE::ViewBBox() const { double angle = GetDrawRotation(); EDA_RECT text_area = GetTextBox( -1, -1 ); if( angle ) text_area = text_area.GetBoundingBoxRotated( m_Pos, angle ); return BOX2I( text_area.GetPosition(), text_area.GetSize() ); }
bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const { EDA_RECT rect = GetTextBox( -1 ); // Get the full text area. wxPoint location = aPoint; rect.Inflate( aAccuracy ); RotatePoint( &location, m_Pos, -m_Orient ); return rect.Contains( location ); }
bool TEXTE_MODULE::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const { EDA_RECT rect = GetTextBox( -1 ); wxPoint location = aPoint; rect.Inflate( aAccuracy ); RotatePoint( &location, GetTextPos(), -GetDrawRotation() ); return rect.Contains( location ); }
bool TEXTE_MODULE::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const { EDA_RECT rect = aRect; rect.Inflate( aAccuracy ); if( aContains ) { return rect.Contains( GetBoundingBox() ); } else { return rect.Intersects( GetTextBox( -1 ), GetDrawRotation() ); } }
const EDA_RECT SCH_FIELD::GetBoundingBox() const { SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; // We must pass the effective text thickness to GetTextBox // when calculating the bounding box linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); // Calculate the text bounding box: EDA_RECT rect; if( m_id == REFERENCE ) // multi units have one letter or more added to reference { SCH_FIELD text( *this ); // Make a local copy to change text // because GetBoundingBox() is const text.SetText( GetFullyQualifiedText() ); rect = text.GetTextBox( -1, linewidth ); } else rect = GetTextBox( -1, linewidth ); // Calculate the bounding box position relative to the component: wxPoint origin = parentComponent->GetPosition(); wxPoint pos = m_Pos - origin; wxPoint begin = rect.GetOrigin() - origin; wxPoint end = rect.GetEnd() - origin; RotatePoint( &begin, pos, m_Orient ); RotatePoint( &end, pos, m_Orient ); // Due to the Y axis direction, we must mirror the bounding box, // relative to the text position: begin.y -= pos.y; end.y -= pos.y; NEGATE( begin.y ); NEGATE( end.y ); begin.y += pos.y; end.y += pos.y; // Now, apply the component transform (mirror/rot) begin = parentComponent->GetTransform().TransformCoordinate( begin ); end = parentComponent->GetTransform().TransformCoordinate( end ); rect.SetOrigin( begin); rect.SetEnd( end); rect.Move( origin ); rect.Normalize(); return rect; }
bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const { wxPoint rel_pos; EDA_RECT area = GetTextBox( -1, -1 ); /* Rotate refPos to - angle to test if refPos is within area (which * is relative to an horizontal text) */ rel_pos = aPosition; RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); if( area.Contains( rel_pos ) ) return true; return false; }
EDA_RECT LIB_TEXT::GetBoundingBox() const { /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when * calling GetTextBox() that works using top to bottom Y axis orientation. */ EDA_RECT rect = GetTextBox( -1, -1, true ); wxPoint orig = rect.GetOrigin(); wxPoint end = rect.GetEnd(); NEGATE( orig.y); NEGATE( end.y); RotatePoint( &orig, m_Pos, -m_Orient ); RotatePoint( &end, m_Pos, -m_Orient ); rect.SetOrigin( orig ); rect.SetEnd( end ); rect.Normalize(); return rect; }
const EDA_RECT SCH_LABEL::GetBoundingBox() const { int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness(); EDA_RECT rect = GetTextBox( -1, linewidth ); if( GetTextAngle() != 0.0 ) { // Rotate rect wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); RotatePoint( &pos, GetTextPos(), GetTextAngle() ); RotatePoint( &end, GetTextPos(), GetTextAngle() ); rect.SetOrigin( pos ); rect.SetEnd( end ); rect.Normalize(); } return rect; }
const EDA_RECT LIB_TEXT::GetBoundingBox() const { /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when * calling GetTextBox() that works using top to bottom Y axis orientation. */ EDA_RECT rect = GetTextBox( -1, -1, true ); rect.RevertYAxis(); // We are using now a bottom to top Y axis. wxPoint orig = rect.GetOrigin(); wxPoint end = rect.GetEnd(); RotatePoint( &orig, GetTextPos(), -GetTextAngle() ); RotatePoint( &end, GetTextPos(), -GetTextAngle() ); rect.SetOrigin( orig ); rect.SetEnd( end ); // We are using now a top to bottom Y axis: rect.RevertYAxis(); return rect; }
EDA_RECT SCH_TEXT::GetBoundingBox() const { // We must pass the effective text thickness to GetTextBox // when calculating the bounding box int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); EDA_RECT rect = GetTextBox( -1, linewidth ); if( m_Orient ) // Rotate rect { wxPoint pos = rect.GetOrigin(); wxPoint end = rect.GetEnd(); RotatePoint( &pos, m_Pos, m_Orient ); RotatePoint( &end, m_Pos, m_Orient ); rect.SetOrigin( pos ); rect.SetEnd( end ); } rect.Normalize(); return rect; }
const TextString& TMessageBox::GetText() const { return GetTextBox().GetText(); }
void TMessageBox::SetText(const TextString& value) { GetTextBox().SetText(value);\ _OnTextChanged(); GetSignal(DefaultSignalID::ObjectTextChanged).Send(); }