const EDA_RECT LIB_BEZIER::GetBoundingBox() const { EDA_RECT rect; int xmin, xmax, ymin, ymax; if( !GetCornerCount() ) return rect; xmin = xmax = m_PolyPoints[0].x; ymin = ymax = m_PolyPoints[0].y; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { xmin = std::min( xmin, m_PolyPoints[ii].x ); xmax = std::max( xmax, m_PolyPoints[ii].x ); ymin = std::min( ymin, m_PolyPoints[ii].y ); ymax = std::max( ymax, m_PolyPoints[ii].y ); } rect.SetOrigin( xmin, ymin ); rect.SetEnd( xmax, ymax ); rect.Inflate( ( GetPenSize()+1 ) / 2 ); rect.RevertYAxis(); return rect; }
void LIB_POLYLINE::DeleteSegment( const wxPoint aPosition ) { // First segment is kept, only its end point is changed while( GetCornerCount() > 2 ) { m_PolyPoints.pop_back(); if( m_PolyPoints[ GetCornerCount() - 1 ] != aPosition ) { m_PolyPoints[ GetCornerCount() - 1 ] = aPosition; break; } } }
bool LIB_POLYLINE::Save( OUTPUTFORMATTER& aFormatter ) { int ccount = GetCornerCount(); aFormatter.Print( 0, "P %d %d %d %d", ccount, m_Unit, m_Convert, m_Width ); for( unsigned i = 0; i < GetCornerCount(); i++ ) { aFormatter.Print( 0, " %d %d", m_PolyPoints[i].x, m_PolyPoints[i].y ); } aFormatter.Print( 0, " %c\n", fill_tab[m_Fill] ); return true; }
bool LIB_POLYLINE::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const { wxPoint ref, start, end; if( aThreshold < 0 ) aThreshold = GetPenSize() / 2; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { start = aTransform.TransformCoordinate( m_PolyPoints[ii - 1] ); end = aTransform.TransformCoordinate( m_PolyPoints[ii] ); if( TestSegmentHit( aPosition, start, end, aThreshold ) ) return true; } return false; }
const EDA_RECT LIB_POLYLINE::GetBoundingBox() const { EDA_RECT rect; int xmin, xmax, ymin, ymax; xmin = xmax = m_PolyPoints[0].x; ymin = ymax = m_PolyPoints[0].y; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) { xmin = std::min( xmin, m_PolyPoints[ii].x ); xmax = std::max( xmax, m_PolyPoints[ii].x ); ymin = std::min( ymin, m_PolyPoints[ii].y ); ymax = std::max( ymax, m_PolyPoints[ii].y ); } rect.SetOrigin( xmin, ymin * -1 ); rect.SetEnd( xmax, ymax * -1 ); rect.Inflate( m_Width / 2, m_Width / 2 ); return rect; }