223 : arcTargetChordLength( 0 ),
224 arcMinChordDegrees( 5.0 ),
226 useUserCoords( false ),
227 fitUserCoords( false ),
228 m_current_item( nullptr )
237 double aScale,
bool aMirror )
289 bbox.
Merge( item.bbox );
299 fprintf(
m_outputFile,
"SC%.0f,%.0f,%.0f,%.0f;\n", 0., pagesize_dev.
x, 0.,
311 if( item.loc_start != loc || pen_up )
319 fprintf(
m_outputFile,
"PA %.0f,%.0f;", item.loc_start.x, item.loc_start.y );
322 if( item.dashType != current_dash )
324 current_dash = item.dashType;
328 if( item.pen != current_pen )
337 current_pen = item.pen;
340 if( pen_up && !item.lift_before )
345 else if( !pen_up && item.lift_before )
351 fputs( static_cast<const char*>( item.content.utf8_str() ),
m_outputFile );
353 if( !item.pen_returns )
359 if( item.lift_after )
415 double const circumf = 2.0 * M_PI * radius;
417 double chord_degrees = 360.0 * target_chord_length / circumf;
423 else if( chord_degrees > 45 )
437 VECTOR2D( 2 * radius, 2 * radius ) ) );
448 VECTOR2D( 2 * radius, 2 * radius ) ) );
457 if( aCornerList.size() <= 1 )
478 for(
unsigned ii = 1; ii < aCornerList.size(); ++ii )
479 LineTo( aCornerList[ii] );
481 int ii = aCornerList.size() - 1;
483 if( aCornerList[ii] != aCornerList[0] )
489 else if( aWidth != 0 )
492 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
493 LineTo( aCornerList[ii] );
498 int ii = aCornerList.size() - 1;
500 if( aCornerList[ii] != aCornerList[0] )
528 else if( plume ==
'D' )
575 double const circumf_dev = 2.0 * M_PI * radius_dev;
577 double chord_degrees = 360.0 * target_chord_length / circumf_dev;
583 else if( chord_degrees > 45 )
591 angle = StAngle - EndAngle;
593 angle = EndAngle - StAngle;
605 centre_dev.
y,
angle, chord_degrees ) );
609 VECTOR2D( radius_dev * 2, radius_dev * 2 ) ) );
620 wxSize size( aSize );
623 if( size.x > size.y )
625 std::swap( size.x, size.y );
629 deltaxy = size.y - size.x;
631 if( trace_mode ==
FILLED )
634 orient, trace_mode, aData );
635 cx = 0; cy = deltaxy / 2;
637 FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
638 cx = 0; cy = -deltaxy / 2;
640 FlashPadCircle( wxPoint( cx + pos.x, cy + pos.y ), size.x, trace_mode, aData );
655 int radius = diametre / 2;
657 if( trace_mode ==
FILLED )
669 if( trace_mode ==
FILLED )
673 MoveTo( wxPoint( pos.x+radius, pos.y ) );
698 std::vector<wxPoint> corners;
700 int dx = padsize.x / 2;
701 int dy = padsize.y / 2;
703 if( trace_mode ==
FILLED )
708 dx = std::max( dx, 0);
710 dy = std::max( dy, 0);
714 corners.emplace_back( - dx, - dy );
715 corners.emplace_back( - dx, + dy );
716 corners.emplace_back( + dx, + dy );
717 corners.emplace_back( + dx, - dy );
720 corners.emplace_back( - dx, - dy );
722 for(
unsigned ii = 0; ii < corners.size(); ii++ )
733 int aCornerRadius,
double aOrient,
740 if( aTraceMode ==
FILLED )
744 size.x = std::max( size.x, 0);
746 size.y = std::max( size.y, 0);
749 aCornerRadius = std::min( aCornerRadius, std::min( size.x, size.y ) /2 );
756 std::vector<wxPoint> cornerList;
760 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
761 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
763 if( cornerList.back() != cornerList.front() )
764 cornerList.push_back( cornerList.front() );
773 std::vector< wxPoint > cornerList;
775 for(
int cnt = 0; cnt < aPolygons->
OutlineCount(); ++cnt )
782 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
783 cornerList.emplace_back( poly.
CPoint( ii ).
x, poly.
CPoint( ii ).
y );
785 if( cornerList.back() != cornerList.front() )
786 cornerList.push_back( cornerList.front() );
794 double aPadOrient,
OUTLINE_MODE aTraceMode,
void* aData )
796 std::vector< wxPoint > cornerList;
797 cornerList.reserve( 5 );
799 for(
int ii = 0; ii < 4; ii++ )
801 wxPoint coord( aCorners[ii] );
804 cornerList.push_back( coord );
808 cornerList.push_back( cornerList.front() );
859 if( items.size() < 2 )
864 std::list<HPGL_ITEM> target;
887 target.emplace_back( last_item );
889 while( !items.empty() )
891 auto best_it = items.begin();
894 for(
auto search_it = best_it; search_it != items.end(); search_it++ )
897 if( best_it->pen != last_item.
pen && search_it->pen == last_item.
pen )
905 if( dist < best_dist )
913 target.emplace_back( *best_it );
914 last_item = *best_it;
915 items.erase( best_it );
918 items.splice( items.begin(), target );
945 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.
void flushItem()
Flush the current HPGL_ITEM and clear out the current item pointer.
BOX2D bbox
Bounding box of this item.
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)
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
Return the number of points (vertices) in this line chain.
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Draw a polygon ( filled or not ).
virtual bool StartPlot() override
At the start of the HPGL plot pen speed and number are requested.
static double dpoint_dist(const DPOINT &a, const DPOINT &b)
Compute the distance between two DPOINT points.
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.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
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
bool startOrAppendItem(const DPOINT &location, const wxString &content)
Start a new HPGL_ITEM with the given string if necessary, or append the string to the current item.
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[]
const wxSize & GetSizeMils() const
virtual void PenTo(const wxPoint &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
virtual DPOINT userToDeviceSize(const wxSize &size)
Modify 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 DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modify 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.
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
bool startItem(const DPOINT &location)
Start a new HPGL_ITEM if necessary, keeping the current one if it exists.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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.
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
HPGL doesn't handle line thickness or color.
virtual void Arc(const wxPoint ¢re, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Plot an arc.