Eeschema: Adding dashed line support to DXF plot

NEW: Dashed, dotted and dash-dot line support to DXF plot
in eeschema.
This commit is contained in:
Seth Hillbrand 2017-11-13 09:29:49 -08:00 committed by jean-pierre charras
parent 7c0a7f9f7b
commit 13ef1a911f
2 changed files with 89 additions and 8 deletions

View File

@ -94,6 +94,19 @@ static const struct
{ "YELLOW4", 2 }
};
/**
* Line types in the boilerplate DXF header. The
* element indices correspond to the eeschema line
* types.
*/
static const char *dxf_lines[] =
{
[ PLOTDASHTYPE_SOLID ] = "CONTINUOUS",
[ PLOTDASHTYPE_DASH ] = "DASHED",
[ PLOTDASHTYPE_DOT ] = "DOTTED",
[ PLOTDASHTYPE_DASHDOT ] = "DASHDOT"
};
// A helper function to create a color name acceptable in DXF files
// DXF files do not use a RGB definition
@ -144,7 +157,7 @@ bool DXF_PLOTTER::StartPlot()
// DXF HEADER - Boilerplate
// Defines the minimum for drawing i.e. the angle system and the
// continuous linetype
// 4 linetypes (CONTINUOUS, DOTDASH, DASHED and DOTTED)
fputs( " 0\n"
"SECTION\n"
" 2\n"
@ -172,9 +185,11 @@ bool DXF_PLOTTER::StartPlot()
" 2\n"
"LTYPE\n"
" 70\n"
"1\n"
"4\n"
" 0\n"
"LTYPE\n"
" 5\n"
"40F\n"
" 2\n"
"CONTINUOUS\n"
" 70\n"
@ -188,6 +203,70 @@ bool DXF_PLOTTER::StartPlot()
" 40\n"
"0.0\n"
" 0\n"
"LTYPE\n"
" 5\n"
"410\n"
" 2\n"
"DASHDOT\n"
" 70\n"
"0\n"
" 3\n"
"Dash Dot ____ _ ____ _\n"
" 72\n"
"65\n"
" 73\n"
"4\n"
" 40\n"
"2.0\n"
" 49\n"
"1.25\n"
" 49\n"
"-0.25\n"
" 49\n"
"0.25\n"
" 49\n"
"-0.25\n"
" 0\n"
"LTYPE\n"
" 5\n"
"411\n"
" 2\n"
"DASHED\n"
" 70\n"
"0\n"
" 3\n"
"Dashed __ __ __ __ __\n"
" 72\n"
"65\n"
" 73\n"
"2\n"
" 40\n"
"0.75\n"
" 49\n"
"0.5\n"
" 49\n"
"-0.25\n"
" 0\n"
"LTYPE\n"
" 5\n"
"43B\n"
" 2\n"
"DOTTED\n"
" 70\n"
"0\n"
" 3\n"
"Dotted . . . .\n"
" 72\n"
"65\n"
" 73\n"
"2\n"
" 40\n"
"0.2\n"
" 49\n"
"0.0\n"
" 49\n"
"-0.2\n"
" 0\n"
"ENDTAB\n",
outputFile );
@ -483,22 +562,22 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
if( penLastpos != pos && plume == 'D' )
{
wxASSERT( m_currentLineType >= 0 && m_currentLineType < 4 );
// DXF LINE
wxString cname = getDXFColorName( m_currentColor );
fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
TO_UTF8( cname ),
const char *lname = dxf_lines[ m_currentLineType ];
fprintf( outputFile, "0\nLINE\n8\n%s\n6\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
TO_UTF8( cname ), lname,
pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
}
penLastpos = pos;
}
/**
* Dashed lines are not (yet) supported by DXF_PLOTTER
*/
void DXF_PLOTTER::SetDash( int dashed )
{
// NOP for now
wxASSERT( dashed >= 0 && dashed < 4 );
m_currentLineType = dashed;
}

View File

@ -1224,6 +1224,7 @@ public:
{
textAsLines = true;
m_currentColor = COLOR4D::BLACK;
m_currentLineType = 0;
}
virtual PlotFormat GetPlotterType() const override
@ -1309,6 +1310,7 @@ public:
protected:
bool textAsLines;
COLOR4D m_currentColor;
int m_currentLineType;
};
class TITLE_BLOCK;