Clean some more tenths-of-degrees out of GerbView.
This commit is contained in:
parent
180137baa4
commit
78385f7ab5
|
@ -117,7 +117,6 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
|
||||
VECTOR2I curPos = aShapePos;
|
||||
D_CODE* tool = aParent->GetDcodeDescr();
|
||||
double rotation;
|
||||
|
||||
switch( primitive_id )
|
||||
{
|
||||
|
@ -134,9 +133,9 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
// shape rotation (if any):
|
||||
if( params.size() >= 5 )
|
||||
{
|
||||
rotation = params[4].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[4].GetValue( tool ), DEGREES_T );
|
||||
|
||||
if( rotation != 0)
|
||||
if( !rotation.IsZero() )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( polybuffer[ii], -rotation );
|
||||
|
@ -170,9 +169,9 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
ConvertShapeToPolygon( aParent, polybuffer );
|
||||
|
||||
// shape rotation:
|
||||
rotation = params[6].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[6].GetValue( tool ), DEGREES_T );
|
||||
|
||||
if( rotation != 0)
|
||||
if( !rotation.IsZero() )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( polybuffer[ii], -rotation );
|
||||
|
@ -202,9 +201,9 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
ConvertShapeToPolygon( aParent, polybuffer );
|
||||
|
||||
// shape rotation:
|
||||
rotation = params[5].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
|
||||
|
||||
if( rotation != 0 )
|
||||
if( !rotation.IsZero() )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( polybuffer[ii], -rotation );
|
||||
|
@ -231,8 +230,9 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
ConvertShapeToPolygon( aParent, polybuffer );
|
||||
|
||||
// shape rotation:
|
||||
rotation = params[5].GetValue( tool ) * 10.0;
|
||||
if( rotation != 0)
|
||||
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
|
||||
|
||||
if( !rotation.IsZero() )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( polybuffer[ii], -rotation );
|
||||
|
@ -264,14 +264,14 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
ConvertShapeToPolygon( aParent, subshape_poly );
|
||||
|
||||
// shape rotation:
|
||||
rotation = params[5].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
|
||||
|
||||
// Because a thermal shape has 4 identical sub-shapes, only one is created in subshape_poly.
|
||||
// We must draw 4 sub-shapes rotated by 90 deg
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
{
|
||||
polybuffer = subshape_poly;
|
||||
double sub_rotation = rotation + 900 * ii;
|
||||
EDA_ANGLE sub_rotation = rotation + ANGLE_90 * ii;
|
||||
|
||||
for( unsigned jj = 0; jj < polybuffer.size(); jj++ )
|
||||
RotatePoint( polybuffer[jj], -sub_rotation );
|
||||
|
@ -337,7 +337,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
// Draw the cross:
|
||||
ConvertShapeToPolygon( aParent, polybuffer );
|
||||
|
||||
rotation = params[8].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[8].GetValue( tool ), DEGREES_T );
|
||||
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
|
@ -376,7 +376,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
|
||||
// the shape rotation is the last param of list, after corners
|
||||
int last_prm = params.size() - 1;
|
||||
rotation = params[last_prm].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[last_prm].GetValue( tool ), DEGREES_T );
|
||||
VECTOR2I pos;
|
||||
|
||||
// Read points.
|
||||
|
@ -418,6 +418,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
}
|
||||
|
||||
case AMP_POLYGON:
|
||||
{
|
||||
/* Polygon, Primitive Code 5
|
||||
* A polygon primitive is a regular polygon defined by the number of vertices n, the
|
||||
* center point and the diameter of the circumscribed circle
|
||||
|
@ -433,7 +434,8 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
ConvertShapeToPolygon( aParent, polybuffer );
|
||||
|
||||
// rotate polygon and move it to the actual position
|
||||
rotation = params[5].GetValue( tool ) * 10.0;
|
||||
EDA_ANGLE rotation( params[5].GetValue( tool ), DEGREES_T );
|
||||
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
RotatePoint( polybuffer[ii], -rotation );
|
||||
|
@ -444,6 +446,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
|
|||
TO_POLY_SHAPE;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AMP_EOF:
|
||||
// not yet supported, waiting for you.
|
||||
|
@ -478,12 +481,12 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
|
|||
if( radius <= 0 )
|
||||
break;
|
||||
|
||||
VECTOR2I center =
|
||||
mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric );
|
||||
VECTOR2I center = mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ),
|
||||
m_GerbMetric );
|
||||
VECTOR2I corner;
|
||||
const int delta = 3600 / seg_per_circle; // rot angle in 0.1 degree
|
||||
EDA_ANGLE delta = ANGLE_360 / seg_per_circle; // rot angle in 0.1 degree
|
||||
|
||||
for( int angle = 0; angle < 3600; angle += delta )
|
||||
for( EDA_ANGLE angle = ANGLE_0; angle < ANGLE_360; angle += delta )
|
||||
{
|
||||
corner.x = radius;
|
||||
corner.y = 0;
|
||||
|
@ -582,16 +585,16 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
|
|||
innerRadius = std::max( 1, innerRadius );
|
||||
|
||||
int halfthickness = scaletoIU( params[4].GetValue( tool ), m_GerbMetric ) / 2;
|
||||
double angle_start = RAD2DECIDEG( asin( (double) halfthickness / innerRadius ) );
|
||||
EDA_ANGLE angle_start( asin( (double) halfthickness / innerRadius ), RADIANS_T );
|
||||
|
||||
// Draw shape in the first quadrant (X and Y > 0)
|
||||
VECTOR2I pos, startpos;
|
||||
|
||||
// Inner arc
|
||||
startpos.x = innerRadius;
|
||||
double angle_end = 900 - angle_start;
|
||||
EDA_ANGLE angle_end = ANGLE_90 - angle_start;
|
||||
|
||||
for( double angle = angle_start; angle < angle_end; angle += 100 )
|
||||
for( EDA_ANGLE angle = angle_start; angle < angle_end; angle += EDA_ANGLE( 10, DEGREES_T ) )
|
||||
{
|
||||
pos = startpos;
|
||||
RotatePoint( pos, angle );
|
||||
|
@ -606,11 +609,11 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
|
|||
// outer arc
|
||||
startpos.x = outerRadius;
|
||||
startpos.y = 0;
|
||||
angle_start = RAD2DECIDEG( asin( (double) halfthickness / outerRadius ) );
|
||||
angle_end = 900 - angle_start;
|
||||
angle_start = EDA_ANGLE( asin( (double) halfthickness / outerRadius ), RADIANS_T );
|
||||
angle_end = ANGLE_90 - angle_start;
|
||||
|
||||
// First point, near Y axis, outer arc
|
||||
for( double angle = angle_end; angle > angle_start; angle -= 100 )
|
||||
for( EDA_ANGLE angle = angle_end; angle > angle_start; angle -= EDA_ANGLE( 10, DEGREES_T ) )
|
||||
{
|
||||
pos = startpos;
|
||||
RotatePoint( pos, angle );
|
||||
|
@ -650,7 +653,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
|
|||
for( int ii = 0; ii < 4; ii++ )
|
||||
{
|
||||
pos = aBuffer[ii];
|
||||
RotatePoint( pos, jj*900 );
|
||||
RotatePoint( pos, ANGLE_90 * jj );
|
||||
aBuffer.push_back( pos );
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +680,7 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
|
|||
for( int ii = 0; ii <= vertexcount; ii++ )
|
||||
{
|
||||
VECTOR2I pos( radius, 0 );
|
||||
RotatePoint( pos, ii * 3600 / vertexcount );
|
||||
RotatePoint( pos, ANGLE_360 * ii / vertexcount );
|
||||
aBuffer.push_back( pos );
|
||||
}
|
||||
|
||||
|
|
|
@ -354,7 +354,7 @@ void D_CODE::ConvertShapeToPolygon()
|
|||
for( ; ii <= SEGS_CNT / 2; ii++ )
|
||||
{
|
||||
currpos = initialpos;
|
||||
RotatePoint( currpos, ii * 3600.0 / SEGS_CNT );
|
||||
RotatePoint( currpos, ANGLE_360 * ii / SEGS_CNT );
|
||||
currpos.x += delta;
|
||||
m_Polygon.Append( VECTOR2I( currpos ) );
|
||||
}
|
||||
|
@ -363,12 +363,12 @@ void D_CODE::ConvertShapeToPolygon()
|
|||
for( ii = SEGS_CNT / 2; ii <= SEGS_CNT; ii++ )
|
||||
{
|
||||
currpos = initialpos;
|
||||
RotatePoint( currpos, ii * 3600.0 / SEGS_CNT );
|
||||
RotatePoint( currpos, ANGLE_360 * ii / SEGS_CNT );
|
||||
currpos.x -= delta;
|
||||
m_Polygon.Append( VECTOR2I( currpos ) );
|
||||
m_Polygon.Append( currpos );
|
||||
}
|
||||
|
||||
m_Polygon.Append( VECTOR2I( initialpos ) ); // close outline
|
||||
m_Polygon.Append( initialpos ); // close outline
|
||||
|
||||
if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon.
|
||||
m_Polygon.Rotate( -M_PI / 2 );
|
||||
|
@ -393,8 +393,8 @@ void D_CODE::ConvertShapeToPolygon()
|
|||
for( int ii = 0; ii < m_EdgesCount; ii++ )
|
||||
{
|
||||
currpos = initialpos;
|
||||
RotatePoint( currpos, ii * 3600.0 / m_EdgesCount );
|
||||
m_Polygon.Append( VECTOR2I( currpos ) );
|
||||
RotatePoint( currpos, ANGLE_360 * ii / m_EdgesCount );
|
||||
m_Polygon.Append( currpos );
|
||||
}
|
||||
|
||||
addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos );
|
||||
|
|
|
@ -367,7 +367,7 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( const GERBER_DRAW_ITEM* aGb
|
|||
{
|
||||
seg_start = curr_start;
|
||||
VECTOR2I curr_end = start;
|
||||
RotatePoint( curr_end, aGbrItem->m_ArcCentre, -RAD2DECIDEG( DELTA_ANGLE * ii ) );
|
||||
RotatePoint( curr_end, aGbrItem->m_ArcCentre, -EDA_ANGLE( DELTA_ANGLE, RADIANS_T ) * ii );
|
||||
seg_end = curr_end;
|
||||
|
||||
// Reverse Y axis:
|
||||
|
|
|
@ -143,9 +143,9 @@ VECTOR2I GERBER_DRAW_ITEM::GetABPosition( const VECTOR2I& aXYPosition ) const
|
|||
abPos += m_layerOffset + m_GerberImageFile->m_ImageOffset;
|
||||
abPos.x = KiROUND( abPos.x * m_drawScale.x );
|
||||
abPos.y = KiROUND( abPos.y * m_drawScale.y );
|
||||
double rotation = m_lyrRotation * 10 + m_GerberImageFile->m_ImageRotation * 10;
|
||||
EDA_ANGLE rotation( m_lyrRotation + m_GerberImageFile->m_ImageRotation, DEGREES_T );
|
||||
|
||||
if( rotation )
|
||||
if( !rotation.IsZero() )
|
||||
RotatePoint( abPos, -rotation );
|
||||
|
||||
// Negate A axis if mirrored
|
||||
|
@ -171,9 +171,9 @@ VECTOR2I GERBER_DRAW_ITEM::GetXYPosition( const VECTOR2I& aABPosition ) const
|
|||
if( !m_mirrorB )
|
||||
xyPos.y = -xyPos.y;
|
||||
|
||||
double rotation = m_lyrRotation * 10 + m_GerberImageFile->m_ImageRotation * 10;
|
||||
EDA_ANGLE rotation( m_lyrRotation + m_GerberImageFile->m_ImageRotation, DEGREES_T );
|
||||
|
||||
if( rotation )
|
||||
if( !rotation.IsZero() )
|
||||
RotatePoint( xyPos, rotation );
|
||||
|
||||
xyPos.x = KiROUND( xyPos.x / m_drawScale.x );
|
||||
|
|
|
@ -349,12 +349,11 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, con
|
|||
VECTOR2I end = dummyGbrItem.m_End - center;
|
||||
|
||||
/* Calculate angle arc
|
||||
* angles are in 0.1 deg
|
||||
* angle is trigonometrical (counter-clockwise),
|
||||
* and axis is the X,Y gerber coordinates
|
||||
*/
|
||||
double start_angle = ArcTangente( start.y, start.x );
|
||||
double end_angle = ArcTangente( end.y, end.x );
|
||||
EDA_ANGLE start_angle( start );
|
||||
EDA_ANGLE end_angle( end );
|
||||
|
||||
// dummyTrack has right geometric parameters, but
|
||||
// fillArcGBRITEM calculates arc parameters for a draw function that expects
|
||||
|
@ -362,13 +361,13 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, con
|
|||
// Due to the fact atan2 returns angles between -180 to + 180 degrees,
|
||||
// this is not always the case ( a modulo 360.0 degrees can be lost )
|
||||
if( start_angle > end_angle )
|
||||
end_angle += 3600;
|
||||
end_angle += ANGLE_360;
|
||||
|
||||
double arc_angle = start_angle - end_angle;
|
||||
EDA_ANGLE arc_angle = start_angle - end_angle;
|
||||
|
||||
// Approximate arc by 36 segments per 360 degree
|
||||
const int increment_angle = 3600 / 36;
|
||||
int count = std::abs( arc_angle / increment_angle );
|
||||
EDA_ANGLE increment_angle = ANGLE_360 / 36;
|
||||
int count = std::abs( arc_angle.AsDegrees() / increment_angle.AsDegrees() );
|
||||
|
||||
if( aGbrItem->m_Polygon.OutlineCount() == 0 )
|
||||
aGbrItem->m_Polygon.NewOutline();
|
||||
|
@ -378,13 +377,13 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, con
|
|||
// and we must always create a polygon from start to end.
|
||||
for( int ii = 0; ii <= count; ii++ )
|
||||
{
|
||||
double rot;
|
||||
EDA_ANGLE rot;
|
||||
VECTOR2I end_arc = start;
|
||||
|
||||
if( aClockwise )
|
||||
rot = ii * increment_angle; // rot is in 0.1 deg
|
||||
rot = increment_angle * ii;
|
||||
else
|
||||
rot = ( count - ii ) * increment_angle; // rot is in 0.1 deg
|
||||
rot = increment_angle * ( count - ii );
|
||||
|
||||
if( ii < count )
|
||||
RotatePoint( end_arc, -rot );
|
||||
|
|
Loading…
Reference in New Issue