Add native Bezier curve plot in SVG plotter.

This commit is contained in:
jean-pierre charras
2019-11-05 14:27:07 +01:00
parent bb9b226744
commit 5f3353cad1
4 changed files with 74 additions and 25 deletions
+28
View File
@@ -50,6 +50,7 @@
#include <gr_text.h>
#include <geometry/shape_line_chain.h>
#include <geometry/geometry_utils.h>
#include <bezier_curves.h>
PLOTTER::PLOTTER( )
{
@@ -198,6 +199,33 @@ void PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int r
}
void PLOTTER::BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
const wxPoint& aControl2, const wxPoint& aEnd,
int aTolerance, int aLineThickness )
{
// Generic fallback: Quadratic Bezier curve plotted as a polyline
int minSegLen = aLineThickness; // The segment min length to approximate a bezier curve
std::vector<wxPoint> ctrlPoints;
ctrlPoints.push_back( aStart );
ctrlPoints.push_back( aControl1 );
ctrlPoints.push_back( aControl2 );
ctrlPoints.push_back( aEnd );
BEZIER_POLY bezier_converter( ctrlPoints );
std::vector<wxPoint> approxPoints;
bezier_converter.GetPoly( approxPoints, minSegLen );
MoveTo( aStart );
for( unsigned ii = 1; ii < approxPoints.size()-1; ii++ )
LineTo( approxPoints[ii] );
FinishTo( aEnd );
}
void PLOTTER::PlotImage(const wxImage & aImage, const wxPoint& aPos, double aScaleFactor )
{
wxSize size( aImage.GetWidth() * aScaleFactor,