223 : arcTargetChordLength( 0 ),
224 arcMinChordDegrees( 5.0 ),
226 useUserCoords( false ),
227 fitUserCoords( false ),
228 m_current_item( nullptr )
236 double aScale,
bool aMirror )
293 bbox.
Merge( item.bbox );
303 fprintf(
m_outputFile,
"SC%.0f,%.0f,%.0f,%.0f;\n", 0., pagesize_dev.
x, 0.,
315 if( item.loc_start != loc || pen_up )
323 fprintf(
m_outputFile,
"PA %.0f,%.0f;", item.loc_start.x, item.loc_start.y );
326 if( item.dashType != current_dash )
328 current_dash = item.dashType;
332 if( item.pen != current_pen )
340 current_pen = item.pen;
343 if( pen_up && !item.lift_before )
348 else if( !pen_up && item.lift_before )
354 fputs( static_cast<const char*>( item.content.utf8_str() ),
m_outputFile );
356 if( !item.pen_returns )
362 if( item.lift_after )
418 double const circumf = 2.0 * M_PI * radius;
420 double chord_degrees = 360.0 * target_chord_length / circumf;
426 else if( chord_degrees > 45 )
440 BOX2D( center_dev - radius,
VECTOR2D( 2 * radius, 2 * radius ) ) );
451 BOX2D( center_dev - radius,
VECTOR2D( 2 * radius, 2 * radius ) ) );
462 FILL_TYPE aFill,
int aWidth,
void * aData )
464 if( aCornerList.size() <= 1 )
485 for(
unsigned ii = 1; ii < aCornerList.size(); ++ii )
486 LineTo( aCornerList[ii] );
488 int ii = aCornerList.size() - 1;
490 if( aCornerList[ii] != aCornerList[0] )
496 else if( aWidth > 0 )
499 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
500 LineTo( aCornerList[ii] );
505 int ii = aCornerList.size() - 1;
507 if( aCornerList[ii] != aCornerList[0] )
535 else if( plume ==
'D' )
600 double const circumf_dev = 2.0 * M_PI * radius_dev;
602 double chord_degrees = 360.0 * target_chord_length / circumf_dev;
608 else if( chord_degrees > 45 )
616 angle = StAngle - EndAngle;
618 angle = EndAngle - StAngle;
630 centre_dev.
y,
angle, chord_degrees ) );
634 BOX2D( centre_dev - radius_dev,
VECTOR2D( radius_dev * 2, radius_dev * 2 ) ) );
647 wxSize size( aSize );
652 if( size.x > size.y )
654 std::swap( size.x, size.y );
658 deltaxy = size.y - size.x;
660 if( trace_mode ==
FILLED )
663 orient, trace_mode, aData );
664 cx = 0; cy = deltaxy / 2;
666 FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
667 cx = 0; cy = -deltaxy / 2;
669 FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
686 int radius = diametre / 2;
688 if( trace_mode ==
FILLED )
700 if( trace_mode ==
FILLED )
704 MoveTo( wxPoint( pos.x+radius, pos.y ) );
728 std::vector<wxPoint> corners;
730 int dx = padsize.x / 2;
731 int dy = padsize.y / 2;
733 if( trace_mode ==
FILLED )
738 dx = std::max( dx, 0);
740 dy = std::max( dy, 0);
744 corners.emplace_back( - dx, - dy );
745 corners.emplace_back( - dx, + dy );
746 corners.emplace_back( + dx, + dy );
747 corners.emplace_back( + dx, - dy );
749 corners.emplace_back( - dx, - dy );
751 for(
unsigned ii = 0; ii < corners.size(); ii++ )
762 int aCornerRadius,
double aOrient,
769 if( aTraceMode ==
FILLED )
774 size.x = std::max( size.x, 0);
776 size.y = std::max( size.y, 0);
779 aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
786 std::vector<wxPoint> cornerList;
790 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
791 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
793 if( cornerList.back() != cornerList.front() )
794 cornerList.push_back( cornerList.front() );
803 std::vector< wxPoint > cornerList;
805 for(
int cnt = 0; cnt < aPolygons->
OutlineCount(); ++cnt )
812 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
813 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
815 if( cornerList.back() != cornerList.front() )
816 cornerList.push_back( cornerList.front() );
824 double aPadOrient,
OUTLINE_MODE aTraceMode,
void* aData )
826 std::vector< wxPoint > cornerList;
827 cornerList.reserve( 5 );
829 for(
int ii = 0; ii < 4; ii++ )
831 wxPoint coord( aCorners[ii] );
834 cornerList.push_back( coord );
838 cornerList.push_back( cornerList.front() );
845 int aRadius,
int aCornerCount,
889 if( items.size() < 2 )
894 std::list<HPGL_ITEM> target;
917 target.emplace_back( last_item );
919 while( !items.empty() )
921 auto best_it = items.begin();
924 for(
auto search_it = best_it; search_it != items.end(); search_it++ )
928 if( best_it->pen != last_item.
pen && search_it->pen == last_item.
pen )
935 if( dist < best_dist )
943 target.emplace_back( *best_it );
944 last_item = *best_it;
945 items.erase( best_it );
948 items.splice( items.begin(), target );
973 return sqrt( diff.
x * diff.
x + diff.
y * diff.
y );
void segmentAsOval(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode)
Convert a thick segment and plot it as an oval.
void FinishTo(const wxPoint &pos)
virtual bool EndPlot() override
HPGL end of plot: sort and emit graphics, pen return and release.
virtual void FlashPadCircle(const wxPoint &aPadPos, int aDiameter, OUTLINE_MODE aTraceMode, void *aData) override
bool pen_returns
Whether the pen returns to its original state after the command.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
PLOT_DASH_TYPE dashType
Line style for this command.
FILL_TYPE
The set of fill types used in plotting or drawing enclosed areas.
void flushItem()
Flush the current HPGL_ITEM and clear out the current item pointer.
BOX2D bbox
Bounding box of this item.
bool startItem(DPOINT location)
Start a new HPGL_ITEM if necessary, keeping the current one if it exists.
FILE * m_outputFile
Output file.
static void sortItems(std::list< HPGL_ITEM > &items)
Sort a list of HPGL items to improve plotting speed on mechanical plotters.
virtual void SetPenDiameter(double diameter)
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError, ERROR_LOC aErrorLoc)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
wxString content
Text of the command.
std::list< HPGL_ITEM > m_items
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a trapezoidal pad.
void NORMALIZE_ANGLE_180(T &Angle)
void RotatePoint(int *pX, int *pY, double angle)
int PointCount() const
Function PointCount()
virtual bool StartPlot() override
At the start of the HPGL plot pen speed and number are requested.
virtual void FlashPadOval(const wxPoint &aPadPos, const wxSize &aSize, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
DPOINT loc_end
Location the pen will be at when it finishes.
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
bool startOrAppendItem(DPOINT location, wxString const &content)
Start a new HPGL_ITEM with the given string if necessary, or append the string to the current item.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void LineTo(const wxPoint &pos)
static const int USE_DEFAULT_LINE_WIDTH
virtual void FlashRegularPolygon(const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a regular polygon.
VECTOR2< double > VECTOR2D
virtual void SetCurrentLineWidth(int width, void *aData=NULL) override
HPGL doesn't handle line thickness or color.
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
bool lift_after
Whether the pen must be lifted after the command.
coord_type GetWidth() const
virtual void SetPenSpeed(int speed)
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData) override
static const char hpgl_end_polygon_cmd[]
Base window classes and related definitions.
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
HPGL polygon:
const wxSize & GetSizeMils() const
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
static double dpoint_dist(DPOINT a, DPOINT b)
Compute the distance between two DPOINT points.
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)
int pen
Pen number for this command.
PLOT_DASH_TYPE
Dashed line types.
void MoveTo(const wxPoint &pos)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
HPGL_ITEM * m_current_item
void SetTargetChordLength(double chord_len)
Set the target length of chords used to draw approximated circles and arcs.
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
virtual void Arc(const wxPoint ¢re, double StAngle, double EndAngle, int rayon, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
static const char * lineTypeCommand(PLOT_DASH_TYPE linetype)
Return the plot command corresponding to a line type.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
virtual void SetPenNumber(int number)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
coord_type GetHeight() const
int GetPlotterArcHighDef() const
virtual void FlashPadRect(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
static const double PLUsPERDECIMIL
double arcMinChordDegrees
bool lift_before
Whether the command should be executed with the pen lifted.
double arcTargetChordLength
DPOINT loc_start
Location the pen should start at.
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
virtual void SetDash(PLOT_DASH_TYPE dashed) override
HPGL supports dashed lines.
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)