FIX: add parameter to GAL::DrawCurve to control the curve to polyline
conversion. Cairo supports curves, but not Opengl, that needs a conversion to polyline. This control allows optimization in conversion
This commit is contained in:
parent
1903052d79
commit
37b6552c42
|
@ -59,7 +59,7 @@ void BEZIER_POLY::GetPoly( std::vector<VECTOR2D>& aOutput, double aMinSegLen )
|
|||
aOutput.clear();
|
||||
aOutput.push_back( m_ctrlPts[0] );
|
||||
|
||||
// If the Bezier curve is degenerated (straight line), skip that:
|
||||
// If the Bezier curve is degenerated (straight line), skip intermediate points:
|
||||
bool degenerated = m_ctrlPts[0] == m_ctrlPts[1] && m_ctrlPts[2] == m_ctrlPts[3];
|
||||
|
||||
if( !degenerated )
|
||||
|
|
|
@ -424,8 +424,11 @@ void CAIRO_GAL_BASE::DrawPolygon( const SHAPE_LINE_CHAIN& aPolygon )
|
|||
|
||||
|
||||
void CAIRO_GAL_BASE::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aControlPointA,
|
||||
const VECTOR2D& aControlPointB, const VECTOR2D& aEndPoint )
|
||||
const VECTOR2D& aControlPointB, const VECTOR2D& aEndPoint,
|
||||
double aFilterValue )
|
||||
{
|
||||
// Note: aFilterValue is not used because the cubic Bezier curve is
|
||||
// supported by Cairo.
|
||||
syncLineWidth();
|
||||
|
||||
const auto sp = roundp( xform( aStartPoint ) );
|
||||
|
|
|
@ -1035,7 +1035,8 @@ void OPENGL_GAL::DrawPolygon( const SHAPE_LINE_CHAIN& aPolygon )
|
|||
|
||||
|
||||
void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aControlPointA,
|
||||
const VECTOR2D& aControlPointB, const VECTOR2D& aEndPoint )
|
||||
const VECTOR2D& aControlPointB, const VECTOR2D& aEndPoint,
|
||||
double aFilterValue )
|
||||
{
|
||||
std::vector<VECTOR2D> output;
|
||||
std::vector<VECTOR2D> pointCtrl;
|
||||
|
@ -1046,7 +1047,7 @@ void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aContro
|
|||
pointCtrl.push_back( aEndPoint );
|
||||
|
||||
BEZIER_POLY converter( pointCtrl );
|
||||
converter.GetPoly( output, GetLineWidth() );
|
||||
converter.GetPoly( output, aFilterValue );
|
||||
|
||||
DrawPolyline( &output[0], output.size() );
|
||||
}
|
||||
|
|
|
@ -101,7 +101,8 @@ public:
|
|||
|
||||
/// @copydoc GAL::DrawCurve()
|
||||
virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
|
||||
const VECTOR2D& controlPointB, const VECTOR2D& endPoint ) override;
|
||||
const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
|
||||
double aFilterValue = 0.0 ) override;
|
||||
|
||||
/// @copydoc GAL::DrawBitmap()
|
||||
virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) override;
|
||||
|
|
|
@ -179,9 +179,13 @@ public:
|
|||
* @param controlPointA is the first control point.
|
||||
* @param controlPointB is the second control point.
|
||||
* @param endPoint is the end point of the spline.
|
||||
* @param aFilterValue is used by Bezier to segments approximation, if
|
||||
* the Bezier curve is not supported and needs a curve to polyline conversion.
|
||||
* aFilterValue = 0 means no filtering.
|
||||
*/
|
||||
virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
|
||||
const VECTOR2D& controlPointB, const VECTOR2D& endPoint ) {};
|
||||
const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
|
||||
double aFilterValue = 0.0 ) {};
|
||||
|
||||
/**
|
||||
* @brief Draw a bitmap image.
|
||||
|
|
|
@ -139,7 +139,8 @@ public:
|
|||
|
||||
/// @copydoc GAL::DrawCurve()
|
||||
virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
|
||||
const VECTOR2D& controlPointB, const VECTOR2D& endPoint ) override;
|
||||
const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
|
||||
double aFilterValue = 0.0 ) override;
|
||||
|
||||
/// @copydoc GAL::DrawBitmap()
|
||||
virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) override;
|
||||
|
|
|
@ -1016,10 +1016,12 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
|
|||
m_gal->SetIsFill( false );
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->SetLineWidth( thickness );
|
||||
// Use thickness as filter value to convert the curve to polyline
|
||||
// when the curve is not supported
|
||||
m_gal->DrawCurve( VECTOR2D( aSegment->GetStart() ),
|
||||
VECTOR2D( aSegment->GetBezControl1() ),
|
||||
VECTOR2D( aSegment->GetBezControl2() ),
|
||||
VECTOR2D( aSegment->GetEnd() ) );
|
||||
VECTOR2D( aSegment->GetEnd() ), thickness );
|
||||
break;
|
||||
|
||||
case S_LAST:
|
||||
|
|
Loading…
Reference in New Issue