110 wxFAIL_MSG(
"Unhandled PLOT_DASH_TYPE" );
121 int( aColor.
g * 255 ),
122 int( aColor.
b * 255 ) );
153 double aScale,
bool aMirror )
239 "Dash Dot ____ _ ____ _\n" 263 "Dashed __ __ __ __ __\n" 307 static const char *style_name[4] = {
"KICAD",
"KICADB",
"KICADI",
"KICADBI"};
308 for(
int i = 0; i < 4; i++ )
339 numLayers = static_cast<EDA_COLOR_T>( 1 );
361 for(
EDA_COLOR_T i =
BLACK; i < numLayers; i = static_cast<EDA_COLOR_T>(
int( i ) + 1 ) )
431 LineTo( wxPoint( p1.x, p2.y ) );
432 LineTo( wxPoint( p2.x, p2.y ) );
433 LineTo( wxPoint( p2.x, p1.y ) );
455 fprintf(
m_outputFile,
"0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
457 centre_dev.
x, centre_dev.
y, radius );
462 double r = radius*0.5;
465 fprintf(
m_outputFile,
"40\n%g\n41\n%g\n", radius, radius);
468 centre_dev.
x-r, centre_dev.
y );
471 centre_dev.
x+r, centre_dev.
y );
485 FILL_TYPE aFill,
int aWidth,
void * aData )
487 if( aCornerList.size() <= 1 )
490 unsigned last = aCornerList.size() - 1;
497 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
498 LineTo( aCornerList[ii] );
503 if( aCornerList[last] != aCornerList[0] )
519 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
535 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
542 for(
unsigned ii = 0; ii < aCornerList.size(); ii++ )
544 bufferPolybase.
Append( aCornerList[ii] );
566 wxPoint startPoint( point.
x, point.
y );
569 for(
int ii = 1; ii < path.
PointCount(); ii++ )
571 point = path.
CPoint( ii );
572 LineTo( wxPoint( point.
x, point.
y ) );
576 point = path.
CPoint( last );
577 wxPoint endPoint( point.
x, point.
y );
579 if( endPoint != startPoint )
604 fprintf(
m_outputFile,
"0\nLINE\n8\n%s\n6\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
606 pen_lastpos_dev.
x, pen_lastpos_dev.
y, pos_dev.
x, pos_dev.
y );
624 std::vector<wxPoint> cornerList;
631 for(
int jj = 0; jj < path.
PointCount(); jj++ )
632 cornerList.emplace_back( path.
CPoint( jj ).
x, path.
CPoint( jj ).
y );
635 if( cornerList[0] != cornerList[cornerList.size() - 1] )
636 cornerList.push_back( cornerList[0] );
661 if( StAngle > EndAngle )
663 std::swap( StAngle, EndAngle );
672 "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
674 centre_dev.
x, centre_dev.
y, radius_dev,
675 StAngle / 10.0, EndAngle / 10.0 );
685 wxSize size( aSize );
689 if( size.x > size.y )
691 std::swap( size.x, size.y );
721 size.x = padsize.x / 2;
722 size.y = padsize.y / 2;
738 MoveTo( wxPoint( ox, oy ) );
750 MoveTo( wxPoint( ox, oy ) );
758 MoveTo( wxPoint( ox, oy ) );
763 LineTo( wxPoint( fx, fy ) );
768 LineTo( wxPoint( fx, fy ) );
773 LineTo( wxPoint( fx, fy ) );
779 int aCornerRadius,
double aOrient,
791 for(
int ii = 1; ii < poly.
PointCount(); ++ii )
801 for(
int cnt = 0; cnt < aPolygons->
OutlineCount(); ++cnt )
807 for(
int ii = 1; ii < poly.
PointCount(); ++ii )
819 double aPadOrient,
OUTLINE_MODE aTrace_Mode,
void* aData )
824 for(
int ii = 0; ii < 4; ii++ )
826 coord[ii] = aCorners[ii];
828 coord[ii] += aPadPos;
841 int aRadius,
int aCornerCount,
859 for(
unsigned i = 0; i <
string.length(); i++ )
861 wchar_t ch =
string[i];
870 const wxString& aText,
878 bool aMultilineAllowed,
882 if( aMultilineAllowed && !aText.Contains( wxT(
"\n" ) ) )
883 aMultilineAllowed =
false;
885 bool processSuperSub = aText.Contains( wxT(
"^{" ) ) || aText.Contains( wxT(
"_{" ) );
892 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
893 aWidth, aItalic, aBold, aMultilineAllowed );
903 int h_code = 0, v_code = 0;
961 aBold ? (aItalic ?
"KICADBI" :
"KICADB")
962 : (aItalic ?
"KICADI" :
"KICAD"),
964 origin_dev.
x, origin_dev.
x,
965 origin_dev.
y, origin_dev.
y,
966 size_dev.
y, fabs( size_dev.
x / size_dev.
y ),
969 size_dev.
x < 0 ? 2 : 0,
994 bool overlining =
false;
998 for(
unsigned i = 0; i < aText.length(); i++ )
1006 wchar_t ch = aText[i];
1017 if( ++i == aText.length() )
1034 overlining = !overlining;
1037 else if( ch ==
' ' || ch ==
'}' || ch ==
')' )
void FinishTo(const wxPoint &pos)
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_TYPE aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=NULL) override
DXF polygon: doesn't fill it but at least it close the filled ones DXF does not know thick outline.
double m_unitScalingFactor
int OutlineCount() const
Return the number of vertices in a given outline/hole.
virtual void FlashPadRect(const wxPoint &pos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
DXF rectangular pad: alwayd done in sketch mode.
FILL_TYPE
The set of fill types used in plotting or drawing enclosed areas.
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL) override
Draws text with the plotter.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
Plotting engines (PostScript, Gerber, HPGL and DXF)
unsigned int m_measurementDirective
virtual void SetDash(PLOT_DASH_TYPE dashed) override
virtual void SetViewport(const wxPoint &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot The DXF engine doesn't support line widths and mirroring.
bool containsNonAsciiChars(const wxString &string)
Checks if a given string contains non-ASCII characters.
static wxString getDXFColorName(COLOR4D aColor)
virtual void FlashPadCircle(const wxPoint &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 FlashRegularPolygon(const wxPoint &aShapePos, int aDiameter, int aCornerCount, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
Flash a regular polygon.
FILE * m_outputFile
Output file.
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...
virtual void PenTo(const wxPoint &pos, char plume) override
moveto/lineto primitive, moves the 'pen' to the specified direction
void SetUnits(DXF_UNITS aUnit)
Set the units to use for plotting the DXF file.
void RotatePoint(int *pX, int *pY, double angle)
int PointCount() const
Function PointCount()
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.
virtual void FlashPadOval(const wxPoint &pos, const wxSize &size, double orient, OUTLINE_MODE trace_mode, void *aData) override
DXF oval pad: always done in sketch mode.
This file contains miscellaneous commonly used macros and functions.
double GetUnitScaling() const
Get the scale factor to apply to convert the device units to be in the currently set units.
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSeg...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
static const double DXF_OBLIQUE_ANGLE
Oblique angle for DXF native text (I don't remember if 15 degrees is the ISO value....
void LineTo(const wxPoint &pos)
virtual void FlashPadCustom(const wxPoint &aPadPos, const wxSize &aSize, double aOrient, SHAPE_POLY_SET *aPolygons, OUTLINE_MODE aTraceMode, void *aData) override
virtual bool StartPlot() override
Opens the DXF plot with a skeleton header.
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)
static const struct @8 dxf_layer[NBCOLORS]
Base window classes and related definitions.
virtual void FlashPadTrapez(const wxPoint &aPadPos, const wxPoint *aCorners, double aPadOrient, OUTLINE_MODE aTraceMode, void *aData) override
DXF trapezoidal pad: only sketch mode is supported.
virtual bool EndPlot() override
virtual DPOINT userToDeviceSize(const wxSize &size)
Modifies size according to the plotter scale factors (wxSize version, returns a DPOINT)
int NewOutline()
Creates a new hole in a given outline.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
EDA_COLOR_T
Legacy color enumeration.
PLOT_DASH_TYPE
Dashed line types.
void MoveTo(const wxPoint &pos)
virtual DPOINT userToDeviceCoordinates(const wxPoint &aCoordinate)
Modifies coordinates according to the orientation, scale factor, and offsets trace.
static const char * getDXFLineType(PLOT_DASH_TYPE aType)
unsigned int GetMeasurementDirective() const
Get the correct value for the $MEASUREMENT field given the current units.
virtual void Circle(const wxPoint &pos, int diametre, FILL_TYPE 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...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
PLOT_DASH_TYPE m_currentLineType
virtual void SetColor(COLOR4D color) override
The DXF exporter handles 'colors' as layers...
int GetPlotterArcHighDef() const
virtual void ThickSegment(const wxPoint &start, const wxPoint &end, int width, OUTLINE_MODE tracemode, void *aData) override
void sketchOval(const wxPoint &pos, const wxSize &size, double orient, int width)
virtual void FlashPadRoundRect(const wxPoint &aPadPos, const wxSize &aSize, int aCornerRadius, double aOrient, OUTLINE_MODE aTraceMode, void *aData) override
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH) override
DXF rectangle: fill not supported.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
A color representation with 4 components: red, green, blue, alpha.
bool GetColorMode() const