Yeet wxPoint/wxSize out of PLOTTER

This commit is contained in:
Mark Roszko
2021-12-29 19:02:50 +00:00
parent ccb94fd1a7
commit 44dc602d6b
28 changed files with 634 additions and 597 deletions
+72 -69
View File
@@ -88,9 +88,9 @@ bool PLOTTER::OpenFile( const wxString& aFullFilename )
}
DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
DPOINT PLOTTER::userToDeviceCoordinates( const VECTOR2I& aCoordinate )
{
wxPoint pos = aCoordinate - m_plotOffset;
VECTOR2I pos = aCoordinate - m_plotOffset;
// Don't allow overflows; they can cause rendering failures in some file viewers
// (such as Acrobat)
@@ -119,7 +119,7 @@ DPOINT PLOTTER::userToDeviceCoordinates( const wxPoint& aCoordinate )
}
DPOINT PLOTTER::userToDeviceSize( const wxSize& size )
DPOINT PLOTTER::userToDeviceSize( const VECTOR2I& size )
{
return DPOINT( size.x * m_plotScale * m_iuPerDeviceUnit,
size.y * m_plotScale * m_iuPerDeviceUnit );
@@ -155,15 +155,15 @@ double PLOTTER::GetDashGapLenIU() const
void PLOTTER::Arc( const SHAPE_ARC& aArc )
{
Arc( wxPoint( aArc.GetCenter() ), aArc.GetStartAngle(), aArc.GetEndAngle(), aArc.GetRadius(),
Arc( VECTOR2I( aArc.GetCenter() ), aArc.GetStartAngle(), aArc.GetEndAngle(), aArc.GetRadius(),
FILL_T::NO_FILL, aArc.GetWidth() );
}
void PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, int radius,
void PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
{
wxPoint start, end;
VECTOR2I start, end;
const int delta = 50; // increment (in 0.1 degrees) to draw circles
if( StAngle > EndAngle )
@@ -207,14 +207,14 @@ 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,
void PLOTTER::BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1,
const VECTOR2I& aControl2, const VECTOR2I& 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;
std::vector<VECTOR2I> ctrlPoints;
ctrlPoints.push_back( aStart );
ctrlPoints.push_back( aControl1 );
ctrlPoints.push_back( aControl2 );
@@ -222,7 +222,7 @@ void PLOTTER::BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
BEZIER_POLY bezier_converter( ctrlPoints );
std::vector<wxPoint> approxPoints;
std::vector<VECTOR2I> approxPoints;
bezier_converter.GetPoly( approxPoints, minSegLen );
SetCurrentLineWidth( aLineThickness );
@@ -235,15 +235,15 @@ void PLOTTER::BezierCurve( const wxPoint& aStart, const wxPoint& aControl1,
}
void PLOTTER::PlotImage(const wxImage& aImage, const wxPoint& aPos, double aScaleFactor )
void PLOTTER::PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double aScaleFactor )
{
wxSize size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
VECTOR2I size( aImage.GetWidth() * aScaleFactor, aImage.GetHeight() * aScaleFactor );
wxPoint start = aPos;
VECTOR2I start = aPos;
start.x -= size.x / 2;
start.y -= size.y / 2;
wxPoint end = start;
VECTOR2I end = start;
end.x += size.x;
end.y += size.y;
@@ -251,11 +251,12 @@ void PLOTTER::PlotImage(const wxImage& aImage, const wxPoint& aPos, double aScal
}
void PLOTTER::markerSquare( const wxPoint& position, int radius )
void PLOTTER::markerSquare( const VECTOR2I& position, int radius )
{
double r = KiROUND( radius / 1.4142 );
std::vector< wxPoint > corner_list;
wxPoint corner;
double r = KiROUND( radius / 1.4142 );
std::vector<VECTOR2I> corner_list;
VECTOR2I corner;
corner.x = position.x + r;
corner.y = position.y + r;
corner_list.push_back( corner );
@@ -276,16 +277,17 @@ void PLOTTER::markerSquare( const wxPoint& position, int radius )
}
void PLOTTER::markerCircle( const wxPoint& position, int radius )
void PLOTTER::markerCircle( const VECTOR2I& position, int radius )
{
Circle( position, radius * 2, FILL_T::NO_FILL, GetCurrentLineWidth() );
}
void PLOTTER::markerLozenge( const wxPoint& position, int radius )
void PLOTTER::markerLozenge( const VECTOR2I& position, int radius )
{
std::vector< wxPoint > corner_list;
wxPoint corner;
std::vector<VECTOR2I> corner_list;
VECTOR2I corner;
corner.x = position.x;
corner.y = position.y + radius;
corner_list.push_back( corner );
@@ -306,35 +308,35 @@ void PLOTTER::markerLozenge( const wxPoint& position, int radius )
}
void PLOTTER::markerHBar( const wxPoint& pos, int radius )
void PLOTTER::markerHBar( const VECTOR2I& pos, int radius )
{
MoveTo( wxPoint( pos.x - radius, pos.y ) );
FinishTo( wxPoint( pos.x + radius, pos.y ) );
MoveTo( VECTOR2I( pos.x - radius, pos.y ) );
FinishTo( VECTOR2I( pos.x + radius, pos.y ) );
}
void PLOTTER::markerSlash( const wxPoint& pos, int radius )
void PLOTTER::markerSlash( const VECTOR2I& pos, int radius )
{
MoveTo( wxPoint( pos.x - radius, pos.y - radius ) );
FinishTo( wxPoint( pos.x + radius, pos.y + radius ) );
MoveTo( VECTOR2I( pos.x - radius, pos.y - radius ) );
FinishTo( VECTOR2I( pos.x + radius, pos.y + radius ) );
}
void PLOTTER::markerBackSlash( const wxPoint& pos, int radius )
void PLOTTER::markerBackSlash( const VECTOR2I& pos, int radius )
{
MoveTo( wxPoint( pos.x + radius, pos.y - radius ) );
FinishTo( wxPoint( pos.x - radius, pos.y + radius ) );
MoveTo( VECTOR2I( pos.x + radius, pos.y - radius ) );
FinishTo( VECTOR2I( pos.x - radius, pos.y + radius ) );
}
void PLOTTER::markerVBar( const wxPoint& pos, int radius )
void PLOTTER::markerVBar( const VECTOR2I& pos, int radius )
{
MoveTo( wxPoint( pos.x, pos.y - radius ) );
FinishTo( wxPoint( pos.x, pos.y + radius ) );
MoveTo( VECTOR2I( pos.x, pos.y - radius ) );
FinishTo( VECTOR2I( pos.x, pos.y + radius ) );
}
void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
void PLOTTER::Marker( const VECTOR2I& position, int diametre, unsigned aShapeId )
{
int radius = diametre / 2;
@@ -456,11 +458,11 @@ void PLOTTER::Marker( const wxPoint& position, int diametre, unsigned aShapeId )
}
void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width,
void PLOTTER::segmentAsOval( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode )
{
wxPoint center( (start.x + end.x) / 2, (start.y + end.y) / 2 );
wxSize size( end.x - start.x, end.y - start.y );
VECTOR2I center( ( start.x + end.x ) / 2, ( start.y + end.y ) / 2 );
VECTOR2I size( end.x - start.x, end.y - start.y );
double orient;
if( size.y == 0 )
@@ -477,12 +479,12 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
}
void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, double orient, int width )
void PLOTTER::sketchOval( const VECTOR2I& pos, const VECTOR2I& aSize, double orient, int width )
{
SetCurrentLineWidth( width );
width = m_currentPenWidth;
int radius, deltaxy, cx, cy;
wxSize size( aSize );
VECTOR2I size( aSize );
if( size.x > size.y )
{
@@ -495,33 +497,34 @@ void PLOTTER::sketchOval( const wxPoint& pos, const wxSize& aSize, double orient
cx = -radius;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
MoveTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
cx = -radius;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
FinishTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
cx = radius;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
MoveTo( wxPoint( cx + pos.x, cy + pos.y ) );
MoveTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
cx = radius;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
FinishTo( wxPoint( cx + pos.x, cy + pos.y ) );
FinishTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
cx = 0;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
Arc( wxPoint( cx + pos.x, cy + pos.y ), orient + 1800, orient + 3600, radius, FILL_T::NO_FILL );
Arc( VECTOR2I( cx + pos.x, cy + pos.y ), orient + 1800, orient + 3600, radius,
FILL_T::NO_FILL );
cx = 0;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
Arc( wxPoint( cx + pos.x, cy + pos.y ), orient, orient + 1800, radius, FILL_T::NO_FILL );
Arc( VECTOR2I( cx + pos.x, cy + pos.y ), orient, orient + 1800, radius, FILL_T::NO_FILL );
}
void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
void PLOTTER::ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode, void* aData )
{
if( tracemode == FILLED )
@@ -545,7 +548,7 @@ void PLOTTER::ThickSegment( const wxPoint& start, const wxPoint& end, int width,
}
void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
void PLOTTER::ThickArc( const VECTOR2I& centre, double StAngle, double EndAngle,
int radius, int width, OUTLINE_MODE tracemode, void* aData )
{
if( tracemode == FILLED )
@@ -563,7 +566,7 @@ void PLOTTER::ThickArc( const wxPoint& centre, double StAngle, double EndAngle,
}
void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
void PLOTTER::ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width,
OUTLINE_MODE tracemode, void* aData )
{
if( tracemode == FILLED )
@@ -573,10 +576,10 @@ void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
else
{
SetCurrentLineWidth( -1 );
wxPoint offsetp1( p1.x - (width - m_currentPenWidth) / 2,
p1.y - (width - m_currentPenWidth) / 2 );
wxPoint offsetp2( p2.x + (width - m_currentPenWidth) / 2,
p2.y + (width - m_currentPenWidth) / 2 );
VECTOR2I offsetp1( p1.x - ( width - m_currentPenWidth ) / 2,
p1.y - (width - m_currentPenWidth) / 2 );
VECTOR2I offsetp2( p2.x + ( width - m_currentPenWidth ) / 2,
p2.y + (width - m_currentPenWidth) / 2 );
Rect( offsetp1, offsetp2, FILL_T::NO_FILL, -1 );
offsetp1.x += ( width - m_currentPenWidth );
offsetp1.y += ( width - m_currentPenWidth );
@@ -587,7 +590,7 @@ void PLOTTER::ThickRect( const wxPoint& p1, const wxPoint& p2, int width,
}
void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, OUTLINE_MODE tracemode,
void PLOTTER::ThickCircle( const VECTOR2I& pos, int diametre, int width, OUTLINE_MODE tracemode,
void* aData )
{
if( tracemode == FILLED )
@@ -603,7 +606,7 @@ void PLOTTER::ThickCircle( const wxPoint& pos, int diametre, int width, OUTLINE_
}
void PLOTTER::FilledCircle( const wxPoint& pos, int diametre, OUTLINE_MODE tracemode, void* aData )
void PLOTTER::FilledCircle( const VECTOR2I& pos, int diametre, OUTLINE_MODE tracemode, void* aData )
{
if( tracemode == FILLED )
{
@@ -619,7 +622,7 @@ void PLOTTER::FilledCircle( const wxPoint& pos, int diametre, OUTLINE_MODE trace
void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int aWidth, void* aData )
{
std::vector<wxPoint> cornerList;
std::vector<VECTOR2I> cornerList;
cornerList.reserve( aCornerList.PointCount() );
for( int ii = 0; ii < aCornerList.PointCount(); ii++ )
@@ -649,19 +652,19 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int a
* @param aData is a parameter used by some plotters in SetCurrentLineWidth(),
* not directly used here.
*/
void PLOTTER::Text( const wxPoint& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const wxSize& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aPenWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aPenWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
{
SetColor( aColor );
SetCurrentLineWidth( aPenWidth, aData );