112 wxFAIL_MSG(
"Unhandled PLOT_DASH_TYPE" );
123 int( aColor.
g * 255 ),
124 int( aColor.
b * 255 ) );
136 case DXF_UNITS::MILLIMETERS:
141 case DXF_UNITS::INCHES:
150 double aScale,
bool aMirror )
234 "Dash Dot ____ _ ____ _\n"
258 "Dashed __ __ __ __ __\n"
302 static const char *style_name[4] = {
"KICAD",
"KICADB",
"KICADI",
"KICADBI"};
303 for(
int i = 0; i < 4; i++ )
356 for(
EDA_COLOR_T i =
BLACK; i < numLayers; i = static_cast<EDA_COLOR_T>(
int( i ) + 1 ) )
405 || (
color == COLOR4D::BLACK )
406 || (
color == COLOR4D::WHITE ) )
438 if( fill == FILL_T::NO_FILL )
440 fprintf(
m_outputFile,
"0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
442 centre_dev.
x, centre_dev.
y, radius );
444 else if( fill == FILL_T::FILLED_SHAPE )
446 double r = radius*0.5;
449 fprintf(
m_outputFile,
"40\n%g\n41\n%g\n", radius, radius);
452 centre_dev.
x-r, centre_dev.
y );
455 centre_dev.
x+r, centre_dev.
y );
465 if( aCornerList.size() <= 1 )
468 unsigned last = aCornerList.size() - 1;
475 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
476 LineTo( aCornerList[ii] );
479 if( aFill != FILL_T::NO_FILL )
481 if( aCornerList[last] != aCornerList[0] )
492 if( aWidth > 0 && aFill == FILL_T::NO_FILL )
496 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
511 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
518 for(
unsigned ii = 0; ii < aCornerList.size(); ii++ )
520 bufferPolybase.
Append( aCornerList[ii] );
535 if(
path.PointCount() < 2 )
539 last =
path.PointCount() - 1;
545 for(
int ii = 1; ii <
path.PointCount(); ii++ )
547 point =
path.CPoint( ii );
552 point =
path.CPoint( last );
555 if( endPoint != startPoint )
581 fprintf(
m_outputFile,
"0\nLINE\n8\n%s\n6\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
583 pen_lastpos_dev.
x, pen_lastpos_dev.
y, pos_dev.
x, pos_dev.
y );
592 wxASSERT( aLineStyle >= PLOT_DASH_TYPE::FIRST_TYPE
593 && aLineStyle <= PLOT_DASH_TYPE::LAST_TYPE );
604 std::vector<VECTOR2I> cornerList;
610 cornerList.reserve(
path.PointCount() );
612 for(
int jj = 0; jj <
path.PointCount(); jj++ )
613 cornerList.emplace_back(
path.CPoint( jj ).x,
path.CPoint( jj ).y );
616 if( cornerList[0] != cornerList[cornerList.size() - 1] )
617 cornerList.push_back( cornerList[0] );
619 PlotPoly( cornerList, FILL_T::NO_FILL );
642 if( startAngle > endAngle )
643 std::swap( startAngle, endAngle );
651 "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
653 centre_device.
x, centre_device.
y, radius_device,
668 if( size.
x > size.
y )
670 std::swap( size.
x, size.
y );
682 Circle( pos, diametre, FILL_T::NO_FILL );
693 size.
x = aPadSize.
x / 2;
694 size.
y = aPadSize.
y / 2;
746 int aCornerRadius,
const EDA_ANGLE& aOrient,
758 for(
int ii = 1; ii < poly.
PointCount(); ++ii )
768 for(
int cnt = 0; cnt < aPolygons->
OutlineCount(); ++cnt )
774 for(
int ii = 1; ii < poly.
PointCount(); ++ii )
789 for(
int ii = 0; ii < 4; ii++ )
791 coord[ii] = aCorners[ii];
793 coord[ii] += aPadPos;
823 for(
unsigned i = 0; i <
string.length(); i++ )
825 wchar_t ch =
string[i];
836 const wxString& aText,
844 bool aMultilineAllowed,
849 if( aMultilineAllowed && !aText.Contains( wxT(
"\n" ) ) )
850 aMultilineAllowed =
false;
852 bool processSuperSub = aText.Contains( wxT(
"^{" ) ) || aText.Contains( wxT(
"_{" ) );
859 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
860 aBold, aMultilineAllowed, aFont, aData );
879 const wxString& aText,
886 if( attrs.
m_Multiline && !aText.Contains( wxT(
"\n" ) ) )
889 bool processSuperSub = aText.Contains( wxT(
"^{" ) ) || aText.Contains( wxT(
"_{" ) );
903 const wxString& aText,
912 int h_code = 0, v_code = 0;
961 (aAttributes.
m_Italic ?
"KICADBI" :
"KICADB")
963 origin_dev.
x, origin_dev.
x,
964 origin_dev.
y, origin_dev.
y,
965 size_dev.
y, fabs( size_dev.
x / size_dev.
y ),
993 int braceNesting = 0;
994 int overbarDepth = -1;
998 for(
unsigned int i = 0; i < aText.length(); i++ )
1006 wchar_t ch = aText[i];
1015 if( aText[i] ==
'~' && i+1 < aText.length() && aText[i+1] ==
'{' )
1018 overbarDepth = braceNesting;
1024 else if( aText[i] ==
'{' )
1028 else if( aText[i] ==
'}' )
1030 if( braceNesting > 0 )
1033 if( braceNesting == overbarDepth )
static wxString getDXFColorName(const COLOR4D &aColor)
static const double DXF_OBLIQUE_ANGLE
Oblique angle for DXF native text (I don't remember if 15 degrees is the ISO value....
static const char * getDXFLineType(PLOT_DASH_TYPE aType)
bool containsNonAsciiChars(const wxString &string)
Check if a given string contains non-ASCII characters.
static const struct @8 dxf_layer[NBCOLORS]
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
virtual void FlashPadCircle(const VECTOR2I &pos, int diametre, OUTLINE_MODE trace_mode, void *aData) override
DXF round pad: always done in sketch mode; it could be filled but it isn't pretty if other kinds of p...
virtual void FlashPadRect(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 Arc(const VECTOR2I &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, int aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
Generic fallback: arc rendered as a polyline.
virtual void FlashPadCustom(const VECTOR2I &aPadPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
virtual void FlashPadTrapez(const VECTOR2I &aPadPos, const VECTOR2I *aCorners, const EDA_ANGLE &aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF trapezoidal pad: only sketch mode is supported.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot.
double GetUnitScaling() const
Get the scale factor to apply to convert the device units to be in the currently set units.
virtual void FlashRegularPolygon(const VECTOR2I &aShapePos, int aDiameter, int aCornerCount, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a regular polygon.
virtual void FlashPadOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF oval pad: always done in sketch mode.
virtual void FlashPadRoundRect(const VECTOR2I &aPadPos, const VECTOR2I &aSize, int aCornerRadius, const EDA_ANGLE &aOrient, OUTLINE_MODE aTraceMode, void *aData) override
PLOT_DASH_TYPE m_currentLineType
virtual void SetDash(int aLineWidth, PLOT_DASH_TYPE aLineStyle) override
virtual bool StartPlot(const wxString &aPageNumber) override
Open the DXF plot with a skeleton header.
unsigned int GetMeasurementDirective() const
Get the correct value for the $MEASUREMENT field given the current units.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF circle: full functionality; it even does 'fills' drawing a circle with a dual-arc polyline wide a...
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
DXF polygon: doesn't fill it but at least it close the filled ones DXF does not know thick outline.
unsigned int m_measurementDirective
virtual bool EndPlot() override
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr) override
virtual void SetColor(const COLOR4D &color) override
The DXF exporter handles 'colors' as layers...
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, KIFONT::FONT *aFont=nullptr, void *aData=nullptr) override
Draw text with the plotter.
void plotOneLineOfText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes)
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF rectangle: fill not supported.
double m_unitScalingFactor
FONT is an abstract base class for both outline and stroke fonts.
A color representation with 4 components: red, green, blue, alpha.
static EDA_COLOR_T FindNearestLegacyColor(int aR, int aG, int aB)
Returns a legacy color ID that is closest to the given 8-bit RGB values.
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
void sketchOval(const VECTOR2I &aPos, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, int aWidth)
int GetPlotterArcHighDef() const
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
bool GetColorMode() const
FILE * m_outputFile
Output file.
void LineTo(const VECTOR2I &pos)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union For aFastMode meaning, see function booleanOp.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
EDA_COLOR_T
Legacy color enumeration.
@ NBCOLORS
Number of colors.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &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.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
static constexpr EDA_ANGLE & ANGLE_90
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
PLOT_DASH_TYPE
Dashed line types.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)