Schematic and symbol text boxes.

Also fixes some plot bugs with arcs.

Also moves polygonization of arcs (when required) in plotting code
from 5 degrees to calculated based on ARC_HIGH_DEF.

Fixes https://gitlab.com/kicad/code/kicad/issues/5017
This commit is contained in:
Jeff Young
2022-01-28 21:38:15 +00:00
parent 3409783d9f
commit c6a8100d46
98 changed files with 10142 additions and 1418 deletions
+59
View File
@@ -261,6 +261,62 @@ void PDF_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T aFill, int w
}
void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd,
FILL_T aFill, int aWidth, int aMaxError )
{
wxASSERT( workFile );
/*
* Arcs are not so easily approximated by beziers (in the general case), so we approximate
* them in the old way
*/
EDA_ANGLE startAngle( aStart - aCenter );
EDA_ANGLE endAngle( aEnd - aCenter );
int radius = ( aStart - aCenter ).EuclideanNorm();
int numSegs = GetArcToSegmentCount( radius, aMaxError, FULL_CIRCLE );
EDA_ANGLE delta = ANGLE_360 / std::max( 8, numSegs );
VECTOR2I start( aStart );
VECTOR2I end( aEnd );
VECTOR2I pt;
if( startAngle > endAngle )
{
if( endAngle < ANGLE_0 )
endAngle.Normalize();
else
startAngle = startAngle.Normalize() - ANGLE_360;
}
SetCurrentLineWidth( aWidth );
VECTOR2D pos_dev = userToDeviceCoordinates( start );
fprintf( workFile, "%g %g m ", pos_dev.x, pos_dev.y );
for( EDA_ANGLE ii = delta; startAngle + ii < endAngle; ii += delta )
{
pt = start;
RotatePoint( pt, aCenter, -ii );
pos_dev = userToDeviceCoordinates( pt );
fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y );
}
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( aFill == FILL_T::NO_FILL )
{
fputs( "S\n", workFile );
}
else
{
pos_dev = userToDeviceCoordinates( aCenter );
fprintf( workFile, "%g %g l b\n", pos_dev.x, pos_dev.y );
}
}
void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth )
{
@@ -282,6 +338,9 @@ void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle,
VECTOR2I end;
const EDA_ANGLE delta( 5, DEGREES_T ); // increment to draw circles
startAngle = ANGLE_180 - startAngle;
endAngle = ANGLE_180 - endAngle;
if( startAngle > endAngle )
std::swap( startAngle, endAngle );