EDA_ANGLE for plotters.

Also fixes a compile error in the PNS Playground.
This commit is contained in:
Jeff Young 2022-01-16 01:06:25 +00:00
parent 1539fa5af2
commit 9b661aea10
52 changed files with 865 additions and 923 deletions

View File

@ -443,23 +443,23 @@ VECTOR2I EDA_SHAPE::GetArcMid() const
}
void EDA_SHAPE::CalcArcAngles( double& aStartAngle, double& aEndAngle ) const
void EDA_SHAPE::CalcArcAngles( EDA_ANGLE& aStartAngle, EDA_ANGLE& aEndAngle ) const
{
VECTOR2D startRadial( GetStart() - getCenter() );
VECTOR2D endRadial( GetEnd() - getCenter() );
aStartAngle = 180.0 / M_PI * atan2( startRadial.y, startRadial.x );
aEndAngle = 180.0 / M_PI * atan2( endRadial.y, endRadial.x );
aStartAngle = EDA_ANGLE( startRadial );
aEndAngle = EDA_ANGLE( endRadial );
if( aEndAngle == aStartAngle )
aEndAngle = aStartAngle + 360.0; // ring, not null
aEndAngle = aStartAngle + ANGLE_360; // ring, not null
if( aStartAngle > aEndAngle )
{
if( aEndAngle < 0 )
aEndAngle = NormalizeAngleDegrees( aEndAngle, 0.0, 360.0 );
if( aEndAngle < ANGLE_0 )
aEndAngle.Normalize();
else
aStartAngle = NormalizeAngleDegrees( aStartAngle, -360.0, 0.0 );
aStartAngle = aStartAngle.Normalize() - ANGLE_360;
}
}
@ -514,12 +514,12 @@ void EDA_SHAPE::SetArcGeometry( const VECTOR2I& aStart, const VECTOR2I& aMid, co
EDA_ANGLE EDA_SHAPE::GetArcAngle() const
{
double startAngle;
double endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
CalcArcAngles( startAngle, endAngle );
return EDA_ANGLE( endAngle - startAngle, DEGREES_T );
return endAngle - startAngle;
}
@ -705,18 +705,18 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
if( abs( radius - dist ) <= maxdist )
{
double startAngle;
double endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
CalcArcAngles( startAngle, endAngle );
if( m_eeWinding && NormalizeAngleDegrees( startAngle - endAngle, -180.0, 180.0 ) > 0 )
if( m_eeWinding && ( startAngle - endAngle ).Normalize180() > ANGLE_0 )
std::swap( startAngle, endAngle );
double relPosAngle = 180.0 / M_PI * atan2( relPos.y, relPos.x );
EDA_ANGLE relPosAngle( relPos );
startAngle = NormalizeAngleDegrees( startAngle, 0.0, 360.0 );
endAngle = NormalizeAngleDegrees( endAngle, 0.0, 360.0 );
relPosAngle = NormalizeAngleDegrees( relPosAngle, 0.0, 360.0 );
startAngle.Normalize();
endAngle.Normalize();
relPosAngle.Normalize();
if( endAngle > startAngle )
return relPosAngle >= startAngle && relPosAngle <= endAngle;
@ -995,13 +995,13 @@ std::vector<VECTOR2I> EDA_SHAPE::GetRectCorners() const
void EDA_SHAPE::computeArcBBox( EDA_RECT& aBBox ) const
{
VECTOR2I start = m_start;
VECTOR2I end = m_end;
double t1, t2;
VECTOR2I start = m_start;
VECTOR2I end = m_end;
EDA_ANGLE t1, t2;
CalcArcAngles( t1, t2 );
if( m_eeWinding && NormalizeAngleDegrees( t1 - t2, -180.0, 180.0 ) > 0 )
if( m_eeWinding && ( t1 - t2 ).Normalize180() > ANGLE_0 )
std::swap( start, end );
// Do not include the center, which is not necessarily inside the BB of an arc with a small
@ -1038,14 +1038,16 @@ void EDA_SHAPE::computeArcBBox( EDA_RECT& aBBox ) const
quarter = 0;
}
int radius = GetRadius();
VECTOR2I startRadial = start - m_arcCenter;
VECTOR2I endRadial = end - m_arcCenter;
double angleStart = ArcTangente( startRadial.y, startRadial.x );
double arcAngle = RAD2DECIDEG( endRadial.Angle() - startRadial.Angle() );
int angle = (int) NormalizeAnglePos( angleStart ) % 900 + NormalizeAnglePos( arcAngle );
int radius = GetRadius();
VECTOR2I startRadial = start - m_arcCenter;
EDA_ANGLE angle = EDA_ANGLE( startRadial ).Normalize();
while( angle > 900 )
while( angle >= ANGLE_90 )
angle -= ANGLE_90;
angle += GetArcAngle();
while( angle > ANGLE_90 )
{
switch( quarter )
{
@ -1056,7 +1058,7 @@ void EDA_SHAPE::computeArcBBox( EDA_RECT& aBBox ) const
}
++quarter %= 4;
angle -= 900;
angle -= ANGLE_90;
}
}

View File

@ -624,50 +624,52 @@ void DXF_PLOTTER::ThickSegment( const VECTOR2I& aStart, const VECTOR2I& aEnd, in
}
void DXF_PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
void DXF_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
wxASSERT( m_outputFile );
if( radius <= 0 )
if( aRadius <= 0 )
return;
// In DXF, arcs are drawn CCW.
// In Kicad, arcs are CW or CCW
// If StAngle > EndAngle, it is CW. So transform it to CCW
if( StAngle > EndAngle )
{
std::swap( StAngle, EndAngle );
}
EDA_ANGLE startAngle( aStartAngle );
EDA_ANGLE endAngle( aEndAngle );
DPOINT centre_dev = userToDeviceCoordinates( centre );
double radius_dev = userToDeviceSize( radius );
// In DXF, arcs are drawn CCW.
// If startAngle > endAngle, it is CW. So transform it to CCW
if( startAngle > endAngle )
std::swap( startAngle, endAngle );
VECTOR2D centre_device = userToDeviceCoordinates( aCenter );
double radius_device = userToDeviceSize( aRadius );
// Emit a DXF ARC entity
wxString cname = getDXFColorName( m_currentColor );
fprintf( m_outputFile,
"0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
TO_UTF8( cname ),
centre_dev.x, centre_dev.y, radius_dev,
StAngle / 10.0, EndAngle / 10.0 );
centre_device.x, centre_device.y, radius_device,
startAngle.AsDegrees(), endAngle.AsDegrees() );
}
void DXF_PLOTTER::FlashPadOval( const VECTOR2I& pos, const VECTOR2I& aSize, double orient,
OUTLINE_MODE trace_mode, void* aData )
void DXF_PLOTTER::FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode, void* aData )
{
wxASSERT( m_outputFile );
VECTOR2I size( aSize );
VECTOR2I size( aSize );
EDA_ANGLE orient( aOrient );
/* The chip is reduced to an oval tablet with size.y > size.x
* (Oval vertical orientation 0) */
if( size.x > size.y )
{
std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
orient += ANGLE_90;
}
sketchOval( pos, size, orient, -1 );
sketchOval( aPos, size, orient, -1 );
}
@ -679,15 +681,15 @@ void DXF_PLOTTER::FlashPadCircle( const VECTOR2I& pos, int diametre,
}
void DXF_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& padsize,
double orient, OUTLINE_MODE trace_mode, void* aData )
void DXF_PLOTTER::FlashPadRect( const VECTOR2I& aPos, const VECTOR2I& aPadSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode, void* aData )
{
wxASSERT( m_outputFile );
VECTOR2I size;
int ox, oy, fx, fy;
size.x = padsize.x / 2;
size.y = padsize.y / 2;
VECTOR2I size, start, end;
size.x = aPadSize.x / 2;
size.y = aPadSize.y / 2;
if( size.x < 0 )
size.x = 0;
@ -698,61 +700,53 @@ void DXF_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& padsize,
// If a dimension is zero, the trace is reduced to 1 line
if( size.x == 0 )
{
ox = pos.x;
oy = pos.y - size.y;
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
fx = pos.x;
fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
MoveTo( VECTOR2I( ox, oy ) );
FinishTo( VECTOR2I( fx, fy ) );
start = VECTOR2I( aPos.x, aPos.y - size.y );
end = VECTOR2I( aPos.x, aPos.y + size.y );
RotatePoint( start, aPos, aOrient );
RotatePoint( end, aPos, aOrient );
MoveTo( start );
FinishTo( end );
return;
}
if( size.y == 0 )
{
ox = pos.x - size.x;
oy = pos.y;
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
fx = pos.x + size.x;
fy = pos.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
MoveTo( VECTOR2I( ox, oy ) );
FinishTo( VECTOR2I( fx, fy ) );
start = VECTOR2I( aPos.x - size.x, aPos.y );
end = VECTOR2I( aPos.x + size.x, aPos.y );
RotatePoint( start, aPos, aOrient );
RotatePoint( end, aPos, aOrient );
MoveTo( start );
FinishTo( end );
return;
}
ox = pos.x - size.x;
oy = pos.y - size.y;
RotatePoint( &ox, &oy, pos.x, pos.y, orient );
MoveTo( VECTOR2I( ox, oy ) );
start = VECTOR2I( aPos.x - size.x, aPos.y - size.y );
RotatePoint( start, aPos, aOrient );
MoveTo( start );
fx = pos.x - size.x;
fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
LineTo( VECTOR2I( fx, fy ) );
end = VECTOR2I( aPos.x - size.x, aPos.y + size.y );
RotatePoint( end, aPos, aOrient );
LineTo( end );
fx = pos.x + size.x;
fy = pos.y + size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
LineTo( VECTOR2I( fx, fy ) );
end = VECTOR2I( aPos.x + size.x, aPos.y + size.y );
RotatePoint( end, aPos, aOrient );
LineTo( end );
fx = pos.x + size.x;
fy = pos.y - size.y;
RotatePoint( &fx, &fy, pos.x, pos.y, orient );
LineTo( VECTOR2I( fx, fy ) );
end = VECTOR2I( aPos.x + size.x, aPos.y - size.y );
RotatePoint( end, aPos, aOrient );
LineTo( end );
FinishTo( VECTOR2I( ox, oy ) );
FinishTo( start );
}
void DXF_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData )
{
SHAPE_POLY_SET outline;
TransformRoundChamferedRectToPolygon( outline, aPadPos, aSize, aOrient, aCornerRadius,
0.0, 0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
TransformRoundChamferedRectToPolygon( outline, aPadPos, aSize, aOrient, aCornerRadius, 0.0, 0,
0, GetPlotterArcHighDef(), ERROR_INSIDE );
// TransformRoundRectToPolygon creates only one convex polygon
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
@ -766,7 +760,7 @@ void DXF_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aS
}
void DXF_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aOrient, SHAPE_POLY_SET* aPolygons,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData )
{
for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
@ -784,7 +778,8 @@ void DXF_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize
void DXF_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTrace_Mode, void* aData )
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
wxASSERT( m_outputFile );
VECTOR2I coord[4]; /* coord actual corners of a trapezoidal trace */
@ -806,7 +801,8 @@ void DXF_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorn
void DXF_PLOTTER::FlashRegularPolygon( const VECTOR2I& aShapePos, int aRadius, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
// Do nothing
wxASSERT( 0 );

View File

@ -407,13 +407,15 @@ void GERBER_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( VECTOR2I( aWidth, aWidth ), 0, 0.0, APERTURE::AT_PLOTTING, aperture_attribute );
selectAperture( VECTOR2I( aWidth, aWidth ), 0, ANGLE_0, APERTURE::AT_PLOTTING,
aperture_attribute );
m_currentPenWidth = aWidth;
}
int GERBER_PLOTTER::GetOrCreateAperture( const VECTOR2I& aSize, int aRadius, double aRotDegree,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute )
int GERBER_PLOTTER::GetOrCreateAperture( const VECTOR2I& aSize, int aRadius,
const EDA_ANGLE& aRotation, APERTURE::APERTURE_TYPE aType,
int aApertureAttribute )
{
int last_D_code = 9;
@ -424,18 +426,18 @@ int GERBER_PLOTTER::GetOrCreateAperture( const VECTOR2I& aSize, int aRadius, dou
last_D_code = tool->m_DCode;
if( (tool->m_Type == aType) && (tool->m_Size == aSize) &&
(tool->m_Radius == aRadius) && (tool->m_Rotation == aRotDegree) &&
(tool->m_Radius == aRadius) && (tool->m_Rotation == aRotation) &&
(tool->m_ApertureAttribute == aApertureAttribute) )
return idx;
}
// Allocate a new aperture
APERTURE new_tool;
new_tool.m_Size = aSize;
new_tool.m_Type = aType;
new_tool.m_Radius = aRadius;
new_tool.m_Rotation = aRotDegree;
new_tool.m_DCode = last_D_code + 1;
new_tool.m_Size = aSize;
new_tool.m_Type = aType;
new_tool.m_Radius = aRadius;
new_tool.m_Rotation = aRotation;
new_tool.m_DCode = last_D_code + 1;
new_tool.m_ApertureAttribute = aApertureAttribute;
m_apertures.push_back( new_tool );
@ -444,8 +446,9 @@ int GERBER_PLOTTER::GetOrCreateAperture( const VECTOR2I& aSize, int aRadius, dou
}
int GERBER_PLOTTER::GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners, double aRotDegree,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute )
int GERBER_PLOTTER::GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners,
const EDA_ANGLE& aRotation, APERTURE::APERTURE_TYPE aType,
int aApertureAttribute )
{
int last_D_code = 9;
@ -469,7 +472,7 @@ int GERBER_PLOTTER::GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners,
if( (tool->m_Type == aType) &&
(tool->m_Corners.size() == aCorners.size() ) &&
(tool->m_Rotation == aRotDegree) &&
(tool->m_Rotation == aRotation) &&
(tool->m_ApertureAttribute == aApertureAttribute) )
{
// A candidate is found. the corner lists must be similar
@ -487,7 +490,7 @@ int GERBER_PLOTTER::GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners,
new_tool.m_Size = VECTOR2I( 0, 0 ); // Not used
new_tool.m_Type = aType;
new_tool.m_Radius = 0; // Not used
new_tool.m_Rotation = aRotDegree;
new_tool.m_Rotation = aRotation;
new_tool.m_DCode = last_D_code + 1;
new_tool.m_ApertureAttribute = aApertureAttribute;
@ -497,14 +500,14 @@ int GERBER_PLOTTER::GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners,
}
void GERBER_PLOTTER::selectAperture( const VECTOR2I& aSize, int aRadius, double aRotDegree,
void GERBER_PLOTTER::selectAperture( const VECTOR2I& aSize, int aRadius, const EDA_ANGLE& aRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute )
{
bool change = ( m_currentApertureIdx < 0 ) ||
( m_apertures[m_currentApertureIdx].m_Type != aType ) ||
( m_apertures[m_currentApertureIdx].m_Size != aSize ) ||
( m_apertures[m_currentApertureIdx].m_Radius != aRadius ) ||
( m_apertures[m_currentApertureIdx].m_Rotation != aRotDegree );
( m_apertures[m_currentApertureIdx].m_Rotation != aRotation );
if( !change )
change = m_apertures[m_currentApertureIdx].m_ApertureAttribute != aApertureAttribute;
@ -512,20 +515,21 @@ void GERBER_PLOTTER::selectAperture( const VECTOR2I& aSize, int aRadius, double
if( change )
{
// Pick an existing aperture or create a new one
m_currentApertureIdx = GetOrCreateAperture( aSize, aRadius, aRotDegree,
aType, aApertureAttribute );
m_currentApertureIdx = GetOrCreateAperture( aSize, aRadius, aRotation, aType,
aApertureAttribute );
fprintf( m_outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode );
}
}
void GERBER_PLOTTER::selectAperture( const std::vector<VECTOR2I>& aCorners, double aRotDegree,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute )
void GERBER_PLOTTER::selectAperture( const std::vector<VECTOR2I>& aCorners,
const EDA_ANGLE& aRotation, APERTURE::APERTURE_TYPE aType,
int aApertureAttribute )
{
bool change = ( m_currentApertureIdx < 0 ) ||
( m_apertures[m_currentApertureIdx].m_Type != aType ) ||
( m_apertures[m_currentApertureIdx].m_Corners.size() != aCorners.size() ) ||
( m_apertures[m_currentApertureIdx].m_Rotation != aRotDegree );
( m_apertures[m_currentApertureIdx].m_Rotation != aRotation );
if( !change ) // Compare corner lists
{
@ -545,14 +549,14 @@ void GERBER_PLOTTER::selectAperture( const std::vector<VECTOR2I>& aCorners, doub
if( change )
{
// Pick an existing aperture or create a new one
m_currentApertureIdx = GetOrCreateAperture( aCorners, aRotDegree,
aType, aApertureAttribute );
m_currentApertureIdx = GetOrCreateAperture( aCorners, aRotation, aType,
aApertureAttribute );
fprintf( m_outputFile, "D%d*\n", m_apertures[m_currentApertureIdx].m_DCode );
}
}
void GERBER_PLOTTER::selectAperture( int aDiameter, double aPolygonRotation,
void GERBER_PLOTTER::selectAperture( int aDiameter, const EDA_ANGLE& aPolygonRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute )
{
// Pick an existing aperture or create a new one, matching the
@ -562,7 +566,7 @@ void GERBER_PLOTTER::selectAperture( int aDiameter, double aPolygonRotation,
wxASSERT( aType>= APERTURE::APERTURE_TYPE::AT_REGULAR_POLY3 &&
aType <= APERTURE::APERTURE_TYPE::AT_REGULAR_POLY12 );
VECTOR2I size( aDiameter, (int) ( aPolygonRotation * 1000.0 ) );
VECTOR2I size( aDiameter, (int) ( aPolygonRotation.AsDegrees() * 1000.0 ) );
selectAperture( VECTOR2I( 0, 0 ), aDiameter / 2, aPolygonRotation, aType, aApertureAttribute );
}
@ -638,7 +642,7 @@ void GERBER_PLOTTER::writeApertureList()
case APERTURE::AT_REGULAR_POLY11:
case APERTURE::AT_REGULAR_POLY12:
sprintf( cbuf, "P,%#fX%dX%#f*%%\n", tool.GetDiameter() * fscale,
tool.GetRegPolyVerticeCount(), tool.GetRotation() );
tool.GetRegPolyVerticeCount(), tool.GetRotation().AsDegrees() );
break;
case APERTURE::AM_ROUND_RECT: // Aperture macro for round rect pads
@ -654,7 +658,7 @@ void GERBER_PLOTTER::writeApertureList()
// Rotate the corner coordinates:
for( int ii = 0; ii < 4; ii++ )
RotatePoint( corners[ii], -tool.m_Rotation*10.0 );
RotatePoint( corners[ii], -tool.m_Rotation );
sprintf( cbuf, "%s,%#fX", APER_MACRO_ROUNDRECT_NAME,
tool.m_Radius * fscale );
@ -675,7 +679,7 @@ void GERBER_PLOTTER::writeApertureList()
case APERTURE::AM_ROT_RECT: // Aperture macro for rotated rect pads
sprintf( cbuf, "%s,%#fX%#fX%#f*%%\n", APER_MACRO_ROT_RECT_NAME,
tool.m_Size.x * fscale, tool.m_Size.y * fscale,
tool.m_Rotation );
tool.m_Rotation.AsDegrees() );
break;
case APERTURE::APER_MACRO_OUTLINE4P: // Aperture macro for trapezoid pads
@ -712,7 +716,7 @@ void GERBER_PLOTTER::writeApertureList()
}
// close outline and output rotation
sprintf( cbuf, "%#f*%%\n", tool.m_Rotation );
sprintf( cbuf, "%#f*%%\n", tool.m_Rotation.AsDegrees() );
break;
case APERTURE::AM_ROTATED_OVAL: // Aperture macro for rotated oval pads
@ -727,8 +731,8 @@ void GERBER_PLOTTER::writeApertureList()
// Center of the circle on the segment end point:
VECTOR2I end( - seg_len/2, 0 );
RotatePoint( start, tool.m_Rotation*10.0 );
RotatePoint( end, tool.m_Rotation*10.0 );
RotatePoint( start, tool.m_Rotation );
RotatePoint( end, tool.m_Rotation );
sprintf( cbuf, "%s,%#fX%#fX%#fX%#fX%#fX0*%%\n", APER_MACRO_SHAPE_OVAL_NAME,
tool.m_Size.y * fscale, // width
@ -745,7 +749,10 @@ void GERBER_PLOTTER::writeApertureList()
// Write DCODE id ( "%ADDxx" is already in buffer) and rotation
// the full line is something like :%ADD12FreePoly1,45.000000*%
sprintf( cbuf, "%s%d,%#f*%%\n", AM_FREEPOLY_BASENAME, idx, tool.m_Rotation );
sprintf( cbuf, "%s%d,%#f*%%\n",
AM_FREEPOLY_BASENAME,
idx,
tool.m_Rotation.AsDegrees() );
break;
}
}
@ -814,18 +821,18 @@ void GERBER_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill,
void GERBER_PLOTTER::Circle( const VECTOR2I& aCenter, int aDiameter, FILL_T aFill, int aWidth )
{
Arc( aCenter, 0, 3600, aDiameter / 2, aFill, aWidth );
Arc( aCenter, ANGLE_0, ANGLE_360, aDiameter / 2, aFill, aWidth );
}
void GERBER_PLOTTER::Arc( const VECTOR2I& aCenter, double aStAngle, double aEndAngle, int aRadius,
FILL_T aFill, int aWidth )
void GERBER_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
SetCurrentLineWidth( aWidth );
// aFill is not used here.
plotArc( aCenter, aStAngle, aEndAngle, aRadius, false );
plotArc( aCenter, aStartAngle, aEndAngle, aRadius, false );
}
@ -860,26 +867,26 @@ void GERBER_PLOTTER::plotArc( const SHAPE_ARC& aArc, bool aPlotInRegion )
}
void GERBER_PLOTTER::plotArc( const VECTOR2I& aCenter, double aStAngle, double aEndAngle,
int aRadius, bool aPlotInRegion )
void GERBER_PLOTTER::plotArc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, bool aPlotInRegion )
{
VECTOR2I start, end;
start.x = aCenter.x + KiROUND( cosdecideg( aRadius, aStAngle ) );
start.y = aCenter.y - KiROUND( sindecideg( aRadius, aStAngle ) );
start.x = aCenter.x + KiROUND( aRadius * cos( aStartAngle.AsRadians() ) );
start.y = aCenter.y - KiROUND( aRadius * sin( aStartAngle.AsRadians() ) );
if( !aPlotInRegion )
MoveTo( start );
else
LineTo( start );
end.x = aCenter.x + KiROUND( cosdecideg( aRadius, aEndAngle ) );
end.y = aCenter.y - KiROUND( sindecideg( aRadius, aEndAngle ) );
end.x = aCenter.x + KiROUND( aRadius * cos( aEndAngle.AsRadians() ) );
end.y = aCenter.y - KiROUND( aRadius * sin( aEndAngle.AsRadians() ) );
DPOINT devEnd = userToDeviceCoordinates( end );
DPOINT devCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start );
fprintf( m_outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode
if( aStAngle < aEndAngle )
if( aStartAngle < aEndAngle )
fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW
else
fprintf( m_outputFile, "G02*\n" ); // Active circular interpolation, CW
@ -1115,26 +1122,27 @@ void GERBER_PLOTTER::ThickSegment( const VECTOR2I& start, const VECTOR2I& end, i
}
}
void GERBER_PLOTTER::ThickArc( const VECTOR2I& centre, double StAngle, double EndAngle,
int radius, int width, OUTLINE_MODE tracemode, void* aData )
void GERBER_PLOTTER::ThickArc( const VECTOR2I& centre, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, int aWidth,
OUTLINE_MODE tracemode, void* aData )
{
GBR_METADATA *gbr_metadata = static_cast<GBR_METADATA*>( aData );
SetCurrentLineWidth( width, gbr_metadata );
SetCurrentLineWidth( aWidth, gbr_metadata );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
if( tracemode == FILLED )
{
Arc( centre, StAngle, EndAngle, radius, FILL_T::NO_FILL, DO_NOT_SET_LINE_WIDTH );
Arc( centre, aStartAngle, aEndAngle, aRadius, FILL_T::NO_FILL, DO_NOT_SET_LINE_WIDTH );
}
else
{
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
Arc( centre, StAngle, EndAngle, radius - ( width - m_currentPenWidth ) / 2, FILL_T::NO_FILL,
DO_NOT_SET_LINE_WIDTH );
Arc( centre, StAngle, EndAngle, radius + ( width - m_currentPenWidth ) / 2, FILL_T::NO_FILL,
DO_NOT_SET_LINE_WIDTH );
Arc( centre, aStartAngle, aEndAngle, aRadius - ( aWidth - m_currentPenWidth ) / 2,
FILL_T::NO_FILL, DO_NOT_SET_LINE_WIDTH );
Arc( centre, aStartAngle, aEndAngle, aRadius + ( aWidth - m_currentPenWidth ) / 2,
FILL_T::NO_FILL, DO_NOT_SET_LINE_WIDTH );
}
}
@ -1238,7 +1246,7 @@ void GERBER_PLOTTER::FlashPadCircle( const VECTOR2I& pos, int diametre, OUTLINE_
DPOINT pos_dev = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, 0.0, APERTURE::AT_CIRCLE, aperture_attrib );
selectAperture( size, 0, ANGLE_0, APERTURE::AT_CIRCLE, aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
@ -1248,33 +1256,34 @@ void GERBER_PLOTTER::FlashPadCircle( const VECTOR2I& pos, int diametre, OUTLINE_
}
void GERBER_PLOTTER::FlashPadOval( const VECTOR2I& pos, const VECTOR2I& aSize, double orient,
OUTLINE_MODE trace_mode, void* aData )
void GERBER_PLOTTER::FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode, void* aData )
{
wxASSERT( m_outputFile );
VECTOR2I size( aSize );
VECTOR2I size( aSize );
EDA_ANGLE orient( aOrient );
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
// Flash a vertical or horizontal shape (this is a basic aperture).
if( ( orient == 0 || orient == 900 || orient == 1800 || orient == 2700 )
&& trace_mode == FILLED )
if( orient.IsCardinal() && aTraceMode == FILLED )
{
if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */
if( orient == ANGLE_90 || orient == ANGLE_270 ) /* orientation turned 90 deg. */
std::swap( size.x, size.y );
DPOINT pos_dev = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, 0.0, APERTURE::AT_OVAL, aperture_attrib );
VECTOR2I pos_device = userToDeviceCoordinates( aPos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, ANGLE_0, APERTURE::AT_OVAL, aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
emitDcode( pos_dev, 3 );
emitDcode( pos_device, 3 );
}
else // Plot pad as region.
// Only regions and flashed items accept a object attribute TO.P for the pin name
{
if( trace_mode == FILLED )
if( aTraceMode == FILLED )
{
#ifdef GBR_USE_MACROS_FOR_ROTATED_OVAL
if( !m_gerberDisableApertMacros )
@ -1287,27 +1296,27 @@ void GERBER_PLOTTER::FlashPadOval( const VECTOR2I& pos, const VECTOR2I& aSize, d
if( size.x < size.y )
{
std::swap( size.x, size.y );
orient += 900;
orient += ANGLE_90;
if( orient > 1800 )
orient -= 1800;
if( orient > ANGLE_180 )
orient -= ANGLE_180;
}
DPOINT pos_dev = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, orient/10.0, APERTURE::AM_ROTATED_OVAL, aperture_attrib );
VECTOR2I pos_device = userToDeviceCoordinates( aPos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, orient, APERTURE::AM_ROTATED_OVAL, aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
emitDcode( pos_dev, 3 );
emitDcode( pos_device, 3 );
return;
}
// Draw the oval as round rect pad with a radius = 50% min size)
// In gerber file, it will be drawn as a region with arcs, and can be
// detected as pads (similar to a flashed pad)
FlashPadRoundRect( pos, aSize, std::min( aSize.x, aSize.y ) / 2,
orient, FILLED, aData );
FlashPadRoundRect( aPos, aSize, std::min( aSize.x, aSize.y ) / 2, orient, FILLED,
aData );
}
else // Non filled shape: plot outlines:
{
@ -1315,37 +1324,34 @@ void GERBER_PLOTTER::FlashPadOval( const VECTOR2I& pos, const VECTOR2I& aSize, d
{
std::swap( size.x, size.y );
if( orient < 2700 )
orient += 900;
if( orient < ANGLE_270 )
orient += ANGLE_90;
else
orient -= 2700;
orient -= ANGLE_270;
}
sketchOval( pos, size, orient, -1 );
sketchOval( aPos, size, orient, -1 );
}
}
}
void GERBER_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& aSize,
double orient, OUTLINE_MODE trace_mode, void* aData )
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode, void* aData )
{
wxASSERT( m_outputFile );
VECTOR2I size( aSize );
VECTOR2I size( aSize );
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
// Plot as an aperture flash
switch( int( orient ) )
{
case 900:
case 2700: // rotation of 90 degrees or 270 swaps sizes
if( aOrient == ANGLE_90 || aOrient == ANGLE_270 )
std::swap( size.x, size.y );
KI_FALLTHROUGH;
case 0:
case 1800:
if( trace_mode == SKETCH )
if( aOrient.IsCardinal() )
{
if( aTraceMode == SKETCH )
{
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
@ -1359,59 +1365,58 @@ void GERBER_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& aSize,
}
else
{
DPOINT pos_dev = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, 0.0, APERTURE::AT_RECT, aperture_attrib );
VECTOR2I pos_device = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, ANGLE_0, APERTURE::AT_RECT, aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
emitDcode( pos_dev, 3 );
emitDcode( pos_device, 3 );
}
break;
default:
}
else
{
#ifdef GBR_USE_MACROS_FOR_ROTATED_RECT
if( trace_mode != SKETCH && !m_gerberDisableApertMacros )
if( aTraceMode != SKETCH && !m_gerberDisableApertMacros )
{
m_hasApertureRotRect = true;
DPOINT pos_dev = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, orient/10.0, APERTURE::AM_ROT_RECT, aperture_attrib );
VECTOR2I pos_device = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, aOrient, APERTURE::AM_ROT_RECT, aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
emitDcode( pos_dev, 3 );
break;
emitDcode( pos_device, 3 );
}
else
#endif
{
// plot pad shape as Gerber region
VECTOR2I coord[4];
// coord[0] is assumed the lower left
// coord[1] is assumed the upper left
// coord[2] is assumed the upper right
// coord[3] is assumed the lower right
// plot pad shape as Gerber region
VECTOR2I coord[4];
// coord[0] is assumed the lower left
// coord[1] is assumed the upper left
// coord[2] is assumed the upper right
// coord[3] is assumed the lower right
coord[0].x = -size.x/2; // lower left
coord[0].y = size.y/2;
coord[1].x = -size.x/2; // upper left
coord[1].y = -size.y/2;
coord[2].x = size.x/2; // upper right
coord[2].y = -size.y/2;
coord[3].x = size.x/2; // lower right
coord[3].y = size.y/2;
coord[0].x = -size.x/2; // lower left
coord[0].y = size.y/2;
coord[1].x = -size.x/2; // upper left
coord[1].y = -size.y/2;
coord[2].x = size.x/2; // upper right
coord[2].y = -size.y/2;
coord[3].x = size.x/2; // lower right
coord[3].y = size.y/2;
FlashPadTrapez( pos, coord, orient, trace_mode, aData );
FlashPadTrapez( pos, coord, aOrient, aTraceMode, aData );
}
break;
}
}
void GERBER_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData )
{
@ -1420,8 +1425,8 @@ void GERBER_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I&
if( aTraceMode != FILLED )
{
SHAPE_POLY_SET outline;
TransformRoundChamferedRectToPolygon( outline, aPadPos, aSize, aOrient, aCornerRadius,
0.0, 0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
TransformRoundChamferedRectToPolygon( outline, aPadPos, aSize, aOrient, aCornerRadius, 0.0,
0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata );
outline.Inflate( -GetCurrentLineWidth()/2, 16 );
@ -1450,8 +1455,8 @@ void GERBER_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I&
DPOINT pos_dev = userToDeviceCoordinates( aPadPos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( aSize, aCornerRadius, aOrient/10.0,
APERTURE::AM_ROUND_RECT, aperture_attrib );
selectAperture( aSize, aCornerRadius, aOrient, APERTURE::AM_ROUND_RECT,
aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
@ -1492,7 +1497,7 @@ void GERBER_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I&
void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const VECTOR2I& aSize,
int aCornerRadius, double aOrient )
int aCornerRadius, const EDA_ANGLE& aOrient )
{
// The region outline is generated by 4 sides and 4 90 deg arcs
// 1 --- 2
@ -1506,14 +1511,12 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
// in user coordinates
struct RR_EDGE
{
VECTOR2I m_start;
VECTOR2I m_end;
VECTOR2I m_center;
// in decidegrees: angle start. angle end = m_arc_angle_start+arc_angle
double m_arc_angle_start;
VECTOR2I m_start;
VECTOR2I m_end;
VECTOR2I m_center;
EDA_ANGLE m_arc_angle_start;
};
const double arc_angle = -900.0; // in decidegrees
int hsizeX = aSize.x/2;
int hsizeY = aSize.y/2;
@ -1529,7 +1532,7 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
curr_edge.m_end.y = -hsizeY + aCornerRadius;
curr_edge.m_center.x = -hsizeX + aCornerRadius;
curr_edge.m_center.y = curr_edge.m_end.y;
curr_edge.m_arc_angle_start = aOrient + 1800.0; // En decidegree
curr_edge.m_arc_angle_start = aOrient + ANGLE_180;
rr_outline.push_back( curr_edge );
@ -1540,7 +1543,7 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
curr_edge.m_end.y = curr_edge.m_start.y;
curr_edge.m_center.x = curr_edge.m_end.x;
curr_edge.m_center.y = -hsizeY + aCornerRadius;
curr_edge.m_arc_angle_start = aOrient + 900.0; // En decidegree
curr_edge.m_arc_angle_start = aOrient + ANGLE_90;
rr_outline.push_back( curr_edge );
@ -1551,7 +1554,7 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
curr_edge.m_end.y = hsizeY - aCornerRadius;
curr_edge.m_center.x = hsizeX - aCornerRadius;
curr_edge.m_center.y = curr_edge.m_end.y;
curr_edge.m_arc_angle_start = aOrient + 0.0; // En decidegree
curr_edge.m_arc_angle_start = aOrient + ANGLE_0;
rr_outline.push_back( curr_edge );
@ -1562,13 +1565,13 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
curr_edge.m_end.y = curr_edge.m_start.y;
curr_edge.m_center.x = curr_edge.m_end.x;
curr_edge.m_center.y = hsizeY - aCornerRadius;
curr_edge.m_arc_angle_start = aOrient - 900.0; // En decidegree
curr_edge.m_arc_angle_start = aOrient - ANGLE_90;
rr_outline.push_back( curr_edge );
// Move relative coordinates to the actual location and rotation:
VECTOR2I arc_last_center;
int arc_last_angle = curr_edge.m_arc_angle_start+arc_angle;
VECTOR2I arc_last_center;
EDA_ANGLE arc_last_angle = curr_edge.m_arc_angle_start - ANGLE_90;
for( RR_EDGE& rr_edge: rr_outline )
{
@ -1586,8 +1589,8 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
// small difference, mainly for rotated pads.
// calculate last point (end of last arc):
VECTOR2I last_pt;
last_pt.x = arc_last_center.x + KiROUND( cosdecideg( aCornerRadius, arc_last_angle ) );
last_pt.y = arc_last_center.y - KiROUND( sindecideg( aCornerRadius, arc_last_angle ) );
last_pt.x = arc_last_center.x + KiROUND( aCornerRadius * cos( arc_last_angle.AsRadians() ) );
last_pt.y = arc_last_center.y - KiROUND( aCornerRadius * sin( arc_last_angle.AsRadians() ) );
VECTOR2I first_pt = rr_outline[0].m_start;
@ -1608,7 +1611,7 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
{
// LineTo( rr_edge.m_end ); // made in plotArc()
plotArc( rr_edge.m_center, rr_edge.m_arc_angle_start,
rr_edge.m_arc_angle_start+arc_angle, aCornerRadius, true );
rr_edge.m_arc_angle_start - ANGLE_90, aCornerRadius, true );
}
else
{
@ -1621,7 +1624,7 @@ void GERBER_PLOTTER::plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const V
void GERBER_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aOrient, SHAPE_POLY_SET* aPolygons,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData )
{
@ -1662,7 +1665,9 @@ void GERBER_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aS
#ifdef GBR_USE_MACROS_FOR_CUSTOM_PAD
if( m_gerberDisableApertMacros
|| cornerList.size() > GBR_MACRO_FOR_CUSTOM_PAD_MAX_CORNER_COUNT )
{
PlotGerberRegion( cornerList, &gbr_metadata );
}
else
{
// An AM will be created. the shape must be in position 0,0 and orientation 0
@ -1674,8 +1679,8 @@ void GERBER_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aS
}
DPOINT pos_dev = userToDeviceCoordinates( aPadPos );
selectAperture( cornerList, aOrient/10.0,
APERTURE::AM_FREE_POLYGON, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aOrient, APERTURE::AM_FREE_POLYGON,
gbr_metadata.GetApertureAttrib() );
formatNetAttribute( &gbr_metadata.m_NetlistMetadata );
emitDcode( pos_dev, 3 );
@ -1690,7 +1695,7 @@ void GERBER_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aS
void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const VECTOR2I& aPadSize,
int aCornerRadius, double aChamferRatio,
int aChamferPositions, double aPadOrient,
int aChamferPositions, const EDA_ANGLE& aPadOrient,
OUTLINE_MODE aPlotMode, void* aData )
{
@ -1699,10 +1704,8 @@ void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const
if( aData )
gbr_metadata = *static_cast<GBR_METADATA*>( aData );
DPOINT pos_dev = userToDeviceCoordinates( aShapePos );
SHAPE_POLY_SET outline;
// polygon corners list
VECTOR2I pos_device = userToDeviceCoordinates( aShapePos );
SHAPE_POLY_SET outline;
std::vector<VECTOR2I> cornerList;
bool hasRoundedCorner = aCornerRadius != 0 && aChamferPositions != 15;
@ -1744,11 +1747,11 @@ void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const
RotatePoint( cornerList[ii], -aPadOrient );
}
selectAperture( cornerList, aPadOrient/10.0,
APERTURE::AM_FREE_POLYGON, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aPadOrient, APERTURE::AM_FREE_POLYGON,
gbr_metadata.GetApertureAttrib() );
formatNetAttribute( &gbr_metadata.m_NetlistMetadata );
emitDcode( pos_dev, 3 );
emitDcode( pos_device, 3 );
}
#else
PlotGerberRegion( cornerList, &gbr_metadata );
@ -1759,7 +1762,7 @@ void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const
}
// Build the chamfered polygon (4 to 8 corners )
TransformRoundChamferedRectToPolygon( outline, VECTOR2I( 0, 0 ), aPadSize, 0.0, 0,
TransformRoundChamferedRectToPolygon( outline, VECTOR2I( 0, 0 ), aPadSize, ANGLE_0, 0,
aChamferRatio, aChamferPositions, 0,
GetPlotterArcHighDef(), ERROR_INSIDE );
@ -1774,32 +1777,32 @@ void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const
{
case 4:
m_hasApertureOutline4P = true;
selectAperture( cornerList, aPadOrient/10.0,
APERTURE::APER_MACRO_OUTLINE4P, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aPadOrient, APERTURE::APER_MACRO_OUTLINE4P,
gbr_metadata.GetApertureAttrib() );
break;
case 5:
m_hasApertureChamferedRect = true;
selectAperture( cornerList, aPadOrient/10.0,
APERTURE::APER_MACRO_OUTLINE5P, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aPadOrient, APERTURE::APER_MACRO_OUTLINE5P,
gbr_metadata.GetApertureAttrib() );
break;
case 6:
m_hasApertureChamferedRect = true;
selectAperture( cornerList, aPadOrient/10.0,
APERTURE::APER_MACRO_OUTLINE6P, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aPadOrient, APERTURE::APER_MACRO_OUTLINE6P,
gbr_metadata.GetApertureAttrib() );
break;
case 7:
m_hasApertureChamferedRect = true;
selectAperture( cornerList, aPadOrient/10.0,
APERTURE::APER_MACRO_OUTLINE7P, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aPadOrient, APERTURE::APER_MACRO_OUTLINE7P,
gbr_metadata.GetApertureAttrib() );
break;
case 8:
m_hasApertureChamferedRect = true;
selectAperture( cornerList, aPadOrient/10.0,
APERTURE::APER_MACRO_OUTLINE8P, gbr_metadata.GetApertureAttrib() );
selectAperture( cornerList, aPadOrient, APERTURE::APER_MACRO_OUTLINE8P,
gbr_metadata.GetApertureAttrib() );
break;
default:
@ -1810,12 +1813,13 @@ void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const
formatNetAttribute( &gbr_metadata.m_NetlistMetadata );
emitDcode( pos_dev, 3 );
emitDcode( pos_device, 3 );
}
void GERBER_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTrace_Mode, void* aData )
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
// polygon corners list
@ -1830,14 +1834,14 @@ void GERBER_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aC
// Close the polygon
cornerList.push_back( cornerList[0] );
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
GBR_METADATA metadata;
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
GBR_METADATA metadata;
if( gbr_metadata )
metadata = *gbr_metadata;
if( aTrace_Mode == SKETCH )
if( aTraceMode == SKETCH )
{
PlotPoly( cornerList, FILL_T::NO_FILL, GetCurrentLineWidth(), &metadata );
return;
@ -1853,7 +1857,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aC
// polygon corners list
std::vector<VECTOR2I> corners = { aCorners[0], aCorners[1], aCorners[2], aCorners[3] };
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( corners, aPadOrient/10.0, APERTURE::APER_MACRO_OUTLINE4P, aperture_attrib );
selectAperture( corners, aPadOrient, APERTURE::APER_MACRO_OUTLINE4P, aperture_attrib );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
@ -1867,7 +1871,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aC
void GERBER_PLOTTER::FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter,
int aCornerCount, double aOrient,
int aCornerCount, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData )
{
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
@ -1882,12 +1886,13 @@ void GERBER_PLOTTER::FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiamet
// Build the polygon:
std::vector<VECTOR2I> cornerList;
double angle_delta = 3600.0 / aCornerCount; // in 0.1 degree
EDA_ANGLE angle_delta = ANGLE_360 / aCornerCount;
for( int ii = 0; ii < aCornerCount; ii++ )
{
double rot = aOrient + (angle_delta*ii);
VECTOR2I vertice( aDiameter / 2, 0 );
EDA_ANGLE rot = aOrient + ( angle_delta * ii );
VECTOR2I vertice( aDiameter / 2, 0 );
RotatePoint( vertice, rot );
vertice += aShapePos;
cornerList.push_back( vertice );

View File

@ -221,7 +221,7 @@ static const double PLUsPERDECIMIL = 0.1016;
HPGL_PLOTTER::HPGL_PLOTTER()
: arcTargetChordLength( 0 ),
arcMinChordDegrees( 5.0 ),
arcMinChordDegrees( 5.0, DEGREES_T ),
dashType( PLOT_DASH_TYPE::SOLID ),
useUserCoords( false ),
fitUserCoords( false ),
@ -284,24 +284,28 @@ bool HPGL_PLOTTER::EndPlot()
if( fitUserCoords )
{
BOX2D bbox = m_items.front().bbox;
for( HPGL_ITEM const& item : m_items )
{
bbox.Merge( item.bbox );
}
fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n", bbox.GetX(),
bbox.GetX() + bbox.GetWidth(), bbox.GetY(),
for( HPGL_ITEM const& item : m_items )
bbox.Merge( item.bbox );
fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n",
bbox.GetX(),
bbox.GetX() + bbox.GetWidth(),
bbox.GetY(),
bbox.GetY() + bbox.GetHeight() );
}
else
{
DPOINT pagesize_dev( m_paperSize * m_iuPerDeviceUnit );
fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n", 0., pagesize_dev.x, 0.,
pagesize_dev.y );
VECTOR2D pagesize_device( m_paperSize * m_iuPerDeviceUnit );
fprintf( m_outputFile, "SC%.0f,%.0f,%.0f,%.0f;\n",
0.0,
pagesize_device.x,
0.0,
pagesize_device.y );
}
}
DPOINT loc = m_items.begin()->loc_start;
VECTOR2I loc = m_items.begin()->loc_start;
bool pen_up = true;
PLOT_DASH_TYPE current_dash = PLOT_DASH_TYPE::SOLID;
int current_pen = penNumber;
@ -383,53 +387,52 @@ void HPGL_PLOTTER::SetPenDiameter( double diameter )
}
void HPGL_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int width )
void HPGL_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T aFill, int aWidth )
{
wxASSERT( m_outputFile );
DPOINT p1dev = userToDeviceCoordinates( p1 );
DPOINT p2dev = userToDeviceCoordinates( p2 );
VECTOR2D p1_device = userToDeviceCoordinates( p1 );
VECTOR2D p2_device = userToDeviceCoordinates( p2 );
MoveTo( p1 );
if( fill == FILL_T::FILLED_SHAPE )
if( aFill == FILL_T::FILLED_SHAPE )
{
startOrAppendItem( p1dev, wxString::Format( "RA %.0f,%.0f;", p2dev.x, p2dev.y ) );
startOrAppendItem( p1_device, wxString::Format( "RA %.0f,%.0f;",
p2_device.x,
p2_device.y ) );
}
startOrAppendItem( p1dev, wxString::Format( "EA %.0f,%.0f;", p2dev.x, p2dev.y ) );
startOrAppendItem( p1_device, wxString::Format( "EA %.0f,%.0f;",
p2_device.x,
p2_device.y ) );
m_current_item->loc_end = m_current_item->loc_start;
m_current_item->bbox.Merge( p2dev );
m_current_item->bbox.Merge( p2_device );
PenFinish();
}
void HPGL_PLOTTER::Circle( const VECTOR2I& centre, int diameter, FILL_T fill, int width )
void HPGL_PLOTTER::Circle( const VECTOR2I& aCenter, int aDiameter, FILL_T aFill, int aWidth )
{
wxASSERT( m_outputFile );
double radius = userToDeviceSize( diameter / 2 );
DPOINT center_dev = userToDeviceCoordinates( centre );
SetCurrentLineWidth( width );
double radius = userToDeviceSize( aDiameter / 2 );
VECTOR2D center_dev = userToDeviceCoordinates( aCenter );
SetCurrentLineWidth( aWidth );
double const circumf = 2.0 * M_PI * radius;
double const target_chord_length = arcTargetChordLength;
double chord_degrees = 360.0 * target_chord_length / circumf;
EDA_ANGLE chord_angle = ANGLE_360 * target_chord_length / circumf;
if( chord_degrees < arcMinChordDegrees )
{
chord_degrees = arcMinChordDegrees;
}
else if( chord_degrees > 45 )
{
chord_degrees = 45;
}
chord_angle = std::max( arcMinChordDegrees, std::min( chord_angle, ANGLE_45 ) );
if( fill == FILL_T::FILLED_SHAPE )
if( aFill == FILL_T::FILLED_SHAPE )
{
// Draw the filled area
MoveTo( centre );
startOrAppendItem( center_dev, wxString::Format( "PM 0;CI %g,%g;%s", radius, chord_degrees,
MoveTo( aCenter );
startOrAppendItem( center_dev, wxString::Format( "PM 0;CI %g,%g;%s",
radius,
chord_angle.AsDegrees(),
hpgl_end_polygon_cmd ) );
m_current_item->lift_before = true;
m_current_item->pen_returns = true;
@ -440,8 +443,10 @@ void HPGL_PLOTTER::Circle( const VECTOR2I& centre, int diameter, FILL_T fill, in
if( radius > 0 )
{
MoveTo( centre );
startOrAppendItem( center_dev, wxString::Format( "CI %g,%g;", radius, chord_degrees ) );
MoveTo( aCenter );
startOrAppendItem( center_dev, wxString::Format( "CI %g,%g;",
radius,
chord_angle.AsDegrees() ) );
m_current_item->lift_before = true;
m_current_item->pen_returns = true;
m_current_item->bbox.Merge( BOX2D( center_dev - radius,
@ -517,8 +522,8 @@ void HPGL_PLOTTER::PenTo( const VECTOR2I& pos, char plume )
return;
}
DPOINT pos_dev = userToDeviceCoordinates( pos );
DPOINT lastpos_dev = userToDeviceCoordinates( m_penLastpos );
VECTOR2D pos_dev = userToDeviceCoordinates( pos );
VECTOR2D lastpos_dev = userToDeviceCoordinates( m_penLastpos );
if( plume == 'U' )
{
@ -562,86 +567,83 @@ void HPGL_PLOTTER::ThickSegment( const VECTOR2I& start, const VECTOR2I& end,
}
void HPGL_PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
void HPGL_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
wxASSERT( m_outputFile );
double angle;
if( radius <= 0 )
if( aRadius <= 0 )
return;
double const radius_dev = userToDeviceSize( radius );
double const circumf_dev = 2.0 * M_PI * radius_dev;
double const radius_device = userToDeviceSize( aRadius );
double const circumf_device = 2.0 * M_PI * radius_device;
double const target_chord_length = arcTargetChordLength;
double chord_degrees = 360.0 * target_chord_length / circumf_dev;
EDA_ANGLE chord_angle = ANGLE_360 * target_chord_length / circumf_device;
if( chord_degrees < arcMinChordDegrees )
{
chord_degrees = arcMinChordDegrees;
}
else if( chord_degrees > 45 )
{
chord_degrees = 45;
}
chord_angle = std::max( arcMinChordDegrees, std::min( chord_angle, ANGLE_45 ) );
DPOINT centre_dev = userToDeviceCoordinates( centre );
VECTOR2D centre_device = userToDeviceCoordinates( aCenter );
EDA_ANGLE angle;
if( m_plotMirror )
angle = StAngle - EndAngle;
angle = aStartAngle - aEndAngle;
else
angle = EndAngle - StAngle;
angle = aEndAngle - aStartAngle;
NORMALIZE_ANGLE_180( angle );
angle /= 10;
angle.Normalize180();
// Calculate arc start point:
VECTOR2I cmap;
cmap.x = centre.x + KiROUND( cosdecideg( radius, StAngle ) );
cmap.y = centre.y - KiROUND( sindecideg( radius, StAngle ) );
DPOINT cmap_dev = userToDeviceCoordinates( cmap );
VECTOR2I cmap( aCenter.x + KiROUND( aRadius * cos( aStartAngle.AsRadians() ) ),
aCenter.y - KiROUND( aRadius * sin( aStartAngle.AsRadians() ) ) );
VECTOR2D cmap_dev = userToDeviceCoordinates( cmap );
startOrAppendItem( cmap_dev, wxString::Format( "AA %.0f,%.0f,%.0f,%g", centre_dev.x,
centre_dev.y, angle, chord_degrees ) );
startOrAppendItem( cmap_dev, wxString::Format( "AA %.0f,%.0f,%.0f,%g",
centre_device.x,
centre_device.y,
angle.AsDegrees(),
chord_angle.AsDegrees() ) );
// TODO We could compute the final position and full bounding box instead...
m_current_item->bbox.Merge( BOX2D( centre_dev - radius_dev,
VECTOR2D( radius_dev * 2, radius_dev * 2 ) ) );
m_current_item->bbox.Merge( BOX2D( centre_device - radius_device,
VECTOR2D( radius_device * 2, radius_device * 2 ) ) );
m_current_item->lift_after = true;
flushItem();
}
void HPGL_PLOTTER::FlashPadOval( const VECTOR2I& pos, const VECTOR2I& aSize, double orient,
OUTLINE_MODE trace_mode, void* aData )
void HPGL_PLOTTER::FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode, void* aData )
{
wxASSERT( m_outputFile );
int deltaxy, cx, cy;
VECTOR2I size( aSize );
EDA_ANGLE orient( aOrient );
// The pad will be drawn as an oblong shape with size.y > size.x (Oval vertical orientation 0).
if( size.x > size.y )
{
std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
orient += ANGLE_90;
}
deltaxy = size.y - size.x; // distance between centers of the oval
if( trace_mode == FILLED )
if( aTraceMode == FILLED )
{
FlashPadRect( pos, VECTOR2I( size.x, deltaxy + KiROUND( penDiameter ) ),
orient, trace_mode, aData );
cx = 0; cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
FlashPadCircle( VECTOR2I( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
FlashPadCircle( VECTOR2I( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
int deltaxy = size.y - size.x; // distance between centers of the oval
FlashPadRect( aPos, VECTOR2I( size.x, deltaxy + KiROUND( penDiameter ) ), orient,
aTraceMode, aData );
VECTOR2I pt( 0, deltaxy / 2 );
RotatePoint( pt, orient );
FlashPadCircle( pt + aPos, size.x, aTraceMode, aData );
pt = VECTOR2I( 0, -deltaxy / 2 );
RotatePoint( pt, orient );
FlashPadCircle( pt + aPos, size.x, aTraceMode, aData );
}
else // Plot in outline mode.
{
sketchOval( pos, size, orient, KiROUND( penDiameter ) );
sketchOval( aPos, size, orient, KiROUND( penDiameter ) );
}
}
@ -691,16 +693,16 @@ void HPGL_PLOTTER::FlashPadCircle( const VECTOR2I& pos, int diametre,
}
void HPGL_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& padsize,
double orient, OUTLINE_MODE trace_mode, void* aData )
void HPGL_PLOTTER::FlashPadRect( const VECTOR2I& aPos, const VECTOR2I& aPadSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode, void* aData )
{
// Build rect polygon:
std::vector<VECTOR2I> corners;
int dx = padsize.x / 2;
int dy = padsize.y / 2;
int dx = aPadSize.x / 2;
int dy = aPadSize.y / 2;
if( trace_mode == FILLED )
if( aTraceMode == FILLED )
{
// in filled mode, the pen diameter is removed from size
// to compensate the extra size due to this pen size
@ -721,16 +723,16 @@ void HPGL_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& padsize,
for( unsigned ii = 0; ii < corners.size(); ii++ )
{
RotatePoint( corners[ii], orient );
corners[ii] += pos;
RotatePoint( corners[ii], aOrient );
corners[ii] += aPos;
}
PlotPoly( corners, trace_mode == FILLED ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL );
PlotPoly( corners, aTraceMode == FILLED ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL );
}
void HPGL_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData )
{
SHAPE_POLY_SET outline;
@ -749,8 +751,8 @@ void HPGL_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& a
aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
}
TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient, aCornerRadius,
0.0, 0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient, aCornerRadius, 0.0, 0,
0, GetPlotterArcHighDef(), ERROR_INSIDE );
// TransformRoundRectToPolygon creates only one convex polygon
std::vector<VECTOR2I> cornerList;
@ -767,8 +769,9 @@ void HPGL_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& a
}
void HPGL_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aOrient,
SHAPE_POLY_SET* aPolygons, OUTLINE_MODE aTraceMode, void* aData )
void HPGL_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData )
{
std::vector<VECTOR2I> cornerList;
@ -791,7 +794,8 @@ void HPGL_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSiz
void HPGL_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
std::vector<VECTOR2I> cornerList;
cornerList.reserve( 5 );
@ -812,7 +816,8 @@ void HPGL_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCor
void HPGL_PLOTTER::FlashRegularPolygon( const VECTOR2I& aShapePos, int aRadius, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
// Do nothing
wxASSERT( 0 );
@ -857,9 +862,7 @@ bool HPGL_PLOTTER::startOrAppendItem( const DPOINT& location, wxString const& co
void HPGL_PLOTTER::sortItems( std::list<HPGL_ITEM>& items )
{
if( items.size() < 2 )
{
return;
}
std::list<HPGL_ITEM> target;

View File

@ -261,55 +261,60 @@ void PDF_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T aFill, int w
}
void PDF_PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
wxASSERT( workFile );
if( radius <= 0 )
if( aRadius <= 0 )
{
Circle( centre, width, FILL_T::FILLED_SHAPE, 0 );
Circle( aCenter, aWidth, FILL_T::FILLED_SHAPE, 0 );
return;
}
/* Arcs are not so easily approximated by beziers (in the general case),
so we approximate them in the old way */
VECTOR2I start, end;
const int delta = 50; // increment (in 0.1 degrees) to draw circles
/*
* Arcs are not so easily approximated by beziers (in the general case), so we approximate
* them in the old way
*/
EDA_ANGLE startAngle( aStartAngle );
EDA_ANGLE endAngle( aEndAngle );
VECTOR2I start;
VECTOR2I end;
const EDA_ANGLE delta( 5, DEGREES_T ); // increment to draw circles
if( StAngle > EndAngle )
std::swap( StAngle, EndAngle );
if( startAngle > endAngle )
std::swap( startAngle, endAngle );
SetCurrentLineWidth( width );
SetCurrentLineWidth( aWidth );
// Usual trig arc plotting routine...
start.x = centre.x + KiROUND( cosdecideg( radius, -StAngle ) );
start.y = centre.y + KiROUND( sindecideg( radius, -StAngle ) );
start.x = aCenter.x + KiROUND( aRadius * cos( -startAngle.AsRadians() ) );
start.y = aCenter.y + KiROUND( aRadius * sin( -startAngle.AsRadians() ) );
DPOINT pos_dev = userToDeviceCoordinates( start );
fprintf( workFile, "%g %g m ", pos_dev.x, pos_dev.y );
for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
for( EDA_ANGLE ii = startAngle + delta; ii < endAngle; ii += delta )
{
end.x = centre.x + KiROUND( cosdecideg( radius, -ii ) );
end.y = centre.y + KiROUND( sindecideg( radius, -ii ) );
end.x = aCenter.x + KiROUND( aRadius * cos( -ii.AsRadians() ) );
end.y = aCenter.y + KiROUND( aRadius * sin( -ii.AsRadians() ) );
pos_dev = userToDeviceCoordinates( end );
fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );
}
end.x = centre.x + KiROUND( cosdecideg( radius, -EndAngle ) );
end.y = centre.y + KiROUND( sindecideg( radius, -EndAngle ) );
end.x = aCenter.x + KiROUND( aRadius * cos( -endAngle.AsRadians() ) );
end.y = aCenter.y + KiROUND( aRadius * sin( -endAngle.AsRadians() ) );
pos_dev = userToDeviceCoordinates( end );
fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );
// The arc is drawn... if not filled we stroke it, otherwise we finish
// closing the pie at the center
if( fill == FILL_T::NO_FILL )
if( aFill == FILL_T::NO_FILL )
{
fputs( "S\n", workFile );
}
else
{
pos_dev = userToDeviceCoordinates( centre );
pos_dev = userToDeviceCoordinates( aCenter );
fprintf( workFile, "%g %g l b\n", pos_dev.x, pos_dev.y );
}
}

View File

@ -88,32 +88,32 @@ void PSLIKE_PLOTTER::SetColor( const COLOR4D& color )
void PSLIKE_PLOTTER::FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
wxASSERT( m_outputFile );
int x0, y0, x1, y1, delta;
VECTOR2I size( aSize );
VECTOR2I size( aSize );
EDA_ANGLE orient( aPadOrient );
// The pad is reduced to an oval by dy > dx
if( size.x > size.y )
{
std::swap( size.x, size.y );
aPadOrient = AddAngles( aPadOrient, 900 );
orient += ANGLE_90;
}
delta = size.y - size.x;
x0 = 0;
y0 = -delta / 2;
x1 = 0;
y1 = delta / 2;
RotatePoint( &x0, &y0, aPadOrient );
RotatePoint( &x1, &y1, aPadOrient );
int delta = size.y - size.x;
VECTOR2I a( 0, -delta / 2 );
VECTOR2I b( 0, delta / 2 );
RotatePoint( a, aPadOrient );
RotatePoint( b, aPadOrient );
if( aTraceMode == FILLED )
ThickSegment( VECTOR2I( aPadPos.x + x0, aPadPos.y + y0 ),
VECTOR2I( aPadPos.x + x1, aPadPos.y + y1 ), size.x, aTraceMode, nullptr );
ThickSegment( a + aPadPos, b + aPadPos, size.x, aTraceMode, nullptr );
else
sketchOval( aPadPos, size, aPadOrient, -1 );
sketchOval( aPadPos, size, orient, -1 );
}
@ -141,7 +141,8 @@ void PSLIKE_PLOTTER::FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter,
void PSLIKE_PLOTTER::FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
static std::vector<VECTOR2I> cornerList;
VECTOR2I size( aSize );
@ -179,9 +180,7 @@ void PSLIKE_PLOTTER::FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSiz
cornerList.push_back( corner );
for( unsigned ii = 0; ii < cornerList.size(); ii++ )
{
RotatePoint( cornerList[ii], aPadPos, aPadOrient );
}
cornerList.push_back( cornerList[0] );
@ -191,7 +190,7 @@ void PSLIKE_PLOTTER::FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSiz
void PSLIKE_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData )
{
VECTOR2I size( aSize );
@ -210,8 +209,8 @@ void PSLIKE_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I&
SHAPE_POLY_SET outline;
TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient, aCornerRadius,
0.0, 0, 0, GetPlotterArcHighDef(), ERROR_INSIDE );
TransformRoundChamferedRectToPolygon( outline, aPadPos, size, aOrient, aCornerRadius, 0.0, 0,
0, GetPlotterArcHighDef(), ERROR_INSIDE );
std::vector<VECTOR2I> cornerList;
@ -231,7 +230,7 @@ void PSLIKE_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I&
void PSLIKE_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aOrient, SHAPE_POLY_SET* aPolygons,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData )
{
VECTOR2I size( aSize );
@ -268,7 +267,8 @@ void PSLIKE_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aS
void PSLIKE_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
static std::vector<VECTOR2I> cornerList;
cornerList.clear();
@ -315,7 +315,8 @@ void PSLIKE_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aC
void PSLIKE_PLOTTER::FlashRegularPolygon( const VECTOR2I& aShapePos, int aRadius, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData )
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData )
{
// Do nothing
wxASSERT( 0 );
@ -586,40 +587,43 @@ void PS_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int wid
}
void PS_PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
void PS_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
wxASSERT( m_outputFile );
if( radius <= 0 )
if( aRadius <= 0 )
return;
if( StAngle > EndAngle )
std::swap( StAngle, EndAngle );
EDA_ANGLE startAngle( aStartAngle );
EDA_ANGLE endAngle( aEndAngle );
SetCurrentLineWidth( width );
if( startAngle > endAngle )
std::swap( startAngle, endAngle );
SetCurrentLineWidth( aWidth );
// Calculate start point.
DPOINT centre_dev = userToDeviceCoordinates( centre );
double radius_dev = userToDeviceSize( radius );
DPOINT centre_dev = userToDeviceCoordinates( aCenter );
double radius_dev = userToDeviceSize( aRadius );
if( m_plotMirror )
{
if( m_mirrorIsHorizontal )
{
StAngle = 1800.0 -StAngle;
EndAngle = 1800.0 -EndAngle;
std::swap( StAngle, EndAngle );
startAngle = ANGLE_180 - startAngle;
endAngle = ANGLE_180 - endAngle;
std::swap( startAngle, endAngle );
}
else
{
StAngle = -StAngle;
EndAngle = -EndAngle;
startAngle = -startAngle;
endAngle = -endAngle;
}
}
fprintf( m_outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y,
radius_dev, StAngle / 10.0, EndAngle / 10.0, getFillId( fill ) );
radius_dev, startAngle.AsDegrees(), endAngle.AsDegrees(), getFillId( aFill ) );
}

View File

@ -427,67 +427,69 @@ void SVG_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int wi
}
void SVG_PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
void SVG_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
/* Draws an arc of a circle, centered on (xc,yc), with starting point
* (x1, y1) and ending at (x2, y2). The current pen is used for the outline
* and the current brush for filling the shape.
/* Draws an arc of a circle, centered on (xc,yc), with starting point (x1, y1) and ending
* at (x2, y2). The current pen is used for the outline and the current brush for filling
* the shape.
*
* The arc is drawn in an anticlockwise direction from the start point to
* the end point
* The arc is drawn in an anticlockwise direction from the start point to the end point.
*/
if( radius <= 0 )
if( aRadius <= 0 )
{
Circle( centre, width, FILL_T::FILLED_SHAPE, 0 );
Circle( aCenter, aWidth, FILL_T::FILLED_SHAPE, 0 );
return;
}
if( StAngle > EndAngle )
std::swap( StAngle, EndAngle );
EDA_ANGLE startAngle( aStartAngle );
EDA_ANGLE endAngle( aEndAngle );
if( startAngle > endAngle )
std::swap( startAngle, endAngle );
// Calculate start point.
DPOINT centre_dev = userToDeviceCoordinates( centre );
double radius_dev = userToDeviceSize( radius );
DPOINT centre_device = userToDeviceCoordinates( aCenter );
double radius_device = userToDeviceSize( aRadius );
if( !m_yaxisReversed ) // Should be never the case
{
double tmp = StAngle;
StAngle = -EndAngle;
EndAngle = -tmp;
std::swap( startAngle, endAngle );
startAngle = -startAngle;
endAngle = -endAngle;
}
if( m_plotMirror )
{
if( m_mirrorIsHorizontal )
{
StAngle = 1800.0 -StAngle;
EndAngle = 1800.0 -EndAngle;
std::swap( StAngle, EndAngle );
std::swap( startAngle, endAngle );
startAngle = ANGLE_180 - startAngle;
endAngle = ANGLE_180 - endAngle;
}
else
{
StAngle = -StAngle;
EndAngle = -EndAngle;
startAngle = -startAngle;
endAngle = -endAngle;
}
}
DPOINT start;
start.x = radius_dev;
RotatePoint( &start.x, &start.y, StAngle );
start.x = radius_device;
RotatePoint( start, startAngle );
DPOINT end;
end.x = radius_dev;
RotatePoint( &end.x, &end.y, EndAngle );
start += centre_dev;
end += centre_dev;
end.x = radius_device;
RotatePoint( end, endAngle );
start += centre_device;
end += centre_device;
double theta1 = DECIDEG2RAD( StAngle );
double theta1 = startAngle.AsRadians();
if( theta1 < 0 )
theta1 = theta1 + M_PI * 2;
double theta2 = DECIDEG2RAD( EndAngle );
double theta2 = endAngle.AsRadians();
if( theta2 < 0 )
theta2 = theta2 + M_PI * 2;
@ -507,23 +509,23 @@ void SVG_PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle,
// flag arc size (0 = small arc > 180 deg, 1 = large arc > 180 deg),
// sweep arc ( 0 = CCW, 1 = CW),
// end point
if( fill != FILL_T::NO_FILL )
if( aFill != FILL_T::NO_FILL )
{
// Filled arcs (in Eeschema) consist of the pie wedge and a stroke only on the arc
// This needs to be drawn in two steps.
setFillMode( fill );
setFillMode( aFill );
SetCurrentLineWidth( 0 );
fprintf( m_outputFile, "<path d=\"M%f %f A%f %f 0.0 %d %d %f %f L %f %f Z\" />\n",
start.x, start.y, radius_dev, radius_dev,
start.x, start.y, radius_device, radius_device,
flg_arc, flg_sweep,
end.x, end.y, centre_dev.x, centre_dev.y );
end.x, end.y, centre_device.x, centre_device.y );
}
setFillMode( FILL_T::NO_FILL );
SetCurrentLineWidth( width );
SetCurrentLineWidth( aWidth );
fprintf( m_outputFile, "<path d=\"M%f %f A%f %f 0.0 %d %d %f %f\" />\n",
start.x, start.y, radius_dev, radius_dev,
start.x, start.y, radius_device, radius_device,
flg_arc, flg_sweep,
end.x, end.y );
}

View File

@ -154,24 +154,26 @@ double PLOTTER::GetDashGapLenIU() const
}
void PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int radius,
FILL_T fill, int width )
void PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
VECTOR2I start, end;
const int delta = 50; // increment (in 0.1 degrees) to draw circles
EDA_ANGLE startAngle( aStartAngle );
EDA_ANGLE endAngle( aEndAngle );
const EDA_ANGLE delta( 5.0, DEGREES_T ); // increment to draw arc
VECTOR2I start, end;
if( StAngle > EndAngle )
std::swap( StAngle, EndAngle );
if( startAngle > endAngle )
std::swap( startAngle, endAngle );
SetCurrentLineWidth( width );
SetCurrentLineWidth( aWidth );
/* Please NOTE the different sign due to Y-axis flip */
start.x = centre.x + KiROUND( cosdecideg( radius, -StAngle ) );
start.y = centre.y + KiROUND( sindecideg( radius, -StAngle ) );
start.x = aCenter.x + KiROUND( aRadius * cos( -startAngle.AsRadians() ) );
start.y = aCenter.y + KiROUND( aRadius * sin( -startAngle.AsRadians() ) );
if( fill != FILL_T::NO_FILL )
if( aFill != FILL_T::NO_FILL )
{
MoveTo( centre );
MoveTo( aCenter );
LineTo( start );
}
else
@ -179,20 +181,20 @@ void PLOTTER::Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int
MoveTo( start );
}
for( int ii = StAngle + delta; ii < EndAngle; ii += delta )
for( EDA_ANGLE ii = startAngle + delta; ii < endAngle; ii += delta )
{
end.x = centre.x + KiROUND( cosdecideg( radius, -ii ) );
end.y = centre.y + KiROUND( sindecideg( radius, -ii ) );
end.x = aCenter.x + KiROUND( aRadius * cos( -ii.AsRadians() ) );
end.y = aCenter.y + KiROUND( aRadius * sin( -ii.AsRadians() ) );
LineTo( end );
}
end.x = centre.x + KiROUND( cosdecideg( radius, -EndAngle ) );
end.y = centre.y + KiROUND( sindecideg( radius, -EndAngle ) );
end.x = aCenter.x + KiROUND( aRadius * cos( -endAngle.AsRadians() ) );
end.y = aCenter.y + KiROUND( aRadius * sin( -endAngle.AsRadians() ) );
if( fill != FILL_T::NO_FILL )
if( aFill != FILL_T::NO_FILL )
{
LineTo( end );
FinishTo( centre );
FinishTo( aCenter );
}
else
{
@ -452,62 +454,64 @@ void PLOTTER::Marker( const VECTOR2I& position, int diametre, unsigned aShapeId
}
void PLOTTER::segmentAsOval( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode )
void PLOTTER::segmentAsOval( const VECTOR2I& start, const VECTOR2I& end, int aWidth,
OUTLINE_MODE aTraceMode )
{
VECTOR2I center( ( start.x + end.x ) / 2, ( start.y + end.y ) / 2 );
VECTOR2I size( end.x - start.x, end.y - start.y );
EDA_ANGLE orient( size );
size.x = KiROUND( EuclideanNorm( size ) ) + width;
size.y = width;
size.x = KiROUND( EuclideanNorm( size ) ) + aWidth;
size.y = aWidth;
FlashPadOval( center, size, orient.AsTenthsOfADegree(), tracemode, nullptr );
FlashPadOval( center, size, orient, aTraceMode, nullptr );
}
void PLOTTER::sketchOval( const VECTOR2I& pos, const VECTOR2I& aSize, double orient, int width )
void PLOTTER::sketchOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA_ANGLE& aOrient,
int aWidth )
{
SetCurrentLineWidth( width );
width = m_currentPenWidth;
int radius, deltaxy, cx, cy;
VECTOR2I size( aSize );
SetCurrentLineWidth( aWidth );
EDA_ANGLE orient( aOrient );
VECTOR2I pt;
VECTOR2I size( aSize );
if( size.x > size.y )
{
std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
orient += ANGLE_90;
}
deltaxy = size.y - size.x; /* distance between centers of the oval */
radius = ( size.x - width ) / 2;
cx = -radius;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
MoveTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
cx = -radius;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
FinishTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
int deltaxy = size.y - size.x; /* distance between centers of the oval */
int radius = ( size.x - m_currentPenWidth ) / 2;
cx = radius;
cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
MoveTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
cx = radius;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
FinishTo( VECTOR2I( cx + pos.x, cy + pos.y ) );
pt.x = -radius;
pt.y = -deltaxy / 2;
RotatePoint( pt, orient );
MoveTo( pt + aPos );
pt.x = -radius;
pt.y = deltaxy / 2;
RotatePoint( pt, orient );
FinishTo( pt + aPos );
cx = 0;
cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
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( VECTOR2I( cx + pos.x, cy + pos.y ), orient, orient + 1800, radius, FILL_T::NO_FILL );
pt.x = radius;
pt.y = -deltaxy / 2;
RotatePoint( pt, orient );
MoveTo( pt + aPos );
pt.x = radius;
pt.y = deltaxy / 2;
RotatePoint( pt, orient );
FinishTo( pt + aPos );
pt.x = 0;
pt.y = deltaxy / 2;
RotatePoint( pt, orient );
Arc( pt + aPos, orient + ANGLE_180, orient + ANGLE_360, radius, FILL_T::NO_FILL );
pt.x = 0;
pt.y = -deltaxy / 2;
RotatePoint( pt, orient );
Arc( pt + aPos, orient, orient + ANGLE_180, radius, FILL_T::NO_FILL );
}
@ -535,19 +539,20 @@ void PLOTTER::ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int widt
}
void PLOTTER::ThickArc( const VECTOR2I& centre, double StAngle, double EndAngle,
int radius, int width, OUTLINE_MODE tracemode, void* aData )
void PLOTTER::ThickArc( const VECTOR2I& centre, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, int aWidth,
OUTLINE_MODE aTraceMode, void* aData )
{
if( tracemode == FILLED )
if( aTraceMode == FILLED )
{
Arc( centre, StAngle, EndAngle, radius, FILL_T::NO_FILL, width );
Arc( centre, aStartAngle, aEndAngle, aRadius, FILL_T::NO_FILL, aWidth );
}
else
{
SetCurrentLineWidth( -1 );
Arc( centre, StAngle, EndAngle, radius - ( width - m_currentPenWidth ) / 2,
Arc( centre, aStartAngle, aEndAngle, aRadius - ( aWidth - m_currentPenWidth ) / 2,
FILL_T::NO_FILL, -1 );
Arc( centre, StAngle, EndAngle, radius + ( width - m_currentPenWidth ) / 2,
Arc( centre, aStartAngle, aEndAngle, aRadius + ( aWidth - m_currentPenWidth ) / 2,
FILL_T::NO_FILL, -1 );
}
}

View File

@ -111,13 +111,13 @@ void LIB_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill,
const TRANSFORM& aTransform ) const
{
VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset;
VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset;
VECTOR2I center;
int startAngle = 0;
int endAngle = 0;
int pen_size = GetEffectivePenWidth( aPlotter->RenderSettings() );
FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL;
VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset;
VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset;
VECTOR2I center;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
int pen_size = GetEffectivePenWidth( aPlotter->RenderSettings() );
FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL;
static std::vector<VECTOR2I> cornerList;
@ -251,11 +251,11 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
{
c = aTransform.TransformCoordinate( getCenter() ) + aOffset;
int t1, t2;
EDA_ANGLE t1, t2;
CalcArcAngles( t1, t2 );
if( aTransform.MapAngles( &t1, &t2 ) == ( NormalizeAngle180( t1 - t2 ) > 0 ) )
if( aTransform.MapAngles( &t1, &t2 ) == ( t1 - t2 ).Normalize180() > ANGLE_0 )
std::swap( pt1, pt2 );
}
@ -419,15 +419,3 @@ void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition )
}
void LIB_SHAPE::CalcArcAngles( int& aStartAngle, int& aEndAngle ) const
{
double start;
double end;
EDA_SHAPE::CalcArcAngles( start, end );
aStartAngle = KiROUND( start * 10.0 );
aEndAngle = KiROUND( end * 10.0 );
}

View File

@ -92,8 +92,6 @@ public:
VECTOR2I GetCenter() const { return getCenter(); }
void CalcArcAngles( int& aStartAngle, int& aEndAngle ) const;
void MirrorHorizontal( const VECTOR2I& aCenter ) override;
void MirrorVertical( const VECTOR2I& aCenter ) override;
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;

View File

@ -637,14 +637,14 @@ void SCH_PAINTER::draw( const LIB_SHAPE *aShape, int aLayer )
{
case SHAPE_T::ARC:
{
int startAngle;
int endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
aShape->CalcArcAngles( startAngle, endAngle );
TRANSFORM().MapAngles( &startAngle, &endAngle );
m_gal->DrawArc( mapCoords( aShape->GetCenter() ), aShape->GetRadius(),
DECIDEG2RAD( startAngle ), DECIDEG2RAD( endAngle ) );
startAngle.AsRadians(), endAngle.AsRadians() );
}
break;
@ -1352,12 +1352,12 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer )
{
case SHAPE_T::ARC:
{
int startAngle;
int endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
aShape->CalcArcAngles( startAngle, endAngle );
m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(),
DECIDEG2RAD( startAngle ), DECIDEG2RAD( endAngle ) );
startAngle.AsRadians(), endAngle.AsRadians() );
}
break;

View File

@ -1319,16 +1319,14 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map<wxString, wxString>& aPropertie
else
{
SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC, SCH_LAYER_ID::LAYER_NOTES );
double includedAngle = elem.endAngle - elem.startAngle;
double startAngle = DEG2RAD( elem.endAngle );
VECTOR2I startOffset = VECTOR2I( KiROUND( std::cos( startAngle ) * elem.radius ),
-KiROUND( std::sin( startAngle ) * elem.radius ) );
EDA_ANGLE includedAngle( elem.endAngle - elem.startAngle, DEGREES_T );
EDA_ANGLE startAngle( elem.endAngle, DEGREES_T );
VECTOR2I startOffset( KiROUND( elem.radius * cos( startAngle.AsRadians() ) ),
-KiROUND( elem.radius * sin( startAngle.AsRadians() ) ) );
arc->SetCenter( elem.center + m_sheetOffset );
arc->SetStart( elem.center + startOffset + m_sheetOffset );
arc->SetArcAngleAndEnd( NormalizeAngleDegreesPos( includedAngle ) * 10.0, true );
arc->SetArcAngleAndEnd( includedAngle.Normalize().AsTenthsOfADegree(), true );
arc->SetStroke( STROKE_PARAMS( elem.lineWidth, PLOT_DASH_TYPE::SOLID ) );

View File

@ -890,8 +890,8 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseArc()
// Parameters for legacy format
VECTOR2I center( 0, 0 );
int startAngle = 0;
int endAngle = 900;
EDA_ANGLE startAngle = ANGLE_0;
EDA_ANGLE endAngle = ANGLE_90;
bool hasAngles = false;
std::unique_ptr<LIB_SHAPE> arc = std::make_unique<LIB_SHAPE>( nullptr, SHAPE_T::ARC );
@ -946,10 +946,10 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseArc()
case T_angles:
{
startAngle = KiROUND( parseDouble( "start radius angle" ) * 10.0 );
endAngle = KiROUND( parseDouble( "end radius angle" ) * 10.0 );
NORMALIZE_ANGLE_POS( startAngle );
NORMALIZE_ANGLE_POS( endAngle );
startAngle = EDA_ANGLE( parseDouble( "start radius angle" ), DEGREES_T );
endAngle = EDA_ANGLE( parseDouble( "end radius angle" ), DEGREES_T );
startAngle.Normalize();
endAngle.Normalize();
NeedRIGHT();
hasAngles = true;
break;
@ -2826,8 +2826,8 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchArc()
VECTOR2I midPoint;
VECTOR2I endPoint;
VECTOR2I pos;
int startAngle;
int endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT );
FILL_PARAMS fill;
bool hasMidPoint = false;
@ -2881,10 +2881,10 @@ SCH_SHAPE* SCH_SEXPR_PARSER::parseSchArc()
case T_angles:
{
startAngle = KiROUND( parseDouble( "start radius angle" ) * 10.0 );
endAngle = KiROUND( parseDouble( "end radius angle" ) * 10.0 );
NORMALIZE_ANGLE_POS( startAngle );
NORMALIZE_ANGLE_POS( endAngle );
startAngle = EDA_ANGLE( parseDouble( "start radius angle" ), DEGREES_T );
endAngle = EDA_ANGLE( parseDouble( "end radius angle" ), DEGREES_T );
startAngle.Normalize();
endAngle.Normalize();
NeedRIGHT();
hasAngles = true;
break;

View File

@ -250,16 +250,10 @@ static const char* getTextTypeToken( KICAD_T aType )
}
static void formatArc( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aArc, int x1, int x2,
static void formatArc( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aArc,
const STROKE_PARAMS& aStroke, FILL_T aFillMode, const COLOR4D& aFillColor,
KIID aUuid = niluuid )
{
if( x1 > 1800 )
x1 -= 3600;
if( x2 > 1800 )
x2 -= 3600;
aFormatter->Print( aNestLevel, "(arc (start %s) (mid %s) (end %s)\n",
FormatInternalUnits( aArc->GetStart() ).c_str(),
FormatInternalUnits( aArc->GetArcMid() ).c_str(),
@ -1345,12 +1339,7 @@ void SCH_SEXPR_PLUGIN::saveShape( SCH_SHAPE* aShape, int aNestLevel )
switch( aShape->GetShape() )
{
case SHAPE_T::ARC:
int x1;
int x2;
aShape->CalcArcAngles( x1, x2 );
formatArc( m_out, aNestLevel, aShape, x1, x2, aShape->GetStroke(), aShape->GetFillMode(),
formatArc( m_out, aNestLevel, aShape, aShape->GetStroke(), aShape->GetFillMode(),
aShape->GetFillColor(), aShape->m_Uuid );
break;
@ -1975,12 +1964,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTE
switch( shape->GetShape() )
{
case SHAPE_T::ARC:
int x1;
int x2;
shape->CalcArcAngles( x1, x2 );
formatArc( &aFormatter, aNestLevel, shape, x1, x2, stroke, fillMode, fillColor );
formatArc( &aFormatter, aNestLevel, shape, stroke, fillMode, fillColor );
break;
case SHAPE_T::CIRCLE:

View File

@ -3283,12 +3283,12 @@ LIB_SHAPE* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr<LIB_SYMBOL>& aSymbo
arc->SetPosition( center );
int radius = Mils2Iu( parseInt( aReader, line, &line ) );
int angle1 = parseInt( aReader, line, &line );
int angle2 = parseInt( aReader, line, &line );
int radius = Mils2Iu( parseInt( aReader, line, &line ) );
EDA_ANGLE angle1( parseInt( aReader, line, &line ), TENTHS_OF_A_DEGREE_T );
EDA_ANGLE angle2( parseInt( aReader, line, &line ), TENTHS_OF_A_DEGREE_T );
NORMALIZE_ANGLE_POS( angle1 );
NORMALIZE_ANGLE_POS( angle2 );
angle1.Normalize();
angle2.Normalize();
arc->SetUnit( parseInt( aReader, line, &line ) );
arc->SetConvert( parseInt( aReader, line, &line ) );
@ -3994,23 +3994,18 @@ void SCH_LEGACY_PLUGIN_CACHE::saveArc( LIB_SHAPE* aArc, OUTPUTFORMATTER& aFormat
{
wxCHECK_RET( aArc && aArc->GetShape() == SHAPE_T::ARC, "Invalid ARC object." );
int x1;
int x2;
EDA_ANGLE startAngle, endAngle;
aArc->CalcArcAngles( x1, x2 );
if( x1 > 1800 )
x1 -= 3600;
if( x2 > 1800 )
x2 -= 3600;
aArc->CalcArcAngles( startAngle, endAngle );
startAngle.Normalize180();
endAngle.Normalize180();
aFormatter.Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n",
Iu2Mils( aArc->GetPosition().x ),
Iu2Mils( aArc->GetPosition().y ),
Iu2Mils( aArc->GetRadius() ),
x1,
x2,
startAngle.AsTenthsOfADegree(),
endAngle.AsTenthsOfADegree(),
aArc->GetUnit(),
aArc->GetConvert(),
Iu2Mils( aArc->GetWidth() ),

View File

@ -89,11 +89,11 @@ void SCH_SHAPE::Rotate( const VECTOR2I& aCenter )
void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const
{
int pen_size = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() );
VECTOR2I center;
int radius = 0;
int startAngle = 0;
int endAngle = 0;
int pen_size = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() );
VECTOR2I center;
int radius = 0;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
static std::vector<VECTOR2I> cornerList;
@ -248,11 +248,11 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
else if( GetShape() == SHAPE_T::ARC )
{
c = getCenter();
int t1, t2;
EDA_ANGLE t1, t2;
CalcArcAngles( t1, t2 );
if( NormalizeAngle180( t1 - t2 ) > 0 )
if( ( t1 - t2 ).Normalize180() > ANGLE_0 )
std::swap( pt1, pt2 );
}
@ -423,15 +423,3 @@ void SCH_SHAPE::AddPoint( const VECTOR2I& aPosition )
}
void SCH_SHAPE::CalcArcAngles( int& aStartAngle, int& aEndAngle ) const
{
double start;
double end;
EDA_SHAPE::CalcArcAngles( start, end );
aStartAngle = KiROUND( start * 10.0 );
aEndAngle = KiROUND( end * 10.0 );
}

View File

@ -78,8 +78,6 @@ public:
VECTOR2I GetCenter() const { return getCenter(); }
void CalcArcAngles( int& aStartAngle, int& aEndAngle ) const;
void BeginEdit( const VECTOR2I& aStartPoint ) { beginEdit( aStartPoint ); }
bool ContinueEdit( const VECTOR2I& aPosition ) { return continueEdit( aPosition ); }
void CalcEdit( const VECTOR2I& aPosition ) { calcEdit( aPosition ); }

View File

@ -76,63 +76,66 @@ TRANSFORM TRANSFORM::InverseTransform() const
}
bool TRANSFORM::MapAngles( int* aAngle1, int* aAngle2 ) const
bool TRANSFORM::MapAngles( EDA_ANGLE* aAngle1, EDA_ANGLE* aAngle2 ) const
{
wxCHECK_MSG( aAngle1 != nullptr && aAngle2 != nullptr, false,
wxT( "Cannot map NULL point angles." ) );
int Angle, Delta;
static const EDA_ANGLE epsilon( 0.1, DEGREES_T );
double x, y, t;
bool swap = false;
Delta = *aAngle2 - *aAngle1;
EDA_ANGLE delta = *aAngle2 - *aAngle1;
if( Delta >= 1800 )
if( delta >= ANGLE_180 )
{
*aAngle1 -= 1;
*aAngle2 += 1;
*aAngle1 -= epsilon;
*aAngle2 += epsilon;
}
x = cos( DECIDEG2RAD( *aAngle1 ) );
y = sin( DECIDEG2RAD( *aAngle1 ) );
x = cos( aAngle1->AsRadians() );
y = sin( aAngle1->AsRadians() );
t = x * x1 + y * y1;
y = x * x2 + y * y2;
x = t;
*aAngle1 = KiROUND( RAD2DECIDEG( atan2( y, x ) ) );
*aAngle1 = EDA_ANGLE( VECTOR2I( x, y ) );
x = cos( DECIDEG2RAD( *aAngle2 ) );
y = sin( DECIDEG2RAD( *aAngle2 ) );
x = cos( aAngle2->AsRadians() );
y = sin( aAngle2->AsRadians() );
t = x * x1 + y * y1;
y = x * x2 + y * y2;
x = t;
*aAngle2 = KiROUND( RAD2DECIDEG( atan2( y, x ) ) );
*aAngle2 = EDA_ANGLE( VECTOR2I( x, y ) );
NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE_POS( *aAngle2 );
aAngle1->Normalize();
aAngle2->Normalize();
if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600;
*aAngle2 += ANGLE_360;
if( *aAngle2 - *aAngle1 > 1800 ) // Need to swap the two angles
if( *aAngle2 - *aAngle1 > ANGLE_180 ) // Need to swap the two angles
{
Angle = (*aAngle1);
*aAngle1 = (*aAngle2);
*aAngle2 = Angle;
EDA_ANGLE temp = *aAngle1;
*aAngle1 = *aAngle2;
*aAngle2 = temp;
NORMALIZE_ANGLE_POS( *aAngle1 );
NORMALIZE_ANGLE_POS( *aAngle2 );
aAngle1->Normalize();
aAngle2->Normalize();
if( *aAngle2 < *aAngle1 )
*aAngle2 += 3600;
*aAngle2 += ANGLE_360;
swap = true;
}
if( Delta >= 1800 )
if( delta >= ANGLE_180 )
{
*aAngle1 += 1;
*aAngle2 -= 1;
*aAngle1 += epsilon;
*aAngle2 -= epsilon;
}
return swap;
}

View File

@ -31,6 +31,7 @@
#define _TRANSFORM_H_
#include <wx/gdicmn.h>
#include <geometry/eda_angle.h>
class EDA_RECT;
@ -97,7 +98,7 @@ public:
* @param aAngle2 = The second angle to transform
* @return True if the angles were swapped during the transform.
*/
bool MapAngles( int* aAngle1, int* aAngle2 ) const;
bool MapAngles( EDA_ANGLE* aAngle1, EDA_ANGLE* aAngle2 ) const;
};

View File

@ -183,7 +183,7 @@ public:
* Calc arc start and end angles such that aStartAngle < aEndAngle. Each may be between
* -360.0 and 360.0.
*/
void CalcArcAngles( double& aStartAngle, double& aEndAngle ) const;
void CalcArcAngles( EDA_ANGLE& aStartAngle, EDA_ANGLE& aEndAngle ) const;
int GetRadius() const;

View File

@ -114,17 +114,8 @@ public:
return m_Type - AT_REGULAR_POLY3 + 3;
}
void SetRotation( double aRotDegree )
{
// The rotation is stored in degree
m_Rotation = aRotDegree;
}
double GetRotation()
{
// The rotation is stored in degree
return m_Rotation;
}
void SetRotation( const EDA_ANGLE& aRotation ) { m_Rotation = aRotation; }
EDA_ANGLE GetRotation() { return m_Rotation; }
// Type ( Line, rect , circulaire , ovale poly 3 to 12 vertices, aperture macro )
APERTURE_TYPE m_Type;
@ -139,7 +130,7 @@ public:
int m_Radius;
// Rotation in degrees
double m_Rotation;
EDA_ANGLE m_Rotation;
// code number ( >= 10 )
int m_DCode;

View File

@ -220,8 +220,9 @@ public:
/**
* Generic fallback: arc rendered as a polyline.
*/
virtual void Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int rayon,
FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH );
virtual void Arc( const VECTOR2I& aCentre, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH );
/**
* Generic fallback: Cubic Bezier curve rendered as a polyline
@ -302,8 +303,9 @@ public:
// Higher level primitives -- can be drawn as line, sketch or 'filled'
virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode, void* aData );
virtual void ThickArc( const VECTOR2I& centre, double StAngle, double EndAngle, int rayon,
int width, OUTLINE_MODE tracemode, void* aData );
virtual void ThickArc( const VECTOR2I& centre, const EDA_ANGLE& StAngle,
const EDA_ANGLE& EndAngle, int rayon, int width,
OUTLINE_MODE tracemode, void* aData );
virtual void ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width, OUTLINE_MODE tracemode,
void* aData );
virtual void ThickCircle( const VECTOR2I& pos, int diametre, int width, OUTLINE_MODE tracemode,
@ -330,8 +332,9 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
/**
* @param aPadPos Position of the shape (center of the rectangle).
@ -340,8 +343,9 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
/**
* @param aPadPos Position of the shape (center of the rectangle.
@ -351,8 +355,9 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize, int aCornerRadius,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
/**
* @param aPadPos Position of the shape.
@ -362,9 +367,9 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aPadOrient,
SHAPE_POLY_SET* aPolygons, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aPadOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
/**
* Flash a trapezoidal pad.
@ -376,8 +381,9 @@ public:
* @param aTraceMode is the drawing mode, FILLED or SKETCH.
* @param aData an auxiliary info (mainly for gerber format attributes).
*/
virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) = 0;
virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
/**
* Flash a regular polygon. Useful only in Gerber files to flash a regular polygon.
@ -385,12 +391,13 @@ public:
* @param aShapePos is the center of the circle containing the polygon.
* @param aRadius is the radius of the circle containing the polygon.
* @param aCornerCount is the number of vertices.
* @param aOrient is the polygon rotation in degrees.
* @param aOrient is the polygon rotation.
* @param aData is a auxiliary parameter used (if needed) to handle extra info
* specific to the plotter.
*/
virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) = 0;
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) = 0;
/**
* Draw text with the plotter.
@ -523,7 +530,8 @@ protected:
void segmentAsOval( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode );
void sketchOval( const VECTOR2I& pos, const VECTOR2I& size, double orient, int width );
void sketchOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA_ANGLE& aOrient,
int aWidth );
// Coordinate and scaling conversion functions

View File

@ -112,8 +112,9 @@ public:
int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode, void* aData ) override;
virtual void Arc( const VECTOR2I& centre, double StAngle, double EndAngle,
int rayon, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void PenTo( const VECTOR2I& pos, char plume ) override;
/**
@ -126,28 +127,32 @@ public:
/**
* DXF oval pad: always done in sketch mode.
*/
virtual void FlashPadOval( const VECTOR2I& pos, const VECTOR2I& size, double orient,
OUTLINE_MODE trace_mode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
/**
* DXF rectangular pad: always done in sketch mode.
*/
virtual void FlashPadRect( const VECTOR2I& pos, const VECTOR2I& size,
double orient, OUTLINE_MODE trace_mode, void* aData ) override;
virtual void FlashPadRect( const VECTOR2I& aPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aOrient,
SHAPE_POLY_SET* aPolygons,
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData ) override;
/**
* DXF trapezoidal pad: only sketch mode is supported.
*/
virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void Text( const VECTOR2I& aPos,
const COLOR4D& aColor,

View File

@ -69,15 +69,17 @@ public:
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, double aStAngle, double aEndAngle, int aRadius,
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
// These functions plot an item and manage X2 gerber attributes
virtual void ThickSegment( const VECTOR2I& start, const VECTOR2I& end, int width,
OUTLINE_MODE tracemode, void* aData ) override;
virtual void ThickArc( const VECTOR2I& centre, double StAngle, double EndAngle,
int rayon, int width, OUTLINE_MODE tracemode, void* aData ) override;
virtual void ThickArc( const VECTOR2I& centre, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, int aWidth,
OUTLINE_MODE tracemode, void* aData ) override;
virtual void ThickRect( const VECTOR2I& p1, const VECTOR2I& p2, int width,
OUTLINE_MODE tracemode, void* aData ) override;
virtual void ThickCircle( const VECTOR2I& pos, int diametre, int width,
@ -117,24 +119,28 @@ public:
virtual void FlashPadCircle( const VECTOR2I& pos, int diametre,
OUTLINE_MODE trace_mode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& size, double orient,
OUTLINE_MODE trace_mode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& size,
double orient, OUTLINE_MODE trace_mode, void* aData ) override;
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aPadOrient, SHAPE_POLY_SET* aPolygons,
const EDA_ANGLE& aPadOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
/**
* Flash a chamfered round rect pad.
@ -149,13 +155,13 @@ public:
* 2 = TOP_RIGHT
* 4 = BOTTOM_LEFT
* 8 = BOTTOM_RIGHT
* @param aPadOrient is the rotation in 0.1 degrees of the shape.
* @param aPadOrient is the rotation of the shape.
* @param aPlotMode is the drawing mode, FILLED or SKETCH.
* @param aData is the a reference to Gerber attributes descr.
*/
void FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const VECTOR2I& aPadSize,
int aCornerRadius, double aChamferRatio,
int aChamferPositions, double aPadOrient,
int aChamferPositions, const EDA_ANGLE& aPadOrient,
OUTLINE_MODE aPlotMode, void* aData );
/**
@ -224,26 +230,26 @@ public:
/**
* @param aSize is the size of tool.
* @param aRadius is the radius used for some shapes tool (oval, roundrect macros).
* @param aRotDegree is the rotation of tool (primitives round, oval rect accept only 0.0).
* @param aRotation is the rotation of tool (primitives round, oval rect accept only 0.0).
* @param aType is the type ( shape ) of tool.
* @param aApertureAttribute is an aperture attribute of the tool (a tool can have only one
* attribute) 0 = no specific attribute.
* @return an index to the aperture in aperture list which meets the size and type of tool
* if the aperture does not exist, it is created and entered in aperture list.
*/
int GetOrCreateAperture( const VECTOR2I& aSize, int aRadius, double aRotDegree,
int GetOrCreateAperture( const VECTOR2I& aSize, int aRadius, const EDA_ANGLE& aRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
/**
* @param aCorners is the corner list.
* @param aRotDegree is the rotation of tool.
* @param aRotation is the rotation of tool.
* @param aType is the type ( shape ) of tool that can manage a list of corners (polygon).
* @param aApertureAttribute is an aperture attribute of the tool (a tool can have only one
* attribute) 0 = no specific attribute.
* @return an index to the aperture in aperture list which meets the data and type of tool
* if the aperture does not exist, it is created and entered in aperture list.
*/
int GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners, double aRotDegree,
int GetOrCreateAperture( const std::vector<VECTOR2I>& aCorners, const EDA_ANGLE& aRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
protected:
@ -259,7 +265,7 @@ protected:
* @param aOrient is the rotation of the rectangle.
*/
void plotRoundRectAsRegion( const VECTOR2I& aRectCenter, const VECTOR2I& aSize,
int aCornerRadius, double aOrient );
int aCornerRadius, const EDA_ANGLE& aOrient );
/**
* Plot a Gerber arc.
*
@ -270,7 +276,7 @@ protected:
* plot an usual arc item. The line thickness is not initialized in plotArc, and must
* be initialized before calling it if needed.
*/
void plotArc( const VECTOR2I& aCenter, double aStAngle, double aEndAngle,
void plotArc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle,
int aRadius, bool aPlotInRegion );
void plotArc( const SHAPE_ARC& aArc, bool aPlotInRegion );
@ -279,7 +285,7 @@ protected:
*
* Write the DCode selection on gerber file.
*/
void selectAperture( const VECTOR2I& aSize, int aRadius, double aRotDegree,
void selectAperture( const VECTOR2I& aSize, int aRadius, const EDA_ANGLE& aRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
/**
* Pick an existing aperture or create a new one, matching the aDiameter, aPolygonRotation,
@ -288,7 +294,7 @@ protected:
* It apply only to apertures with type = AT_REGULAR_POLY3 to AT_REGULAR_POLY12
* write the DCode selection on gerber file
*/
void selectAperture( const std::vector<VECTOR2I>& aCorners, double aPolygonRotation,
void selectAperture( const std::vector<VECTOR2I>& aCorners, const EDA_ANGLE& aPolygonRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
/**
@ -299,7 +305,7 @@ protected:
* to AT_REGULAR_POLY12 (for instance APER_MACRO_TRAPEZOID ) write the DCode selection
* on gerber file.
*/
void selectAperture( int aDiameter, double aRotDegree,
void selectAperture( int aDiameter, const EDA_ANGLE& aRotation,
APERTURE::APERTURE_TYPE aType, int aApertureAttribute );
/**

View File

@ -96,10 +96,10 @@ public:
virtual void SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) override;
virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Circle( const VECTOR2I& aCenter, int aDiameter, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
@ -115,29 +115,32 @@ public:
*
* center is the center of the arc.
* StAngled is the start angle of the arc.
* EndAngle is end angle the arc.
* aEndAngle is end angle the arc.
* Radius is the radius of the arc.
*/
virtual void Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int rayon,
FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void PenTo( const VECTOR2I& pos, char plume ) override;
virtual void FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
double aOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aOrient,
SHAPE_POLY_SET* aPolygons,
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
protected:
@ -166,7 +169,7 @@ protected:
int penNumber;
double penDiameter;
double arcTargetChordLength;
double arcMinChordDegrees;
EDA_ANGLE arcMinChordDegrees;
PLOT_DASH_TYPE dashType;
bool useUserCoords;
bool fitUserCoords;

View File

@ -63,20 +63,23 @@ public:
// Pad routines are handled with lower level primitives
virtual void FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aPadOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
int aCornerRadius, double aOrient,
int aCornerRadius, const EDA_ANGLE& aOrient,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize, double aOrient,
SHAPE_POLY_SET* aPolygons,
virtual void FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aSize,
const EDA_ANGLE& aOrient, SHAPE_POLY_SET* aPolygons,
OUTLINE_MODE aTraceMode, void* aData ) override;
virtual void FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aCorners,
double aPadOrient, OUTLINE_MODE aTraceMode, void* aData ) override;
const EDA_ANGLE& aPadOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
virtual void FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiameter, int aCornerCount,
double aOrient, OUTLINE_MODE aTraceMode,
const EDA_ANGLE& aOrient, OUTLINE_MODE aTraceMode,
void* aData ) override;
/**
@ -201,8 +204,9 @@ public:
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int rayon,
FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void PlotPoly( const std::vector<VECTOR2I>& aCornerList, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override;
@ -321,8 +325,8 @@ public:
* The PDF engine can't directly plot arcs, it uses the base emulation.
* So no filled arcs (not a great loss... )
*/
virtual void Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int rayon,
FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle, int aRadius,
FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
/**
* Polygon plotting for PDF. Everything is supported
@ -450,8 +454,9 @@ public:
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill,
int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& centre, double StAngle, double EndAngle, int rayon,
FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override;
virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill,
int aWidth = USE_DEFAULT_LINE_WIDTH ) override;
virtual void BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1,
const VECTOR2I& aControl2, const VECTOR2I& aEnd,

View File

@ -141,7 +141,7 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I&
* @param aPosition is the coordinate of the center of the rectangle.
* @param aSize is the size of the rectangle.
* @param aCornerRadius is the radius of rounded corners (can be 0).
* @param aRotation is the rotation in 0.1 degrees of the rectangle.
* @param aRotation is the rotationof the rectangle.
* @param aChamferRatio is the ratio between smaller rect side and chamfer value.
* @param aChamferCorners is the identifier of the corners to chamfer:
* - 0 = no chamfer
@ -156,7 +156,7 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I&
*/
void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer,
const VECTOR2I& aPosition, const VECTOR2I& aSize,
double aRotation, int aCornerRadius,
const EDA_ANGLE& aRotation, int aCornerRadius,
double aChamferRatio, int aChamferCorners, int aInflate,
int aError, ERROR_LOC aErrorLoc );

View File

@ -64,7 +64,7 @@ bool SegmentIntersectsSegment( const VECTOR2I& a_p1_l1, const VECTOR2I& a_p2_l1,
*/
void RotatePoint( int *pX, int *pY, double angle );
inline void RotatePoint( int *pX, int *pY, EDA_ANGLE angle )
inline void RotatePoint( int *pX, int *pY, const EDA_ANGLE& angle )
{
RotatePoint( pX, pY, angle.AsTenthsOfADegree() );
}
@ -75,6 +75,11 @@ inline void RotatePoint( int *pX, int *pY, EDA_ANGLE angle )
*/
void RotatePoint( int *pX, int *pY, int cx, int cy, double angle );
inline void RotatePoint( int *pX, int *pY, int cx, int cy, const EDA_ANGLE& angle )
{
RotatePoint( pX, pY, cx, cy, angle.AsTenthsOfADegree() );
}
/*
* Calculate the new coord point point for a rotation angle in (1/10 degree).
*/
@ -83,14 +88,14 @@ inline void RotatePoint( VECTOR2I& point, double angle )
RotatePoint( &point.x, &point.y, angle );
}
inline void RotatePoint( VECTOR2I& point, EDA_ANGLE angle )
inline void RotatePoint( VECTOR2I& point, const EDA_ANGLE& angle )
{
RotatePoint( &point.x, &point.y, angle.AsTenthsOfADegree() );
}
void RotatePoint( VECTOR2I& point, const VECTOR2I& centre, double angle );
inline void RotatePoint( VECTOR2I& point, const VECTOR2I& centre, EDA_ANGLE angle )
inline void RotatePoint( VECTOR2I& point, const VECTOR2I& centre, const EDA_ANGLE& angle )
{
RotatePoint( point, centre, angle.AsTenthsOfADegree() );
}
@ -101,24 +106,24 @@ inline void RotatePoint( VECTOR2I& point, const VECTOR2I& centre, EDA_ANGLE angl
void RotatePoint( double* pX, double* pY, double angle );
inline void RotatePoint( double* pX, double* pY, EDA_ANGLE angle )
inline void RotatePoint( double* pX, double* pY, const EDA_ANGLE& angle )
{
RotatePoint( pX, pY, angle.AsTenthsOfADegree() );
}
inline void RotatePoint( VECTOR2D& point, EDA_ANGLE angle )
inline void RotatePoint( VECTOR2D& point, const EDA_ANGLE& angle )
{
RotatePoint( &point.x, &point.y, angle.AsTenthsOfADegree() );
}
void RotatePoint( double* pX, double* pY, double cx, double cy, double angle );
inline void RotatePoint( double* pX, double* pY, double cx, double cy, EDA_ANGLE angle )
inline void RotatePoint( double* pX, double* pY, double cx, double cy, const EDA_ANGLE& angle )
{
RotatePoint( pX, pY, cx, cy, angle.AsTenthsOfADegree() );
}
inline void RotatePoint( VECTOR2D& point, const VECTOR2D& aCenter, EDA_ANGLE angle )
inline void RotatePoint( VECTOR2D& point, const VECTOR2D& aCenter, const EDA_ANGLE& angle )
{
RotatePoint( &point.x, &point.y, aCenter.x, aCenter.y, angle.AsTenthsOfADegree() );
}
@ -284,19 +289,6 @@ template <class T> inline void NORMALIZE_ANGLE_POS( T& Angle )
}
/// Normalize angle to be in the 0.0 .. 360.0 range: angle is in degrees.
inline double NormalizeAngleDegreesPos( double Angle )
{
while( Angle < 0 )
Angle += 360.0;
while( Angle >= 360.0 )
Angle -= 360.0;
return Angle;
}
/// Normalize angle to be aMin < angle <= aMax angle is in degrees.
inline double NormalizeAngleDegrees( double Angle, double aMin, double aMax )
{
@ -309,17 +301,6 @@ inline double NormalizeAngleDegrees( double Angle, double aMin, double aMax )
return Angle;
}
/// Add two angles (keeping the result normalized). T2 is here
// because most of the time it's an int (and templates don't promote in
// that way)
template <class T, class T2> inline T AddAngles( T a1, T2 a2 )
{
a1 += a2;
NORMALIZE_ANGLE_POS( a1 );
return a1;
}
/// Normalize angle to be in the -180.0 .. 180.0 range
template <class T> inline T NormalizeAngle180( T Angle )
{
@ -332,11 +313,6 @@ template <class T> inline T NormalizeAngle180( T Angle )
return Angle;
}
template <class T> inline void NORMALIZE_ANGLE_180( T& Angle )
{
Angle = NormalizeAngle180( Angle );
}
/**
* Test if an arc from \a aStartAngle to \a aEndAngle crosses the positive X axis (0 degrees).
*
@ -373,22 +349,4 @@ inline bool InterceptsNegativeX( double aStartAngle, double aEndAngle )
return aStartAngle < 180.0 && end > 180.0;
}
/**
* Circle generation utility: computes r * sin(a)
* Where a is in decidegrees, not in radians.
*/
inline double sindecideg( double r, double a )
{
return r * sin( DECIDEG2RAD( a ) );
}
/**
* Circle generation utility: computes r * cos(a)
* Where a is in decidegrees, not in radians.
*/
inline double cosdecideg( double r, double a )
{
return r * cos( DECIDEG2RAD( a ) );
}
#endif

View File

@ -435,9 +435,10 @@ void TransformTrapezoidToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I&
void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer, const VECTOR2I& aPosition,
const VECTOR2I& aSize, double aRotation, int aCornerRadius,
double aChamferRatio, int aChamferCorners, int aInflate,
int aError, ERROR_LOC aErrorLoc )
const VECTOR2I& aSize, const EDA_ANGLE& aRotation,
int aCornerRadius, double aChamferRatio,
int aChamferCorners, int aInflate, int aError,
ERROR_LOC aErrorLoc )
{
SHAPE_POLY_SET outline;
VECTOR2I size( aSize / 2 );
@ -492,10 +493,10 @@ void TransformRoundChamferedRectToPolygon( SHAPE_POLY_SET& aCornerBuffer, const
CornerListToPolygon( outline, corners, aInflate, aError, aErrorLoc );
if( aRotation != 0.0 )
outline.Rotate( DECIDEG2RAD( -aRotation ), VECTOR2I( 0, 0 ) );
if( !aRotation.IsZero() )
outline.Rotate( -aRotation.AsRadians(), VECTOR2I( 0, 0 ) );
outline.Move( VECTOR2I( aPosition ) );
outline.Move( aPosition );
aCornerBuffer.Append( outline );
}

View File

@ -83,7 +83,7 @@ int EDA_ANGLE::normalize( int aValue, EDA_ANGLE_T aAngleType, bool n720 ) const
* if n720 == false, clamp between 0..full_circle_upper
* if n720 == true, clamp between +/- full_circle_upper
*/
int full_circle_lower = n720 ? 0 : -full_circle_upper;
int full_circle_lower = n720 ? -full_circle_upper : 0;
while( aValue < full_circle_lower )
aValue += full_circle_upper;

View File

@ -251,23 +251,6 @@ bool AR_AUTOPLACER::fillMatrix()
}
void AR_AUTOPLACER::rotateFootprint( FOOTPRINT* aFootprint, double aAngle, bool incremental )
{
if( aFootprint == nullptr )
return;
EDA_ANGLE angle( aAngle, TENTHS_OF_A_DEGREE_T );
if( incremental )
aFootprint->SetOrientation( aFootprint->GetOrientation() + angle );
else
aFootprint->SetOrientation( angle );
m_board->GetConnectivity()->Update( aFootprint );
}
void AR_AUTOPLACER::addFpBody( const VECTOR2I& aStart, const VECTOR2I& aEnd, LSET aLayerMask )
{
// Add a polygonal shape (rectangle) to m_fpAreaFront and/or m_fpAreaBack

View File

@ -85,7 +85,6 @@ public:
private:
void drawPlacementRoutingMatrix(); // draw the working area (shows free and occupied areas)
void rotateFootprint( FOOTPRINT* aFootprint, double angle, bool incremental );
int genPlacementRoutingMatrix();
/**

View File

@ -33,6 +33,26 @@
#include <pcb_shape.h>
#include <pad.h>
/**
* Circle generation utility: computes r * sin(a)
* Where a is in decidegrees, not in radians.
*/
double sindecideg( double r, double a )
{
return r * sin( DECIDEG2RAD( a ) );
}
/**
* Circle generation utility: computes r * cos(a)
* Where a is in decidegrees, not in radians.
*/
double cosdecideg( double r, double a )
{
return r * cos( DECIDEG2RAD( a ) );
}
AR_MATRIX::AR_MATRIX()
{
m_BoardSide[0] = nullptr;

View File

@ -32,8 +32,8 @@
DIALOG_MOVE_EXACT::MOVE_EXACT_OPTIONS DIALOG_MOVE_EXACT::m_options;
DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, wxPoint& aTranslate,
double& aRotate, ROTATION_ANCHOR& aAnchor,
DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, VECTOR2I& aTranslate,
EDA_ANGLE& aRotate, ROTATION_ANCHOR& aAnchor,
const EDA_RECT& aBbox ) :
DIALOG_MOVE_EXACT_BASE( aParent ),
m_translation( aTranslate ),
@ -244,7 +244,7 @@ bool DIALOG_MOVE_EXACT::TransferDataFromWindow()
bool ok = GetTranslationInIU( translation, m_polarCoords->IsChecked() );
m_translation.x = KiROUND(translation.x);
m_translation.y = KiROUND(translation.y);
m_rotation = m_rotate.GetDoubleValue();
m_rotation = m_rotate.GetAngleValue();
m_rotationAnchor = m_menuIDs[ m_anchorOptions->GetSelection() ];
// save the settings

View File

@ -46,7 +46,7 @@ enum ROTATION_ANCHOR
class DIALOG_MOVE_EXACT : public DIALOG_MOVE_EXACT_BASE
{
public:
DIALOG_MOVE_EXACT( PCB_BASE_FRAME* aParent, wxPoint& aTranslate, double& aRotate,
DIALOG_MOVE_EXACT( PCB_BASE_FRAME* aParent, VECTOR2I& aTranslate, EDA_ANGLE& aRotate,
ROTATION_ANCHOR& aAnchor, const EDA_RECT& aBbox );
~DIALOG_MOVE_EXACT() { };
@ -111,8 +111,8 @@ private:
static MOVE_EXACT_OPTIONS m_options;
private:
wxPoint& m_translation;
double& m_rotation;
VECTOR2I& m_translation;
EDA_ANGLE& m_rotation;
ROTATION_ANCHOR& m_rotationAnchor;
const EDA_RECT& m_bbox;

View File

@ -591,7 +591,7 @@ static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
VECTOR2I padOffset( 0, 0 );
TransformRoundChamferedRectToPolygon( outline, padOffset, pad->GetSize(),
pad->GetOrientation().AsTenthsOfADegree(),
pad->GetOrientation(),
pad->GetRoundRectCornerRadius(),
pad->GetChamferRectRatio(),
pad->GetChamferPositions(), 0, maxError,

View File

@ -449,10 +449,7 @@ bool GENDRILL_WRITER_BASE::plotDrillMarks( PLOTTER* aPlotter )
aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 );
if( hole.m_Hole_Shape != 0 )
{
VECTOR2I oblong_size = hole.m_Hole_Size;
aPlotter->FlashPadOval( pos, oblong_size, hole.m_Hole_Orient, SKETCH, nullptr );
}
aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr );
}
aPlotter->SetCurrentLineWidth( -1 );

View File

@ -95,7 +95,7 @@ void GENDRILL_WRITER_BASE::buildHolesList( DRILL_LAYER_PAIR aLayerPair,
new_hole.m_HoleAttribute = HOLE_ATTRIBUTE::HOLE_VIA_BURIED;
new_hole.m_Tool_Reference = -1; // Flag value for Not initialized
new_hole.m_Hole_Orient = 0;
new_hole.m_Hole_Orient = ANGLE_0;
new_hole.m_Hole_Diameter = hole_sz;
new_hole.m_Hole_NotPlated = false;
new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
@ -141,7 +141,7 @@ void GENDRILL_WRITER_BASE::buildHolesList( DRILL_LAYER_PAIR aLayerPair,
? HOLE_ATTRIBUTE::HOLE_MECHANICAL
: HOLE_ATTRIBUTE::HOLE_PAD;
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
new_hole.m_Hole_Orient = pad->GetOrientation().AsTenthsOfADegree();
new_hole.m_Hole_Orient = pad->GetOrientation();
new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Diameter = std::min( pad->GetDrillSize().x, pad->GetDrillSize().y );
new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;

View File

@ -90,7 +90,7 @@ public:
m_Hole_NotPlated = false;
m_Hole_Diameter = 0;
m_Tool_Reference = 0;
m_Hole_Orient = 0.0;
m_Hole_Orient = ANGLE_0;
m_Hole_Shape = 0;
m_Hole_Bottom_Layer = B_Cu;
m_Hole_Top_Layer = F_Cu;
@ -104,7 +104,7 @@ public:
int m_Tool_Reference; // Tool reference for this hole = 1 ... n (values <=0
// must not be used).
VECTOR2I m_Hole_Size; // hole size for oblong holes
double m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes
EDA_ANGLE m_Hole_Orient; // Hole rotation (= pad rotation) for oblong holes
int m_Hole_Shape; // hole shape: round (0) or oval (1)
VECTOR2I m_Hole_Pos; // hole position
PCB_LAYER_ID m_Hole_Bottom_Layer; // hole ending layer (usually back layer)

View File

@ -231,8 +231,8 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
{
#if FLASH_OVAL_HOLE // set to 1 to use flashed oblong holes,
// 0 to draw them as a line.
plotter.FlashPadOval( hole_pos, hole_descr.m_Hole_Size,
hole_descr.m_Hole_Orient, FILLED, &gbr_metadata );
plotter.FlashPadOval( hole_pos, hole_descr.m_Hole_Size, hole_descr.m_Hole_Orient,
FILLED, &gbr_metadata );
#else
// Use routing for oblong hole (Slots)
VECTOR2I start, end;
@ -261,10 +261,11 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
#if !FLASH_OVAL_HOLE
void convertOblong2Segment( wxSize aSize, double aOrient, VECTOR2I& aStart, VECTOR2I& aEnd )
void convertOblong2Segment( wxSize aSize, const EDA_ANGLE& aOrient, VECTOR2I& aStart,
VECTOR2I& aEnd )
{
wxSize size( aSize );
double orient = aOrient;
wxSize size( aSize );
EDA_ANGLE orient( aOrient );
/* The pad will be drawn as an oblong shape with size.y > size.x
* (Oval vertical orientation 0)
@ -272,18 +273,15 @@ void convertOblong2Segment( wxSize aSize, double aOrient, VECTOR2I& aStart, VECT
if( size.x > size.y )
{
std::swap( size.x, size.y );
orient = AddAngles( orient, 900 );
orient += ANGLE_90;
}
int deltaxy = size.y - size.x; // distance between centers of the oval
aStart = VECTOR2I( 0, deltaxy / 2 );
RotatePoint( aStart, orient );
int cx = 0;
int cy = deltaxy / 2;
RotatePoint( &cx, &cy, orient );
aStart = VECTOR2I( cx, cy );
cx = 0; cy = -deltaxy / 2;
RotatePoint( &cx, &cy, orient );
aEnd = VECTOR2I( cx, cy );
aEnd = VECTOR2I( 0, -deltaxy / 2 );
RotatePoint( aEnd, orient );
}
#endif

View File

@ -241,8 +241,8 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
// Flashes a diamond at pad position:
plotter.FlashRegularPolygon( pad1->GetPosition(), pad1_mark_size, 4, 0.0, FILLED,
&gbr_metadata );
plotter.FlashRegularPolygon( pad1->GetPosition(), pad1_mark_size, 4, ANGLE_0,
FILLED, &gbr_metadata );
}
}

View File

@ -462,8 +462,7 @@ void PAD::BuildEffectiveShapes( PCB_LAYER_ID aLayer ) const
{
SHAPE_POLY_SET outline;
TransformRoundChamferedRectToPolygon( outline, shapePos, GetSize(),
m_orient.AsTenthsOfADegree(),
TransformRoundChamferedRectToPolygon( outline, shapePos, GetSize(), m_orient,
GetRoundRectCornerRadius(), GetChamferRectRatio(),
GetChamferPositions(), 0, maxError, ERROR_INSIDE );
@ -1551,8 +1550,7 @@ void PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
bool doChamfer = GetShape() == PAD_SHAPE::CHAMFERED_RECT;
SHAPE_POLY_SET outline;
TransformRoundChamferedRectToPolygon( outline, padShapePos, m_size,
m_orient.AsTenthsOfADegree(),
TransformRoundChamferedRectToPolygon( outline, padShapePos, m_size, m_orient,
GetRoundRectCornerRadius(),
doChamfer ? GetChamferRectRatio() : 0,
doChamfer ? GetChamferPositions() : 0,

View File

@ -1401,14 +1401,14 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
case SHAPE_T::ARC:
{
double startAngle;
double endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
aShape->CalcArcAngles( startAngle, endAngle );
if( outline_mode )
{
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(),
DEG2RAD( startAngle ), DEG2RAD( endAngle ), thickness,
startAngle.AsRadians(), endAngle.AsRadians(), thickness,
m_maxError );
}
else
@ -1417,7 +1417,7 @@ void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
m_gal->SetIsStroke( false );
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(),
DEG2RAD( startAngle ), DEG2RAD( endAngle ), thickness,
startAngle.AsRadians(), endAngle.AsRadians(), thickness,
m_maxError );
}
break;

View File

@ -134,8 +134,7 @@ private:
*/
void plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I& aDrillPos,
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
double aOrientation,
int aSmallDrill );
const EDA_ANGLE& aOrientation, int aSmallDrill );
PLOTTER* m_plotter;
BOARD* m_board;

View File

@ -584,8 +584,7 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
EDA_ANGLE start_angle = arc->GetArcAngleStart();
EDA_ANGLE end_angle = start_angle + arc->GetAngle();
aPlotter->ThickArc( VECTOR2I( center.x, center.y ), -end_angle.AsTenthsOfADegree(),
-start_angle.AsTenthsOfADegree(), radius, width, plotMode,
aPlotter->ThickArc( center, -end_angle, -start_angle, radius, width, plotMode,
&gbr_metadata );
}
else

View File

@ -224,21 +224,18 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
break;
case PAD_SHAPE::OVAL:
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(),
aPad->GetOrientation().AsTenthsOfADegree(), aPlotMode,
m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
&gbr_metadata );
break;
case PAD_SHAPE::RECT:
m_plotter->FlashPadRect( shape_pos, aPad->GetSize(),
aPad->GetOrientation().AsTenthsOfADegree(), aPlotMode,
m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
&gbr_metadata );
break;
case PAD_SHAPE::ROUNDRECT:
m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
aPad->GetOrientation().AsTenthsOfADegree(), aPlotMode,
&gbr_metadata );
aPad->GetOrientation(), aPlotMode, &gbr_metadata );
break;
case PAD_SHAPE::TRAPEZOID:
@ -257,23 +254,22 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation().AsTenthsOfADegree(),
aPlotMode, &gbr_metadata );
m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode,
&gbr_metadata );
}
break;
case PAD_SHAPE::CHAMFERED_RECT:
if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
{
static_cast<GERBER_PLOTTER*>( m_plotter )->FlashPadChamferRoundRect(
shape_pos,
aPad->GetSize(),
aPad->GetRoundRectCornerRadius(),
aPad->GetChamferRectRatio(),
aPad->GetChamferPositions(),
aPad->GetOrientation().AsTenthsOfADegree(),
aPlotMode,
&gbr_metadata );
GERBER_PLOTTER* gerberPlotter = static_cast<GERBER_PLOTTER*>( m_plotter );
gerberPlotter->FlashPadChamferRoundRect( shape_pos, aPad->GetSize(),
aPad->GetRoundRectCornerRadius(),
aPad->GetChamferRectRatio(),
aPad->GetChamferPositions(),
aPad->GetOrientation(), aPlotMode,
&gbr_metadata );
break;
}
@ -286,9 +282,8 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
if( polygons->OutlineCount() )
{
m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(),
aPad->GetOrientation().AsTenthsOfADegree(), polygons.get(),
aPlotMode, &gbr_metadata );
m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
polygons.get(), aPlotMode, &gbr_metadata );
}
}
break;
@ -650,9 +645,8 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItem( const FP_SHAPE* aShape )
}
else
{
m_plotter->ThickArc( aShape->GetCenter(), -endAngle.AsTenthsOfADegree(),
-startAngle.AsTenthsOfADegree(), radius, thickness,
GetPlotMode(), &gbr_metadata );
m_plotter->ThickArc( aShape->GetCenter(), -endAngle, -startAngle, radius,
thickness, GetPlotMode(), &gbr_metadata );
}
}
break;
@ -967,9 +961,8 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
}
else
{
m_plotter->ThickArc( aShape->GetCenter(), -endAngle.AsTenthsOfADegree(),
-startAngle.AsTenthsOfADegree(), aShape->GetRadius(),
thickness, GetPlotMode(), &gbr_metadata );
m_plotter->ThickArc( aShape->GetCenter(), -endAngle, -startAngle,
aShape->GetRadius(), thickness, GetPlotMode(), &gbr_metadata );
}
break;
@ -1066,7 +1059,7 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const VECTOR2I& aDrillPos,
const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
double aOrientation, int aSmallDrill )
const EDA_ANGLE& aOrientation, int aSmallDrill )
{
VECTOR2I drillSize = aDrillSize;
@ -1082,6 +1075,7 @@ void BRDITEMS_PLOTTER::plotOneDrillMark( PAD_DRILL_SHAPE_T aDrillShape, const VE
{
drillSize.y -= getFineWidthAdj();
drillSize.y = Clamp( 1, drillSize.y, aPadSize.y - 1 );
m_plotter->FlashPadOval( aDrillPos, drillSize, aOrientation, GetPlotMode(), nullptr );
}
else
@ -1120,7 +1114,7 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
{
plotOneDrillMark( PAD_DRILL_SHAPE_CIRCLE, via->GetStart(),
wxSize( via->GetDrillValue(), 0 ),
wxSize( via->GetWidth(), 0 ), 0, smallDrill );
wxSize( via->GetWidth(), 0 ), ANGLE_0, smallDrill );
}
}
@ -1132,8 +1126,7 @@ void BRDITEMS_PLOTTER::PlotDrillMarks()
continue;
plotOneDrillMark( pad->GetDrillShape(), pad->GetPosition(), pad->GetDrillSize(),
pad->GetSize(), pad->GetOrientation().AsTenthsOfADegree(),
smallDrill );
pad->GetSize(), pad->GetOrientation(), smallDrill );
}
}

View File

@ -1912,15 +1912,15 @@ void ALTIUM_PCB::ParseArcs6Data( const CFB::CompoundFileReader& aReader,
shape.SetShape( SHAPE_T::ARC );
double includedAngle = elem.endangle - elem.startangle;
double startAngle = DEG2RAD( elem.endangle );
EDA_ANGLE includedAngle( elem.endangle - elem.startangle, DEGREES_T );
EDA_ANGLE startAngle( elem.endangle, DEGREES_T );
VECTOR2I startOffset = VECTOR2I( KiROUND( std::cos( startAngle ) * elem.radius ),
-KiROUND( std::sin( startAngle ) * elem.radius ) );
VECTOR2I startOffset( KiROUND( elem.radius * cos( startAngle.AsRadians() ) ),
-KiROUND( elem.radius * sin( startAngle.AsRadians() ) ) );
shape.SetCenter( elem.center );
shape.SetStart( elem.center + startOffset );
shape.SetArcAngleAndEnd( NormalizeAngleDegreesPos( includedAngle ) * 10.0, true );
shape.SetArcAngleAndEnd( includedAngle.Normalize().AsTenthsOfADegree(), true );
};
ALTIUM_PARSER reader( aReader, aEntry );
@ -2134,22 +2134,23 @@ void ALTIUM_PCB::ParsePads6Data( const CFB::CompoundFileReader& aReader,
case ALTIUM_PAD_HOLE_SHAPE::SLOT:
{
pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_OBLONG );
double normalizedSlotrotation =
NormalizeAngleDegreesPos( elem.sizeAndShape->slotrotation );
EDA_ANGLE slotRotation( elem.sizeAndShape->slotrotation, DEGREES_T );
if( normalizedSlotrotation == 0. || normalizedSlotrotation == 180. )
slotRotation.Normalize();
if( slotRotation == ANGLE_0 || slotRotation == ANGLE_180 )
{
pad->SetDrillSize( wxSize( elem.sizeAndShape->slotsize, elem.holesize ) );
}
else
{
if( normalizedSlotrotation != 90. && normalizedSlotrotation != 270. )
if( slotRotation != ANGLE_90 && slotRotation != ANGLE_270 )
{
wxLogWarning( _( "Footprint %s pad %s has a hole-rotation of %f "
"degrees. KiCad only supports 90 degree rotations." ),
footprint->GetReference(),
elem.name,
normalizedSlotrotation );
slotRotation.AsDegrees() );
}
pad->SetDrillSize( wxSize( elem.holesize, elem.sizeAndShape->slotsize ) );

View File

@ -57,7 +57,6 @@ void PCB_ARC::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
const wxString& aActualConversion )
{
XNODE* lNode;
double a = 0.0;
int r = 0;
int endX = 0;
int endY = 0;
@ -133,16 +132,18 @@ void PCB_ARC::Parse( XNODE* aNode, int aLayer, const wxString& aDefaultUnits,
lNode = FindNode( aNode, wxT( "startAngle" ) );
EDA_ANGLE a = ANGLE_0;
if( lNode )
a = StrToInt1Units( lNode->GetNodeContent() );
a = EDA_ANGLE( StrToInt1Units( lNode->GetNodeContent() ), TENTHS_OF_A_DEGREE_T );
lNode = FindNode( aNode, wxT( "sweepAngle" ) );
if( lNode )
m_Angle = StrToInt1Units( lNode->GetNodeContent() );
m_StartX = m_positionX + KiROUND( cosdecideg( r, a ) );
m_StartY = m_positionY - KiROUND( sindecideg( r, a ) );
m_StartX = m_positionX + KiROUND( r * cos( a.AsRadians() ) );
m_StartY = m_positionY - KiROUND( r * sin( a.AsRadians() ) );
}
}

View File

@ -11,10 +11,10 @@
{
double GetArcAngleStart()
{
double startAngle;
double endAngle;
EDA_ANGLE startAngle;
EDA_ANGLE endAngle;
$self->CalcArcAngles( startAngle, endAngle );
return startAngle * 10;
return startAngle.AsTenthsOfADegree();
}
%pythoncode

View File

@ -499,10 +499,12 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, PAD* aPad )
rradius += extra_clearance;
bool doChamfer = aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT;
TransformRoundChamferedRectToPolygon(
cornerBuffer, VECTOR2I( 0, 0 ), psize, 0, rradius, aPad->GetChamferRectRatio(),
doChamfer ? aPad->GetChamferPositions() : 0, 0,
aBoard->GetDesignSettings().m_MaxError, ERROR_INSIDE );
TransformRoundChamferedRectToPolygon( cornerBuffer, VECTOR2I( 0, 0 ), psize, ANGLE_0,
rradius, aPad->GetChamferRectRatio(),
doChamfer ? aPad->GetChamferPositions() : 0,
0, aBoard->GetDesignSettings().m_MaxError,
ERROR_INSIDE );
SHAPE_LINE_CHAIN& polygonal_shape = cornerBuffer.Outline( 0 );
for( int ndx = 0; ndx < reportedLayers; ++ndx )

View File

@ -1973,8 +1973,8 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
if( selection.Empty() )
return 0;
wxPoint translation;
double rotation;
VECTOR2I translation;
EDA_ANGLE rotation;
ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
: ROTATE_AROUND_ITEM_ANCHOR;
@ -1986,15 +1986,15 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
if( ret == wxID_OK )
{
EDA_ANGLE angle( rotation, TENTHS_OF_A_DEGREE_T );
EDA_ANGLE angle = rotation;
VECTOR2I rp = selection.GetCenter();
wxPoint selCenter( rp.x, rp.y );
VECTOR2I selCenter( rp.x, rp.y );
// Make sure the rotation is from the right reference point
selCenter += translation;
if( !frame()->Settings().m_Display.m_DisplayInvertYAxis )
rotation *= -1.0;
rotation = -rotation;
// When editing footprints, all items have the same parent
if( IsFootprintEditor() )

View File

@ -151,8 +151,8 @@ int playground_main_func( int argc, char* argv[] )
overlay = frame->GetOverlay();
overlay->SetIsFill(false);
overlay->SetLineWidth(10000);
overlay->SetIsFill( false );
overlay->SetLineWidth( 10000 );
std::vector<SHAPE_ARC> arcs;
int n_arcs = sizeof( test_data ) / sizeof( ARC_DATA );
@ -164,8 +164,8 @@ int playground_main_func( int argc, char* argv[] )
const ARC_DATA& d = test_data[i];
SHAPE_ARC arc( VECTOR2D( Millimeter2iu( d.cx ), Millimeter2iu( d.cy ) ),
VECTOR2D( Millimeter2iu( d.sx ), Millimeter2iu( d.sy ) ), d.ca,
Millimeter2iu( d.w ) );
VECTOR2D( Millimeter2iu( d.sx ), Millimeter2iu( d.sy ) ),
EDA_ANGLE( d.ca, DEGREES_T ), Millimeter2iu( d.w ) );
arcs.push_back( arc );