113 wxFAIL_MSG(
"Unhandled LINE_STYLE" );
124 int( aColor.
g * 255 ),
125 int( aColor.
b * 255 ) );
137 case DXF_UNITS::MILLIMETERS:
142 case DXF_UNITS::INCHES:
158 buf = fmt::format(
"{:.16f}", aValue );
161 while( !buf.empty() && buf[buf.size() - 1] ==
'0' )
171 double aScale,
bool aMirror )
255 "Dash Dot ____ _ ____ _\n"
279 "Dashed __ __ __ __ __\n"
323 static const char *style_name[4] = {
"KICAD",
"KICADB",
"KICADI",
"KICADBI"};
324 for(
int i = 0; i < 4; i++ )
377 for(
EDA_COLOR_T i =
BLACK; i < numLayers; i = static_cast<EDA_COLOR_T>(
int( i ) + 1 ) )
426 || (
color == COLOR4D::BLACK )
427 || (
color == COLOR4D::WHITE ) )
456 fprintf(
m_outputFile,
"0\nPOINT\n8\n%s\n10\n%s\n20\n%s\n",
474 if( fill == FILL_T::NO_FILL )
476 fprintf(
m_outputFile,
"0\nCIRCLE\n8\n%s\n10\n%s\n20\n%s\n40\n%s\n",
482 else if( fill == FILL_T::FILLED_SHAPE )
484 double r = radius * 0.5;
504 fprintf(
m_outputFile,
"0\nPOINT\n8\n%s\n10\n%s\n20\n%s\n",
515 if( aCornerList.size() <= 1 )
518 unsigned last = aCornerList.size() - 1;
525 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
526 LineTo( aCornerList[ii] );
529 if( aFill != FILL_T::NO_FILL )
531 if( aCornerList[last] != aCornerList[0] )
542 if( aWidth > 0 && aFill == FILL_T::NO_FILL )
546 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
561 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
568 for(
unsigned ii = 0; ii < aCornerList.size(); ii++ )
570 bufferPolybase.
Append( aCornerList[ii] );
585 if(
path.PointCount() < 2 )
589 last =
path.PointCount() - 1;
595 for(
int ii = 1; ii <
path.PointCount(); ii++ )
597 point =
path.CPoint( ii );
602 point =
path.CPoint( last );
605 if( endPoint != startPoint )
631 fprintf(
m_outputFile,
"0\nLINE\n8\n%s\n6\n%s\n10\n%s\n20\n%s\n11\n%s\n21\n%s\n",
645 wxASSERT( aLineStyle >= LINE_STYLE::FIRST_TYPE
646 && aLineStyle <= LINE_STYLE::LAST_TYPE );
657 std::vector<VECTOR2I> cornerList;
663 cornerList.reserve(
path.PointCount() );
665 for(
int jj = 0; jj <
path.PointCount(); jj++ )
666 cornerList.emplace_back(
path.CPoint( jj ).x,
path.CPoint( jj ).y );
669 if( cornerList[0] != cornerList[cornerList.size() - 1] )
670 cornerList.push_back( cornerList[0] );
672 PlotPoly( cornerList, FILL_T::NO_FILL );
691 EDA_ANGLE endAngle = startAngle - aAngle;
695 if( endAngle < startAngle )
696 std::swap( startAngle, endAngle );
704 "0\nARC\n8\n%s\n10\n%s\n20\n%s\n40\n%s\n50\n%.8f\n51\n%.8f\n",
723 if( size.
x > size.
y )
725 std::swap( size.
x, size.
y );
737 Circle( pos, diametre, FILL_T::NO_FILL );
748 size.
x = aPadSize.
x / 2;
749 size.
y = aPadSize.
y / 2;
801 int aCornerRadius,
const EDA_ANGLE& aOrient,
813 for(
int ii = 1; ii < poly.
PointCount(); ++ii )
823 for(
int cnt = 0; cnt < aPolygons->
OutlineCount(); ++cnt )
829 for(
int ii = 1; ii < poly.
PointCount(); ++ii )
844 for(
int ii = 0; ii < 4; ii++ )
846 coord[ii] = aCorners[ii];
848 coord[ii] += aPadPos;
878 for(
unsigned i = 0; i <
string.length(); i++ )
880 wchar_t ch =
string[i];
891 const wxString& aText,
899 bool aMultilineAllowed,
905 if( aMultilineAllowed && !aText.Contains( wxT(
"\n" ) ) )
906 aMultilineAllowed =
false;
908 bool processSuperSub = aText.Contains( wxT(
"^{" ) ) || aText.Contains( wxT(
"_{" ) );
915 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
916 aBold, aMultilineAllowed, aFont, aFontMetrics, aData );
936 const wxString& aText,
944 if( attrs.
m_Multiline && !aText.Contains( wxT(
"\n" ) ) )
947 bool processSuperSub = aText.Contains( wxT(
"^{" ) ) || aText.Contains( wxT(
"_{" ) );
954 PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aFontMetrics, aData );
971 int h_code = 0, v_code = 0;
979 wxFAIL_MSG( wxT(
"Indeterminate state legal only in dialogs." ) );
989 wxFAIL_MSG( wxT(
"Indeterminate state legal only in dialogs." ) );
1025 aAttributes.
m_Bold ? ( aAttributes.
m_Italic ?
"KICADBI" :
"KICADB" )
1026 : ( aAttributes.
m_Italic ?
"KICADI" :
"KICAD" ),
1058 int braceNesting = 0;
1059 int overbarDepth = -1;
1063 for(
unsigned int i = 0; i < aText.length(); i++ )
1071 wchar_t ch = aText[i];
1080 if( aText[i] ==
'~' && i+1 < aText.length() && aText[i+1] ==
'{' )
1083 overbarDepth = braceNesting;
1089 else if( aText[i] ==
'{' )
1093 else if( aText[i] ==
'}' )
1095 if( braceNesting > 0 )
1098 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 std::string formatCoord(double aValue)
bool containsNonAsciiChars(const wxString &string)
Check if a given string contains non-ASCII characters.
static const char * getDXFLineType(LINE_STYLE aType)
static const struct @16 dxf_layer[NBCOLORS]
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData) override
void plotOneLineOfText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttrs)
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 PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
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 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.
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
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
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 SetColor(const COLOR4D &color) override
The DXF exporter handles 'colors' as layers...
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF rectangle: fill not supported.
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, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
double m_unitScalingFactor
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
LINE_STYLE m_currentLineType
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 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')
bool GetColorMode() const
FILE * m_outputFile
Output file.
void LineTo(const VECTOR2I &pos)
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont=nullptr, const KIFONT::METRICS &aFontMetrics=KIFONT::METRICS::Default(), void *aData=nullptr)
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, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Draw text with the plotter.
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.
LINE_STYLE
Dashed line types.
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_INDETERMINATE
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I